claude-code-workflow 6.3.43 → 6.3.44

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.
Files changed (77) hide show
  1. package/.claude/agents/tdd-developer.md +530 -0
  2. package/.claude/commands/issue/discover-by-prompt.md +5 -1
  3. package/.claude/commands/issue/discover.md +472 -468
  4. package/.claude/commands/issue/execute.md +580 -581
  5. package/.claude/commands/issue/new.md +417 -413
  6. package/.claude/commands/issue/plan.md +5 -1
  7. package/.claude/commands/issue/queue.md +445 -441
  8. package/.claude/commands/task/breakdown.md +207 -203
  9. package/.claude/commands/task/replan.md +440 -436
  10. package/.claude/commands/workflow/action-plan-verify.md +485 -447
  11. package/.claude/commands/workflow/brainstorm/artifacts.md +457 -453
  12. package/.claude/commands/workflow/brainstorm/auto-parallel.md +5 -1
  13. package/.claude/commands/workflow/brainstorm/synthesis.md +402 -398
  14. package/.claude/commands/workflow/clean.md +67 -35
  15. package/.claude/commands/workflow/debug-with-file.md +670 -666
  16. package/.claude/commands/workflow/debug.md +331 -327
  17. package/.claude/commands/workflow/develop-with-file.md +5 -1
  18. package/.claude/commands/workflow/execute.md +546 -498
  19. package/.claude/commands/workflow/lite-execute.md +44 -26
  20. package/.claude/commands/workflow/lite-fix.md +780 -730
  21. package/.claude/commands/workflow/lite-lite-lite.md +5 -1
  22. package/.claude/commands/workflow/lite-plan.md +87 -39
  23. package/.claude/commands/workflow/multi-cli-plan.md +572 -568
  24. package/.claude/commands/workflow/plan-verify.md +527 -0
  25. package/.claude/commands/workflow/plan.md +555 -551
  26. package/.claude/commands/workflow/replan.md +572 -515
  27. package/.claude/commands/workflow/review-fix.md +608 -610
  28. package/.claude/commands/workflow/session/complete.md +37 -14
  29. package/.claude/commands/workflow/session/solidify.md +303 -299
  30. package/.claude/commands/workflow/tdd-plan.md +630 -597
  31. package/.claude/commands/workflow/tdd-verify.md +391 -206
  32. package/.claude/commands/workflow/tools/conflict-resolution.md +24 -12
  33. package/.claude/commands/workflow/tools/task-generate-agent.md +583 -563
  34. package/.claude/commands/workflow/tools/task-generate-tdd.md +749 -517
  35. package/.claude/commands/workflow/ui-design/animation-extract.md +1154 -1150
  36. package/.claude/commands/workflow/ui-design/layout-extract.md +792 -788
  37. package/.claude/commands/workflow/ui-design/style-extract.md +777 -773
  38. package/.claude/skills/ccw/command.json +4 -4
  39. package/.claude/skills/ccw-coordinator/README.md +45 -0
  40. package/.claude/skills/ccw-coordinator/SKILL.md +320 -0
  41. package/.claude/skills/ccw-coordinator/phases/actions/action-abort.md +9 -0
  42. package/.claude/skills/ccw-coordinator/phases/actions/action-command-build.md +40 -0
  43. package/.claude/skills/ccw-coordinator/phases/actions/action-command-execute.md +124 -0
  44. package/.claude/skills/ccw-coordinator/phases/actions/action-command-selection.md +48 -0
  45. package/.claude/skills/ccw-coordinator/phases/actions/action-complete.md +25 -0
  46. package/.claude/skills/ccw-coordinator/phases/actions/action-init.md +26 -0
  47. package/.claude/skills/ccw-coordinator/phases/orchestrator.md +59 -0
  48. package/.claude/skills/ccw-coordinator/phases/state-schema.md +66 -0
  49. package/.claude/skills/ccw-coordinator/skill-config.json +66 -0
  50. package/.claude/skills/ccw-coordinator/specs/command-library.md +169 -0
  51. package/.claude/skills/ccw-coordinator/specs/specs.md +362 -0
  52. package/.claude/skills/ccw-coordinator/tools/README.md +95 -0
  53. package/.claude/skills/ccw-coordinator/tools/chain-validate.cjs +320 -0
  54. package/.claude/skills/ccw-coordinator/tools/command-registry.cjs +255 -0
  55. package/.claude/skills/ccw-help/command.json +5 -5
  56. package/.claude/skills/ccw-help/scripts/analyze_commands.py +337 -337
  57. package/.claude/workflows/cli-templates/prompts/workflow-impl-plan-template.txt +1 -1
  58. package/ccw/dist/commands/issue.d.ts +4 -0
  59. package/ccw/dist/commands/issue.d.ts.map +1 -1
  60. package/ccw/dist/commands/issue.js +73 -6
  61. package/ccw/dist/commands/issue.js.map +1 -1
  62. package/ccw/dist/core/routes/cli-routes.d.ts.map +1 -1
  63. package/ccw/dist/core/routes/cli-routes.js +32 -28
  64. package/ccw/dist/core/routes/cli-routes.js.map +1 -1
  65. package/ccw/dist/tools/claude-cli-tools.d.ts +10 -0
  66. package/ccw/dist/tools/claude-cli-tools.d.ts.map +1 -1
  67. package/ccw/dist/tools/claude-cli-tools.js +45 -0
  68. package/ccw/dist/tools/claude-cli-tools.js.map +1 -1
  69. package/ccw/dist/tools/codex-lens.d.ts.map +1 -1
  70. package/ccw/dist/tools/codex-lens.js +38 -11
  71. package/ccw/dist/tools/codex-lens.js.map +1 -1
  72. package/ccw/src/commands/issue.ts +84 -6
  73. package/ccw/src/core/routes/cli-routes.ts +30 -25
  74. package/ccw/src/templates/dashboard-js/views/help.js +1 -1
  75. package/ccw/src/tools/claude-cli-tools.ts +50 -0
  76. package/ccw/src/tools/codex-lens.ts +40 -11
  77. package/package.json +1 -1
@@ -1,666 +1,670 @@
1
- ---
2
- name: debug-with-file
3
- description: Interactive hypothesis-driven debugging with documented exploration, understanding evolution, and Gemini-assisted correction
4
- argument-hint: "\"bug description or error message\""
5
- allowed-tools: TodoWrite(*), Task(*), AskUserQuestion(*), Read(*), Grep(*), Glob(*), Bash(*), Edit(*), Write(*)
6
- ---
7
-
8
- # Workflow Debug-With-File Command (/workflow:debug-with-file)
9
-
10
- ## Overview
11
-
12
- Enhanced evidence-based debugging with **documented exploration process**. Records understanding evolution, consolidates insights, and uses Gemini to correct misunderstandings.
13
-
14
- **Core workflow**: Explore → Document → Log → Analyze → Correct Understanding → Fix → Verify
15
-
16
- **Key enhancements over /workflow:debug**:
17
- - **understanding.md**: Timeline of exploration and learning
18
- - **Gemini-assisted correction**: Validates and corrects hypotheses
19
- - **Consolidation**: Simplifies proven-wrong understanding to avoid clutter
20
- - **Learning retention**: Preserves what was learned, even from failed attempts
21
-
22
- ## Usage
23
-
24
- ```bash
25
- /workflow:debug-with-file <BUG_DESCRIPTION>
26
-
27
- # Arguments
28
- <bug-description> Bug description, error message, or stack trace (required)
29
- ```
30
-
31
- ## Execution Process
32
-
33
- ```
34
- Session Detection:
35
- ├─ Check if debug session exists for this bug
36
- ├─ EXISTS + understanding.md exists → Continue mode
37
- └─ NOT_FOUND → Explore mode
38
-
39
- Explore Mode:
40
- ├─ Locate error source in codebase
41
- ├─ Document initial understanding in understanding.md
42
- ├─ Generate testable hypotheses with Gemini validation
43
- ├─ Add NDJSON logging instrumentation
44
- └─ Output: Hypothesis list + await user reproduction
45
-
46
- Analyze Mode:
47
- ├─ Parse debug.log, validate each hypothesis
48
- ├─ Use Gemini to analyze evidence and correct understanding
49
- ├─ Update understanding.md with:
50
- │ ├─ New evidence
51
- ├─ Corrected misunderstandings (strikethrough + correction)
52
- │ └─ Consolidated current understanding
53
- └─ Decision:
54
- ├─ Confirmed → Fix root cause
55
- ├─ Inconclusive Add more logging, iterate
56
- └─ All rejected → Gemini-assisted new hypotheses
57
-
58
- Fix & Cleanup:
59
- ├─ Apply fix based on confirmed hypothesis
60
- ├─ User verifies
61
- ├─ Document final understanding + lessons learned
62
- ├─ Remove debug instrumentation
63
- └─ If not fixed Return to Analyze mode
64
- ```
65
-
66
- ## Implementation
67
-
68
- ### Session Setup & Mode Detection
69
-
70
- ```javascript
71
- const getUtc8ISOString = () => new Date(Date.now() + 8 * 60 * 60 * 1000).toISOString()
72
-
73
- const bugSlug = bug_description.toLowerCase().replace(/[^a-z0-9]+/g, '-').substring(0, 30)
74
- const dateStr = getUtc8ISOString().substring(0, 10)
75
-
76
- const sessionId = `DBG-${bugSlug}-${dateStr}`
77
- const sessionFolder = `.workflow/.debug/${sessionId}`
78
- const debugLogPath = `${sessionFolder}/debug.log`
79
- const understandingPath = `${sessionFolder}/understanding.md`
80
- const hypothesesPath = `${sessionFolder}/hypotheses.json`
81
-
82
- // Auto-detect mode
83
- const sessionExists = fs.existsSync(sessionFolder)
84
- const hasUnderstanding = sessionExists && fs.existsSync(understandingPath)
85
- const logHasContent = sessionExists && fs.existsSync(debugLogPath) && fs.statSync(debugLogPath).size > 0
86
-
87
- const mode = logHasContent ? 'analyze' : (hasUnderstanding ? 'continue' : 'explore')
88
-
89
- if (!sessionExists) {
90
- bash(`mkdir -p ${sessionFolder}`)
91
- }
92
- ```
93
-
94
- ---
95
-
96
- ### Explore Mode
97
-
98
- **Step 1.1: Locate Error Source**
99
-
100
- ```javascript
101
- // Extract keywords from bug description
102
- const keywords = extractErrorKeywords(bug_description)
103
-
104
- // Search codebase for error locations
105
- const searchResults = []
106
- for (const keyword of keywords) {
107
- const results = Grep({ pattern: keyword, path: ".", output_mode: "content", "-C": 3 })
108
- searchResults.push({ keyword, results })
109
- }
110
-
111
- // Identify affected files and functions
112
- const affectedLocations = analyzeSearchResults(searchResults)
113
- ```
114
-
115
- **Step 1.2: Document Initial Understanding**
116
-
117
- Create `understanding.md` with exploration timeline:
118
-
119
- ```markdown
120
- # Understanding Document
121
-
122
- **Session ID**: ${sessionId}
123
- **Bug Description**: ${bug_description}
124
- **Started**: ${getUtc8ISOString()}
125
-
126
- ---
127
-
128
- ## Exploration Timeline
129
-
130
- ### Iteration 1 - Initial Exploration (${timestamp})
131
-
132
- #### Current Understanding
133
-
134
- Based on bug description and initial code search:
135
-
136
- - Error pattern: ${errorPattern}
137
- - Affected areas: ${affectedLocations.map(l => l.file).join(', ')}
138
- - Initial hypothesis: ${initialThoughts}
139
-
140
- #### Evidence from Code Search
141
-
142
- ${searchResults.map(r => `
143
- **Keyword: "${r.keyword}"**
144
- - Found in: ${r.results.files.join(', ')}
145
- - Key findings: ${r.insights}
146
- `).join('\n')}
147
-
148
- #### Next Steps
149
-
150
- - Generate testable hypotheses
151
- - Add instrumentation
152
- - Await reproduction
153
-
154
- ---
155
-
156
- ## Current Consolidated Understanding
157
-
158
- ${initialConsolidatedUnderstanding}
159
- ```
160
-
161
- **Step 1.3: Gemini-Assisted Hypothesis Generation**
162
-
163
- ```bash
164
- ccw cli -p "
165
- PURPOSE: Generate debugging hypotheses for: ${bug_description}
166
- Success criteria: Testable hypotheses with clear evidence criteria
167
-
168
- TASK:
169
- Analyze error pattern and code search results
170
- Identify 3-5 most likely root causes
171
- • For each hypothesis, specify:
172
- - What might be wrong
173
- - What evidence would confirm/reject it
174
- - Where to add instrumentation
175
- Rank by likelihood
176
-
177
- MODE: analysis
178
-
179
- CONTEXT: @${sessionFolder}/understanding.md | Search results in understanding.md
180
-
181
- EXPECTED:
182
- - Structured hypothesis list (JSON format)
183
- - Each hypothesis with: id, description, testable_condition, logging_point, evidence_criteria
184
- - Likelihood ranking (1=most likely)
185
-
186
- CONSTRAINTS: Focus on testable conditions
187
- " --tool gemini --mode analysis --rule analysis-diagnose-bug-root-cause
188
- ```
189
-
190
- Save Gemini output to `hypotheses.json`:
191
-
192
- ```json
193
- {
194
- "iteration": 1,
195
- "timestamp": "2025-01-21T10:00:00+08:00",
196
- "hypotheses": [
197
- {
198
- "id": "H1",
199
- "description": "Data structure mismatch - expected key not present",
200
- "testable_condition": "Check if target key exists in dict",
201
- "logging_point": "file.py:func:42",
202
- "evidence_criteria": {
203
- "confirm": "data shows missing key",
204
- "reject": "key exists with valid value"
205
- },
206
- "likelihood": 1,
207
- "status": "pending"
208
- }
209
- ],
210
- "gemini_insights": "...",
211
- "corrected_assumptions": []
212
- }
213
- ```
214
-
215
- **Step 1.4: Add NDJSON Instrumentation**
216
-
217
- For each hypothesis, add logging (same as original debug command).
218
-
219
- **Step 1.5: Update understanding.md**
220
-
221
- Append hypothesis section:
222
-
223
- ```markdown
224
- #### Hypotheses Generated (Gemini-Assisted)
225
-
226
- ${hypotheses.map(h => `
227
- **${h.id}** (Likelihood: ${h.likelihood}): ${h.description}
228
- - Logging at: ${h.logging_point}
229
- - Testing: ${h.testable_condition}
230
- - Evidence to confirm: ${h.evidence_criteria.confirm}
231
- - Evidence to reject: ${h.evidence_criteria.reject}
232
- `).join('\n')}
233
-
234
- **Gemini Insights**: ${geminiInsights}
235
- ```
236
-
237
- ---
238
-
239
- ### Analyze Mode
240
-
241
- **Step 2.1: Parse Debug Log**
242
-
243
- ```javascript
244
- // Parse NDJSON log
245
- const entries = Read(debugLogPath).split('\n')
246
- .filter(l => l.trim())
247
- .map(l => JSON.parse(l))
248
-
249
- // Group by hypothesis
250
- const byHypothesis = groupBy(entries, 'hid')
251
- ```
252
-
253
- **Step 2.2: Gemini-Assisted Evidence Analysis**
254
-
255
- ```bash
256
- ccw cli -p "
257
- PURPOSE: Analyze debug log evidence to validate/correct hypotheses for: ${bug_description}
258
- Success criteria: Clear verdict per hypothesis + corrected understanding
259
-
260
- TASK:
261
- Parse log entries by hypothesis
262
- Evaluate evidence against expected criteria
263
- • Determine verdict: confirmed | rejected | inconclusive
264
- • Identify incorrect assumptions from previous understanding
265
- Suggest corrections to understanding
266
-
267
- MODE: analysis
268
-
269
- CONTEXT:
270
- @${debugLogPath}
271
- @${understandingPath}
272
- @${hypothesesPath}
273
-
274
- EXPECTED:
275
- - Per-hypothesis verdict with reasoning
276
- - Evidence summary
277
- - List of incorrect assumptions with corrections
278
- - Updated consolidated understanding
279
- - Root cause if confirmed, or next investigation steps
280
-
281
- CONSTRAINTS: Evidence-based reasoning only, no speculation
282
- " --tool gemini --mode analysis --rule analysis-diagnose-bug-root-cause
283
- ```
284
-
285
- **Step 2.3: Update Understanding with Corrections**
286
-
287
- Append new iteration to `understanding.md`:
288
-
289
- ```markdown
290
- ### Iteration ${n} - Evidence Analysis (${timestamp})
291
-
292
- #### Log Analysis Results
293
-
294
- ${results.map(r => `
295
- **${r.id}**: ${r.verdict.toUpperCase()}
296
- - Evidence: ${JSON.stringify(r.evidence)}
297
- - Reasoning: ${r.reason}
298
- `).join('\n')}
299
-
300
- #### Corrected Understanding
301
-
302
- Previous misunderstandings identified and corrected:
303
-
304
- ${corrections.map(c => `
305
- - ~~${c.wrong}~~ → ${c.corrected}
306
- - Why wrong: ${c.reason}
307
- - Evidence: ${c.evidence}
308
- `).join('\n')}
309
-
310
- #### New Insights
311
-
312
- ${newInsights.join('\n- ')}
313
-
314
- #### Gemini Analysis
315
-
316
- ${geminiAnalysis}
317
-
318
- ${confirmedHypothesis ? `
319
- #### Root Cause Identified
320
-
321
- **${confirmedHypothesis.id}**: ${confirmedHypothesis.description}
322
-
323
- Evidence supporting this conclusion:
324
- ${confirmedHypothesis.supportingEvidence}
325
- ` : `
326
- #### Next Steps
327
-
328
- ${nextSteps}
329
- `}
330
-
331
- ---
332
-
333
- ## Current Consolidated Understanding (Updated)
334
-
335
- ${consolidatedUnderstanding}
336
- ```
337
-
338
- **Step 2.4: Consolidate Understanding**
339
-
340
- At the bottom of `understanding.md`, update the consolidated section:
341
-
342
- - Remove or simplify proven-wrong assumptions
343
- - Keep them in strikethrough for reference
344
- - Focus on current valid understanding
345
- - Avoid repeating details from timeline
346
-
347
- ```markdown
348
- ## Current Consolidated Understanding
349
-
350
- ### What We Know
351
-
352
- - ${validUnderstanding1}
353
- - ${validUnderstanding2}
354
-
355
- ### What Was Disproven
356
-
357
- - ~~Initial assumption: ${wrongAssumption}~~ (Evidence: ${disproofEvidence})
358
-
359
- ### Current Investigation Focus
360
-
361
- ${currentFocus}
362
-
363
- ### Remaining Questions
364
-
365
- - ${openQuestion1}
366
- - ${openQuestion2}
367
- ```
368
-
369
- **Step 2.5: Update hypotheses.json**
370
-
371
- ```json
372
- {
373
- "iteration": 2,
374
- "timestamp": "2025-01-21T10:15:00+08:00",
375
- "hypotheses": [
376
- {
377
- "id": "H1",
378
- "status": "rejected",
379
- "verdict_reason": "Evidence shows key exists with valid value",
380
- "evidence": {...}
381
- },
382
- {
383
- "id": "H2",
384
- "status": "confirmed",
385
- "verdict_reason": "Log data confirms timing issue",
386
- "evidence": {...}
387
- }
388
- ],
389
- "gemini_corrections": [
390
- {
391
- "wrong_assumption": "...",
392
- "corrected_to": "...",
393
- "reason": "..."
394
- }
395
- ]
396
- }
397
- ```
398
-
399
- ---
400
-
401
- ### Fix & Verification
402
-
403
- **Step 3.1: Apply Fix**
404
-
405
- (Same as original debug command)
406
-
407
- **Step 3.2: Document Resolution**
408
-
409
- Append to `understanding.md`:
410
-
411
- ```markdown
412
- ### Iteration ${n} - Resolution (${timestamp})
413
-
414
- #### Fix Applied
415
-
416
- - Modified files: ${modifiedFiles.join(', ')}
417
- - Fix description: ${fixDescription}
418
- - Root cause addressed: ${rootCause}
419
-
420
- #### Verification Results
421
-
422
- ${verificationResults}
423
-
424
- #### Lessons Learned
425
-
426
- What we learned from this debugging session:
427
-
428
- 1. ${lesson1}
429
- 2. ${lesson2}
430
- 3. ${lesson3}
431
-
432
- #### Key Insights for Future
433
-
434
- - ${insight1}
435
- - ${insight2}
436
- ```
437
-
438
- **Step 3.3: Cleanup**
439
-
440
- Remove debug instrumentation (same as original command).
441
-
442
- ---
443
-
444
- ## Session Folder Structure
445
-
446
- ```
447
- .workflow/.debug/DBG-{slug}-{date}/
448
- ├── debug.log # NDJSON log (execution evidence)
449
- ├── understanding.md # NEW: Exploration timeline + consolidated understanding
450
- ├── hypotheses.json # NEW: Hypothesis history with verdicts
451
- └── resolution.md # Optional: Final summary
452
- ```
453
-
454
- ## Understanding Document Template
455
-
456
- ```markdown
457
- # Understanding Document
458
-
459
- **Session ID**: DBG-xxx-2025-01-21
460
- **Bug Description**: [original description]
461
- **Started**: 2025-01-21T10:00:00+08:00
462
-
463
- ---
464
-
465
- ## Exploration Timeline
466
-
467
- ### Iteration 1 - Initial Exploration (2025-01-21 10:00)
468
-
469
- #### Current Understanding
470
- ...
471
-
472
- #### Evidence from Code Search
473
- ...
474
-
475
- #### Hypotheses Generated (Gemini-Assisted)
476
- ...
477
-
478
- ### Iteration 2 - Evidence Analysis (2025-01-21 10:15)
479
-
480
- #### Log Analysis Results
481
- ...
482
-
483
- #### Corrected Understanding
484
- - ~~[wrong]~~ [corrected]
485
-
486
- #### Gemini Analysis
487
- ...
488
-
489
- ---
490
-
491
- ## Current Consolidated Understanding
492
-
493
- ### What We Know
494
- - [valid understanding points]
495
-
496
- ### What Was Disproven
497
- - ~~[disproven assumptions]~~
498
-
499
- ### Current Investigation Focus
500
- [current focus]
501
-
502
- ### Remaining Questions
503
- - [open questions]
504
- ```
505
-
506
- ## Iteration Flow
507
-
508
- ```
509
- First Call (/workflow:debug-with-file "error"):
510
- ├─ No session exists → Explore mode
511
- ├─ Extract error keywords, search codebase
512
- ├─ Document initial understanding in understanding.md
513
- ├─ Use Gemini to generate hypotheses
514
- ├─ Add logging instrumentation
515
- └─ Await user reproduction
516
-
517
- After Reproduction (/workflow:debug-with-file "error"):
518
- ├─ Session exists + debug.log has content → Analyze mode
519
- ├─ Parse log, use Gemini to evaluate hypotheses
520
- ├─ Update understanding.md with:
521
- │ ├─ Evidence analysis results
522
- ├─ Corrected misunderstandings (strikethrough)
523
- ├─ New insights
524
- │ └─ Updated consolidated understanding
525
- ├─ Update hypotheses.json with verdicts
526
- └─ Decision:
527
- ├─ Confirmed → Fix → Document resolution
528
- ├─ Inconclusive Add logging, document next steps
529
- └─ All rejected Gemini-assisted new hypotheses
530
-
531
- Output:
532
- ├─ .workflow/.debug/DBG-{slug}-{date}/debug.log
533
- ├─ .workflow/.debug/DBG-{slug}-{date}/understanding.md (evolving document)
534
- └─ .workflow/.debug/DBG-{slug}-{date}/hypotheses.json (history)
535
- ```
536
-
537
- ## Gemini Integration Points
538
-
539
- ### 1. Hypothesis Generation (Explore Mode)
540
-
541
- **Purpose**: Generate evidence-based, testable hypotheses
542
-
543
- **Prompt Pattern**:
544
- ```
545
- PURPOSE: Generate debugging hypotheses + evidence criteria
546
- TASK: Analyze error + code → testable hypotheses with clear pass/fail criteria
547
- CONTEXT: @understanding.md (search results)
548
- EXPECTED: JSON with hypotheses, likelihood ranking, evidence criteria
549
- ```
550
-
551
- ### 2. Evidence Analysis (Analyze Mode)
552
-
553
- **Purpose**: Validate hypotheses and correct misunderstandings
554
-
555
- **Prompt Pattern**:
556
- ```
557
- PURPOSE: Analyze debug log evidence + correct understanding
558
- TASK: Evaluate each hypothesis → identify wrong assumptions → suggest corrections
559
- CONTEXT: @debug.log @understanding.md @hypotheses.json
560
- EXPECTED: Verdicts + corrections + updated consolidated understanding
561
- ```
562
-
563
- ### 3. New Hypothesis Generation (After All Rejected)
564
-
565
- **Purpose**: Generate new hypotheses based on what was disproven
566
-
567
- **Prompt Pattern**:
568
- ```
569
- PURPOSE: Generate new hypotheses given disproven assumptions
570
- TASK: Review rejected hypotheses → identify knowledge gaps → new investigation angles
571
- CONTEXT: @understanding.md (with disproven section) @hypotheses.json
572
- EXPECTED: New hypotheses avoiding previously rejected paths
573
- ```
574
-
575
- ## Error Correction Mechanism
576
-
577
- ### Correction Format in understanding.md
578
-
579
- ```markdown
580
- #### Corrected Understanding
581
-
582
- - ~~Assumed dict key "config" was missing~~ → Key exists, but value is None
583
- - Why wrong: Only checked existence, not value validity
584
- - Evidence: H1 log shows {"config": null, "exists": true}
585
-
586
- - ~~Thought error occurred in initialization~~ → Error happens during runtime update
587
- - Why wrong: Stack trace misread as init code
588
- - Evidence: H2 timestamp shows 30s after startup
589
- ```
590
-
591
- ### Consolidation Rules
592
-
593
- When updating "Current Consolidated Understanding":
594
-
595
- 1. **Simplify disproven items**: Move to "What Was Disproven" with single-line summary
596
- 2. **Keep valid insights**: Promote confirmed findings to "What We Know"
597
- 3. **Avoid duplication**: Don't repeat timeline details in consolidated section
598
- 4. **Focus on current state**: What do we know NOW, not the journey
599
- 5. **Preserve key corrections**: Keep important wrong→right transformations for learning
600
-
601
- **Bad (cluttered)**:
602
- ```markdown
603
- ## Current Consolidated Understanding
604
-
605
- In iteration 1 we thought X, but in iteration 2 we found Y, then in iteration 3...
606
- Also we checked A and found B, and then we checked C...
607
- ```
608
-
609
- **Good (consolidated)**:
610
- ```markdown
611
- ## Current Consolidated Understanding
612
-
613
- ### What We Know
614
- - Error occurs during runtime update, not initialization
615
- - Config value is None (not missing key)
616
-
617
- ### What Was Disproven
618
- - ~~Initialization error~~ (Timing evidence)
619
- - ~~Missing key hypothesis~~ (Key exists)
620
-
621
- ### Current Investigation Focus
622
- Why is config value None during update?
623
- ```
624
-
625
- ## Post-Completion Expansion
626
-
627
- 完成后询问用户是否扩展为issue(test/enhance/refactor/doc),选中项调用 `/issue:new "{summary} - {dimension}"`
628
-
629
- ---
630
-
631
- ## Error Handling
632
-
633
- | Situation | Action |
634
- |-----------|--------|
635
- | Empty debug.log | Verify reproduction triggered the code path |
636
- | All hypotheses rejected | Use Gemini to generate new hypotheses based on disproven assumptions |
637
- | Fix doesn't work | Document failed fix attempt, iterate with refined understanding |
638
- | >5 iterations | Review consolidated understanding, escalate to `/workflow:lite-fix` with full context |
639
- | Gemini unavailable | Fallback to manual hypothesis generation, document without Gemini insights |
640
- | Understanding too long | Consolidate aggressively, archive old iterations to separate file |
641
-
642
- ## Comparison with /workflow:debug
643
-
644
- | Feature | /workflow:debug | /workflow:debug-with-file |
645
- |---------|-----------------|---------------------------|
646
- | NDJSON logging | ✅ | ✅ |
647
- | Hypothesis generation | Manual | Gemini-assisted |
648
- | Exploration documentation | | understanding.md |
649
- | Understanding evolution | ❌ | ✅ Timeline + corrections |
650
- | Error correction | | ✅ Strikethrough + reasoning |
651
- | Consolidated learning | | Current understanding section |
652
- | Hypothesis history | ❌ | ✅ hypotheses.json |
653
- | Gemini validation | ❌ | ✅ At key decision points |
654
-
655
- ## Usage Recommendations
656
-
657
- Use `/workflow:debug-with-file` when:
658
- - Complex bugs requiring multiple investigation rounds
659
- - Learning from debugging process is valuable
660
- - Team needs to understand debugging rationale
661
- - Bug might recur, documentation helps prevention
662
-
663
- Use `/workflow:debug` when:
664
- - Simple, quick bugs
665
- - One-off issues
666
- - Documentation overhead not needed
1
+ ---
2
+ name: debug-with-file
3
+ description: Interactive hypothesis-driven debugging with documented exploration, understanding evolution, and Gemini-assisted correction
4
+ argument-hint: "[-y|--yes] \"bug description or error message\""
5
+ allowed-tools: TodoWrite(*), Task(*), AskUserQuestion(*), Read(*), Grep(*), Glob(*), Bash(*), Edit(*), Write(*)
6
+ ---
7
+
8
+ ## Auto Mode
9
+
10
+ When `--yes` or `-y`: Auto-confirm all decisions (hypotheses, fixes, iteration), use recommended settings.
11
+
12
+ # Workflow Debug-With-File Command (/workflow:debug-with-file)
13
+
14
+ ## Overview
15
+
16
+ Enhanced evidence-based debugging with **documented exploration process**. Records understanding evolution, consolidates insights, and uses Gemini to correct misunderstandings.
17
+
18
+ **Core workflow**: Explore Document → Log → Analyze → Correct Understanding → Fix → Verify
19
+
20
+ **Key enhancements over /workflow:debug**:
21
+ - **understanding.md**: Timeline of exploration and learning
22
+ - **Gemini-assisted correction**: Validates and corrects hypotheses
23
+ - **Consolidation**: Simplifies proven-wrong understanding to avoid clutter
24
+ - **Learning retention**: Preserves what was learned, even from failed attempts
25
+
26
+ ## Usage
27
+
28
+ ```bash
29
+ /workflow:debug-with-file <BUG_DESCRIPTION>
30
+
31
+ # Arguments
32
+ <bug-description> Bug description, error message, or stack trace (required)
33
+ ```
34
+
35
+ ## Execution Process
36
+
37
+ ```
38
+ Session Detection:
39
+ ├─ Check if debug session exists for this bug
40
+ ├─ EXISTS + understanding.md exists → Continue mode
41
+ └─ NOT_FOUND Explore mode
42
+
43
+ Explore Mode:
44
+ ├─ Locate error source in codebase
45
+ ├─ Document initial understanding in understanding.md
46
+ ├─ Generate testable hypotheses with Gemini validation
47
+ ├─ Add NDJSON logging instrumentation
48
+ └─ Output: Hypothesis list + await user reproduction
49
+
50
+ Analyze Mode:
51
+ ├─ Parse debug.log, validate each hypothesis
52
+ ├─ Use Gemini to analyze evidence and correct understanding
53
+ ├─ Update understanding.md with:
54
+ ├─ New evidence
55
+ ├─ Corrected misunderstandings (strikethrough + correction)
56
+ └─ Consolidated current understanding
57
+ └─ Decision:
58
+ ├─ Confirmed → Fix root cause
59
+ ├─ Inconclusive Add more logging, iterate
60
+ └─ All rejected → Gemini-assisted new hypotheses
61
+
62
+ Fix & Cleanup:
63
+ ├─ Apply fix based on confirmed hypothesis
64
+ ├─ User verifies
65
+ ├─ Document final understanding + lessons learned
66
+ ├─ Remove debug instrumentation
67
+ └─ If not fixed → Return to Analyze mode
68
+ ```
69
+
70
+ ## Implementation
71
+
72
+ ### Session Setup & Mode Detection
73
+
74
+ ```javascript
75
+ const getUtc8ISOString = () => new Date(Date.now() + 8 * 60 * 60 * 1000).toISOString()
76
+
77
+ const bugSlug = bug_description.toLowerCase().replace(/[^a-z0-9]+/g, '-').substring(0, 30)
78
+ const dateStr = getUtc8ISOString().substring(0, 10)
79
+
80
+ const sessionId = `DBG-${bugSlug}-${dateStr}`
81
+ const sessionFolder = `.workflow/.debug/${sessionId}`
82
+ const debugLogPath = `${sessionFolder}/debug.log`
83
+ const understandingPath = `${sessionFolder}/understanding.md`
84
+ const hypothesesPath = `${sessionFolder}/hypotheses.json`
85
+
86
+ // Auto-detect mode
87
+ const sessionExists = fs.existsSync(sessionFolder)
88
+ const hasUnderstanding = sessionExists && fs.existsSync(understandingPath)
89
+ const logHasContent = sessionExists && fs.existsSync(debugLogPath) && fs.statSync(debugLogPath).size > 0
90
+
91
+ const mode = logHasContent ? 'analyze' : (hasUnderstanding ? 'continue' : 'explore')
92
+
93
+ if (!sessionExists) {
94
+ bash(`mkdir -p ${sessionFolder}`)
95
+ }
96
+ ```
97
+
98
+ ---
99
+
100
+ ### Explore Mode
101
+
102
+ **Step 1.1: Locate Error Source**
103
+
104
+ ```javascript
105
+ // Extract keywords from bug description
106
+ const keywords = extractErrorKeywords(bug_description)
107
+
108
+ // Search codebase for error locations
109
+ const searchResults = []
110
+ for (const keyword of keywords) {
111
+ const results = Grep({ pattern: keyword, path: ".", output_mode: "content", "-C": 3 })
112
+ searchResults.push({ keyword, results })
113
+ }
114
+
115
+ // Identify affected files and functions
116
+ const affectedLocations = analyzeSearchResults(searchResults)
117
+ ```
118
+
119
+ **Step 1.2: Document Initial Understanding**
120
+
121
+ Create `understanding.md` with exploration timeline:
122
+
123
+ ```markdown
124
+ # Understanding Document
125
+
126
+ **Session ID**: ${sessionId}
127
+ **Bug Description**: ${bug_description}
128
+ **Started**: ${getUtc8ISOString()}
129
+
130
+ ---
131
+
132
+ ## Exploration Timeline
133
+
134
+ ### Iteration 1 - Initial Exploration (${timestamp})
135
+
136
+ #### Current Understanding
137
+
138
+ Based on bug description and initial code search:
139
+
140
+ - Error pattern: ${errorPattern}
141
+ - Affected areas: ${affectedLocations.map(l => l.file).join(', ')}
142
+ - Initial hypothesis: ${initialThoughts}
143
+
144
+ #### Evidence from Code Search
145
+
146
+ ${searchResults.map(r => `
147
+ **Keyword: "${r.keyword}"**
148
+ - Found in: ${r.results.files.join(', ')}
149
+ - Key findings: ${r.insights}
150
+ `).join('\n')}
151
+
152
+ #### Next Steps
153
+
154
+ - Generate testable hypotheses
155
+ - Add instrumentation
156
+ - Await reproduction
157
+
158
+ ---
159
+
160
+ ## Current Consolidated Understanding
161
+
162
+ ${initialConsolidatedUnderstanding}
163
+ ```
164
+
165
+ **Step 1.3: Gemini-Assisted Hypothesis Generation**
166
+
167
+ ```bash
168
+ ccw cli -p "
169
+ PURPOSE: Generate debugging hypotheses for: ${bug_description}
170
+ Success criteria: Testable hypotheses with clear evidence criteria
171
+
172
+ TASK:
173
+ Analyze error pattern and code search results
174
+ • Identify 3-5 most likely root causes
175
+ For each hypothesis, specify:
176
+ - What might be wrong
177
+ - What evidence would confirm/reject it
178
+ - Where to add instrumentation
179
+ Rank by likelihood
180
+
181
+ MODE: analysis
182
+
183
+ CONTEXT: @${sessionFolder}/understanding.md | Search results in understanding.md
184
+
185
+ EXPECTED:
186
+ - Structured hypothesis list (JSON format)
187
+ - Each hypothesis with: id, description, testable_condition, logging_point, evidence_criteria
188
+ - Likelihood ranking (1=most likely)
189
+
190
+ CONSTRAINTS: Focus on testable conditions
191
+ " --tool gemini --mode analysis --rule analysis-diagnose-bug-root-cause
192
+ ```
193
+
194
+ Save Gemini output to `hypotheses.json`:
195
+
196
+ ```json
197
+ {
198
+ "iteration": 1,
199
+ "timestamp": "2025-01-21T10:00:00+08:00",
200
+ "hypotheses": [
201
+ {
202
+ "id": "H1",
203
+ "description": "Data structure mismatch - expected key not present",
204
+ "testable_condition": "Check if target key exists in dict",
205
+ "logging_point": "file.py:func:42",
206
+ "evidence_criteria": {
207
+ "confirm": "data shows missing key",
208
+ "reject": "key exists with valid value"
209
+ },
210
+ "likelihood": 1,
211
+ "status": "pending"
212
+ }
213
+ ],
214
+ "gemini_insights": "...",
215
+ "corrected_assumptions": []
216
+ }
217
+ ```
218
+
219
+ **Step 1.4: Add NDJSON Instrumentation**
220
+
221
+ For each hypothesis, add logging (same as original debug command).
222
+
223
+ **Step 1.5: Update understanding.md**
224
+
225
+ Append hypothesis section:
226
+
227
+ ```markdown
228
+ #### Hypotheses Generated (Gemini-Assisted)
229
+
230
+ ${hypotheses.map(h => `
231
+ **${h.id}** (Likelihood: ${h.likelihood}): ${h.description}
232
+ - Logging at: ${h.logging_point}
233
+ - Testing: ${h.testable_condition}
234
+ - Evidence to confirm: ${h.evidence_criteria.confirm}
235
+ - Evidence to reject: ${h.evidence_criteria.reject}
236
+ `).join('\n')}
237
+
238
+ **Gemini Insights**: ${geminiInsights}
239
+ ```
240
+
241
+ ---
242
+
243
+ ### Analyze Mode
244
+
245
+ **Step 2.1: Parse Debug Log**
246
+
247
+ ```javascript
248
+ // Parse NDJSON log
249
+ const entries = Read(debugLogPath).split('\n')
250
+ .filter(l => l.trim())
251
+ .map(l => JSON.parse(l))
252
+
253
+ // Group by hypothesis
254
+ const byHypothesis = groupBy(entries, 'hid')
255
+ ```
256
+
257
+ **Step 2.2: Gemini-Assisted Evidence Analysis**
258
+
259
+ ```bash
260
+ ccw cli -p "
261
+ PURPOSE: Analyze debug log evidence to validate/correct hypotheses for: ${bug_description}
262
+ Success criteria: Clear verdict per hypothesis + corrected understanding
263
+
264
+ TASK:
265
+ Parse log entries by hypothesis
266
+ • Evaluate evidence against expected criteria
267
+ • Determine verdict: confirmed | rejected | inconclusive
268
+ • Identify incorrect assumptions from previous understanding
269
+ • Suggest corrections to understanding
270
+
271
+ MODE: analysis
272
+
273
+ CONTEXT:
274
+ @${debugLogPath}
275
+ @${understandingPath}
276
+ @${hypothesesPath}
277
+
278
+ EXPECTED:
279
+ - Per-hypothesis verdict with reasoning
280
+ - Evidence summary
281
+ - List of incorrect assumptions with corrections
282
+ - Updated consolidated understanding
283
+ - Root cause if confirmed, or next investigation steps
284
+
285
+ CONSTRAINTS: Evidence-based reasoning only, no speculation
286
+ " --tool gemini --mode analysis --rule analysis-diagnose-bug-root-cause
287
+ ```
288
+
289
+ **Step 2.3: Update Understanding with Corrections**
290
+
291
+ Append new iteration to `understanding.md`:
292
+
293
+ ```markdown
294
+ ### Iteration ${n} - Evidence Analysis (${timestamp})
295
+
296
+ #### Log Analysis Results
297
+
298
+ ${results.map(r => `
299
+ **${r.id}**: ${r.verdict.toUpperCase()}
300
+ - Evidence: ${JSON.stringify(r.evidence)}
301
+ - Reasoning: ${r.reason}
302
+ `).join('\n')}
303
+
304
+ #### Corrected Understanding
305
+
306
+ Previous misunderstandings identified and corrected:
307
+
308
+ ${corrections.map(c => `
309
+ - ~~${c.wrong}~~ → ${c.corrected}
310
+ - Why wrong: ${c.reason}
311
+ - Evidence: ${c.evidence}
312
+ `).join('\n')}
313
+
314
+ #### New Insights
315
+
316
+ ${newInsights.join('\n- ')}
317
+
318
+ #### Gemini Analysis
319
+
320
+ ${geminiAnalysis}
321
+
322
+ ${confirmedHypothesis ? `
323
+ #### Root Cause Identified
324
+
325
+ **${confirmedHypothesis.id}**: ${confirmedHypothesis.description}
326
+
327
+ Evidence supporting this conclusion:
328
+ ${confirmedHypothesis.supportingEvidence}
329
+ ` : `
330
+ #### Next Steps
331
+
332
+ ${nextSteps}
333
+ `}
334
+
335
+ ---
336
+
337
+ ## Current Consolidated Understanding (Updated)
338
+
339
+ ${consolidatedUnderstanding}
340
+ ```
341
+
342
+ **Step 2.4: Consolidate Understanding**
343
+
344
+ At the bottom of `understanding.md`, update the consolidated section:
345
+
346
+ - Remove or simplify proven-wrong assumptions
347
+ - Keep them in strikethrough for reference
348
+ - Focus on current valid understanding
349
+ - Avoid repeating details from timeline
350
+
351
+ ```markdown
352
+ ## Current Consolidated Understanding
353
+
354
+ ### What We Know
355
+
356
+ - ${validUnderstanding1}
357
+ - ${validUnderstanding2}
358
+
359
+ ### What Was Disproven
360
+
361
+ - ~~Initial assumption: ${wrongAssumption}~~ (Evidence: ${disproofEvidence})
362
+
363
+ ### Current Investigation Focus
364
+
365
+ ${currentFocus}
366
+
367
+ ### Remaining Questions
368
+
369
+ - ${openQuestion1}
370
+ - ${openQuestion2}
371
+ ```
372
+
373
+ **Step 2.5: Update hypotheses.json**
374
+
375
+ ```json
376
+ {
377
+ "iteration": 2,
378
+ "timestamp": "2025-01-21T10:15:00+08:00",
379
+ "hypotheses": [
380
+ {
381
+ "id": "H1",
382
+ "status": "rejected",
383
+ "verdict_reason": "Evidence shows key exists with valid value",
384
+ "evidence": {...}
385
+ },
386
+ {
387
+ "id": "H2",
388
+ "status": "confirmed",
389
+ "verdict_reason": "Log data confirms timing issue",
390
+ "evidence": {...}
391
+ }
392
+ ],
393
+ "gemini_corrections": [
394
+ {
395
+ "wrong_assumption": "...",
396
+ "corrected_to": "...",
397
+ "reason": "..."
398
+ }
399
+ ]
400
+ }
401
+ ```
402
+
403
+ ---
404
+
405
+ ### Fix & Verification
406
+
407
+ **Step 3.1: Apply Fix**
408
+
409
+ (Same as original debug command)
410
+
411
+ **Step 3.2: Document Resolution**
412
+
413
+ Append to `understanding.md`:
414
+
415
+ ```markdown
416
+ ### Iteration ${n} - Resolution (${timestamp})
417
+
418
+ #### Fix Applied
419
+
420
+ - Modified files: ${modifiedFiles.join(', ')}
421
+ - Fix description: ${fixDescription}
422
+ - Root cause addressed: ${rootCause}
423
+
424
+ #### Verification Results
425
+
426
+ ${verificationResults}
427
+
428
+ #### Lessons Learned
429
+
430
+ What we learned from this debugging session:
431
+
432
+ 1. ${lesson1}
433
+ 2. ${lesson2}
434
+ 3. ${lesson3}
435
+
436
+ #### Key Insights for Future
437
+
438
+ - ${insight1}
439
+ - ${insight2}
440
+ ```
441
+
442
+ **Step 3.3: Cleanup**
443
+
444
+ Remove debug instrumentation (same as original command).
445
+
446
+ ---
447
+
448
+ ## Session Folder Structure
449
+
450
+ ```
451
+ .workflow/.debug/DBG-{slug}-{date}/
452
+ ├── debug.log # NDJSON log (execution evidence)
453
+ ├── understanding.md # NEW: Exploration timeline + consolidated understanding
454
+ ├── hypotheses.json # NEW: Hypothesis history with verdicts
455
+ └── resolution.md # Optional: Final summary
456
+ ```
457
+
458
+ ## Understanding Document Template
459
+
460
+ ```markdown
461
+ # Understanding Document
462
+
463
+ **Session ID**: DBG-xxx-2025-01-21
464
+ **Bug Description**: [original description]
465
+ **Started**: 2025-01-21T10:00:00+08:00
466
+
467
+ ---
468
+
469
+ ## Exploration Timeline
470
+
471
+ ### Iteration 1 - Initial Exploration (2025-01-21 10:00)
472
+
473
+ #### Current Understanding
474
+ ...
475
+
476
+ #### Evidence from Code Search
477
+ ...
478
+
479
+ #### Hypotheses Generated (Gemini-Assisted)
480
+ ...
481
+
482
+ ### Iteration 2 - Evidence Analysis (2025-01-21 10:15)
483
+
484
+ #### Log Analysis Results
485
+ ...
486
+
487
+ #### Corrected Understanding
488
+ - ~~[wrong]~~ → [corrected]
489
+
490
+ #### Gemini Analysis
491
+ ...
492
+
493
+ ---
494
+
495
+ ## Current Consolidated Understanding
496
+
497
+ ### What We Know
498
+ - [valid understanding points]
499
+
500
+ ### What Was Disproven
501
+ - ~~[disproven assumptions]~~
502
+
503
+ ### Current Investigation Focus
504
+ [current focus]
505
+
506
+ ### Remaining Questions
507
+ - [open questions]
508
+ ```
509
+
510
+ ## Iteration Flow
511
+
512
+ ```
513
+ First Call (/workflow:debug-with-file "error"):
514
+ ├─ No session exists → Explore mode
515
+ ├─ Extract error keywords, search codebase
516
+ ├─ Document initial understanding in understanding.md
517
+ ├─ Use Gemini to generate hypotheses
518
+ ├─ Add logging instrumentation
519
+ └─ Await user reproduction
520
+
521
+ After Reproduction (/workflow:debug-with-file "error"):
522
+ ├─ Session exists + debug.log has content → Analyze mode
523
+ ├─ Parse log, use Gemini to evaluate hypotheses
524
+ ├─ Update understanding.md with:
525
+ ├─ Evidence analysis results
526
+ │ ├─ Corrected misunderstandings (strikethrough)
527
+ ├─ New insights
528
+ │ └─ Updated consolidated understanding
529
+ ├─ Update hypotheses.json with verdicts
530
+ └─ Decision:
531
+ ├─ Confirmed → Fix → Document resolution
532
+ ├─ Inconclusive → Add logging, document next steps
533
+ └─ All rejected → Gemini-assisted new hypotheses
534
+
535
+ Output:
536
+ ├─ .workflow/.debug/DBG-{slug}-{date}/debug.log
537
+ ├─ .workflow/.debug/DBG-{slug}-{date}/understanding.md (evolving document)
538
+ └─ .workflow/.debug/DBG-{slug}-{date}/hypotheses.json (history)
539
+ ```
540
+
541
+ ## Gemini Integration Points
542
+
543
+ ### 1. Hypothesis Generation (Explore Mode)
544
+
545
+ **Purpose**: Generate evidence-based, testable hypotheses
546
+
547
+ **Prompt Pattern**:
548
+ ```
549
+ PURPOSE: Generate debugging hypotheses + evidence criteria
550
+ TASK: Analyze error + code → testable hypotheses with clear pass/fail criteria
551
+ CONTEXT: @understanding.md (search results)
552
+ EXPECTED: JSON with hypotheses, likelihood ranking, evidence criteria
553
+ ```
554
+
555
+ ### 2. Evidence Analysis (Analyze Mode)
556
+
557
+ **Purpose**: Validate hypotheses and correct misunderstandings
558
+
559
+ **Prompt Pattern**:
560
+ ```
561
+ PURPOSE: Analyze debug log evidence + correct understanding
562
+ TASK: Evaluate each hypothesis → identify wrong assumptions → suggest corrections
563
+ CONTEXT: @debug.log @understanding.md @hypotheses.json
564
+ EXPECTED: Verdicts + corrections + updated consolidated understanding
565
+ ```
566
+
567
+ ### 3. New Hypothesis Generation (After All Rejected)
568
+
569
+ **Purpose**: Generate new hypotheses based on what was disproven
570
+
571
+ **Prompt Pattern**:
572
+ ```
573
+ PURPOSE: Generate new hypotheses given disproven assumptions
574
+ TASK: Review rejected hypotheses → identify knowledge gaps → new investigation angles
575
+ CONTEXT: @understanding.md (with disproven section) @hypotheses.json
576
+ EXPECTED: New hypotheses avoiding previously rejected paths
577
+ ```
578
+
579
+ ## Error Correction Mechanism
580
+
581
+ ### Correction Format in understanding.md
582
+
583
+ ```markdown
584
+ #### Corrected Understanding
585
+
586
+ - ~~Assumed dict key "config" was missing~~ → Key exists, but value is None
587
+ - Why wrong: Only checked existence, not value validity
588
+ - Evidence: H1 log shows {"config": null, "exists": true}
589
+
590
+ - ~~Thought error occurred in initialization~~ → Error happens during runtime update
591
+ - Why wrong: Stack trace misread as init code
592
+ - Evidence: H2 timestamp shows 30s after startup
593
+ ```
594
+
595
+ ### Consolidation Rules
596
+
597
+ When updating "Current Consolidated Understanding":
598
+
599
+ 1. **Simplify disproven items**: Move to "What Was Disproven" with single-line summary
600
+ 2. **Keep valid insights**: Promote confirmed findings to "What We Know"
601
+ 3. **Avoid duplication**: Don't repeat timeline details in consolidated section
602
+ 4. **Focus on current state**: What do we know NOW, not the journey
603
+ 5. **Preserve key corrections**: Keep important wrong→right transformations for learning
604
+
605
+ **Bad (cluttered)**:
606
+ ```markdown
607
+ ## Current Consolidated Understanding
608
+
609
+ In iteration 1 we thought X, but in iteration 2 we found Y, then in iteration 3...
610
+ Also we checked A and found B, and then we checked C...
611
+ ```
612
+
613
+ **Good (consolidated)**:
614
+ ```markdown
615
+ ## Current Consolidated Understanding
616
+
617
+ ### What We Know
618
+ - Error occurs during runtime update, not initialization
619
+ - Config value is None (not missing key)
620
+
621
+ ### What Was Disproven
622
+ - ~~Initialization error~~ (Timing evidence)
623
+ - ~~Missing key hypothesis~~ (Key exists)
624
+
625
+ ### Current Investigation Focus
626
+ Why is config value None during update?
627
+ ```
628
+
629
+ ## Post-Completion Expansion
630
+
631
+ 完成后询问用户是否扩展为issue(test/enhance/refactor/doc),选中项调用 `/issue:new "{summary} - {dimension}"`
632
+
633
+ ---
634
+
635
+ ## Error Handling
636
+
637
+ | Situation | Action |
638
+ |-----------|--------|
639
+ | Empty debug.log | Verify reproduction triggered the code path |
640
+ | All hypotheses rejected | Use Gemini to generate new hypotheses based on disproven assumptions |
641
+ | Fix doesn't work | Document failed fix attempt, iterate with refined understanding |
642
+ | >5 iterations | Review consolidated understanding, escalate to `/workflow:lite-fix` with full context |
643
+ | Gemini unavailable | Fallback to manual hypothesis generation, document without Gemini insights |
644
+ | Understanding too long | Consolidate aggressively, archive old iterations to separate file |
645
+
646
+ ## Comparison with /workflow:debug
647
+
648
+ | Feature | /workflow:debug | /workflow:debug-with-file |
649
+ |---------|-----------------|---------------------------|
650
+ | NDJSON logging | | ✅ |
651
+ | Hypothesis generation | Manual | Gemini-assisted |
652
+ | Exploration documentation | ❌ | ✅ understanding.md |
653
+ | Understanding evolution | ❌ | ✅ Timeline + corrections |
654
+ | Error correction | ❌ | ✅ Strikethrough + reasoning |
655
+ | Consolidated learning | ❌ | ✅ Current understanding section |
656
+ | Hypothesis history | ❌ | ✅ hypotheses.json |
657
+ | Gemini validation | ❌ | ✅ At key decision points |
658
+
659
+ ## Usage Recommendations
660
+
661
+ Use `/workflow:debug-with-file` when:
662
+ - Complex bugs requiring multiple investigation rounds
663
+ - Learning from debugging process is valuable
664
+ - Team needs to understand debugging rationale
665
+ - Bug might recur, documentation helps prevention
666
+
667
+ Use `/workflow:debug` when:
668
+ - Simple, quick bugs
669
+ - One-off issues
670
+ - Documentation overhead not needed