claude-code-workflow 7.2.29 → 7.2.30

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