# Nestjs Expert

> Use when building NestJS REST or GraphQL backends — modules, controllers, services, DTOs, guards, interceptors, pipes, JWT/Passport auth, TypeORM/Prisma. Invoke for .module.ts/.controller.ts/.service.ts files. Triggers: NestJS, Nest, Node.js backend, TypeScript backend, dependency injection, controller, service, module, guard, interceptor.

- Skill: `aashutosh396/nestjs-expert` (Agent Skill)
- Install (CLI): `npx get-skill add aashutosh396/nestjs-expert`
- Raw SKILL.md: https://api.skillmd.com/api/skills/aashutosh396/nestjs-expert/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Integrations & APIs
- License: MIT
- Author: aashutosh396 (https://skillmd.com/u/aashutosh396)
- Updated: 2026-11-24
- Page: https://skillmd.com/skills/aashutosh396/nestjs-expert

---


# NestJS Expert

Enterprise NestJS: modular TypeScript backends.

## When to use

NestJS REST or GraphQL services; DI + modular architecture; JWT/Passport auth; TypeORM or Prisma; guards, interceptors, pipes, validation; Swagger docs; unit/E2E tests.

## Core workflow

1. **Analyze** — domain modules, boundaries, data layer.
2. **Design** — modules per bounded context; DTOs with class-validator.
3. **Implement** — controllers (thin) → services (logic) → repositories; DI throughout.
4. **Cross-cutting** — guards (authz), interceptors (logging/transform), pipes (validation).
5. **Test** — Jest unit tests + Supertest E2E.

## Key practices

- One module per feature; export only what other modules need.
- DTOs validated by `ValidationPipe` + class-validator decorators.
- Guards for auth (JWT via Passport strategy); `@UseGuards`.
- Interceptors for response shaping, logging, caching.
- TypeORM/Prisma repositories injected into services; never query in controllers.
- `@nestjs/swagger` decorators for OpenAPI.

## Constraints

MUST: thin controllers, logic in services; DI for all dependencies; global `ValidationPipe` + DTO validation; guards for protected routes; module boundaries respected; unit + E2E tests.
MUST NOT: business logic in controllers; direct DB access outside repositories/services; skip DTO validation; circular module dependencies; secrets in code (use ConfigModule/env).

## Output

1. Module + DTOs (class-validator). 2. Controller + service + repository. 3. Guards/interceptors/pipes. 4. Jest + Supertest tests. 5. Brief note on module design.

## Knowledge

NestJS, dependency injection, modules/controllers/providers, DTOs, class-validator, guards/interceptors/pipes, Passport/JWT, TypeORM, Prisma, @nestjs/swagger, Jest, Supertest.

