sm new feature
Adds a new endpoint to an existing module. The generated endpoint implements IEndpoint and is automatically discovered by the Roslyn source generator -- no manual registration needed.
Usage
sm new feature [name]If you omit required options, the CLI prompts you interactively with selection menus.
Options
| Option | Description |
|---|---|
[name] | Feature name in PascalCase (e.g., UpdateInvoice). Prompted if omitted. |
-m, --module <name> | Target module name. If omitted, presents a selection list of existing modules. |
--method <method> | HTTP method: GET, POST, PUT, or DELETE. Prompted if omitted. |
-r, --route <pattern> | Route pattern (e.g., /{id}). Defaults to /{id} when prompted. |
--validator | Include a request validator class alongside the endpoint. |
What Gets Created
Running sm new feature UpdateInvoice --module Invoices --method PUT --route /{id} --validator generates:
modules/Invoices/src/Invoices/Endpoints/Invoices/
UpdateInvoiceEndpoint.cs # IEndpoint implementation
UpdateInvoiceRequestValidator.cs # Request validator (when --validator is used)Endpoint Auto-Discovery
The generated endpoint implements IEndpoint, which the Roslyn source generator scans at compile time. There is no need to manually register routes -- just build the project and the endpoint is live.
Validator (Optional)
When you pass --validator, the CLI generates a companion validator class that validates the request before the endpoint logic runs.
Interactive Mode
When run without flags, the CLI walks you through each option:
sm new feature
# ? Feature name (PascalCase): UpdateInvoice
# ? Select a module: Invoices
# ? HTTP method: PUT
# ? Route pattern: /{id}
# ? Include a validator? YesRequirements
- Must be run from within a SimpleModule project (the CLI looks for a
.slnxfile) - At least one module must exist. If no modules are found, the CLI directs you to run
sm new modulefirst
View Endpoints
If your feature is a page (view endpoint using Inertia.Render), remember to add a corresponding entry in your module's Pages/index.ts. See the Pages Registry Pattern for details.
Example
# Fully specified
sm new feature CreateInvoice --module Invoices --method POST --route / --validator
# Interactive
sm new featureNext Steps
- Endpoints -- API and view endpoint patterns in detail
- Pages Registry -- register your new page component
- sm doctor -- validate everything is wired correctly