What it does
spraxium generate creates a new source file from a named schematic and wires it into the correct module. The command accepts the schematic name and the file name as arguments; if either is omitted, an interactive selector appears. All generated class names are normalized to PascalCase and file names to kebab-case, so you never need to worry about naming conventions by hand.
spraxium generate [schematic] [name]
# alias:
spraxium g [schematic] [name]This command is most valuable when you want speed without losing project consistency. Instead of manually creating a file, choosing a folder, adding decorators, and then remembering to register the class in a module, you let the CLI produce a framework-aligned starting point in one step.
When to use generate instead of writing files by hand
Use spraxium generate when the file you need already matches a known framework pattern: services, listeners, handlers, guards, tasks, commands, and module scaffolds. It is especially useful early in a project, when naming drift and forgotten registrations are common.
Writing files manually still makes sense when you are building something intentionally custom, heavily refactoring an existing module, or creating a file type that does not map to a supported schematic. The CLI is there to remove repetitive setup, not to replace judgment.
How generation works
Resolve schematic
The CLI reads the schematic argument or, if missing, presents an interactive
list of all 19 available schematics. Aliases are accepted anywhere a full
name is accepted, so g sc ping is equivalent to g slash-command ping.
Normalize the name
The provided name is split on hyphens and underscores, normalized to
PascalCase for the class name, and to kebab-case for the file name. A name
like auction-bid becomes AuctionBidService in the class and
auction-bid.service.ts as the file.
Select target module
For all schematics that live inside a module, the CLI scans src/modules/
and presents a prompt listing the detected modules. Select the one that
should own the new file. Only the module schematic itself skips this step.
Write the file
The CLI writes the generated file into the correct subfolder under the
chosen module, following the standard layout (services/, tasks/,
listeners/, etc.).
Auto-register in the module
When the schematic supports it, the CLI injects the import statement and the
class name into the correct array inside the target module's @Module
decorator: providers, listeners, controllers, or imports.
All schematics
Core structure
Event handling
Slash commands
Prefix commands
HTTP
Components
Security
Scheduling
Name validation
The CLI blocks repeated suffix patterns to prevent redundant file names. Passing invoice-service to the service schematic is rejected because the suffix is already implied by the schematic type. Use just invoice and the CLI appends the correct suffix automatically.
This is a small detail, but it keeps large projects cleaner. You avoid file names like invoice-service.service.ts and class names like InvoiceServiceService, which are easy to create by accident when generation is entirely manual.
Practical selection advice
If you are unsure which schematic to choose, focus on the runtime role of the file:
- Business logic reused by many entry points: choose service.
- A Discord event boundary: choose listener.
- A slash or prefix command definition: choose the matching command schematic.
- The runtime logic for an interaction or command: choose the matching handler schematic.
- Access control or policy checks: choose guard.
- Background execution on a timer: choose a scheduling schematic.
That rule of thumb is usually enough to pick the right scaffold without memorizing every alias.
Practical examples
# create a new domain module
spraxium g module billing
# create a service inside a module (prompted)
spraxium g service invoice
# create a slash command and its handler
spraxium g slash-command ping
spraxium g slash-handler ping
# create an interval task
spraxium g interval-task presence-cycleWhat generate does not do
Generation gives you the file, decorator shape, and module registration when supported. It does not finish the feature for you. You still need to add business logic, fill in configuration, wire dependencies, and decide whether the generated structure matches the final design of the module.