.claude/skills/nestjs/SKILL.md
NestJS modular API architecture with controllers, services, guards, middleware, and dependency injection patterns. Use when: building API endpoints, implementing services, creating guards/interceptors, handling authentication/authorization, or any backend business logic with NestJS
npx skillsauth add kaxuna1/ecomsite nestjsInstall 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.
NestJS provides a structured, Angular-inspired architecture for Node.js backends. It enforces separation of concerns through modules, controllers, and services with built-in dependency injection. Use decorators for routing, validation, and metadata.
// src/products/products.module.ts
@Module({
imports: [TypeOrmModule.forFeature([Product])],
controllers: [ProductsController],
providers: [ProductsService],
exports: [ProductsService],
})
export class ProductsModule {}
// src/products/products.controller.ts
@Controller('products')
export class ProductsController {
constructor(private readonly productsService: ProductsService) {}
@Get()
findAll(@Query() query: FindProductsDto) {
return this.productsService.findAll(query);
}
@Post()
@UseGuards(JwtAuthGuard)
create(@Body() dto: CreateProductDto, @Request() req) {
return this.productsService.create(dto, req.user.id);
}
}
// src/products/products.service.ts
@Injectable()
export class ProductsService {
constructor(
@InjectRepository(Product)
private readonly productRepo: Repository<Product>,
) {}
async findAll(query: FindProductsDto): Promise<Product[]> {
return this.productRepo.find({ where: query });
}
}
| Concept | Usage | Example |
|---------|-------|---------|
| Module | Feature boundary, DI container | @Module({ providers: [...] }) |
| Controller | HTTP routing, request handling | @Controller('users') |
| Service | Business logic, injectable | @Injectable() |
| Guard | Auth/authorization checks | @UseGuards(AuthGuard) |
| Pipe | Validation, transformation | @UsePipes(ValidationPipe) |
| Interceptor | Response transformation, logging | @UseInterceptors(LoggingInterceptor) |
// main.ts
app.useGlobalPipes(new ValidationPipe({
whitelist: true,
forbidNonWhitelisted: true,
transform: true,
}));
@Catch(HttpException)
export class HttpExceptionFilter implements ExceptionFilter {
catch(exception: HttpException, host: ArgumentsHost) {
const ctx = host.switchToHttp();
const response = ctx.getResponse<Response>();
const status = exception.getStatus();
response.status(status).json({
statusCode: status,
message: exception.message,
timestamp: new Date().toISOString(),
});
}
}
tools
Zustand lightweight state management with persistence and middleware. Use when: managing client-side state (cart, auth, UI preferences), replacing React Context with simpler API, accessing state outside React components, implementing localStorage persistence
development
Zod schema validation and TypeScript integration for runtime type safety. Use when: Validating API payloads, form inputs, environment variables, or any external data boundaries where TypeScript types alone cannot guarantee safety.
tools
Configures Vite 5.x build tool, dev server, and frontend asset optimization for the Luxia e-commerce platform. Use when: configuring builds, adding environment variables, optimizing bundle size, setting up testing, debugging HMR issues, or adding Vite plugins.
development
Enforces strict TypeScript types across frontend and backend codebases. Use when: Writing new services, DTOs, interfaces, type guards, debugging type errors, or ensuring type safety at API boundaries.