nestjs-best-practices

Applies 40 prioritized NestJS architecture, security, and performance rules when writing or refactoring code.

Updated Jun 8, 2026
One-click install
npx skills add https://github.com/raulisai/eva02 --skill nestjs-best-practices-raulisai
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: nestjs-best-practices
Source: https://github.com/raulisai/eva02/tree/main/.agents/skills/nestjs-best-practices
Command: npx skills add https://github.com/raulisai/eva02 --skill nestjs-best-practices-raulisai

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) components.

What problem does it solve? NestJS codebases frequently suffer from circular dependencies, god services, insecure endpoints, and untestable dependency injection. This Skill gives AI agents a structured, prioritized rulebook so generated or refactored NestJS code follows proven architecture patterns instead of accumulating technical debt. ## Core Features & Use Cases - 40 rules across 10 categories: Architecture, Dependency Injection, Error Handling, Security, Performance, Testing, Database & ORM, API Design, Microservices, and DevOps, each ranked by impact from CRITICAL to LOW-MEDIUM. - Incorrect vs. correct code examples: Every rule shows a real anti-pattern alongside the recommended implementation with explanations and references to official NestJS documentation. - EVA project overrides: Project-specific constraints for the eva-core app, including Supabase-backed data access, org_id tenant filtering, RLS migrations, and Approval Engine requirements. - Use Case: When asked to add a new orders module to a NestJS API, the agent applies feature-module organization, constructor injection, DTO validation, and JWT guard rules automatically instead of producing a monolithic controller. ## Quick Start Ask the agent to review or generate a NestJS module, service, or controller using the nestjs-best-practices rules for architecture, security, and testing.

Frequently Asked Questions about nestjs-best-practices

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

FAQPage Schema
How do I avoid circular dependencies in NestJS modules?

Extract shared logic into a third module that both modules import, or use @nestjs/event-emitter to decouple communication through events. Circular imports are the leading cause of NestJS runtime crashes and should be refactored rather than patched with forward references.

How should I organize a NestJS project structure?

Organize by feature modules where each domain (users, orders) contains its own controllers, services, DTOs, and entities. Avoid grouping by technical layer, since feature-based organization improves onboarding speed and keeps modules self-contained.

What is the correct way to share services between NestJS modules?

Encapsulate the service in a dedicated module, export it explicitly, and import that module where needed. Providing the same service in multiple modules creates separate instances with divergent state, causing memory waste and synchronization bugs.

Does this skill work with Supabase instead of TypeORM?

Yes. The EVA project overrides require using the existing Supabase-backed DatabaseService and explicitly prohibit introducing TypeORM, Prisma, or Mongoose. Repository examples are illustrative and must be adapted to org_id-filtered Supabase queries.

When should I use constructor injection versus ModuleRef in NestJS?

Prefer constructor injection because dependencies stay explicit and testable. ModuleRef.get() is a service locator anti-pattern that hides dependencies, though it remains valid inside factory patterns that resolve handlers dynamically by type.