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,597 +1,630 @@
1
- ---
2
- name: tdd-plan
3
- description: TDD workflow planning with Red-Green-Refactor task chain generation, test-first development structure, and cycle tracking
4
- argument-hint: "\"feature description\"|file.md"
5
- allowed-tools: SlashCommand(*), TodoWrite(*), Read(*), Bash(*)
6
- ---
7
-
8
- # TDD Workflow Plan Command (/workflow:tdd-plan)
9
-
10
- ## Coordinator Role
11
-
12
- **This command is a pure orchestrator**: Executes 6 slash commands in sequence, parse outputs, pass context, and ensure complete TDD workflow creation with Red-Green-Refactor task generation.
13
-
14
- **CLI Tool Selection**: CLI tool usage is determined semantically from user's task description. Include "use Codex/Gemini/Qwen" in your request for CLI execution.
15
-
16
- **Task Attachment Model**:
17
- - SlashCommand execute **expands workflow** by attaching sub-tasks to current TodoWrite
18
- - When executing a sub-command (e.g., `/workflow:tools:test-context-gather`), its internal tasks are attached to the orchestrator's TodoWrite
19
- - Orchestrator **executes these attached tasks** sequentially
20
- - After completion, attached tasks are **collapsed** back to high-level phase summary
21
- - This is **task expansion**, not external delegation
22
-
23
- **Auto-Continue Mechanism**:
24
- - TodoList tracks current phase status and dynamically manages task attachment/collapse
25
- - When each phase finishes executing, automatically execute next pending phase
26
- - All phases run autonomously without user interaction
27
- - **⚠️ CONTINUOUS EXECUTION** - Do not stop until all phases complete
28
-
29
- ## Core Rules
30
-
31
- 1. **Start Immediately**: First action is TodoWrite initialization, second action is execute Phase 1
32
- 2. **No Preliminary Analysis**: Do not read files before Phase 1
33
- 3. **Parse Every Output**: Extract required data for next phase
34
- 4. **Auto-Continue via TodoList**: Check TodoList status to execute next pending phase automatically
35
- 5. **Track Progress**: Update TodoWrite dynamically with task attachment/collapse pattern
36
- 6. **TDD Context**: All descriptions include "TDD:" prefix
37
- 7. **Task Attachment Model**: SlashCommand execute **attaches** sub-tasks to current workflow. Orchestrator **executes** these attached tasks itself, then **collapses** them after completion
38
- 8. **⚠️ CRITICAL: DO NOT STOP**: Continuous multi-phase workflow. After executing all attached tasks, immediately collapse them and execute next phase
39
-
40
- ## TDD Compliance Requirements
41
-
42
- ### The Iron Law
43
-
44
- ```
45
- NO PRODUCTION CODE WITHOUT A FAILING TEST FIRST
46
- ```
47
-
48
- **Enforcement Method**:
49
- - Phase 5: `implementation_approach` includes test-first steps (Red → Green → Refactor)
50
- - Green phase: Includes test-fix-cycle configuration (max 3 iterations)
51
- - Auto-revert: Triggered when max iterations reached without passing tests
52
-
53
- **Verification**: Phase 6 validates Red-Green-Refactor structure in all generated tasks
54
-
55
- ### TDD Compliance Checkpoint
56
-
57
- | Checkpoint | Validation Phase | Evidence Required |
58
- |------------|------------------|-------------------|
59
- | Test-first structure | Phase 5 | `implementation_approach` has 3 steps |
60
- | Red phase exists | Phase 6 | Step 1: `tdd_phase: "red"` |
61
- | Green phase with test-fix | Phase 6 | Step 2: `tdd_phase: "green"` + test-fix-cycle |
62
- | Refactor phase exists | Phase 6 | Step 3: `tdd_phase: "refactor"` |
63
-
64
- ### Core TDD Principles (from ref skills)
65
-
66
- **Red Flags - STOP and Reassess**:
67
- - Code written before test
68
- - Test passes immediately (no Red phase witnessed)
69
- - Cannot explain why test should fail
70
- - "Just this once" rationalization
71
- - "Tests after achieve same goals" thinking
72
-
73
- **Why Order Matters**:
74
- - Tests written after code pass immediately → proves nothing
75
- - Test-first forces edge case discovery before implementation
76
- - Tests-after verify what was built, not what's required
77
-
78
- ## 6-Phase Execution (with Conflict Resolution)
79
-
80
- ### Phase 1: Session Discovery
81
-
82
- **Step 1.1: Execute** - Session discovery and initialization
83
-
84
- ```javascript
85
- SlashCommand(command="/workflow:session:start --type tdd --auto \"TDD: [structured-description]\"")
86
- ```
87
-
88
- **TDD Structured Format**:
89
- ```
90
- TDD: [Feature Name]
91
- GOAL: [Objective]
92
- SCOPE: [Included/excluded]
93
- CONTEXT: [Background]
94
- TEST_FOCUS: [Test scenarios]
95
- ```
96
-
97
- **Parse**: Extract sessionId
98
-
99
- **TodoWrite**: Mark phase 1 completed, phase 2 in_progress
100
-
101
- **After Phase 1**: Return to user showing Phase 1 results, then auto-continue to Phase 2
102
-
103
- ---
104
-
105
- ### Phase 2: Context Gathering
106
-
107
- **Step 2.1: Execute** - Context gathering and analysis
108
-
109
- ```javascript
110
- SlashCommand(command="/workflow:tools:context-gather --session [sessionId] \"TDD: [structured-description]\"")
111
- ```
112
-
113
- **Use Same Structured Description**: Pass the same structured format from Phase 1
114
-
115
- **Input**: `sessionId` from Phase 1
116
-
117
- **Parse Output**:
118
- - Extract: context-package.json path (store as `contextPath`)
119
- - Typical pattern: `.workflow/active/[sessionId]/.process/context-package.json`
120
-
121
- **Validation**:
122
- - Context package path extracted
123
- - File exists and is valid JSON
124
-
125
- **TodoWrite**: Mark phase 2 completed, phase 3 in_progress
126
-
127
- **After Phase 2**: Return to user showing Phase 2 results, then auto-continue to Phase 3
128
-
129
- ---
130
-
131
- ### Phase 3: Test Coverage Analysis
132
-
133
- **Step 3.1: Execute** - Test coverage analysis and framework detection
134
-
135
- ```javascript
136
- SlashCommand(command="/workflow:tools:test-context-gather --session [sessionId]")
137
- ```
138
-
139
- **Purpose**: Analyze existing codebase for:
140
- - Existing test patterns and conventions
141
- - Current test coverage
142
- - Related components and integration points
143
- - Test framework detection
144
-
145
- **Parse**: Extract testContextPath (`.workflow/active/[sessionId]/.process/test-context-package.json`)
146
-
147
-
148
-
149
- <!-- TodoWrite: When test-context-gather executed, INSERT 3 test-context-gather tasks -->
150
-
151
- **TodoWrite Update (Phase 3 SlashCommand executed - tasks attached)**:
152
- ```json
153
- [
154
- {"content": "Phase 1: Session Discovery", "status": "completed", "activeForm": "Executing session discovery"},
155
- {"content": "Phase 2: Context Gathering", "status": "completed", "activeForm": "Executing context gathering"},
156
- {"content": "Phase 3: Test Coverage Analysis", "status": "in_progress", "activeForm": "Executing test coverage analysis"},
157
- {"content": " → Detect test framework and conventions", "status": "in_progress", "activeForm": "Detecting test framework"},
158
- {"content": " → Analyze existing test coverage", "status": "pending", "activeForm": "Analyzing test coverage"},
159
- {"content": " → Identify coverage gaps", "status": "pending", "activeForm": "Identifying coverage gaps"},
160
- {"content": "Phase 5: TDD Task Generation", "status": "pending", "activeForm": "Executing TDD task generation"},
161
- {"content": "Phase 6: TDD Structure Validation", "status": "pending", "activeForm": "Validating TDD structure"}
162
- ]
163
- ```
164
-
165
- **Note**: SlashCommand execute **attaches** test-context-gather's 3 tasks. Orchestrator **executes** these tasks.
166
-
167
- **Next Action**: Tasks attached → **Execute Phase 3.1-3.3** sequentially
168
-
169
- <!-- TodoWrite: After Phase 3 tasks complete, REMOVE Phase 3.1-3.3, restore to orchestrator view -->
170
-
171
- **TodoWrite Update (Phase 3 completed - tasks collapsed)**:
172
- ```json
173
- [
174
- {"content": "Phase 1: Session Discovery", "status": "completed", "activeForm": "Executing session discovery"},
175
- {"content": "Phase 2: Context Gathering", "status": "completed", "activeForm": "Executing context gathering"},
176
- {"content": "Phase 3: Test Coverage Analysis", "status": "completed", "activeForm": "Executing test coverage analysis"},
177
- {"content": "Phase 5: TDD Task Generation", "status": "pending", "activeForm": "Executing TDD task generation"},
178
- {"content": "Phase 6: TDD Structure Validation", "status": "pending", "activeForm": "Validating TDD structure"}
179
- ]
180
- ```
181
-
182
- **Note**: Phase 3 tasks completed and collapsed to summary.
183
-
184
- **After Phase 3**: Return to user showing test coverage results, then auto-continue to Phase 4/5 (depending on conflict_risk)
185
-
186
- ---
187
-
188
- ### Phase 4: Conflict Resolution (Optional - auto-triggered by conflict risk)
189
-
190
- **Trigger**: Only execute when context-package.json indicates conflict_risk is "medium" or "high"
191
-
192
- **Step 4.1: Execute** - Conflict detection and resolution
193
-
194
- ```javascript
195
- SlashCommand(command="/workflow:tools:conflict-resolution --session [sessionId] --context [contextPath]")
196
- ```
197
-
198
- **Input**:
199
- - sessionId from Phase 1
200
- - contextPath from Phase 2
201
- - conflict_risk from context-package.json
202
-
203
- **Parse Output**:
204
- - Extract: Execution status (success/skipped/failed)
205
- - Verify: conflict-resolution.json file path (if executed)
206
-
207
- **Validation**:
208
- - File `.workflow/active/[sessionId]/.process/conflict-resolution.json` exists (if executed)
209
-
210
- **Skip Behavior**:
211
- - If conflict_risk is "none" or "low", skip directly to Phase 5
212
- - Display: "No significant conflicts detected, proceeding to TDD task generation"
213
-
214
- <!-- TodoWrite: If conflict_risk ≥ medium, INSERT 3 conflict-resolution tasks when executed -->
215
-
216
- **TodoWrite Update (Phase 4 SlashCommand executed - tasks attached, if conflict_risk ≥ medium)**:
217
- ```json
218
- [
219
- {"content": "Phase 1: Session Discovery", "status": "completed", "activeForm": "Executing session discovery"},
220
- {"content": "Phase 2: Context Gathering", "status": "completed", "activeForm": "Executing context gathering"},
221
- {"content": "Phase 3: Test Coverage Analysis", "status": "completed", "activeForm": "Executing test coverage analysis"},
222
- {"content": "Phase 4: Conflict Resolution", "status": "in_progress", "activeForm": "Executing conflict resolution"},
223
- {"content": " → Detect conflicts with CLI analysis", "status": "in_progress", "activeForm": "Detecting conflicts"},
224
- {"content": " → Log and analyze detected conflicts", "status": "pending", "activeForm": "Analyzing conflicts"},
225
- {"content": " → Apply resolution strategies", "status": "pending", "activeForm": "Applying resolution strategies"},
226
- {"content": "Phase 5: TDD Task Generation", "status": "pending", "activeForm": "Executing TDD task generation"},
227
- {"content": "Phase 6: TDD Structure Validation", "status": "pending", "activeForm": "Validating TDD structure"}
228
- ]
229
- ```
230
-
231
- **Note**: SlashCommand execute **attaches** conflict-resolution's 3 tasks. Orchestrator **executes** these tasks.
232
-
233
- **Next Action**: Tasks attached → **Execute Phase 4.1-4.3** sequentially
234
-
235
- <!-- TodoWrite: After Phase 4 tasks complete, REMOVE Phase 4.1-4.3, restore to orchestrator view -->
236
-
237
- **TodoWrite Update (Phase 4 completed - tasks collapsed)**:
238
- ```json
239
- [
240
- {"content": "Phase 1: Session Discovery", "status": "completed", "activeForm": "Executing session discovery"},
241
- {"content": "Phase 2: Context Gathering", "status": "completed", "activeForm": "Executing context gathering"},
242
- {"content": "Phase 3: Test Coverage Analysis", "status": "completed", "activeForm": "Executing test coverage analysis"},
243
- {"content": "Phase 4: Conflict Resolution", "status": "completed", "activeForm": "Executing conflict resolution"},
244
- {"content": "Phase 5: TDD Task Generation", "status": "pending", "activeForm": "Executing TDD task generation"},
245
- {"content": "Phase 6: TDD Structure Validation", "status": "pending", "activeForm": "Validating TDD structure"}
246
- ]
247
- ```
248
-
249
- **Note**: Phase 4 tasks completed and collapsed to summary.
250
-
251
- **After Phase 4**: Return to user showing conflict resolution results (if executed) and selected strategies, then auto-continue to Phase 5
252
-
253
- **Memory State Check**:
254
- - Evaluate current context window usage and memory state
255
- - If memory usage is high (>110K tokens or approaching context limits):
256
-
257
- **Step 4.5: Execute** - Memory compaction
258
-
259
- ```javascript
260
- SlashCommand(command="/compact")
261
- ```
262
-
263
- - This optimizes memory before proceeding to Phase 5
264
- - Memory compaction is particularly important after analysis phase which may generate extensive documentation
265
- - Ensures optimal performance and prevents context overflow
266
-
267
- ---
268
-
269
- ### Phase 5: TDD Task Generation
270
-
271
- **Step 5.1: Execute** - TDD task generation via action-planning-agent
272
-
273
- ```javascript
274
- SlashCommand(command="/workflow:tools:task-generate-tdd --session [sessionId]")
275
- ```
276
-
277
- **Note**: CLI tool usage is determined semantically from user's task description.
278
-
279
- **Parse**: Extract feature count, task count (not chain count - tasks now contain internal TDD cycles)
280
-
281
- **Validate**:
282
- - IMPL_PLAN.md exists (unified plan with TDD Implementation Tasks section)
283
- - IMPL-*.json files exist (one per feature, or container + subtasks for complex features)
284
- - TODO_LIST.md exists with internal TDD phase indicators
285
- - Each IMPL task includes:
286
- - `meta.tdd_workflow: true`
287
- - `flow_control.implementation_approach` with 3 steps (red/green/refactor)
288
- - Green phase includes test-fix-cycle configuration
289
- - IMPL_PLAN.md contains workflow_type: "tdd" in frontmatter
290
- - Task count ≤10 (compliance with task limit)
291
-
292
- **Red Flag Detection** (Non-Blocking Warnings):
293
- - Task count >10: `⚠️ High task count may indicate insufficient decomposition`
294
- - Missing test-fix-cycle: `⚠️ Green phase lacks auto-revert configuration`
295
- - Generic task names: `⚠️ Vague task names suggest unclear TDD cycles`
296
-
297
- **Action**: Log warnings to `.workflow/active/[sessionId]/.process/tdd-warnings.log` (non-blocking)
298
-
299
- <!-- TodoWrite: When task-generate-tdd executed, INSERT 3 task-generate-tdd tasks -->
300
-
301
- **TodoWrite Update (Phase 5 SlashCommand executed - tasks attached)**:
302
- ```json
303
- [
304
- {"content": "Phase 1: Session Discovery", "status": "completed", "activeForm": "Executing session discovery"},
305
- {"content": "Phase 2: Context Gathering", "status": "completed", "activeForm": "Executing context gathering"},
306
- {"content": "Phase 3: Test Coverage Analysis", "status": "completed", "activeForm": "Executing test coverage analysis"},
307
- {"content": "Phase 5: TDD Task Generation", "status": "in_progress", "activeForm": "Executing TDD task generation"},
308
- {"content": " → Discovery - analyze TDD requirements", "status": "in_progress", "activeForm": "Analyzing TDD requirements"},
309
- {"content": " → Planning - design Red-Green-Refactor cycles", "status": "pending", "activeForm": "Designing TDD cycles"},
310
- {"content": " → Output - generate IMPL tasks with internal TDD phases", "status": "pending", "activeForm": "Generating TDD tasks"},
311
- {"content": "Phase 6: TDD Structure Validation", "status": "pending", "activeForm": "Validating TDD structure"}
312
- ]
313
- ```
314
-
315
- **Note**: SlashCommand execute **attaches** task-generate-tdd's 3 tasks. Orchestrator **executes** these tasks. Each generated IMPL task will contain internal Red-Green-Refactor cycle.
316
-
317
- **Next Action**: Tasks attached **Execute Phase 5.1-5.3** sequentially
318
-
319
- <!-- TodoWrite: After Phase 5 tasks complete, REMOVE Phase 5.1-5.3, restore to orchestrator view -->
320
-
321
- **TodoWrite Update (Phase 5 completed - tasks collapsed)**:
322
- ```json
323
- [
324
- {"content": "Phase 1: Session Discovery", "status": "completed", "activeForm": "Executing session discovery"},
325
- {"content": "Phase 2: Context Gathering", "status": "completed", "activeForm": "Executing context gathering"},
326
- {"content": "Phase 3: Test Coverage Analysis", "status": "completed", "activeForm": "Executing test coverage analysis"},
327
- {"content": "Phase 5: TDD Task Generation", "status": "completed", "activeForm": "Executing TDD task generation"},
328
- {"content": "Phase 6: TDD Structure Validation", "status": "in_progress", "activeForm": "Validating TDD structure"}
329
- ]
330
- ```
331
-
332
- **Note**: Phase 5 tasks completed and collapsed to summary. Each generated IMPL task contains complete Red-Green-Refactor cycle internally.
333
-
334
- ### Phase 6: TDD Structure Validation & Action Plan Verification (RECOMMENDED)
335
- **Internal validation first, then recommend external verification**
336
-
337
- **Internal Validation**:
338
- 1. Each task contains complete TDD workflow (Red-Green-Refactor internally)
339
- 2. Task structure validation:
340
- - `meta.tdd_workflow: true` in all IMPL tasks
341
- - `flow_control.implementation_approach` has exactly 3 steps
342
- - Each step has correct `tdd_phase`: "red", "green", "refactor"
343
- 3. Dependency validation:
344
- - Sequential features: IMPL-N depends_on ["IMPL-(N-1)"] if needed
345
- - Complex features: IMPL-N.M depends_on ["IMPL-N.(M-1)"] for subtasks
346
- 4. Agent assignment: All IMPL tasks use @code-developer
347
- 5. Test-fix cycle: Green phase step includes test-fix-cycle logic with max_iterations
348
- 6. Task count: Total tasks ≤10 (simple + subtasks)
349
-
350
- **Red Flag Checklist** (from TDD best practices):
351
- - [ ] No tasks skip Red phase (`tdd_phase: "red"` exists in step 1)
352
- - [ ] Test files referenced in Red phase (explicit paths, not placeholders)
353
- - [ ] Green phase has test-fix-cycle with `max_iterations` configured
354
- - [ ] Refactor phase has clear completion criteria
355
-
356
- **Non-Compliance Warning Format**:
357
- ```
358
- ⚠️ TDD Red Flag: [issue description]
359
- Task: [IMPL-N]
360
- Recommendation: [action to fix]
361
- ```
362
-
363
- **Evidence Gathering** (Before Completion Claims):
364
-
365
- ```bash
366
- # Verify session artifacts exist
367
- ls -la .workflow/active/[sessionId]/{IMPL_PLAN.md,TODO_LIST.md}
368
- ls -la .workflow/active/[sessionId]/.task/IMPL-*.json
369
-
370
- # Count generated artifacts
371
- echo "IMPL tasks: $(ls .workflow/active/[sessionId]/.task/IMPL-*.json 2>/dev/null | wc -l)"
372
-
373
- # Sample task structure verification (first task)
374
- jq '{id, tdd: .meta.tdd_workflow, phases: [.flow_control.implementation_approach[].tdd_phase]}' \
375
- "$(ls .workflow/active/[sessionId]/.task/IMPL-*.json | head -1)"
376
- ```
377
-
378
- **Evidence Required Before Summary**:
379
- | Evidence Type | Verification Method | Pass Criteria |
380
- |---------------|---------------------|---------------|
381
- | File existence | `ls -la` artifacts | All files present |
382
- | Task count | Count IMPL-*.json | Count matches claims |
383
- | TDD structure | jq sample extraction | Shows red/green/refactor |
384
- | Warning log | Check tdd-warnings.log | Logged (may be empty) |
385
-
386
- **Return Summary**:
387
- ```
388
- TDD Planning complete for session: [sessionId]
389
-
390
- Features analyzed: [N]
391
- Total tasks: [M] (1 task per simple feature + subtasks for complex features)
392
-
393
- Task breakdown:
394
- - Simple features: [K] tasks (IMPL-1 to IMPL-K)
395
- - Complex features: [L] features with [P] subtasks
396
- - Total task count: [M] (within 10-task limit)
397
-
398
- Structure:
399
- - IMPL-1: {Feature 1 Name} (Internal: Red → Green → Refactor)
400
- - IMPL-2: {Feature 2 Name} (Internal: Red Green → Refactor)
401
- - IMPL-3: {Complex Feature} (Container)
402
- - IMPL-3.1: {Sub-feature A} (Internal: Red Green → Refactor)
403
- - IMPL-3.2: {Sub-feature B} (Internal: Red Green Refactor)
404
- [...]
405
-
406
- Plans generated:
407
- - Unified Implementation Plan: .workflow/active/[sessionId]/IMPL_PLAN.md
408
- (includes TDD Implementation Tasks section with workflow_type: "tdd")
409
- - Task List: .workflow/active/[sessionId]/TODO_LIST.md
410
- (with internal TDD phase indicators)
411
-
412
- TDD Configuration:
413
- - Each task contains complete Red-Green-Refactor cycle
414
- - Green phase includes test-fix cycle (max 3 iterations)
415
- - Auto-revert on max iterations reached
416
-
417
- ⚠️ ACTION REQUIRED: Before execution, ensure you understand WHY each Red phase test is expected to fail.
418
- This is crucial for valid TDD - if you don't know why the test fails, you can't verify it tests the right thing.
419
-
420
- Recommended Next Steps:
421
- 1. /workflow:action-plan-verify --session [sessionId] # Verify TDD plan quality and dependencies
422
- 2. /workflow:execute --session [sessionId] # Start TDD execution
423
- 3. /workflow:tdd-verify [sessionId] # Post-execution TDD compliance check
424
-
425
- Quality Gate: Consider running /workflow:action-plan-verify to validate TDD task structure and dependencies
426
- ```
427
-
428
- ## TodoWrite Pattern
429
-
430
- **Core Concept**: Dynamic task attachment and collapse for TDD workflow with test coverage analysis and Red-Green-Refactor cycle generation.
431
-
432
- ### Key Principles
433
-
434
- 1. **Task Attachment** (when SlashCommand executed):
435
- - Sub-command's internal tasks are **attached** to orchestrator's TodoWrite
436
- - Example: `/workflow:tools:test-context-gather` attaches 3 sub-tasks (Phase 3.1, 3.2, 3.3)
437
- - First attached task marked as `in_progress`, others as `pending`
438
- - Orchestrator **executes** these attached tasks sequentially
439
-
440
- 2. **Task Collapse** (after sub-tasks complete):
441
- - Remove detailed sub-tasks from TodoWrite
442
- - **Collapse** to high-level phase summary
443
- - Example: Phase 3.1-3.3 collapse to "Execute test coverage analysis: completed"
444
- - Maintains clean orchestrator-level view
445
-
446
- 3. **Continuous Execution**:
447
- - After collapse, automatically proceed to next pending phase
448
- - No user intervention required between phases
449
- - TodoWrite dynamically reflects current execution state
450
-
451
- **Lifecycle Summary**: Initial pending tasks → Phase executed (tasks ATTACHED) → Sub-tasks executed sequentially → Phase completed (tasks COLLAPSED to summary) → Next phase begins (conditional Phase 4 if conflict_risk ≥ medium) → Repeat until all phases complete.
452
-
453
- ### TDD-Specific Features
454
-
455
- - **Phase 3**: Test coverage analysis detects existing patterns and gaps
456
- - **Phase 5**: Generated IMPL tasks contain internal Red-Green-Refactor cycles
457
- - **Conditional Phase 4**: Conflict resolution only if conflict_risk ≥ medium
458
-
459
-
460
-
461
- **Note**: See individual Phase descriptions (Phase 3, 4, 5) for detailed TodoWrite Update examples with full JSON structures.
462
-
463
- ## Execution Flow Diagram
464
-
465
- ```
466
- TDD Workflow Orchestrator
467
-
468
- ├─ Phase 1: Session Discovery
469
- │ └─ /workflow:session:start --auto
470
- │ └─ Returns: sessionId
471
-
472
- ├─ Phase 2: Context Gathering
473
- │ └─ /workflow:tools:context-gather
474
- │ └─ Returns: context-package.json path
475
-
476
- ├─ Phase 3: Test Coverage Analysis ← ATTACHED (3 tasks)
477
- │ └─ /workflow:tools:test-context-gather
478
- │ ├─ Phase 3.1: Detect test framework
479
- │ ├─ Phase 3.2: Analyze existing test coverage
480
- │ └─ Phase 3.3: Identify coverage gaps
481
- │ └─ Returns: test-context-package.json ← COLLAPSED
482
-
483
- ├─ Phase 4: Conflict Resolution (conditional)
484
- │ IF conflict_risk ≥ medium:
485
- │ └─ /workflow:tools:conflict-resolution ← ATTACHED (3 tasks)
486
- │ ├─ Phase 4.1: Detect conflicts with CLI
487
- │ ├─ Phase 4.2: Log and analyze detected conflicts
488
- │ └─ Phase 4.3: Apply resolution strategies
489
- │ └─ Returns: conflict-resolution.json ← COLLAPSED
490
- │ ELSE:
491
- │ └─ Skip to Phase 5
492
-
493
- ├─ Phase 5: TDD Task Generation ← ATTACHED (3 tasks)
494
- │ └─ /workflow:tools:task-generate-tdd
495
- │ ├─ Phase 5.1: Discovery - analyze TDD requirements
496
- │ ├─ Phase 5.2: Planning - design Red-Green-Refactor cycles
497
- │ └─ Phase 5.3: Output - generate IMPL tasks with internal TDD phases
498
- └─ Returns: IMPL-*.json, IMPL_PLAN.md ← COLLAPSED
499
- │ (Each IMPL task contains internal Red-Green-Refactor cycle)
500
-
501
- └─ Phase 6: TDD Structure Validation
502
- └─ Internal validation + summary returned
503
- └─ Recommend: /workflow:action-plan-verify
504
-
505
- Key Points:
506
- • ← ATTACHED: SlashCommand attaches sub-tasks to orchestrator TodoWrite
507
- COLLAPSED: Sub-tasks executed and collapsed to phase summary
508
- TDD-specific: Each generated IMPL task contains complete Red-Green-Refactor cycle
509
- ```
510
-
511
- ## Input Processing
512
-
513
- Convert user input to TDD-structured format:
514
-
515
- **Simple text** Add TDD context
516
- **Detailed text** Extract components with TEST_FOCUS
517
- **File/Issue** Read and structure with TDD
518
-
519
- ## Error Handling
520
-
521
- - **Parsing failure**: Retry once, then report
522
- - **Validation failure**: Report missing/invalid data
523
- - **Command failure**: Keep phase in_progress, report error
524
- - **TDD validation failure**: Report incomplete chains or wrong dependencies
525
-
526
- ### TDD Warning Patterns
527
-
528
- | Pattern | Warning Message | Recommended Action |
529
- |---------|----------------|-------------------|
530
- | Task count >10 | High task count detected | Consider splitting into multiple sessions |
531
- | Missing test-fix-cycle | Green phase lacks auto-revert | Add `max_iterations: 3` to task config |
532
- | Red phase missing test path | Test file path not specified | Add explicit test file paths |
533
- | Generic task names | Vague names like "Add feature" | Use specific behavior descriptions |
534
- | No refactor criteria | Refactor phase lacks completion criteria | Define clear refactor scope |
535
-
536
- ### Non-Blocking Warning Policy
537
-
538
- **All warnings are advisory** - they do not halt execution:
539
- 1. Warnings logged to `.process/tdd-warnings.log`
540
- 2. Summary displayed in Phase 6 output
541
- 3. User decides whether to address before `/workflow:execute`
542
-
543
- ### Error Handling Quick Reference
544
-
545
- | Error Type | Detection | Recovery Action |
546
- |------------|-----------|-----------------|
547
- | Parsing failure | Empty/malformed output | Retry once, then report |
548
- | Missing context-package | File read error | Re-run `/workflow:tools:context-gather` |
549
- | Invalid task JSON | jq parse error | Report malformed file path |
550
- | High task count (>10) | Count validation | Log warning, continue (non-blocking) |
551
- | Test-context missing | File not found | Re-run `/workflow:tools:test-context-gather` |
552
- | Phase timeout | No response | Retry phase, check CLI connectivity |
553
-
554
- ## Related Commands
555
-
556
- **Prerequisite Commands**:
557
- - None - TDD planning is self-contained (can optionally run brainstorm commands before)
558
-
559
- **Called by This Command** (6 phases):
560
- - `/workflow:session:start` - Phase 1: Create or discover TDD workflow session
561
- - `/workflow:tools:context-gather` - Phase 2: Gather project context and analyze codebase
562
- - `/workflow:tools:test-context-gather` - Phase 3: Analyze existing test patterns and coverage
563
- - `/workflow:tools:conflict-resolution` - Phase 4: Detect and resolve conflicts (auto-triggered if conflict_risk medium)
564
- - `/compact` - Phase 4: Memory optimization (if context approaching limits)
565
- - `/workflow:tools:task-generate-tdd` - Phase 5: Generate TDD tasks (CLI tool usage determined semantically)
566
-
567
- **Follow-up Commands**:
568
- - `/workflow:action-plan-verify` - Recommended: Verify TDD plan quality and structure before execution
569
- - `/workflow:status` - Review TDD task breakdown
570
- - `/workflow:execute` - Begin TDD implementation
571
- - `/workflow:tdd-verify` - Post-execution: Verify TDD compliance and generate quality report
572
-
573
- ## Next Steps Decision Table
574
-
575
- | Situation | Recommended Command | Purpose |
576
- |-----------|---------------------|---------|
577
- | First time planning | `/workflow:action-plan-verify` | Validate task structure before execution |
578
- | Warnings in tdd-warnings.log | Review log, refine tasks | Address Red Flags before proceeding |
579
- | High task count warning | Consider `/workflow:session:start` | Split into focused sub-sessions |
580
- | Ready to implement | `/workflow:execute` | Begin TDD Red-Green-Refactor cycles |
581
- | After implementation | `/workflow:tdd-verify` | Generate TDD compliance report |
582
- | Need to review tasks | `/workflow:status --session [id]` | Inspect current task breakdown |
583
- | Plan needs changes | `/task:replan` | Update task JSON with new requirements |
584
-
585
- ### TDD Workflow State Transitions
586
-
587
- ```
588
- /workflow:tdd-plan
589
-
590
- [Planning Complete] ──→ /workflow:action-plan-verify (recommended)
591
-
592
- [Verified/Ready] ─────→ /workflow:execute
593
-
594
- [Implementation] ─────→ /workflow:tdd-verify (post-execution)
595
-
596
- [Quality Report] ─────→ Done or iterate
597
- ```
1
+ ---
2
+ name: tdd-plan
3
+ description: TDD workflow planning with Red-Green-Refactor task chain generation, test-first development structure, and cycle tracking
4
+ argument-hint: "\"feature description\"|file.md"
5
+ allowed-tools: SlashCommand(*), TodoWrite(*), Read(*), Bash(*)
6
+ ---
7
+
8
+ # TDD Workflow Plan Command (/workflow:tdd-plan)
9
+
10
+ ## Coordinator Role
11
+
12
+ **This command is a pure orchestrator**: Executes 6 slash commands in sequence, parse outputs, pass context, and ensure complete TDD workflow creation with Red-Green-Refactor task generation.
13
+
14
+ **CLI Tool Selection**: CLI tool usage is determined semantically from user's task description. Include "use Codex/Gemini/Qwen" in your request for CLI execution.
15
+
16
+ **Task Attachment Model**:
17
+ - SlashCommand execute **expands workflow** by attaching sub-tasks to current TodoWrite
18
+ - When executing a sub-command (e.g., `/workflow:tools:test-context-gather`), its internal tasks are attached to the orchestrator's TodoWrite
19
+ - Orchestrator **executes these attached tasks** sequentially
20
+ - After completion, attached tasks are **collapsed** back to high-level phase summary
21
+ - This is **task expansion**, not external delegation
22
+
23
+ **Auto-Continue Mechanism**:
24
+ - TodoList tracks current phase status and dynamically manages task attachment/collapse
25
+ - When each phase finishes executing, automatically execute next pending phase
26
+ - All phases run autonomously without user interaction
27
+ - **⚠️ CONTINUOUS EXECUTION** - Do not stop until all phases complete
28
+
29
+ ## Core Rules
30
+
31
+ 1. **Start Immediately**: First action is TodoWrite initialization, second action is execute Phase 1
32
+ 2. **No Preliminary Analysis**: Do not read files before Phase 1
33
+ 3. **Parse Every Output**: Extract required data for next phase
34
+ 4. **Auto-Continue via TodoList**: Check TodoList status to execute next pending phase automatically
35
+ 5. **Track Progress**: Update TodoWrite dynamically with task attachment/collapse pattern
36
+ 6. **TDD Context**: All descriptions include "TDD:" prefix
37
+ 7. **Task Attachment Model**: SlashCommand execute **attaches** sub-tasks to current workflow. Orchestrator **executes** these attached tasks itself, then **collapses** them after completion
38
+ 8. **⚠️ CRITICAL: DO NOT STOP**: Continuous multi-phase workflow. After executing all attached tasks, immediately collapse them and execute next phase
39
+
40
+ ## TDD Compliance Requirements
41
+
42
+ ### The Iron Law
43
+
44
+ ```
45
+ NO PRODUCTION CODE WITHOUT A FAILING TEST FIRST
46
+ ```
47
+
48
+ **Enforcement Method**:
49
+ - Phase 5: `implementation_approach` includes test-first steps (Red → Green → Refactor)
50
+ - Green phase: Includes test-fix-cycle configuration (max 3 iterations)
51
+ - Auto-revert: Triggered when max iterations reached without passing tests
52
+
53
+ **Verification**: Phase 6 validates Red-Green-Refactor structure in all generated tasks
54
+
55
+ ### TDD Compliance Checkpoint
56
+
57
+ | Checkpoint | Validation Phase | Evidence Required |
58
+ |------------|------------------|-------------------|
59
+ | Test-first structure | Phase 5 | `implementation_approach` has 3 steps |
60
+ | Red phase exists | Phase 6 | Step 1: `tdd_phase: "red"` |
61
+ | Green phase with test-fix | Phase 6 | Step 2: `tdd_phase: "green"` + test-fix-cycle |
62
+ | Refactor phase exists | Phase 6 | Step 3: `tdd_phase: "refactor"` |
63
+
64
+ ### Core TDD Principles (from ref skills)
65
+
66
+ **Red Flags - STOP and Reassess**:
67
+ - Code written before test
68
+ - Test passes immediately (no Red phase witnessed)
69
+ - Cannot explain why test should fail
70
+ - "Just this once" rationalization
71
+ - "Tests after achieve same goals" thinking
72
+
73
+ **Why Order Matters**:
74
+ - Tests written after code pass immediately → proves nothing
75
+ - Test-first forces edge case discovery before implementation
76
+ - Tests-after verify what was built, not what's required
77
+
78
+ ## 6-Phase Execution (with Conflict Resolution)
79
+
80
+ ### Phase 1: Session Discovery
81
+
82
+ **Step 1.1: Execute** - Session discovery and initialization
83
+
84
+ ```javascript
85
+ SlashCommand(command="/workflow:session:start --type tdd --auto \"TDD: [structured-description]\"")
86
+ ```
87
+
88
+ **TDD Structured Format**:
89
+ ```
90
+ TDD: [Feature Name]
91
+ GOAL: [Objective]
92
+ SCOPE: [Included/excluded]
93
+ CONTEXT: [Background]
94
+ TEST_FOCUS: [Test scenarios]
95
+ ```
96
+
97
+ **Parse**: Extract sessionId
98
+
99
+ **TodoWrite**: Mark phase 1 completed, phase 2 in_progress
100
+
101
+ **After Phase 1**: Return to user showing Phase 1 results, then auto-continue to Phase 2
102
+
103
+ ---
104
+
105
+ ### Phase 2: Context Gathering
106
+
107
+ **Step 2.1: Execute** - Context gathering and analysis
108
+
109
+ ```javascript
110
+ SlashCommand(command="/workflow:tools:context-gather --session [sessionId] \"TDD: [structured-description]\"")
111
+ ```
112
+
113
+ **Use Same Structured Description**: Pass the same structured format from Phase 1
114
+
115
+ **Input**: `sessionId` from Phase 1
116
+
117
+ **Parse Output**:
118
+ - Extract: context-package.json path (store as `contextPath`)
119
+ - Typical pattern: `.workflow/active/[sessionId]/.process/context-package.json`
120
+
121
+ **Validation**:
122
+ - Context package path extracted
123
+ - File exists and is valid JSON
124
+
125
+ **TodoWrite**: Mark phase 2 completed, phase 3 in_progress
126
+
127
+ **After Phase 2**: Return to user showing Phase 2 results, then auto-continue to Phase 3
128
+
129
+ ---
130
+
131
+ ### Phase 3: Test Coverage Analysis
132
+
133
+ **Step 3.1: Execute** - Test coverage analysis and framework detection
134
+
135
+ ```javascript
136
+ SlashCommand(command="/workflow:tools:test-context-gather --session [sessionId]")
137
+ ```
138
+
139
+ **Purpose**: Analyze existing codebase for:
140
+ - Existing test patterns and conventions
141
+ - Current test coverage
142
+ - Related components and integration points
143
+ - Test framework detection
144
+
145
+ **Parse**: Extract testContextPath (`.workflow/active/[sessionId]/.process/test-context-package.json`)
146
+
147
+
148
+
149
+ <!-- TodoWrite: When test-context-gather executed, INSERT 3 test-context-gather tasks -->
150
+
151
+ **TodoWrite Update (Phase 3 SlashCommand executed - tasks attached)**:
152
+ ```json
153
+ [
154
+ {"content": "Phase 1: Session Discovery", "status": "completed", "activeForm": "Executing session discovery"},
155
+ {"content": "Phase 2: Context Gathering", "status": "completed", "activeForm": "Executing context gathering"},
156
+ {"content": "Phase 3: Test Coverage Analysis", "status": "in_progress", "activeForm": "Executing test coverage analysis"},
157
+ {"content": " → Detect test framework and conventions", "status": "in_progress", "activeForm": "Detecting test framework"},
158
+ {"content": " → Analyze existing test coverage", "status": "pending", "activeForm": "Analyzing test coverage"},
159
+ {"content": " → Identify coverage gaps", "status": "pending", "activeForm": "Identifying coverage gaps"},
160
+ {"content": "Phase 5: TDD Task Generation", "status": "pending", "activeForm": "Executing TDD task generation"},
161
+ {"content": "Phase 6: TDD Structure Validation", "status": "pending", "activeForm": "Validating TDD structure"}
162
+ ]
163
+ ```
164
+
165
+ **Note**: SlashCommand execute **attaches** test-context-gather's 3 tasks. Orchestrator **executes** these tasks.
166
+
167
+ **Next Action**: Tasks attached → **Execute Phase 3.1-3.3** sequentially
168
+
169
+ <!-- TodoWrite: After Phase 3 tasks complete, REMOVE Phase 3.1-3.3, restore to orchestrator view -->
170
+
171
+ **TodoWrite Update (Phase 3 completed - tasks collapsed)**:
172
+ ```json
173
+ [
174
+ {"content": "Phase 1: Session Discovery", "status": "completed", "activeForm": "Executing session discovery"},
175
+ {"content": "Phase 2: Context Gathering", "status": "completed", "activeForm": "Executing context gathering"},
176
+ {"content": "Phase 3: Test Coverage Analysis", "status": "completed", "activeForm": "Executing test coverage analysis"},
177
+ {"content": "Phase 5: TDD Task Generation", "status": "pending", "activeForm": "Executing TDD task generation"},
178
+ {"content": "Phase 6: TDD Structure Validation", "status": "pending", "activeForm": "Validating TDD structure"}
179
+ ]
180
+ ```
181
+
182
+ **Note**: Phase 3 tasks completed and collapsed to summary.
183
+
184
+ **After Phase 3**: Return to user showing test coverage results, then auto-continue to Phase 4/5 (depending on conflict_risk)
185
+
186
+ ---
187
+
188
+ ### Phase 4: Conflict Resolution (Optional - auto-triggered by conflict risk)
189
+
190
+ **Trigger**: Only execute when context-package.json indicates conflict_risk is "medium" or "high"
191
+
192
+ **Step 4.1: Execute** - Conflict detection and resolution
193
+
194
+ ```javascript
195
+ SlashCommand(command="/workflow:tools:conflict-resolution --session [sessionId] --context [contextPath]")
196
+ ```
197
+
198
+ **Input**:
199
+ - sessionId from Phase 1
200
+ - contextPath from Phase 2
201
+ - conflict_risk from context-package.json
202
+
203
+ **Parse Output**:
204
+ - Extract: Execution status (success/skipped/failed)
205
+ - Verify: conflict-resolution.json file path (if executed)
206
+
207
+ **Validation**:
208
+ - File `.workflow/active/[sessionId]/.process/conflict-resolution.json` exists (if executed)
209
+
210
+ **Skip Behavior**:
211
+ - If conflict_risk is "none" or "low", skip directly to Phase 5
212
+ - Display: "No significant conflicts detected, proceeding to TDD task generation"
213
+
214
+ <!-- TodoWrite: If conflict_risk ≥ medium, INSERT 3 conflict-resolution tasks when executed -->
215
+
216
+ **TodoWrite Update (Phase 4 SlashCommand executed - tasks attached, if conflict_risk ≥ medium)**:
217
+ ```json
218
+ [
219
+ {"content": "Phase 1: Session Discovery", "status": "completed", "activeForm": "Executing session discovery"},
220
+ {"content": "Phase 2: Context Gathering", "status": "completed", "activeForm": "Executing context gathering"},
221
+ {"content": "Phase 3: Test Coverage Analysis", "status": "completed", "activeForm": "Executing test coverage analysis"},
222
+ {"content": "Phase 4: Conflict Resolution", "status": "in_progress", "activeForm": "Executing conflict resolution"},
223
+ {"content": " → Detect conflicts with CLI analysis", "status": "in_progress", "activeForm": "Detecting conflicts"},
224
+ {"content": " → Log and analyze detected conflicts", "status": "pending", "activeForm": "Analyzing conflicts"},
225
+ {"content": " → Apply resolution strategies", "status": "pending", "activeForm": "Applying resolution strategies"},
226
+ {"content": "Phase 5: TDD Task Generation", "status": "pending", "activeForm": "Executing TDD task generation"},
227
+ {"content": "Phase 6: TDD Structure Validation", "status": "pending", "activeForm": "Validating TDD structure"}
228
+ ]
229
+ ```
230
+
231
+ **Note**: SlashCommand execute **attaches** conflict-resolution's 3 tasks. Orchestrator **executes** these tasks.
232
+
233
+ **Next Action**: Tasks attached → **Execute Phase 4.1-4.3** sequentially
234
+
235
+ <!-- TodoWrite: After Phase 4 tasks complete, REMOVE Phase 4.1-4.3, restore to orchestrator view -->
236
+
237
+ **TodoWrite Update (Phase 4 completed - tasks collapsed)**:
238
+ ```json
239
+ [
240
+ {"content": "Phase 1: Session Discovery", "status": "completed", "activeForm": "Executing session discovery"},
241
+ {"content": "Phase 2: Context Gathering", "status": "completed", "activeForm": "Executing context gathering"},
242
+ {"content": "Phase 3: Test Coverage Analysis", "status": "completed", "activeForm": "Executing test coverage analysis"},
243
+ {"content": "Phase 4: Conflict Resolution", "status": "completed", "activeForm": "Executing conflict resolution"},
244
+ {"content": "Phase 5: TDD Task Generation", "status": "pending", "activeForm": "Executing TDD task generation"},
245
+ {"content": "Phase 6: TDD Structure Validation", "status": "pending", "activeForm": "Validating TDD structure"}
246
+ ]
247
+ ```
248
+
249
+ **Note**: Phase 4 tasks completed and collapsed to summary.
250
+
251
+ **After Phase 4**: Return to user showing conflict resolution results (if executed) and selected strategies, then auto-continue to Phase 5
252
+
253
+ **Memory State Check**:
254
+ - Evaluate current context window usage and memory state
255
+ - If memory usage is high (>110K tokens or approaching context limits):
256
+
257
+ **Step 4.5: Execute** - Memory compaction
258
+
259
+ ```javascript
260
+ SlashCommand(command="/compact")
261
+ ```
262
+
263
+ - This optimizes memory before proceeding to Phase 5
264
+ - Memory compaction is particularly important after analysis phase which may generate extensive documentation
265
+ - Ensures optimal performance and prevents context overflow
266
+
267
+ ---
268
+
269
+ ### Phase 5: TDD Task Generation
270
+
271
+ **Step 5.1: Execute** - TDD task generation via action-planning-agent with Phase 0 user configuration
272
+
273
+ ```javascript
274
+ SlashCommand(command="/workflow:tools:task-generate-tdd --session [sessionId]")
275
+ ```
276
+
277
+ **Note**: Phase 0 now includes:
278
+ - Supplementary materials collection (file paths or inline content)
279
+ - Execution method preference (Agent/Hybrid/CLI)
280
+ - CLI tool preference (Codex/Gemini/Qwen/Auto)
281
+ - These preferences are passed to agent for task generation
282
+
283
+ **Parse**: Extract feature count, task count (not chain count - tasks now contain internal TDD cycles), CLI execution IDs assigned
284
+
285
+ **Validate**:
286
+ - IMPL_PLAN.md exists (unified plan with TDD Implementation Tasks section)
287
+ - IMPL-*.json files exist (one per feature, or container + subtasks for complex features)
288
+ - TODO_LIST.md exists with internal TDD phase indicators
289
+ - Each IMPL task includes:
290
+ - `meta.tdd_workflow: true`
291
+ - `meta.cli_execution_id: {session_id}-{task_id}`
292
+ - `meta.cli_execution: { "strategy": "new|resume|fork|merge_fork", ... }`
293
+ - `flow_control.implementation_approach` with exactly 3 steps (red/green/refactor)
294
+ - Green phase includes test-fix-cycle configuration
295
+ - `context.focus_paths`: absolute or clear relative paths (enhanced with exploration critical_files)
296
+ - `flow_control.pre_analysis`: includes exploration integration_points analysis
297
+ - IMPL_PLAN.md contains workflow_type: "tdd" in frontmatter
298
+ - User configuration applied:
299
+ - If executionMethod == "cli" or "hybrid": command field added to steps
300
+ - CLI tool preference reflected in execution guidance
301
+ - Task count ≤18 (compliance with hard limit)
302
+
303
+ **Red Flag Detection** (Non-Blocking Warnings):
304
+ - Task count >18: `⚠️ Task count exceeds hard limit - request re-scope`
305
+ - Missing cli_execution_id: `⚠️ Task lacks CLI execution ID for resume support`
306
+ - Missing test-fix-cycle: `⚠️ Green phase lacks auto-revert configuration`
307
+ - Generic task names: `⚠️ Vague task names suggest unclear TDD cycles`
308
+ - Missing focus_paths: `⚠️ Task lacks clear file scope for implementation`
309
+
310
+ **Action**: Log warnings to `.workflow/active/[sessionId]/.process/tdd-warnings.log` (non-blocking)
311
+
312
+ <!-- TodoWrite: When task-generate-tdd executed, INSERT 3 task-generate-tdd tasks -->
313
+
314
+ **TodoWrite Update (Phase 5 SlashCommand executed - tasks attached)**:
315
+ ```json
316
+ [
317
+ {"content": "Phase 1: Session Discovery", "status": "completed", "activeForm": "Executing session discovery"},
318
+ {"content": "Phase 2: Context Gathering", "status": "completed", "activeForm": "Executing context gathering"},
319
+ {"content": "Phase 3: Test Coverage Analysis", "status": "completed", "activeForm": "Executing test coverage analysis"},
320
+ {"content": "Phase 5: TDD Task Generation", "status": "in_progress", "activeForm": "Executing TDD task generation"},
321
+ {"content": " → Discovery - analyze TDD requirements", "status": "in_progress", "activeForm": "Analyzing TDD requirements"},
322
+ {"content": " → Planning - design Red-Green-Refactor cycles", "status": "pending", "activeForm": "Designing TDD cycles"},
323
+ {"content": " → Output - generate IMPL tasks with internal TDD phases", "status": "pending", "activeForm": "Generating TDD tasks"},
324
+ {"content": "Phase 6: TDD Structure Validation", "status": "pending", "activeForm": "Validating TDD structure"}
325
+ ]
326
+ ```
327
+
328
+ **Note**: SlashCommand execute **attaches** task-generate-tdd's 3 tasks. Orchestrator **executes** these tasks. Each generated IMPL task will contain internal Red-Green-Refactor cycle.
329
+
330
+ **Next Action**: Tasks attached → **Execute Phase 5.1-5.3** sequentially
331
+
332
+ <!-- TodoWrite: After Phase 5 tasks complete, REMOVE Phase 5.1-5.3, restore to orchestrator view -->
333
+
334
+ **TodoWrite Update (Phase 5 completed - tasks collapsed)**:
335
+ ```json
336
+ [
337
+ {"content": "Phase 1: Session Discovery", "status": "completed", "activeForm": "Executing session discovery"},
338
+ {"content": "Phase 2: Context Gathering", "status": "completed", "activeForm": "Executing context gathering"},
339
+ {"content": "Phase 3: Test Coverage Analysis", "status": "completed", "activeForm": "Executing test coverage analysis"},
340
+ {"content": "Phase 5: TDD Task Generation", "status": "completed", "activeForm": "Executing TDD task generation"},
341
+ {"content": "Phase 6: TDD Structure Validation", "status": "in_progress", "activeForm": "Validating TDD structure"}
342
+ ]
343
+ ```
344
+
345
+ **Note**: Phase 5 tasks completed and collapsed to summary. Each generated IMPL task contains complete Red-Green-Refactor cycle internally.
346
+
347
+ ### Phase 6: TDD Structure Validation & Action Plan Verification (RECOMMENDED)
348
+ **Internal validation first, then recommend external verification**
349
+
350
+ **Internal Validation**:
351
+ 1. Each task contains complete TDD workflow (Red-Green-Refactor internally)
352
+ 2. Task structure validation:
353
+ - `meta.tdd_workflow: true` in all IMPL tasks
354
+ - `meta.cli_execution_id` present (format: {session_id}-{task_id})
355
+ - `meta.cli_execution` strategy assigned (new/resume/fork/merge_fork)
356
+ - `flow_control.implementation_approach` has exactly 3 steps
357
+ - Each step has correct `tdd_phase`: "red", "green", "refactor"
358
+ - `context.focus_paths` are absolute or clear relative paths
359
+ - `flow_control.pre_analysis` includes exploration integration analysis
360
+ 3. Dependency validation:
361
+ - Sequential features: IMPL-N depends_on ["IMPL-(N-1)"] if needed
362
+ - Complex features: IMPL-N.M depends_on ["IMPL-N.(M-1)"] for subtasks
363
+ - CLI execution strategies correctly assigned based on dependency graph
364
+ 4. Agent assignment: All IMPL tasks use @code-developer
365
+ 5. Test-fix cycle: Green phase step includes test-fix-cycle logic with max_iterations
366
+ 6. Task count: Total tasks ≤18 (simple + subtasks hard limit)
367
+ 7. User configuration:
368
+ - Execution method choice reflected in task structure
369
+ - CLI tool preference documented in implementation guidance (if CLI selected)
370
+
371
+ **Red Flag Checklist** (from TDD best practices):
372
+ - [ ] No tasks skip Red phase (`tdd_phase: "red"` exists in step 1)
373
+ - [ ] Test files referenced in Red phase (explicit paths, not placeholders)
374
+ - [ ] Green phase has test-fix-cycle with `max_iterations` configured
375
+ - [ ] Refactor phase has clear completion criteria
376
+
377
+ **Non-Compliance Warning Format**:
378
+ ```
379
+ ⚠️ TDD Red Flag: [issue description]
380
+ Task: [IMPL-N]
381
+ Recommendation: [action to fix]
382
+ ```
383
+
384
+ **Evidence Gathering** (Before Completion Claims):
385
+
386
+ ```bash
387
+ # Verify session artifacts exist
388
+ ls -la .workflow/active/[sessionId]/{IMPL_PLAN.md,TODO_LIST.md}
389
+ ls -la .workflow/active/[sessionId]/.task/IMPL-*.json
390
+
391
+ # Count generated artifacts
392
+ echo "IMPL tasks: $(ls .workflow/active/[sessionId]/.task/IMPL-*.json 2>/dev/null | wc -l)"
393
+
394
+ # Sample task structure verification (first task)
395
+ jq '{id, tdd: .meta.tdd_workflow, cli_id: .meta.cli_execution_id, phases: [.flow_control.implementation_approach[].tdd_phase]}' \
396
+ "$(ls .workflow/active/[sessionId]/.task/IMPL-*.json | head -1)"
397
+ ```
398
+
399
+ **Evidence Required Before Summary**:
400
+ | Evidence Type | Verification Method | Pass Criteria |
401
+ |---------------|---------------------|---------------|
402
+ | File existence | `ls -la` artifacts | All files present |
403
+ | Task count | Count IMPL-*.json | Count matches claims (≤18) |
404
+ | TDD structure | jq sample extraction | Shows red/green/refactor + cli_execution_id |
405
+ | CLI execution IDs | jq extraction | All tasks have cli_execution_id assigned |
406
+ | Warning log | Check tdd-warnings.log | Logged (may be empty) |
407
+
408
+ **Return Summary**:
409
+ ```
410
+ TDD Planning complete for session: [sessionId]
411
+
412
+ Features analyzed: [N]
413
+ Total tasks: [M] (1 task per simple feature + subtasks for complex features)
414
+
415
+ Task breakdown:
416
+ - Simple features: [K] tasks (IMPL-1 to IMPL-K)
417
+ - Complex features: [L] features with [P] subtasks
418
+ - Total task count: [M] (within 18-task hard limit)
419
+
420
+ Structure:
421
+ - IMPL-1: {Feature 1 Name} (Internal: Red Green → Refactor)
422
+ - IMPL-2: {Feature 2 Name} (Internal: Red Green Refactor)
423
+ - IMPL-3: {Complex Feature} (Container)
424
+ - IMPL-3.1: {Sub-feature A} (Internal: Red → Green → Refactor)
425
+ - IMPL-3.2: {Sub-feature B} (Internal: Red Green Refactor)
426
+ [...]
427
+
428
+ Plans generated:
429
+ - Unified Implementation Plan: .workflow/active/[sessionId]/IMPL_PLAN.md
430
+ (includes TDD Implementation Tasks section with workflow_type: "tdd")
431
+ - Task List: .workflow/active/[sessionId]/TODO_LIST.md
432
+ (with internal TDD phase indicators and CLI execution strategies)
433
+ - Task JSONs: .workflow/active/[sessionId]/.task/IMPL-*.json
434
+ (with cli_execution_id and execution strategies for resume support)
435
+
436
+ TDD Configuration:
437
+ - Each task contains complete Red-Green-Refactor cycle
438
+ - Green phase includes test-fix cycle (max 3 iterations)
439
+ - Auto-revert on max iterations reached
440
+ - CLI execution strategies: new/resume/fork/merge_fork based on dependency graph
441
+
442
+ User Configuration Applied:
443
+ - Execution Method: [agent|hybrid|cli]
444
+ - CLI Tool Preference: [codex|gemini|qwen|auto]
445
+ - Supplementary Materials: [included|none]
446
+ - Task generation follows cli-tools-usage.md guidelines
447
+
448
+ ⚠️ ACTION REQUIRED: Before execution, ensure you understand WHY each Red phase test is expected to fail.
449
+ This is crucial for valid TDD - if you don't know why the test fails, you can't verify it tests the right thing.
450
+
451
+ Recommended Next Steps:
452
+ 1. /workflow:plan-verify --session [sessionId] # Verify TDD plan quality and dependencies
453
+ 2. /workflow:execute --session [sessionId] # Start TDD execution with CLI strategies
454
+ 3. /workflow:tdd-verify [sessionId] # Post-execution TDD compliance check
455
+
456
+ Quality Gate: Consider running /workflow:plan-verify to validate TDD task structure, dependencies, and CLI execution strategies
457
+ ```
458
+
459
+ ## TodoWrite Pattern
460
+
461
+ **Core Concept**: Dynamic task attachment and collapse for TDD workflow with test coverage analysis and Red-Green-Refactor cycle generation.
462
+
463
+ ### Key Principles
464
+
465
+ 1. **Task Attachment** (when SlashCommand executed):
466
+ - Sub-command's internal tasks are **attached** to orchestrator's TodoWrite
467
+ - Example: `/workflow:tools:test-context-gather` attaches 3 sub-tasks (Phase 3.1, 3.2, 3.3)
468
+ - First attached task marked as `in_progress`, others as `pending`
469
+ - Orchestrator **executes** these attached tasks sequentially
470
+
471
+ 2. **Task Collapse** (after sub-tasks complete):
472
+ - Remove detailed sub-tasks from TodoWrite
473
+ - **Collapse** to high-level phase summary
474
+ - Example: Phase 3.1-3.3 collapse to "Execute test coverage analysis: completed"
475
+ - Maintains clean orchestrator-level view
476
+
477
+ 3. **Continuous Execution**:
478
+ - After collapse, automatically proceed to next pending phase
479
+ - No user intervention required between phases
480
+ - TodoWrite dynamically reflects current execution state
481
+
482
+ **Lifecycle Summary**: Initial pending tasks → Phase executed (tasks ATTACHED) → Sub-tasks executed sequentially → Phase completed (tasks COLLAPSED to summary) → Next phase begins (conditional Phase 4 if conflict_risk ≥ medium) → Repeat until all phases complete.
483
+
484
+ ### TDD-Specific Features
485
+
486
+ - **Phase 3**: Test coverage analysis detects existing patterns and gaps
487
+ - **Phase 5**: Generated IMPL tasks contain internal Red-Green-Refactor cycles
488
+ - **Conditional Phase 4**: Conflict resolution only if conflict_risk ≥ medium
489
+
490
+
491
+
492
+ **Note**: See individual Phase descriptions (Phase 3, 4, 5) for detailed TodoWrite Update examples with full JSON structures.
493
+
494
+ ## Execution Flow Diagram
495
+
496
+ ```
497
+ TDD Workflow Orchestrator
498
+
499
+ ├─ Phase 1: Session Discovery
500
+ └─ /workflow:session:start --auto
501
+ └─ Returns: sessionId
502
+
503
+ ├─ Phase 2: Context Gathering
504
+ │ └─ /workflow:tools:context-gather
505
+ │ └─ Returns: context-package.json path
506
+
507
+ ├─ Phase 3: Test Coverage Analysis ← ATTACHED (3 tasks)
508
+ │ └─ /workflow:tools:test-context-gather
509
+ │ ├─ Phase 3.1: Detect test framework
510
+ │ ├─ Phase 3.2: Analyze existing test coverage
511
+ │ └─ Phase 3.3: Identify coverage gaps
512
+ │ └─ Returns: test-context-package.json ← COLLAPSED
513
+
514
+ ├─ Phase 4: Conflict Resolution (conditional)
515
+ │ IF conflict_risk medium:
516
+ │ └─ /workflow:tools:conflict-resolution ← ATTACHED (3 tasks)
517
+ │ ├─ Phase 4.1: Detect conflicts with CLI
518
+ │ ├─ Phase 4.2: Log and analyze detected conflicts
519
+ │ └─ Phase 4.3: Apply resolution strategies
520
+ │ └─ Returns: conflict-resolution.json ← COLLAPSED
521
+ │ ELSE:
522
+ │ └─ Skip to Phase 5
523
+
524
+ ├─ Phase 5: TDD Task Generation ← ATTACHED (3 tasks)
525
+ │ └─ /workflow:tools:task-generate-tdd
526
+ │ ├─ Phase 5.1: Discovery - analyze TDD requirements
527
+ │ ├─ Phase 5.2: Planning - design Red-Green-Refactor cycles
528
+ │ └─ Phase 5.3: Output - generate IMPL tasks with internal TDD phases
529
+ │ └─ Returns: IMPL-*.json, IMPL_PLAN.md ← COLLAPSED
530
+ │ (Each IMPL task contains internal Red-Green-Refactor cycle)
531
+
532
+ └─ Phase 6: TDD Structure Validation
533
+ └─ Internal validation + summary returned
534
+ └─ Recommend: /workflow:plan-verify
535
+
536
+ Key Points:
537
+ • ← ATTACHED: SlashCommand attaches sub-tasks to orchestrator TodoWrite
538
+ COLLAPSED: Sub-tasks executed and collapsed to phase summary
539
+ TDD-specific: Each generated IMPL task contains complete Red-Green-Refactor cycle
540
+ ```
541
+
542
+ ## Input Processing
543
+
544
+ Convert user input to TDD-structured format:
545
+
546
+ **Simple text** → Add TDD context
547
+ **Detailed text** Extract components with TEST_FOCUS
548
+ **File/Issue** Read and structure with TDD
549
+
550
+ ## Error Handling
551
+
552
+ - **Parsing failure**: Retry once, then report
553
+ - **Validation failure**: Report missing/invalid data
554
+ - **Command failure**: Keep phase in_progress, report error
555
+ - **TDD validation failure**: Report incomplete chains or wrong dependencies
556
+
557
+ ### TDD Warning Patterns
558
+
559
+ | Pattern | Warning Message | Recommended Action |
560
+ |---------|----------------|-------------------|
561
+ | Task count >10 | High task count detected | Consider splitting into multiple sessions |
562
+ | Missing test-fix-cycle | Green phase lacks auto-revert | Add `max_iterations: 3` to task config |
563
+ | Red phase missing test path | Test file path not specified | Add explicit test file paths |
564
+ | Generic task names | Vague names like "Add feature" | Use specific behavior descriptions |
565
+ | No refactor criteria | Refactor phase lacks completion criteria | Define clear refactor scope |
566
+
567
+ ### Non-Blocking Warning Policy
568
+
569
+ **All warnings are advisory** - they do not halt execution:
570
+ 1. Warnings logged to `.process/tdd-warnings.log`
571
+ 2. Summary displayed in Phase 6 output
572
+ 3. User decides whether to address before `/workflow:execute`
573
+
574
+ ### Error Handling Quick Reference
575
+
576
+ | Error Type | Detection | Recovery Action |
577
+ |------------|-----------|-----------------|
578
+ | Parsing failure | Empty/malformed output | Retry once, then report |
579
+ | Missing context-package | File read error | Re-run `/workflow:tools:context-gather` |
580
+ | Invalid task JSON | jq parse error | Report malformed file path |
581
+ | Task count exceeds 18 | Count validation ≥19 | Request re-scope, split into multiple sessions |
582
+ | Missing cli_execution_id | All tasks lack ID | Regenerate tasks with phase 0 user config |
583
+ | Test-context missing | File not found | Re-run `/workflow:tools:test-context-gather` |
584
+ | Phase timeout | No response | Retry phase, check CLI connectivity |
585
+ | CLI tool not available | Tool not in cli-tools.json | Fall back to alternative preferred tool |
586
+
587
+ ## Related Commands
588
+
589
+ **Prerequisite Commands**:
590
+ - None - TDD planning is self-contained (can optionally run brainstorm commands before)
591
+
592
+ **Called by This Command** (6 phases):
593
+ - `/workflow:session:start` - Phase 1: Create or discover TDD workflow session
594
+ - `/workflow:tools:context-gather` - Phase 2: Gather project context and analyze codebase
595
+ - `/workflow:tools:test-context-gather` - Phase 3: Analyze existing test patterns and coverage
596
+ - `/workflow:tools:conflict-resolution` - Phase 4: Detect and resolve conflicts (auto-triggered if conflict_risk ≥ medium)
597
+ - `/compact` - Phase 4: Memory optimization (if context approaching limits)
598
+ - `/workflow:tools:task-generate-tdd` - Phase 5: Generate TDD tasks (CLI tool usage determined semantically)
599
+
600
+ **Follow-up Commands**:
601
+ - `/workflow:plan-verify` - Recommended: Verify TDD plan quality and structure before execution
602
+ - `/workflow:status` - Review TDD task breakdown
603
+ - `/workflow:execute` - Begin TDD implementation
604
+ - `/workflow:tdd-verify` - Post-execution: Verify TDD compliance and generate quality report
605
+
606
+ ## Next Steps Decision Table
607
+
608
+ | Situation | Recommended Command | Purpose |
609
+ |-----------|---------------------|---------|
610
+ | First time planning | `/workflow:plan-verify` | Validate task structure before execution |
611
+ | Warnings in tdd-warnings.log | Review log, refine tasks | Address Red Flags before proceeding |
612
+ | High task count warning | Consider `/workflow:session:start` | Split into focused sub-sessions |
613
+ | Ready to implement | `/workflow:execute` | Begin TDD Red-Green-Refactor cycles |
614
+ | After implementation | `/workflow:tdd-verify` | Generate TDD compliance report |
615
+ | Need to review tasks | `/workflow:status --session [id]` | Inspect current task breakdown |
616
+ | Plan needs changes | `/task:replan` | Update task JSON with new requirements |
617
+
618
+ ### TDD Workflow State Transitions
619
+
620
+ ```
621
+ /workflow:tdd-plan
622
+
623
+ [Planning Complete] ──→ /workflow:plan-verify (recommended)
624
+
625
+ [Verified/Ready] ─────→ /workflow:execute
626
+
627
+ [Implementation] ─────→ /workflow:tdd-verify (post-execution)
628
+
629
+ [Quality Report] ─────→ Done or iterate
630
+ ```