nestjs

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

NestJS Framework Expert

NestJS 框架专家

Category

分类

Backend & Frameworks
后端与框架

⚠️ MANDATORY COMPLIANCE ⚠️

⚠️ 强制合规要求 ⚠️

CRITICAL: The 6-step workflow outlined in this document MUST be followed in exact order for EVERY NestJS engagement. Skipping steps or deviating from the procedure will result in incomplete or unsafe guidance. This is non-negotiable.
关键提示:所有NestJS相关工作必须严格遵循本文档中列出的6步工作流顺序执行。跳过步骤或偏离流程将导致指导不完整或存在安全风险,这是不可协商的要求。

File Structure

文件结构

  • SKILL.md (this file): Main instructions and MANDATORY workflow
  • SKILL.md(本文档):主要说明与强制工作流

Step 1: Initial Analysis

步骤1:初始分析

Gather inputs and determine scope and requirements.
收集输入信息,确定范围与需求。

Step 2: Load Memory

步骤2:加载内存数据

Load project-specific memory via MemoryStore interface.
通过MemoryStore接口加载项目特定的内存数据。

Step 3: Load Context

步骤3:加载上下文

Load relevant context files via ContextProvider interface.
通过ContextProvider接口加载相关上下文文件。

Step 4: Core Implementation

步骤4:核心实现

Execute the skill-specific core action.
执行技能专属的核心操作。

Step 5: Generate Output

步骤5:生成输出

Create deliverables and save to
/claudedocs/
following OUTPUT_CONVENTIONS.md.
创建交付成果,并按照OUTPUT_CONVENTIONS.md的要求保存至
/claudedocs/
目录。

Step 6: Update Memory

步骤6:更新内存数据

Update project memory with new patterns and decisions.
将新的模式与决策更新到项目内存中。

Interface References

接口参考

  • Context: Loaded via ContextProvider Interface
  • Memory: Accessed via MemoryStore Interface
  • Shared Patterns: Shared Loading Patterns
  • Context:通过ContextProvider 接口加载
  • Memory:通过MemoryStore 接口访问
  • 共享模式共享加载模式

Focus Areas

重点关注领域

  1. Module Architecture: feature modules, shared modules, dependency boundaries
  2. Controllers & Providers: DI scopes, service layering, lifecycle hooks
  3. Validation & DTOs: class-validator, pipes, transformation
  4. Data Access: TypeORM/Prisma patterns, transactions, migrations
  5. Security: guards, auth strategies, rate limiting, secrets
  6. Messaging: microservices, queues, event-driven patterns
  7. Testing: unit + e2e setup, test modules, mocking

  1. 模块架构:功能模块、共享模块、依赖边界
  2. 控制器与提供者:DI作用域、服务分层、生命周期钩子
  3. 验证与DTO:class-validator、管道、转换处理
  4. 数据访问:TypeORM/Prisma模式、事务、迁移
  5. 安全:守卫、认证策略、速率限制、密钥管理
  6. 消息传递:微服务、队列、事件驱动模式
  7. 测试:单元测试+端到端测试配置、测试模块、模拟实现

Purpose

目的

Enterprise-grade NestJS development guidance for building modular, testable Node.js backends with TypeScript. Covers module design, dependency injection, validation, security, performance, and deployment.
面向企业级的NestJS开发指南,用于构建基于TypeScript的模块化、可测试的Node.js后端。内容涵盖模块设计、依赖注入、验证、安全、性能优化与部署。

MANDATORY WORKFLOW (MUST FOLLOW EXACTLY)

强制工作流(必须严格遵循)

⚠️ STEP 1: Scope the NestJS Engagement (REQUIRED)

⚠️ 步骤1:确定NestJS项目范围(必填)

YOU MUST:
  1. Identify NestJS version and runtime environment
  2. Clarify the domain (API, microservice, hybrid) and deployment target
  3. Determine ORM/transport stack (TypeORM, Prisma, Redis, RabbitMQ)
  4. Ask clarifying questions about auth, messaging, and module boundaries
  5. Think through your implementation plan in a
    <thinking>
    block before writing any files or recommending changes
DO NOT PROCEED WITHOUT A CLEAR SCOPE AND PLAN
你必须:
  1. 确认NestJS版本与运行环境
  2. 明确业务领域(API、微服务、混合架构)与部署目标
  3. 确定ORM/传输栈(TypeORM、Prisma、Redis、RabbitMQ)
  4. 询问关于认证、消息传递与模块边界的澄清问题
  5. 在编写任何文件或提出修改建议前,在
    <thinking>
    块中梳理你的实现计划
未明确范围与计划前,不得继续推进

⚠️ STEP 2: Load Project Memory (REQUIRED)

⚠️ 步骤2:加载项目内存数据(必填)

YOU MUST:
  1. Load memory with
    memoryStore.getSkillMemory("nestjs", "{project-name}")
  2. Review cross-skill memory with
    memoryStore.getByProject("{project-name}")
  3. Note existing module conventions and integrations
DO NOT PROCEED WITHOUT CHECKING MEMORY
你必须:
  1. 通过
    memoryStore.getSkillMemory("nestjs", "{project-name}")
    加载内存数据
  2. 通过
    memoryStore.getByProject("{project-name}")
    查看跨技能内存数据
  3. 记录现有的模块约定与集成情况
未检查内存数据前,不得继续推进

⚠️ STEP 3: Load Context (REQUIRED)

⚠️ 步骤3:加载上下文(必填)

YOU MUST:
  1. Use
    contextProvider.getDomainIndex("engineering")
    for general architecture patterns
  2. Pull security context with
    contextProvider.getCrossDomainContext("engineering", ["auth", "security"])
  3. Stay within the declared file budget
DO NOT PROCEED WITHOUT RELEVANT CONTEXT
你必须:
  1. 使用
    contextProvider.getDomainIndex("engineering")
    获取通用架构模式
  2. 通过
    contextProvider.getCrossDomainContext("engineering", ["auth", "security"])
    获取安全上下文
  3. 严格遵守已声明的文件预算
未加载相关上下文前,不得继续推进

⚠️ STEP 4: Analyze Architecture & Code Paths (REQUIRED)

⚠️ 步骤4:分析架构与代码路径(必填)

YOU MUST:
  1. Review module boundaries, controller routes, and provider scopes
  2. Inspect DTO validation, pipes, and exception filters
  3. Evaluate data access patterns and transaction handling
  4. Check integration points (queues, caches, external services)
DO NOT PROCEED WITHOUT A COMPLETE ANALYSIS
你必须:
  1. 检查模块边界、控制器路由与提供者作用域
  2. 审查DTO验证、管道与异常过滤器
  3. 评估数据访问模式与事务处理
  4. 检查集成点(队列、缓存、外部服务)
未完成完整分析前,不得继续推进

⚠️ STEP 5: Provide NestJS Guidance (REQUIRED)

⚠️ 步骤5:提供NestJS指导建议(必填)

YOU MUST:
  1. Recommend module restructuring or DI improvements
  2. Provide validation, security, and testing guidance
  3. Suggest performance or messaging enhancements
DO NOT PROVIDE GENERIC OR UNSUPPORTED RECOMMENDATIONS
你必须:
  1. 建议模块重构或依赖注入优化方案
  2. 提供验证、安全与测试相关指导
  3. 提出性能优化或消息传递增强建议
不得提供通用或无依据的建议

⚠️ STEP 6: Generate Output & Update Memory (REQUIRED)

⚠️ 步骤6:生成输出并更新内存数据(必填)

YOU MUST:
  1. Produce a structured report in
    /claudedocs/nestjs_{project}_{YYYY-MM-DD}.md
  2. Follow the naming conventions in
    ../OUTPUT_CONVENTIONS.md
  3. Update memory with
    memoryStore.update("nestjs", "{project-name}", ...)
    :
    • project_overview.md
    • module_map.md
    • integration_notes.md
    • testing_strategy.md
DO NOT FINISH WITHOUT SAVING OUTPUT AND UPDATING MEMORY

你必须:
  1. /claudedocs/nestjs_{project}_{YYYY-MM-DD}.md
    路径下生成结构化报告
  2. 遵循
    ../OUTPUT_CONVENTIONS.md
    中的命名规范
  3. 通过
    memoryStore.update("nestjs", "{project-name}", ...)
    更新内存数据:
    • project_overview.md
    • module_map.md
    • integration_notes.md
    • testing_strategy.md
未保存输出与更新内存数据前,不得结束任务

Compliance Checklist

合规检查清单

Before completing ANY NestJS task, verify:
  • Step 1: Scope defined and plan documented in
    <thinking>
  • Step 2: Project memory loaded via
    memoryStore.getSkillMemory()
  • Step 3: Context loaded via
    contextProvider
  • Step 4: Architecture and code paths analyzed
  • Step 5: NestJS guidance provided with actionable recommendations
  • Step 6: Output saved to
    /claudedocs/
    and memory updated
FAILURE TO COMPLETE ALL STEPS INVALIDATES THE GUIDANCE

在完成任何NestJS任务前,请验证:
  • 步骤1:已定义范围并在
    <thinking>
    中记录计划
  • 步骤2:已通过
    memoryStore.getSkillMemory()
    加载项目内存数据
  • 步骤3:已通过
    contextProvider
    加载上下文
  • 步骤4:已完成架构与代码路径分析
  • 步骤5:已提供NestJS指导建议与可执行方案
  • 步骤6:已将输出保存至
    /claudedocs/
    并更新内存数据
未完成所有步骤的指导建议视为无效

Version History

版本历史

VersionDateChanges
1.0.02026-02-12Initial release for NestJS framework guidance
版本日期变更内容
1.0.02026-02-12首次发布NestJS框架指导文档