nestjs
Original:🇺🇸 English
Translated
NestJS reference skill: modules, controllers, providers, DTOs with class-validator, TypeORM/Prisma, guards, interceptors, pipes, queues (BullMQ), WebSockets, microservices, testing, OpenAPI, and CLI scaffolding. Use when the task touches NestJS application code and should follow the project's module-based architecture.
12installs
Sourceulpi-io/skills
Added on
NPX Install
npx skill4agent add ulpi-io/skills nestjsTags
Translated version includes tags in frontmatterSKILL.md Content
View Translation Comparison →<EXTREMELY-IMPORTANT>
This skill is a routing shell over the NestJS reference set.
Non-negotiable rules:
- Read first to understand the project's NestJS version, ORM, and locked decisions.
references/stack.md - Then load only the references needed for the actual task.
- One module per domain — controllers, services, DTOs, and entities live together in their module directory.
- Controllers are thin — validate (DTO + pipe), delegate (service), return. No business logic.
- All input validated via DTOs — class-validator decorators on every DTO, globally.
ValidationPipe - Dependency injection everywhere — never . Inject via constructor, provide via module.
new Service() - No circular dependencies — use only as a last resort, prefer restructuring.
forwardRef() - Keep the heavy NestJS guidance in , not inline here. </EXTREMELY-IMPORTANT>
references/
nestjs
Inputs
- : The NestJS module, endpoint, subsystem, or feature being worked on
$request
Goal
Route NestJS work through the project's module-based architecture so implementation follows the established patterns for dependency injection, validation, data access, and request lifecycle.
Step 0: Read the stack contract
Always start with:
references/stack.md
That establishes: NestJS version, ORM (TypeORM/Prisma/Drizzle), package manager, auth strategy, queue system, and locked dependency choices.
Success criteria: The project's NestJS architecture and locked decisions are explicit before implementation starts.
Step 1: Load only the relevant references
Use the routing table to pick reference files. Do not bulk-load the full reference tree.
| Task | Read |
|---|---|
| NestJS version, ORM, key deps, CLI, project layout | |
| Folder conventions, module organization, barrel exports | |
| Creating or editing a module | |
| Controllers, route decorators, request lifecycle | |
| Services, providers, dependency injection | |
| DTOs, class-validator, ValidationPipe, transformation | |
| TypeORM entities, repositories, migrations | |
| Prisma integration with NestJS | |
| Guards, authentication, authorization, JWT, Passport | |
| Interceptors, logging, caching, response mapping | |
| Pipes, custom validation, parameter transformation | |
| Exception filters, custom exceptions, error responses | |
| BullMQ queues, processors, flows | |
| WebSocket gateways, events, rooms | |
| Microservices, transports, message patterns | |
| OpenAPI/Swagger decorators, schema generation | |
| Unit tests, e2e tests, testing module, mocking | |
| Configuration, ConfigModule, env validation | |
| Middleware, lifecycle hooks, shutdown | |
| Logging with pino or built-in logger | |
| Health checks, Terminus | |
| CQRS, events, sagas | |
| Scheduling, cron jobs, intervals | |
| Docker, deployment, production setup | |
Multiple tasks? Read multiple files. The references are self-contained.
Success criteria: Only the task-relevant NestJS conventions are in play.
Step 2: Implement with the core NestJS guardrails
Keep these rules active:
- every module declares its controllers, providers, imports, and exports explicitly
- controllers validate via DTOs + , delegate to services, return typed responses
ValidationPipe - services contain business logic, injected via constructor — never instantiated with
new - entities/models are separate from DTOs — never return a raw entity from a controller
- guards handle auth/authz, interceptors handle cross-cutting concerns, pipes handle transformation
- all external input has a DTO with class-validator decorators
- database mutations wrapped in transactions where atomicity matters
- use with Zod or Joi validation for env vars
@nestjs/config
Success criteria: The change fits the project's NestJS module architecture instead of bypassing the framework.
Step 3: Verify the affected surface
Use the narrowest relevant verification:
- unit tests ()
jest --testPathPattern=<module> - e2e tests ()
jest --config test/jest-e2e.json - type checking ()
tsc --noEmit - linting ()
eslint . - OpenAPI spec regeneration if decorators changed
Success criteria: The changed NestJS surface still builds, type-checks, and passes tests.
Guardrails
- Do not inline the whole NestJS handbook in .
SKILL.md - Do not skip .
references/stack.md - Do not put business logic in controllers — delegate to services.
- Do not return raw entities — use DTOs or serialization interceptors.
- Do not bypass dependency injection — never .
new Service() - Do not create circular module dependencies without exhausting alternatives first.
- Do not use barrel imports for types — import from specific subpaths when possible.
@nestjs/common - Do not add ; this is a normal domain skill.
disable-model-invocation
When To Load References
-
Always.
references/stack.md -
then only the task-relevant files under
references/
Output Contract
Report:
- which NestJS references were loaded
- the module and architecture pattern chosen
- the change made
- the verification run