nestjs-best-practices by kadajett/agent-nestjs-skills
npx skills add https://github.com/kadajett/agent-nestjs-skills --skill nestjs-best-practices适用于 NestJS 应用程序的全面最佳实践指南。包含 10 个类别下的 40 条规则,按影响优先级排序,以指导自动化重构和代码生成。
在以下情况下参考这些指南:
| 优先级 | 类别 | 影响 | 前缀 |
|---|---|---|---|
| 1 | 架构 | 关键 | arch- |
| 2 | 依赖注入 | 关键 | di- |
| 3 | 错误处理 | 高 |
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
error-| 4 | 安全性 | 高 | security- |
| 5 | 性能 | 高 | perf- |
| 6 | 测试 | 中高 | test- |
| 7 | 数据库与 ORM | 中高 | db- |
| 8 | API 设计 | 中 | api- |
| 9 | 微服务 | 中 | micro- |
| 10 | DevOps 与部署 | 低中 | devops- |
arch-avoid-circular-deps - 避免循环模块依赖arch-feature-modules - 按功能而非技术层组织arch-module-sharing - 正确的模块导出/导入,避免重复提供者arch-single-responsibility - 聚焦的服务而非"上帝服务"arch-use-repository-pattern - 抽象数据库逻辑以提高可测试性arch-use-events - 事件驱动架构以实现解耦di-avoid-service-locator - 避免服务定位器反模式di-interface-segregation - 接口隔离原则 (ISP)di-liskov-substitution - 里氏替换原则 (LSP)di-prefer-constructor-injection - 构造函数注入优于属性注入di-scope-awareness - 理解单例/请求/瞬态作用域di-use-interfaces-tokens - 使用注入令牌处理接口error-use-exception-filters - 集中式异常处理error-throw-http-exceptions - 使用 NestJS HTTP 异常error-handle-async-errors - 正确处理异步错误security-auth-jwt - 安全的 JWT 身份验证security-validate-all-input - 使用 class-validator 进行验证security-use-guards - 身份验证和授权守卫security-sanitize-output - 防止 XSS 攻击security-rate-limiting - 实现速率限制perf-async-hooks - 正确的异步生命周期钩子perf-use-caching - 实现缓存策略perf-optimize-database - 优化数据库查询perf-lazy-loading - 延迟加载模块以加快启动速度test-use-testing-module - 使用 NestJS 测试工具test-e2e-supertest - 使用 Supertest 进行端到端测试test-mock-external-services - 模拟外部依赖db-use-transactions - 事务管理db-avoid-n-plus-one - 避免 N+1 查询问题db-use-migrations - 使用迁移进行模式变更api-use-dto-serialization - DTO 和响应序列化api-use-interceptors - 横切关注点api-versioning - API 版本控制策略api-use-pipes - 使用管道进行输入转换micro-use-patterns - 消息和事件模式micro-use-health-checks - 编排用的健康检查micro-use-queues - 后台作业处理devops-use-config-module - 环境配置devops-use-logging - 结构化日志记录devops-graceful-shutdown - 零停机部署阅读各个规则文件以获取详细解释和代码示例:
rules/arch-avoid-circular-deps.md
rules/security-validate-all-input.md
rules/_sections.md
每个规则文件包含:
要获取包含所有扩展规则的完整指南:AGENTS.md
每周安装量
8.7K
仓库
GitHub 星标数
95
首次出现
2026年1月19日
安全审计
安装于
opencode7.1K
gemini-cli7.0K
codex7.0K
github-copilot6.9K
amp6.2K
kimi-cli6.2K
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
Weekly Installs
8.7K
Repository
GitHub Stars
95
First Seen
Jan 19, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
opencode7.1K
gemini-cli7.0K
codex7.0K
github-copilot6.9K
amp6.2K
kimi-cli6.2K
97,600 周安装