nestjs-conventions

Enforce NestJS backend conventions across modules, controllers, services, and DTOs.

291|38|Updated Mar 16, 2026
One-click install
npx skills add https://github.com/J-Pster/Psters_AI_Workflow --skill nestjs-conventions-j-pster
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: nestjs-conventions
Source: https://github.com/J-Pster/Psters_AI_Workflow/tree/main/plugins/psters-ai-workflow/skills/nestjs-conventions
Command: npx skills add https://github.com/J-Pster/Psters_AI_Workflow --skill nestjs-conventions-j-pster

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

NestJS projects often diverge in structure and conventions, leading to maintenance challenges and inconsistent code quality.

Core Features & Use Cases

  • Enforces modular architecture: feature-based modules with separate module.ts, controller.ts, service.ts, entities, dto/.
  • DTOs with validation: always use DTOs with class-validator; separate create/update/response; English messages.
  • Migration and config discipline: use TypeORM CLI for migrations; @nestjs/config with typed configs; avoid hardcoded secrets.
  • Common guards/interceptors: use shared guards and interceptors; dependency injection.

Quick Start

Configure a new NestJS project to follow these conventions.

Frequently Asked Questions about nestjs-conventions

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
What are the best practices for structuring NestJS modules and controllers?

NestJS backend conventions standardize feature-based modules with separate module.ts, controller.ts, service.ts, entities, and dto/ folders. This modular structure isolates domain logic, ensuring consistent code quality and separation of concerns across your project.

How do I validate DTOs in NestJS using class-validator?

To validate DTOs in NestJS, always define them with class-validator and separate create, update, and response variations. This approach ensures incoming data matches expected schemas while providing English validation messages to standardize error handling across endpoints.

Does this NestJS convention guide work for existing projects or only new ones?

Yes, these NestJS backend conventions apply to both new and existing projects during implementation and code review. You can incrementally refactor legacy code to satisfy requirements for modular structure, typed config usage, and standardized error handling.

How to manage database migrations and config in a NestJS backend?

Manage NestJS database migrations using TypeORM CLI and load typed configurations via @nestjs/config to avoid hardcoded secrets. This discipline ensures environment-specific settings are safely injected through dependency injection rather than scattered inline.

When should I use shared guards and interceptors in NestJS?

Use shared guards and interceptors in NestJS when you need to standardize authentication, authorization, or response transformation across modules. Applying these via dependency injection ensures separation of concerns and prevents duplicated logic across controllers.