Agent-skills-standard nestjs-architecture
Design decoupled, testable NestJS module boundaries with feature, core, and shared modules. Use when structuring module imports, creating feature modules, or enforcing separation of concerns in NestJS. (triggers: **/*.module.ts, main.ts, NestFactory, Module, Controller, Injectable)
install
source · Clone the upstream repo
git clone https://github.com/HoangNguyen0403/agent-skills-standard
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/HoangNguyen0403/agent-skills-standard "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/nestjs/nestjs-architecture" ~/.claude/skills/hoangnguyen0403-agent-skills-standard-nestjs-architecture && rm -rf "$T"
manifest:
skills/nestjs/nestjs-architecture/SKILL.mdsource content
NestJS Architecture Expert
Priority: P0 (CRITICAL)
Design decoupled, testable modules with clear boundaries.
Workflow: Create New Feature Module
- Generate module —
creates feature module.nest g module users - Add controller + service —
andnest g controller users
.nest g service users - Register dependencies — Import
in module.TypeOrmModule.forFeature([User]) - Validate inputs — Apply
decorators on all DTOs.class-validator - Check circular deps — Run
to verify no cycles.madge --circular src/
Module Structure Example
Implementation Guidelines
- Modules: Feature Modules (Auth) vs Core (Config/DB) vs Shared (Utils).
- Controllers: Thin controllers, fat services. Verify DTOs here.
- Services: Business logic only. Use Repository pattern for DB.
- Config: Use
, never@nestjs/config
directly.process.env
Architecture Checklist (Mandatory)
- Circular Deps: there any circular dependencies? (Use
).madge - Env Validation: Joi/Zod schema used for env vars?
- Exception Filters: global filters catching unhandled errors?
- DTO Validation:
decorators on all inputs?class-validator - Dependency Integrity: all
or injected services properly registered in module's@InjectRepository()
(viaimports
) orTypeOrmModule.forFeature
?providers
Anti-Patterns
- No Global Scope: Avoid global pipes/guards unless truly universal.
- No Direct Entity: Don't return ORM entities; return DTOs.
- No Business in Controller: Move logic to Service.
- No Manual Instantiation: Use DI, never
.new Service()