tech-design-doc
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseTechnical Design Document Skill
技术设计文档Skill
When to Use
适用场景
- Designing a new feature or system
- Documenting architecture decisions (ADR/RFC)
- Planning refactoring or optimization work
- 设计新功能或系统
- 记录架构决策(ADR/RFC)
- 规划重构或优化工作
Execution Flow
执行流程
1. Assess Complexity
1. 评估复杂度
| Level | Scope | Sections Required |
|---|---|---|
| Small | Single component, <100 LOC | TL;DR, Design, Implementation |
| Medium | Cross-component, API changes | + Background, Solution Analysis |
| Large | System-level, new service | Full template |
| 级别 | 范围 | 所需章节 |
|---|---|---|
| 小型 | 单一组件,代码量<100行 | TL;DR、设计、实现 |
| 中型 | 跨组件、涉及API变更 | + 背景、方案分析 |
| 大型 | 系统级、新增服务 | 完整模板 |
2. Gather Context
2. 收集上下文信息
Before writing, explore the codebase:
- Identify affected components (grep/glob for related code)
- Read existing implementations and patterns
- Note dependencies and potential side effects
- Check for similar solutions already in codebase
在撰写前,先梳理代码库:
- 确定受影响的组件(使用grep/glob查找相关代码)
- 阅读现有实现和模式
- 记录依赖关系和潜在副作用
- 检查代码库中是否已有类似解决方案
3. Write Document
3. 撰写文档
Follow the template structure below, scaled to complexity level.
按照以下模板结构撰写,根据复杂度级别调整内容范围。
4. Verify Before Handoff
4. 交付前验证
- Problem clearly defined (what breaks if we do nothing?)
- Options compared with trade-offs (not just one solution)
- Decision rationale documented
- Diagrams illustrate key flows
- Implementation steps are concrete and actionable
- Risks identified with mitigations
- 问题定义清晰(如果不处理会有什么问题?)
- 对比了多种方案并说明取舍(不只是单一方案)
- 记录了决策依据
- 图表清晰展示关键流程
- 实现步骤具体且可执行
- 识别了风险并给出缓解措施
Document Template
文档模板
markdown
undefinedmarkdown
undefined[Feature/System Name] Technical Design
[功能/系统名称] 技术设计
TL;DR
TL;DR
- 3-5 bullets: problem, solution, key decisions, expected outcome
- 3-5条要点:问题、解决方案、关键决策、预期成果
Background (Medium/Large)
背景(中型/大型项目适用)
Current State
当前状态
- Existing behavior and limitations
- 现有行为和局限性
Problem Statement
问题陈述
- What breaks if we do nothing?
- Who is affected and how?
- 如果不处理会产生什么问题?
- 受影响的对象及影响方式?
Goals / Non-Goals
目标/非目标
- Goals: what this design achieves
- Non-Goals: explicitly out of scope
- 目标:本设计要达成的内容
- 非目标:明确排除在范围外的内容
Solution Analysis (Medium/Large)
方案分析(中型/大型项目适用)
Option 1: [Name]
方案1:[名称]
Pros: ...
Cons: ...
优点:...
缺点:...
Option 2: [Name]
方案2:[名称]
Pros: ...
Cons: ...
优点:...
缺点:...
Comparison
对比
| Criteria | Option 1 | Option 2 |
|---|---|---|
| Performance | ... | ... |
| Complexity | ... | ... |
| 评估维度 | 方案1 | 方案2 |
|---|---|---|
| 性能 | ... | ... |
| 复杂度 | ... | ... |
Recommendation
推荐方案
Selected: Option X
Rationale: [why]
选定:方案X
依据:[原因]
Detailed Design
详细设计
Architecture
架构
[Mermaid diagram - see examples below]
[Mermaid图表 - 见下方示例]
Component Design
组件设计
- Responsibilities
- Interfaces
- Dependencies
- 职责
- 接口
- 依赖关系
Data Model (if applicable)
数据模型(如适用)
[Schema or structure]
[Schema或结构]
API Design (if applicable)
API设计(如适用)
[Endpoints, request/response]
[接口、请求/响应格式]
Implementation Plan
实施计划
Phase 1: [Name]
阶段1:[名称]
- Task 1
- Task 2
- 任务1
- 任务2
Migration Strategy (if applicable)
迁移策略(如适用)
Risk Assessment
风险评估
| Risk | Probability | Impact | Mitigation |
|---|---|---|---|
| ... | High/Med/Low | High/Med/Low | ... |
| 风险 | 概率 | 影响 | 缓解措施 |
|---|---|---|---|
| ... | 高/中/低 | 高/中/低 | ... |
References
参考资料
- Related docs, external resources
undefined- 相关文档、外部资源
undefinedMermaid Diagram Examples
Mermaid图表示例
Architecture (flowchart):
mermaid
flowchart TD
A[Client] --> B[API Gateway]
B --> C[Service]
C --> D[(Database)]Sequence:
mermaid
sequenceDiagram
Client->>Server: Request
Server->>DB: Query
DB-->>Server: Result
Server-->>Client: ResponseState:
mermaid
stateDiagram-v2
[*] --> Pending
Pending --> Processing: start
Processing --> Done: complete
Processing --> Failed: error架构(流程图):
mermaid
flowchart TD
A[Client] --> B[API Gateway]
B --> C[Service]
C --> D[(Database)]时序图:
mermaid
sequenceDiagram
Client->>Server: Request
Server->>DB: Query
DB-->>Server: Result
Server-->>Client: Response状态图:
mermaid
stateDiagram-v2
[*] --> Pending
Pending --> Processing: start
Processing --> Done: complete
Processing --> Failed: errorHandling Feedback
反馈处理
When user requests changes:
- Understand which section needs revision
- Update only affected sections
- Ensure changes don't contradict other sections
- Re-verify the checklist items related to changes
当用户要求修改时:
- 明确需要修订的章节
- 仅更新受影响的章节
- 确保修改内容与其他章节不矛盾
- 重新验证与修改内容相关的检查项
Output Location
输出位置
- Check if project has ,
docs/, orai_docs/directorydesign/ - Ask user if location is unclear
- Use descriptive filename:
design-[feature-name].md
- 检查项目是否有、
docs/或ai_docs/目录design/ - 若位置不明确,询问用户
- 使用描述性文件名:
design-[feature-name].md