cc-devflow 1.0.3 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/CLAUDE.md +123 -4
- package/.claude/agents/code-quality-reviewer.md +205 -0
- package/.claude/agents/spec-reviewer.md +221 -0
- package/.claude/commands/cancel-ralph.md +59 -0
- package/.claude/commands/flow-dev.md +202 -21
- package/.claude/commands/flow-epic.md +33 -0
- package/.claude/commands/flow-fix.md +138 -20
- package/.claude/commands/flow-init.md +104 -15
- package/.claude/commands/flow-new.md +84 -35
- package/.claude/commands/flow-prd.md +16 -3
- package/.claude/commands/flow-release.md +33 -0
- package/.claude/commands/flow-review.md +257 -0
- package/.claude/docs/templates/ATTEMPT_TEMPLATE.md +156 -0
- package/.claude/docs/templates/BRAINSTORM_TEMPLATE.md +148 -0
- package/.claude/docs/templates/ERROR_LOG_TEMPLATE.md +80 -0
- package/.claude/docs/templates/INIT_FLOW_TEMPLATE.md +22 -14
- package/.claude/guides/workflow-guides/flow-orchestrator.md +2 -2
- package/.claude/hooks/hooks.json +15 -0
- package/.claude/hooks/ralph-stop-hook.sh +190 -0
- package/.claude/rules/devflow-conventions.md +3 -1
- package/.claude/rules/project-constitution.md +256 -2
- package/.claude/rules/rationalization-library.md +282 -0
- package/.claude/scripts/create-requirement.sh +19 -6
- package/.claude/scripts/setup-ralph-loop.sh +155 -0
- package/.claude/scripts/verify-gate.sh +269 -0
- package/.claude/skills/cc-devflow-orchestrator/SKILL.md +70 -20
- package/.claude/skills/file-header-guardian/SKILL.md +56 -0
- package/.claude/skills/flow-attention-refresh/SKILL.md +170 -0
- package/.claude/skills/flow-brainstorming/SKILL.md +161 -0
- package/.claude/skills/flow-debugging/SKILL.md +221 -0
- package/.claude/skills/flow-finishing-branch/SKILL.md +189 -0
- package/.claude/skills/flow-receiving-review/SKILL.md +153 -0
- package/.claude/skills/flow-tdd/SKILL.md +218 -0
- package/.claude/skills/fractal-docs-generator/SKILL.md +45 -0
- package/.claude/skills/skill-rules.json +75 -0
- package/.claude/skills/verification-before-completion/SKILL.md +158 -0
- package/README.md +104 -19
- package/README.zh-CN.md +79 -1
- package/docs/commands/flow-init.md +3 -1
- package/docs/commands/flow-init.zh-CN.md +3 -1
- package/package.json +1 -1
- package/.claude/tsc-cache/777aa1de-497e-411b-a40f-13b74efcec58/affected-repos.txt +0 -1
|
@@ -1,28 +1,99 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: flow-dev
|
|
3
|
-
description: 'Execute development tasks following TDD order. Usage: /flow-dev "REQ-123"
|
|
3
|
+
description: 'Execute development tasks following TDD order. Usage: /flow-dev "REQ-123" [--manual] [--max-iterations N]'
|
|
4
4
|
scripts:
|
|
5
5
|
prereq: .claude/scripts/check-prerequisites.sh
|
|
6
6
|
check_tasks: .claude/scripts/check-task-status.sh
|
|
7
7
|
mark_task: .claude/scripts/mark-task-complete.sh
|
|
8
8
|
validate_constitution: .claude/scripts/validate-constitution.sh
|
|
9
|
+
verify_gate: .claude/scripts/verify-gate.sh
|
|
10
|
+
setup_loop: .claude/scripts/setup-ralph-loop.sh
|
|
11
|
+
skills:
|
|
12
|
+
tdd: .claude/skills/flow-tdd/SKILL.md
|
|
13
|
+
verification: .claude/skills/verification-before-completion/SKILL.md
|
|
14
|
+
attention: .claude/skills/flow-attention-refresh/SKILL.md
|
|
9
15
|
---
|
|
10
16
|
|
|
11
17
|
# Flow-Dev - 开发执行命令
|
|
12
18
|
|
|
19
|
+
## TDD Iron Law (新增)
|
|
20
|
+
|
|
21
|
+
参考 `{SKILL:tdd}`:
|
|
22
|
+
|
|
23
|
+
```
|
|
24
|
+
NO PRODUCTION CODE WITHOUT A FAILING TEST FIRST
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### TDD Checkpoint
|
|
28
|
+
|
|
29
|
+
在 Phase 2 (Tests) 和 Phase 3 (Implementation) 之间,必须执行:
|
|
30
|
+
|
|
31
|
+
```yaml
|
|
32
|
+
⚠️ TEST VERIFICATION CHECKPOINT:
|
|
33
|
+
1. 运行所有 Phase 2 测试
|
|
34
|
+
→ npm test (或 quickstart 中的测试命令)
|
|
35
|
+
|
|
36
|
+
2. 验证所有新测试 FAIL
|
|
37
|
+
→ 如果任何测试 PASS → STOP
|
|
38
|
+
→ 通过的测试 = 无效测试或代码已存在
|
|
39
|
+
|
|
40
|
+
3. 只有全部 FAIL 后才能进入 Phase 3
|
|
41
|
+
|
|
42
|
+
4. 如果已经写了实现代码:
|
|
43
|
+
→ DELETE 代码
|
|
44
|
+
→ 重新从 failing tests 开始
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Rationalization Prevention
|
|
48
|
+
|
|
49
|
+
| Excuse | Reality |
|
|
50
|
+
|--------|---------|
|
|
51
|
+
| "Tests are ready, let's implement" | Run tests first. Verify they FAIL. |
|
|
52
|
+
| "I'll run tests after implementation" | That's testing-after, not TDD. |
|
|
53
|
+
| "Test passed, that's good" | Test passing before implementation = invalid test. |
|
|
54
|
+
| "Just this once" | No exceptions. TDD is non-negotiable. |
|
|
55
|
+
|
|
13
56
|
## User Input
|
|
14
57
|
```text
|
|
15
|
-
$ARGUMENTS = "REQ_ID? [--task T###]"
|
|
58
|
+
$ARGUMENTS = "REQ_ID? [--task T###] [--manual] [--max-iterations N]"
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
- **REQ_ID**: 未提供时从当前分支或 `DEVFLOW_REQ_ID` 推断
|
|
62
|
+
- **--task T###**: 指定起始任务(从该任务开始执行)
|
|
63
|
+
- **--manual**: Manual模式,遇错停止等待人工修复(向后兼容)
|
|
64
|
+
- **--max-iterations N**: Autonomous模式最大迭代次数(默认10)
|
|
65
|
+
|
|
66
|
+
**默认行为**: Autonomous模式(自动重试直到完成)
|
|
67
|
+
|
|
68
|
+
### 运行模式对比
|
|
69
|
+
|
|
70
|
+
| | Manual模式 | Autonomous模式(默认) |
|
|
71
|
+
|--|------------|----------------------|
|
|
72
|
+
| 触发方式 | `--manual` | 默认(或指定 `--max-iterations`) |
|
|
73
|
+
| 遇到错误 | 停止,等待人工修复 | 自动重试,记录 ERROR_LOG.md |
|
|
74
|
+
| 注意力刷新 | Protocol 2(每任务) | Protocol 2 + Protocol 3(每迭代) + Protocol 4(遇错) |
|
|
75
|
+
| 适用场景 | 复杂需求需人工判断 | 清晰需求可无人值守 |
|
|
76
|
+
| 退出条件 | 任务失败可停止 | 迭代直到完成或达到上限 |
|
|
77
|
+
|
|
78
|
+
**示例**:
|
|
79
|
+
```bash
|
|
80
|
+
/flow-dev "REQ-123" # Autonomous模式,max 10 iterations
|
|
81
|
+
/flow-dev "REQ-123" --max-iterations 20 # Autonomous模式,max 20 iterations
|
|
82
|
+
/flow-dev "REQ-123" --manual # Manual模式,遇错停止
|
|
83
|
+
/flow-dev "REQ-123" --task T005 # 从 T005 开始(Autonomous模式)
|
|
84
|
+
/flow-dev "REQ-123" --task T005 --manual # 从 T005 开始(Manual模式)
|
|
16
85
|
```
|
|
17
|
-
未提供 REQ_ID 时从当前分支或 `DEVFLOW_REQ_ID` 推断;`--task` 用于指定起始任务。
|
|
18
86
|
|
|
19
87
|
## 执行流程
|
|
20
88
|
|
|
21
89
|
### 阶段 1: Entry Gate
|
|
22
90
|
```
|
|
23
|
-
1.
|
|
24
|
-
→
|
|
25
|
-
→
|
|
91
|
+
1. 解析参数
|
|
92
|
+
→ Parse: REQ_ID, --task, --manual, --max-iterations
|
|
93
|
+
→ If REQ_ID not provided: run {SCRIPT:prereq} --json --paths-only
|
|
94
|
+
→ Determine mode:
|
|
95
|
+
• --manual flag present → Manual mode
|
|
96
|
+
• Otherwise → Autonomous mode (default max_iterations = 10)
|
|
26
97
|
|
|
27
98
|
2. 校验资产
|
|
28
99
|
→ 必须存在(/flow-tech 产物):
|
|
@@ -43,7 +114,16 @@ $ARGUMENTS = "REQ_ID? [--task T###]"
|
|
|
43
114
|
→ Phase 顺序: Setup → Foundational → Phase 2 Tests First → ⚠️ Test Verification → Phase 3 Core Implementation → ...
|
|
44
115
|
→ 任务格式 `- [ ] T### [P?] [US?] Description (path)`
|
|
45
116
|
|
|
46
|
-
4.
|
|
117
|
+
4. 模式初始化
|
|
118
|
+
→ If Autonomous mode:
|
|
119
|
+
• Run: {SCRIPT:setup_loop} "${REQ_ID}" --max-iterations ${MAX_ITERATIONS}
|
|
120
|
+
• Creates .claude/ralph-loop.local.md (state file for Stop Hook)
|
|
121
|
+
• Creates ERROR_LOG.md if not exists
|
|
122
|
+
• Log to EXECUTION_LOG.md: "Starting Autonomous mode"
|
|
123
|
+
→ If Manual mode:
|
|
124
|
+
• Log to EXECUTION_LOG.md: "Starting Manual mode"
|
|
125
|
+
|
|
126
|
+
5. 起始任务
|
|
47
127
|
→ Run: {SCRIPT:check_tasks} --json
|
|
48
128
|
→ 若指定 --task,验证任务存在且未完成
|
|
49
129
|
→ 记录下一任务 ID
|
|
@@ -76,10 +156,18 @@ $ARGUMENTS = "REQ_ID? [--task T###]"
|
|
|
76
156
|
4. 在 EXECUTION_LOG.md 记录 quickstart 版本 + STYLE.md 版本(如有)
|
|
77
157
|
```
|
|
78
158
|
|
|
79
|
-
### 阶段 3:
|
|
159
|
+
### 阶段 3: 执行循环
|
|
160
|
+
|
|
161
|
+
**Manual 模式循环** (--manual):
|
|
80
162
|
```
|
|
81
163
|
For each remaining task (顺序严格遵循 TASKS.md):
|
|
82
164
|
|
|
165
|
+
**注意力刷新** (参见 {SKILL:attention} Protocol 2):
|
|
166
|
+
→ Read: TASKS.md 当前任务 T### 段落 + DoD
|
|
167
|
+
→ Read: quickstart.md 相关命令
|
|
168
|
+
→ Focus: 这个任务的验收标准是什么?
|
|
169
|
+
→ Then: 开始执行任务
|
|
170
|
+
|
|
83
171
|
1. 读取任务定义
|
|
84
172
|
→ 提取 task id、phase、文件路径、是否 [P]
|
|
85
173
|
|
|
@@ -97,21 +185,93 @@ For each remaining task (顺序严格遵循 TASKS.md):
|
|
|
97
185
|
→ 测试失败/成功状态符合阶段要求
|
|
98
186
|
→ 文件路径与任务描述一致
|
|
99
187
|
|
|
100
|
-
4.
|
|
101
|
-
→
|
|
188
|
+
4. 错误处理 (Manual 模式)
|
|
189
|
+
→ 遇到错误 → 停止执行
|
|
190
|
+
→ 提示用户修复问题
|
|
191
|
+
→ 可选:记录到 ERROR_LOG.md
|
|
192
|
+
|
|
193
|
+
5. 标记完成 (CRITICAL)
|
|
194
|
+
→ Run: {SCRIPT:mark_task} T### (MANDATORY)
|
|
195
|
+
→ 必须执行此脚本将 TASKS.md 中的 [ ] update 为 [x]
|
|
196
|
+
→ 如果不执行此脚本,Check Tasks 将认为任务未完成并导致死循环
|
|
102
197
|
→ Git 提交 (一任务一提交)
|
|
103
198
|
```
|
|
104
199
|
|
|
200
|
+
**Autonomous 模式循环** (默认):
|
|
201
|
+
```
|
|
202
|
+
FOR iteration in 1..max_iterations:
|
|
203
|
+
|
|
204
|
+
┌──────────────────────────────────────────────────────┐
|
|
205
|
+
│ Step A: 注意力刷新 (Protocol 2 + Protocol 3) │
|
|
206
|
+
├──────────────────────────────────────────────────────┤
|
|
207
|
+
│ → Read: TASKS.md 第一个未完成任务 `- [ ]` │
|
|
208
|
+
│ → Read: ERROR_LOG.md 最近 5 条记录(如存在) │
|
|
209
|
+
│ → Read: quickstart.md 相关命令 │
|
|
210
|
+
│ → Focus: 下一步行动 + 避免重复错误 │
|
|
211
|
+
└──────────────────────────────────────────────────────┘
|
|
212
|
+
|
|
213
|
+
┌──────────────────────────────────────────────────────┐
|
|
214
|
+
│ Step B: 执行任务 (TDD 方式) │
|
|
215
|
+
├──────────────────────────────────────────────────────┤
|
|
216
|
+
│ → 提取任务 ID, phase, 文件路径 │
|
|
217
|
+
│ → 遵循 {SKILL:tdd} 执行 │
|
|
218
|
+
│ → Phase 2: 写测试,验证 FAIL │
|
|
219
|
+
│ → Phase 3: 写实现,验证 PASS │
|
|
220
|
+
│ → 后续 Phase: 按任务描述完成 │
|
|
221
|
+
└──────────────────────────────────────────────────────┘
|
|
222
|
+
|
|
223
|
+
┌──────────────────────────────────────────────────────┐
|
|
224
|
+
│ Step C: 错误处理 (Autonomous 自动重试) │
|
|
225
|
+
├──────────────────────────────────────────────────────┤
|
|
226
|
+
│ IF test fails OR build error: │
|
|
227
|
+
│ → Record error to ERROR_LOG.md (强制) │
|
|
228
|
+
│ → Apply Protocol 4 (Error Recovery) │
|
|
229
|
+
│ → Analyze root cause │
|
|
230
|
+
│ → Fix and re-run tests │
|
|
231
|
+
│ → Update ERROR_LOG.md with resolution │
|
|
232
|
+
│ ELSE: │
|
|
233
|
+
│ → Task succeeded │
|
|
234
|
+
│ → Run: {SCRIPT:mark_task} T### (CRITICAL: MUST RUN)│
|
|
235
|
+
│ → NEVER skip this step. Task is NOT done until marked.│
|
|
236
|
+
│ → Git commit (one task per commit) │
|
|
237
|
+
└──────────────────────────────────────────────────────┘
|
|
238
|
+
|
|
239
|
+
┌──────────────────────────────────────────────────────┐
|
|
240
|
+
│ Step D: 完成检查 │
|
|
241
|
+
├──────────────────────────────────────────────────────┤
|
|
242
|
+
│ → Run: {SCRIPT:check_tasks} --json │
|
|
243
|
+
│ → IF remaining_tasks == 0: │
|
|
244
|
+
│ → Output "AUTONOMOUS_COMPLETE" │
|
|
245
|
+
│ → BREAK (Exit loop successfully) │
|
|
246
|
+
│ → ELSE IF iteration == max_iterations: │
|
|
247
|
+
│ → Output status report │
|
|
248
|
+
│ → BREAK (Reached limit) │
|
|
249
|
+
│ → ELSE: │
|
|
250
|
+
│ → Continue to next iteration │
|
|
251
|
+
│ → Stop Hook will re-inject same prompt │
|
|
252
|
+
└──────────────────────────────────────────────────────┘
|
|
253
|
+
|
|
254
|
+
END FOR
|
|
255
|
+
|
|
256
|
+
Note: Stop Hook (.claude/hooks/ralph-stop-hook.sh) 会在 Autonomous 模式下:
|
|
257
|
+
• 检测 .claude/ralph-loop.local.md 存在
|
|
258
|
+
• 阻止退出,重新注入任务继续 prompt
|
|
259
|
+
• 直到 remaining_tasks == 0 或达到 max_iterations
|
|
260
|
+
```
|
|
261
|
+
|
|
105
262
|
### 阶段 4: Exit Gate
|
|
106
263
|
```
|
|
107
264
|
1. 所有任务完成?
|
|
108
265
|
→ {SCRIPT:check_tasks} --json 确认 remaining=0
|
|
109
266
|
|
|
110
|
-
2.
|
|
267
|
+
2. 清理 Autonomous 状态文件(如存在)
|
|
268
|
+
→ rm .claude/ralph-loop.local.md
|
|
269
|
+
|
|
270
|
+
3. 代码质量
|
|
111
271
|
→ 运行 quickstart 中全量测试命令
|
|
112
272
|
→ 可选: {SCRIPT:validate_constitution} --type dev --severity warning
|
|
113
273
|
|
|
114
|
-
|
|
274
|
+
4. 状态更新
|
|
115
275
|
→ orchestration_status:
|
|
116
276
|
status = "development_complete"
|
|
117
277
|
completedSteps append "dev"
|
|
@@ -119,16 +279,37 @@ For each remaining task (顺序严格遵循 TASKS.md):
|
|
|
119
279
|
```
|
|
120
280
|
|
|
121
281
|
## 运行提示
|
|
122
|
-
-
|
|
123
|
-
-
|
|
124
|
-
-
|
|
125
|
-
-
|
|
282
|
+
- **默认 Autonomous 模式**: 遇错自动重试,无需人工干预
|
|
283
|
+
- **使用 `--manual` 退出**: 适合需要人工判断的复杂场景
|
|
284
|
+
- **使用 `/cancel-ralph` 停止**: 紧急停止 Autonomous 循环
|
|
285
|
+
- 始终使用 quickstart 中提供的命令(测试、lint、db migrate 等)
|
|
286
|
+
- Phase 2 的所有测试必须在实现前失败;若某测试直接通过,回滚并修正
|
|
287
|
+
- 遵循 TASKS.md 标注的 `[P]` 仅表示逻辑上可并行,实际执行依旧串行
|
|
288
|
+
- 如需恢复,可使用 `/flow-dev --task TXYZ` 指向首个未完成任务
|
|
126
289
|
|
|
127
290
|
## 错误处理
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
-
|
|
291
|
+
|
|
292
|
+
**Manual 模式**:
|
|
293
|
+
- 缺少资产 → 引导用户先运行 `/flow-tech` 或 `/flow-epic`
|
|
294
|
+
- quickstart 命令失败 → 输出日志路径,要求修复环境后重试
|
|
295
|
+
- 任务执行失败 → 保留当前状态,停止执行,等待人工修复
|
|
296
|
+
|
|
297
|
+
**Autonomous 模式**:
|
|
298
|
+
- 缺少资产 → 同 Manual 模式(Entry Gate 阻止)
|
|
299
|
+
- quickstart 命令失败 → 记录 ERROR_LOG.md,分析根因,自动修复,重试
|
|
300
|
+
- 任务执行失败 → 记录 ERROR_LOG.md,Protocol 4 刷新注意力,自动重试
|
|
301
|
+
- 达到 max_iterations → 输出状态报告(已完成/剩余任务),保持 development_in_progress
|
|
302
|
+
- 紧急停止 → 使用 `/cancel-ralph` 删除状态文件,立即终止循环
|
|
303
|
+
|
|
304
|
+
## 取消 Autonomous 循环
|
|
305
|
+
|
|
306
|
+
```bash
|
|
307
|
+
/cancel-ralph
|
|
308
|
+
# 检查 .claude/ralph-loop.local.md 存在性
|
|
309
|
+
# 删除状态文件,Stop Hook 将允许退出
|
|
310
|
+
# 输出:Cancelled autonomous loop (was at iteration N)
|
|
311
|
+
```
|
|
131
312
|
|
|
132
313
|
## 下一步
|
|
133
|
-
1. 完成所有任务后运行 `/flow-qa`
|
|
134
|
-
2. 若有新技术引入,回到 `research/tasks.json` 补记并通知 planner
|
|
314
|
+
1. 完成所有任务后运行 `/flow-qa` 进入测试与安全审查
|
|
315
|
+
2. 若有新技术引入,回到 `research/tasks.json` 补记并通知 planner
|
|
@@ -8,10 +8,43 @@ scripts:
|
|
|
8
8
|
agent_scripts:
|
|
9
9
|
sh: .claude/scripts/update-agent-context.sh __AGENT__
|
|
10
10
|
ps: scripts/powershell/update-agent-context.ps1 -AgentType __AGENT__
|
|
11
|
+
skills:
|
|
12
|
+
tdd: .claude/skills/flow-tdd/SKILL.md
|
|
11
13
|
---
|
|
12
14
|
|
|
13
15
|
# Flow-Epic - Epic 和任务规划命令
|
|
14
16
|
|
|
17
|
+
## Bite-Sized Tasks 原则
|
|
18
|
+
|
|
19
|
+
任务必须足够小:
|
|
20
|
+
|
|
21
|
+
```yaml
|
|
22
|
+
Task 粒度规范:
|
|
23
|
+
- 每个 step 2-5 分钟可完成
|
|
24
|
+
- "Write the failing test" = 1 step
|
|
25
|
+
- "Run it to make sure it fails" = 1 step
|
|
26
|
+
- "Implement minimal code to pass" = 1 step
|
|
27
|
+
- "Run tests and verify" = 1 step
|
|
28
|
+
- "Commit" = 1 step
|
|
29
|
+
|
|
30
|
+
Task 内容规范:
|
|
31
|
+
- 精确的文件路径 (不是 "update the config")
|
|
32
|
+
- 完整的代码片段 (不是 "add validation")
|
|
33
|
+
- 精确的命令 + 期望输出
|
|
34
|
+
- 明确的验收标准
|
|
35
|
+
|
|
36
|
+
Bad Task Examples:
|
|
37
|
+
❌ "Implement user authentication"
|
|
38
|
+
❌ "Add validation"
|
|
39
|
+
❌ "Update the API"
|
|
40
|
+
|
|
41
|
+
Good Task Examples:
|
|
42
|
+
✅ "Create src/auth/login.ts with LoginRequest interface"
|
|
43
|
+
✅ "Write failing test: POST /api/login returns 401 for invalid credentials"
|
|
44
|
+
✅ "Run npm test -- --grep 'login' and verify test fails"
|
|
45
|
+
✅ "Implement login handler to pass the test"
|
|
46
|
+
```
|
|
47
|
+
|
|
15
48
|
## User Input
|
|
16
49
|
```text
|
|
17
50
|
$ARGUMENTS = "REQ_ID?"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: flow-fix
|
|
3
|
-
description: 'One-shot BUG fix flow. Usage: /flow-fix "BUG-123|登录时报 500"'
|
|
3
|
+
description: 'One-shot BUG fix flow with systematic debugging. Usage: /flow-fix "BUG-123|登录时报 500"'
|
|
4
4
|
scripts:
|
|
5
5
|
prereq: .claude/scripts/check-prerequisites.sh
|
|
6
6
|
recover: .claude/scripts/recover-workflow.sh
|
|
@@ -8,9 +8,19 @@ scripts:
|
|
|
8
8
|
agent_scripts:
|
|
9
9
|
sh: .claude/scripts/update-agent-context.sh __AGENT__
|
|
10
10
|
ps: scripts/powershell/update-agent-context.ps1 -AgentType __AGENT__
|
|
11
|
+
skills:
|
|
12
|
+
debugging: .claude/skills/flow-debugging/SKILL.md
|
|
13
|
+
verification: .claude/skills/verification-before-completion/SKILL.md
|
|
14
|
+
tdd: .claude/skills/flow-tdd/SKILL.md
|
|
11
15
|
---
|
|
12
16
|
|
|
13
|
-
# Flow-Fix -
|
|
17
|
+
# Flow-Fix - 系统化 BUG 修复流
|
|
18
|
+
|
|
19
|
+
## The Iron Law
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
NO FIXES WITHOUT ROOT CAUSE INVESTIGATION FIRST
|
|
23
|
+
```
|
|
14
24
|
|
|
15
25
|
## User Input
|
|
16
26
|
```text
|
|
@@ -23,68 +33,165 @@ BUG_ID 必须满足 `BUG-\d+`;TITLE 为简洁现象描述。
|
|
|
23
33
|
/flow-fix "BUG-123|登录时报500"
|
|
24
34
|
```
|
|
25
35
|
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## 核心理念
|
|
39
|
+
|
|
40
|
+
Bug 修复不是猜测游戏。系统化调试 = 更快修复 + 更少回归。
|
|
41
|
+
|
|
42
|
+
```
|
|
43
|
+
错误方式: 看到错误 → 猜测原因 → 尝试修复 → 失败 → 再猜...
|
|
44
|
+
正确方式: 看到错误 → 调查根因 → 理解问题 → 写测试 → 修复 → 验证
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Rationalization Prevention
|
|
48
|
+
|
|
49
|
+
| Excuse | Reality |
|
|
50
|
+
|--------|---------|
|
|
51
|
+
| "我知道问题在哪" | 证明它。先调查。 |
|
|
52
|
+
| "快速修复一下" | 快速修复 = 快速回归。系统化调试。 |
|
|
53
|
+
| "没时间写测试" | 没测试 = 不知道是否真的修好了。 |
|
|
54
|
+
| "这个改动很小" | 小改动也能引入大 bug。测试它。 |
|
|
55
|
+
| "先修复,后调查" | 不理解问题就修复 = 猜测。 |
|
|
56
|
+
| "试试这个" | "试试"不是调试。形成假设,验证它。 |
|
|
57
|
+
|
|
58
|
+
### Red Flags - STOP
|
|
59
|
+
|
|
60
|
+
如果你发现自己:
|
|
61
|
+
- 没有复现就开始修复
|
|
62
|
+
- 在"试试这个,试试那个"
|
|
63
|
+
- 3+ 次修复尝试失败
|
|
64
|
+
- 没写测试就说"修好了"
|
|
65
|
+
- 改了很多文件来修一个 bug
|
|
66
|
+
|
|
67
|
+
**STOP. 回到阶段 1. 调查根因。**
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
26
71
|
## 执行流程
|
|
27
72
|
|
|
28
73
|
### 阶段 0: Entry Gate
|
|
29
74
|
```
|
|
30
75
|
1. 解析 BUG_ID、TITLE
|
|
76
|
+
→ 若 TITLE 含中文/非ASCII,使用模型意译生成 BRANCH_TITLE_EN(英文语义翻译,禁止拼音/音译)
|
|
77
|
+
→ 若意译不确定或未生成 ASCII 结果,向用户确认英文分支标题
|
|
31
78
|
2. {SCRIPT:prereq} --json 验证:
|
|
32
79
|
→ devflow/bugs/${BUG_ID}/ 是否存在(首次执行将创建)
|
|
33
80
|
→ Git 工作区干净
|
|
34
81
|
3. 创建目录与分支:
|
|
35
|
-
→ git checkout -b "bugfix/${BUG_ID}-${slug(
|
|
82
|
+
→ git checkout -b "bugfix/${BUG_ID}-${slug(BRANCH_TITLE_EN)}"
|
|
36
83
|
→ 初始化 devflow/bugs/${BUG_ID}/ 结构与 orchestration_status.json
|
|
37
84
|
4. 检查 quickstart.md
|
|
38
85
|
→ 若需求目录已有 quickstart.md,复制引用用于测试执行
|
|
39
86
|
```
|
|
40
87
|
|
|
41
|
-
### 阶段 1:
|
|
88
|
+
### 阶段 1: Root Cause Investigation (NO FIXES YET)
|
|
89
|
+
|
|
90
|
+
**Iron Law**: 在这个阶段,**禁止写任何修复代码**。
|
|
91
|
+
|
|
92
|
+
参考 `{SKILL:debugging}` Phase 1:
|
|
93
|
+
|
|
42
94
|
```
|
|
43
|
-
1
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
95
|
+
Step 1: 完整阅读错误信息
|
|
96
|
+
→ 不要跳过任何细节
|
|
97
|
+
→ 记录: 错误类型、消息、堆栈跟踪
|
|
98
|
+
→ 记录: 发生时间、频率、影响范围
|
|
99
|
+
|
|
100
|
+
Step 2: 稳定复现
|
|
101
|
+
→ 找到可靠的复现步骤
|
|
102
|
+
→ 记录: 输入、环境、前置条件
|
|
103
|
+
→ 如果无法复现 → 收集更多信息
|
|
104
|
+
|
|
105
|
+
Step 3: 检查最近变更
|
|
106
|
+
→ git log --oneline -20
|
|
107
|
+
→ git diff HEAD~5
|
|
108
|
+
→ 问: 什么变了?何时开始出问题?
|
|
109
|
+
|
|
110
|
+
Step 4: 逆向追踪数据流
|
|
111
|
+
→ 从错误点向上追踪
|
|
112
|
+
→ 找到数据来源
|
|
113
|
+
→ 识别数据在哪里变坏
|
|
47
114
|
```
|
|
48
115
|
|
|
49
|
-
|
|
116
|
+
**输出**: ANALYSIS.md(现象、复现、根因假设、影响范围)
|
|
117
|
+
|
|
118
|
+
### 阶段 2: Pattern Analysis & Planning
|
|
119
|
+
|
|
120
|
+
参考 `{SKILL:debugging}` Phase 2:
|
|
121
|
+
|
|
50
122
|
```
|
|
51
|
-
1.
|
|
123
|
+
1. 找到正常工作的例子
|
|
124
|
+
→ 类似功能哪里正常工作?
|
|
125
|
+
→ 对比: 正常 vs 异常
|
|
126
|
+
|
|
127
|
+
2. 与参考实现对比
|
|
128
|
+
→ 官方文档怎么说?
|
|
129
|
+
→ 其他项目怎么做?
|
|
130
|
+
|
|
131
|
+
3. 调用 planner
|
|
52
132
|
→ 输入 ANALYSIS.md、现有 quickstart、代码结构
|
|
53
133
|
→ 产出 PLAN.md、tasks/ (TDD 顺序: Root Cause → Failing Test → Fix → Regression)
|
|
54
|
-
|
|
134
|
+
|
|
135
|
+
4. 调用 qa-tester / security-reviewer
|
|
55
136
|
→ 生成 TEST_PLAN.md、SECURITY_PLAN.md
|
|
56
|
-
3. orchestration_status: status="planning_complete"
|
|
57
137
|
```
|
|
58
138
|
|
|
59
|
-
|
|
139
|
+
**输出**: PLAN.md, tasks/, TEST_PLAN.md, SECURITY_PLAN.md
|
|
140
|
+
|
|
141
|
+
### 阶段 3: 修复执行 (TDD)
|
|
142
|
+
|
|
143
|
+
参考 `{SKILL:tdd}` + `{SKILL:debugging}` Phase 3-4:
|
|
144
|
+
|
|
60
145
|
```
|
|
61
|
-
1.
|
|
146
|
+
1. 先写失败测试用例
|
|
147
|
+
→ 测试必须复现 bug
|
|
148
|
+
→ 运行测试,确认失败
|
|
149
|
+
→ 这是你的"红灯"
|
|
150
|
+
|
|
151
|
+
2. 主代理按 tasks/ 顺序执行:
|
|
62
152
|
→ Phase 1: 重现/Root Cause (分析日志、添加监控)
|
|
63
153
|
→ Phase 2: Tests First (根据 quickstart 运行失败测试)
|
|
64
|
-
→ Phase 3: Fix Implementation
|
|
154
|
+
→ Phase 3: Fix Implementation (最小化改动)
|
|
65
155
|
→ Phase 4: Regression hardening
|
|
66
|
-
|
|
156
|
+
|
|
157
|
+
3. 每个任务完成后:
|
|
67
158
|
→ 运行 quickstart 中相关测试命令
|
|
68
159
|
→ Git 提交 (一任务一提交)
|
|
69
160
|
→ 更新 tasks/TASK_*.completed
|
|
70
|
-
|
|
161
|
+
|
|
162
|
+
4. 3+ 次修复失败 → STOP
|
|
163
|
+
→ 停下来,质疑架构
|
|
164
|
+
→ 可能问题比想象的更深
|
|
71
165
|
```
|
|
72
166
|
|
|
73
167
|
### 阶段 4: 验证与发布
|
|
168
|
+
|
|
169
|
+
参考 `{SKILL:verification}`:
|
|
170
|
+
|
|
74
171
|
```
|
|
75
172
|
1. qa-tester 生成 TEST_REPORT.md(必须全部通过)
|
|
76
173
|
2. security-reviewer 生成 SECURITY_REPORT.md
|
|
77
174
|
3. release-manager 生成 RELEASE_PLAN.md
|
|
78
175
|
4. {SCRIPT:validate_constitution} --type bug_fix --severity warning
|
|
79
176
|
5. orchestration_status: status="fix_complete"
|
|
177
|
+
|
|
178
|
+
验证清单:
|
|
179
|
+
□ 根因已记录
|
|
180
|
+
□ 失败测试已写
|
|
181
|
+
□ 修复已实现
|
|
182
|
+
□ 测试通过
|
|
183
|
+
□ 无回归
|
|
184
|
+
□ 文档已更新 (如需要)
|
|
80
185
|
```
|
|
81
186
|
|
|
187
|
+
---
|
|
188
|
+
|
|
82
189
|
## 产物结构
|
|
83
190
|
```
|
|
84
191
|
devflow/bugs/${BUG_ID}/
|
|
85
|
-
ANALYSIS.md
|
|
86
|
-
PLAN.md
|
|
87
|
-
tasks/
|
|
192
|
+
ANALYSIS.md # 根因分析
|
|
193
|
+
PLAN.md # 修复计划
|
|
194
|
+
tasks/ # TDD 任务
|
|
88
195
|
TEST_PLAN.md / SECURITY_PLAN.md
|
|
89
196
|
TEST_REPORT.md / SECURITY_REPORT.md
|
|
90
197
|
RELEASE_PLAN.md
|
|
@@ -102,3 +209,14 @@ devflow/bugs/${BUG_ID}/
|
|
|
102
209
|
1. 提交 PR:`fix(${BUG_ID}): <summary>`
|
|
103
210
|
2. 通知相关需求负责人回归验证。
|
|
104
211
|
3. 评估是否需更新研究/技术设计文档以反映修复影响。
|
|
212
|
+
|
|
213
|
+
---
|
|
214
|
+
|
|
215
|
+
**Related Documentation**:
|
|
216
|
+
- [flow-debugging](.claude/skills/flow-debugging/SKILL.md) - 4 阶段调试法
|
|
217
|
+
- [flow-tdd](.claude/skills/flow-tdd/SKILL.md) - TDD 原则
|
|
218
|
+
- [verification-before-completion](.claude/skills/verification-before-completion/SKILL.md) - 验证技能
|
|
219
|
+
|
|
220
|
+
---
|
|
221
|
+
|
|
222
|
+
**[PROTOCOL]**: 变更时更新此头部,然后检查 CLAUDE.md
|