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.
- package/README.md +316 -288
- package/dist/assets/CHANGELOG.md +14 -0
- package/dist/assets/hooks/maxsim-capture-learnings.cjs +128 -0
- package/dist/assets/hooks/maxsim-capture-learnings.cjs.map +1 -0
- package/dist/assets/hooks/maxsim-check-update.cjs +126 -88
- package/dist/assets/hooks/maxsim-check-update.cjs.map +1 -1
- package/dist/assets/hooks/maxsim-notification-sound.cjs +87 -43
- package/dist/assets/hooks/maxsim-notification-sound.cjs.map +1 -1
- package/dist/assets/hooks/maxsim-statusline.cjs +45 -171
- package/dist/assets/hooks/maxsim-statusline.cjs.map +1 -1
- package/dist/assets/hooks/maxsim-stop-sound.cjs +86 -43
- package/dist/assets/hooks/maxsim-stop-sound.cjs.map +1 -1
- package/dist/assets/hooks/maxsim-sync-reminder.cjs +72 -21
- package/dist/assets/hooks/maxsim-sync-reminder.cjs.map +1 -1
- package/dist/assets/templates/agents/AGENTS.md +62 -51
- package/dist/assets/templates/agents/executor.md +44 -59
- package/dist/assets/templates/agents/planner.md +36 -31
- package/dist/assets/templates/agents/researcher.md +35 -43
- package/dist/assets/templates/agents/verifier.md +29 -31
- package/dist/assets/templates/commands/maxsim/debug.md +20 -154
- package/dist/assets/templates/commands/maxsim/execute.md +19 -33
- package/dist/assets/templates/commands/maxsim/go.md +21 -20
- package/dist/assets/templates/commands/maxsim/help.md +5 -14
- package/dist/assets/templates/commands/maxsim/init.md +18 -40
- package/dist/assets/templates/commands/maxsim/plan.md +22 -37
- package/dist/assets/templates/commands/maxsim/progress.md +15 -16
- package/dist/assets/templates/commands/maxsim/quick.md +18 -29
- package/dist/assets/templates/commands/maxsim/settings.md +18 -26
- package/dist/assets/templates/references/continuation-format.md +2 -4
- package/dist/assets/templates/references/model-profiles.md +2 -2
- package/dist/assets/templates/references/planning-config.md +10 -11
- package/dist/assets/templates/references/self-improvement.md +120 -0
- package/dist/assets/templates/rules/conventions.md +1 -1
- package/dist/assets/templates/rules/verification-protocol.md +1 -1
- package/dist/assets/templates/skills/brainstorming/SKILL.md +35 -26
- package/dist/assets/templates/skills/code-review/SKILL.md +78 -55
- package/dist/assets/templates/skills/commit-conventions/SKILL.md +70 -36
- package/dist/assets/templates/skills/github-operations/SKILL.md +142 -0
- package/dist/assets/templates/skills/handoff-contract/SKILL.md +62 -28
- package/dist/assets/templates/skills/maxsim-batch/SKILL.md +68 -42
- package/dist/assets/templates/skills/maxsim-simplify/SKILL.md +65 -40
- package/dist/assets/templates/skills/project-memory/SKILL.md +121 -0
- package/dist/assets/templates/skills/research/SKILL.md +126 -0
- package/dist/assets/templates/skills/roadmap-writing/SKILL.md +71 -68
- package/dist/assets/templates/skills/systematic-debugging/SKILL.md +37 -25
- package/dist/assets/templates/skills/tdd/SKILL.md +36 -39
- package/dist/assets/templates/skills/using-maxsim/SKILL.md +69 -55
- package/dist/assets/templates/skills/verification/SKILL.md +167 -0
- package/dist/assets/templates/workflows/batch.md +249 -268
- package/dist/assets/templates/workflows/diagnose-issues.md +225 -151
- package/dist/assets/templates/workflows/execute-plan.md +191 -981
- package/dist/assets/templates/workflows/execute.md +350 -309
- package/dist/assets/templates/workflows/go.md +119 -138
- package/dist/assets/templates/workflows/health.md +71 -114
- package/dist/assets/templates/workflows/help.md +85 -147
- package/dist/assets/templates/workflows/init-existing.md +180 -1373
- package/dist/assets/templates/workflows/init.md +53 -165
- package/dist/assets/templates/workflows/new-milestone.md +91 -334
- package/dist/assets/templates/workflows/new-project.md +165 -1384
- package/dist/assets/templates/workflows/plan-create.md +182 -73
- package/dist/assets/templates/workflows/plan-discuss.md +89 -82
- package/dist/assets/templates/workflows/plan-research.md +191 -85
- package/dist/assets/templates/workflows/plan.md +122 -58
- package/dist/assets/templates/workflows/progress.md +76 -310
- package/dist/assets/templates/workflows/quick.md +70 -495
- package/dist/assets/templates/workflows/sdd.md +231 -221
- package/dist/assets/templates/workflows/settings.md +90 -120
- package/dist/assets/templates/workflows/verify-phase.md +296 -258
- package/dist/cli.cjs +17 -23465
- package/dist/cli.cjs.map +1 -1
- package/dist/install.cjs +356 -8358
- package/dist/install.cjs.map +1 -1
- package/package.json +16 -22
- package/dist/assets/templates/skills/agent-system-map/SKILL.md +0 -92
- package/dist/assets/templates/skills/evidence-collection/SKILL.md +0 -87
- package/dist/assets/templates/skills/github-artifact-protocol/SKILL.md +0 -67
- package/dist/assets/templates/skills/github-tools-guide/SKILL.md +0 -89
- package/dist/assets/templates/skills/input-validation/SKILL.md +0 -51
- package/dist/assets/templates/skills/memory-management/SKILL.md +0 -75
- package/dist/assets/templates/skills/research-methodology/SKILL.md +0 -137
- package/dist/assets/templates/skills/sdd/SKILL.md +0 -91
- package/dist/assets/templates/skills/tool-priority-guide/SKILL.md +0 -80
- package/dist/assets/templates/skills/verification-before-completion/SKILL.md +0 -71
- package/dist/assets/templates/skills/verification-gates/SKILL.md +0 -169
- package/dist/assets/templates/workflows/discuss-phase.md +0 -683
- package/dist/assets/templates/workflows/research-phase.md +0 -73
- package/dist/assets/templates/workflows/verify-work.md +0 -572
- package/dist/core-D5zUr9cb.cjs +0 -4305
- package/dist/core-D5zUr9cb.cjs.map +0 -1
- package/dist/skills-CjFWZIGM.cjs +0 -6824
- 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.
|
|
5
|
-
3.
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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
|
|
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
|
|
36
|
+
MAXSIM > BATCH PARALLEL EXECUTION
|
|
63
37
|
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
64
38
|
|
|
65
|
-
|
|
66
|
-
|
|
39
|
+
Task: {description from $ARGUMENTS}
|
|
40
|
+
Base branch: {BASE_BRANCH}
|
|
67
41
|
```
|
|
68
|
-
</step>
|
|
69
42
|
|
|
70
|
-
|
|
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
|
-
|
|
79
|
-
**Description:** ${DESCRIPTION}
|
|
80
|
-
**Base branch:** ${BASE_BRANCH}
|
|
47
|
+
Spawn planner to produce a decomposition:
|
|
81
48
|
|
|
82
|
-
|
|
83
|
-
|
|
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
|
-
|
|
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
|
|
108
|
+
1. Verify `.planning/batch/{slug}/DECOMPOSITION.md` exists
|
|
142
109
|
2. Extract unit count
|
|
143
|
-
3. If
|
|
144
|
-
4. Report: "Decomposition complete:
|
|
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
|
-
|
|
147
|
-
</step>
|
|
113
|
+
## Step 3 — Validate Independence
|
|
148
114
|
|
|
149
|
-
|
|
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
|
|
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
|
|
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
|
|
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
|
-
|
|
175
|
-
|
|
176
|
-
|
|
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
|
-
|
|
179
|
-
${overlap_table}
|
|
143
|
+
## Step 4 — Plan Mode — Confirm Before Spawning
|
|
180
144
|
|
|
181
|
-
|
|
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
|
-
|
|
150
|
+
Task: {description}
|
|
151
|
+
Units: {N} independent worktree agents
|
|
152
|
+
Base branch: {BASE_BRANCH}
|
|
196
153
|
|
|
197
|
-
|
|
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
|
-
|
|
205
|
-
Record the decomposition decision in STATE.md:
|
|
164
|
+
Wait for user confirmation. **Exit Plan Mode after user confirms.**
|
|
206
165
|
|
|
207
|
-
|
|
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
|
-
|
|
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
|
|
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
|
|
178
|
+
For EACH unit (all in one message block):
|
|
224
179
|
|
|
225
180
|
```
|
|
226
|
-
|
|
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
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
- .
|
|
248
|
-
- .
|
|
249
|
-
</files_to_read>
|
|
250
|
-
|
|
251
|
-
<instructions>
|
|
252
|
-
1. Create branch:
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
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
|
-
|
|
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 | #
|
|
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
|
|
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.
|
|
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
|
-
|
|
293
|
-
</step>
|
|
266
|
+
## Step 7 — Handle Failures
|
|
294
267
|
|
|
295
|
-
|
|
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
|
-
|
|
271
|
+
Agent(
|
|
301
272
|
subagent_type="executor",
|
|
302
273
|
model="{executor_model}",
|
|
303
274
|
isolation="worktree",
|
|
304
275
|
prompt="
|
|
305
|
-
Unit
|
|
306
|
-
|
|
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
|
-
|
|
309
|
-
|
|
310
|
-
</unit_spec>
|
|
283
|
+
Original unit spec:
|
|
284
|
+
{unit_spec}
|
|
311
285
|
|
|
312
|
-
Fix the
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
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:**
|
|
294
|
+
**Merge conflict detected:** Decomposition had hidden overlap. Escalate to user:
|
|
320
295
|
```
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
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
|
|
304
|
+
**3+ failures on same unit:** Stop retrying. Escalate:
|
|
329
305
|
```
|
|
330
|
-
## Unit
|
|
306
|
+
## Unit {unit_number} Escalated
|
|
331
307
|
|
|
332
|
-
Unit "
|
|
333
|
-
|
|
334
|
-
|
|
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
|
-
|
|
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:
|
|
347
|
-
Units:
|
|
323
|
+
Task: {description}
|
|
324
|
+
Units: {completed}/{total} complete
|
|
348
325
|
|
|
349
326
|
| # | Unit | Status | PR |
|
|
350
327
|
|---|------|--------|----|
|
|
351
|
-
|
|
328
|
+
{final_status_table}
|
|
352
329
|
|
|
353
|
-
|
|
330
|
+
{failed_count > 0 ? "Failed units require manual attention." : "All units completed."}
|
|
354
331
|
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
355
332
|
```
|
|
356
333
|
|
|
357
|
-
Update STATE.md
|
|
334
|
+
Update STATE.md:
|
|
358
335
|
```bash
|
|
359
|
-
node ~/.claude/maxsim/bin/maxsim-tools.cjs state add-decision
|
|
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
|
-
|
|
364
|
-
Store batch record in `.planning/batch/` directory.
|
|
341
|
+
## Step 9 — Commit Batch Metadata
|
|
365
342
|
|
|
366
|
-
Update DECOMPOSITION.md
|
|
367
|
-
- All
|
|
343
|
+
Update `DECOMPOSITION.md` status:
|
|
344
|
+
- All done: `status: complete`
|
|
368
345
|
- Some failed: `status: partial`
|
|
369
346
|
|
|
370
|
-
|
|
347
|
+
Write `.planning/batch/{slug}/RESULTS.md`:
|
|
371
348
|
```markdown
|
|
372
349
|
---
|
|
373
|
-
task:
|
|
374
|
-
date:
|
|
375
|
-
status:
|
|
376
|
-
units_total:
|
|
377
|
-
units_complete:
|
|
378
|
-
units_failed:
|
|
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
|
-
|
|
362
|
+
{results_table}
|
|
386
363
|
|
|
387
364
|
## Failed Units
|
|
388
|
-
|
|
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
|
|
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
|
-
- [ ]
|
|
401
|
-
- [ ]
|
|
402
|
-
- [ ]
|
|
403
|
-
- [ ]
|
|
404
|
-
- [ ]
|
|
405
|
-
- [ ]
|
|
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
|
|
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
|
|
391
|
+
- [ ] Batch metadata committed to .planning/batch/
|
|
411
392
|
</success_criteria>
|
|
412
393
|
|
|
413
394
|
<failure_handling>
|
|
414
|
-
- **
|
|
415
|
-
- **
|
|
416
|
-
- **
|
|
417
|
-
- **
|
|
418
|
-
- **
|
|
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>
|