maxsimcli 5.0.6 → 5.1.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 (91) hide show
  1. package/README.md +316 -288
  2. package/dist/assets/CHANGELOG.md +14 -0
  3. package/dist/assets/hooks/maxsim-capture-learnings.cjs +128 -0
  4. package/dist/assets/hooks/maxsim-capture-learnings.cjs.map +1 -0
  5. package/dist/assets/hooks/maxsim-check-update.cjs +126 -88
  6. package/dist/assets/hooks/maxsim-check-update.cjs.map +1 -1
  7. package/dist/assets/hooks/maxsim-notification-sound.cjs +87 -43
  8. package/dist/assets/hooks/maxsim-notification-sound.cjs.map +1 -1
  9. package/dist/assets/hooks/maxsim-statusline.cjs +45 -171
  10. package/dist/assets/hooks/maxsim-statusline.cjs.map +1 -1
  11. package/dist/assets/hooks/maxsim-stop-sound.cjs +86 -43
  12. package/dist/assets/hooks/maxsim-stop-sound.cjs.map +1 -1
  13. package/dist/assets/hooks/maxsim-sync-reminder.cjs +72 -21
  14. package/dist/assets/hooks/maxsim-sync-reminder.cjs.map +1 -1
  15. package/dist/assets/templates/agents/AGENTS.md +62 -51
  16. package/dist/assets/templates/agents/executor.md +44 -59
  17. package/dist/assets/templates/agents/planner.md +36 -31
  18. package/dist/assets/templates/agents/researcher.md +35 -43
  19. package/dist/assets/templates/agents/verifier.md +29 -31
  20. package/dist/assets/templates/commands/maxsim/debug.md +20 -154
  21. package/dist/assets/templates/commands/maxsim/execute.md +19 -33
  22. package/dist/assets/templates/commands/maxsim/go.md +21 -20
  23. package/dist/assets/templates/commands/maxsim/help.md +5 -14
  24. package/dist/assets/templates/commands/maxsim/init.md +18 -40
  25. package/dist/assets/templates/commands/maxsim/plan.md +22 -37
  26. package/dist/assets/templates/commands/maxsim/progress.md +15 -16
  27. package/dist/assets/templates/commands/maxsim/quick.md +18 -29
  28. package/dist/assets/templates/commands/maxsim/settings.md +18 -26
  29. package/dist/assets/templates/references/continuation-format.md +2 -4
  30. package/dist/assets/templates/references/model-profiles.md +2 -2
  31. package/dist/assets/templates/references/planning-config.md +10 -11
  32. package/dist/assets/templates/references/self-improvement.md +120 -0
  33. package/dist/assets/templates/rules/conventions.md +1 -1
  34. package/dist/assets/templates/rules/verification-protocol.md +1 -1
  35. package/dist/assets/templates/skills/brainstorming/SKILL.md +35 -26
  36. package/dist/assets/templates/skills/code-review/SKILL.md +78 -55
  37. package/dist/assets/templates/skills/commit-conventions/SKILL.md +70 -36
  38. package/dist/assets/templates/skills/github-operations/SKILL.md +142 -0
  39. package/dist/assets/templates/skills/handoff-contract/SKILL.md +62 -28
  40. package/dist/assets/templates/skills/maxsim-batch/SKILL.md +68 -42
  41. package/dist/assets/templates/skills/maxsim-simplify/SKILL.md +65 -40
  42. package/dist/assets/templates/skills/project-memory/SKILL.md +121 -0
  43. package/dist/assets/templates/skills/research/SKILL.md +126 -0
  44. package/dist/assets/templates/skills/roadmap-writing/SKILL.md +71 -68
  45. package/dist/assets/templates/skills/systematic-debugging/SKILL.md +37 -25
  46. package/dist/assets/templates/skills/tdd/SKILL.md +36 -39
  47. package/dist/assets/templates/skills/using-maxsim/SKILL.md +69 -55
  48. package/dist/assets/templates/skills/verification/SKILL.md +167 -0
  49. package/dist/assets/templates/workflows/batch.md +249 -268
  50. package/dist/assets/templates/workflows/diagnose-issues.md +225 -151
  51. package/dist/assets/templates/workflows/execute-plan.md +191 -981
  52. package/dist/assets/templates/workflows/execute.md +350 -309
  53. package/dist/assets/templates/workflows/go.md +119 -138
  54. package/dist/assets/templates/workflows/health.md +71 -114
  55. package/dist/assets/templates/workflows/help.md +85 -147
  56. package/dist/assets/templates/workflows/init-existing.md +180 -1373
  57. package/dist/assets/templates/workflows/init.md +53 -165
  58. package/dist/assets/templates/workflows/new-milestone.md +91 -334
  59. package/dist/assets/templates/workflows/new-project.md +165 -1384
  60. package/dist/assets/templates/workflows/plan-create.md +182 -73
  61. package/dist/assets/templates/workflows/plan-discuss.md +89 -82
  62. package/dist/assets/templates/workflows/plan-research.md +191 -85
  63. package/dist/assets/templates/workflows/plan.md +122 -58
  64. package/dist/assets/templates/workflows/progress.md +76 -310
  65. package/dist/assets/templates/workflows/quick.md +70 -495
  66. package/dist/assets/templates/workflows/sdd.md +231 -221
  67. package/dist/assets/templates/workflows/settings.md +90 -120
  68. package/dist/assets/templates/workflows/verify-phase.md +296 -258
  69. package/dist/cli.cjs +17 -23465
  70. package/dist/cli.cjs.map +1 -1
  71. package/dist/install.cjs +356 -8358
  72. package/dist/install.cjs.map +1 -1
  73. package/package.json +16 -22
  74. package/dist/assets/templates/skills/agent-system-map/SKILL.md +0 -92
  75. package/dist/assets/templates/skills/evidence-collection/SKILL.md +0 -87
  76. package/dist/assets/templates/skills/github-artifact-protocol/SKILL.md +0 -67
  77. package/dist/assets/templates/skills/github-tools-guide/SKILL.md +0 -89
  78. package/dist/assets/templates/skills/input-validation/SKILL.md +0 -51
  79. package/dist/assets/templates/skills/memory-management/SKILL.md +0 -75
  80. package/dist/assets/templates/skills/research-methodology/SKILL.md +0 -137
  81. package/dist/assets/templates/skills/sdd/SKILL.md +0 -91
  82. package/dist/assets/templates/skills/tool-priority-guide/SKILL.md +0 -80
  83. package/dist/assets/templates/skills/verification-before-completion/SKILL.md +0 -71
  84. package/dist/assets/templates/skills/verification-gates/SKILL.md +0 -169
  85. package/dist/assets/templates/workflows/discuss-phase.md +0 -683
  86. package/dist/assets/templates/workflows/research-phase.md +0 -73
  87. package/dist/assets/templates/workflows/verify-work.md +0 -572
  88. package/dist/core-D5zUr9cb.cjs +0 -4305
  89. package/dist/core-D5zUr9cb.cjs.map +0 -1
  90. package/dist/skills-CjFWZIGM.cjs +0 -6824
  91. package/dist/skills-CjFWZIGM.cjs.map +0 -1
@@ -1,341 +1,318 @@
1
1
  <sanity_check>
2
2
  Before executing any step in this workflow, verify:
3
3
  1. The current directory contains a `.planning/` folder — if not, stop and tell the user to run `/maxsim:init` first.
4
- 2. Git is initialized (`git rev-parse --git-dir` succeeds) worktrees require a git repository.
5
- 3. `.planning/ROADMAP.md` exists if not, stop and tell the user to initialize the project.
4
+ 2. `.planning/ROADMAP.md` exists if not, stop and tell the user to initialize the project.
5
+ 3. Git is initialized (`git rev-parse --git-dir` succeeds) worktrees require a git repository.
6
6
  </sanity_check>
7
7
 
8
8
  <purpose>
9
- Decompose a large task into independent units, execute each in an isolated git worktree, and produce one PR per unit. Each unit gets its own branch, worktree, and PR enabling parallel implementation with zero merge conflicts.
9
+ Execute multiple independent tasks in parallel using the Agent tool. Each unit gets its own isolated git worktree, branch, and PR. Based on Anthropic's own /batch pattern: decompose validate independence spawn ALL agents in ONE message block track → report.
10
10
 
11
- Follows the batch-worktree skill process: Research (decompose) -> Plan (validate independence) -> Spawn (worktree agents) -> Track (progress and failures).
11
+ Use this when you have 3+ tasks that share no files and have no runtime dependencies between them.
12
12
  </purpose>
13
13
 
14
- <required_reading>
15
- Read all files referenced by the invoking prompt's execution_context before starting.
16
- </required_reading>
17
-
18
14
  <process>
19
15
 
20
- <step name="initialize" priority="first">
21
- Load context in one call:
16
+ ## Step 1 — Initialize
22
17
 
23
18
  ```bash
19
+ EXECUTOR_MODEL=$(node ~/.claude/maxsim/bin/maxsim-tools.cjs resolve-model executor --raw)
20
+ PLANNER_MODEL=$(node ~/.claude/maxsim/bin/maxsim-tools.cjs resolve-model planner --raw)
24
21
  INIT=$(node ~/.claude/maxsim/bin/maxsim-tools.cjs init quick "$DESCRIPTION")
25
22
  ```
26
23
 
27
- Parse JSON for: `planner_model`, `executor_model`, `slug`, `date`, `timestamp`, `roadmap_exists`, `planning_exists`.
28
-
29
- **If `roadmap_exists` is false:** Error — Batch mode requires an active project with ROADMAP.md. Run `/maxsim:init` first.
24
+ Parse JSON: `planner_model`, `executor_model`, `slug`, `date`, `timestamp`, `roadmap_exists`.
30
25
 
31
- Verify git is available:
32
- ```bash
33
- git rev-parse --git-dir > /dev/null 2>&1 || echo "ERROR: Not a git repository"
34
- ```
26
+ If `roadmap_exists` is false: error — batch mode requires an active project. Run `/maxsim:init` first.
35
27
 
36
- Store `BASE_BRANCH`:
28
+ Store base branch:
37
29
  ```bash
38
30
  BASE_BRANCH=$(git rev-parse --abbrev-ref HEAD)
39
31
  ```
40
- </step>
41
-
42
- <step name="gather_task">
43
- Parse `$ARGUMENTS` for the task description.
44
-
45
- If `$ARGUMENTS` is empty, prompt user interactively:
46
-
47
- ```
48
- AskUserQuestion(
49
- header: "Batch Task",
50
- question: "Describe the large task to decompose into independent worktree units.",
51
- followUp: null
52
- )
53
- ```
54
-
55
- Store response as `$DESCRIPTION`.
56
-
57
- If still empty, re-prompt: "Please provide a task description."
58
32
 
59
33
  Display banner:
60
34
  ```
61
35
  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
62
- MAXSIM > BATCH WORKTREE EXECUTION
36
+ MAXSIM > BATCH PARALLEL EXECUTION
63
37
  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
64
38
 
65
- Task: ${DESCRIPTION}
66
- Base branch: ${BASE_BRANCH}
39
+ Task: {description from $ARGUMENTS}
40
+ Base branch: {BASE_BRANCH}
67
41
  ```
68
- </step>
69
42
 
70
- <step name="decompose">
71
- Spawn planner with batch-specific prompt to produce a decomposition:
43
+ If `$ARGUMENTS` is empty, prompt: "Describe the large task to decompose into independent units."
72
44
 
73
- ```
74
- Task(
75
- prompt="
76
- <planning_context>
45
+ ## Step 2 — Decompose into Independent Units
77
46
 
78
- **Mode:** batch
79
- **Description:** ${DESCRIPTION}
80
- **Base branch:** ${BASE_BRANCH}
47
+ Spawn planner to produce a decomposition:
81
48
 
82
- <files_to_read>
83
- - .planning/STATE.md (Project State)
84
- - .planning/ROADMAP.md (Phase structure)
85
- - ./CLAUDE.md (if exists — follow project-specific guidelines)
86
- - .skills/maxsim-batch/SKILL.md (if exists — maxsim-batch constraints)
87
- </files_to_read>
88
-
89
- **Project skills:** Check .skills/ directory (if exists) — read SKILL.md files, plans should account for project skill rules
90
-
91
- </planning_context>
92
-
93
- <constraints>
94
- - Decompose into 3-30 independent units
95
- - Each unit MUST be independently mergeable (hard gate from batch-worktree skill)
96
- - If fewer than 3 units are identified, STOP and recommend /maxsim:quick instead
97
- - No file may appear in more than one unit
98
- - No runtime dependency between units (unit A output must not be unit B input)
99
- - Each unit must have: title, description, files owned, acceptance criteria
100
- </constraints>
101
-
102
- <output>
103
- Write decomposition to: .planning/batch/${slug}/DECOMPOSITION.md
104
-
105
- Format:
106
- ---
107
- task: ${DESCRIPTION}
108
- date: ${date}
109
- base_branch: ${BASE_BRANCH}
110
- unit_count: N
111
- status: pending
112
- ---
113
-
114
- ## Units
115
-
116
- ### Unit 1: [Title]
117
- **Description:** ...
118
- **Files owned:**
119
- - path/to/file1.ts
120
- - path/to/file2.ts
121
- **Acceptance criteria:**
122
- - [ ] Criterion 1
123
- - [ ] Criterion 2
124
-
125
- ### Unit 2: [Title]
126
- ...
127
-
128
- ## Independence Matrix
129
- [For each pair of units, confirm no file overlap and no runtime dependency]
130
-
131
- Return: ## PLANNING COMPLETE with unit count and decomposition path
132
- </output>
133
- ",
49
+ ```
50
+ Agent(
134
51
  subagent_type="planner",
135
52
  model="{planner_model}",
136
- description="Batch decomposition: ${DESCRIPTION}"
53
+ prompt="
54
+ <planning_context>
55
+ Mode: batch
56
+ Description: {description}
57
+ Base branch: {BASE_BRANCH}
58
+
59
+ Read these files:
60
+ - .planning/STATE.md
61
+ - .planning/ROADMAP.md
62
+ - ./CLAUDE.md (if exists — follow project guidelines)
63
+ </planning_context>
64
+
65
+ <constraints>
66
+ Decompose into 3–30 independent units. Hard rules:
67
+ - Each unit MUST be independently mergeable — no unit depends on another unit's output
68
+ - No file may appear in more than one unit
69
+ - No runtime dependency between units (unit A output must not be unit B input)
70
+ - If fewer than 3 independent units can be identified, output: INSUFFICIENT UNITS — recommend /maxsim:quick instead
71
+ - Each unit must have: title, description, files owned (exhaustive list), acceptance criteria
72
+ </constraints>
73
+
74
+ <output>
75
+ Write decomposition to: .planning/batch/{slug}/DECOMPOSITION.md
76
+
77
+ Format:
78
+ ---
79
+ task: {description}
80
+ date: {date}
81
+ base_branch: {BASE_BRANCH}
82
+ unit_count: N
83
+ status: pending
84
+ ---
85
+
86
+ ## Units
87
+
88
+ ### Unit 1: {Title}
89
+ **Description:** ...
90
+ **Files owned:**
91
+ - path/to/file1.ts
92
+ **Acceptance criteria:**
93
+ - [ ] Criterion 1
94
+
95
+ ### Unit 2: {Title}
96
+ ...
97
+
98
+ ## Independence Matrix
99
+ [For each pair of units: confirm no file overlap and no runtime dependency]
100
+
101
+ Return: ## PLANNING COMPLETE — {N} units
102
+ </output>
103
+ "
137
104
  )
138
105
  ```
139
106
 
140
107
  After planner returns:
141
- 1. Verify decomposition exists at `.planning/batch/${slug}/DECOMPOSITION.md`
108
+ 1. Verify `.planning/batch/{slug}/DECOMPOSITION.md` exists
142
109
  2. Extract unit count
143
- 3. If unit count < 3: warn user and suggest `/maxsim:quick` instead. Ask: "Continue with batch (${unit_count} units) or switch to quick mode?"
144
- 4. Report: "Decomposition complete: ${unit_count} units identified"
110
+ 3. If `INSUFFICIENT UNITS`: warn and suggest `/maxsim:quick`. Ask: "Continue with batch ({N} units) or switch to quick?"
111
+ 4. Report: "Decomposition complete: {N} units identified"
145
112
 
146
- If decomposition not found, error: "Planner failed to create DECOMPOSITION.md"
147
- </step>
113
+ ## Step 3 Validate Independence
148
114
 
149
- <step name="validate_independence">
150
- Read the DECOMPOSITION.md and validate file independence across all units.
115
+ Read `DECOMPOSITION.md` and check file independence across all unit pairs.
151
116
 
152
- For each pair of units:
153
- 1. Extract the files owned by each unit
154
- 2. Compute the intersection
155
- 3. If any file appears in more than one unit, the validation fails
117
+ For each pair (Unit A, Unit B): compute intersection of their file lists.
156
118
 
157
- **If validation fails:**
119
+ **If any overlap found:**
158
120
 
159
- Report the overlapping files and which units conflict:
160
121
  ```
161
122
  ## Independence Validation Failed
162
123
 
163
124
  | File | Unit A | Unit B |
164
125
  |------|--------|--------|
165
- | path/to/file.ts | Unit 1: Title | Unit 3: Title |
126
+ | {path} | {Unit N: title} | {Unit M: title} |
166
127
  ```
167
128
 
168
- Return to planner with revision prompt:
129
+ Return to planner with revision prompt. Re-validate after revision. If validation fails a second time, stop and escalate to user.
130
+
131
+ **If validation passes:**
132
+ ```
133
+ Independence validated: {N} units, no file overlap confirmed
169
134
  ```
170
- Task(
171
- prompt="
172
- <revision_context>
173
135
 
174
- <files_to_read>
175
- - .planning/batch/${slug}/DECOMPOSITION.md (Existing decomposition)
176
- </files_to_read>
136
+ Record decision:
137
+ ```bash
138
+ node ~/.claude/maxsim/bin/maxsim-tools.cjs state add-decision \
139
+ --phase "batch" \
140
+ --summary "Batch decomposition: {N} units, independence validated"
141
+ ```
177
142
 
178
- **Independence validation failed.** The following files appear in multiple units:
179
- ${overlap_table}
143
+ ## Step 4 Plan Mode Confirm Before Spawning
180
144
 
181
- Options:
182
- 1. Merge overlapping units into one
183
- 2. Extract shared files into a prerequisite unit that runs first
184
- 3. Redesign the split so each file belongs to exactly one unit
145
+ **Enter Plan Mode.** Display the full execution plan:
185
146
 
186
- Revise DECOMPOSITION.md to resolve all overlaps.
187
- </revision_context>
188
- ",
189
- subagent_type="planner",
190
- model="{planner_model}",
191
- description="Revise batch decomposition: fix overlaps"
192
- )
193
147
  ```
148
+ ## Batch Execution Plan
194
149
 
195
- Re-validate after revision. If validation fails a second time, stop and escalate to user.
150
+ Task: {description}
151
+ Units: {N} independent worktree agents
152
+ Base branch: {BASE_BRANCH}
196
153
 
197
- **If validation passes:**
154
+ | # | Unit | Files | Acceptance Criteria |
155
+ |---|------|-------|---------------------|
156
+ | 1 | {title} | {file count} | {criteria count} |
157
+ | 2 | {title} | {file count} | {criteria count} |
198
158
 
159
+ Each unit runs in isolation: own branch, own worktree, own PR.
160
+
161
+ Confirm to spawn all {N} agents? (yes/no)
199
162
  ```
200
- Independence validated: ${unit_count} units, no file overlap
201
- ```
202
- </step>
203
163
 
204
- <step name="record_decision">
205
- Record the decomposition decision in STATE.md:
164
+ Wait for user confirmation. **Exit Plan Mode after user confirms.**
206
165
 
207
- ```bash
208
- node ~/.claude/maxsim/bin/maxsim-tools.cjs state add-decision --phase "batch" --summary "Batch decomposition: ${unit_count} units, no file overlap confirmed"
209
- ```
210
- </step>
166
+ ## Step 5 — Spawn All Agents in ONE Message Block
211
167
 
212
- <step name="spawn_worktree_agents">
213
- For each unit in the decomposition, spawn a worktree agent.
168
+ All Agent calls are issued simultaneously in a single message. Every agent gets `isolation="worktree"` and `run_in_background=true`.
214
169
 
215
- Display progress table header:
170
+ Display header:
216
171
  ```
217
- ## Spawning Worktree Agents
172
+ ## Spawning {N} Worktree Agents
218
173
 
219
- | # | Unit | Status | PR |
220
- |---|------|--------|----|
174
+ | # | Unit | Status | Branch | PR |
175
+ |---|------|--------|--------|----|
221
176
  ```
222
177
 
223
- For each unit (spawn all with `run_in_background: true` for parallel execution):
178
+ For EACH unit (all in one message block):
224
179
 
225
180
  ```
226
- Task(
181
+ Agent(
227
182
  subagent_type="executor",
228
183
  model="{executor_model}",
229
184
  isolation="worktree",
230
185
  run_in_background=true,
231
186
  prompt="
232
- You are implementing Unit ${unit_number} of a batch worktree execution.
233
-
234
- <unit_spec>
235
- **Title:** ${unit_title}
236
- **Description:** ${unit_description}
237
- **Base branch:** ${BASE_BRANCH}
238
- **Branch name:** batch/${slug}/unit-${unit_number}
239
- **Files owned (ONLY touch these files):**
240
- ${unit_files}
241
- **Acceptance criteria:**
242
- ${unit_criteria}
243
- </unit_spec>
244
-
245
- <files_to_read>
246
- - ./CLAUDE.md (if exists — follow project-specific guidelines)
247
- - .planning/STATE.md (Project state)
248
- - .skills/ (if exists — list skills, read SKILL.md for each, follow relevant rules)
249
- </files_to_read>
250
-
251
- <instructions>
252
- 1. Create branch: git checkout -b batch/${slug}/unit-${unit_number}
253
- 2. Implement the changes described in the unit spec
254
- 3. ONLY modify files listed in 'Files owned' do not touch any other files
255
- 4. Run tests relevant to your changes
256
- 5. Commit atomically with message: feat(batch): ${unit_title}
257
- 6. Push branch: git push -u origin batch/${slug}/unit-${unit_number}
258
- 7. Create PR: gh pr create --title 'batch(${slug}): ${unit_title}' --body '## Unit ${unit_number}: ${unit_title}\n\n${unit_description}\n\nPart of batch: ${DESCRIPTION}'
259
- 8. Return the PR URL
260
-
261
- If tests fail, fix and retry. If you cannot fix after 2 attempts, report failure with error details.
262
- </instructions>
263
-
264
- <output>
265
- Return one of:
266
- - ## UNIT COMPLETE\nPR: <url>
267
- - ## UNIT FAILED\nError: <details>
268
- </output>
269
- ",
270
- description="Batch unit ${unit_number}: ${unit_title}"
187
+ You are implementing Unit {unit_number} of a batch parallel execution.
188
+ You are running in an isolated git worktree with your own branch.
189
+
190
+ <unit_spec>
191
+ Title: {unit_title}
192
+ Description: {unit_description}
193
+ Base branch: {BASE_BRANCH}
194
+ Branch name: batch/{slug}/unit-{unit_number}
195
+ Files owned (ONLY touch these files — do not modify any others):
196
+ {unit_files_list}
197
+ Acceptance criteria:
198
+ {unit_acceptance_criteria}
199
+ </unit_spec>
200
+
201
+ <files_to_read>
202
+ - ./CLAUDE.md (if exists — follow project coding conventions)
203
+ - .planning/STATE.md
204
+ </files_to_read>
205
+
206
+ <instructions>
207
+ 1. Create branch:
208
+ git checkout -b batch/{slug}/unit-{unit_number}
209
+ 2. Read each file listed in Files owned to understand current state
210
+ 3. Implement the changes described in unit_description
211
+ 4. ONLY modify files listed in Files owned
212
+ 5. Run tests relevant to your changed files
213
+ 6. If tests fail: diagnose and fix. Retry up to 2 times.
214
+ 7. Commit with conventional commit message:
215
+ git add {specific_files_only}
216
+ git commit -m 'feat(batch/{slug}): {unit_title}'
217
+ 8. Push branch:
218
+ git push -u origin batch/{slug}/unit-{unit_number}
219
+ 9. Create PR:
220
+ gh pr create \\
221
+ --title 'batch({slug}): {unit_title}' \\
222
+ --body 'Unit {unit_number}: {unit_description}\n\nPart of batch: {description}\n\nAcceptance criteria:\n{unit_acceptance_criteria}'
223
+ 10. Return the PR URL
224
+ </instructions>
225
+
226
+ <codebase_conventions>
227
+ - Follow existing code style and patterns in the files you modify
228
+ - No dead code, TODOs, stubs, or placeholder comments
229
+ - Handle errors explicitly
230
+ - Stage specific files only — never git add . or git add -A
231
+ </codebase_conventions>
232
+
233
+ <output>
234
+ Final output must be exactly one of:
235
+ ## UNIT COMPLETE
236
+ PR: {pr_url}
237
+
238
+ ## UNIT FAILED
239
+ Error: {specific error details}
240
+ </output>
241
+ ",
242
+ description="Batch unit {unit_number}: {unit_title}"
271
243
  )
272
244
  ```
273
- </step>
274
245
 
275
- <step name="track_progress">
246
+ ## Step 6 — Track Progress
247
+
276
248
  As agents complete, update the status table:
277
249
 
278
- | # | Unit | Status | PR |
279
- |---|------|--------|----|
280
- | 1 | title | done | #123 |
281
- | 2 | title | in-progress | -- |
282
- | 3 | title | failed | -- |
250
+ | # | Unit | Status | Branch | PR |
251
+ |---|------|--------|--------|----|
252
+ | 1 | {title} | done | batch/{slug}/unit-1 | #{pr_number} |
253
+ | 2 | {title} | in-progress | batch/{slug}/unit-2 | — |
254
+ | 3 | {title} | failed | batch/{slug}/unit-3 | — |
283
255
 
284
- Statuses: `pending`, `in-progress`, `done`, `failed`
256
+ Statuses: `pending` `in-progress` `done` | `failed`
285
257
 
286
258
  After each agent returns:
287
259
  1. Parse output for `## UNIT COMPLETE` or `## UNIT FAILED`
288
260
  2. Extract PR URL if complete
289
- 3. Update status table
290
- 4. Report progress: "${completed}/${unit_count} units complete"
261
+ 3. Update status table row
262
+ 4. Print progress: "{done}/{total} units complete"
263
+
264
+ Wait for ALL agents to finish before proceeding.
291
265
 
292
- Wait for all agents to finish before proceeding.
293
- </step>
266
+ ## Step 7 Handle Failures
294
267
 
295
- <step name="handle_failures">
296
- For each failed unit:
268
+ For each failed unit, spawn a fix agent:
297
269
 
298
- **Attempt 1 — spawn fix agent:**
299
270
  ```
300
- Task(
271
+ Agent(
301
272
  subagent_type="executor",
302
273
  model="{executor_model}",
303
274
  isolation="worktree",
304
275
  prompt="
305
- Unit ${unit_number} failed with error:
306
- ${error_details}
276
+ Unit {unit_number} ({unit_title}) failed with this error:
277
+ {error_details}
278
+
279
+ The worktree and branch may already exist. Check:
280
+ git worktree list
281
+ git checkout batch/{slug}/unit-{unit_number} 2>/dev/null || git checkout -b batch/{slug}/unit-{unit_number}
307
282
 
308
- <unit_spec>
309
- ${original_unit_spec}
310
- </unit_spec>
283
+ Original unit spec:
284
+ {unit_spec}
311
285
 
312
- Fix the failing unit. The worktree and branch already exist.
313
- Check out the existing branch, diagnose the failure, fix it, test, commit, push, create PR.
314
- ",
315
- description="Fix batch unit ${unit_number}: ${unit_title}"
286
+ Fix the failure. Diagnose the root cause before attempting changes.
287
+ After fixing: test, commit, push, create PR.
288
+ Return: ## UNIT COMPLETE\nPR: {url} or ## UNIT FAILED\nError: {details}
289
+ ",
290
+ description="Fix batch unit {unit_number}: {unit_title}"
316
291
  )
317
292
  ```
318
293
 
319
- **Merge conflict detected:** Flag to user — decomposition had hidden overlap.
294
+ **Merge conflict detected:** Decomposition had hidden overlap. Escalate to user:
320
295
  ```
321
- AskUserQuestion(
322
- header: "Merge Conflict in Unit ${unit_number}",
323
- question: "Unit ${unit_number} (${unit_title}) has a merge conflict. This suggests the decomposition missed a dependency. Options:\n1. Fix manually\n2. Skip this unit\n3. Abort remaining units",
324
- followUp: null
325
- )
296
+ Merge conflict in Unit {unit_number} ({unit_title}).
297
+ This suggests the decomposition missed a dependency.
298
+ Options:
299
+ 1. Fix manually on branch batch/{slug}/unit-{unit_number}
300
+ 2. Skip this unit
301
+ 3. Abort remaining fix attempts
326
302
  ```
327
303
 
328
- **3+ failures on same unit:** Stop retrying and escalate:
304
+ **3+ failures on same unit:** Stop retrying. Escalate:
329
305
  ```
330
- ## Unit ${unit_number} Escalated
306
+ ## Unit {unit_number} Escalated
331
307
 
332
- Unit "${unit_title}" failed 3+ times. Manual intervention required.
333
- Error history: ${error_summaries}
334
- Branch: batch/${slug}/unit-${unit_number}
308
+ Unit "{unit_title}" failed 3+ times. Manual intervention required.
309
+ Branch: batch/{slug}/unit-{unit_number}
310
+ Error history:
311
+ {error_summaries}
335
312
  ```
336
- </step>
337
313
 
338
- <step name="report">
314
+ ## Step 8 — Final Report
315
+
339
316
  After all units are resolved (complete or escalated):
340
317
 
341
318
  ```
@@ -343,77 +320,81 @@ After all units are resolved (complete or escalated):
343
320
  MAXSIM > BATCH EXECUTION COMPLETE
344
321
  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
345
322
 
346
- Task: ${DESCRIPTION}
347
- Units: ${completed_count}/${unit_count} complete
323
+ Task: {description}
324
+ Units: {completed}/{total} complete
348
325
 
349
326
  | # | Unit | Status | PR |
350
327
  |---|------|--------|----|
351
- ${final_status_table}
328
+ {final_status_table}
352
329
 
353
- ${failed_count > 0 ? "Failed units require manual attention." : "All units completed successfully."}
330
+ {failed_count > 0 ? "Failed units require manual attention." : "All units completed."}
354
331
  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
355
332
  ```
356
333
 
357
- Update STATE.md with batch completion:
334
+ Update STATE.md:
358
335
  ```bash
359
- node ~/.claude/maxsim/bin/maxsim-tools.cjs state add-decision --phase "batch" --summary "Batch complete: ${completed_count}/${unit_count} units done. PRs: ${pr_list}"
336
+ node ~/.claude/maxsim/bin/maxsim-tools.cjs state add-decision \
337
+ --phase "batch" \
338
+ --summary "Batch complete: {completed}/{total} units done. PRs: {pr_list}"
360
339
  ```
361
- </step>
362
340
 
363
- <step name="commit_metadata">
364
- Store batch record in `.planning/batch/` directory.
341
+ ## Step 9 — Commit Batch Metadata
365
342
 
366
- Update DECOMPOSITION.md frontmatter status:
367
- - All units done: `status: complete`
343
+ Update `DECOMPOSITION.md` status:
344
+ - All done: `status: complete`
368
345
  - Some failed: `status: partial`
369
346
 
370
- Create `.planning/batch/${slug}/RESULTS.md`:
347
+ Write `.planning/batch/{slug}/RESULTS.md`:
371
348
  ```markdown
372
349
  ---
373
- task: ${DESCRIPTION}
374
- date: ${date}
375
- status: ${all_done ? "complete" : "partial"}
376
- units_total: ${unit_count}
377
- units_complete: ${completed_count}
378
- units_failed: ${failed_count}
350
+ task: {description}
351
+ date: {date}
352
+ status: {complete | partial}
353
+ units_total: {N}
354
+ units_complete: {completed}
355
+ units_failed: {failed}
379
356
  ---
380
357
 
381
358
  ## Results
382
359
 
383
360
  | # | Unit | Status | PR | Branch |
384
361
  |---|------|--------|----|--------|
385
- ${results_table}
362
+ {results_table}
386
363
 
387
364
  ## Failed Units
388
- ${failed_summaries or "None"}
365
+ {failed_summaries or "None."}
389
366
  ```
390
367
 
391
368
  Commit metadata:
392
369
  ```bash
393
- node ~/.claude/maxsim/bin/maxsim-tools.cjs commit "docs(batch): ${DESCRIPTION}" --files .planning/batch/${slug}/DECOMPOSITION.md .planning/batch/${slug}/RESULTS.md .planning/STATE.md
370
+ node ~/.claude/maxsim/bin/maxsim-tools.cjs commit \
371
+ "docs(batch): {description}" \
372
+ --files .planning/batch/{slug}/DECOMPOSITION.md \
373
+ .planning/batch/{slug}/RESULTS.md \
374
+ .planning/STATE.md
394
375
  ```
395
- </step>
396
376
 
397
377
  </process>
398
378
 
399
379
  <success_criteria>
400
- - [ ] `.planning/` and git repository verified
401
- - [ ] User provides task description
402
- - [ ] Decomposition produces 3+ independent units
403
- - [ ] File independence validated across all unit pairs
404
- - [ ] Decision recorded in STATE.md
405
- - [ ] One worktree agent spawned per unit
380
+ - [ ] .planning/ and git repository verified
381
+ - [ ] Decomposition produces 3+ independent units (or user confirms fewer)
382
+ - [ ] File independence validated across all unit pairs before spawning
383
+ - [ ] Plan Mode shown and confirmed before any agents spawned
384
+ - [ ] All agents spawned in a SINGLE message block using Agent tool (not Task)
385
+ - [ ] Every agent has isolation="worktree" and run_in_background=true
406
386
  - [ ] Each agent creates its own branch and PR
407
- - [ ] Progress tracked with status table
408
- - [ ] Failed units retried once before escalation
387
+ - [ ] Progress tracked with live status table
388
+ - [ ] Failed units retried with fix agent (max 2 retries before escalation)
389
+ - [ ] Merge conflicts escalated to user immediately
409
390
  - [ ] Final report lists all PRs and flags failures
410
- - [ ] Batch metadata committed to `.planning/batch/`
391
+ - [ ] Batch metadata committed to .planning/batch/
411
392
  </success_criteria>
412
393
 
413
394
  <failure_handling>
414
- - **classifyHandoffIfNeeded false failure:** Agent reports "failed" with `classifyHandoffIfNeeded is not defined` error — Claude Code bug, not MAXSIM. Check if branch exists and has commits. If so, treat as success.
415
- - **Independence validation fails twice:** Stop, present overlaps to user, ask for manual decomposition guidance.
416
- - **Agent fails to create PR:** Check if `gh` CLI is authenticated. If not, report branch name for manual PR creation.
417
- - **All agents fail:** Likely systemic issue (git config, permissions). Stop and report for investigation.
418
- - **Fewer than 3 units identified:** Suggest `/maxsim:quick` instead. Do not force worktree overhead for small tasks.
395
+ - **Independence validation fails twice:** Present overlaps to user. Ask for manual decomposition guidance.
396
+ - **Agent fails to create PR:** Check `gh` CLI auth. If not authenticated, report branch name for manual PR creation.
397
+ - **All agents fail:** Likely systemic issue (git config, permissions, worktree limit). Stop and report for investigation.
398
+ - **Fewer than 3 independent units:** Suggest `/maxsim:quick`. Do not force worktree overhead for small tasks.
399
+ - **classifyHandoffIfNeeded error:** Claude Code runtime bug (not MAXSIM). Check if branch has commits. If commits exist, treat as success and extract PR URL from branch.
419
400
  </failure_handling>