Agent skill
NestJS
Align all NestJS services, modules, and controllers with these conventions.
Stars
10
Forks
1
Install this agent skill to your Project
npx add-skill https://github.com/hivellm/rulebook/tree/main/templates/skills/frameworks/nestjs
SKILL.md
NestJS Framework Rules
CRITICAL: Align all NestJS services, modules, and controllers with these conventions.
Project Structure
- Maintain feature-first modules under
src/<feature>/ - Keep global providers in
src/common/ - Register new modules in
AppModuleand ensure dependency injection consistency - Prefer
@nestjs/configfor environment configuration
Quality Gates
- Lint:
npm run lint - Unit tests:
npm run test - e2e tests:
npm run test:e2e - Build validation:
npm run build - Coverage threshold: 80%+ for service and controller layers
Implementation Guidelines
- Use DTOs with
class-validatorandclass-transformer - Encapsulate database access in providers (avoid direct repository use in controllers)
- Document routes with
@nestjs/swaggerwhen OpenAPI is enabled - Keep asynchronous logic wrapped with
try/catchand map errors to HTTP exceptions
Scripts to Run Before Commit
bash
npm run lint
npm run test
npm run test:e2e
npm run build
Additional Checks
- Ensure Circular Dependency detection is clean (
npm run lint -- --max-warnings=0) - Synchronize
.env.examplewith actual required variables - Maintain aligned versions for Nest core packages (
@nestjs/*)
Documentation
- Update
/docs/architecture.mdwith new modules and providers - Keep OpenAPI spec regenerated via
npm run swagger:generate - Log breaking changes in
CHANGELOG.md
Didn't find tool you were looking for?