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,551 +1,555 @@
1
- ---
2
- name: plan
3
- description: 5-phase planning workflow with action-planning-agent task generation, outputs IMPL_PLAN.md and task JSONs
4
- argument-hint: "\"text description\"|file.md"
5
- allowed-tools: SlashCommand(*), TodoWrite(*), Read(*), Bash(*)
6
- ---
7
-
8
- # Workflow Plan Command (/workflow:plan)
9
-
10
- ## Coordinator Role
11
-
12
- **This command is a pure orchestrator**: Execute 5 slash commands in sequence (including a quality gate), parse their outputs, pass context between them, and ensure complete execution through **automatic continuation**.
13
-
14
- **Execution Model - Auto-Continue Workflow with Quality Gate**:
15
-
16
- This workflow runs **fully autonomously** once triggered. Phase 3 (conflict resolution) and Phase 4 (task generation) are delegated to specialized agents.
17
-
18
-
19
- 1. **User triggers**: `/workflow:plan "task"`
20
- 2. **Phase 1 executes** Session discovery Auto-continues
21
- 3. **Phase 2 executes** → Context gathering → Auto-continues
22
- 4. **Phase 3 executes** (optional, if conflict_risk ≥ medium) → Conflict resolution → Auto-continues
23
- 5. **Phase 4 executes** → Task generation (task-generate-agent) → Reports final summary
24
-
25
- **Task Attachment Model**:
26
- - SlashCommand execute **expands workflow** by attaching sub-tasks to current TodoWrite
27
- - When a sub-command is executed (e.g., `/workflow:tools:context-gather`), its internal tasks are attached to the orchestrator's TodoWrite
28
- - Orchestrator **executes these attached tasks** sequentially
29
- - After completion, attached tasks are **collapsed** back to high-level phase summary
30
- - This is **task expansion**, not external delegation
31
-
32
- **Auto-Continue Mechanism**:
33
- - TodoList tracks current phase status and dynamically manages task attachment/collapse
34
- - When each phase finishes executing, automatically execute next pending phase
35
- - All phases run autonomously without user interaction (clarification handled in brainstorm phase)
36
- - Progress updates shown at each phase for visibility
37
- - **⚠️ CONTINUOUS EXECUTION** - Do not stop until all phases complete
38
-
39
- ## Core Rules
40
-
41
- 1. **Start Immediately**: First action is TodoWrite initialization, second action is Phase 1 command execution
42
- 2. **No Preliminary Analysis**: Do not read files, analyze structure, or gather context before Phase 1
43
- 3. **Parse Every Output**: Extract required data from each command/agent output for next phase
44
- 4. **Auto-Continue via TodoList**: Check TodoList status to execute next pending phase automatically
45
- 5. **Track Progress**: Update TodoWrite dynamically with task attachment/collapse pattern
46
- 6. **Task Attachment Model**: SlashCommand execute **attaches** sub-tasks to current workflow. Orchestrator **executes** these attached tasks itself, then **collapses** them after completion
47
- 7. **⚠️ CRITICAL: DO NOT STOP**: Continuous multi-phase workflow. After executing all attached tasks, immediately collapse them and execute next phase
48
-
49
- ## Execution Process
50
-
51
- ```
52
- Input Parsing:
53
- └─ Convert user input to structured format (GOAL/SCOPE/CONTEXT)
54
-
55
- Phase 1: Session Discovery
56
- └─ /workflow:session:start --auto "structured-description"
57
- └─ Output: sessionId (WFS-xxx)
58
-
59
- Phase 2: Context Gathering
60
- └─ /workflow:tools:context-gather --session sessionId "structured-description"
61
- ├─ Tasks attached: Analyze structure → Identify integration → Generate package
62
- └─ Output: contextPath + conflict_risk
63
-
64
- Phase 3: Conflict Resolution
65
- └─ Decision (conflict_risk check):
66
- ├─ conflict_risk medium → Execute /workflow:tools:conflict-resolution
67
- │ ├─ Tasks attached: Detect conflicts → Present to user → Apply strategies
68
- │ └─ Output: Modified brainstorm artifacts
69
- └─ conflict_risk < medium → Skip to Phase 4
70
-
71
- Phase 4: Task Generation
72
- └─ /workflow:tools:task-generate-agent --session sessionId
73
- └─ Output: IMPL_PLAN.md, task JSONs, TODO_LIST.md
74
-
75
- Return:
76
- └─ Summary with recommended next steps
77
- ```
78
-
79
- ## 5-Phase Execution
80
-
81
- ### Phase 1: Session Discovery
82
-
83
- **Step 1.1: Execute** - Create or discover workflow session
84
-
85
- ```javascript
86
- SlashCommand(command="/workflow:session:start --auto \"[structured-task-description]\"")
87
- ```
88
-
89
- **Task Description Structure**:
90
- ```
91
- GOAL: [Clear, concise objective]
92
- SCOPE: [What's included/excluded]
93
- CONTEXT: [Relevant background or constraints]
94
- ```
95
-
96
- **Example**:
97
- ```
98
- GOAL: Build JWT-based authentication system
99
- SCOPE: User registration, login, token validation
100
- CONTEXT: Existing user database schema, REST API endpoints
101
- ```
102
-
103
- **Parse Output**:
104
- - Extract: `SESSION_ID: WFS-[id]` (store as `sessionId`)
105
-
106
- **Validation**:
107
- - Session ID successfully extracted
108
- - Session directory `.workflow/active/[sessionId]/` exists
109
-
110
- **Note**: Session directory contains `workflow-session.json` (metadata). Do NOT look for `manifest.json` here - it only exists in `.workflow/archives/` for archived sessions.
111
-
112
- **TodoWrite**: Mark phase 1 completed, phase 2 in_progress
113
-
114
- **After Phase 1**: Return to user showing Phase 1 results, then auto-continue to Phase 2
115
-
116
- ---
117
-
118
- ### Phase 2: Context Gathering
119
-
120
- **Step 2.1: Execute** - Gather project context and analyze codebase
121
-
122
- ```javascript
123
- SlashCommand(command="/workflow:tools:context-gather --session [sessionId] \"[structured-task-description]\"")
124
- ```
125
-
126
- **Use Same Structured Description**: Pass the same structured format from Phase 1
127
-
128
- **Input**: `sessionId` from Phase 1
129
-
130
- **Parse Output**:
131
- - Extract: context-package.json path (store as `contextPath`)
132
- - Typical pattern: `.workflow/active/[sessionId]/.process/context-package.json`
133
-
134
- **Validation**:
135
- - Context package path extracted
136
- - File exists and is valid JSON
137
-
138
- <!-- TodoWrite: When context-gather executed, INSERT 3 context-gather tasks, mark first as in_progress -->
139
-
140
- **TodoWrite Update (Phase 2 SlashCommand executed - tasks attached)**:
141
- ```json
142
- [
143
- {"content": "Phase 1: Session Discovery", "status": "completed", "activeForm": "Executing session discovery"},
144
- {"content": "Phase 2: Context Gathering", "status": "in_progress", "activeForm": "Executing context gathering"},
145
- {"content": " → Analyze codebase structure", "status": "in_progress", "activeForm": "Analyzing codebase structure"},
146
- {"content": " → Identify integration points", "status": "pending", "activeForm": "Identifying integration points"},
147
- {"content": " Generate context package", "status": "pending", "activeForm": "Generating context package"},
148
- {"content": "Phase 4: Task Generation", "status": "pending", "activeForm": "Executing task generation"}
149
- ]
150
- ```
151
-
152
- **Note**: SlashCommand execute **attaches** context-gather's 3 tasks. Orchestrator **executes** these tasks sequentially.
153
-
154
- <!-- TodoWrite: After Phase 2 tasks complete, REMOVE Phase 2.1-2.3, restore to orchestrator view -->
155
-
156
- **TodoWrite Update (Phase 2 completed - tasks collapsed)**:
157
- ```json
158
- [
159
- {"content": "Phase 1: Session Discovery", "status": "completed", "activeForm": "Executing session discovery"},
160
- {"content": "Phase 2: Context Gathering", "status": "completed", "activeForm": "Executing context gathering"},
161
- {"content": "Phase 4: Task Generation", "status": "pending", "activeForm": "Executing task generation"}
162
- ]
163
- ```
164
-
165
- **Note**: Phase 2 tasks completed and collapsed to summary.
166
-
167
- **After Phase 2**: Return to user showing Phase 2 results, then auto-continue to Phase 3/4 (depending on conflict_risk)
168
-
169
- ---
170
-
171
- ### Phase 3: Conflict Resolution
172
-
173
- **Trigger**: Only execute when context-package.json indicates conflict_risk is "medium" or "high"
174
-
175
- **Step 3.1: Execute** - Detect and resolve conflicts with CLI analysis
176
-
177
- ```javascript
178
- SlashCommand(command="/workflow:tools:conflict-resolution --session [sessionId] --context [contextPath]")
179
- ```
180
-
181
- **Input**:
182
- - sessionId from Phase 1
183
- - contextPath from Phase 2
184
- - conflict_risk from context-package.json
185
-
186
- **Parse Output**:
187
- - Extract: Execution status (success/skipped/failed)
188
- - Verify: conflict-resolution.json file path (if executed)
189
-
190
- **Validation**:
191
- - File `.workflow/active/[sessionId]/.process/conflict-resolution.json` exists (if executed)
192
-
193
- **Skip Behavior**:
194
- - If conflict_risk is "none" or "low", skip directly to Phase 3.5
195
- - Display: "No significant conflicts detected, proceeding to clarification"
196
-
197
- <!-- TodoWrite: If conflict_risk ≥ medium, INSERT 3 conflict-resolution tasks -->
198
-
199
- **TodoWrite Update (Phase 3 SlashCommand executed - tasks attached, if conflict_risk ≥ medium)**:
200
- ```json
201
- [
202
- {"content": "Phase 1: Session Discovery", "status": "completed", "activeForm": "Executing session discovery"},
203
- {"content": "Phase 2: Context Gathering", "status": "completed", "activeForm": "Executing context gathering"},
204
- {"content": "Phase 3: Conflict Resolution", "status": "in_progress", "activeForm": "Resolving conflicts"},
205
- {"content": " → Detect conflicts with CLI analysis", "status": "in_progress", "activeForm": "Detecting conflicts"},
206
- {"content": " Present conflicts to user", "status": "pending", "activeForm": "Presenting conflicts"},
207
- {"content": " Apply resolution strategies", "status": "pending", "activeForm": "Applying resolution strategies"},
208
- {"content": "Phase 4: Task Generation", "status": "pending", "activeForm": "Executing task generation"}
209
- ]
210
- ```
211
-
212
- **Note**: SlashCommand execute **attaches** conflict-resolution's 3 tasks. Orchestrator **executes** these tasks sequentially.
213
-
214
- <!-- TodoWrite: After Phase 3 tasks complete, REMOVE Phase 3.1-3.3, restore to orchestrator view -->
215
-
216
- **TodoWrite Update (Phase 3 completed - tasks collapsed)**:
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: Conflict Resolution", "status": "completed", "activeForm": "Resolving conflicts"},
222
- {"content": "Phase 4: Task Generation", "status": "pending", "activeForm": "Executing task generation"}
223
- ]
224
- ```
225
-
226
- **Note**: Phase 3 tasks completed and collapsed to summary.
227
-
228
- **After Phase 3**: Return to user showing conflict resolution results (if executed) and selected strategies, then auto-continue to Phase 3.5
229
-
230
- **Memory State Check**:
231
- - Evaluate current context window usage and memory state
232
- - If memory usage is high (>120K tokens or approaching context limits):
233
-
234
- **Step 3.2: Execute** - Optimize memory before proceeding
235
-
236
- ```javascript
237
- SlashCommand(command="/compact")
238
- ```
239
-
240
- - Memory compaction is particularly important after analysis phase which may generate extensive documentation
241
- - Ensures optimal performance and prevents context overflow
242
-
243
- ---
244
-
245
- ### Phase 3.5: Pre-Task Generation Validation (Optional Quality Gate)
246
-
247
- **Purpose**: Optional quality gate before task generation - primarily handled by brainstorm synthesis phase
248
-
249
-
250
- **Current Behavior**: Auto-skip to Phase 4 (Task Generation)
251
-
252
- **Future Enhancement**: Could add additional validation steps like:
253
- - Cross-reference checks between conflict resolution and brainstorm analyses
254
- - Final sanity checks before task generation
255
- - User confirmation prompt for proceeding
256
-
257
- **TodoWrite**: Mark phase 3.5 completed (auto-skip), phase 4 in_progress
258
-
259
- **After Phase 3.5**: Auto-continue to Phase 4 immediately
260
-
261
- ---
262
-
263
- ### Phase 4: Task Generation
264
-
265
- **Relationship with Brainstorm Phase**:
266
- - If brainstorm role analyses exist ([role]/analysis.md files), Phase 3 analysis incorporates them as input
267
- - **User's original intent is ALWAYS primary**: New or refined user goals override brainstorm recommendations
268
- - **Role analysis.md files define "WHAT"**: Requirements, design specs, role-specific insights
269
- - **IMPL_PLAN.md defines "HOW"**: Executable task breakdown, dependencies, implementation sequence
270
- - Task generation translates high-level role analyses into concrete, actionable work items
271
- - **Intent priority**: Current user prompt > role analysis.md files > guidance-specification.md
272
-
273
- **Step 4.1: Execute** - Generate implementation plan and task JSONs
274
-
275
- ```javascript
276
- SlashCommand(command="/workflow:tools:task-generate-agent --session [sessionId]")
277
- ```
278
-
279
- **CLI Execution Note**: CLI tool usage is now determined semantically by action-planning-agent based on user's task description. If user specifies "use Codex/Gemini/Qwen for X", the agent embeds `command` fields in relevant `implementation_approach` steps.
280
-
281
- **Input**: `sessionId` from Phase 1
282
-
283
- **Validation**:
284
- - `.workflow/active/[sessionId]/IMPL_PLAN.md` exists
285
- - `.workflow/active/[sessionId]/.task/IMPL-*.json` exists (at least one)
286
- - `.workflow/active/[sessionId]/TODO_LIST.md` exists
287
-
288
- <!-- TodoWrite: When task-generate-agent executed, ATTACH 1 agent task -->
289
-
290
- **TodoWrite Update (Phase 4 SlashCommand executed - agent task attached)**:
291
- ```json
292
- [
293
- {"content": "Phase 1: Session Discovery", "status": "completed", "activeForm": "Executing session discovery"},
294
- {"content": "Phase 2: Context Gathering", "status": "completed", "activeForm": "Executing context gathering"},
295
- {"content": "Phase 4: Task Generation", "status": "in_progress", "activeForm": "Executing task generation"}
296
- ]
297
- ```
298
-
299
- **Note**: Single agent task attached. Agent autonomously completes discovery, planning, and output generation internally.
300
-
301
- <!-- TodoWrite: After agent completes, mark task as completed -->
302
-
303
- **TodoWrite Update (Phase 4 completed)**:
304
- ```json
305
- [
306
- {"content": "Phase 1: Session Discovery", "status": "completed", "activeForm": "Executing session discovery"},
307
- {"content": "Phase 2: Context Gathering", "status": "completed", "activeForm": "Executing context gathering"},
308
- {"content": "Phase 4: Task Generation", "status": "completed", "activeForm": "Executing task generation"}
309
- ]
310
- ```
311
-
312
- **Note**: Agent task completed. No collapse needed (single task).
313
-
314
- **Return to User**:
315
- ```
316
- Planning complete for session: [sessionId]
317
- Tasks generated: [count]
318
- Plan: .workflow/active/[sessionId]/IMPL_PLAN.md
319
-
320
- Recommended Next Steps:
321
- 1. /workflow:action-plan-verify --session [sessionId] # Verify plan quality before execution
322
- 2. /workflow:status # Review task breakdown
323
- 3. /workflow:execute # Start implementation (after verification)
324
-
325
- Quality Gate: Consider running /workflow:action-plan-verify to catch issues early
326
- ```
327
-
328
- ## TodoWrite Pattern
329
-
330
- **Core Concept**: Dynamic task attachment and collapse for real-time visibility into workflow execution.
331
-
332
- ### Key Principles
333
-
334
- 1. **Task Attachment** (when SlashCommand executed):
335
- - Sub-command's internal tasks are **attached** to orchestrator's TodoWrite
336
- - **Phase 2, 3**: Multiple sub-tasks attached (e.g., Phase 2.1, 2.2, 2.3)
337
- - **Phase 4**: Single agent task attached (e.g., "Execute task-generate-agent")
338
- - First attached task marked as `in_progress`, others as `pending`
339
- - Orchestrator **executes** these attached tasks sequentially
340
-
341
- 2. **Task Collapse** (after sub-tasks complete):
342
- - **Applies to Phase 2, 3**: Remove detailed sub-tasks from TodoWrite
343
- - **Collapse** to high-level phase summary
344
- - Example: Phase 2.1-2.3 collapse to "Execute context gathering: completed"
345
- - **Phase 4**: No collapse needed (single task, just mark completed)
346
- - Maintains clean orchestrator-level view
347
-
348
- 3. **Continuous Execution**:
349
- - After completion, automatically proceed to next pending phase
350
- - No user intervention required between phases
351
- - TodoWrite dynamically reflects current execution state
352
-
353
- **Lifecycle Summary**: Initial pending tasks → Phase executed (tasks ATTACHED) → Sub-tasks executed sequentially Phase completed (tasks COLLAPSED to summary for Phase 2/3, or marked completed for Phase 4) → Next phase begins → Repeat until all phases complete.
354
-
355
-
356
-
357
- **Note**: See individual Phase descriptions for detailed TodoWrite Update examples:
358
- - **Phase 2, 3**: Multiple sub-tasks with attach/collapse pattern
359
- - **Phase 4**: Single agent task (no collapse needed)
360
-
361
- ## Input Processing
362
-
363
- **Convert User Input to Structured Format**:
364
-
365
- 1. **Simple Text** → Structure it:
366
- ```
367
- User: "Build authentication system"
368
-
369
- Structured:
370
- GOAL: Build authentication system
371
- SCOPE: Core authentication features
372
- CONTEXT: New implementation
373
- ```
374
-
375
- 2. **Detailed Text** → Extract components:
376
- ```
377
- User: "Add JWT authentication with email/password login and token refresh"
378
-
379
- Structured:
380
- GOAL: Implement JWT-based authentication
381
- SCOPE: Email/password login, token generation, token refresh endpoints
382
- CONTEXT: JWT token-based security, refresh token rotation
383
- ```
384
-
385
- 3. **File Reference** (e.g., `requirements.md`) Read and structure:
386
- - Read file content
387
- - Extract goal, scope, requirements
388
- - Format into structured description
389
-
390
- ## Data Flow
391
-
392
- ```
393
- User Input (task description)
394
-
395
- [Convert to Structured Format]
396
- ↓ Structured Description:
397
- ↓ GOAL: [objective]
398
- SCOPE: [boundaries]
399
- ↓ CONTEXT: [background]
400
-
401
- Phase 1: session:start --auto "structured-description"
402
- Output: sessionId
403
- Session Memory: Previous tasks, context, artifacts
404
-
405
- Phase 2: context-gather --session sessionId "structured-description"
406
- Input: sessionId + session memory + structured description
407
- Output: contextPath (context-package.json) + conflict_risk
408
-
409
- Phase 3: conflict-resolution [AUTO-TRIGGERED if conflict_risk ≥ medium]
410
- ↓ Input: sessionId + contextPath + conflict_risk
411
- CLI-powered conflict detection (JSON output)
412
- AskUserQuestion: Present conflicts + resolution strategies
413
- User selects strategies (or skip)
414
- Apply modifications via Edit tool:
415
- - Update guidance-specification.md
416
- - Update role analyses (*.md)
417
- - Mark context-package.json as "resolved"
418
- Output: Modified brainstorm artifacts (NO report file)
419
- Skip if conflict_risk is none/low → proceed directly to Phase 4
420
-
421
- Phase 4: task-generate-agent --session sessionId
422
- Input: sessionId + resolved brainstorm artifacts + session memory
423
- Output: IMPL_PLAN.md, task JSONs, TODO_LIST.md
424
-
425
- Return summary to user
426
- ```
427
-
428
- **Session Memory Flow**: Each phase receives session ID, which provides access to:
429
- - Previous task summaries
430
- - Existing context and analysis
431
- - Brainstorming artifacts (potentially modified by Phase 3)
432
- - Session-specific configuration
433
-
434
-
435
- ## Execution Flow Diagram
436
-
437
- ```
438
- User triggers: /workflow:plan "Build authentication system"
439
-
440
- [TodoWrite Init] 3 orchestrator-level tasks
441
-
442
- Phase 1: Session Discovery
443
- → sessionId extracted
444
-
445
- Phase 2: Context Gathering (SlashCommand executed)
446
- ATTACH 3 sub-tasks: ATTACHED
447
- - Analyze codebase structure
448
- - → Identify integration points
449
- - Generate context package
450
- Execute sub-tasks sequentially
451
- COLLAPSE tasks ← COLLAPSED
452
- contextPath + conflict_risk extracted
453
-
454
- Conditional Branch: Check conflict_risk
455
- ├─ IF conflict_risk medium:
456
- │ Phase 3: Conflict Resolution (SlashCommand executed)
457
- │ → ATTACH 3 sub-tasks: ← ATTACHED
458
- │ - Detect conflicts with CLI analysis
459
- │ - Present conflicts to user
460
- - Apply resolution strategies
461
- │ → Execute sub-tasks sequentially
462
- COLLAPSE tasks COLLAPSED
463
-
464
- └─ ELSE: Skip Phase 3, proceed to Phase 4
465
-
466
- Phase 4: Task Generation (SlashCommand executed)
467
- → Single agent task (no sub-tasks)
468
- Agent autonomously completes internally:
469
- (discovery → planning → output)
470
- Outputs: IMPL_PLAN.md, IMPL-*.json, TODO_LIST.md
471
-
472
- Return summary to user
473
- ```
474
-
475
- **Key Points**:
476
- - **← ATTACHED**: Tasks attached to TodoWrite when SlashCommand executed
477
- - Phase 2, 3: Multiple sub-tasks
478
- - Phase 4: Single agent task
479
- - **← COLLAPSED**: Sub-tasks collapsed to summary after completion (Phase 2, 3 only)
480
- - **Phase 4**: Single agent task, no collapse (just mark completed)
481
- - **Conditional Branch**: Phase 3 only executes if conflict_risk ≥ medium
482
- - **Continuous Flow**: No user intervention between phases
483
-
484
- ## Error Handling
485
-
486
- - **Parsing Failure**: If output parsing fails, retry command once, then report error
487
- - **Validation Failure**: If validation fails, report which file/data is missing
488
- - **Command Failure**: Keep phase `in_progress`, report error to user, do not proceed to next phase
489
-
490
- ## Coordinator Checklist
491
-
492
- - **Pre-Phase**: Convert user input to structured format (GOAL/SCOPE/CONTEXT)
493
- - Initialize TodoWrite before any command (Phase 3 added dynamically after Phase 2)
494
- - Execute Phase 1 immediately with structured description
495
- - Parse session ID from Phase 1 output, store in memory
496
- - Pass session ID and structured description to Phase 2 command
497
- - Parse context path from Phase 2 output, store in memory
498
- - **Extract conflict_risk from context-package.json**: Determine Phase 3 execution
499
- - **If conflict_risk medium**: Launch Phase 3 conflict-resolution with sessionId and contextPath
500
- - Wait for Phase 3 to finish executing (if executed), verify conflict-resolution.json created
501
- - **If conflict_risk is none/low**: Skip Phase 3, proceed directly to Phase 4
502
- - **Build Phase 4 command**: `/workflow:tools:task-generate-agent --session [sessionId]`
503
- - Pass session ID to Phase 4 command
504
- - Verify all Phase 4 outputs
505
- - Update TodoWrite after each phase (dynamically adjust for Phase 3 presence)
506
- - After each phase, automatically continue to next phase based on TodoList status
507
-
508
- ## Structure Template Reference
509
-
510
- **Minimal Structure**:
511
- ```
512
- GOAL: [What to achieve]
513
- SCOPE: [What's included]
514
- CONTEXT: [Relevant info]
515
- ```
516
-
517
- **Detailed Structure** (optional, when more context available):
518
- ```
519
- GOAL: [Primary objective]
520
- SCOPE: [Included features/components]
521
- CONTEXT: [Existing system, constraints, dependencies]
522
- REQUIREMENTS: [Specific technical requirements]
523
- CONSTRAINTS: [Limitations or boundaries]
524
- ```
525
-
526
- **Usage in Commands**:
527
- ```bash
528
- # Phase 1
529
- /workflow:session:start --auto "GOAL: Build authentication\nSCOPE: JWT, login, registration\nCONTEXT: REST API"
530
-
531
- # Phase 2
532
- /workflow:tools:context-gather --session WFS-123 "GOAL: Build authentication\nSCOPE: JWT, login, registration\nCONTEXT: REST API"
533
- ```
534
-
535
- ## Related Commands
536
-
537
- **Prerequisite Commands**:
538
- - `/workflow:brainstorm:artifacts` - Optional: Generate role-based analyses before planning (if complex requirements need multiple perspectives)
539
- - `/workflow:brainstorm:synthesis` - Optional: Refine brainstorm analyses with clarifications
540
-
541
- **Called by This Command** (5 phases):
542
- - `/workflow:session:start` - Phase 1: Create or discover workflow session
543
- - `/workflow:tools:context-gather` - Phase 2: Gather project context and analyze codebase
544
- - `/workflow:tools:conflict-resolution` - Phase 3: Detect and resolve conflicts (auto-triggered if conflict_risk ≥ medium)
545
- - `/compact` - Phase 3: Memory optimization (if context approaching limits)
546
- - `/workflow:tools:task-generate-agent` - Phase 4: Generate task JSON files with agent-driven approach
547
-
548
- **Follow-up Commands**:
549
- - `/workflow:action-plan-verify` - Recommended: Verify plan quality and catch issues before execution
550
- - `/workflow:status` - Review task breakdown and current progress
551
- - `/workflow:execute` - Begin implementation of generated tasks
1
+ ---
2
+ name: plan
3
+ description: 5-phase planning workflow with action-planning-agent task generation, outputs IMPL_PLAN.md and task JSONs
4
+ argument-hint: "[-y|--yes] \"text description\"|file.md"
5
+ allowed-tools: SlashCommand(*), TodoWrite(*), Read(*), Bash(*)
6
+ ---
7
+
8
+ ## Auto Mode
9
+
10
+ When `--yes` or `-y`: Auto-continue all phases (skip confirmations), use recommended conflict resolutions.
11
+
12
+ # Workflow Plan Command (/workflow:plan)
13
+
14
+ ## Coordinator Role
15
+
16
+ **This command is a pure orchestrator**: Execute 5 slash commands in sequence (including a quality gate), parse their outputs, pass context between them, and ensure complete execution through **automatic continuation**.
17
+
18
+ **Execution Model - Auto-Continue Workflow with Quality Gate**:
19
+
20
+ This workflow runs **fully autonomously** once triggered. Phase 3 (conflict resolution) and Phase 4 (task generation) are delegated to specialized agents.
21
+
22
+
23
+ 1. **User triggers**: `/workflow:plan "task"`
24
+ 2. **Phase 1 executes** → Session discovery → Auto-continues
25
+ 3. **Phase 2 executes** → Context gathering → Auto-continues
26
+ 4. **Phase 3 executes** (optional, if conflict_risk medium) Conflict resolution → Auto-continues
27
+ 5. **Phase 4 executes** Task generation (task-generate-agent) Reports final summary
28
+
29
+ **Task Attachment Model**:
30
+ - SlashCommand execute **expands workflow** by attaching sub-tasks to current TodoWrite
31
+ - When a sub-command is executed (e.g., `/workflow:tools:context-gather`), its internal tasks are attached to the orchestrator's TodoWrite
32
+ - Orchestrator **executes these attached tasks** sequentially
33
+ - After completion, attached tasks are **collapsed** back to high-level phase summary
34
+ - This is **task expansion**, not external delegation
35
+
36
+ **Auto-Continue Mechanism**:
37
+ - TodoList tracks current phase status and dynamically manages task attachment/collapse
38
+ - When each phase finishes executing, automatically execute next pending phase
39
+ - All phases run autonomously without user interaction (clarification handled in brainstorm phase)
40
+ - Progress updates shown at each phase for visibility
41
+ - **⚠️ CONTINUOUS EXECUTION** - Do not stop until all phases complete
42
+
43
+ ## Core Rules
44
+
45
+ 1. **Start Immediately**: First action is TodoWrite initialization, second action is Phase 1 command execution
46
+ 2. **No Preliminary Analysis**: Do not read files, analyze structure, or gather context before Phase 1
47
+ 3. **Parse Every Output**: Extract required data from each command/agent output for next phase
48
+ 4. **Auto-Continue via TodoList**: Check TodoList status to execute next pending phase automatically
49
+ 5. **Track Progress**: Update TodoWrite dynamically with task attachment/collapse pattern
50
+ 6. **Task Attachment Model**: SlashCommand execute **attaches** sub-tasks to current workflow. Orchestrator **executes** these attached tasks itself, then **collapses** them after completion
51
+ 7. **⚠️ CRITICAL: DO NOT STOP**: Continuous multi-phase workflow. After executing all attached tasks, immediately collapse them and execute next phase
52
+
53
+ ## Execution Process
54
+
55
+ ```
56
+ Input Parsing:
57
+ └─ Convert user input to structured format (GOAL/SCOPE/CONTEXT)
58
+
59
+ Phase 1: Session Discovery
60
+ └─ /workflow:session:start --auto "structured-description"
61
+ └─ Output: sessionId (WFS-xxx)
62
+
63
+ Phase 2: Context Gathering
64
+ └─ /workflow:tools:context-gather --session sessionId "structured-description"
65
+ ├─ Tasks attached: Analyze structure → Identify integration → Generate package
66
+ └─ Output: contextPath + conflict_risk
67
+
68
+ Phase 3: Conflict Resolution
69
+ └─ Decision (conflict_risk check):
70
+ ├─ conflict_risk ≥ medium → Execute /workflow:tools:conflict-resolution
71
+ │ ├─ Tasks attached: Detect conflicts → Present to user → Apply strategies
72
+ └─ Output: Modified brainstorm artifacts
73
+ └─ conflict_risk < medium Skip to Phase 4
74
+
75
+ Phase 4: Task Generation
76
+ └─ /workflow:tools:task-generate-agent --session sessionId
77
+ └─ Output: IMPL_PLAN.md, task JSONs, TODO_LIST.md
78
+
79
+ Return:
80
+ └─ Summary with recommended next steps
81
+ ```
82
+
83
+ ## 5-Phase Execution
84
+
85
+ ### Phase 1: Session Discovery
86
+
87
+ **Step 1.1: Execute** - Create or discover workflow session
88
+
89
+ ```javascript
90
+ SlashCommand(command="/workflow:session:start --auto \"[structured-task-description]\"")
91
+ ```
92
+
93
+ **Task Description Structure**:
94
+ ```
95
+ GOAL: [Clear, concise objective]
96
+ SCOPE: [What's included/excluded]
97
+ CONTEXT: [Relevant background or constraints]
98
+ ```
99
+
100
+ **Example**:
101
+ ```
102
+ GOAL: Build JWT-based authentication system
103
+ SCOPE: User registration, login, token validation
104
+ CONTEXT: Existing user database schema, REST API endpoints
105
+ ```
106
+
107
+ **Parse Output**:
108
+ - Extract: `SESSION_ID: WFS-[id]` (store as `sessionId`)
109
+
110
+ **Validation**:
111
+ - Session ID successfully extracted
112
+ - Session directory `.workflow/active/[sessionId]/` exists
113
+
114
+ **Note**: Session directory contains `workflow-session.json` (metadata). Do NOT look for `manifest.json` here - it only exists in `.workflow/archives/` for archived sessions.
115
+
116
+ **TodoWrite**: Mark phase 1 completed, phase 2 in_progress
117
+
118
+ **After Phase 1**: Return to user showing Phase 1 results, then auto-continue to Phase 2
119
+
120
+ ---
121
+
122
+ ### Phase 2: Context Gathering
123
+
124
+ **Step 2.1: Execute** - Gather project context and analyze codebase
125
+
126
+ ```javascript
127
+ SlashCommand(command="/workflow:tools:context-gather --session [sessionId] \"[structured-task-description]\"")
128
+ ```
129
+
130
+ **Use Same Structured Description**: Pass the same structured format from Phase 1
131
+
132
+ **Input**: `sessionId` from Phase 1
133
+
134
+ **Parse Output**:
135
+ - Extract: context-package.json path (store as `contextPath`)
136
+ - Typical pattern: `.workflow/active/[sessionId]/.process/context-package.json`
137
+
138
+ **Validation**:
139
+ - Context package path extracted
140
+ - File exists and is valid JSON
141
+
142
+ <!-- TodoWrite: When context-gather executed, INSERT 3 context-gather tasks, mark first as in_progress -->
143
+
144
+ **TodoWrite Update (Phase 2 SlashCommand executed - tasks attached)**:
145
+ ```json
146
+ [
147
+ {"content": "Phase 1: Session Discovery", "status": "completed", "activeForm": "Executing session discovery"},
148
+ {"content": "Phase 2: Context Gathering", "status": "in_progress", "activeForm": "Executing context gathering"},
149
+ {"content": " → Analyze codebase structure", "status": "in_progress", "activeForm": "Analyzing codebase structure"},
150
+ {"content": " → Identify integration points", "status": "pending", "activeForm": "Identifying integration points"},
151
+ {"content": " → Generate context package", "status": "pending", "activeForm": "Generating context package"},
152
+ {"content": "Phase 4: Task Generation", "status": "pending", "activeForm": "Executing task generation"}
153
+ ]
154
+ ```
155
+
156
+ **Note**: SlashCommand execute **attaches** context-gather's 3 tasks. Orchestrator **executes** these tasks sequentially.
157
+
158
+ <!-- TodoWrite: After Phase 2 tasks complete, REMOVE Phase 2.1-2.3, restore to orchestrator view -->
159
+
160
+ **TodoWrite Update (Phase 2 completed - tasks collapsed)**:
161
+ ```json
162
+ [
163
+ {"content": "Phase 1: Session Discovery", "status": "completed", "activeForm": "Executing session discovery"},
164
+ {"content": "Phase 2: Context Gathering", "status": "completed", "activeForm": "Executing context gathering"},
165
+ {"content": "Phase 4: Task Generation", "status": "pending", "activeForm": "Executing task generation"}
166
+ ]
167
+ ```
168
+
169
+ **Note**: Phase 2 tasks completed and collapsed to summary.
170
+
171
+ **After Phase 2**: Return to user showing Phase 2 results, then auto-continue to Phase 3/4 (depending on conflict_risk)
172
+
173
+ ---
174
+
175
+ ### Phase 3: Conflict Resolution
176
+
177
+ **Trigger**: Only execute when context-package.json indicates conflict_risk is "medium" or "high"
178
+
179
+ **Step 3.1: Execute** - Detect and resolve conflicts with CLI analysis
180
+
181
+ ```javascript
182
+ SlashCommand(command="/workflow:tools:conflict-resolution --session [sessionId] --context [contextPath]")
183
+ ```
184
+
185
+ **Input**:
186
+ - sessionId from Phase 1
187
+ - contextPath from Phase 2
188
+ - conflict_risk from context-package.json
189
+
190
+ **Parse Output**:
191
+ - Extract: Execution status (success/skipped/failed)
192
+ - Verify: conflict-resolution.json file path (if executed)
193
+
194
+ **Validation**:
195
+ - File `.workflow/active/[sessionId]/.process/conflict-resolution.json` exists (if executed)
196
+
197
+ **Skip Behavior**:
198
+ - If conflict_risk is "none" or "low", skip directly to Phase 3.5
199
+ - Display: "No significant conflicts detected, proceeding to clarification"
200
+
201
+ <!-- TodoWrite: If conflict_risk ≥ medium, INSERT 3 conflict-resolution tasks -->
202
+
203
+ **TodoWrite Update (Phase 3 SlashCommand executed - tasks attached, if conflict_risk medium)**:
204
+ ```json
205
+ [
206
+ {"content": "Phase 1: Session Discovery", "status": "completed", "activeForm": "Executing session discovery"},
207
+ {"content": "Phase 2: Context Gathering", "status": "completed", "activeForm": "Executing context gathering"},
208
+ {"content": "Phase 3: Conflict Resolution", "status": "in_progress", "activeForm": "Resolving conflicts"},
209
+ {"content": " → Detect conflicts with CLI analysis", "status": "in_progress", "activeForm": "Detecting conflicts"},
210
+ {"content": " → Present conflicts to user", "status": "pending", "activeForm": "Presenting conflicts"},
211
+ {"content": " → Apply resolution strategies", "status": "pending", "activeForm": "Applying resolution strategies"},
212
+ {"content": "Phase 4: Task Generation", "status": "pending", "activeForm": "Executing task generation"}
213
+ ]
214
+ ```
215
+
216
+ **Note**: SlashCommand execute **attaches** conflict-resolution's 3 tasks. Orchestrator **executes** these tasks sequentially.
217
+
218
+ <!-- TodoWrite: After Phase 3 tasks complete, REMOVE Phase 3.1-3.3, restore to orchestrator view -->
219
+
220
+ **TodoWrite Update (Phase 3 completed - tasks collapsed)**:
221
+ ```json
222
+ [
223
+ {"content": "Phase 1: Session Discovery", "status": "completed", "activeForm": "Executing session discovery"},
224
+ {"content": "Phase 2: Context Gathering", "status": "completed", "activeForm": "Executing context gathering"},
225
+ {"content": "Phase 3: Conflict Resolution", "status": "completed", "activeForm": "Resolving conflicts"},
226
+ {"content": "Phase 4: Task Generation", "status": "pending", "activeForm": "Executing task generation"}
227
+ ]
228
+ ```
229
+
230
+ **Note**: Phase 3 tasks completed and collapsed to summary.
231
+
232
+ **After Phase 3**: Return to user showing conflict resolution results (if executed) and selected strategies, then auto-continue to Phase 3.5
233
+
234
+ **Memory State Check**:
235
+ - Evaluate current context window usage and memory state
236
+ - If memory usage is high (>120K tokens or approaching context limits):
237
+
238
+ **Step 3.2: Execute** - Optimize memory before proceeding
239
+
240
+ ```javascript
241
+ SlashCommand(command="/compact")
242
+ ```
243
+
244
+ - Memory compaction is particularly important after analysis phase which may generate extensive documentation
245
+ - Ensures optimal performance and prevents context overflow
246
+
247
+ ---
248
+
249
+ ### Phase 3.5: Pre-Task Generation Validation (Optional Quality Gate)
250
+
251
+ **Purpose**: Optional quality gate before task generation - primarily handled by brainstorm synthesis phase
252
+
253
+
254
+ **Current Behavior**: Auto-skip to Phase 4 (Task Generation)
255
+
256
+ **Future Enhancement**: Could add additional validation steps like:
257
+ - Cross-reference checks between conflict resolution and brainstorm analyses
258
+ - Final sanity checks before task generation
259
+ - User confirmation prompt for proceeding
260
+
261
+ **TodoWrite**: Mark phase 3.5 completed (auto-skip), phase 4 in_progress
262
+
263
+ **After Phase 3.5**: Auto-continue to Phase 4 immediately
264
+
265
+ ---
266
+
267
+ ### Phase 4: Task Generation
268
+
269
+ **Relationship with Brainstorm Phase**:
270
+ - If brainstorm role analyses exist ([role]/analysis.md files), Phase 3 analysis incorporates them as input
271
+ - **User's original intent is ALWAYS primary**: New or refined user goals override brainstorm recommendations
272
+ - **Role analysis.md files define "WHAT"**: Requirements, design specs, role-specific insights
273
+ - **IMPL_PLAN.md defines "HOW"**: Executable task breakdown, dependencies, implementation sequence
274
+ - Task generation translates high-level role analyses into concrete, actionable work items
275
+ - **Intent priority**: Current user prompt > role analysis.md files > guidance-specification.md
276
+
277
+ **Step 4.1: Execute** - Generate implementation plan and task JSONs
278
+
279
+ ```javascript
280
+ SlashCommand(command="/workflow:tools:task-generate-agent --session [sessionId]")
281
+ ```
282
+
283
+ **CLI Execution Note**: CLI tool usage is now determined semantically by action-planning-agent based on user's task description. If user specifies "use Codex/Gemini/Qwen for X", the agent embeds `command` fields in relevant `implementation_approach` steps.
284
+
285
+ **Input**: `sessionId` from Phase 1
286
+
287
+ **Validation**:
288
+ - `.workflow/active/[sessionId]/IMPL_PLAN.md` exists
289
+ - `.workflow/active/[sessionId]/.task/IMPL-*.json` exists (at least one)
290
+ - `.workflow/active/[sessionId]/TODO_LIST.md` exists
291
+
292
+ <!-- TodoWrite: When task-generate-agent executed, ATTACH 1 agent task -->
293
+
294
+ **TodoWrite Update (Phase 4 SlashCommand executed - agent task attached)**:
295
+ ```json
296
+ [
297
+ {"content": "Phase 1: Session Discovery", "status": "completed", "activeForm": "Executing session discovery"},
298
+ {"content": "Phase 2: Context Gathering", "status": "completed", "activeForm": "Executing context gathering"},
299
+ {"content": "Phase 4: Task Generation", "status": "in_progress", "activeForm": "Executing task generation"}
300
+ ]
301
+ ```
302
+
303
+ **Note**: Single agent task attached. Agent autonomously completes discovery, planning, and output generation internally.
304
+
305
+ <!-- TodoWrite: After agent completes, mark task as completed -->
306
+
307
+ **TodoWrite Update (Phase 4 completed)**:
308
+ ```json
309
+ [
310
+ {"content": "Phase 1: Session Discovery", "status": "completed", "activeForm": "Executing session discovery"},
311
+ {"content": "Phase 2: Context Gathering", "status": "completed", "activeForm": "Executing context gathering"},
312
+ {"content": "Phase 4: Task Generation", "status": "completed", "activeForm": "Executing task generation"}
313
+ ]
314
+ ```
315
+
316
+ **Note**: Agent task completed. No collapse needed (single task).
317
+
318
+ **Return to User**:
319
+ ```
320
+ Planning complete for session: [sessionId]
321
+ Tasks generated: [count]
322
+ Plan: .workflow/active/[sessionId]/IMPL_PLAN.md
323
+
324
+ Recommended Next Steps:
325
+ 1. /workflow:plan-verify --session [sessionId] # Verify plan quality before execution
326
+ 2. /workflow:status # Review task breakdown
327
+ 3. /workflow:execute # Start implementation (after verification)
328
+
329
+ Quality Gate: Consider running /workflow:plan-verify to catch issues early
330
+ ```
331
+
332
+ ## TodoWrite Pattern
333
+
334
+ **Core Concept**: Dynamic task attachment and collapse for real-time visibility into workflow execution.
335
+
336
+ ### Key Principles
337
+
338
+ 1. **Task Attachment** (when SlashCommand executed):
339
+ - Sub-command's internal tasks are **attached** to orchestrator's TodoWrite
340
+ - **Phase 2, 3**: Multiple sub-tasks attached (e.g., Phase 2.1, 2.2, 2.3)
341
+ - **Phase 4**: Single agent task attached (e.g., "Execute task-generate-agent")
342
+ - First attached task marked as `in_progress`, others as `pending`
343
+ - Orchestrator **executes** these attached tasks sequentially
344
+
345
+ 2. **Task Collapse** (after sub-tasks complete):
346
+ - **Applies to Phase 2, 3**: Remove detailed sub-tasks from TodoWrite
347
+ - **Collapse** to high-level phase summary
348
+ - Example: Phase 2.1-2.3 collapse to "Execute context gathering: completed"
349
+ - **Phase 4**: No collapse needed (single task, just mark completed)
350
+ - Maintains clean orchestrator-level view
351
+
352
+ 3. **Continuous Execution**:
353
+ - After completion, automatically proceed to next pending phase
354
+ - No user intervention required between phases
355
+ - TodoWrite dynamically reflects current execution state
356
+
357
+ **Lifecycle Summary**: Initial pending tasks → Phase executed (tasks ATTACHED) → Sub-tasks executed sequentially → Phase completed (tasks COLLAPSED to summary for Phase 2/3, or marked completed for Phase 4) → Next phase begins → Repeat until all phases complete.
358
+
359
+
360
+
361
+ **Note**: See individual Phase descriptions for detailed TodoWrite Update examples:
362
+ - **Phase 2, 3**: Multiple sub-tasks with attach/collapse pattern
363
+ - **Phase 4**: Single agent task (no collapse needed)
364
+
365
+ ## Input Processing
366
+
367
+ **Convert User Input to Structured Format**:
368
+
369
+ 1. **Simple Text** → Structure it:
370
+ ```
371
+ User: "Build authentication system"
372
+
373
+ Structured:
374
+ GOAL: Build authentication system
375
+ SCOPE: Core authentication features
376
+ CONTEXT: New implementation
377
+ ```
378
+
379
+ 2. **Detailed Text** → Extract components:
380
+ ```
381
+ User: "Add JWT authentication with email/password login and token refresh"
382
+
383
+ Structured:
384
+ GOAL: Implement JWT-based authentication
385
+ SCOPE: Email/password login, token generation, token refresh endpoints
386
+ CONTEXT: JWT token-based security, refresh token rotation
387
+ ```
388
+
389
+ 3. **File Reference** (e.g., `requirements.md`) → Read and structure:
390
+ - Read file content
391
+ - Extract goal, scope, requirements
392
+ - Format into structured description
393
+
394
+ ## Data Flow
395
+
396
+ ```
397
+ User Input (task description)
398
+
399
+ [Convert to Structured Format]
400
+ Structured Description:
401
+ ↓ GOAL: [objective]
402
+ SCOPE: [boundaries]
403
+ CONTEXT: [background]
404
+
405
+ Phase 1: session:start --auto "structured-description"
406
+ Output: sessionId
407
+ Session Memory: Previous tasks, context, artifacts
408
+
409
+ Phase 2: context-gather --session sessionId "structured-description"
410
+ ↓ Input: sessionId + session memory + structured description
411
+ Output: contextPath (context-package.json) + conflict_risk
412
+
413
+ Phase 3: conflict-resolution [AUTO-TRIGGERED if conflict_risk ≥ medium]
414
+ Input: sessionId + contextPath + conflict_risk
415
+ CLI-powered conflict detection (JSON output)
416
+ AskUserQuestion: Present conflicts + resolution strategies
417
+ User selects strategies (or skip)
418
+ Apply modifications via Edit tool:
419
+ - Update guidance-specification.md
420
+ - Update role analyses (*.md)
421
+ ↓ - Mark context-package.json as "resolved"
422
+ Output: Modified brainstorm artifacts (NO report file)
423
+ Skip if conflict_risk is none/low → proceed directly to Phase 4
424
+
425
+ Phase 4: task-generate-agent --session sessionId
426
+ ↓ Input: sessionId + resolved brainstorm artifacts + session memory
427
+ ↓ Output: IMPL_PLAN.md, task JSONs, TODO_LIST.md
428
+
429
+ Return summary to user
430
+ ```
431
+
432
+ **Session Memory Flow**: Each phase receives session ID, which provides access to:
433
+ - Previous task summaries
434
+ - Existing context and analysis
435
+ - Brainstorming artifacts (potentially modified by Phase 3)
436
+ - Session-specific configuration
437
+
438
+
439
+ ## Execution Flow Diagram
440
+
441
+ ```
442
+ User triggers: /workflow:plan "Build authentication system"
443
+
444
+ [TodoWrite Init] 3 orchestrator-level tasks
445
+
446
+ Phase 1: Session Discovery
447
+ sessionId extracted
448
+
449
+ Phase 2: Context Gathering (SlashCommand executed)
450
+ ATTACH 3 sub-tasks: ← ATTACHED
451
+ - Analyze codebase structure
452
+ - Identify integration points
453
+ - → Generate context package
454
+ Execute sub-tasks sequentially
455
+ COLLAPSE tasks COLLAPSED
456
+ contextPath + conflict_risk extracted
457
+
458
+ Conditional Branch: Check conflict_risk
459
+ ├─ IF conflict_risk medium:
460
+ Phase 3: Conflict Resolution (SlashCommand executed)
461
+ │ → ATTACH 3 sub-tasks: ← ATTACHED
462
+ - Detect conflicts with CLI analysis
463
+ - → Present conflicts to user
464
+ │ - Apply resolution strategies
465
+ │ → Execute sub-tasks sequentially
466
+ │ → COLLAPSE tasks COLLAPSED
467
+
468
+ └─ ELSE: Skip Phase 3, proceed to Phase 4
469
+
470
+ Phase 4: Task Generation (SlashCommand executed)
471
+ → Single agent task (no sub-tasks)
472
+ Agent autonomously completes internally:
473
+ (discovery → planning → output)
474
+ → Outputs: IMPL_PLAN.md, IMPL-*.json, TODO_LIST.md
475
+
476
+ Return summary to user
477
+ ```
478
+
479
+ **Key Points**:
480
+ - **← ATTACHED**: Tasks attached to TodoWrite when SlashCommand executed
481
+ - Phase 2, 3: Multiple sub-tasks
482
+ - Phase 4: Single agent task
483
+ - **← COLLAPSED**: Sub-tasks collapsed to summary after completion (Phase 2, 3 only)
484
+ - **Phase 4**: Single agent task, no collapse (just mark completed)
485
+ - **Conditional Branch**: Phase 3 only executes if conflict_risk ≥ medium
486
+ - **Continuous Flow**: No user intervention between phases
487
+
488
+ ## Error Handling
489
+
490
+ - **Parsing Failure**: If output parsing fails, retry command once, then report error
491
+ - **Validation Failure**: If validation fails, report which file/data is missing
492
+ - **Command Failure**: Keep phase `in_progress`, report error to user, do not proceed to next phase
493
+
494
+ ## Coordinator Checklist
495
+
496
+ - **Pre-Phase**: Convert user input to structured format (GOAL/SCOPE/CONTEXT)
497
+ - Initialize TodoWrite before any command (Phase 3 added dynamically after Phase 2)
498
+ - Execute Phase 1 immediately with structured description
499
+ - Parse session ID from Phase 1 output, store in memory
500
+ - Pass session ID and structured description to Phase 2 command
501
+ - Parse context path from Phase 2 output, store in memory
502
+ - **Extract conflict_risk from context-package.json**: Determine Phase 3 execution
503
+ - **If conflict_risk medium**: Launch Phase 3 conflict-resolution with sessionId and contextPath
504
+ - Wait for Phase 3 to finish executing (if executed), verify conflict-resolution.json created
505
+ - **If conflict_risk is none/low**: Skip Phase 3, proceed directly to Phase 4
506
+ - **Build Phase 4 command**: `/workflow:tools:task-generate-agent --session [sessionId]`
507
+ - Pass session ID to Phase 4 command
508
+ - Verify all Phase 4 outputs
509
+ - Update TodoWrite after each phase (dynamically adjust for Phase 3 presence)
510
+ - After each phase, automatically continue to next phase based on TodoList status
511
+
512
+ ## Structure Template Reference
513
+
514
+ **Minimal Structure**:
515
+ ```
516
+ GOAL: [What to achieve]
517
+ SCOPE: [What's included]
518
+ CONTEXT: [Relevant info]
519
+ ```
520
+
521
+ **Detailed Structure** (optional, when more context available):
522
+ ```
523
+ GOAL: [Primary objective]
524
+ SCOPE: [Included features/components]
525
+ CONTEXT: [Existing system, constraints, dependencies]
526
+ REQUIREMENTS: [Specific technical requirements]
527
+ CONSTRAINTS: [Limitations or boundaries]
528
+ ```
529
+
530
+ **Usage in Commands**:
531
+ ```bash
532
+ # Phase 1
533
+ /workflow:session:start --auto "GOAL: Build authentication\nSCOPE: JWT, login, registration\nCONTEXT: REST API"
534
+
535
+ # Phase 2
536
+ /workflow:tools:context-gather --session WFS-123 "GOAL: Build authentication\nSCOPE: JWT, login, registration\nCONTEXT: REST API"
537
+ ```
538
+
539
+ ## Related Commands
540
+
541
+ **Prerequisite Commands**:
542
+ - `/workflow:brainstorm:artifacts` - Optional: Generate role-based analyses before planning (if complex requirements need multiple perspectives)
543
+ - `/workflow:brainstorm:synthesis` - Optional: Refine brainstorm analyses with clarifications
544
+
545
+ **Called by This Command** (5 phases):
546
+ - `/workflow:session:start` - Phase 1: Create or discover workflow session
547
+ - `/workflow:tools:context-gather` - Phase 2: Gather project context and analyze codebase
548
+ - `/workflow:tools:conflict-resolution` - Phase 3: Detect and resolve conflicts (auto-triggered if conflict_risk ≥ medium)
549
+ - `/compact` - Phase 3: Memory optimization (if context approaching limits)
550
+ - `/workflow:tools:task-generate-agent` - Phase 4: Generate task JSON files with agent-driven approach
551
+
552
+ **Follow-up Commands**:
553
+ - `/workflow:plan-verify` - Recommended: Verify plan quality and catch issues before execution
554
+ - `/workflow:status` - Review task breakdown and current progress
555
+ - `/workflow:execute` - Begin implementation of generated tasks