Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Nestjs Services?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/adityaaatiwari-nestjs-services-anvil)
---
name: nestjs-services
description: "Build NestJS modules safely: DI scopes, DTO validation pipes, exception filters, guards and lifecycle hooks"
---
<!-- Generated by `anvil plugin build` from catalog/. Edit the catalog, not this file. -->
# NestJS services
Use when authoring NestJS controllers, providers, guards, interceptors, or module boundaries.
## Modules and DI
- Keep services request-stateless (`Scope.DEFAULT` singleton). Request-scoped providers (`Scope.REQUEST`) bubble up the entire dependency tree and allocate per request.
- Export only public module facades; use `forwardRef` only as a last resort when decoupling circular dependencies properly is blocked.
- Register `enableShutdownHooks()` so `onModuleDestroy` and `onApplicationShutdown` drain database pools and queues gracefully.
## Validation and pipeline order
- Enable global `ValidationPipe({ whitelist: true, forbidNonWhitelisted: true, transform: true })` so unexpected fields never slip into handlers.
- Know the Nest execution sequence: Middleware → Guards → Interceptors (before) → Pipes → Controller → Interceptors (after) → Exception Filters.
- Never catch and swallow database or transport errors silently inside services; map domain errors cleanly to typed HTTP exceptions.
## Security and serialization
Use `ClassSerializerInterceptor` with `@Exclude()` on password/token properties or map explicit response DTOs instead of returning ORM entities directly.
## Verify
Unit tests overriding providers cleanly with `Test.createTestingModule`, plus e2e `supertest` specs exercising guards, whitelist validation rejection, and shutdown cleanup.