bugfix-workflow
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseBugfix 工作流通用知识库
General Bugfix Workflow Knowledge Base
本 Skill 提供标准化 6 阶段 Bugfix 工作流的通用知识,适用于所有技术栈。
This Skill provides general knowledge of the standardized 6-phase Bugfix workflow, applicable to all tech stacks.
TDD 流程(核心原则)
TDD Process (Core Principles)
RED Phase(先写失败测试)
RED Phase (Write failing tests first)
- 测试必须能复现当前 bug
- 测试必须在修复前失败
- 测试应该测试行为,不是实现
验证命令模板:
bash
make test TARGET={stack} FILTER={test_file}- Tests must reproduce the current bug
- Tests must fail before the fix
- Tests should verify behavior, not implementation
Verification command template:
bash
make test TARGET={stack} FILTER={test_file}GREEN Phase(最小实现)
GREEN Phase (Minimal implementation)
- 只写让测试通过的最小代码
- 不要在此阶段优化
- 不要添加未被测试覆盖的功能
- Only write the minimal code required to pass the tests
- Do not optimize during this phase
- Do not add features not covered by tests
REFACTOR Phase(重构)
REFACTOR Phase (Refactoring)
- 改善代码结构
- 保持测试通过
- 消除重复代码
最终验证:
bash
make test TARGET={stack}
make lint TARGET={stack}
make typecheck TARGET={stack}- Improve code structure
- Keep tests passing
- Eliminate duplicate code
Final verification:
bash
make test TARGET={stack}
make lint TARGET={stack}
make typecheck TARGET={stack}置信度评分标准
Confidence Scoring Standards
根因分析置信度
Root Cause Analysis Confidence
| 分数范围 | 行为 |
|---|---|
| ≥60 | 自动继续 |
| 40-59 | 暂停询问用户 |
| <40 | 停止并收集更多信息 |
| Score Range | Action |
|---|---|
| ≥60 | Proceed automatically |
| 40-59 | Pause and ask user |
| <40 | Stop and collect more information |
代码审查置信度
Code Review Confidence
| 分数范围 | 级别 | 行为 |
|---|---|---|
| ≥90 | Critical | 自动修复 |
| 80-89 | Important | 自动修复 |
| <80 | 低于阈值 | 不报告 |
| Score Range | Level | Action |
|---|---|---|
| ≥90 | Critical | Auto-fix |
| 80-89 | Important | Auto-fix |
| <80 | Below threshold | Do not report |
通用输出格式
General Output Format
Error 结构
Error Structure
json
{
"id": "BF-{YYYY}-{MMDD}-{NNN}",
"file": "文件路径",
"line": 行号,
"severity": "critical|high|medium|low",
"category": "错误类型",
"description": "问题描述",
"evidence": ["支持判断的证据"],
"stack": "堆栈信息"
}json
{
"id": "BF-{YYYY}-{MMDD}-{NNN}",
"file": "File path",
"line": Line number,
"severity": "critical|high|medium|low",
"category": "Error type",
"description": "Issue description",
"evidence": ["Evidence supporting the judgment"],
"stack": "Stack trace"
}Summary 结构
Summary Structure
json
{
"total": 总数,
"by_type": { "类型": 数量 },
"by_file": { "文件": 数量 }
}json
{
"total": Total count,
"by_type": { "Type": Count },
"by_file": { "File": Count }
}Solution 结构
Solution Structure
json
{
"solution": {
"approach": "修复思路概述",
"steps": ["步骤1", "步骤2"],
"risks": ["风险1", "风险2"],
"estimated_complexity": "low|medium|high"
},
"tdd_plan": {
"red_phase": { "tests": [...] },
"green_phase": { "changes": [...] },
"refactor_phase": { "items": [...] }
},
"impact_analysis": {
"affected_files": [...],
"api_changes": [...],
"test_impact": [...]
},
"security_review": {
"performed": true/false,
"vulnerabilities": [...],
"passed": true/false
}
}json
{
"solution": {
"approach": "Overview of fix思路",
"steps": ["Step 1", "Step 2"],
"risks": ["Risk 1", "Risk 2"],
"estimated_complexity": "low|medium|high"
},
"tdd_plan": {
"red_phase": { "tests": [...] },
"green_phase": { "changes": [...] },
"refactor_phase": { "items": [...] }
},
"impact_analysis": {
"affected_files": [...],
"api_changes": [...],
"test_impact": [...]
},
"security_review": {
"performed": true/false,
"vulnerabilities": [...],
"passed": true/false
}
}Execution Result 结构
Execution Result Structure
json
{
"issue_id": "BF-2025-MMDD-001",
"phases": {
"red": { "status": "pass|fail|skip", "duration_ms": 1234 },
"green": { "status": "pass|fail|skip", "changes": [...] },
"refactor": { "status": "pass|fail|skip", "changes": [...] }
},
"overall_status": "success|partial|failed"
}json
{
"issue_id": "BF-2025-MMDD-001",
"phases": {
"red": { "status": "pass|fail|skip", "duration_ms": 1234 },
"green": { "status": "pass|fail|skip", "changes": [...] },
"refactor": { "status": "pass|fail|skip", "changes": [...] }
},
"overall_status": "success|partial|failed"
}影响分析维度
Impact Analysis Dimensions
- 直接影响:修改的文件
- 间接影响:依赖修改文件的组件
- API 影响:是否有破坏性变更
- 测试影响:需要更新的测试
- Direct Impact: Modified files
- Indirect Impact: Components dependent on modified files
- API Impact: Whether there are breaking changes
- Test Impact: Tests that need to be updated
安全审查清单(常见安全问题)
Security Review Checklist (Common Security Issues)
仅在涉及敏感代码(认证、输入处理、数据存储等)时进行:
- SQL/命令注入
- XSS 跨站脚本
- 敏感信息泄露
- 认证/授权问题
- 输入验证不足
Perform only when involving sensitive code (authentication, input handling, data storage, etc.):
- SQL/Command injection
- XSS Cross-site scripting
- Sensitive information leakage
- Authentication/Authorization issues
- Insufficient input validation
批次执行策略
Batch Execution Strategy
- 默认批次大小:3 个问题/批
- 每批完成后:输出批次报告,等待用户确认
- 失败处理:记录失败原因,尝试最多 3 次,3 次失败后标记为 failed
- Default batch size: 3 issues per batch
- After each batch completion: Output batch report and wait for user confirmation
- Failure handling: Record failure reason, retry up to 3 times, mark as failed after 3 failures
Bugfix 文档模板
Bugfix Documentation Template
markdown
undefinedmarkdown
undefined[问题简述] Bugfix 报告
[Issue Brief] Bugfix Report
日期:{YYYY-MM-DD} 置信度:{confidence}/100 技术栈:{stack}
Date: {YYYY-MM-DD} Confidence: {confidence}/100 Tech stack: {stack}
1. 问题描述
1. Issue Description
1.1 错误信息
1.1 Error Messages
[结构化错误列表]
[Structured error list]
1.2 根因分析
1.2 Root Cause Analysis
[根因描述 + 证据]
[Root cause description + evidence]
2. 修复方案
2. Fix Solution
2.1 TDD 计划
2.1 TDD Plan
RED Phase
RED Phase
[失败测试代码]
[Failing test code]
GREEN Phase
GREEN Phase
[最小实现代码]
[Minimal implementation code]
REFACTOR Phase
REFACTOR Phase
- 重构项
- Refactoring items
2.2 影响分析
2.2 Impact Analysis
[影响范围]
[Impact scope]
3. 验证计划
3. Verification Plan
- 测试通过
- 覆盖率达标
- 无回归
undefined- Tests passed
- Coverage meets standard
- No regression
undefined知识沉淀标准
Knowledge Precipitation Standards
值得沉淀的知识
Knowledge Worth Precipitating
- 新发现的问题模式 - 之前没有记录的错误类型
- 可复用的解决方案 - 适用于多种场景的修复模式
- 重要的教训 - 容易犯的错误,反直觉的行为
- 性能优化 - 测试执行速度提升
- Newly discovered issue patterns - Error types not documented before
- Reusable solutions - Fix patterns applicable to multiple scenarios
- Important lessons - Common mistakes, counterintuitive behaviors
- Performance optimization - Test execution speed improvements
不需要沉淀的情况
Cases Not Needing Precipitation
- 一次性问题 - 特定于某个文件的 typo
- 已有文档覆盖 - 问题已在 troubleshooting 中记录
- One-time issues - Typos specific to a single file
- Already covered by existing documentation - Issue already recorded in troubleshooting
质量门禁标准
Quality Gate Standards
| 检查项 | 标准 | 阻塞级别 |
|---|---|---|
| 测试通过 | 100% | 阻塞 |
| 覆盖率 | >= 90% | 阻塞 |
| 新代码覆盖率 | 100% | 阻塞 |
| Lint | 无错误 | 阻塞 |
| TypeCheck | 无错误 | 阻塞 |
| 回归测试 | 无回归 | 阻塞 |
| Check Item | Standard | Blocking Level |
|---|---|---|
| Test Pass Rate | 100% | Blocking |
| Coverage | >= 90% | Blocking |
| New Code Coverage | 100% | Blocking |
| Lint | No errors | Blocking |
| TypeCheck | No errors | Blocking |
| Regression Test | No regression | Blocking |