
Cli
- 2 installs
- 1 repo stars
- Updated January 2, 2026
- ramziddin/ccplugins
Reference for the NestJS CLI: generating controllers, services, and modules, building apps, and managing monorepo workspaces.
About
Covers the NestJS CLI for scaffolding projects and components, building applications, and working with monorepo workspaces. A developer uses it to generate boilerplate or manage NestJS project structure.
- Install globally with npm i -g @nestjs/cli or run via npx
- Generates controllers, services, modules, and libraries
Cli by the numbers
- 2 all-time installs (skills.sh)
- Ranked #3,765 of 4,347 Backend & APIs skills by installs in the Skillselion catalog
- Data as of Aug 4, 2026 (Skillselion catalog sync)
npx skills add https://github.com/ramziddin/ccplugins --skill cliAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 2 |
|---|---|
| repo stars | ★ 1 |
| Last updated | January 2, 2026 |
| Repository | ramziddin/ccplugins ↗ |
What it does
Reference for the NestJS CLI: generating controllers, services, and modules, building apps, and managing monorepo workspaces.
Files
NestJS CLI
When to Use This Skill
Use this skill when:
- Creating new NestJS projects
- Generating controllers, services, modules, and other components
- Building and bundling applications
- Working with monorepo/workspace structures
- Running development servers
- Managing project configuration
- Creating libraries for shared code
What is the NestJS CLI?
The NestJS CLI is a command-line interface tool that helps you initialize, develop, and maintain NestJS applications. It provides generators for components, supports workspaces, and handles build configurations.
Installation
Global Installation
npm install -g @nestjs/cliUsing npx
npx @nestjs/cli new my-projectBasic Commands
Create New Project
nest new project-nameOptions:
--strict- TypeScript strict mode--package-manager [npm|yarn|pnpm]- Package manager to use--language [TS|JS]- Programming language--skip-git- Skip git repository initialization--skip-install- Skip package installation
Example:
nest new my-app --strict --package-manager pnpmGenerate Resources
nest generate <schematic> <name> [options]Aliases:
nest g <schematic> <name>Schematics (Generators)
Application
nest generate application <name>Creates a new application in a monorepo structure.
Module
nest generate module users
nest g mo usersCreates:
users/users.module.ts
Controller
nest generate controller users
nest g co usersCreates:
users/users.controller.tsusers/users.controller.spec.ts
Options:
--no-spec- Skip test file--flat- Don't create a folder
Service
nest generate service users
nest g s usersCreates:
users/users.service.tsusers/users.service.spec.ts
Resource (Complete CRUD)
nest generate resource users
nest g res usersPrompts:
- Transport layer (REST API, GraphQL, Microservice, WebSockets)
- Generate CRUD entry points?
Creates:
- Module
- Controller
- Service
- Entity
- DTOs (create, update)
- Test files
Example output for REST API:
users/
├── dto/
│ ├── create-user.dto.ts
│ └── update-user.dto.ts
├── entities/
│ └── user.entity.ts
├── users.controller.ts
├── users.controller.spec.ts
├── users.module.ts
├── users.service.ts
└── users.service.spec.tsOther Schematics
# Class
nest g class users/dto/create-user
# Interface
nest g interface users/interfaces/user
# Guard
nest g guard auth/guards/jwt
# Interceptor
nest g interceptor common/interceptors/logging
# Pipe
nest g pipe common/pipes/validation
# Filter
nest g filter common/filters/http-exception
# Middleware
nest g middleware common/middleware/logger
# Decorator
nest g decorator auth/decorators/user
# Gateway (WebSocket)
nest g gateway events
# Resolver (GraphQL)
nest g resolver users
# Library
nest g library sharedSchematic Options
Common Options
# Skip test files
nest g service users --no-spec
# Flat structure (no folder)
nest g controller users --flat
# Dry run (preview changes)
nest g module users --dry-run
# Specific path
nest g service users/services/user
# Skip import into module
nest g service users --no-importExample:
nest g resource products --no-spec --flatBuild Commands
Development Build
nest buildCompiles TypeScript to JavaScript in dist/ folder.
Production Build
nest build --webpackOptions:
--watch- Watch mode for development--webpack- Use webpack for bundling--path [path]- Path to tsconfig file--config [path]- Path to nest-cli.json
Watch Mode
nest build --watchAutomatically rebuilds on file changes.
Development Commands
Start Application
nest startBuilds and runs the application.
Development Mode (Watch)
nest start --watchWatches for changes and restarts automatically.
Alias:
npm run start:devDebug Mode
nest start --debugStarts with Node.js inspector for debugging.
Options:
--debug [port]- Debug on specific port (default: 9229)--watch- Watch mode with debugging
Example:
nest start --debug --watchWorkspaces and Monorepo
Create Workspace
nest new my-workspace
cd my-workspace
nest generate app api
nest generate app adminStructure:
my-workspace/
├── apps/
│ ├── api/
│ └── admin/
├── libs/
├── nest-cli.json
└── package.jsonGenerate Library
nest generate library shared
nest g lib commonCreates a shared library in libs/ folder.
Usage in apps:
import { SharedModule } from '@app/shared';Build Specific Application
nest build api
nest build adminStart Specific Application
nest start api
nest start admin --watchProject Configuration
nest-cli.json
{
"$schema": "https://json.schemastore.org/nest-cli",
"collection": "@nestjs/schematics",
"sourceRoot": "src",
"compilerOptions": {
"deleteOutDir": true,
"webpack": true,
"tsConfigPath": "tsconfig.build.json"
},
"generateOptions": {
"spec": false,
"flat": true
}
}Options:
sourceRoot- Source code root directorycompilerOptions.deleteOutDir- Delete output directory before buildcompilerOptions.webpack- Use webpackgenerateOptions.spec- Generate test files by defaultgenerateOptions.flat- Generate without folder
Monorepo Configuration
{
"projects": {
"api": {
"type": "application",
"root": "apps/api",
"entryFile": "main",
"sourceRoot": "apps/api/src",
"compilerOptions": {
"tsConfigPath": "apps/api/tsconfig.app.json"
}
},
"shared": {
"type": "library",
"root": "libs/shared",
"entryFile": "index",
"sourceRoot": "libs/shared/src",
"compilerOptions": {
"tsConfigPath": "libs/shared/tsconfig.lib.json"
}
}
}
}Additional Commands
Info
nest infoDisplays information about:
- Installed packages
- Node.js version
- Operating system
- NestJS CLI version
Example output:
_ _ _ ___ _____ _____ _ _____
| \ | | | | |_ |/ ___|/ __ \| | |_ _|
| \| | ___ ___ | |_ | |\ `--. | / \/| | | |
| . ` | / _ \/ __|| __| | | `--. \| | | | | |
| |\ || __/\__ \| |_ /\__/ //\__/ /| \__/\| |_____| |_
\_| \_/ \___||___/ \__|\____/ \____/ \____/\_____/\___/
[System Information]
OS Version : macOS
NodeJS Version : v18.12.0
NPM Version : 8.19.2
[Nest CLI]
Nest CLI Version : 9.1.5
[Nest Platform Information]
platform-express version : 9.2.0
schematics version : 9.0.3
common version : 9.2.0
core version : 9.2.0Add
nest add @nestjs/swaggerAdds a library with its schematic installation script.
Common libraries:
nest add @nestjs/swagger
nest add @nestjs/graphql
nest add @nestjs/mongoose
nest add @nestjs/typeormComplete Workflow Examples
New REST API Project
# Create project
nest new my-api --strict
# Navigate to project
cd my-api
# Generate a complete resource
nest g resource users
# Generate authentication module
nest g module auth
nest g service auth
nest g controller auth
nest g guard auth/guards/jwt
# Start development server
npm run start:devMonorepo Setup
# Create workspace
nest new my-workspace
# Add applications
cd my-workspace
nest g app api
nest g app admin
# Add shared library
nest g lib database
nest g lib common
# Generate resources in specific app
nest g resource users --project api
nest g resource products --project admin
# Start specific app
nest start api --watchGraphQL Project
# Create project
nest new graphql-api
# Add GraphQL
cd graphql-api
nest add @nestjs/graphql @nestjs/apollo
# Generate GraphQL resources
nest g resource users --type graphql-code-first
nest g resource posts --type graphql-code-first
# Start development
npm run start:devMicroservices Project
# Create workspace
nest new microservices-app
# Generate microservices
cd microservices-app
nest g app auth-service
nest g app user-service
nest g app api-gateway
# Generate shared library
nest g lib shared
# Start services
nest start auth-service --watch
nest start user-service --watch
nest start api-gateway --watchBest Practices
1. Use generators - Don't create files manually, use CLI generators 2. Consistent structure - Let CLI maintain project structure 3. Use workspaces - For microservices or multiple related apps 4. Shared libraries - Extract common code into libraries 5. Configure defaults - Set generateOptions in nest-cli.json 6. Skip specs when needed - Use --no-spec for DTOs and entities 7. Use resource generator - For complete CRUD modules 8. Dry run first - Test generators with --dry-run 9. Version control - Commit nest-cli.json for team consistency 10. Use absolute imports - Configure path aliases for clean imports
CLI Shortcuts
# Shorten commands with aliases
nest g mo users # module
nest g co users # controller
nest g s users # service
nest g res users # resource
nest g gu auth/jwt # guard
nest g in logging # interceptor
nest g pi validation # pipe
nest g fi http-exception # filter
nest g mi logger # middleware
nest g d current-user # decorator
nest g ga events # gateway
nest g r users # resolverCommon Scripts
Add these to package.json:
{
"scripts": {
"start": "nest start",
"start:dev": "nest start --watch",
"start:debug": "nest start --debug --watch",
"start:prod": "node dist/main",
"build": "nest build",
"format": "prettier --write \"src/**/*.ts\"",
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
"test": "jest",
"test:watch": "jest --watch",
"test:cov": "jest --coverage",
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
"test:e2e": "jest --config ./test/jest-e2e.json"
}
}Troubleshooting
CLI Not Found
# Reinstall globally
npm uninstall -g @nestjs/cli
npm install -g @nestjs/cli
# Or use npx
npx @nestjs/cli new my-projectImport Errors in Monorepo
Check tsconfig.json paths:
{
"compilerOptions": {
"paths": {
"@app/shared": ["libs/shared/src"],
"@app/common": ["libs/common/src"]
}
}
}Build Errors
# Clean build
rm -rf dist
nest build
# Check TypeScript version
npm list typescript