nestjs-best-practices by xirothedev/agent-skills
npx skills add https://github.com/xirothedev/agent-skills --skill nestjs-best-practices构建生产就绪型 NestJS 应用程序的全面指南。包含 13 个类别下的 26 条规则,涵盖安全性、架构、性能、验证、数据库操作、身份验证和高级模式。
在以下情况下参考这些指南:
| 优先级 | 类别 | 影响 | 前缀 |
|---|---|---|---|
| 1 | 安全性 | 关键 | security- |
| 2 | 性能 | 高 | performance- |
| 3 | 架构 |
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
| 高 |
architecture- |
| 4 | 错误处理 | 高 | error-handling- |
| 5 | 验证 | 关键 | validation- |
| 6 | 数据库 | 关键 | database- |
| 7 | 身份验证 | 关键 | auth- |
| 8 | API | 中 | api- |
| 9 | 配置 | 关键 | config- |
| 10 | 测试 | 中 | testing- |
| 11 | 部署 | 中 | deployment- |
| 12 | 中间件 | 中 | middleware- |
| 13 | 高级 | 高 | advanced- |
security-cors-whitelist - 仅启用白名单来源的 CORSsecurity-dependency-audit - 使用 bun 定期进行依赖项安全审计security-helmet-headers - 使用 Helmet 中间件设置安全头performance-redis-caching - 使用 Redis 缓存频繁使用的数据architecture-short-functions - 保持函数简短且单一职责architecture-feature-modules - 按功能模块组织代码architecture-no-dead-code - 移除未使用的代码和依赖项architecture-thin-controllers - 单一职责 - 分离控制器和服务architecture-naming-conventions - 使用一致的命名约定architecture-event-driven - 使用事件驱动架构实现松耦合error-handling-exception-filter - 启用全局异常过滤器error-handling-structured-logging - 实施适当的日志记录策略validation-custom-pipes - 为查询参数转换创建自定义管道validation-dto-validation - 使用 DTO 和 ValidationPipe 验证所有输入database-parameterized-queries - 使用参数化查询防止 SQL 注入(Prisma v7)auth-password-hashing - 使用 Bun 内置的 Crypto 进行安全的密码哈希(argon2/bcrypt)auth-route-guards - 使用守卫保护路由api-cursor-pagination - 对大型数据集使用基于游标的分页api-swagger-docs - 生成 Swagger/OpenAPI 文档config-no-secrets - 切勿硬编码密钥 - 使用环境变量testing-unit-tests - 编写全面的单元测试deployment-health-checks - 实现健康检查端点middleware-compression - 为响应启用压缩中间件middleware-rate-limiting - 为所有路由实现速率限制advanced-lazy-loading - 延迟加载非关键模块advanced-scheduled-tasks - 使用 @nestjs/schedule 处理 cron 作业和计划任务阅读各个规则文件以获取详细说明和代码示例:
rules/security-cors-whitelist.md
rules/auth-route-guards.md
rules/validation-dto-validation.md
rules/_sections.md
每个规则文件包含:
bun add 的安装命令所有规则都针对 AI 智能体进行了优化,包含:
src/users/users.service.ts)获取包含所有规则详细说明的完整指南:AGENTS.md
cd packages/nestjs-best-practices-build
bun install
bun run build # 生成 AGENTS.md
bun run validate # 验证规则文件
bun run dev # 构建并验证
每周安装量
104
代码仓库
GitHub 星标数
13
首次出现
2026年1月20日
安全审计
已安装于
gemini-cli92
opencode91
codex89
cursor88
github-copilot84
amp75
Comprehensive guide for building production-ready NestJS applications. Contains 26 rules across 13 categories, covering security, architecture, performance, validation, database operations, authentication, and advanced patterns.
Reference these guidelines when:
| Priority | Category | Impact | Prefix |
|---|---|---|---|
| 1 | Security | CRITICAL | security- |
| 2 | Performance | HIGH | performance- |
| 3 | Architecture | HIGH | architecture- |
| 4 | Error Handling | HIGH | error-handling- |
| 5 | Validation | CRITICAL | validation- |
| 6 | Database | CRITICAL | database- |
| 7 | Authentication | CRITICAL | auth- |
| 8 | API | MEDIUM | api- |
| 9 | Configuration | CRITICAL | config- |
| 10 | Testing | MEDIUM | testing- |
| 11 | Deployment | MEDIUM | deployment- |
| 12 | Middleware | MEDIUM | middleware- |
| 13 | Advanced | HIGH | advanced- |
security-cors-whitelist - Enable CORS with whitelist origins onlysecurity-dependency-audit - Regular dependency security audits with bunsecurity-helmet-headers - Use Helmet middleware for security headersperformance-redis-caching - Cache frequently used data with Redisarchitecture-short-functions - Keep functions short and single purposearchitecture-feature-modules - Organize code by feature modulesarchitecture-no-dead-code - Remove unused code and dependenciesarchitecture-thin-controllers - Single responsibility - separate controller and servicearchitecture-naming-conventions - Use consistent naming conventionsarchitecture-event-driven - Use event-driven architecture for loose couplingerror-handling-exception-filter - Enable global exception filtererror-handling-structured-logging - Implement proper logging strategyvalidation-custom-pipes - Create custom pipes for query parameter transformationvalidation-dto-validation - Validate all inputs with DTOs and ValidationPipedatabase-parameterized-queries - Use parameterized queries to prevent SQL injection (Prisma v7)auth-password-hashing - Use Bun's built-in Crypto for secure password hashing (argon2/bcrypt)auth-route-guards - Use guards for route protectionapi-cursor-pagination - Use cursor-based pagination for large datasetsapi-swagger-docs - Generate Swagger/OpenAPI documentationconfig-no-secrets - Never hardcode secrets - use environment variablestesting-unit-tests - Write comprehensive unit testsdeployment-health-checks - Implement health check endpointsmiddleware-compression - Enable compression middleware for responsesmiddleware-rate-limiting - Implement rate limiting for all routesadvanced-lazy-loading - Lazy load non-critical modulesadvanced-scheduled-tasks - Use @nestjs/schedule for cron jobs and scheduled tasksRead individual rule files for detailed explanations and code examples:
rules/security-cors-whitelist.md
rules/auth-route-guards.md
rules/validation-dto-validation.md
rules/_sections.md
Each rule file contains:
bun addAll rules are optimized for AI agents with:
src/users/users.service.ts)For the complete guide with all rules expanded: AGENTS.md
cd packages/nestjs-best-practices-build
bun install
bun run build # Generate AGENTS.md
bun run validate # Validate rule files
bun run dev # Build and validate
Weekly Installs
104
Repository
GitHub Stars
13
First Seen
Jan 20, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
gemini-cli92
opencode91
codex89
cursor88
github-copilot84
amp75
Node.js 环境配置指南:多环境管理、类型安全与最佳实践
10,500 周安装
Firecrawl Search:支持内容抓取的网络搜索工具,JSON格式返回结果
13,900 周安装
Firebase Authentication 身份验证基础教程 - 用户管理与安全登录配置指南
14,800 周安装
Claude 文件规划技能:使用 Markdown 文件作为持久工作记忆,提升 AI 协作效率
14,000 周安装
Obsidian Bases 插件教程:创建自定义数据库视图,高效管理知识库笔记
14,300 周安装
Firecrawl Scrape:智能网页抓取工具,一键提取LLM优化Markdown内容
14,200 周安装
Firebase 基础入门指南:环境设置、CLI 使用与最佳实践
15,000 周安装