claude-code-workflow 7.2.14 → 7.2.15

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 (75) hide show
  1. package/.claude/commands/workflow/analyze-with-file.md +7 -0
  2. package/.codex/skills/analyze-with-file/SKILL.md +1181 -1182
  3. package/.codex/skills/brainstorm/SKILL.md +723 -725
  4. package/.codex/skills/brainstorm-with-file/SKILL.md +10 -5
  5. package/.codex/skills/clean/SKILL.md +33 -26
  6. package/.codex/skills/collaborative-plan-with-file/SKILL.md +830 -831
  7. package/.codex/skills/csv-wave-pipeline/SKILL.md +906 -906
  8. package/.codex/skills/issue-discover/SKILL.md +57 -50
  9. package/.codex/skills/issue-discover/phases/01-issue-new.md +18 -11
  10. package/.codex/skills/issue-discover/phases/02-discover.md +31 -26
  11. package/.codex/skills/issue-discover/phases/03-discover-by-prompt.md +13 -11
  12. package/.codex/skills/issue-discover/phases/04-quick-execute.md +32 -27
  13. package/.codex/skills/parallel-dev-cycle/SKILL.md +402 -402
  14. package/.codex/skills/project-documentation-workflow/SKILL.md +13 -3
  15. package/.codex/skills/roadmap-with-file/SKILL.md +901 -897
  16. package/.codex/skills/session-sync/SKILL.md +222 -212
  17. package/.codex/skills/spec-add/SKILL.md +620 -613
  18. package/.codex/skills/spec-generator/SKILL.md +2 -2
  19. package/.codex/skills/spec-generator/phases/01-5-requirement-clarification.md +10 -10
  20. package/.codex/skills/spec-generator/phases/01-discovery.md +11 -18
  21. package/.codex/skills/spec-generator/phases/02-product-brief.md +5 -5
  22. package/.codex/skills/spec-generator/phases/03-requirements.md +7 -7
  23. package/.codex/skills/spec-generator/phases/04-architecture.md +4 -4
  24. package/.codex/skills/spec-generator/phases/05-epics-stories.md +5 -6
  25. package/.codex/skills/spec-generator/phases/06-readiness-check.md +10 -17
  26. package/.codex/skills/spec-generator/phases/07-issue-export.md +326 -329
  27. package/.codex/skills/spec-setup/SKILL.md +669 -657
  28. package/.codex/skills/team-arch-opt/SKILL.md +50 -50
  29. package/.codex/skills/team-arch-opt/agents/completion-handler.md +3 -3
  30. package/.codex/skills/team-brainstorm/SKILL.md +724 -725
  31. package/.codex/skills/team-coordinate/SKILL.md +51 -51
  32. package/.codex/skills/team-coordinate/agents/completion-handler.md +3 -3
  33. package/.codex/skills/team-coordinate/agents/plan-reviewer.md +4 -4
  34. package/.codex/skills/team-designer/SKILL.md +691 -691
  35. package/.codex/skills/team-designer/agents/requirement-clarifier.md +11 -12
  36. package/.codex/skills/team-executor/SKILL.md +45 -45
  37. package/.codex/skills/team-frontend/SKILL.md +45 -45
  38. package/.codex/skills/team-frontend/agents/completion-handler.md +3 -3
  39. package/.codex/skills/team-frontend/agents/qa-gate-reviewer.md +4 -4
  40. package/.codex/skills/team-frontend-debug/SKILL.md +50 -50
  41. package/.codex/skills/team-frontend-debug/agents/completion-handler.md +3 -3
  42. package/.codex/skills/team-frontend-debug/agents/conditional-skip-gate.md +4 -4
  43. package/.codex/skills/team-issue/SKILL.md +751 -740
  44. package/.codex/skills/team-iterdev/SKILL.md +825 -826
  45. package/.codex/skills/team-lifecycle-v4/SKILL.md +775 -775
  46. package/.codex/skills/team-lifecycle-v4/agents/quality-gate.md +165 -165
  47. package/.codex/skills/team-lifecycle-v4/agents/requirement-clarifier.md +163 -163
  48. package/.codex/skills/team-perf-opt/SKILL.md +50 -50
  49. package/.codex/skills/team-perf-opt/agents/completion-handler.md +3 -3
  50. package/.codex/skills/team-planex-v2/SKILL.md +652 -637
  51. package/.codex/skills/team-quality-assurance/SKILL.md +51 -52
  52. package/.codex/skills/team-review/SKILL.md +40 -40
  53. package/.codex/skills/team-roadmap-dev/SKILL.md +51 -51
  54. package/.codex/skills/team-roadmap-dev/agents/roadmap-discusser.md +8 -8
  55. package/.codex/skills/team-tech-debt/SKILL.md +50 -50
  56. package/.codex/skills/team-tech-debt/agents/plan-approver.md +5 -5
  57. package/.codex/skills/team-testing/SKILL.md +51 -52
  58. package/.codex/skills/team-uidesign/SKILL.md +40 -40
  59. package/.codex/skills/team-uidesign/agents/completion-handler.md +177 -177
  60. package/.codex/skills/team-ultra-analyze/SKILL.md +786 -787
  61. package/.codex/skills/team-ultra-analyze/agents/discussion-feedback.md +8 -8
  62. package/.codex/skills/team-ux-improve/SKILL.md +51 -52
  63. package/.codex/skills/team-ux-improve/agents/ux-designer.md +2 -2
  64. package/.codex/skills/team-ux-improve/agents/ux-explorer.md +1 -1
  65. package/.codex/skills/unified-execute-with-file/SKILL.md +797 -796
  66. package/.codex/skills/workflow-execute/SKILL.md +1117 -1118
  67. package/.codex/skills/workflow-lite-planex/SKILL.md +1144 -1141
  68. package/.codex/skills/workflow-plan/SKILL.md +631 -636
  69. package/.codex/skills/workflow-tdd-plan/SKILL.md +753 -759
  70. package/.codex/skills/workflow-test-fix-cycle/SKILL.md +402 -392
  71. package/README.md +25 -0
  72. package/ccw/dist/commands/install.d.ts.map +1 -1
  73. package/ccw/dist/commands/install.js +12 -0
  74. package/ccw/dist/commands/install.js.map +1 -1
  75. package/package.json +1 -1
@@ -1,636 +1,631 @@
1
- ---
2
- name: workflow-plan
3
- description: |
4
- Planning pipeline with multi-mode routing (plan/verify/replan). Session discovery →
5
- context gathering (spawn_agent) → conditional conflict resolution → task generation
6
- (spawn_agent or N+1 parallel agents) → plan verification → interactive replan.
7
- Produces IMPL_PLAN.md, task JSONs, TODO_LIST.md.
8
- argument-hint: "[-y|--yes] [--session ID] \"task description\" | verify [--session ID] | replan [--session ID] [IMPL-N] \"changes\""
9
- allowed-tools: spawn_agent, wait, send_input, close_agent, AskUserQuestion, Read, Write, Edit, Bash, Glob, Grep
10
- ---
11
-
12
- ## Auto Mode
13
-
14
- When `--yes` or `-y`: Skip all confirmations, use defaults, auto-verify, auto-continue to execute if PROCEED.
15
-
16
- # Workflow Plan
17
-
18
- ## Usage
19
-
20
- ```bash
21
- # Plan mode (default)
22
- $workflow-plan "Build authentication system with JWT and OAuth"
23
- $workflow-plan -y "Add rate limiting to API endpoints"
24
- $workflow-plan --session WFS-auth "Extend with 2FA support"
25
-
26
- # Verify mode
27
- $workflow-plan verify --session WFS-auth
28
- $workflow-plan verify
29
-
30
- # Replan mode
31
- $workflow-plan replan --session WFS-auth "Change from JWT to session-based auth"
32
- $workflow-plan replan --session WFS-auth IMPL-3 "Split into two smaller tasks"
33
- ```
34
-
35
- **Flags**:
36
- - `-y, --yes`: Skip all confirmations (auto mode)
37
- - `--session ID`: Use specific session
38
-
39
- ---
40
-
41
- ## Overview
42
-
43
- Multi-mode planning pipeline using subagent coordination. Plan mode runs 4 sequential phases with conditional branching; verify and replan modes operate on existing plans.
44
-
45
- ```
46
- ┌──────────────────────────────────────────────────────────────────┐
47
- │ WORKFLOW PLAN PIPELINE │
48
- ├──────────────────────────────────────────────────────────────────┤
49
- │ │
50
- │ Mode Detection: plan | verify | replan │
51
- │ │
52
- │ ═══ Plan Mode (default) ═══ │
53
- │ │
54
- │ Phase 1: Session Discovery │
55
- │ ├─ Create or find workflow session │
56
- │ └─ Initialize planning-notes.md │
57
- │ │
58
- │ Phase 2: Context Gathering (spawn_agent: context-search-agent) │
59
- │ ├─ Codebase analysis → context-package.json │
60
- │ └─ Conflict risk assessment │
61
- │ │
62
- │ Phase 3: Conflict Resolution (conditional: risk ≥ medium) │
63
- │ ├─ CLI-driven conflict analysis │
64
- │ └─ User-selected resolution strategies │
65
- │ │
66
- │ Phase 4: Task Generation (spawn_agent: action-planning-agent) │
67
- │ ├─ Single module → 1 agent │
68
- │ ├─ Multi-module → N+1 parallel agents │
69
- │ └─ Output: IMPL_PLAN.md + task JSONs + TODO_LIST.md │
70
- │ │
71
- │ Plan Confirmation Gate
72
- │ ├─ "Verify Plan" → Phase 5 │
73
- │ ├─ "Start Execution" → workflow-execute
74
- │ └─ "Review Status" → Display inline │
75
- │ │
76
- │ ═══ Verify Mode ═══ │
77
- │ Phase 5: Plan Verification (spawn_agent: cli-explore-agent) │
78
- │ └─ 10-dimension analysis → PLAN_VERIFICATION.md │
79
- │ │
80
- │ ═══ Replan Mode ═══ │
81
- │ Phase 6: Interactive Replan │
82
- │ └─ Clarification → Impact → Backup → Apply → Verify │
83
- │ │
84
- └──────────────────────────────────────────────────────────────────┘
85
- ```
86
-
87
- ---
88
-
89
- ## Data Flow
90
-
91
- ```
92
- User Input (task description)
93
-
94
- ↓ [Convert to GOAL/SCOPE/CONTEXT]
95
-
96
- Phase 1 ──→ sessionId, planning-notes.md
97
-
98
- Phase 2 ──→ context-package.json, conflictRisk
99
-
100
- ├── conflictRisk ≥ medium ──→ Phase 3 ──→ modified artifacts
101
- └── conflictRisk < medium ──→ skip Phase 3
102
-
103
- Phase 4 ──→ IMPL_PLAN.md, plan.json, task JSONs, TODO_LIST.md
104
-
105
- ├── Verify → Phase 5 → PLAN_VERIFICATION.md
106
- ├── Execute → workflow-execute skill
107
- └── Review → inline display
108
- ```
109
-
110
- ---
111
-
112
- ## Session Structure
113
-
114
- ```
115
- .workflow/active/WFS-{session}/
116
- ├── workflow-session.json # Session metadata
117
- ├── planning-notes.md # Accumulated context across phases
118
- ├── IMPL_PLAN.md # Implementation plan (human-readable)
119
- ├── plan.json # Structured plan overview (machine-readable)
120
- ├── TODO_LIST.md # Task checklist
121
- ├── .task/ # Task definitions
122
- │ ├── IMPL-1.json
123
- │ └── IMPL-N.json
124
- └── .process/
125
- ├── context-package.json # Phase 2 output
126
- ├── conflict-resolution.json # Phase 3 output (conditional)
127
- ├── PLAN_VERIFICATION.md # Phase 5 output
128
- └── backup/ # Phase 6 backups
129
- ```
130
-
131
- ---
132
-
133
- ## Implementation
134
-
135
- ### Session Initialization
136
-
137
- ```javascript
138
- const getUtc8ISOString = () => new Date(Date.now() + 8 * 60 * 60 * 1000).toISOString()
139
-
140
- // Parse flags
141
- const AUTO_YES = $ARGUMENTS.includes('--yes') || $ARGUMENTS.includes('-y')
142
- const sessionMatch = $ARGUMENTS.match(/--session\s+(\S+)/)
143
- const existingSessionId = sessionMatch ? sessionMatch[1] : null
144
-
145
- // Mode detection
146
- const cleanArgs = $ARGUMENTS
147
- .replace(/--yes|-y|--session\s+\S+/g, '').trim()
148
-
149
- let mode = 'plan'
150
- if (cleanArgs.startsWith('verify')) mode = 'verify'
151
- else if (cleanArgs.startsWith('replan')) mode = 'replan'
152
-
153
- const taskDescription = cleanArgs
154
- .replace(/^(verify|replan)\s*/, '')
155
- .replace(/^["']|["']$/g, '')
156
- .trim()
157
-
158
- // Extract replan task ID if present
159
- const replanTaskMatch = taskDescription.match(/^(IMPL-\d+(?:\.\d+)?)\s+(.+)/)
160
- const replanTaskId = replanTaskMatch ? replanTaskMatch[1] : null
161
- const replanDescription = replanTaskMatch ? replanTaskMatch[2] : taskDescription
162
- ```
163
-
164
- ---
165
-
166
- ### Phase 1: Session Discovery (Plan Mode)
167
-
168
- **Objective**: Create or find workflow session, initialize planning notes.
169
-
170
- ```javascript
171
- if (mode !== 'plan') {
172
- // verify/replan: locate existing session
173
- // → Jump to Phase 5 or Phase 6
174
- }
175
-
176
- let sessionId, sessionFolder
177
-
178
- if (existingSessionId) {
179
- sessionId = existingSessionId
180
- sessionFolder = `.workflow/active/${sessionId}`
181
- if (!Bash(`test -d "${sessionFolder}" && echo yes`).trim()) {
182
- console.log(`ERROR: Session ${sessionId} not found`)
183
- return
184
- }
185
- } else {
186
- // Auto-detect from .workflow/active/ or create new
187
- const sessions = Bash(`ls -d .workflow/active/WFS-* 2>/dev/null`).trim().split('\n').filter(Boolean)
188
-
189
- if (sessions.length === 0 || taskDescription) {
190
- // Create new session
191
- const slug = taskDescription.toLowerCase()
192
- .replace(/[^a-z0-9\u4e00-\u9fa5]+/g, '-').substring(0, 40)
193
- sessionId = `WFS-${slug}`
194
- sessionFolder = `.workflow/active/${sessionId}`
195
- Bash(`mkdir -p "${sessionFolder}/.task" "${sessionFolder}/.process" "${sessionFolder}/.summaries"`)
196
-
197
- Write(`${sessionFolder}/workflow-session.json`, JSON.stringify({
198
- session_id: sessionId,
199
- status: 'planning',
200
- created_at: getUtc8ISOString(),
201
- task_description: taskDescription
202
- }, null, 2))
203
- } else if (sessions.length === 1) {
204
- sessionId = sessions[0].split('/').pop()
205
- sessionFolder = sessions[0]
206
- } else {
207
- // Multiple sessions — ask user
208
- if (AUTO_YES) {
209
- sessionFolder = sessions[0]
210
- sessionId = sessions[0].split('/').pop()
211
- } else {
212
- const answer = AskUserQuestion({
213
- questions: [{
214
- question: "Multiple sessions found. Select one:",
215
- header: "Session",
216
- multiSelect: false,
217
- options: sessions.slice(0, 4).map(s => ({
218
- label: s.split('/').pop(),
219
- description: s
220
- }))
221
- }]
222
- })
223
- sessionId = answer.Session
224
- sessionFolder = `.workflow/active/${sessionId}`
225
- }
226
- }
227
- }
228
-
229
- // Initialize planning-notes.md
230
- const structuredDesc = `GOAL: ${taskDescription}\nSCOPE: Core implementation\nCONTEXT: New development`
231
- Write(`${sessionFolder}/planning-notes.md`, `# Planning Notes\n\n## User Intent\n${structuredDesc}\n`)
232
-
233
- console.log(`Session: ${sessionId}`)
234
- ```
235
-
236
- ---
237
-
238
- ### Phase 2: Context Gathering (spawn_agent)
239
-
240
- **Objective**: Gather project context, assess conflict risk.
241
-
242
- ```javascript
243
- console.log(`\n## Phase 2: Context Gathering\n`)
244
-
245
- const ctxAgent = spawn_agent({
246
- agent: `~/.codex/agents/context-search-agent.md`,
247
- instruction: `
248
- Gather implementation context for planning.
249
-
250
- **Session**: ${sessionFolder}
251
- **Task**: ${taskDescription}
252
- **Mode**: PLAN
253
-
254
- ### Steps
255
- 1. Analyze project structure (package.json, tsconfig, etc.)
256
- 2. Search for existing similar implementations
257
- 3. Identify integration points and dependencies
258
- 4. Assess conflict risk with existing code
259
- 5. Generate context package
260
-
261
- ### Output
262
- Write context package to: ${sessionFolder}/.process/context-package.json
263
- Format: {
264
- "critical_files": [...],
265
- "patterns": [...],
266
- "dependencies": [...],
267
- "integration_points": [...],
268
- "conflict_risk": "none" | "low" | "medium" | "high",
269
- "conflict_areas": [...],
270
- "constraints": [...]
271
- }
272
- `
273
- })
274
-
275
- wait({ id: ctxAgent })
276
- close_agent({ id: ctxAgent })
277
-
278
- // Parse outputs
279
- const contextPkg = JSON.parse(Read(`${sessionFolder}/.process/context-package.json`) || '{}')
280
- const conflictRisk = contextPkg.conflict_risk || 'none'
281
- const contextPath = `${sessionFolder}/.process/context-package.json`
282
-
283
- // Update planning-notes.md
284
- Edit(`${sessionFolder}/planning-notes.md`, {
285
- oldText: '## User Intent',
286
- newText: `## Context Findings
287
- - Critical files: ${(contextPkg.critical_files || []).join(', ')}
288
- - Conflict risk: ${conflictRisk}
289
- - Constraints: ${(contextPkg.constraints || []).join('; ')}
290
-
291
- ## User Intent`
292
- })
293
-
294
- console.log(` Context gathered. Conflict risk: ${conflictRisk}`)
295
- ```
296
-
297
- ---
298
-
299
- ### Phase 3: Conflict Resolution (Conditional)
300
-
301
- **Objective**: Detect and resolve conflicts when risk ≥ medium.
302
-
303
- ```javascript
304
- if (['medium', 'high'].includes(conflictRisk)) {
305
- console.log(`\n## Phase 3: Conflict Resolution (risk: ${conflictRisk})\n`)
306
-
307
- Bash({
308
- command: `ccw cli -p "PURPOSE: Analyze and resolve conflicts between planned changes and existing codebase.
309
- TASK:
310
- Read context package for conflict areas
311
- Analyze each conflict area in detail
312
- Propose resolution strategies (refactor, adapt, isolate, defer)
313
- • For each conflict: assess impact and recommend approach
314
- MODE: analysis
315
- CONTEXT: @**/*
316
- EXPECTED: JSON: {conflicts: [{area, severity, description, strategy, impact}], summary: string}
317
- CONSTRAINTS: Focus on ${(contextPkg.conflict_areas || []).join(', ')}
318
-
319
- TASK DESCRIPTION: ${taskDescription}" --tool gemini --mode analysis --rule analysis-diagnose-bug-root-cause`,
320
- run_in_background: true
321
- })
322
- // Wait for CLI → conflicts[]
323
-
324
- if (!AUTO_YES && conflicts.length > 0) {
325
- // Present conflicts and let user select strategies
326
- console.log(`\n### Conflicts Found: ${conflicts.length}\n`)
327
- conflicts.forEach((c, i) => {
328
- console.log(`${i + 1}. [${c.severity}] ${c.area}: ${c.description}`)
329
- console.log(` Strategy: ${c.strategy} | Impact: ${c.impact}`)
330
- })
331
-
332
- const answer = AskUserQuestion({
333
- questions: [{
334
- question: "Accept conflict resolution strategies?",
335
- header: "Conflicts",
336
- multiSelect: false,
337
- options: [
338
- { label: "Accept All", description: "Apply all recommended strategies" },
339
- { label: "Review Each", description: "Approve strategies individually" },
340
- { label: "Skip", description: "Proceed without resolving" }
341
- ]
342
- }]
343
- })
344
- }
345
-
346
- // Write resolution
347
- Write(`${sessionFolder}/.process/conflict-resolution.json`,
348
- JSON.stringify({ conflicts, resolved_at: getUtc8ISOString() }, null, 2))
349
-
350
- // Update planning-notes
351
- // Append conflict decisions to planning-notes.md
352
- } else {
353
- console.log(` Conflict risk: ${conflictRisk} — skipping Phase 3`)
354
- }
355
- ```
356
-
357
- ---
358
-
359
- ### Phase 4: Task Generation (spawn_agent)
360
-
361
- **Objective**: Generate IMPL_PLAN.md, task JSONs, TODO_LIST.md.
362
-
363
- **Steps**:
364
-
365
- 1. **Determine Planning Strategy**
366
-
367
- ```javascript
368
- console.log(`\n## Phase 4: Task Generation\n`)
369
-
370
- // Detect module count from context
371
- const modules = contextPkg.integration_points?.map(p => p.module).filter(Boolean) || []
372
- const uniqueModules = [...new Set(modules)]
373
- const isMultiModule = uniqueModules.length >= 2
374
- ```
375
-
376
- 2. **Single Module → One Agent**
377
-
378
- ```javascript
379
- if (!isMultiModule) {
380
- const planAgent = spawn_agent({
381
- agent: `~/.codex/agents/action-planning-agent.md`,
382
- instruction: `
383
- Generate implementation plan and task JSONs.
384
-
385
- **Session**: ${sessionFolder}
386
- **Task**: ${taskDescription}
387
- **Context**: ${contextPath}
388
- **Planning Notes**: ${sessionFolder}/planning-notes.md
389
- ${contextPkg.conflict_risk === 'medium' || contextPkg.conflict_risk === 'high'
390
- ? `**Conflict Resolution**: ${sessionFolder}/.process/conflict-resolution.json` : ''}
391
-
392
- ### Output Requirements
393
- 1. **IMPL_PLAN.md** at ${sessionFolder}/IMPL_PLAN.md
394
- - Section 1: Requirements Summary
395
- - Section 2: Architecture Decisions
396
- - Section 3: Task Breakdown (with dependencies)
397
- - Section 4: Implementation Strategy (Sequential/Parallel/Phased)
398
- - Section 5: Risk Assessment
399
- 2. **plan.json** at ${sessionFolder}/plan.json
400
- - {task_ids[], recommended_execution, complexity, shared_context}
401
- 3. **Task JSONs** at ${sessionFolder}/.task/IMPL-{N}.json
402
- - {id, title, description, depends_on[], convergence, meta: {type, agent}}
403
- 4. **TODO_LIST.md** at ${sessionFolder}/TODO_LIST.md
404
- - Checkbox format: - [ ] IMPL-{N}: {title}
405
- `
406
- })
407
-
408
- wait({ id: planAgent })
409
- close_agent({ id: planAgent })
410
- }
411
- ```
412
-
413
- 3. **Multi-Module → N+1 Parallel Agents**
414
-
415
- ```javascript
416
- if (isMultiModule) {
417
- const prefixes = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
418
- const moduleAgents = []
419
-
420
- // Spawn N module planners in parallel
421
- for (let i = 0; i < uniqueModules.length; i++) {
422
- const prefix = prefixes[i]
423
- const mod = uniqueModules[i]
424
-
425
- const agentId = spawn_agent({
426
- agent: `~/.codex/agents/action-planning-agent.md`,
427
- instruction: `
428
- Plan module: ${mod} (prefix: ${prefix})
429
-
430
- **Session**: ${sessionFolder}
431
- **Module**: ${mod}
432
- **Context**: ${contextPath}
433
- **Task ID prefix**: ${prefix} (e.g., ${prefix}1, ${prefix}2, ...)
434
-
435
- Generate task JSONs for this module only.
436
- Output to: ${sessionFolder}/.task/${prefix}{N}.json
437
- Mark cross-module dependencies as CROSS::${'{module}'}::${'{task}'}
438
- `
439
- })
440
- moduleAgents.push({ id: agentId, module: mod, prefix })
441
- }
442
-
443
- // Wait for all module planners
444
- wait({ ids: moduleAgents.map(a => a.id) })
445
- moduleAgents.forEach(a => close_agent({ id: a.id }))
446
-
447
- // +1 Coordinator: integrate all modules
448
- const coordAgent = spawn_agent({
449
- agent: `~/.codex/agents/action-planning-agent.md`,
450
- instruction: `
451
- Integrate ${uniqueModules.length} module plans into unified IMPL_PLAN.md.
452
-
453
- **Session**: ${sessionFolder}
454
- **Modules**: ${uniqueModules.join(', ')}
455
- **Task Directory**: ${sessionFolder}/.task/
456
-
457
- ### Steps
458
- 1. Read all module task JSONs from .task/
459
- 2. Resolve CROSS:: dependencies (replace with actual task IDs)
460
- 3. Generate unified IMPL_PLAN.md, plan.json, TODO_LIST.md
461
- 4. Renumber task IDs to sequential IMPL-1, IMPL-2, ...
462
- `
463
- })
464
-
465
- wait({ id: coordAgent })
466
- close_agent({ id: coordAgent })
467
- }
468
- ```
469
-
470
- 4. **Plan Confirmation Gate**
471
-
472
- ```javascript
473
- // Validate outputs exist
474
- const planExists = Bash(`test -f "${sessionFolder}/IMPL_PLAN.md" && echo yes`).trim() === 'yes'
475
- const taskCount = parseInt(Bash(`ls ${sessionFolder}/.task/IMPL-*.json 2>/dev/null | wc -l`).trim()) || 0
476
-
477
- console.log(`\n## Plan Generated\n`)
478
- console.log(` Tasks: ${taskCount}`)
479
- console.log(` Plan: ${sessionFolder}/IMPL_PLAN.md`)
480
-
481
- if (AUTO_YES) {
482
- // Auto-verify then auto-execute if PROCEED
483
- console.log(` [--yes] Auto-verifying plan...`)
484
- // Fall through to Phase 5, then Phase 5 result determines next step
485
- } else {
486
- const nextStep = AskUserQuestion({
487
- questions: [{
488
- question: "Plan generated. What's next?",
489
- header: "Next Step",
490
- multiSelect: false,
491
- options: [
492
- { label: "Verify Plan (Recommended)", description: "Run quality verification before execution" },
493
- { label: "Start Execution", description: "Proceed to workflow-execute" },
494
- { label: "Review Status", description: "Display plan summary inline" }
495
- ]
496
- }]
497
- })
498
-
499
- if (nextStep['Next Step'] === 'Start Execution') {
500
- console.log(`\nReady to execute. Run: $workflow-execute --session ${sessionId}`)
501
- return
502
- }
503
- if (nextStep['Next Step'] === 'Review Status') {
504
- const plan = Read(`${sessionFolder}/IMPL_PLAN.md`)
505
- console.log(plan)
506
- return
507
- }
508
- // Verify → continue to Phase 5
509
- }
510
- ```
511
-
512
- ---
513
-
514
- ### Phase 5: Plan Verification (Verify Mode)
515
-
516
- **Objective**: Read-only multi-dimensional plan analysis.
517
-
518
- ```javascript
519
- if (mode === 'verify' || /* auto-verify from Phase 4 */) {
520
- console.log(`\n## Phase 5: Plan Verification\n`)
521
-
522
- // Find session if in verify mode entry
523
- if (mode === 'verify' && !sessionFolder) {
524
- // Session discovery (same logic as Phase 1)
525
- }
526
-
527
- Bash({
528
- command: `ccw cli -p "PURPOSE: Verify implementation plan quality across 10 dimensions. Read-only analysis. Success = actionable quality gate recommendation.
529
- TASK:
530
- A: User Intent Alignment does plan match original goal?
531
- B: Requirements Coverageare all requirements addressed?
532
- C: Consistency Validationinternal consistency of plan
533
- D: Dependency Integrityvalid dependency chain
534
- E: Synthesis Alignmentmatches brainstorm artifacts (if exist)
535
- F: Task Specification Quality clear, actionable, testable
536
- G: Duplication Detectionno overlapping tasks
537
- • H: Feasibility Assessment — realistic scope and effort
538
- • I: Constraints Compliance respects stated constraints
539
- • J: Context Validation planning-notes consistent with plan
540
- MODE: analysis
541
- CONTEXT: @${sessionFolder}/IMPL_PLAN.md @${sessionFolder}/.task/**/*.json @${sessionFolder}/planning-notes.md @${sessionFolder}/TODO_LIST.md
542
- EXPECTED: Structured report with: per-dimension score (PASS/WARN/FAIL), issues list, quality gate (BLOCK_EXECUTION/PROCEED_WITH_FIXES/PROCEED_WITH_CAUTION/PROCEED)
543
- CONSTRAINTS: Read-only | No file modifications | Be specific about issues" --tool gemini --mode analysis --rule analysis-review-architecture --cd "${sessionFolder}"`,
544
- run_in_background: true
545
- })
546
- // Wait for CLI → verification report
547
-
548
- Write(`${sessionFolder}/.process/PLAN_VERIFICATION.md`, verificationReport)
549
-
550
- console.log(` Quality gate: ${qualityGate}`)
551
- console.log(` Report: ${sessionFolder}/.process/PLAN_VERIFICATION.md`)
552
-
553
- if (AUTO_YES && qualityGate === 'PROCEED') {
554
- console.log(` [--yes] Plan verified. Ready for execution.`)
555
- console.log(` Run: $workflow-execute --session ${sessionId}`)
556
- }
557
- }
558
- ```
559
-
560
- ---
561
-
562
- ### Phase 6: Interactive Replan (Replan Mode)
563
-
564
- **Objective**: Modify existing plan based on new requirements.
565
-
566
- ```javascript
567
- if (mode === 'replan') {
568
- console.log(`\n## Phase 6: Interactive Replan\n`)
569
-
570
- // Find session
571
- if (!sessionFolder) {
572
- // Session discovery logic
573
- }
574
-
575
- const scope = replanTaskId ? 'task' : 'session'
576
- console.log(` Scope: ${scope}${replanTaskId ? ` (${replanTaskId})` : ''}`)
577
- console.log(` Changes: ${replanDescription}`)
578
-
579
- // 1. Backup current plan
580
- Bash(`mkdir -p "${sessionFolder}/.process/backup" && cp "${sessionFolder}/IMPL_PLAN.md" "${sessionFolder}/.process/backup/IMPL_PLAN-$(date +%Y%m%d%H%M%S).md"`)
581
-
582
- // 2. Replan via agent
583
- const replanAgent = spawn_agent({
584
- agent: `~/.codex/agents/action-planning-agent.md`,
585
- instruction: `
586
- Replan ${scope === 'task' ? `task ${replanTaskId}` : 'entire session'}.
587
-
588
- **Session**: ${sessionFolder}
589
- **Current Plan**: ${sessionFolder}/IMPL_PLAN.md
590
- **Current Tasks**: ${sessionFolder}/.task/
591
- **Changes Requested**: ${replanDescription}
592
- ${replanTaskId ? `**Target Task**: ${sessionFolder}/.task/${replanTaskId}.json` : ''}
593
-
594
- ### Steps
595
- 1. Read current plan and task JSONs
596
- 2. Analyze impact of requested changes
597
- 3. Modify affected tasks (update/add/remove)
598
- 4. Update IMPL_PLAN.md with change annotations
599
- 5. Update TODO_LIST.md
600
- 6. Generate change summary
601
-
602
- ### Constraints
603
- - Preserve completed tasks
604
- - Minimize changes to unaffected tasks
605
- - Maintain dependency integrity
606
- `
607
- })
608
-
609
- wait({ id: replanAgent })
610
- close_agent({ id: replanAgent })
611
-
612
- console.log(` Replan complete. Review: ${sessionFolder}/IMPL_PLAN.md`)
613
- }
614
- ```
615
-
616
- ---
617
-
618
- ## Error Handling
619
-
620
- | Error | Recovery |
621
- |-------|----------|
622
- | No active session | Guide: run `$workflow-plan "description"` first |
623
- | Context gathering timeout | Retry with reduced scope |
624
- | Conflict analysis failure | Skip Phase 3, proceed with warning |
625
- | Task generation failure | Retry agent with simplified context |
626
- | Plan verification failure | Display partial results |
627
- | Session not found (verify/replan) | List available sessions |
628
-
629
- ---
630
-
631
- ## Compact Protection
632
-
633
- > **COMPACT DIRECTIVE**: If context compression occurs:
634
- > - Re-read `planning-notes.md` for accumulated context
635
- > - Re-read `workflow-session.json` for session state
636
- > - Phase 4 is the most token-intensive — if compressed, re-read task JSONs on demand
1
+ ---
2
+ name: workflow-plan
3
+ description: |
4
+ Planning pipeline with multi-mode routing (plan/verify/replan). Session discovery →
5
+ context gathering (spawn_agent) → conditional conflict resolution → task generation
6
+ (spawn_agent or N+1 parallel agents) → plan verification → interactive replan.
7
+ Produces IMPL_PLAN.md, task JSONs, TODO_LIST.md.
8
+ argument-hint: "[-y|--yes] [--session ID] \"task description\" | verify [--session ID] | replan [--session ID] [IMPL-N] \"changes\""
9
+ allowed-tools: spawn_agent, wait, send_input, close_agent, request_user_input, Read, Write, Edit, Bash, Glob, Grep
10
+ ---
11
+
12
+ ## Auto Mode
13
+
14
+ When `--yes` or `-y`: Skip all confirmations, use defaults, auto-verify. **This skill is planning-only it NEVER executes implementation. Output is the plan for user review.**
15
+
16
+ # Workflow Plan
17
+
18
+ ## Usage
19
+
20
+ ```bash
21
+ # Plan mode (default)
22
+ $workflow-plan "Build authentication system with JWT and OAuth"
23
+ $workflow-plan -y "Add rate limiting to API endpoints"
24
+ $workflow-plan --session WFS-auth "Extend with 2FA support"
25
+
26
+ # Verify mode
27
+ $workflow-plan verify --session WFS-auth
28
+ $workflow-plan verify
29
+
30
+ # Replan mode
31
+ $workflow-plan replan --session WFS-auth "Change from JWT to session-based auth"
32
+ $workflow-plan replan --session WFS-auth IMPL-3 "Split into two smaller tasks"
33
+ ```
34
+
35
+ **Flags**:
36
+ - `-y, --yes`: Skip all confirmations (auto mode)
37
+ - `--session ID`: Use specific session
38
+
39
+ ---
40
+
41
+ ## Overview
42
+
43
+ Multi-mode planning pipeline using subagent coordination. Plan mode runs 4 sequential phases with conditional branching; verify and replan modes operate on existing plans.
44
+
45
+ ```
46
+ ┌──────────────────────────────────────────────────────────────────┐
47
+ │ WORKFLOW PLAN PIPELINE │
48
+ ├──────────────────────────────────────────────────────────────────┤
49
+ │ │
50
+ │ Mode Detection: plan | verify | replan │
51
+ │ │
52
+ │ ═══ Plan Mode (default) ═══ │
53
+ │ │
54
+ │ Phase 1: Session Discovery │
55
+ │ ├─ Create or find workflow session │
56
+ │ └─ Initialize planning-notes.md │
57
+ │ │
58
+ │ Phase 2: Context Gathering (spawn_agent: context-search-agent) │
59
+ │ ├─ Codebase analysis → context-package.json │
60
+ │ └─ Conflict risk assessment │
61
+ │ │
62
+ │ Phase 3: Conflict Resolution (conditional: risk ≥ medium) │
63
+ │ ├─ CLI-driven conflict analysis │
64
+ │ └─ User-selected resolution strategies │
65
+ │ │
66
+ │ Phase 4: Task Generation (spawn_agent: action-planning-agent) │
67
+ │ ├─ Single module → 1 agent │
68
+ │ ├─ Multi-module → N+1 parallel agents │
69
+ │ └─ Output: IMPL_PLAN.md + task JSONs + TODO_LIST.md │
70
+ │ │
71
+ │ Plan Confirmation Gate (PLANNING ENDS HERE)
72
+ │ ├─ "Verify Plan" → Phase 5 │
73
+ │ ├─ "Done" → Display next-step command for user
74
+ │ └─ "Review Status" → Display inline │
75
+ │ │
76
+ │ ═══ Verify Mode ═══ │
77
+ │ Phase 5: Plan Verification (spawn_agent: cli-explore-agent) │
78
+ │ └─ 10-dimension analysis → PLAN_VERIFICATION.md │
79
+ │ │
80
+ │ ═══ Replan Mode ═══ │
81
+ │ Phase 6: Interactive Replan │
82
+ │ └─ Clarification → Impact → Backup → Apply → Verify │
83
+ │ │
84
+ └──────────────────────────────────────────────────────────────────┘
85
+ ```
86
+
87
+ ---
88
+
89
+ ## Data Flow
90
+
91
+ ```
92
+ User Input (task description)
93
+
94
+ ↓ [Convert to GOAL/SCOPE/CONTEXT]
95
+
96
+ Phase 1 ──→ sessionId, planning-notes.md
97
+
98
+ Phase 2 ──→ context-package.json, conflictRisk
99
+
100
+ ├── conflictRisk ≥ medium ──→ Phase 3 ──→ modified artifacts
101
+ └── conflictRisk < medium ──→ skip Phase 3
102
+
103
+ Phase 4 ──→ IMPL_PLAN.md, plan.json, task JSONs, TODO_LIST.md
104
+
105
+ ├── Verify → Phase 5 → PLAN_VERIFICATION.md
106
+ ├── Execute → workflow-execute skill
107
+ └── Review → inline display
108
+ ```
109
+
110
+ ---
111
+
112
+ ## Session Structure
113
+
114
+ ```
115
+ .workflow/active/WFS-{session}/
116
+ ├── workflow-session.json # Session metadata
117
+ ├── planning-notes.md # Accumulated context across phases
118
+ ├── IMPL_PLAN.md # Implementation plan (human-readable)
119
+ ├── plan.json # Structured plan overview (machine-readable)
120
+ ├── TODO_LIST.md # Task checklist
121
+ ├── .task/ # Task definitions
122
+ │ ├── IMPL-1.json
123
+ │ └── IMPL-N.json
124
+ └── .process/
125
+ ├── context-package.json # Phase 2 output
126
+ ├── conflict-resolution.json # Phase 3 output (conditional)
127
+ ├── PLAN_VERIFICATION.md # Phase 5 output
128
+ └── backup/ # Phase 6 backups
129
+ ```
130
+
131
+ ---
132
+
133
+ ## Implementation
134
+
135
+ ### Session Initialization
136
+
137
+ ```javascript
138
+ const getUtc8ISOString = () => new Date(Date.now() + 8 * 60 * 60 * 1000).toISOString()
139
+
140
+ // Parse flags
141
+ const AUTO_YES = $ARGUMENTS.includes('--yes') || $ARGUMENTS.includes('-y')
142
+ const sessionMatch = $ARGUMENTS.match(/--session\s+(\S+)/)
143
+ const existingSessionId = sessionMatch ? sessionMatch[1] : null
144
+
145
+ // Mode detection
146
+ const cleanArgs = $ARGUMENTS
147
+ .replace(/--yes|-y|--session\s+\S+/g, '').trim()
148
+
149
+ let mode = 'plan'
150
+ if (cleanArgs.startsWith('verify')) mode = 'verify'
151
+ else if (cleanArgs.startsWith('replan')) mode = 'replan'
152
+
153
+ const taskDescription = cleanArgs
154
+ .replace(/^(verify|replan)\s*/, '')
155
+ .replace(/^["']|["']$/g, '')
156
+ .trim()
157
+
158
+ // Extract replan task ID if present
159
+ const replanTaskMatch = taskDescription.match(/^(IMPL-\d+(?:\.\d+)?)\s+(.+)/)
160
+ const replanTaskId = replanTaskMatch ? replanTaskMatch[1] : null
161
+ const replanDescription = replanTaskMatch ? replanTaskMatch[2] : taskDescription
162
+ ```
163
+
164
+ ---
165
+
166
+ ### Phase 1: Session Discovery (Plan Mode)
167
+
168
+ **Objective**: Create or find workflow session, initialize planning notes.
169
+
170
+ ```javascript
171
+ if (mode !== 'plan') {
172
+ // verify/replan: locate existing session
173
+ // → Jump to Phase 5 or Phase 6
174
+ }
175
+
176
+ let sessionId, sessionFolder
177
+
178
+ if (existingSessionId) {
179
+ sessionId = existingSessionId
180
+ sessionFolder = `.workflow/active/${sessionId}`
181
+ if (!Bash(`test -d "${sessionFolder}" && echo yes`).trim()) {
182
+ console.log(`ERROR: Session ${sessionId} not found`)
183
+ return
184
+ }
185
+ } else {
186
+ // Auto-detect from .workflow/active/ or create new
187
+ const sessions = Bash(`ls -d .workflow/active/WFS-* 2>/dev/null`).trim().split('\n').filter(Boolean)
188
+
189
+ if (sessions.length === 0 || taskDescription) {
190
+ // Create new session
191
+ const slug = taskDescription.toLowerCase()
192
+ .replace(/[^a-z0-9\u4e00-\u9fa5]+/g, '-').substring(0, 40)
193
+ sessionId = `WFS-${slug}`
194
+ sessionFolder = `.workflow/active/${sessionId}`
195
+ Bash(`mkdir -p "${sessionFolder}/.task" "${sessionFolder}/.process" "${sessionFolder}/.summaries"`)
196
+
197
+ Write(`${sessionFolder}/workflow-session.json`, JSON.stringify({
198
+ session_id: sessionId,
199
+ status: 'planning',
200
+ created_at: getUtc8ISOString(),
201
+ task_description: taskDescription
202
+ }, null, 2))
203
+ } else if (sessions.length === 1) {
204
+ sessionId = sessions[0].split('/').pop()
205
+ sessionFolder = sessions[0]
206
+ } else {
207
+ // Multiple sessions — ask user
208
+ if (AUTO_YES) {
209
+ sessionFolder = sessions[0]
210
+ sessionId = sessions[0].split('/').pop()
211
+ } else {
212
+ const answer = request_user_input({
213
+ questions: [{
214
+ question: "Multiple sessions found. Select one:",
215
+ header: "Session",
216
+ options: sessions.slice(0, 4).map(s => ({
217
+ label: s.split('/').pop(),
218
+ description: s
219
+ }))
220
+ }]
221
+ })
222
+ sessionId = answer.Session
223
+ sessionFolder = `.workflow/active/${sessionId}`
224
+ }
225
+ }
226
+ }
227
+
228
+ // Initialize planning-notes.md
229
+ const structuredDesc = `GOAL: ${taskDescription}\nSCOPE: Core implementation\nCONTEXT: New development`
230
+ Write(`${sessionFolder}/planning-notes.md`, `# Planning Notes\n\n## User Intent\n${structuredDesc}\n`)
231
+
232
+ console.log(`Session: ${sessionId}`)
233
+ ```
234
+
235
+ ---
236
+
237
+ ### Phase 2: Context Gathering (spawn_agent)
238
+
239
+ **Objective**: Gather project context, assess conflict risk.
240
+
241
+ ```javascript
242
+ console.log(`\n## Phase 2: Context Gathering\n`)
243
+
244
+ const ctxAgent = spawn_agent({
245
+ agent: `~/.codex/agents/context-search-agent.md`,
246
+ instruction: `
247
+ Gather implementation context for planning.
248
+
249
+ **Session**: ${sessionFolder}
250
+ **Task**: ${taskDescription}
251
+ **Mode**: PLAN
252
+
253
+ ### Steps
254
+ 1. Analyze project structure (package.json, tsconfig, etc.)
255
+ 2. Search for existing similar implementations
256
+ 3. Identify integration points and dependencies
257
+ 4. Assess conflict risk with existing code
258
+ 5. Generate context package
259
+
260
+ ### Output
261
+ Write context package to: ${sessionFolder}/.process/context-package.json
262
+ Format: {
263
+ "critical_files": [...],
264
+ "patterns": [...],
265
+ "dependencies": [...],
266
+ "integration_points": [...],
267
+ "conflict_risk": "none" | "low" | "medium" | "high",
268
+ "conflict_areas": [...],
269
+ "constraints": [...]
270
+ }
271
+ `
272
+ })
273
+
274
+ wait({ id: ctxAgent })
275
+ close_agent({ id: ctxAgent })
276
+
277
+ // Parse outputs
278
+ const contextPkg = JSON.parse(Read(`${sessionFolder}/.process/context-package.json`) || '{}')
279
+ const conflictRisk = contextPkg.conflict_risk || 'none'
280
+ const contextPath = `${sessionFolder}/.process/context-package.json`
281
+
282
+ // Update planning-notes.md
283
+ Edit(`${sessionFolder}/planning-notes.md`, {
284
+ oldText: '## User Intent',
285
+ newText: `## Context Findings
286
+ - Critical files: ${(contextPkg.critical_files || []).join(', ')}
287
+ - Conflict risk: ${conflictRisk}
288
+ - Constraints: ${(contextPkg.constraints || []).join('; ')}
289
+
290
+ ## User Intent`
291
+ })
292
+
293
+ console.log(` Context gathered. Conflict risk: ${conflictRisk}`)
294
+ ```
295
+
296
+ ---
297
+
298
+ ### Phase 3: Conflict Resolution (Conditional)
299
+
300
+ **Objective**: Detect and resolve conflicts when risk ≥ medium.
301
+
302
+ ```javascript
303
+ if (['medium', 'high'].includes(conflictRisk)) {
304
+ console.log(`\n## Phase 3: Conflict Resolution (risk: ${conflictRisk})\n`)
305
+
306
+ Bash({
307
+ command: `ccw cli -p "PURPOSE: Analyze and resolve conflicts between planned changes and existing codebase.
308
+ TASK:
309
+ • Read context package for conflict areas
310
+ Analyze each conflict area in detail
311
+ Propose resolution strategies (refactor, adapt, isolate, defer)
312
+ For each conflict: assess impact and recommend approach
313
+ MODE: analysis
314
+ CONTEXT: @**/*
315
+ EXPECTED: JSON: {conflicts: [{area, severity, description, strategy, impact}], summary: string}
316
+ CONSTRAINTS: Focus on ${(contextPkg.conflict_areas || []).join(', ')}
317
+
318
+ TASK DESCRIPTION: ${taskDescription}" --tool gemini --mode analysis --rule analysis-diagnose-bug-root-cause`,
319
+ run_in_background: true
320
+ })
321
+ // Wait for CLI → conflicts[]
322
+
323
+ if (!AUTO_YES && conflicts.length > 0) {
324
+ // Present conflicts and let user select strategies
325
+ console.log(`\n### Conflicts Found: ${conflicts.length}\n`)
326
+ conflicts.forEach((c, i) => {
327
+ console.log(`${i + 1}. [${c.severity}] ${c.area}: ${c.description}`)
328
+ console.log(` Strategy: ${c.strategy} | Impact: ${c.impact}`)
329
+ })
330
+
331
+ const answer = request_user_input({
332
+ questions: [{
333
+ question: "Accept conflict resolution strategies?",
334
+ header: "Conflicts",
335
+ options: [
336
+ { label: "Accept All", description: "Apply all recommended strategies" },
337
+ { label: "Review Each", description: "Approve strategies individually" },
338
+ { label: "Skip", description: "Proceed without resolving" }
339
+ ]
340
+ }]
341
+ })
342
+ }
343
+
344
+ // Write resolution
345
+ Write(`${sessionFolder}/.process/conflict-resolution.json`,
346
+ JSON.stringify({ conflicts, resolved_at: getUtc8ISOString() }, null, 2))
347
+
348
+ // Update planning-notes
349
+ // Append conflict decisions to planning-notes.md
350
+ } else {
351
+ console.log(` Conflict risk: ${conflictRisk} skipping Phase 3`)
352
+ }
353
+ ```
354
+
355
+ ---
356
+
357
+ ### Phase 4: Task Generation (spawn_agent)
358
+
359
+ **Objective**: Generate IMPL_PLAN.md, task JSONs, TODO_LIST.md.
360
+
361
+ **Steps**:
362
+
363
+ 1. **Determine Planning Strategy**
364
+
365
+ ```javascript
366
+ console.log(`\n## Phase 4: Task Generation\n`)
367
+
368
+ // Detect module count from context
369
+ const modules = contextPkg.integration_points?.map(p => p.module).filter(Boolean) || []
370
+ const uniqueModules = [...new Set(modules)]
371
+ const isMultiModule = uniqueModules.length >= 2
372
+ ```
373
+
374
+ 2. **Single Module → One Agent**
375
+
376
+ ```javascript
377
+ if (!isMultiModule) {
378
+ const planAgent = spawn_agent({
379
+ agent: `~/.codex/agents/action-planning-agent.md`,
380
+ instruction: `
381
+ Generate implementation plan and task JSONs.
382
+
383
+ **Session**: ${sessionFolder}
384
+ **Task**: ${taskDescription}
385
+ **Context**: ${contextPath}
386
+ **Planning Notes**: ${sessionFolder}/planning-notes.md
387
+ ${contextPkg.conflict_risk === 'medium' || contextPkg.conflict_risk === 'high'
388
+ ? `**Conflict Resolution**: ${sessionFolder}/.process/conflict-resolution.json` : ''}
389
+
390
+ ### Output Requirements
391
+ 1. **IMPL_PLAN.md** at ${sessionFolder}/IMPL_PLAN.md
392
+ - Section 1: Requirements Summary
393
+ - Section 2: Architecture Decisions
394
+ - Section 3: Task Breakdown (with dependencies)
395
+ - Section 4: Implementation Strategy (Sequential/Parallel/Phased)
396
+ - Section 5: Risk Assessment
397
+ 2. **plan.json** at ${sessionFolder}/plan.json
398
+ - {task_ids[], recommended_execution, complexity, shared_context}
399
+ 3. **Task JSONs** at ${sessionFolder}/.task/IMPL-{N}.json
400
+ - {id, title, description, depends_on[], convergence, meta: {type, agent}}
401
+ 4. **TODO_LIST.md** at ${sessionFolder}/TODO_LIST.md
402
+ - Checkbox format: - [ ] IMPL-{N}: {title}
403
+ `
404
+ })
405
+
406
+ wait({ id: planAgent })
407
+ close_agent({ id: planAgent })
408
+ }
409
+ ```
410
+
411
+ 3. **Multi-Module → N+1 Parallel Agents**
412
+
413
+ ```javascript
414
+ if (isMultiModule) {
415
+ const prefixes = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
416
+ const moduleAgents = []
417
+
418
+ // Spawn N module planners in parallel
419
+ for (let i = 0; i < uniqueModules.length; i++) {
420
+ const prefix = prefixes[i]
421
+ const mod = uniqueModules[i]
422
+
423
+ const agentId = spawn_agent({
424
+ agent: `~/.codex/agents/action-planning-agent.md`,
425
+ instruction: `
426
+ Plan module: ${mod} (prefix: ${prefix})
427
+
428
+ **Session**: ${sessionFolder}
429
+ **Module**: ${mod}
430
+ **Context**: ${contextPath}
431
+ **Task ID prefix**: ${prefix} (e.g., ${prefix}1, ${prefix}2, ...)
432
+
433
+ Generate task JSONs for this module only.
434
+ Output to: ${sessionFolder}/.task/${prefix}{N}.json
435
+ Mark cross-module dependencies as CROSS::${'{module}'}::${'{task}'}
436
+ `
437
+ })
438
+ moduleAgents.push({ id: agentId, module: mod, prefix })
439
+ }
440
+
441
+ // Wait for all module planners
442
+ wait({ ids: moduleAgents.map(a => a.id) })
443
+ moduleAgents.forEach(a => close_agent({ id: a.id }))
444
+
445
+ // +1 Coordinator: integrate all modules
446
+ const coordAgent = spawn_agent({
447
+ agent: `~/.codex/agents/action-planning-agent.md`,
448
+ instruction: `
449
+ Integrate ${uniqueModules.length} module plans into unified IMPL_PLAN.md.
450
+
451
+ **Session**: ${sessionFolder}
452
+ **Modules**: ${uniqueModules.join(', ')}
453
+ **Task Directory**: ${sessionFolder}/.task/
454
+
455
+ ### Steps
456
+ 1. Read all module task JSONs from .task/
457
+ 2. Resolve CROSS:: dependencies (replace with actual task IDs)
458
+ 3. Generate unified IMPL_PLAN.md, plan.json, TODO_LIST.md
459
+ 4. Renumber task IDs to sequential IMPL-1, IMPL-2, ...
460
+ `
461
+ })
462
+
463
+ wait({ id: coordAgent })
464
+ close_agent({ id: coordAgent })
465
+ }
466
+ ```
467
+
468
+ 4. **Plan Confirmation Gate**
469
+
470
+ ```javascript
471
+ // Validate outputs exist
472
+ const planExists = Bash(`test -f "${sessionFolder}/IMPL_PLAN.md" && echo yes`).trim() === 'yes'
473
+ const taskCount = parseInt(Bash(`ls ${sessionFolder}/.task/IMPL-*.json 2>/dev/null | wc -l`).trim()) || 0
474
+
475
+ console.log(`\n## Plan Generated\n`)
476
+ console.log(` Tasks: ${taskCount}`)
477
+ console.log(` Plan: ${sessionFolder}/IMPL_PLAN.md`)
478
+
479
+ if (AUTO_YES) {
480
+ // Auto-verify plan quality
481
+ console.log(` [--yes] Auto-verifying plan...`)
482
+ // Fall through to Phase 5
483
+ } else {
484
+ const nextStep = request_user_input({
485
+ questions: [{
486
+ question: "Plan generated. What's next?",
487
+ header: "Next Step",
488
+ options: [
489
+ { label: "Verify Plan (Recommended)", description: "Run quality verification" },
490
+ { label: "Done", description: "Planning complete — show next-step command" },
491
+ { label: "Review Status", description: "Display plan summary inline" }
492
+ ]
493
+ }]
494
+ })
495
+
496
+ if (nextStep['Next Step'] === 'Done') {
497
+ console.log(`\nPlanning complete. To execute, run: $workflow-execute --session ${sessionId}`)
498
+ return // STOP — this skill is planning-only
499
+ }
500
+ if (nextStep['Next Step'] === 'Review Status') {
501
+ const plan = Read(`${sessionFolder}/IMPL_PLAN.md`)
502
+ console.log(plan)
503
+ return // STOP this skill is planning-only
504
+ }
505
+ // Verify → continue to Phase 5
506
+ }
507
+ ```
508
+
509
+ ---
510
+
511
+ ### Phase 5: Plan Verification (Verify Mode)
512
+
513
+ **Objective**: Read-only multi-dimensional plan analysis.
514
+
515
+ ```javascript
516
+ if (mode === 'verify' || /* auto-verify from Phase 4 */) {
517
+ console.log(`\n## Phase 5: Plan Verification\n`)
518
+
519
+ // Find session if in verify mode entry
520
+ if (mode === 'verify' && !sessionFolder) {
521
+ // Session discovery (same logic as Phase 1)
522
+ }
523
+
524
+ Bash({
525
+ command: `ccw cli -p "PURPOSE: Verify implementation plan quality across 10 dimensions. Read-only analysis. Success = actionable quality gate recommendation.
526
+ TASK:
527
+ • A: User Intent Alignment — does plan match original goal?
528
+ B: Requirements Coverage are all requirements addressed?
529
+ • C: Consistency Validation — internal consistency of plan
530
+ D: Dependency Integrityvalid dependency chain
531
+ E: Synthesis Alignmentmatches brainstorm artifacts (if exist)
532
+ F: Task Specification Quality clear, actionable, testable
533
+ G: Duplication Detectionno overlapping tasks
534
+ H: Feasibility Assessmentrealistic scope and effort
535
+ I: Constraints Compliancerespects stated constraints
536
+ J: Context Validationplanning-notes consistent with plan
537
+ MODE: analysis
538
+ CONTEXT: @${sessionFolder}/IMPL_PLAN.md @${sessionFolder}/.task/**/*.json @${sessionFolder}/planning-notes.md @${sessionFolder}/TODO_LIST.md
539
+ EXPECTED: Structured report with: per-dimension score (PASS/WARN/FAIL), issues list, quality gate (BLOCK_EXECUTION/PROCEED_WITH_FIXES/PROCEED_WITH_CAUTION/PROCEED)
540
+ CONSTRAINTS: Read-only | No file modifications | Be specific about issues" --tool gemini --mode analysis --rule analysis-review-architecture --cd "${sessionFolder}"`,
541
+ run_in_background: true
542
+ })
543
+ // Wait for CLI verification report
544
+
545
+ Write(`${sessionFolder}/.process/PLAN_VERIFICATION.md`, verificationReport)
546
+
547
+ console.log(` Quality gate: ${qualityGate}`)
548
+ console.log(` Report: ${sessionFolder}/.process/PLAN_VERIFICATION.md`)
549
+
550
+ console.log(`\nPlanning complete. To execute, run: $workflow-execute --session ${sessionId}`)
551
+ // STOP — this skill is planning-only, NEVER proceed to execution
552
+ }
553
+ ```
554
+
555
+ ---
556
+
557
+ ### Phase 6: Interactive Replan (Replan Mode)
558
+
559
+ **Objective**: Modify existing plan based on new requirements.
560
+
561
+ ```javascript
562
+ if (mode === 'replan') {
563
+ console.log(`\n## Phase 6: Interactive Replan\n`)
564
+
565
+ // Find session
566
+ if (!sessionFolder) {
567
+ // Session discovery logic
568
+ }
569
+
570
+ const scope = replanTaskId ? 'task' : 'session'
571
+ console.log(` Scope: ${scope}${replanTaskId ? ` (${replanTaskId})` : ''}`)
572
+ console.log(` Changes: ${replanDescription}`)
573
+
574
+ // 1. Backup current plan
575
+ Bash(`mkdir -p "${sessionFolder}/.process/backup" && cp "${sessionFolder}/IMPL_PLAN.md" "${sessionFolder}/.process/backup/IMPL_PLAN-$(date +%Y%m%d%H%M%S).md"`)
576
+
577
+ // 2. Replan via agent
578
+ const replanAgent = spawn_agent({
579
+ agent: `~/.codex/agents/action-planning-agent.md`,
580
+ instruction: `
581
+ Replan ${scope === 'task' ? `task ${replanTaskId}` : 'entire session'}.
582
+
583
+ **Session**: ${sessionFolder}
584
+ **Current Plan**: ${sessionFolder}/IMPL_PLAN.md
585
+ **Current Tasks**: ${sessionFolder}/.task/
586
+ **Changes Requested**: ${replanDescription}
587
+ ${replanTaskId ? `**Target Task**: ${sessionFolder}/.task/${replanTaskId}.json` : ''}
588
+
589
+ ### Steps
590
+ 1. Read current plan and task JSONs
591
+ 2. Analyze impact of requested changes
592
+ 3. Modify affected tasks (update/add/remove)
593
+ 4. Update IMPL_PLAN.md with change annotations
594
+ 5. Update TODO_LIST.md
595
+ 6. Generate change summary
596
+
597
+ ### Constraints
598
+ - Preserve completed tasks
599
+ - Minimize changes to unaffected tasks
600
+ - Maintain dependency integrity
601
+ `
602
+ })
603
+
604
+ wait({ id: replanAgent })
605
+ close_agent({ id: replanAgent })
606
+
607
+ console.log(` Replan complete. Review: ${sessionFolder}/IMPL_PLAN.md`)
608
+ }
609
+ ```
610
+
611
+ ---
612
+
613
+ ## Error Handling
614
+
615
+ | Error | Recovery |
616
+ |-------|----------|
617
+ | No active session | Guide: run `$workflow-plan "description"` first |
618
+ | Context gathering timeout | Retry with reduced scope |
619
+ | Conflict analysis failure | Skip Phase 3, proceed with warning |
620
+ | Task generation failure | Retry agent with simplified context |
621
+ | Plan verification failure | Display partial results |
622
+ | Session not found (verify/replan) | List available sessions |
623
+
624
+ ---
625
+
626
+ ## Compact Protection
627
+
628
+ > **COMPACT DIRECTIVE**: If context compression occurs:
629
+ > - Re-read `planning-notes.md` for accumulated context
630
+ > - Re-read `workflow-session.json` for session state
631
+ > - Phase 4 is the most token-intensive — if compressed, re-read task JSONs on demand