nestjs-expert
Skill5 starsChanged 3 months agoMITView on GitHub
Use when working in a NestJS project - nest-cli.json, @nestjs/* imports, *.module.ts / *.controller.ts / *.service.ts files, main.ts with NestFactory, or tasks mentioning NestJS, Nest modules, providers, guards, interceptors, pipes, or BullMQ workers. Builds and refactors NestJS 11 APIs, wires DI and config, integrates Prisma/TypeORM, implements JWT auth and refresh flows, and writes e2e tests. Invoke for creating modules/endpoints, fixing DI errors, adding validation, auth, OpenAPI docs, queues, or e2e test suites.
- Reads credentials
10 other projects use a version of this.
Adopted by
Most recently taken up by
- nafiskabbo/skillstheir own version, first seen Sep 23, 2026
- Leo-Atienza/atlas-claudetheir own version, first seen Jul 24, 2026
- codeApe-7/ai-agent-workflowGrouptheir own version, first seen Jun 6, 2026
- tranhieutt/software_development_departmenttheir own version, first seen Apr 30, 2026
- ai4brands-design/claude-skillstheir own version, first seen Mar 22, 2026
- d3labs-thomas/claude-codetheir own version, first seen Mar 5, 2026
Other versions10 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 10
- Jeffallan/claude-skills★ 12ksame name
- tranhieutt/software_development_department★ 72same name
- codeApe-7/ai-agent-workflowGroup★ 17same name
- xfstudio/skills★ 9same name
- Leo-Atienza/atlas-claude★ 4same name
- ai4brands-design/claude-skills★ 2same name
- Aver005/agent-skills★ 2same name
- d3labs-thomas/claude-code★ 2same name
- nafiskabbo/skills★ 1same name
- usmanmubarak1/ClaudeSkilledAgents★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository15 other files it gives its agents.
- docker-expertSkill
- engineering-rulesSkill
- fastapi-expertSkill
- fastify-expertSkill
- flutter-expertSkill
- go-expertSkill
- jetpack-compose-expertSkill
- mobile-qa-expertSkill
- playwright-expertSkill
- react-expertSkill
- react-native-expertSkill
- remix-expertSkill
- swiftui-expertSkill
- terraform-expertSkill
- vue-expertSkill
The file
We split this skill into the rules it gives an agent
8 rules. 0 are common, 3 are distinctive, and 5 are very specific to this project.
0
Common
Most of the 10 edited versions we read keep these.
3
Distinctive
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- could be automatic: a setting could enforce it
- Distinctive: line 21
Add request validation (ValidationPipe + class-validator, or Zod pipes) and typed, validated env config
- Distinctive: line 24
Add OpenAPI/Swagger documentation that matches the actual DTOs
- Distinctive: line 25
Write or fix e2e tests with Test.createTestingModule + supertest, and background jobs with BullMQ
- Very specific: line 29
Analyze: - Read nest-cli.json, package.json (confirm @nestjs/core major = 11, ORM, validation lib), src/main.ts (global …
- Very specific: line 30
Implement: - Write the feature as module + controller + service + DTOs.
- Very specific: line 31
Verify types and lint: - run npx tsc --noEmit and npm run lint.
- Very specific: line 32
Test: - add/update unit tests for services and e2e tests for new endpoints.
- Very specific: line 98
ValidationPipe without
whitelist/transform: Default config lets unknown properties through (mass-assignment risk) and leaves @Query() …
“Common” is measured: kept by at least 6 in 10 of the 10 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
NestJS Expert
Turns Claude into a senior NestJS backend engineer who ships NestJS 11 / Node 22 services with correct DI scoping, validated config, typed database access, and verified tests.
When to Use This Skill
- Scaffold or extend a NestJS module: controller, service, DTOs, and wiring into the app graph
- Debug DI failures ("Nest can't resolve dependencies of X") or circular module imports
- Add request validation (ValidationPipe + class-validator, or Zod pipes) and typed, validated env config
- Integrate Prisma or TypeORM, including transactions and testcontainer-backed tests
- Implement auth: passport-jwt guards, @nestjs/jwt token issuing, refresh-token rotation
- Add OpenAPI/Swagger documentation that matches the actual DTOs
- Write or fix e2e tests with Test.createTestingModule + supertest, and background jobs with BullMQ
Core Workflow
- Analyze - Read
nest-cli.json,package.json(confirm@nestjs/coremajor = 11, ORM, validation lib),src/main.ts(global pipes/filters/prefix), andapp.module.tsto map the module graph. Match the project's existing conventions (barrel files, DTO location,ConfigServicevsregisterAstokens) before writing anything. - Implement - Write the feature as module + controller + service + DTOs. Default to singleton providers; justify any
Scope.REQUESTexplicitly (seereferences/architecture-di.md). New cross-cutting behavior goes in guards/interceptors/filters, not in controllers. - Verify types and lint - run
npx tsc --noEmitandnpm run lint; fix all reported issues and re-run until clean before proceeding. - Test - add/update unit tests for services and e2e tests for new endpoints; run
npm testandnpm run test:e2e; fix all failures and re-run until clean. Never weaken an assertion to make a test pass. - Prove it works - start the app (
npm run start:dev) and hit the new endpoint withcurl, including one invalid payload to confirm the 400 shape from ValidationPipe. For queues, enqueue a job and confirm the processor log. Fix anything wrong and re-verify until the observed behavior matches the requirement.
Reference Guide
Load detailed guidance only when the task needs it:
| Topic | Reference | Load When |
| Modules, DI scopes, providers, lifecycle, execution order | references/architecture-di.md | Creating modules, DI resolution errors, request-scoped providers, guard/interceptor/filter ordering questions |
| ValidationPipe, class-validator vs Zod, ConfigModule + env validation, OpenAPI decorators | references/validation-config.md | Adding DTO validation, choosing a validation library, wiring .env config, "config is undefined at bootstrap", Swagger/OpenAPI docs |
| Prisma and TypeORM integration, transactions, migrations | references/database-prisma.md | Any DB work: schema changes, repositories, transactions, connection lifecycle, choosing Prisma vs TypeORM |
| Passport-jwt vs @nestjs/jwt, refresh-token rotation, route guarding | references/auth.md | Login/JWT endpoints, protecting routes, refresh flows, "401 on valid token" debugging |
| Unit + e2e testing, supertest, overriding providers, BullMQ jobs | references/testing.md | Writing tests, mocking providers, e2e app bootstrap parity, queue/worker implementation and testing |
Key Patterns
Singleton by default; request scope is a measured exception. Scope.REQUEST bubbles: every consumer of a request-scoped provider becomes request-scoped and is re-instantiated per request. For "who is the current user" style needs, prefer AsyncLocalStorage (via nestjs-cls) or pass context explicitly:
@Injectable() // singleton - no scope option
export class AuditService {
constructor(private readonly cls: ClsService) {}
log(action: string) {
this.cls.get('userId'); // per-request data without per-request instantiation
}
}Global ValidationPipe with the three flags that matter (in main.ts):
app.useGlobalPipes(new ValidationPipe({
whitelist: true, // strip unknown properties
forbidNonWhitelisted: true, // 400 on unknown properties
transform: true, // plain body -> DTO instance, enables @Type coercion
}));Custom providers use tokens, not strings scattered inline:
export const REDIS = Symbol('REDIS');
@Module({
providers: [{ provide: REDIS, useFactory: (cfg: ConfigService) => new Redis(cfg.getOrThrow('REDIS_URL')), inject: [ConfigService] }],
exports: [REDIS],
})
export class RedisModule {}
// consumer: constructor(@Inject(REDIS) private readonly redis: Redis) {}e2e tests must mirror production bootstrap - apply the same global pipes/filters the real main.ts applies, or e2e tests pass while production rejects:
const moduleRef = await Test.createTestingModule({ imports: [AppModule] }).compile();
app = moduleRef.createNestApplication();
applyGlobalConfig(app); // shared helper also called from main.ts
await app.init();Common Mistakes
- Marking providers
Scope.REQUESTfor convenience. It cascades to every dependent, kills singleton caching, and breaks in passive contexts (cron, queue processors). Correction: stay singleton; usenestjs-cls/AsyncLocalStoragefor per-request data, ormoduleRef.resolve()with aContextIdwhen you truly need per-request instances. - Assuming providers are visible app-wide. A provider is injectable only inside its module unless
exports-ed and the consumerimportsthat module. "Nest can't resolve dependencies" is almost always a missing export/import, not a missing@Injectable(). - Wrong mental model of execution order. Request path: middleware → guards → interceptors (pre) → pipes → handler → interceptors (post, reverse registration order) → exception filters. Guards run before interceptors, so an interceptor cannot run for a request a guard rejected; filters catch errors from all of the preceding stages except middleware.
- ValidationPipe without
whitelist/transform. Default config lets unknown properties through (mass-assignment risk) and leaves@Query()params as strings. Also: class-validator decorators do nothing oninterfaces or on properties without decorators - every DTO field needs one (or@Allow()). - Reading
process.envdirectly in providers. Bypasses ConfigModule validation and load order; values arestring | undefinedat type level and unvalidated at runtime. Correction: validate env at bootstrap (Joi/ZodvalidateinConfigModule.forRoot) and injectConfigServicewithgetOrThrow, or typedregisterAsnamespaces. - Passport confusion:
@nestjs/jwtandpassport-jwtare not alternatives for the same job.@nestjs/jwtsigns/verifies tokens (issuing side);passport-jwt+JwtStrategy+AuthGuard('jwt')validates them on requests. A typical app uses both; implementing verification manually in a guard while also registering a strategy leads to double/contradictory validation. - Storing raw refresh tokens, or not rotating them. Store only a hash, rotate on every refresh, and revoke the family on reuse detection. See
references/auth.md. @Body() body: anyplus manual checks instead of DTOs. Kills ValidationPipe, OpenAPI generation (@nestjs/swaggerCLI plugin reads DTO classes), and type safety in one move.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

