planflow-ai 1.3.4 → 1.4.1

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 (90) hide show
  1. package/.claude/commands/create-plan.md +11 -0
  2. package/.claude/commands/discovery-plan.md +12 -0
  3. package/.claude/commands/execute-plan.md +114 -23
  4. package/.claude/commands/flow.md +30 -5
  5. package/.claude/commands/resume-work.md +261 -0
  6. package/.claude/commands/review-code.md +11 -0
  7. package/.claude/commands/review-pr.md +11 -0
  8. package/.claude/resources/core/_index.md +45 -2
  9. package/.claude/resources/core/atomic-commits.md +380 -0
  10. package/.claude/resources/core/autopilot-mode.md +3 -2
  11. package/.claude/resources/core/compaction-guide.md +15 -1
  12. package/.claude/resources/core/heartbeat.md +129 -1
  13. package/.claude/resources/core/model-routing.md +6 -2
  14. package/.claude/resources/core/per-task-verification.md +362 -0
  15. package/.claude/resources/core/phase-isolation.md +192 -4
  16. package/.claude/resources/core/session-scratchpad.md +1 -0
  17. package/.claude/resources/core/wave-execution.md +329 -0
  18. package/.claude/resources/patterns/plans-patterns.md +56 -0
  19. package/.claude/resources/patterns/plans-templates.md +152 -0
  20. package/.claude/resources/skills/_index.md +8 -6
  21. package/.claude/resources/skills/create-plan-skill.md +71 -5
  22. package/.claude/resources/skills/execute-plan-skill.md +357 -12
  23. package/.claude/resources/skills/resume-work-skill.md +159 -0
  24. package/.claude/rules/core/forbidden-patterns.md +38 -0
  25. package/dist/cli/commands/init.js +1 -1
  26. package/dist/cli/commands/init.js.map +1 -1
  27. package/dist/cli/commands/state.d.ts +12 -0
  28. package/dist/cli/commands/state.d.ts.map +1 -0
  29. package/dist/cli/commands/state.js +47 -0
  30. package/dist/cli/commands/state.js.map +1 -0
  31. package/dist/cli/daemon/desktop-notifier.d.ts +16 -0
  32. package/dist/cli/daemon/desktop-notifier.d.ts.map +1 -0
  33. package/dist/cli/daemon/desktop-notifier.js +53 -0
  34. package/dist/cli/daemon/desktop-notifier.js.map +1 -0
  35. package/dist/cli/daemon/event-writer.d.ts +22 -0
  36. package/dist/cli/daemon/event-writer.d.ts.map +1 -0
  37. package/dist/cli/daemon/event-writer.js +76 -0
  38. package/dist/cli/daemon/event-writer.js.map +1 -0
  39. package/dist/cli/daemon/heartbeat-daemon.js +81 -1
  40. package/dist/cli/daemon/heartbeat-daemon.js.map +1 -1
  41. package/dist/cli/daemon/log-writer.d.ts +17 -0
  42. package/dist/cli/daemon/log-writer.d.ts.map +1 -0
  43. package/dist/cli/daemon/log-writer.js +62 -0
  44. package/dist/cli/daemon/log-writer.js.map +1 -0
  45. package/dist/cli/daemon/notification-router.d.ts +17 -0
  46. package/dist/cli/daemon/notification-router.d.ts.map +1 -0
  47. package/dist/cli/daemon/notification-router.js +35 -0
  48. package/dist/cli/daemon/notification-router.js.map +1 -0
  49. package/dist/cli/daemon/prompt-manager.d.ts +27 -0
  50. package/dist/cli/daemon/prompt-manager.d.ts.map +1 -0
  51. package/dist/cli/daemon/prompt-manager.js +107 -0
  52. package/dist/cli/daemon/prompt-manager.js.map +1 -0
  53. package/dist/cli/index.js +9 -0
  54. package/dist/cli/index.js.map +1 -1
  55. package/dist/cli/state/flowconfig-parser.d.ts +16 -0
  56. package/dist/cli/state/flowconfig-parser.d.ts.map +1 -0
  57. package/dist/cli/state/flowconfig-parser.js +166 -0
  58. package/dist/cli/state/flowconfig-parser.js.map +1 -0
  59. package/dist/cli/state/heartbeat-state.d.ts +16 -0
  60. package/dist/cli/state/heartbeat-state.d.ts.map +1 -0
  61. package/dist/cli/state/heartbeat-state.js +97 -0
  62. package/dist/cli/state/heartbeat-state.js.map +1 -0
  63. package/dist/cli/state/model-router.d.ts +8 -0
  64. package/dist/cli/state/model-router.d.ts.map +1 -0
  65. package/dist/cli/state/model-router.js +36 -0
  66. package/dist/cli/state/model-router.js.map +1 -0
  67. package/dist/cli/state/plan-parser.d.ts +16 -0
  68. package/dist/cli/state/plan-parser.d.ts.map +1 -0
  69. package/dist/cli/state/plan-parser.js +124 -0
  70. package/dist/cli/state/plan-parser.js.map +1 -0
  71. package/dist/cli/state/session-state.d.ts +21 -0
  72. package/dist/cli/state/session-state.d.ts.map +1 -0
  73. package/dist/cli/state/session-state.js +36 -0
  74. package/dist/cli/state/session-state.js.map +1 -0
  75. package/dist/cli/state/state-md-parser.d.ts +18 -0
  76. package/dist/cli/state/state-md-parser.d.ts.map +1 -0
  77. package/dist/cli/state/state-md-parser.js +222 -0
  78. package/dist/cli/state/state-md-parser.js.map +1 -0
  79. package/dist/cli/state/types.d.ts +106 -0
  80. package/dist/cli/state/types.d.ts.map +1 -0
  81. package/dist/cli/state/types.js +8 -0
  82. package/dist/cli/state/types.js.map +1 -0
  83. package/dist/cli/state/wave-calculator.d.ts +18 -0
  84. package/dist/cli/state/wave-calculator.d.ts.map +1 -0
  85. package/dist/cli/state/wave-calculator.js +134 -0
  86. package/dist/cli/state/wave-calculator.js.map +1 -0
  87. package/dist/cli/types.d.ts +15 -0
  88. package/dist/cli/types.d.ts.map +1 -1
  89. package/package.json +4 -2
  90. package/templates/shared/CLAUDE.md.template +4 -0
@@ -0,0 +1,329 @@
1
+
2
+ # Wave-Based Parallel Execution
3
+
4
+ ## Purpose
5
+
6
+ When `wave_execution: true` in `flow/.flowconfig` (default), `/execute-plan` analyzes phase dependencies, groups independent phases into **waves**, and executes phases within each wave **in parallel** using Agent sub-agents. Waves are sequenced — Wave N+1 starts only after all Wave N phases complete. This reduces total execution time by 40-60% for plans with independent phases.
7
+
8
+ **Core principle**: Dependency analysis in, parallel waves out, sequential commits after.
9
+
10
+ ---
11
+
12
+ ## Architecture
13
+
14
+ ```
15
+ Coordinator (main session)
16
+
17
+ ├─ Step 2b: Wave Analysis
18
+ │ ├─ Parse Dependencies from each phase
19
+ │ ├─ Build dependency graph
20
+ │ ├─ Topological sort → group into waves
21
+ │ └─ Present wave summary to user
22
+
23
+ ├─ For each Wave:
24
+ │ │
25
+ │ ├─ Sequential: Approve each phase in Plan Mode
26
+ │ │
27
+ │ ├─ Parallel: Spawn Agent sub-agents for all wave phases
28
+ │ │ ├─► Agent: Phase A (model: [tier from model routing])
29
+ │ │ ├─► Agent: Phase B (model: [tier from model routing])
30
+ │ │ └─► Agent: Phase C (model: [tier from model routing])
31
+ │ │
32
+ │ ├─ Collect JSON returns from all sub-agents
33
+ │ │
34
+ │ ├─ Post-wave processing:
35
+ │ │ ├─ Detect file conflicts (files_modified overlap)
36
+ │ │ ├─ Accumulate files_modified list
37
+ │ │ ├─ Buffer patterns from all phases
38
+ │ │ ├─ Git commit per-task (iterate tasks within each phase, in phase order)
39
+ │ │ └─ Handle failures (present to user)
40
+ │ │
41
+ │ └─ Next Wave...
42
+
43
+ └─ Completion summary with wave execution stats
44
+ ```
45
+
46
+ Planning and user approval always happen **sequentially** in the main session. Only **implementation** is parallelized within waves.
47
+
48
+ ---
49
+
50
+ ## Dependency Analysis
51
+
52
+ ### Dependency Declaration Syntax
53
+
54
+ Each plan phase may include an optional `**Dependencies**` field after `**Complexity**`:
55
+
56
+ ```markdown
57
+ ### Phase 3: API Integration
58
+
59
+ **Scope**: ...
60
+ **Complexity**: 5/10
61
+ **Dependencies**: Phase 1, Phase 2
62
+
63
+ - [ ] Task 1
64
+ - [ ] Task 2
65
+ ```
66
+
67
+ ### Dependency Rules
68
+
69
+ | Declaration | Meaning |
70
+ |-------------|---------|
71
+ | `**Dependencies**: Phase 1, Phase 3` | Phase depends on Phase 1 and Phase 3 completing first |
72
+ | `**Dependencies**: None` | Phase has no dependencies — can run in parallel with others |
73
+ | No `Dependencies` field | **Default**: depends on previous phase (backward-compatible sequential) |
74
+
75
+ **Parsing rules**:
76
+ 1. Look for `**Dependencies**:` line in each phase section
77
+ 2. Extract phase numbers: parse `Phase N` references (case-insensitive)
78
+ 3. `None` (case-insensitive) means explicitly independent
79
+ 4. Missing field = implicit dependency on Phase N-1 (Phase 1 has no implicit dependency)
80
+ 5. Self-references are ignored
81
+ 6. References to non-existent phases are ignored with a warning
82
+
83
+ ### Special Rules
84
+
85
+ - **Tests phase**: NEVER parallelized, regardless of dependency declaration. Always runs alone in the final wave.
86
+ - **Phase 1**: Always in Wave 1 (no possible predecessors)
87
+
88
+ ---
89
+
90
+ ## Wave Grouping Algorithm
91
+
92
+ ### Topological Sort
93
+
94
+ 1. **Build graph**: For each phase, record its dependencies (explicit or implicit)
95
+ 2. **Assign wave numbers**:
96
+ - Phases with no dependencies → Wave 1
97
+ - For each remaining phase: wave = max(wave of each dependency) + 1
98
+ 3. **Tests phase exception**: Move to its own final wave regardless of computed wave number
99
+ 4. **Validate**: Check for circular dependencies — if found, warn user and fall back to sequential
100
+
101
+ ### Example
102
+
103
+ Given a plan with 5 phases:
104
+ ```
105
+ Phase 1: Types and interfaces Dependencies: None
106
+ Phase 2: Utility functions Dependencies: None
107
+ Phase 3: API integration Dependencies: Phase 1, Phase 2
108
+ Phase 4: Configuration updates Dependencies: Phase 1, Phase 3
109
+ Phase 5: Tests Dependencies: Phase 1, Phase 2, Phase 3, Phase 4
110
+ ```
111
+
112
+ Wave grouping result:
113
+ ```
114
+ Wave 1: Phase 1, Phase 2 (both independent)
115
+ Wave 2: Phase 3 (depends on Wave 1 phases)
116
+ Wave 3: Phase 4 (depends on Phase 3 in Wave 2)
117
+ Wave 4: Phase 5 (tests — always last, alone)
118
+ ```
119
+
120
+ Sequential execution: 5 phases in sequence
121
+ Wave execution: 4 waves (Wave 1 runs 2 phases in parallel)
122
+ Estimated speedup: ~20% (1 fewer sequential step)
123
+
124
+ ### Backward Compatibility
125
+
126
+ Plans without any `Dependencies` fields produce a fully sequential wave plan:
127
+ ```
128
+ Wave 1: Phase 1
129
+ Wave 2: Phase 2
130
+ Wave 3: Phase 3
131
+ ...
132
+ ```
133
+
134
+ This matches existing behavior exactly — no regression.
135
+
136
+ ---
137
+
138
+ ## Wave Execution Summary
139
+
140
+ Before execution begins, the coordinator presents the wave plan to the user:
141
+
142
+ ```markdown
143
+ ## Wave Execution Plan
144
+
145
+ | Wave | Phases | Parallel |
146
+ |------|--------|----------|
147
+ | 1 | Phase 1: Types, Phase 2: Utilities | Yes (2 parallel) |
148
+ | 2 | Phase 3: API Integration | No (1 phase) |
149
+ | 3 | Phase 4: Config Updates | No (1 phase) |
150
+ | 4 | Phase 5: Tests | No (always sequential) |
151
+
152
+ **Sequential phases**: 5 → **Waves**: 4 → **Estimated speedup**: ~20%
153
+
154
+ Proceed with wave execution? (yes/no/sequential)
155
+ ```
156
+
157
+ User options:
158
+ - **yes**: Execute with wave parallelism
159
+ - **no**: Stop execution
160
+ - **sequential**: Fall back to sequential execution (ignore waves)
161
+
162
+ ---
163
+
164
+ ## Parallel Spawning Rules
165
+
166
+ ### Sub-Agent Setup
167
+
168
+ Each phase within a wave is spawned as an **independent Agent sub-agent** following the phase-isolation context template (see `phase-isolation.md` COR-PI-2). Key additions for wave execution:
169
+
170
+ 1. **Files Modified context**: For Wave N, include files_modified from ALL completed waves (1 through N-1), not just the previous phase
171
+ 2. **No cross-phase awareness**: Sub-agents within the same wave do NOT know about each other. They receive no information about sibling phases.
172
+ 3. **Model routing**: Each sub-agent uses the model tier from its own phase complexity score (same as phase isolation)
173
+
174
+ ### Spawning Pattern
175
+
176
+ ```
177
+ For Wave N (phases A, B, C):
178
+ Launch in parallel:
179
+ - Agent(model: [tier_A], prompt: phase_A_context)
180
+ - Agent(model: [tier_B], prompt: phase_B_context)
181
+ - Agent(model: [tier_C], prompt: phase_C_context)
182
+
183
+ Wait for all to complete.
184
+ Process results sequentially.
185
+ ```
186
+
187
+ This mirrors the discovery-sub-agents pattern (see `discovery-sub-agents.md` COR-DSA-3) but with phase-isolation context templates instead of exploration prompts.
188
+
189
+ ### Return Format
190
+
191
+ Each sub-agent returns the **same JSON format** as phase isolation (see `phase-isolation.md`), including the `tasks_completed` array for per-task file tracking. The `tasks_completed` field enables the wave coordinator to create atomic per-task commits after the wave completes. See `.claude/resources/core/atomic-commits.md` for the full `tasks_completed` schema.
192
+
193
+ ---
194
+
195
+ ## Wave Coordinator Behavior
196
+
197
+ ### Per-Wave Processing
198
+
199
+ After all sub-agents in a wave return, the coordinator processes results **sequentially in phase order**:
200
+
201
+ 1. **Collect returns**: Gather JSON from all sub-agents
202
+ 2. **Validate JSON**: Parse each return, check for required fields
203
+ 3. **Detect file conflicts**: Check for files_modified overlap between phases in this wave
204
+ 4. **Process each phase** (in phase number order):
205
+ - Update plan file (mark tasks `[x]`)
206
+ - Accumulate files_modified into running list
207
+ - Buffer patterns_captured entries
208
+ - Git commit per-task if enabled: iterate `tasks_completed` array and create one commit per task (`feat(phase-N.task-M): <desc> — <feature>`). See `.claude/resources/core/atomic-commits.md` for format.
209
+ - Log decisions and deviations
210
+ 5. **Report wave completion**: Summary of all phases in this wave, including `task_verifications` results from each phase return (display pass/fail counts and any repairs applied per phase)
211
+
212
+ ### File Conflict Detection
213
+
214
+ After collecting all wave results, check for **files_modified overlap**:
215
+
216
+ ```
217
+ For each pair of phases (A, B) in the wave:
218
+ overlap = A.files_modified ∩ B.files_modified
219
+ if overlap is not empty:
220
+ → File conflict detected
221
+ ```
222
+
223
+ **On conflict**:
224
+ 1. Present the conflicting files and which phases modified them
225
+ 2. Offer options:
226
+ - **(1) Accept as-is**: Last writer wins (the phase with the higher number committed last)
227
+ - **(2) Re-run conflicting phases sequentially**: Re-execute only the conflicting phases in order
228
+ - **(3) Stop execution**: Halt for manual resolution
229
+
230
+ File conflict does NOT affect non-conflicting phases — their results are preserved.
231
+
232
+ ### Failure Handling
233
+
234
+ | Scenario | Behavior |
235
+ |----------|----------|
236
+ | One phase fails, others succeed | Process successful phases normally. Present failure to user. Offer: retry failed phase, skip it, or stop. |
237
+ | Multiple phases fail | Process any successful phases. Present all failures. Offer same options per failed phase. |
238
+ | All phases in wave fail | Present all failures. Offer: retry wave, skip wave, or stop. |
239
+ | Sub-agent timeout | Treat as failure for that phase. Other phases unaffected. |
240
+ | Invalid JSON return | Treat as failure for that phase. |
241
+
242
+ **Key rule**: A failed phase in a wave does NOT cancel other phases in the same wave. Parallel phases are independent — let them all complete.
243
+
244
+ ### Git Commit Ordering
245
+
246
+ When `commit: true` in `.flowconfig`, git commits happen **after** the wave completes, **per-task in phase order then task order**:
247
+
248
+ ```
249
+ Wave 1 complete:
250
+ Phase 1, Task 1: git add -A && git commit -m "feat(phase-1.task-1): Define user and session types — feature-name"
251
+ Phase 1, Task 2: git add -A && git commit -m "feat(phase-1.task-2): Create user schema with Prisma — feature-name"
252
+ Phase 2, Task 1: git add -A && git commit -m "feat(phase-2.task-1): Implement utility helpers — feature-name"
253
+ Phase 2, Task 2: git add -A && git commit -m "feat(phase-2.task-2): Add string formatting utils — feature-name"
254
+ ```
255
+
256
+ The coordinator iterates each phase's `tasks_completed` array (from the JSON return) in task_number order. This ensures **deterministic, fine-grained commit history** regardless of which sub-agent finished first. See `.claude/resources/core/atomic-commits.md` for the full commit format spec.
257
+
258
+ ---
259
+
260
+ ## Configuration
261
+
262
+ ### `.flowconfig` Setting
263
+
264
+ ```yaml
265
+ wave_execution: true # Enable wave-based parallel execution (default: true)
266
+ ```
267
+
268
+ - `true` (default): Analyze dependencies and execute in parallel waves
269
+ - `false`: Sequential execution (ignore Dependencies, legacy behavior)
270
+
271
+ ### Toggle via `/flow`
272
+
273
+ ```
274
+ /flow wave_execution=true
275
+ /flow wave_execution=false
276
+ ```
277
+
278
+ ### Interaction Matrix
279
+
280
+ | wave_execution | phase_isolation | model_routing | Behavior |
281
+ |---------------|-----------------|---------------|----------|
282
+ | `true` | `true` | `true` | Full parallel: waves + isolated sub-agents + correct tier models |
283
+ | `true` | `true` | `false` | Parallel waves + isolated sub-agents + session model |
284
+ | `true` | `false` | `true` | Parallel waves + inline execution per phase + correct tier models |
285
+ | `true` | `false` | `false` | Parallel waves + inline execution + session model |
286
+ | `false` | `true` | `true` | Sequential + isolated sub-agents + correct tier models (existing behavior) |
287
+ | `false` | `true` | `false` | Sequential + isolated sub-agents + session model |
288
+ | `false` | `false` | `true` | Sequential + inline + correct tier models |
289
+ | `false` | `false` | `false` | Sequential + inline + session model (original behavior) |
290
+
291
+ **Note**: `wave_execution: true` requires `phase_isolation: true` for best results. Without phase isolation, parallel execution still works but sub-agents share the session context, which may cause interference.
292
+
293
+ ### Interaction with Aggregation
294
+
295
+ When phases are aggregated (combined complexity ≤ 6), aggregated phases are treated as a **single unit** for wave analysis:
296
+ - They share one dependency set (union of all aggregated phases' dependencies)
297
+ - They produce one wave slot
298
+ - They run as one sub-agent call (same as current aggregation behavior)
299
+
300
+ ---
301
+
302
+ ## Rules
303
+
304
+ 1. **Planning stays sequential** — approve each phase before wave execution begins
305
+ 2. **Tests never parallel** — tests phase always runs alone in the final wave
306
+ 3. **No cross-phase awareness** — sub-agents in the same wave know nothing about each other
307
+ 4. **Deterministic commits** — git commits happen sequentially in phase order after wave completes
308
+ 5. **Failures are isolated** — one failed phase does not cancel sibling phases in the same wave
309
+ 6. **Backward compatible** — plans without Dependencies fields execute sequentially (no behavior change)
310
+ 7. **User controls** — user can always choose sequential execution at the wave summary prompt
311
+ 8. **File conflicts are presented** — never silently resolve file conflicts, always ask the user
312
+ 9. **Reuse phase-isolation format** — sub-agent prompts and JSON returns follow phase-isolation.md exactly
313
+ 10. **Wave analysis is fast** — dependency parsing and topological sort add negligible overhead
314
+ 11. **Verification is internal to sub-agents** — per-task verification loops run entirely inside each phase sub-agent. The wave coordinator does not interact with verification; it only processes the final `task_verifications` field from the JSON return. See `.claude/resources/core/per-task-verification.md` for the complete verification system.
315
+
316
+ ---
317
+
318
+ ## Related Files
319
+
320
+ | File | Purpose |
321
+ |------|---------|
322
+ | `.claude/resources/core/phase-isolation.md` | Sub-agent context template, JSON return format, coordinator processing |
323
+ | `.claude/resources/core/discovery-sub-agents.md` | Parallel spawning pattern (3 agents → collect → merge) |
324
+ | `.claude/resources/core/review-multi-agent.md` | Parallel agents with deduplication |
325
+ | `.claude/resources/core/model-routing.md` | Model tier selection per phase complexity |
326
+ | `.claude/resources/core/complexity-scoring.md` | Complexity scores and aggregation rules |
327
+ | `.claude/resources/core/per-task-verification.md` | Per-task verification system, debug sub-agent, and repair loops |
328
+ | `.claude/resources/skills/execute-plan-skill.md` | Execute-plan skill (Steps 2b, 3, 4 modified for waves) |
329
+ | `.claude/resources/patterns/plans-templates.md` | Plan template with Dependencies field |
@@ -74,6 +74,7 @@ Every plan must be divided into implementation phases with clear scope boundarie
74
74
 
75
75
  - **Scope**: What this phase covers
76
76
  - **Complexity**: Score from 0-10
77
+ - **Dependencies**: (Optional) Which phases must complete first
77
78
  - **Tasks**: Checkboxes for tracking
78
79
  - **Build Verification**: Command to verify
79
80
 
@@ -130,6 +131,48 @@ When executing a plan, each phase must trigger **Plan mode** before implementati
130
131
 
131
132
  ---
132
133
 
134
+ ### 13. Declare Phase Dependencies for Parallel Execution
135
+
136
+ Phases may include an optional `**Dependencies**` field to declare which prior phases must complete before execution can begin. This enables wave-based parallel execution where independent phases run simultaneously.
137
+
138
+ **Syntax**:
139
+
140
+ - `**Dependencies**: None` — No dependencies; can run in the first wave
141
+ - `**Dependencies**: Phase 1, Phase 3` — Depends on specific phases completing first
142
+ - **Omitting the field** — Defaults to depending on the immediately previous phase (sequential)
143
+
144
+ **Rules**:
145
+
146
+ 1. Mark phases as `Dependencies: None` when they have no data or code dependency on other phases
147
+ 2. When two or more phases share the same dependency set, they form a wave and can execute in parallel
148
+ 3. The Tests phase always depends on ALL prior phases — never mark it as `Dependencies: None`
149
+ 4. Dependencies must only reference phases with lower numbers (no forward or circular dependencies)
150
+ 5. When uncertain whether phases are independent, default to sequential (omit the field)
151
+ 6. The dependency declaration is metadata for the execution engine — it does not change the phase content
152
+
153
+ **Example** — independent phases forming a parallel wave:
154
+
155
+ ```markdown
156
+ ### Phase 1: Types and Schemas
157
+ **Dependencies**: None
158
+
159
+ ### Phase 2: API Routes
160
+ **Dependencies**: Phase 1
161
+
162
+ ### Phase 3: CLI Commands
163
+ **Dependencies**: Phase 1
164
+
165
+ ### Phase 4: Integration
166
+ **Dependencies**: Phase 2, Phase 3
167
+
168
+ ### Phase 5: Tests (Final)
169
+ **Dependencies**: Phase 1, Phase 2, Phase 3, Phase 4
170
+ ```
171
+
172
+ Phases 2 and 3 can run in parallel (Wave 2). Phase 4 waits for both. Phase 5 waits for all.
173
+
174
+ ---
175
+
133
176
  ## Forbidden Patterns
134
177
 
135
178
  ### 1. DON'T Read or Reference Archived Plans
@@ -210,6 +253,18 @@ Keep discovery documents in `flow/discovery/` and plans in `flow/plans/`.
210
253
 
211
254
  ---
212
255
 
256
+ ### 14. DON'T Mark the Tests Phase as Independent
257
+
258
+ The Tests phase must always depend on ALL prior phases. Never assign `Dependencies: None` to the Tests phase.
259
+
260
+ ---
261
+
262
+ ### 15. DON'T Create Circular or Forward Dependencies
263
+
264
+ Dependencies must only reference phases with lower numbers. A phase cannot depend on itself or on any phase that comes after it.
265
+
266
+ ---
267
+
213
268
  ## Summary
214
269
 
215
270
  Following these planning patterns ensures:
@@ -223,3 +278,4 @@ Following these planning patterns ensures:
223
278
  - **Clarity**: Archived plans are ignored, only active plans are referenced
224
279
  - **Intelligent Pacing**: Complexity scores guide execution strategy
225
280
  - **Collaborative Execution**: Plan mode ensures user approval before each phase
281
+ - **Parallel Execution**: Dependency declarations enable wave-based parallel phase execution
@@ -51,8 +51,10 @@ Use this template when creating new implementation plans:
51
51
 
52
52
  **Scope**: [What this phase covers]
53
53
  **Complexity**: X/10
54
+ **Dependencies**: None
54
55
 
55
56
  - [ ] Task 1
57
+ <verify>npx tsc --noEmit src/path/to/file.ts</verify>
56
58
  - [ ] Task 2
57
59
 
58
60
  **Build Verification**: Run `npm run build`
@@ -61,6 +63,7 @@ Use this template when creating new implementation plans:
61
63
 
62
64
  **Scope**: [What this phase covers]
63
65
  **Complexity**: X/10
66
+ **Dependencies**: Phase 1
64
67
 
65
68
  - [ ] Task 1
66
69
  - [ ] Task 2
@@ -71,6 +74,7 @@ Use this template when creating new implementation plans:
71
74
 
72
75
  **Scope**: Write comprehensive tests
73
76
  **Complexity**: X/10
77
+ **Dependencies**: Phase 1, Phase 2, ..., Phase N-1
74
78
 
75
79
  - [ ] Unit tests for logic hooks
76
80
  - [ ] Unit tests for utilities
@@ -87,6 +91,130 @@ Use this template when creating new implementation plans:
87
91
 
88
92
  ---
89
93
 
94
+ ## Dependencies Field
95
+
96
+ The optional `**Dependencies**` field declares which phases must complete before a phase can start. This enables wave-based parallel execution.
97
+
98
+ ### Syntax
99
+
100
+ - `**Dependencies**: None` — Phase has no dependencies and can run in the first wave (parallel with other independent phases)
101
+ - `**Dependencies**: Phase 1, Phase 3` — Phase depends on Phases 1 and 3 completing first
102
+ - **Omitting the field entirely** — Backward-compatible default; phase depends on the immediately previous phase (sequential execution)
103
+
104
+ ### Rules
105
+
106
+ 1. The Tests phase (always last) depends on ALL prior phases — it is never parallelized
107
+ 2. Phases with `Dependencies: None` form the first execution wave
108
+ 3. A phase cannot depend on itself or on phases that come after it
109
+ 4. When in doubt, omit the field to default to sequential execution
110
+
111
+ ### Example
112
+
113
+ ```markdown
114
+ ### Phase 1: Types and Schemas
115
+ **Scope**: Define TypeScript types
116
+ **Complexity**: 3/10
117
+ **Dependencies**: None
118
+
119
+ ### Phase 2: Config Parser
120
+ **Scope**: Implement config parsing
121
+ **Complexity**: 4/10
122
+ **Dependencies**: Phase 1
123
+
124
+ ### Phase 3: CLI Commands
125
+ **Scope**: Implement CLI interface
126
+ **Complexity**: 4/10
127
+ **Dependencies**: Phase 1
128
+
129
+ ### Phase 4: Integration
130
+ **Scope**: Connect all pieces
131
+ **Complexity**: 5/10
132
+ **Dependencies**: Phase 2, Phase 3
133
+
134
+ ### Phase 5: Tests (Final)
135
+ **Scope**: Write comprehensive tests
136
+ **Complexity**: 5/10
137
+ **Dependencies**: Phase 1, Phase 2, Phase 3, Phase 4
138
+ ```
139
+
140
+ In this example, Phases 2 and 3 can run in parallel (both only depend on Phase 1). Phase 4 waits for both 2 and 3. Phase 5 (tests) waits for everything.
141
+
142
+ ---
143
+
144
+ ## Verify Tag
145
+
146
+ The optional `<verify>` tag allows tasks to include a verification command that runs immediately after the task completes. This enables early error detection — failures are caught per-task instead of waiting until the final build step.
147
+
148
+ ### Syntax
149
+
150
+ Add a `<verify>` tag indented under a task checkbox:
151
+
152
+ ```markdown
153
+ - [ ] Create type definitions in `/src/types/workflow.ts`
154
+ <verify>npx tsc --noEmit src/types/workflow.ts</verify>
155
+ ```
156
+
157
+ The `<verify>` tag contains a single shell command that validates the task's output. The command should be **targeted** (single file or narrow scope) rather than a full build.
158
+
159
+ ### Rules
160
+
161
+ 1. **Optional**: Tasks without a `<verify>` tag skip verification entirely (backward compatible)
162
+ 2. **One command per tag**: Each `<verify>` tag contains exactly one shell command
163
+ 3. **Targeted checks only**: Use single-file or narrow-scope commands — never full builds
164
+ 4. **Indented under the task**: The `<verify>` tag must be indented under its parent task checkbox
165
+ 5. **No verify for manual-review tasks**: Config files, documentation, and other tasks requiring human judgment should omit `<verify>`
166
+
167
+ ### Examples
168
+
169
+ **Task with verification:**
170
+
171
+ ```markdown
172
+ - [ ] Create `UserProfile` type in `/src/types/user.ts`
173
+ <verify>npx tsc --noEmit src/types/user.ts</verify>
174
+ - [ ] Write unit tests for user validation
175
+ <verify>npx jest src/types/__tests__/user.test.ts --no-coverage</verify>
176
+ ```
177
+
178
+ **Task without verification (backward compatible):**
179
+
180
+ ```markdown
181
+ - [ ] Update `.flowconfig` with new setting
182
+ - [ ] Add documentation for the new feature
183
+ ```
184
+
185
+ **Mixed phase (some tasks verified, some not):**
186
+
187
+ ```markdown
188
+ ### Phase 2: Backend Implementation
189
+
190
+ **Scope**: Implement API routes and data layer.
191
+ **Complexity**: 6/10
192
+ **Dependencies**: Phase 1
193
+
194
+ - [ ] Create API route handler in `/src/routes/workflow.ts`
195
+ <verify>npx tsc --noEmit src/routes/workflow.ts</verify>
196
+ - [ ] Add database migration for `workflow_steps` table
197
+ - [ ] Create service layer in `/src/services/workflow.ts`
198
+ <verify>npx tsc --noEmit src/services/workflow.ts</verify>
199
+
200
+ **Build Verification**: Run `npm run build`
201
+ ```
202
+
203
+ ### Heuristic Reference
204
+
205
+ When writing plans, use these heuristics to decide which tasks get `<verify>` tags:
206
+
207
+ | Task Type | Verify Command | Example |
208
+ |-----------|---------------|---------|
209
+ | File creation (`.ts`) | `npx tsc --noEmit <file>` | `npx tsc --noEmit src/types/user.ts` |
210
+ | Test writing | `npx jest <test-file> --no-coverage` | `npx jest src/__tests__/user.test.ts --no-coverage` |
211
+ | Schema/type definition | `npx tsc --noEmit <type-file>` | `npx tsc --noEmit src/types/schema.ts` |
212
+ | Config file changes | No verify (manual review) | — |
213
+ | Documentation | No verify (manual review) | — |
214
+ | Generic/ambiguous tasks | No verify (default) | — |
215
+
216
+ ---
217
+
90
218
  ## Phase Templates
91
219
 
92
220
  ### Types and Schemas Phase
@@ -96,9 +224,12 @@ Use this template when creating new implementation plans:
96
224
 
97
225
  **Scope**: Define all TypeScript types and Zod schemas needed for the feature.
98
226
  **Complexity**: 3/10
227
+ **Dependencies**: None
99
228
 
100
229
  - [ ] Create type definitions in `/src/types/`
230
+ <verify>npx tsc --noEmit src/types/feature.ts</verify>
101
231
  - [ ] Create Zod validation schemas in `/src/types/rest-inputs.ts`
232
+ <verify>npx tsc --noEmit src/types/rest-inputs.ts</verify>
102
233
 
103
234
  **Build Verification**: Run `npm run build`
104
235
  ```
@@ -110,9 +241,12 @@ Use this template when creating new implementation plans:
110
241
 
111
242
  **Scope**: Implement API routes and commands.
112
243
  **Complexity**: 7/10
244
+ **Dependencies**: Phase 1
113
245
 
114
246
  - [ ] Create command in `/src/commands/`
247
+ <verify>npx tsc --noEmit src/commands/feature.ts</verify>
115
248
  - [ ] Create API route in `/src/app/api/`
249
+ <verify>npx tsc --noEmit src/app/api/feature/route.ts</verify>
116
250
  - [ ] Add database operations if needed
117
251
 
118
252
  **Build Verification**: Run `npm run build`
@@ -125,8 +259,10 @@ Use this template when creating new implementation plans:
125
259
 
126
260
  **Scope**: Implement Zustand stores for state management.
127
261
  **Complexity**: 5/10
262
+ **Dependencies**: Phase 1
128
263
 
129
264
  - [ ] Create or extend store in `/src/stores/`
265
+ <verify>npx tsc --noEmit src/stores/featureStore.ts</verify>
130
266
  - [ ] Add actions and selectors
131
267
 
132
268
  **Build Verification**: Run `npm run build`
@@ -139,9 +275,12 @@ Use this template when creating new implementation plans:
139
275
 
140
276
  **Scope**: Build the user interface components.
141
277
  **Complexity**: 6/10
278
+ **Dependencies**: Phase 3
142
279
 
143
280
  - [ ] Create logic hook (`useFeatureLogic.internal.ts`)
281
+ <verify>npx tsc --noEmit src/components/feature/useFeatureLogic.internal.ts</verify>
144
282
  - [ ] Create view component (`index.tsx`)
283
+ <verify>npx tsc --noEmit src/components/feature/index.tsx</verify>
145
284
  - [ ] Follow view/logic separation pattern
146
285
 
147
286
  **Build Verification**: Run `npm run build`
@@ -154,6 +293,7 @@ Use this template when creating new implementation plans:
154
293
 
155
294
  **Scope**: Connect all pieces and verify functionality.
156
295
  **Complexity**: 4/10
296
+ **Dependencies**: Phase 2, Phase 4
157
297
 
158
298
  - [ ] Integrate components with pages
159
299
  - [ ] Connect to API endpoints
@@ -169,11 +309,16 @@ Use this template when creating new implementation plans:
169
309
 
170
310
  **Scope**: Write comprehensive tests for all new code.
171
311
  **Complexity**: 5/10
312
+ **Dependencies**: Phase 1, Phase 2, Phase 3, Phase 4, Phase 5
172
313
 
173
314
  - [ ] Unit tests for logic hooks (`*.client.test.ts`)
315
+ <verify>npx jest src/components/feature/__tests__/useFeatureLogic.test.ts --no-coverage</verify>
174
316
  - [ ] Unit tests for utility functions
317
+ <verify>npx jest src/utils/__tests__/feature.test.ts --no-coverage</verify>
175
318
  - [ ] Integration tests for API routes
319
+ <verify>npx jest src/app/api/feature/__tests__/route.test.ts --no-coverage</verify>
176
320
  - [ ] Command tests
321
+ <verify>npx jest src/commands/__tests__/feature.test.ts --no-coverage</verify>
177
322
 
178
323
  **Build Verification**: Run `npm run build && npm run test`
179
324
  ```
@@ -226,4 +371,11 @@ Based on complexity scores (per `.claude/resources/core/complexity-scoring.md`):
226
371
  - **Phases 3-4**: Can be aggregated (combined complexity: 11, but cautious)
227
372
  - **Phase 5**: Can aggregate with Phase 6 if simple
228
373
  - **Phase 6**: Tests - always execute separately
374
+
375
+ Based on dependency graph (when Dependencies fields are present):
376
+
377
+ - **Wave 1**: Phase 1 (no dependencies)
378
+ - **Wave 2**: Phases 2, 3 (both depend only on Phase 1 — run in parallel)
379
+ - **Wave 3**: Phases 4, 5 (depend on earlier waves)
380
+ - **Wave 4**: Phase 6 (Tests — always sequential, always last)
229
381
  ```
@@ -14,6 +14,8 @@ Skills implement the workflow logic for commands. Each skill orchestrates a spec
14
14
  >
15
15
  > **Note**: The execute-plan skill supports **Model Routing** — automatic model selection per phase based on complexity scores (0-3 → haiku, 4-5 → sonnet, 6-10 → opus). Controlled by `model_routing` in `flow/.flowconfig`. See `.claude/resources/core/model-routing.md` for full rules.
16
16
  >
17
+ > **Note**: The execute-plan skill supports **Wave-Based Parallel Execution** — dependency-aware grouping of independent phases into parallel waves. When `wave_execution: true` in `.flowconfig` (default), phases with explicit `Dependencies` metadata are analyzed, grouped into waves via topological sort, and executed in parallel within each wave. See `.claude/resources/core/wave-execution.md` for full rules.
18
+ >
17
19
  > **Note**: The discovery skill also includes **Design Awareness**. During discovery, the LLM asks whether the feature involves UI work and captures structured design tokens (colors, typography, spacing) into a `## Design Context` section. During execution, these tokens are auto-injected into UI phase prompts. See `.claude/resources/core/design-awareness.md` for full rules.
18
20
  >
19
21
  > **Note**: The review-code and review-pr skills include a **Verification Pass**. After initial analysis, each finding is re-examined against surrounding code context and classified as Confirmed, Likely, or Dismissed. False positives are filtered before output. See `.claude/resources/core/review-verification.md` for full rules.
@@ -100,9 +102,9 @@ Skills implement the workflow logic for commands. Each skill orchestrates a spec
100
102
  | SKL-EXEC-1 | Purpose and inputs | execute-plan-skill.md | 4-100 |
101
103
  | SKL-EXEC-2 | Critical rules (build only at end, no DB commands) | execute-plan-skill.md | 18-92 |
102
104
  | SKL-EXEC-3 | Step 1: Parse the plan | execute-plan-skill.md | 103-112 |
103
- | SKL-EXEC-4 | Step 2: Analyze complexity and determine execution strategy | execute-plan-skill.md | 113-151 |
104
- | SKL-EXEC-5 | Step 3: Present execution plan summary | execute-plan-skill.md | 152-180 |
105
- | SKL-EXEC-6 | Step 4: Execute each phase with Plan mode | execute-plan-skill.md | 181-236 |
105
+ | SKL-EXEC-4 | Step 2: Analyze complexity + Step 2b: Wave analysis (dependency graph, wave grouping) | execute-plan-skill.md | 113-151 |
106
+ | SKL-EXEC-5 | Step 3: Present execution plan summary (with wave groupings and estimated speedup) | execute-plan-skill.md | 152-180 |
107
+ | SKL-EXEC-6 | Step 4: Execute each wave (approve sequentially, spawn parallel sub-agents per wave) | execute-plan-skill.md | 181-236 |
106
108
  | SKL-EXEC-7 | Step 5: Update progress after each phase | execute-plan-skill.md | 237-249 |
107
109
  | SKL-EXEC-8 | Step 5b: Phase-boundary context check (compaction) | execute-plan-skill.md | 250-275 |
108
110
  | SKL-EXEC-9 | Step 6: Handle tests phase | execute-plan-skill.md | 277-302 |
@@ -189,9 +191,9 @@ Skills implement the workflow logic for commands. Each skill orchestrates a spec
189
191
  |------|-------------|
190
192
  | SKL-EXEC-2 | Need critical rules (build timing, DB commands) |
191
193
  | SKL-EXEC-3 | Parsing plan file structure |
192
- | SKL-EXEC-4 | Analyzing complexity and determining execution strategy |
193
- | SKL-EXEC-5 | Presenting execution plan summary to user |
194
- | SKL-EXEC-6 | Executing a phase with Plan mode |
194
+ | SKL-EXEC-4 | Analyzing complexity, wave analysis, or determining execution strategy |
195
+ | SKL-EXEC-5 | Presenting execution plan summary (with wave groupings) to user |
196
+ | SKL-EXEC-6 | Executing a wave (parallel sub-agents) or single phase with Plan mode |
195
197
  | SKL-EXEC-7 | Updating progress after a phase |
196
198
  | SKL-EXEC-8 | Compacting at phase boundaries |
197
199
  | SKL-EXEC-9 | Handling the tests phase |