planflow-ai 1.3.5 → 1.4.3

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 (123) hide show
  1. package/.claude/commands/brainstorm.md +6 -14
  2. package/.claude/commands/create-contract.md +6 -38
  3. package/.claude/commands/create-plan.md +18 -38
  4. package/.claude/commands/discovery-plan.md +19 -49
  5. package/.claude/commands/execute-plan.md +116 -77
  6. package/.claude/commands/flow.md +27 -2
  7. package/.claude/commands/heartbeat.md +12 -14
  8. package/.claude/commands/learn.md +20 -80
  9. package/.claude/commands/note.md +6 -23
  10. package/.claude/commands/resume-work.md +261 -0
  11. package/.claude/commands/review-code.md +19 -51
  12. package/.claude/commands/review-pr.md +21 -57
  13. package/.claude/commands/setup.md +8 -56
  14. package/.claude/commands/write-tests.md +7 -41
  15. package/.claude/resources/core/atomic-commits.md +380 -0
  16. package/.claude/resources/core/autopilot-mode.md +3 -2
  17. package/.claude/resources/core/compaction-guide.md +15 -1
  18. package/.claude/resources/core/heartbeat.md +129 -1
  19. package/.claude/resources/core/per-task-verification.md +362 -0
  20. package/.claude/resources/core/phase-isolation.md +237 -4
  21. package/.claude/resources/core/session-scratchpad.md +1 -0
  22. package/.claude/resources/core/shared-context.md +110 -0
  23. package/.claude/resources/core/wave-execution.md +407 -0
  24. package/.claude/resources/patterns/plans-patterns.md +56 -0
  25. package/.claude/resources/patterns/plans-templates.md +152 -0
  26. package/.claude/resources/skills/create-plan-skill.md +71 -5
  27. package/.claude/resources/skills/execute-plan-skill.md +420 -14
  28. package/.claude/resources/skills/resume-work-skill.md +159 -0
  29. package/README.md +154 -96
  30. package/dist/cli/commands/brain.d.ts +20 -0
  31. package/dist/cli/commands/brain.d.ts.map +1 -0
  32. package/dist/cli/commands/brain.js +127 -0
  33. package/dist/cli/commands/brain.js.map +1 -0
  34. package/dist/cli/commands/init.d.ts.map +1 -1
  35. package/dist/cli/commands/init.js +10 -1
  36. package/dist/cli/commands/init.js.map +1 -1
  37. package/dist/cli/commands/state-query.d.ts +13 -0
  38. package/dist/cli/commands/state-query.d.ts.map +1 -0
  39. package/dist/cli/commands/state-query.js +32 -0
  40. package/dist/cli/commands/state-query.js.map +1 -0
  41. package/dist/cli/commands/state.d.ts +12 -0
  42. package/dist/cli/commands/state.d.ts.map +1 -0
  43. package/dist/cli/commands/state.js +47 -0
  44. package/dist/cli/commands/state.js.map +1 -0
  45. package/dist/cli/daemon/desktop-notifier.d.ts +16 -0
  46. package/dist/cli/daemon/desktop-notifier.d.ts.map +1 -0
  47. package/dist/cli/daemon/desktop-notifier.js +53 -0
  48. package/dist/cli/daemon/desktop-notifier.js.map +1 -0
  49. package/dist/cli/daemon/event-writer.d.ts +22 -0
  50. package/dist/cli/daemon/event-writer.d.ts.map +1 -0
  51. package/dist/cli/daemon/event-writer.js +76 -0
  52. package/dist/cli/daemon/event-writer.js.map +1 -0
  53. package/dist/cli/daemon/heartbeat-daemon.js +81 -1
  54. package/dist/cli/daemon/heartbeat-daemon.js.map +1 -1
  55. package/dist/cli/daemon/log-writer.d.ts +17 -0
  56. package/dist/cli/daemon/log-writer.d.ts.map +1 -0
  57. package/dist/cli/daemon/log-writer.js +62 -0
  58. package/dist/cli/daemon/log-writer.js.map +1 -0
  59. package/dist/cli/daemon/notification-router.d.ts +17 -0
  60. package/dist/cli/daemon/notification-router.d.ts.map +1 -0
  61. package/dist/cli/daemon/notification-router.js +35 -0
  62. package/dist/cli/daemon/notification-router.js.map +1 -0
  63. package/dist/cli/daemon/prompt-manager.d.ts +27 -0
  64. package/dist/cli/daemon/prompt-manager.d.ts.map +1 -0
  65. package/dist/cli/daemon/prompt-manager.js +107 -0
  66. package/dist/cli/daemon/prompt-manager.js.map +1 -0
  67. package/dist/cli/daemon/shared-context.d.ts +38 -0
  68. package/dist/cli/daemon/shared-context.d.ts.map +1 -0
  69. package/dist/cli/daemon/shared-context.js +129 -0
  70. package/dist/cli/daemon/shared-context.js.map +1 -0
  71. package/dist/cli/handlers/claude.d.ts.map +1 -1
  72. package/dist/cli/handlers/claude.js +18 -0
  73. package/dist/cli/handlers/claude.js.map +1 -1
  74. package/dist/cli/handlers/shared.js +1 -1
  75. package/dist/cli/handlers/shared.js.map +1 -1
  76. package/dist/cli/index.js +30 -0
  77. package/dist/cli/index.js.map +1 -1
  78. package/dist/cli/state/brain-query.d.ts +48 -0
  79. package/dist/cli/state/brain-query.d.ts.map +1 -0
  80. package/dist/cli/state/brain-query.js +113 -0
  81. package/dist/cli/state/brain-query.js.map +1 -0
  82. package/dist/cli/state/flowconfig-parser.d.ts +16 -0
  83. package/dist/cli/state/flowconfig-parser.d.ts.map +1 -0
  84. package/dist/cli/state/flowconfig-parser.js +166 -0
  85. package/dist/cli/state/flowconfig-parser.js.map +1 -0
  86. package/dist/cli/state/heartbeat-state.d.ts +16 -0
  87. package/dist/cli/state/heartbeat-state.d.ts.map +1 -0
  88. package/dist/cli/state/heartbeat-state.js +97 -0
  89. package/dist/cli/state/heartbeat-state.js.map +1 -0
  90. package/dist/cli/state/model-router.d.ts +8 -0
  91. package/dist/cli/state/model-router.d.ts.map +1 -0
  92. package/dist/cli/state/model-router.js +36 -0
  93. package/dist/cli/state/model-router.js.map +1 -0
  94. package/dist/cli/state/plan-parser.d.ts +16 -0
  95. package/dist/cli/state/plan-parser.d.ts.map +1 -0
  96. package/dist/cli/state/plan-parser.js +124 -0
  97. package/dist/cli/state/plan-parser.js.map +1 -0
  98. package/dist/cli/state/session-state.d.ts +21 -0
  99. package/dist/cli/state/session-state.d.ts.map +1 -0
  100. package/dist/cli/state/session-state.js +36 -0
  101. package/dist/cli/state/session-state.js.map +1 -0
  102. package/dist/cli/state/state-md-parser.d.ts +18 -0
  103. package/dist/cli/state/state-md-parser.d.ts.map +1 -0
  104. package/dist/cli/state/state-md-parser.js +222 -0
  105. package/dist/cli/state/state-md-parser.js.map +1 -0
  106. package/dist/cli/state/types.d.ts +137 -0
  107. package/dist/cli/state/types.d.ts.map +1 -0
  108. package/dist/cli/state/types.js +8 -0
  109. package/dist/cli/state/types.js.map +1 -0
  110. package/dist/cli/state/wave-calculator.d.ts +18 -0
  111. package/dist/cli/state/wave-calculator.d.ts.map +1 -0
  112. package/dist/cli/state/wave-calculator.js +134 -0
  113. package/dist/cli/state/wave-calculator.js.map +1 -0
  114. package/dist/cli/types.d.ts +15 -0
  115. package/dist/cli/types.d.ts.map +1 -1
  116. package/package.json +7 -2
  117. package/templates/shared/CLAUDE.md.template +4 -0
  118. package/.claude/resources/core/_index.md +0 -304
  119. package/.claude/resources/languages/_index.md +0 -76
  120. package/.claude/resources/patterns/_index.md +0 -200
  121. package/.claude/resources/skills/_index.md +0 -285
  122. package/.claude/resources/tools/_index.md +0 -110
  123. package/.claude/resources/tools/reference-expansion-tool.md +0 -326
@@ -648,59 +648,15 @@ flow/
648
648
  - Component structure
649
649
  - Error handling approach
650
650
 
651
- ---
651
+ ## Context Loading
652
+
653
+ This command uses the **brain index** for context retrieval. Before executing, query the project brain for relevant documentation:
654
+
655
+ **Queries**:
656
+ - `planflow-ai state-query "project setup" --scope resources`
657
+ - `planflow-ai state-query "pattern generation" --scope resources`
652
658
 
653
- ## Context Optimization
654
-
655
- This command uses hierarchical context loading to reduce context consumption. Instead of loading full files, load indexes first and expand specific sections on-demand.
656
-
657
- ### Recommended Loading Order
658
-
659
- 1. **Always load first**: This command file (`commands/setup.md`)
660
- 2. **Load indexes**: Load `_index.md` files for relevant folders
661
- 3. **Expand on-demand**: Use reference codes to load specific sections when needed
662
-
663
- ### Index Files for Setup
664
-
665
- | Index | When to Load |
666
- |-------|--------------|
667
- | `resources/skills/_index.md` | To understand setup workflow |
668
- | `resources/tools/_index.md` | For interactive questions tool |
669
- | `resources/core/_index.md` | For pattern references |
670
- | `resources/languages/_index.md` | For language-specific patterns |
671
-
672
- ### Reference Codes for Setup
673
-
674
- | Code | Description | When to Expand |
675
- |------|-------------|----------------|
676
- | SKL-SETUP-1 | Purpose and critical approach | Understanding setup goals |
677
- | SKL-SETUP-2 | Scan project structure | Scanning files and directories |
678
- | SKL-SETUP-3 | Deep dependency analysis | Analyzing package dependencies |
679
- | SKL-SETUP-4 | Deep code analysis | Sampling files and extracting patterns |
680
- | SKL-SETUP-7 | Ask confirming questions | Presenting questions via Plan mode |
681
- | SKL-SETUP-8 | Generate pattern files | Creating framework/library pattern files |
682
- | SKL-SETUP-9 | Update core pattern files | Updating allowed/forbidden patterns |
683
- | SKL-SETUP-11 | Create analysis document | Generating project analysis doc |
684
- | SKL-SETUP-12 | Index documentation | Indexing project docs with reference codes |
685
- | SKL-SETUP-13 | Create flow folder | Setting up flow/ directory structure |
686
- | SKL-SETUP-14 | Present summary | Final setup summary output |
687
- | TLS-IQ-1 | Interactive questions overview | Before asking questions |
688
- | TLS-IQ-2 | Switch to Plan mode | Starting question session |
689
- | TLS-IQ-3 | Ask questions format | Asking confirmation questions |
690
- | COR-AP-1 | Allowed patterns structure | Updating allowed patterns |
691
- | COR-FP-1 | Forbidden patterns structure | Updating forbidden patterns |
692
- | LNG-TS-1 | TypeScript patterns | If TS project detected |
693
- | LNG-PY-1 | Python patterns | If Python project detected |
694
-
695
- ### Expansion Instructions
696
-
697
- When executing this command:
698
-
699
- 1. **Start with indexes**: Read `resources/skills/_index.md` and `resources/tools/_index.md`
700
- 2. **Expand for detection phase**: Load minimal context during code analysis
701
- 3. **Expand for questions**: Load TLS-IQ-* before asking confirmation questions
702
- 4. **Expand for generation**: Load relevant language patterns when generating files
703
- 5. **Don't expand everything**: Only load patterns relevant to detected stack
659
+ The brain returns ranked chunks from indexed markdown files. Use the top results to inform execution.
704
660
 
705
661
  ---
706
662
 
@@ -708,10 +664,6 @@ When executing this command:
708
664
 
709
665
  | Resource | Purpose |
710
666
  | ------------------------------ | -------------------------------------- |
711
- | `resources/skills/_index.md` | Index of skills with reference codes |
712
- | `resources/tools/_index.md` | Index of tools with reference codes |
713
- | `resources/core/_index.md` | Index of core rules with reference codes |
714
- | `resources/languages/_index.md` | Index of language patterns with reference codes |
715
667
  | `setup-skill.md` | Detailed execution logic |
716
668
  | `interactive-questions-tool.md` | Questions UI for confirmations |
717
669
  | `allowed-patterns.md` | Core allowed patterns |
@@ -199,47 +199,16 @@ All metrics (Lines, Branches, Functions, Statements) meet the target.
199
199
  3. Invoke write-tests skill
200
200
  4. Present final coverage summary
201
201
 
202
- ---
203
-
204
- ## Context Optimization
205
-
206
- This command uses hierarchical context loading to reduce context consumption. Instead of loading full files, load indexes first and expand specific sections on-demand.
207
-
208
- ### Recommended Loading Order
209
-
210
- 1. **Always load first**: This command file (`commands/write-tests.md`)
211
- 2. **Load indexes**: Load `_index.md` files for relevant folders
212
- 3. **Expand on-demand**: Use reference codes to load specific sections when needed
213
-
214
- ### Index Files for Writing Tests
215
-
216
- | Index | When to Load |
217
- |-------|--------------|
218
- | `resources/skills/_index.md` | To understand test writing workflow |
219
- | `resources/patterns/_index.md` | For testing patterns |
220
- | `resources/tools/_index.md` | For testing tool commands |
221
-
222
- ### Reference Codes for Writing Tests
223
-
224
- | Code | Description | When to Expand |
225
- |------|-------------|----------------|
226
- | SKL-TEST-1 | Write tests skill workflow | Understanding full process |
227
- | PTN-JEST-1 | Jest test structure | Writing Jest tests |
228
- | PTN-JEST-2 | Jest mocking patterns | When mocking is needed |
229
- | PTN-PYTEST-1 | Pytest test structure | Writing Pytest tests |
230
- | PTN-PYTEST-2 | Pytest fixtures | When fixtures are needed |
231
- | TLS-JEST-1 | Jest commands | Running Jest tests |
232
- | TLS-PYTEST-1 | Pytest commands | Running Pytest tests |
202
+ ## Context Loading
233
203
 
234
- ### Expansion Instructions
204
+ This command uses the **brain index** for context retrieval. Before executing, query the project brain for relevant documentation:
235
205
 
236
- When executing this command:
206
+ **Queries**:
207
+ - `planflow-ai state-query "test writing" --scope resources`
208
+ - `planflow-ai state-query "jest patterns" --scope resources`
209
+ - `planflow-ai state-query "pytest patterns" --scope resources`
237
210
 
238
- 1. **Start with indexes**: Read `resources/skills/_index.md` and `resources/patterns/_index.md`
239
- 2. **Detect framework first**: Determine Jest or Pytest before expanding patterns
240
- 3. **Expand framework-specific**: Only load PTN-JEST-* or PTN-PYTEST-*, not both
241
- 4. **Expand tool commands**: Load TLS-JEST-* or TLS-PYTEST-* for running tests
242
- 5. **Don't expand everything**: Only load patterns relevant to detected framework
211
+ The brain returns ranked chunks from indexed markdown files. Use the top results to inform execution.
243
212
 
244
213
  ---
245
214
 
@@ -247,9 +216,6 @@ When executing this command:
247
216
 
248
217
  | Resource | Purpose |
249
218
  | ------------------------- | ------------------------------- |
250
- | `resources/skills/_index.md` | Index of skills with reference codes |
251
- | `resources/patterns/_index.md` | Index of patterns with reference codes |
252
- | `resources/tools/_index.md` | Index of tools with reference codes |
253
219
  | `write-tests-skill.md` | Skill that writes the tests |
254
220
  | `jest-patterns.md` | Jest testing patterns |
255
221
  | `pytest-patterns.md` | Pytest testing patterns |
@@ -0,0 +1,380 @@
1
+
2
+ # Atomic Commits Per Task
3
+
4
+ ## Purpose
5
+
6
+ When `commit: true` in `flow/.flowconfig`, `/execute-plan` creates a **git commit after each individual task** completes (and passes verification, if applicable), rather than one commit per phase. This enables `git bisect` to pinpoint task-level regressions, independent reverts of specific task changes, and clearer git history.
7
+
8
+ **Core principle**: Fine-grained commit history, tied to task completion.
9
+
10
+ ---
11
+
12
+ ## Commit Format
13
+
14
+ All per-task commits follow a consistent format:
15
+
16
+ ```
17
+ feat(phase-N.task-M): <description truncated to 50 chars> — <feature>
18
+ ```
19
+
20
+ ### Format Breakdown
21
+
22
+ | Part | Example | Description |
23
+ |------|---------|-------------|
24
+ | **Type** | `feat` | Always `feat` for feature implementation (per plan-flow convention) |
25
+ | **Scope** | `phase-1.task-2` | Phase number (N) and task number (M, 1-indexed within phase) |
26
+ | **Description** | `Create user auth middleware` | Short description of what the task did, truncated to 50 characters |
27
+ | **Feature** | `— user-auth-system` | Feature name from the plan, separated by ` — ` |
28
+
29
+ ### Example Commits
30
+
31
+ ```
32
+ feat(phase-1.task-1): Define user and session types — user-auth-system
33
+ feat(phase-1.task-2): Create user schema with Prisma — user-auth-system
34
+ feat(phase-2.task-1): Implement authentication middleware — user-auth-system
35
+ feat(phase-2.task-2): Add rate limiting to API routes — user-auth-system
36
+ feat(phase-3.task-1): Update API documentation — user-auth-system
37
+ ```
38
+
39
+ ### Description Truncation
40
+
41
+ - Truncate task descriptions to **50 characters maximum**
42
+ - Preserve the most meaningful part of the task name
43
+ - Use ellipsis (`...`) if truncation occurs: `Create user authentication middle...`
44
+ - This keeps commit messages concise and readable in `git log`
45
+
46
+ ---
47
+
48
+ ## Sequential Mode Behavior
49
+
50
+ In **sequential mode** (default, `wave_execution: false`), each phase runs in an **isolated Agent sub-agent**:
51
+
52
+ ```
53
+ Coordinator (main session)
54
+
55
+ ├─ Spawn Phase sub-agent
56
+ │ │
57
+ │ ├─ Task 1: Implement → ✅ Pass verification → Commit immediately
58
+ │ ├─ Task 2: Implement → ✅ Pass verification → Commit immediately
59
+ │ └─ Task 3: Implement → ✅ Pass verification → Commit immediately
60
+
61
+ ├─ Receive JSON return with tasks_completed array
62
+
63
+ ├─ Process summary:
64
+ │ └─ Sub-agent commits are already in git
65
+ │ (files are in working dir from sub-agent context)
66
+
67
+ └─ Next phase...
68
+ ```
69
+
70
+ ### Sub-Agent Commit Behavior
71
+
72
+ In sequential mode, the **phase sub-agent commits directly** after each task:
73
+
74
+ 1. Complete task implementation in isolation
75
+ 2. Run verification (if `<verify>` tag present)
76
+ 3. If verification passes: run `git add -A && git commit -m "feat(phase-N.task-M): ..."`
77
+ 4. Proceed to next task
78
+ 5. Return JSON summary with `tasks_completed` array
79
+
80
+ The coordinator receives the JSON return and knows which tasks were completed by checking `tasks_completed`. File conflicts do not occur in sequential mode because only one sub-agent runs at a time.
81
+
82
+ **Context template extension**: Add to phase sub-agent context:
83
+
84
+ ```markdown
85
+ ## Commit Instructions
86
+ - After each task completes and verification passes (if applicable):
87
+ 1. Stage changed files: `git add -A`
88
+ 2. Create atomic commit: `git commit -m "feat(phase-N.task-M): <truncated description> — <feature>"`
89
+ - Use format: feat(phase-{phase_number}.task-{task_number_in_phase}): <description> — <feature>
90
+ - Truncate description to 50 chars
91
+ - Task numbers are 1-indexed within each phase
92
+ 3. Continue to next task
93
+ - Return `tasks_completed` array in JSON with files_created/files_modified per task
94
+ - Do NOT create a final phase commit (coordinator will not create one either)
95
+ ```
96
+
97
+ ---
98
+
99
+ ## Wave Mode Behavior
100
+
101
+ In **wave mode** (`wave_execution: true`), multiple sub-agents run in **parallel per wave**, and the **coordinator commits after the wave completes**:
102
+
103
+ ```
104
+ Coordinator (main session)
105
+
106
+ ├─ For each Wave:
107
+ │ │
108
+ │ ├─ Spawn MULTIPLE Phase sub-agents IN PARALLEL:
109
+ │ │ ├─► Phase A sub-agent (runs tasks, NO commits)
110
+ │ │ └─► Phase B sub-agent (runs tasks, NO commits)
111
+ │ │
112
+ │ ├─ Wait for all to complete
113
+ │ │
114
+ │ ├─ Collect JSON returns with tasks_completed arrays
115
+ │ │
116
+ │ ├─ Post-wave processing (sequential, in phase order):
117
+ │ │ │
118
+ │ │ ├─ Detect file conflicts
119
+ │ │ │
120
+ │ │ ├─ For each phase (A, then B):
121
+ │ │ │ └─ For each task in phase (1, 2, 3, ...):
122
+ │ │ │ └─ Commit: git add -A && git commit -m "feat(phase-N.task-M): ..."
123
+ │ │ │
124
+ │ │ └─ Commit all tasks from Phase A, then all from Phase B
125
+ │ │
126
+ │ └─ Next Wave...
127
+
128
+ └─ Completion summary
129
+ ```
130
+
131
+ ### Sub-Agent Behavior in Wave Mode
132
+
133
+ In wave mode, **sub-agents do NOT commit**. They implement all tasks and return a JSON summary:
134
+
135
+ 1. Implement all phase tasks
136
+ 2. Run per-task verification (if applicable)
137
+ 3. **Do NOT commit** — parallel git conflicts would occur
138
+ 4. Return JSON with `tasks_completed` array containing per-task metadata
139
+ 5. Exit
140
+
141
+ The coordinator collects all JSON returns, detects file conflicts, then commits sequentially.
142
+
143
+ **Context template extension**: Add to phase sub-agent context in wave mode:
144
+
145
+ ```markdown
146
+ ## Commit Instructions (Wave Mode)
147
+ - Do NOT create any commits during task implementation
148
+ - The coordinator will commit your changes after this wave completes
149
+ - Return `tasks_completed` array with per-task file lists (see Return Format below)
150
+ - Coordinator will iterate tasks and commit: feat(phase-N.task-M): ... per task
151
+ ```
152
+
153
+ ---
154
+
155
+ ## JSON Return Schema Extension
156
+
157
+ The phase isolation return format is extended with a **`tasks_completed` array** for per-task file tracking:
158
+
159
+ ```json
160
+ {
161
+ "status": "success",
162
+ "phase": "Phase 1: Create Core Resource",
163
+ "summary": "Implemented three core resource files...",
164
+ "files_created": [
165
+ ".claude/resources/core/atomic-commits.md",
166
+ ".claude/resources/core/_index.md"
167
+ ],
168
+ "files_modified": [],
169
+ "decisions": [],
170
+ "deviations": [],
171
+ "errors": [],
172
+ "patterns_captured": [],
173
+ "tasks_completed": [
174
+ {
175
+ "task_number": 1,
176
+ "task_name": "Create atomic-commits.md resource file",
177
+ "files_created": [".claude/resources/core/atomic-commits.md"],
178
+ "files_modified": []
179
+ },
180
+ {
181
+ "task_number": 2,
182
+ "task_name": "Update _index.md with reference entry",
183
+ "files_created": [],
184
+ "files_modified": [".claude/resources/core/_index.md"]
185
+ }
186
+ ]
187
+ }
188
+ ```
189
+
190
+ ### tasks_completed Field
191
+
192
+ | Field | Type | Description |
193
+ |-------|------|-------------|
194
+ | `task_number` | number | 1-indexed task number within the phase |
195
+ | `task_name` | string | Short task description from the plan |
196
+ | `files_created` | string[] | Files created by this task (empty array if none) |
197
+ | `files_modified` | string[] | Files modified by this task (empty array if none) |
198
+
199
+ ### When to Include
200
+
201
+ - Always include `tasks_completed` if any tasks ran in the phase
202
+ - Omit `tasks_completed` only if the phase has no tasks (edge case)
203
+ - Include all tasks, even those without `<verify>` tags
204
+ - Order entries by task_number (1, 2, 3, ...)
205
+
206
+ ---
207
+
208
+ ## Coordinator Processing: Sequential Mode
209
+
210
+ After receiving the sub-agent JSON return in sequential mode:
211
+
212
+ 1. **Validate return**: Check `status` field
213
+ 2. **Verify commits exist**: The sub-agent has already created per-task commits
214
+ 3. **Update plan file**: Mark phase tasks as `[x]`
215
+ 4. **Accumulate file list**: Merge `files_created` and `files_modified` into running list
216
+ 5. **Buffer patterns**: Append `patterns_captured` entries
217
+ 6. **Display summary**: Show tasks completed with verification results
218
+ 7. **Do NOT create phase commit**: Sub-agent already created per-task commits
219
+ 8. **Proceed**: Move to next phase
220
+
221
+ ---
222
+
223
+ ## Coordinator Processing: Wave Mode
224
+
225
+ After collecting all sub-agent JSON returns from a wave:
226
+
227
+ 1. **Validate all returns**: Check `status` field for each
228
+ 2. **Detect file conflicts**: Check `files_modified` overlap between phases (same as existing wave behavior)
229
+ 3. **For each phase** (in phase number order):
230
+ - **For each task** (in task_number order):
231
+ - Extract `task_name`, `files_created`, `files_modified` from `tasks_completed[i]`
232
+ - **Stage files**: `git add -A` (stages all task changes in working directory)
233
+ - **Create commit**: `git commit -m "feat(phase-N.task-M): <truncated task_name> — <feature>"`
234
+ - Truncate `task_name` to 50 chars if needed
235
+ - Use task_number from JSON (not computed)
236
+ - Use feature name from plan
237
+ - **Update plan file**: Mark phase tasks as `[x]` (after all phase tasks are committed)
238
+ - **Accumulate file list**: Merge task file lists into running list
239
+ 4. **Buffer patterns**: Collect `patterns_captured` from all phases
240
+ 5. **Display summary**: Show all phases and tasks completed, including verification results
241
+ 6. **Do NOT create wave commit**: Per-task commits already created
242
+ 7. **Proceed**: Next wave
243
+
244
+ ### Deterministic Commit Ordering
245
+
246
+ Commits are created in **strict phase order, then task order**:
247
+
248
+ ```
249
+ Wave 1 complete:
250
+ Phase A, Task 1 → commit
251
+ Phase A, Task 2 → commit
252
+ Phase A, Task 3 → commit
253
+ Phase B, Task 1 → commit
254
+ Phase B, Task 2 → commit
255
+ ```
256
+
257
+ This ensures **deterministic git history** regardless of which sub-agent finished first.
258
+
259
+ ---
260
+
261
+ ## Interaction with Per-Task Verification
262
+
263
+ Verification runs **before** the task's commit:
264
+
265
+ ```
266
+ Phase sub-agent:
267
+ Task 1: Implement
268
+ ├─ Implementation complete
269
+ ├─ Run verification (if <verify> tag present)
270
+ ├─ If fail: debug sub-agent → repair loop → re-verify
271
+ ├─ If pass or fail (max retries): commit this task
272
+ └─ Continue to Task 2
273
+ ```
274
+
275
+ **Rule**: A task commits even if verification failed (after max retries). The coordinator and user see the failure in `task_verifications[i].status == "fail"`.
276
+
277
+ ---
278
+
279
+ ## Interaction with Phase Isolation
280
+
281
+ Atomic commits per task is **independent of phase isolation**:
282
+
283
+ | phase_isolation | Behavior |
284
+ |---|---|
285
+ | `true` (default) | Sub-agent isolated with clean context; per-task commits work normally |
286
+ | `false` (legacy) | Phases execute inline in main session; per-task commits still work but less clean context isolation |
287
+
288
+ Per-task commits work the same way in both modes — the difference is context isolation, not commit behavior.
289
+
290
+ ---
291
+
292
+ ## Interaction with Wave Execution
293
+
294
+ Atomic commits per task **requires wave execution to work correctly**:
295
+
296
+ | wave_execution | Behavior |
297
+ |---|---|
298
+ | `true` (default) | Coordinator commits per-task after wave completes (no parallel git conflicts) |
299
+ | `false` (sequential) | Sub-agent commits per-task directly (no coordinator involvement) |
300
+
301
+ Per-task commits are the **only reason wave mode does NOT commit** in the sub-agent. Without per-task commits, we might revert to per-phase commits from the coordinator.
302
+
303
+ ---
304
+
305
+ ## Aggregated Phases
306
+
307
+ When phases are aggregated (combined complexity ≤ 6), they run as **one sub-agent call** with all tasks from all aggregated phases. Commit format still uses **relative phase numbering**:
308
+
309
+ ```
310
+ Phase 1 (aggregated with Phase 2):
311
+ Aggregated Phase tasks:
312
+ feat(phase-1.task-1): ...
313
+ feat(phase-1.task-2): ...
314
+ feat(phase-2.task-1): ...
315
+ feat(phase-2.task-2): ...
316
+ ```
317
+
318
+ **Rule**: Use the **actual phase number** from the plan, not a computed aggregate phase number.
319
+
320
+ ---
321
+
322
+ ## Configuration
323
+
324
+ ### `.flowconfig` Setting
325
+
326
+ Per-task commits are **not a separate feature flag**. They are **controlled by the existing `commit` setting**:
327
+
328
+ ```yaml
329
+ commit: true # Enable per-task commits (default: true)
330
+ ```
331
+
332
+ - `true`: Create atomic per-task commits (this feature)
333
+ - `false`: No commits during execution (existing behavior)
334
+
335
+ No new `.flowconfig` setting is needed — `commit: true` automatically upgrades from per-phase to per-task commits.
336
+
337
+ ### Toggle via `/flow`
338
+
339
+ ```
340
+ /flow commit=true
341
+ /flow commit=false
342
+ ```
343
+
344
+ ---
345
+
346
+ ## Error Handling
347
+
348
+ | Scenario | Behavior |
349
+ |---|---|
350
+ | Task implementation fails | Task does NOT commit; coordinator reports failure in `errors` array |
351
+ | Verification fails (max retries) | Task commits anyway; coordinator shows failure in `task_verifications[i].status == "fail"` |
352
+ | Git commit command fails | Coordinator reports error and asks user whether to retry, skip, or stop |
353
+ | File conflict in wave mode | Same as existing wave conflict handling — present to user with options |
354
+
355
+ ---
356
+
357
+ ## Rules
358
+
359
+ 1. **Format is strict**: `feat(phase-N.task-M): <50 chars max> — <feature>`
360
+ 2. **Sequential mode**: Sub-agents commit; coordinator validates
361
+ 3. **Wave mode**: Sub-agents do NOT commit; coordinator commits in phase/task order
362
+ 4. **No final phase commit**: Replaced by per-task commits
363
+ 5. **Backward compatible**: When `commit: false`, no commits (existing behavior)
364
+ 6. **Verification before commit**: Tasks commit after passing verification
365
+ 7. **Failure still commits**: Failed verification after max retries still commits the task
366
+ 8. **Deterministic order**: Wave mode commits always in phase order, task order
367
+ 9. **Truncate descriptions**: 50 character max for readability
368
+ 10. **Task numbers reset per phase**: Phase 1 Task 1, Phase 2 Task 1 (not global numbering)
369
+
370
+ ---
371
+
372
+ ## Related Files
373
+
374
+ | File | Purpose |
375
+ |---|---|
376
+ | `.claude/resources/core/phase-isolation.md` | Sub-agent context template, JSON return format (extended by this feature) |
377
+ | `.claude/resources/core/wave-execution.md` | Wave coordinator behavior (changed to commit per-task after waves) |
378
+ | `.claude/resources/core/per-task-verification.md` | Per-task verification (runs before task's commit) |
379
+ | `.claude/resources/skills/execute-plan-skill.md` | Execute-plan skill (updated for per-task commit format) |
380
+ | `.claude/commands/execute-plan.md` | Execute-plan command docs (updated for per-task format) |
@@ -97,8 +97,9 @@ Check `flow/contracts/` for any relevant integration contracts. If found, note t
97
97
  5. If `commit: true`: auto-commit after each completed phase
98
98
  6. Run build + test verification at the end
99
99
  7. If `push: true` and build+test pass: auto-push
100
- 8. Write transition summary
101
- 9. **Auto-proceed** to Step 5
100
+ 8. If `pr: true` and push succeeds: create feature branch `feat/<feature>`, open PR via `gh pr create`, capture PR URL
101
+ 9. Write transition summary
102
+ 10. **Auto-proceed** to Step 5
102
103
 
103
104
  ### Step 5: Review Code
104
105
 
@@ -103,9 +103,23 @@ Open questions: retry policy, refund flow. Resume with remaining questions.
103
103
 
104
104
  ---
105
105
 
106
+ ## STATE.md Integration
107
+
108
+ Before compaction, write current execution state to `flow/STATE.md` using the standard state format (skill, phase, status, decisions, errors). This ensures that even if the compaction summary loses detail, the full execution position is recoverable from the file.
109
+
110
+ After compaction, re-read `flow/STATE.md` to restore execution context. This supplements the compaction summary with structured state that the summary format may not fully capture (phase numbers, file lists, decision references).
111
+
112
+ **Workflow**:
113
+ 1. Before `/compact`: Update `flow/STATE.md` with current state (or create it if it doesn't exist)
114
+ 2. Run `/compact` with the summary
115
+ 3. After compaction: Re-read `flow/STATE.md` and the active plan file to restore full context
116
+
117
+ ---
118
+
106
119
  ## Rules
107
120
 
108
121
  1. **Never compact mid-phase** — only at phase boundaries
109
122
  2. **Always include enough context to resume** — the model after compaction should know exactly what to do next
110
123
  3. **After compaction, re-read the plan file** — don't rely on memory of plan contents
111
- 4. **Default to preserving** — when in doubt, keep it. It's better to preserve something unnecessary than lose something critical.
124
+ 4. **After compaction, re-read STATE.md** — restore structured execution state that the summary may not fully capture
125
+ 5. **Default to preserving** — when in doubt, keep it. It's better to preserve something unnecessary than lose something critical.