skills/nestjs-best-practices/SKILL.md
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.
npx skillsauth add sonvee/ai-skills nestjs-best-practicesInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Comprehensive best practices guide for NestJS applications. Contains 40 rules across 10 categories, prioritized by impact to guide automated refactoring and code generation.
Reference these guidelines when:
| Priority | Category | Impact | Prefix |
|----------|----------|--------|--------|
| 1 | Architecture | CRITICAL | arch- |
| 2 | Dependency Injection | CRITICAL | di- |
| 3 | Error Handling | HIGH | error- |
| 4 | Security | HIGH | security- |
| 5 | Performance | HIGH | perf- |
| 6 | Testing | MEDIUM-HIGH | test- |
| 7 | Database & ORM | MEDIUM-HIGH | db- |
| 8 | API Design | MEDIUM | api- |
| 9 | Microservices | MEDIUM | micro- |
| 10 | DevOps & Deployment | LOW-MEDIUM | devops- |
arch-avoid-circular-deps - Avoid circular module dependenciesarch-feature-modules - Organize by feature, not technical layerarch-module-sharing - Proper module exports/imports, avoid duplicate providersarch-single-responsibility - Focused services over "god services"arch-use-repository-pattern - Abstract database logic for testabilityarch-use-events - Event-driven architecture for decouplingdi-avoid-service-locator - Avoid service locator anti-patterndi-interface-segregation - Interface Segregation Principle (ISP)di-liskov-substitution - Liskov Substitution Principle (LSP)di-prefer-constructor-injection - Constructor over property injectiondi-scope-awareness - Understand singleton/request/transient scopesdi-use-interfaces-tokens - Use injection tokens for interfaceserror-use-exception-filters - Centralized exception handlingerror-throw-http-exceptions - Use NestJS HTTP exceptionserror-handle-async-errors - Handle async errors properlysecurity-auth-jwt - Secure JWT authenticationsecurity-validate-all-input - Validate with class-validatorsecurity-use-guards - Authentication and authorization guardssecurity-sanitize-output - Prevent XSS attackssecurity-rate-limiting - Implement rate limitingperf-async-hooks - Proper async lifecycle hooksperf-use-caching - Implement caching strategiesperf-optimize-database - Optimize database queriesperf-lazy-loading - Lazy load modules for faster startuptest-use-testing-module - Use NestJS testing utilitiestest-e2e-supertest - E2E testing with Supertesttest-mock-external-services - Mock external dependenciesdb-use-transactions - Transaction managementdb-avoid-n-plus-one - Avoid N+1 query problemsdb-use-migrations - Use migrations for schema changesapi-use-dto-serialization - DTO and response serializationapi-use-interceptors - Cross-cutting concernsapi-versioning - API versioning strategiesapi-use-pipes - Input transformation with pipesmicro-use-patterns - Message and event patternsmicro-use-health-checks - Health checks for orchestrationmicro-use-queues - Background job processingdevops-use-config-module - Environment configurationdevops-use-logging - Structured loggingdevops-graceful-shutdown - Zero-downtime deploymentsRead 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:
For the complete guide with all rules expanded: AGENTS.md
development
Pinia official Vue state management library, type-safe and extensible. Use when defining stores, working with state/getters/actions, or implementing store patterns in Vue apps.
tools
编码时必须严格遵循我的编码风格,在进行 vue项目/nestjs项目/uniapp项目/js/ts 时应优先使用该技能,在写文档或其他编程语言时不使用该技能
development
用于初始化“全新的”前后端分离全栈项目脚手架与基础配置,默认目录结构为同仓库下的 `frontend/` + `backend/`。当用户表达要新建项目、初始化项目、搭建前后端分离仓库、创建 monorepo 全栈模板,或已经进入 `superteam` 模式并要求按 `fullstack-init + superteam` 流程启动一个新项目时,应优先使用本 skill。它适用于从零创建项目结构、根目录共享文件、前后端初始化流程与基础环境配置约定;不适用于现有项目中的功能开发、Bug 修复、单独初始化前端或后端、只调整 README / `.gitignore` / `.env.*`、或仅讨论技术方案而尚未真正开始初始化项目的场景。
development
Create distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, artifacts, posters, or applications (examples include websites, landing pages, dashboards, React components, HTML/CSS layouts, or when styling/beautifying any web UI). Generates creative, polished code and UI design that avoids generic AI aesthetics.