create-merlin-brain 3.11.0 → 3.13.0

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 (147) hide show
  1. package/bin/install.cjs +156 -32
  2. package/bin/runtime-adapters.cjs +396 -0
  3. package/dist/server/api/types.d.ts +7 -0
  4. package/dist/server/api/types.d.ts.map +1 -1
  5. package/dist/server/cost/tracker.d.ts +38 -2
  6. package/dist/server/cost/tracker.d.ts.map +1 -1
  7. package/dist/server/cost/tracker.js +87 -15
  8. package/dist/server/cost/tracker.js.map +1 -1
  9. package/dist/server/server.d.ts.map +1 -1
  10. package/dist/server/server.js +74 -30
  11. package/dist/server/server.js.map +1 -1
  12. package/dist/server/tools/__tests__/augmentation.test.d.ts +8 -0
  13. package/dist/server/tools/__tests__/augmentation.test.d.ts.map +1 -0
  14. package/dist/server/tools/__tests__/augmentation.test.js +76 -0
  15. package/dist/server/tools/__tests__/augmentation.test.js.map +1 -0
  16. package/dist/server/tools/__tests__/route-helpers.test.d.ts +5 -0
  17. package/dist/server/tools/__tests__/route-helpers.test.d.ts.map +1 -0
  18. package/dist/server/tools/__tests__/route-helpers.test.js +49 -0
  19. package/dist/server/tools/__tests__/route-helpers.test.js.map +1 -0
  20. package/dist/server/tools/adaptive.js +1 -1
  21. package/dist/server/tools/adaptive.js.map +1 -1
  22. package/dist/server/tools/agent-spawn.d.ts +25 -0
  23. package/dist/server/tools/agent-spawn.d.ts.map +1 -0
  24. package/dist/server/tools/agent-spawn.js +95 -0
  25. package/dist/server/tools/agent-spawn.js.map +1 -0
  26. package/dist/server/tools/agents-index.js +3 -3
  27. package/dist/server/tools/agents-index.js.map +1 -1
  28. package/dist/server/tools/agents.js +5 -5
  29. package/dist/server/tools/agents.js.map +1 -1
  30. package/dist/server/tools/augmentation.d.ts +45 -0
  31. package/dist/server/tools/augmentation.d.ts.map +1 -0
  32. package/dist/server/tools/augmentation.js +167 -0
  33. package/dist/server/tools/augmentation.js.map +1 -0
  34. package/dist/server/tools/behaviors.js +4 -4
  35. package/dist/server/tools/behaviors.js.map +1 -1
  36. package/dist/server/tools/context.js +7 -7
  37. package/dist/server/tools/context.js.map +1 -1
  38. package/dist/server/tools/cost.d.ts +3 -1
  39. package/dist/server/tools/cost.d.ts.map +1 -1
  40. package/dist/server/tools/cost.js +66 -13
  41. package/dist/server/tools/cost.js.map +1 -1
  42. package/dist/server/tools/discoveries.js +6 -6
  43. package/dist/server/tools/discoveries.js.map +1 -1
  44. package/dist/server/tools/index.d.ts +4 -0
  45. package/dist/server/tools/index.d.ts.map +1 -1
  46. package/dist/server/tools/index.js +4 -0
  47. package/dist/server/tools/index.js.map +1 -1
  48. package/dist/server/tools/learning.d.ts +12 -0
  49. package/dist/server/tools/learning.d.ts.map +1 -0
  50. package/dist/server/tools/learning.js +269 -0
  51. package/dist/server/tools/learning.js.map +1 -0
  52. package/dist/server/tools/project.js +7 -7
  53. package/dist/server/tools/project.js.map +1 -1
  54. package/dist/server/tools/promote.d.ts +11 -0
  55. package/dist/server/tools/promote.d.ts.map +1 -0
  56. package/dist/server/tools/promote.js +315 -0
  57. package/dist/server/tools/promote.js.map +1 -0
  58. package/dist/server/tools/route-helpers.d.ts +45 -0
  59. package/dist/server/tools/route-helpers.d.ts.map +1 -0
  60. package/dist/server/tools/route-helpers.js +93 -0
  61. package/dist/server/tools/route-helpers.js.map +1 -0
  62. package/dist/server/tools/route.d.ts +4 -3
  63. package/dist/server/tools/route.d.ts.map +1 -1
  64. package/dist/server/tools/route.js +80 -284
  65. package/dist/server/tools/route.js.map +1 -1
  66. package/dist/server/tools/session-restore.d.ts +18 -0
  67. package/dist/server/tools/session-restore.d.ts.map +1 -0
  68. package/dist/server/tools/session-restore.js +154 -0
  69. package/dist/server/tools/session-restore.js.map +1 -0
  70. package/dist/server/tools/session-search.d.ts +16 -0
  71. package/dist/server/tools/session-search.d.ts.map +1 -0
  72. package/dist/server/tools/session-search.js +240 -0
  73. package/dist/server/tools/session-search.js.map +1 -0
  74. package/dist/server/tools/sights-index.js +2 -2
  75. package/dist/server/tools/sights-index.js.map +1 -1
  76. package/dist/server/tools/smart-route.d.ts.map +1 -1
  77. package/dist/server/tools/smart-route.js +4 -5
  78. package/dist/server/tools/smart-route.js.map +1 -1
  79. package/dist/server/tools/verification.js +1 -1
  80. package/dist/server/tools/verification.js.map +1 -1
  81. package/files/agents/code-organization-supervisor.md +1 -0
  82. package/files/agents/context-guardian.md +1 -0
  83. package/files/agents/docs-keeper.md +1 -0
  84. package/files/agents/dry-refactor.md +1 -0
  85. package/files/agents/elite-code-refactorer.md +1 -0
  86. package/files/agents/hardening-guard.md +1 -0
  87. package/files/agents/implementation-dev.md +1 -0
  88. package/files/agents/merlin-access-control-reviewer.md +248 -0
  89. package/files/agents/merlin-codebase-mapper.md +1 -1
  90. package/files/agents/merlin-dependency-auditor.md +216 -0
  91. package/files/agents/merlin-executor.md +1 -0
  92. package/files/agents/merlin-input-validator.md +247 -0
  93. package/files/agents/merlin-reviewer.md +1 -0
  94. package/files/agents/merlin-sast-reviewer.md +182 -0
  95. package/files/agents/merlin-secret-scanner.md +203 -0
  96. package/files/agents/tests-qa.md +1 -0
  97. package/files/commands/merlin/execute-phase.md +94 -197
  98. package/files/commands/merlin/execute-plan.md +116 -180
  99. package/files/commands/merlin/health.md +385 -0
  100. package/files/commands/merlin/loop-recipes.md +93 -36
  101. package/files/commands/merlin/optimize-prompts.md +158 -0
  102. package/files/commands/merlin/profiles.md +215 -0
  103. package/files/commands/merlin/promote.md +176 -0
  104. package/files/commands/merlin/quick.md +229 -0
  105. package/files/commands/merlin/resume-work.md +27 -1
  106. package/files/commands/merlin/route.md +43 -1
  107. package/files/commands/merlin/sandbox.md +359 -0
  108. package/files/commands/merlin/usage.md +55 -0
  109. package/files/docker/Dockerfile.merlin +20 -0
  110. package/files/docker/docker-compose.merlin.yml +23 -0
  111. package/files/hook-templates/auto-commit.sh +64 -0
  112. package/files/hook-templates/auto-format.sh +95 -0
  113. package/files/hook-templates/auto-test.sh +117 -0
  114. package/files/hook-templates/branch-protection.sh +72 -0
  115. package/files/hook-templates/changelog-reminder.sh +76 -0
  116. package/files/hook-templates/complexity-check.sh +112 -0
  117. package/files/hook-templates/import-audit.sh +83 -0
  118. package/files/hook-templates/license-header.sh +84 -0
  119. package/files/hook-templates/pr-description.sh +100 -0
  120. package/files/hook-templates/todo-tracker.sh +80 -0
  121. package/files/hooks/check-file-size.sh +17 -4
  122. package/files/hooks/config-change.sh +44 -16
  123. package/files/hooks/instructions-loaded.sh +22 -5
  124. package/files/hooks/notify-desktop.sh +157 -0
  125. package/files/hooks/notify-webhook.sh +141 -0
  126. package/files/hooks/pre-edit-sights-check.sh +76 -9
  127. package/files/hooks/security-scanner.sh +153 -0
  128. package/files/hooks/session-end-memory-sync.sh +97 -0
  129. package/files/hooks/session-end.sh +274 -1
  130. package/files/hooks/session-start.sh +19 -6
  131. package/files/hooks/smart-approve.sh +270 -0
  132. package/files/hooks/teammate-idle-verify.sh +87 -12
  133. package/files/hooks/worktree-create.sh +20 -3
  134. package/files/hooks/worktree-remove.sh +21 -3
  135. package/files/merlin/references/plan-format.md +37 -9
  136. package/files/merlin/sandbox.json +9 -0
  137. package/files/merlin/security.json +11 -0
  138. package/files/merlin/templates/ci/docs-update.yml +81 -0
  139. package/files/merlin/templates/ci/pr-review.yml +50 -0
  140. package/files/merlin/templates/ci/security-audit.yml +74 -0
  141. package/files/merlin/templates/config.json +9 -1
  142. package/files/rules/api-rules.md +30 -0
  143. package/files/rules/frontend-rules.md +25 -0
  144. package/files/rules/hooks-rules.md +36 -0
  145. package/files/rules/mcp-rules.md +30 -0
  146. package/files/rules/worker-rules.md +29 -0
  147. package/package.json +5 -2
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: merlin:execute-plan
3
3
  description: Execute a PLAN.md file
4
- argument-hint: "[path-to-PLAN.md]"
4
+ argument-hint: "[path-to-PLAN.md] [--teams]"
5
5
  allowed-tools:
6
6
  - Read
7
7
  - Glob
@@ -22,13 +22,15 @@ Orchestrator stays lean: validate plan, determine mode, write handoff, spawn fre
22
22
  handle checkpoints, report completion. The executor gets full 200K context.
23
23
 
24
24
  No Task(). No shared context. Deterministic execution.
25
+
26
+ When a plan contains parallel task groups and `--teams` is active, each group spawns
27
+ as a named Teammate for true parallel execution within the single plan.
25
28
  </objective>
26
29
 
27
30
  <process>
28
31
 
29
32
  ## Step 1: Validate Plan Exists
30
33
 
31
- Confirm file at $ARGUMENTS exists.
32
34
  ```bash
33
35
  ls "$PLAN_PATH" 2>/dev/null
34
36
  ```
@@ -36,26 +38,30 @@ Error if not found: "Plan not found: {path}"
36
38
 
37
39
  ## Step 2: Check If Already Executed
38
40
 
39
- Derive SUMMARY path from plan path (replace PLAN.md with SUMMARY.md).
40
41
  ```bash
41
42
  SUMMARY_PATH="${PLAN_PATH/PLAN.md/SUMMARY.md}"
42
43
  ls "$SUMMARY_PATH" 2>/dev/null
43
44
  ```
44
-
45
- If SUMMARY exists: "Plan already executed. SUMMARY: {path}"
46
- Offer: re-execute or exit.
45
+ If SUMMARY exists: "Plan already executed." Offer re-execute or exit.
47
46
 
48
47
  ## Step 3: Determine Mode
49
48
 
50
- Same mode detection as `/merlin:route`:
51
- 1. Check arguments for `--automated` or `--interactive`
52
- 2. Check `.planning/config.json`
53
- 3. Check `~/.claude/merlin/settings.local.json`
49
+ 1. Check args for `--teams`, `--automated`, `--interactive`
50
+ 2. If no `--teams` flag, check env: `CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS`
51
+ 3. Check `.planning/config.json`, then `~/.claude/merlin/settings.local.json`
54
52
  4. Default: `interactive`
55
53
 
54
+ ```bash
55
+ TEAMS_MODE=false
56
+ if echo "${ARGUMENTS}" | grep -q '\-\-teams'; then
57
+ TEAMS_MODE=true
58
+ elif [ "${CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS:-0}" = "1" ]; then
59
+ TEAMS_MODE=true
60
+ fi
61
+ ```
62
+
56
63
  ## Step 4: Get Sights Context
57
64
 
58
- Parse plan to get the objective:
59
65
  ```bash
60
66
  head -30 "$PLAN_PATH" 2>/dev/null
61
67
  ```
@@ -68,89 +74,71 @@ Task: "{objective from plan}"
68
74
  ## Step 5: Parse Plan Identifiers
69
75
 
70
76
  Extract from path like `.planning/phases/03-auth/03-02-PLAN.md`:
71
- - phase_number: `03`
72
- - phase_name: `auth`
73
- - plan_number: `02`
77
+ `phase_number=03`, `phase_name=auth`, `plan_number=02`
74
78
 
75
79
  ## Step 6: Pre-Execution Summary
76
80
 
77
- Parse PLAN.md to extract:
78
- - objective: First sentence from `<objective>` element
79
- - task_count: Count of `<task` elements
80
- - files: Collect unique file paths from `<files>` elements
81
+ Parse PLAN.md: objective, task_count, files, parallel_groups.
81
82
 
82
- Display:
83
83
  ```
84
84
  ════════════════════════════════════════
85
85
  EXECUTING: {phase_number}-{plan_number} {phase_name}
86
86
  ════════════════════════════════════════
87
-
88
87
  Building: {objective one-liner}
89
- Tasks: {task_count}
90
- Files: {comma-separated file list}
91
- Mode: {interactive|automated}
92
-
88
+ Tasks: {task_count} | Files: {file list}
89
+ Mode: {interactive|automated|teams}
90
+ {if teams + parallel groups: "Parallel groups: {N} — will spawn {N} teammates"}
93
91
  Full plan: {plan_path}
94
92
  ════════════════════════════════════════
95
93
  ```
96
94
 
97
95
  ## Step 7: Interactive Pre-Flight (interactive mode only)
98
96
 
99
- **Skip in automated mode.**
100
-
101
- Ask user if they have any notes before execution:
102
- - "Any specific concerns or constraints for this plan?"
103
- - If user has none, proceed directly.
97
+ Ask: "Any specific concerns or constraints for this plan?"
98
+ Skip in automated and teams mode.
104
99
 
105
100
  ## Step 8: Write Handoff File
106
101
 
107
102
  ```bash
108
103
  HANDOFF_DIR="/tmp/merlin-exec-$$"
109
104
  mkdir -p "$HANDOFF_DIR"
110
- HANDOFF_FILE="$HANDOFF_DIR/handoff.md"
111
105
  ```
112
106
 
113
- Write:
107
+ Derive a concise session label (max 40 chars) from the plan path:
108
+ ```bash
109
+ PLAN_LABEL=$(basename "${PLAN_PATH}" -PLAN.md | sed 's/^[0-9]*-[0-9]*-//')
110
+ SESSION_NAME="Merlin: merlin-executor — ${PLAN_LABEL}"
111
+ ```
112
+
113
+ The `SESSION_NAME` appears in VS Code's Spark panel — keep it concise but descriptive.
114
114
 
115
115
  ```markdown
116
116
  # Execution Handoff
117
-
118
- ## Plan
119
- Execute plan at: {plan_path}
120
-
121
- ## Mode
122
- {interactive|automated}
123
- {automated: "Make reasonable assumptions at decision points. Do NOT checkpoint."}
124
- {interactive: "At decision points, output CHECKPOINT_NEEDED with details and stop."}
125
-
126
- ## Sights Context
127
- {SIGHTS_CONTEXT}
128
-
129
- ## User Inputs
130
- {USER_INPUTS or "Automated mode — make reasonable assumptions"}
131
-
132
- ## Files to Read
133
- - Plan: {plan_path}
134
- - State: .planning/STATE.md
135
- - Config: .planning/config.json (if exists)
117
+ ## Session: {SESSION_NAME}
118
+ ## Plan: {plan_path}
119
+ ## Mode: {interactive|automated|teams}
120
+ - automated: "Make reasonable assumptions. Do NOT checkpoint."
121
+ - interactive: "At decision points, output CHECKPOINT_NEEDED and stop."
122
+ - teams: "You are a Teammate. Make reasonable assumptions. Do NOT checkpoint."
123
+ ## Sights Context: {SIGHTS_CONTEXT}
124
+ ## User Inputs: {USER_INPUTS or "Automated make reasonable assumptions"}
125
+ ## Files to Read: plan_path, .planning/STATE.md, .planning/config.json
136
126
 
137
127
  Read the plan file yourself — you have fresh 200K context.
138
128
 
139
- ## Result Protocol
140
- When done, output:
141
-
129
+ ## Result Protocol:
142
130
  ---EXEC_RESULT---
143
131
  Status: completed | checkpoint | error
144
- Summary: <2-3 sentence summary>
145
- Tasks-Completed: <number>
146
- Tasks-Total: <number>
147
- Commits: <list of commit hashes, one per line>
148
- Files-Changed: <comma-separated list>
149
- Checkpoint: <only if status=checkpoint — what you need>
132
+ Summary: <2-3 sentences>
133
+ Tasks-Completed: <N> Tasks-Total: <N>
134
+ Commits: <hash list> Files-Changed: <file list>
135
+ Checkpoint: <only if status=checkpoint>
150
136
  ---END_EXEC_RESULT---
151
137
  ```
152
138
 
153
- ## Step 9: Spawn Fresh Executor Process
139
+ ## Step 9: Spawn Executor
140
+
141
+ ### Standard mode (interactive or automated)
154
142
 
155
143
  ```bash
156
144
  RESULT=$(unset CLAUDECODE && cat "$HANDOFF_FILE" | claude \
@@ -164,157 +152,110 @@ EXIT_CODE=$?
164
152
 
165
153
  Use Bash tool with `timeout: 600000` (10 minutes).
166
154
 
167
- ## Step 10: Handle Result
168
-
169
- Parse result between `---EXEC_RESULT---` and `---END_EXEC_RESULT---`.
155
+ ### Teams mode parallel task groups within plan
170
156
 
171
- ### If status = completed
157
+ When `TEAMS_MODE=true` and the plan has parallel task groups:
172
158
 
173
- 1. Verify SUMMARY.md was created:
159
+ 1. Count parallel groups:
174
160
  ```bash
175
- ls "${PLAN_PATH/PLAN.md/SUMMARY.md}" 2>/dev/null
161
+ PARALLEL_GROUPS=$(grep -c "^parallel: true" "$PLAN_PATH" 2>/dev/null || echo "0")
176
162
  ```
177
- 2. Sync tasks to cloud:
163
+
164
+ 2. If groups exist, write a per-group teammate handoff:
165
+ ```markdown
166
+ # Teammate Task — Plan {PLAN_LABEL}, Group {GROUP_ID}
167
+ ## Session Name: Merlin: merlin-executor — {PLAN_LABEL} group-{GROUP_ID}
168
+ ## Plan: {PLAN_PATH} — execute only tasks in group {GROUP_ID}
169
+ ## Mode: teams — make assumptions, do NOT checkpoint
170
+ ## Sights Context: {SIGHTS_CONTEXT}
171
+ ## Result Protocol: (same standard format)
178
172
  ```
179
- Call: merlin_sync_task
180
- Title: "{plan objective}"
181
- Status: "completed"
173
+
174
+ 3. Show live status during execution:
182
175
  ```
183
- 3. Clean up handoff:
184
- ```bash
185
- rm -rf "$HANDOFF_DIR"
176
+ Plan {PLAN_LABEL} {N} teammates active:
177
+ Teammate 1: merlin-executor — "Group 1: API endpoints"
178
+ Teammate 2: merlin-executor "Group 2: Database schema" (done)
186
179
  ```
187
- 4. Go to Step 11 (Present Result).
188
180
 
189
- ### If status = checkpoint (interactive mode only)
181
+ 4. Fallback if no parallel groups or Teams spawn fails: single executor.
182
+ Log: `[merlin] Running as single executor (no parallel groups or Teams unavailable)`
183
+
184
+ ## Step 10: Handle Result
185
+
186
+ Parse result between `---EXEC_RESULT---` and `---END_EXEC_RESULT---`.
190
187
 
191
- Run the checkpoint loop (Step 10a).
188
+ **completed:**
189
+ 1. Verify SUMMARY.md created
190
+ 2. Sync: `merlin_sync_task` → status: completed
191
+ 3. `rm -rf "$HANDOFF_DIR"`
192
+ 4. Go to Step 11
192
193
 
193
- ### If status = error
194
+ **checkpoint (interactive only):** Run Step 10a loop.
194
195
 
195
- Present error, offer retry or skip.
196
+ **error:** Present error, offer retry or skip.
196
197
 
197
198
  ## Step 10a: Checkpoint Loop (interactive mode only)
198
199
 
199
200
  When executor returns `status: checkpoint`:
200
201
 
201
- 1. **Present checkpoint to user:**
202
+ 1. Present to user:
202
203
  ```
203
- ╔═══════════════════════════════════════════════════════════╗
204
- ║ CHECKPOINT: Executor needs input
205
- ╚═══════════════════════════════════════════════════════════╝
206
-
207
- Progress: {tasks-completed}/{tasks-total} tasks complete
208
-
204
+ ╔═══════════════════════════════════════╗
205
+ ║ CHECKPOINT: Executor needs input
206
+ ╚═══════════════════════════════════════╝
207
+ Progress: {tasks-completed}/{tasks-total}
209
208
  {checkpoint details}
210
-
211
- ────────────────────────────────────────────────────────────
212
209
  Your response:
213
210
  ```
214
211
 
215
- 2. **Collect user response.**
212
+ 2. Collect user response.
216
213
 
217
- 3. **Write continuation handoff:**
214
+ 3. Write continuation handoff:
218
215
  ```markdown
219
216
  # Execution Continuation
220
-
221
- ## Original Plan
222
- {plan_path}
223
-
224
- ## Previous Progress
225
- {tasks-completed} of {tasks-total} tasks complete
226
- Commits so far: {commits list}
227
- Files changed so far: {files list}
228
-
229
- ## Checkpoint Response
230
- User said: {user_response}
231
-
232
- ## Instructions
233
- Continue executing the plan from where you left off.
234
- Read the plan file to find remaining tasks.
235
- The user has answered your checkpoint question.
236
-
237
- ## Result Protocol
238
- (same as original)
217
+ ## Original Plan: {plan_path}
218
+ ## Previous Progress: {tasks-completed}/{tasks-total} complete
219
+ ## Commits so far: {list} Files changed: {list}
220
+ ## Checkpoint Response: User said: {user_response}
221
+ ## Instructions: Continue from where you left off. Read plan for remaining tasks.
222
+ ## Result Protocol: (same as original)
239
223
  ```
240
224
 
241
- 4. **Spawn NEW fresh process** with continuation handoff.
242
- Brand new 200K context. NOT a resume.
243
-
244
- 5. **Repeat** until `completed` or `error` (max 5 cycles).
225
+ 4. Spawn NEW fresh process. NOT a resume.
226
+ 5. Repeat until `completed` or `error` (max 5 cycles).
245
227
 
246
228
  ## Step 11: Present Result and Next Steps
247
229
 
248
- Check remaining plans in phase:
249
230
  ```bash
250
231
  PHASE_DIR=$(dirname "$PLAN_PATH")
251
232
  PLAN_COUNT=$(ls -1 "$PHASE_DIR"/*-PLAN.md 2>/dev/null | wc -l)
252
233
  SUMMARY_COUNT=$(ls -1 "$PHASE_DIR"/*-SUMMARY.md 2>/dev/null | wc -l)
253
234
  ```
254
235
 
255
- ### If more plans remain in phase (summaries < plans):
256
-
257
- Find next PLAN.md without matching SUMMARY.md:
258
-
236
+ **More plans remain:**
259
237
  ```
260
- Plan {phase}-{plan} complete.
261
- Summary: {summary_path}
262
-
263
- {SUMMARY_COUNT} of {PLAN_COUNT} plans complete for Phase {Z}.
264
-
265
- ---
266
-
267
- ## Next Up
268
-
269
- **{phase}-{next-plan}: [Plan Name]**
270
-
271
- `/merlin:execute-plan {next-plan-path}`
238
+ Plan {phase}-{plan} complete. {SUMMARY_COUNT}/{PLAN_COUNT} plans done for Phase {Z}.
239
+ Next: /merlin:execute-plan {next-plan-path}
272
240
  ```
273
241
 
274
- ### If phase complete (summaries = plans):
275
-
276
- Check verification status — spawn merlin-verifier as fresh process:
277
-
242
+ **Phase complete spawn verifier:**
278
243
  ```bash
279
- # Write verifier handoff
280
- cat > "/tmp/merlin-verify-$$/handoff.md" << 'VERIFY'
281
- Verify phase {phase_number} goal achievement.
282
-
283
- Phase: {phase_number} - {phase_name}
284
- Phase goal: {phase_goal}
285
- Phase directory: {phase_dir}
286
-
287
- Check must_haves against actual codebase (not SUMMARY claims).
288
- Create VERIFICATION.md in the phase directory.
289
-
290
- ---VERIFY_RESULT---
291
- Status: passed | gaps_found | human_needed
292
- Score: X/Y must-haves verified
293
- Summary: <what was verified>
294
- ---END_VERIFY_RESULT---
295
- VERIFY
296
-
297
- # Spawn fresh verifier
298
244
  VERIFY_RESULT=$(unset CLAUDECODE && cat "/tmp/merlin-verify-$$/handoff.md" | claude \
299
- --agent merlin-verifier \
300
- -p \
301
- --permission-mode acceptEdits \
302
- --output-format text \
303
- 2>&1)
245
+ --agent merlin-verifier -p --permission-mode acceptEdits \
246
+ --output-format text 2>&1)
304
247
  ```
305
248
 
306
- Route based on verification:
307
- - **passed + more phases:** Suggest `/merlin:plan-phase {next}`
308
- - **passed + last phase:** Suggest `/merlin:complete-milestone`
309
- - **gaps_found:** Suggest `/merlin:plan-phase {current} --gaps`
310
- - **human_needed:** Present items for user review
249
+ Verifier handoff: check must_haves against actual codebase, create VERIFICATION.md.
311
250
 
312
- ### Update Requirements (when phase complete + verified)
251
+ Route: `passed + more phases` → `/merlin:plan-phase {next}` |
252
+ `passed + last phase` → `/merlin:complete-milestone` |
253
+ `gaps_found` → `/merlin:plan-phase {current} --gaps` |
254
+ `human_needed` → present items
313
255
 
314
- Read ROADMAP.md for phase requirements, update REQUIREMENTS.md status to "Complete".
315
-
316
- ### Commit Phase Metadata (when phase complete)
256
+ **When phase complete + verified:** Update REQUIREMENTS.md status to "Complete".
317
257
 
258
+ **Commit phase metadata:**
318
259
  ```bash
319
260
  git add .planning/ROADMAP.md .planning/STATE.md .planning/REQUIREMENTS.md 2>/dev/null
320
261
  git commit -m "docs({phase}): complete {phase-name} phase"
@@ -323,38 +264,33 @@ git commit -m "docs({phase}): complete {phase-name} phase"
323
264
  </process>
324
265
 
325
266
  <commit_rules>
326
- **Per-Task Commits:** Handled by the executor process (per-task atomic commits).
327
- **Plan Metadata Commit:** Handled by the executor process (PLAN.md + SUMMARY.md).
267
+ **Per-Task Commits:** Handled by executor process (atomic per task).
268
+ **Plan Metadata Commit:** Handled by executor process (PLAN.md + SUMMARY.md).
328
269
  **Phase Completion Commit:** Handled by this orchestrator (ROADMAP.md + STATE.md + REQUIREMENTS.md).
329
-
330
- **NEVER use:** `git add .` or `git add -A`. Always stage files individually.
270
+ **NEVER use:** `git add .` or `git add -A`. Stage files individually.
331
271
  </commit_rules>
332
272
 
333
273
  <critical_rules>
334
-
335
274
  **NEVER USE Task().** Task() shares parent context. Use `claude --agent -p` via Bash.
336
-
337
275
  **ALWAYS FRESH PROCESS.** Every execution spawns a new `claude` process.
338
-
339
- **CHECKPOINT = NEW PROCESS.** After a checkpoint, spawn a NEW fresh process with continuation state.
340
- Never try to resume the old process.
341
-
276
+ **CHECKPOINT = NEW PROCESS.** Spawn NEW fresh process after checkpoint. Never resume old.
342
277
  **MAX 10 MINUTES PER SPAWN.** For longer tasks, use `merlin-loop`.
343
-
344
278
  **CLEAN UP HANDOFFS.** Remove /tmp files after processing.
345
-
279
+ **TEAMS MODE IS ADDITIVE.** Single-executor mode always works as fallback.
280
+ **TEAMS = NO CHECKPOINTS.** Teammates make assumptions, never checkpoint.
346
281
  </critical_rules>
347
282
 
348
283
  <success_criteria>
349
284
  - [ ] Plan validated and not already executed
350
- - [ ] Mode determined (interactive or automated)
285
+ - [ ] Mode determined (interactive, automated, or teams)
351
286
  - [ ] Handoff file written to /tmp
352
287
  - [ ] Fresh `claude --agent merlin-executor -p` spawned via Bash
353
- - [ ] All checkpoints handled (interactive) or none expected (automated)
288
+ - [ ] Checkpoints handled (interactive) or none expected (automated/teams)
354
289
  - [ ] SUMMARY.md created by executor
355
290
  - [ ] Tasks synced to cloud
356
291
  - [ ] Phase verification triggered if phase complete
357
292
  - [ ] Requirements updated if phase complete
358
293
  - [ ] Temp files cleaned up
359
294
  - [ ] Next steps offered
295
+ - [ ] Teams: parallel groups shown with teammate names, fallback to single on failure
360
296
  </success_criteria>