skills/nestjs/nestjs-controllers-services/SKILL.md
Separate Controllers from Services and build Custom Decorators in NestJS. Use when defining NestJS controllers, services, or custom parameter decorators.
npx skillsauth add hoangnguyen0403/agent-skills-standard nestjs-controllers-servicesInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
ExecutionContext helpers (switchToHttp()) for platform-agnostic code.@Request() req -> req.user (Not type-safe).@CurrentUser(), @DeviceIp().import { RequestWithUser } from 'src/common/interfaces/request.interface';
export const CurrentUser = createParamDecorator(
(data: unknown, ctx: ExecutionContext): User => {
const request = ctx.switchToHttp().getRequest<RequestWithUser>();
return request.user;
},
);
whitelist: true: Strip properties without decorators.forbidNonWhitelisted: true: Throw error if unknown properties exist.transform: true: Auto-convert primitives (String '1' -> Number 1) and instantiate DTO classes.@nestjs/swagger CLI plugin in nest-cli.json auto-detects DTO properties — no manual @ApiProperty().map() wraps success responses (e.g. { data: T }).PageDto and ApiResponse.catchError() maps low-level errors (DB constraints) to HttpException (e.g. ConflictException) before global filter.Scope.REQUEST.ValidationPipe globally.ParseIntPipe, ParseUUIDPipe on all ID parameters.@Get(':id')
findOne(@Param('id', ParseIntPipe) id: number) { ... }
OnModuleInit for connection setup.OnApplicationShutdown for cleanup. (Requires enableShutdownHooks()).@CurrentUser() decorator instead of accessing raw req.testing
Infer the requesting operator's technical fluency from message content (never ask directly) and adapt register — business, hybrid, or technical — across SDLC workflow output. Use when starting sdlc, brainstorm-feature, plan-feature, verify-work, publish-notes, or session-report, or whenever a request's phrasing signals a non-technical or cross-stack operator.
documentation
Define transaction boundaries, locking, and consistency guarantees for multi-step writes. Use when designing atomic operations, retries, idempotency, or concurrent write behavior.
development
Design relational or document schemas from access patterns, cardinality, and lifecycle. Use when modeling entities, choosing embed vs normalize, or shaping schema boundaries before implementation.
data-ai
Diagnose database latency with explain plans, index ownership, and query-shape review. Use when a query is slow, an index is missing, or scans and N+1 patterns appear.