skills/nutnut123qq/agent-nestjs-skills/nestjs-best-practices

nestjs-best-practices

SKILL.md

NestJS Best Practices

Conventions for NestJS applications using configurable dynamic modules, custom domain exceptions, Mongoose, and feature-based module organization.

When to Apply

  • Writing new NestJS modules, services, or controllers
  • Refactoring existing NestJS code to follow these patterns
  • Implementing authentication, validation, or data access
  • Organizing code by feature (not by technical layer)

Rule Categories

Architecture

  • arch-dynamic-modules — Use ConfigurableModuleBuilder, *-module-definition.ts, and static register() for dynamic modules. See rules/arch-dynamic-modules.md.
  • arch-feature-modules — Organize by feature under src/modules/<feature>/ with *.module.ts, *.module-definition.ts, and index.ts. See rules/arch-feature-modules.md.

Error Handling

Database & Data Access

  • db-mongoose-data-access — Inject Mongoose Connection via custom decorator (e.g. @InjectPrimaryMongoose()), use connection.model(Schema.name). See rules/db-mongoose-data-access.md.

Dependency Injection

API & Validation

  • api-dto-validation — Define DTOs with class-validator decorators (@IsEmail(), @IsString(), etc.) for input validation. See rules/api-dto-validation.md.

Security

  • security-guards — Use Throttler, JWT, and TOTP guards; configure ThrottlerModule with Redis storage where needed. See rules/security-guards.md.

How to Use

Read individual rule files under rules/ for incorrect vs correct examples and detailed guidance.

For the full compiled document with all rules in one file: AGENTS.md (generated by scripts/build-agents.ts).

Weekly Installs
11
First Seen
Feb 5, 2026
Installed on
cursor11
gemini-cli7
github-copilot7
codex7
amp7
kimi-cli7