Skip to content
cccskills
FreePublished on GitHub

nestjs-best-practices

NestJS best practices and architecture patterns for building production-ready applications. This skill should be used when writing, reviewing, or refactoring NestJS code to ensure proper patterns for modules, dependency injection, security, and performance.

The English summary is being prepared. Showing the original description.

ever-works/ever-works182 stars(GitHub 182 + cccskills 0)

Run score Not tested

See how to install

Files included (49)

  • SKILL.md4.8 KB
  • AGENTS.md154.2 KB
  • README.md4.7 KB
  • rules/_sections.md2.1 KB
  • rules/_template.md633 B
  • rules/api-use-dto-serialization.md4.2 KB
  • rules/api-use-interceptors.md5.4 KB
  • rules/api-use-pipes.md5.3 KB
  • rules/api-versioning.md4.7 KB
  • rules/arch-avoid-circular-deps.md1.9 KB
  • rules/arch-feature-modules.md2.3 KB
  • rules/arch-module-sharing.md3.7 KB
  • rules/arch-single-responsibility.md2.8 KB
  • rules/arch-use-events.md2.9 KB
  • rules/arch-use-repository-pattern.md2.7 KB
  • rules/db-avoid-n-plus-one.md3.8 KB
  • rules/db-use-migrations.md3.7 KB
  • rules/db-use-transactions.md3.6 KB
  • rules/devops-graceful-shutdown.md5.5 KB
  • rules/devops-use-config-module.md4.2 KB
  • rules/devops-use-logging.md5.1 KB
  • rules/di-avoid-service-locator.md2.8 KB
  • rules/di-interface-segregation.md5.0 KB
  • rules/di-liskov-substitution.md6.8 KB
  • rules/di-prefer-constructor-injection.md2.2 KB
  • rules/di-scope-awareness.md2.5 KB
  • rules/di-use-interfaces-tokens.md2.5 KB
  • rules/error-handle-async-errors.md3.4 KB
  • rules/error-throw-http-exceptions.md3.0 KB
  • rules/error-use-exception-filters.md3.4 KB
  • rules/micro-use-health-checks.md6.1 KB
  • rules/micro-use-patterns.md5.0 KB
  • rules/micro-use-queues.md5.7 KB
  • rules/perf-async-hooks.md2.8 KB
  • rules/perf-lazy-loading.md3.6 KB
  • rules/perf-optimize-database.md3.0 KB
  • rules/perf-use-caching.md3.3 KB
  • rules/security-auth-jwt.md3.8 KB
  • rules/security-rate-limiting.md3.1 KB
  • rules/security-sanitize-output.md3.7 KB
  • rules/security-use-guards.md3.4 KB
  • rules/security-validate-all-input.md3.2 KB
  • rules/test-e2e-supertest.md4.4 KB
  • rules/test-mock-external-services.md4.2 KB
  • rules/test-use-testing-module.md4.1 KB
  • scripts/build-agents.ts8.1 KB
  • scripts/build.sh369 B
  • scripts/package-lock.json7.7 KB
  • scripts/package.json410 B

SKILL.md (original)

Review the instructions the agent will receive before you install.

NestJS Best Practices

Comprehensive best practices guide for NestJS applications. Contains 40 rules across 10 categories, prioritized by impact to guide automated refactoring and code generation.

When to Apply

Reference these guidelines when:

  • Writing new NestJS modules, controllers, or services
  • Implementing authentication and authorization
  • Reviewing code for architecture and security issues
  • Refactoring existing NestJS codebases
  • Optimizing performance or database queries
  • Building microservices architectures

Rule Categories by Priority

PriorityCategoryImpactPrefix
1ArchitectureCRITICALarch-
2Dependency InjectionCRITICALdi-
3Error HandlingHIGHerror-
4SecurityHIGHsecurity-
5PerformanceHIGHperf-
6TestingMEDIUM-HIGHtest-
7Database & ORMMEDIUM-HIGHdb-
8API DesignMEDIUMapi-
9MicroservicesMEDIUMmicro-
10DevOps & DeploymentLOW-MEDIUMdevops-

Quick Reference

1. Architecture (CRITICAL)

  • arch-avoid-circular-deps - Avoid circular module dependencies
  • arch-feature-modules - Organize by feature, not technical layer
  • arch-module-sharing - Proper module exports/imports, avoid duplicate providers
  • arch-single-responsibility - Focused services over "god services"
  • arch-use-repository-pattern - Abstract database logic for testability
  • arch-use-events - Event-driven architecture for decoupling

2. Dependency Injection (CRITICAL)

  • di-avoid-service-locator - Avoid service locator anti-pattern
  • di-interface-segregation - Interface Segregation Principle (ISP)
  • di-liskov-substitution - Liskov Substitution Principle (LSP)
  • di-prefer-constructor-injection - Constructor over property injection
  • di-scope-awareness - Understand singleton/request/transient scopes
  • di-use-interfaces-tokens - Use injection tokens for interfaces

3. Error Handling (HIGH)

  • error-use-exception-filters - Centralized exception handling
  • error-throw-http-exceptions - Use NestJS HTTP exceptions
  • error-handle-async-errors - Handle async errors properly

4. Security (HIGH)

  • security-auth-jwt - Secure JWT authentication
  • security-validate-all-input - Validate with class-validator
  • security-use-guards - Authentication and authorization guards
  • security-sanitize-output - Prevent XSS attacks
  • security-rate-limiting - Implement rate limiting

5. Performance (HIGH)

  • perf-async-hooks - Proper async lifecycle hooks
  • perf-use-caching - Implement caching strategies
  • perf-optimize-database - Optimize database queries
  • perf-lazy-loading - Lazy load modules for faster startup

6. Testing (MEDIUM-HIGH)

  • test-use-testing-module - Use NestJS testing utilities
  • test-e2e-supertest - E2E testing with Supertest
  • test-mock-external-services - Mock external dependencies

7. Database & ORM (MEDIUM-HIGH)

  • db-use-transactions - Transaction management
  • db-avoid-n-plus-one - Avoid N+1 query problems
  • db-use-migrations - Use migrations for schema changes

8. API Design (MEDIUM)

  • api-use-dto-serialization - DTO and response serialization
  • api-use-interceptors - Cross-cutting concerns
  • api-versioning - API versioning strategies
  • api-use-pipes - Input transformation with pipes

9. Microservices (MEDIUM)

  • micro-use-patterns - Message and event patterns
  • micro-use-health-checks - Health checks for orchestration
  • micro-use-queues - Background job processing

10. DevOps & Deployment (LOW-MEDIUM)

  • devops-use-config-module - Environment configuration
  • devops-use-logging - Structured logging
  • devops-graceful-shutdown - Zero-downtime deployments

How to Use

Read individual rule files for detailed explanations and code examples:

rules/arch-avoid-circular-deps.md
rules/security-validate-all-input.md
rules/_sections.md

Each rule file contains:

  • Brief explanation of why it matters
  • Incorrect code example with explanation
  • Correct code example with explanation
  • Additional context and references

Full Compiled Document

For the complete guide with all rules expanded: AGENTS.md

Reviews

No reviews yet. Tell others what you thought.

Comments

No login needed. Share how it worked for you, ask a question, or note where it did not run.

No comments yet. Be the first to write one.

Comments are published right away. Do not include personal information such as email addresses or phone numbers. Up to 2 URLs.

0 / 1,000 characters

This form is protected by reCAPTCHA, and the Google Privacy Policy and Terms of Service apply.

More skills from this repository

Audit and improve web accessibility following WCAG 2.2 guidelines. Use when asked to "improve accessibility", "a11y audit", "WCAG compliance", "screen reader support", "keyboard navigation", or "make accessible".

The English summary is being prepared. Showing the original description.

ever-works/ever-works182Updated Oct 24, 2026

ai-sdk

Free

Answer questions about the AI SDK and help build AI-powered features. Use when developers: (1) Ask about AI SDK functions like generateText, streamText, ToolLoopAgent, embed, or tools, (2) Want to build AI agents, chatbots, RAG systems, or text generation features, (3) Have questions about AI providers (OpenAI, Anthropic, Google, etc.), streaming, tool calling, structured output, or embeddings, (4) Use React hooks like useChat or useCompletion. Triggers on: "AI SDK", "Vercel AI SDK", "generateText", "streamText", "add AI to my app", "build an agent", "tool calling", "structured output", "useChat".

The English summary is being prepared. Showing the original description.

ever-works/ever-works182Updated Oct 24, 2026

Configure Better Auth server and client, set up database adapters, manage sessions, add plugins, and handle environment variables. Use when users mention Better Auth, betterauth, auth.ts, or need to set up TypeScript authentication with email/password, OAuth, or plugin configuration.

The English summary is being prepared. Showing the original description.

ever-works/ever-works182Updated Oct 24, 2026

Deploy applications and websites to Vercel. Use when the user requests deployment actions like "deploy my app", "deploy and give me the link", "push this live", or "create a preview deployment".

The English summary is being prepared. Showing the original description.

ever-works/ever-works182Updated Oct 24, 2026

Configure email verification, implement password reset flows, set password policies, and customise hashing algorithms for Better Auth email/password authentication. Use when users need to set up login, sign-in, sign-up, credential authentication, or password security with Better Auth.

The English summary is being prepared. Showing the original description.

ever-works/ever-works182Updated Oct 24, 2026

Repo-specific guide to the Ever Works monorepo (ever-works/ever-works) — its pnpm + Turborepo layout, the per-workspace test runners (Jest vs Vitest vs Playwright), file-naming and import-alias conventions, the commit/branch model, and the real build/lint/type-check commands. Use this whenever working anywhere in this repository so changes match the codebase's actual conventions and pass CI.

The English summary is being prepared. Showing the original description.

ever-works/ever-works182Updated Oct 24, 2026

See all skills by ever-works

Report a problem with this skill