CLI Workflow
A detailed guide to the NestForge CLI, including generators, DB commands, and utility commands.
CLI command families
Section titled “CLI command families”The NestForge CLI currently groups its workflow into four areas:
newfor scaffolding a fresh appgorgeneratefor adding code to an existing appdbfor migration-oriented database workflowsdocsandfmtfor project maintenance
Scaffold a new app
Section titled “Scaffold a new app”Base syntax:
nestforge new <app-name>nestforge new <app-name> --transport <http|graphql|grpc|microservices|websockets>What the transport flag changes:
http: classic controller-first applicationgraphql: schema-first bootstrap with GraphiQL supportgrpc: tonic-oriented transport setup withproto/andbuild.rsmicroservices: pattern registry plus in-process client examplewebsockets: gateway-first bootstrap andsrc/ws/
Generate application code
Section titled “Generate application code”Generators are designed to work inside an application folder containing Cargo.toml
and src/.
Core generators:
nestforge g module usersnestforge g resource usersnestforge g controller usersnestforge g service usersCross-cutting generators:
nestforge g guard authnestforge g decorator correlation_idnestforge g filter rewrite_bad_requestnestforge g middleware auditnestforge g interceptor loggingnestforge g serializer userTransport-specific generators:
nestforge g graphql usersnestforge g grpc billingnestforge g gateway eventsnestforge g microservice usersTarget a feature module
Section titled “Target a feature module”To generate inside a feature boundary instead of at the app root:
nestforge g resource users --module usersThe CLI will:
- verify the feature module exists
- write DTO, service, and controller files under
src/users/ - patch the module exports, providers, and controller wiring
Database commands
Section titled “Database commands”The CLI includes a lightweight migration workflow.
nestforge db initnestforge db generate create_users_tablenestforge db migratenestforge db statusBehavior to know:
initcreatesmigrations/and.nestforge/applied_migrations.txtgeneratecreates a timestamped SQL filemigratereadsDATABASE_URLand applies pending filesstatuscompares migration files with recorded state and reports drift
Utility commands
Section titled “Utility commands”nestforge docsnestforge fmtdocscreates adocs/openapi.jsonskeleton in the current appfmtrunscargo fmtin the app root
Practical advice
Section titled “Practical advice”Use the CLI to accelerate structure, not to avoid understanding the output. After each generation step, inspect the generated code and make sure:
- module wiring is correct
- feature flags in
Cargo.tomlmatch the transport or runtime you want .envdefaults match your local environment- generated stubs are replaced with application-specific logic before production use