maxsimcli 5.0.7 → 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 +101 -99
  2. package/dist/assets/CHANGELOG.md +7 -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,1090 +1,300 @@
1
1
  <purpose>
2
- Execute a phase plan (loaded from GitHub issue comment or local PLAN.md) and post the outcome summary as a GitHub comment. Per-task board transitions keep the project board current throughout execution.
2
+ Template prompt for individual plan execution by a spawned executor agent. This file defines what each executor agent receives and must produce. It is self-contained the executor has no access to the orchestrator's context and must work from what is explicitly provided here.
3
+
4
+ Executor agents run in isolated git worktrees. Each agent executes all tasks in one plan, commits atomically per task, updates the GitHub board, and posts a summary comment on the phase issue.
3
5
  </purpose>
4
6
 
5
- <required_reading>
6
- Read STATE.md before any operation to load project context.
7
- Read config.json for planning behavior settings.
7
+ <agent_type>executor</agent_type>
8
+ <isolation>worktree</isolation>
8
9
 
9
- @~/.claude/maxsim/references/git-integration.md
10
+ <required_reading>
11
+ Read these files immediately upon start, before any other action:
12
+ - .planning/STATE.md — project state and position
13
+ - .planning/config.json — planning behavior settings (if exists)
14
+ - ./CLAUDE.md — project-specific coding conventions (if exists)
10
15
  </required_reading>
11
16
 
12
- MAXSIM provides CLI commands (`github create-phase`, `github list-phases`, etc.) for structured operations.
13
-
14
17
  <process>
15
18
 
16
- <step name="init_context" priority="first">
17
- Load execution context (paths only to minimize orchestrator context):
18
-
19
- ```bash
20
- INIT=$(node ~/.claude/maxsim/bin/maxsim-tools.cjs init execute-phase "${PHASE}")
21
- ```
22
-
23
- Extract from init JSON: `executor_model`, `commit_docs`, `phase_dir`, `phase_number`, `plans`, `summaries`, `incomplete_plans`, `state_path`, `config_path`, `phase_issue_number`, `task_mappings`.
24
-
25
- If `.planning/` missing: error.
26
- </step>
19
+ ## Step 1 — Load Context
27
20
 
28
- <step name="load_plan_from_github">
29
-
30
- ## Plan Loading -- GitHub First
31
-
32
- When the orchestrator passes `github_context` (phase_issue_number and plan_comment_body), use it directly:
33
-
34
- 1. The plan content is in `plan_comment_body` passed from the orchestrator. Parse it in memory -- do NOT read a local PLAN.md file.
35
- 2. Extract frontmatter fields: `wave`, `autonomous`, `objective`, `requirements`, `task_mappings`, `gap_closure`.
36
- 3. Extract the task list and verification criteria from the comment body.
37
-
38
- **External edit detection (WIRE-06):** Before beginning execution, check if the plan comment was modified since the orchestrator read it:
21
+ Load execution context:
39
22
 
40
23
  ```bash
41
- node ~/.claude/maxsim/bin/maxsim-tools.cjs github detect-external-edits --phase-number "$PHASE_NUMBER"
24
+ INIT=$(node ~/.claude/maxsim/bin/maxsim-tools.cjs init execute-phase "${PHASE_NUMBER}")
42
25
  ```
43
26
 
44
- If external edits detected: warn user and offer to re-read the plan before proceeding.
27
+ Extract: `phase_dir`, `phase_number`, `phase_name`, `executor_model`, `commit_docs`, `phase_issue_number`.
45
28
 
46
- **If no GitHub context is available:**
47
-
48
- GitHub Issues is the source of truth for plans. If no `phase_issue_number` or `plan_comment_body` was passed, report the error and exit:
49
-
50
- ```
51
- Plan content must be provided via GitHub Issue comment. Ensure GitHub integration is configured.
52
- ```
53
- </step>
29
+ If `.planning/` is missing: exit immediately with `RESULT: FAIL — .planning/ directory not found`.
54
30
 
55
- <step name="record_start_time">
31
+ Record start time:
56
32
  ```bash
57
33
  PLAN_START_TIME=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
58
34
  PLAN_START_EPOCH=$(date +%s)
59
35
  ```
60
- </step>
61
36
 
62
- <step name="parse_segments">
37
+ ## Step 2 — Parse Plan Content
63
38
 
64
- Identify checkpoint type from plan content:
39
+ The plan content is provided in the orchestrator's prompt via `<plan_content>` and `<github_context>` blocks.
65
40
 
66
- ```bash
67
- # If plan loaded from GitHub comment, scan comment body for checkpoint markers
68
- # If plan loaded from local file:
69
- grep -n "type=\"checkpoint" .planning/phases/XX-name/{phase}-{plan}-PLAN.md
70
- ```
71
-
72
- **Routing by checkpoint type:**
73
-
74
- | Checkpoints | Pattern | Execution |
75
- |-------------|---------|-----------|
76
- | None | A (autonomous) | Single subagent: full plan + post SUMMARY comment + commit |
77
- | Verify-only | B (segmented) | Segments between checkpoints. After none/human-verify → SUBAGENT. After decision/human-action → MAIN |
78
- | Decision | C (main) | Execute entirely in main context |
41
+ Parse from the plan content:
42
+ - **Plan ID** e.g. `03-02`
43
+ - **Objective** one-line description of what this plan builds
44
+ - **Wave** — wave number (for ordering context only)
45
+ - **Task list** — ordered list of tasks, each with: name, description, files to modify, acceptance criteria, done criteria
46
+ - **Success criteria** — overall plan success criteria
47
+ - **Task sub-issue numbers** — from `task_mappings` in github_context
79
48
 
80
- **Pattern A:** init_agent_tracking spawn Task(subagent_type="executor", model=executor_model) with prompt: execute plan (content from GitHub comment or local path), autonomous, all tasks + post SUMMARY comment + commit, follow deviation/auth rules, move task sub-issues on board as each task starts/completes, report: plan name, tasks, summary comment URL, commit hash → track agent_id → wait → update tracking → report.
49
+ Detect checkpoint type from plan content:
50
+ - No checkpoints → **Pattern A** (autonomous, single pass)
51
+ - Checkpoint markers present → **Pattern B** (segmented execution)
81
52
 
82
- **Pattern B:** Execute segment-by-segment. Autonomous segments: spawn subagent for assigned tasks only (no SUMMARY/commit). Checkpoints: main context. After all segments: aggregate, post SUMMARY as GitHub comment, commit. See segment_execution.
53
+ ## Step 3 Execute Tasks (Pattern A Autonomous)
83
54
 
84
- **Pattern C:** Execute in main using standard flow (step name="execute").
55
+ Execute all tasks in sequence. For each task:
85
56
 
86
- Fresh context per subagent preserves peak quality. Main context stays lean.
87
- </step>
57
+ ### 3a Announce task start
88
58
 
89
- <step name="init_agent_tracking">
59
+ Move task sub-issue to "In Progress" on the board:
90
60
  ```bash
91
- if [ ! -f .planning/agent-history.json ]; then
92
- echo '{"version":"1.0","max_entries":50,"entries":[]}' > .planning/agent-history.json
93
- fi
94
- rm -f .planning/current-agent-id.txt
95
- if [ -f .planning/current-agent-id.txt ]; then
96
- INTERRUPTED_ID=$(cat .planning/current-agent-id.txt)
97
- echo "Found interrupted agent: $INTERRUPTED_ID"
98
- fi
99
- ```
100
-
101
- If interrupted: ask user to resume (Task `resume` parameter) or start fresh.
102
-
103
- **Tracking protocol:** On spawn: write agent_id to `current-agent-id.txt`, append to agent-history.json: `{"agent_id":"[id]","task_description":"[desc]","phase":"[phase]","plan":"[plan]","segment":[num|null],"timestamp":"[ISO]","status":"spawned","completion_timestamp":null}`. On completion: status → "completed", set completion_timestamp, delete current-agent-id.txt. Prune: if entries > max_entries, remove oldest "completed" (never "spawned").
104
-
105
- Run for Pattern A/B before spawning. Pattern C: skip.
106
- </step>
107
-
108
- <step name="segment_execution">
109
- Pattern B only (verify-only checkpoints). Skip for A/C.
110
-
111
- 1. Parse segment map: checkpoint locations and types
112
- 2. Per segment:
113
- - Subagent route: spawn executor for assigned tasks only. Prompt: task range, plan content (from GitHub comment or local path), read full plan for context, execute assigned tasks, track deviations, move task sub-issues to "In Progress" when started and "Done" when completed, NO SUMMARY/commit. Track via agent protocol.
114
- - Main route: execute tasks using standard flow (step name="execute")
115
- 3. After ALL segments: aggregate files/deviations/decisions → post SUMMARY as GitHub comment (`github post-comment` with type=summary) → commit → self-check:
116
- - Verify key-files.created exist on disk with `[ -f ]`
117
- - Check `git log --oneline --all --grep="{phase}-{plan}"` returns ≥1 commit
118
- - Check for `## Self-Check: PASSED` or `## Self-Check: FAILED` and append to summary comment body
119
-
120
- **Known Claude Code bug (classifyHandoffIfNeeded):** If any segment agent reports "failed" with `classifyHandoffIfNeeded is not defined`, this is a Claude Code runtime bug — not a real failure. Run spot-checks; if they pass, treat as successful.
121
- </step>
122
-
123
- <step name="load_prompt">
124
-
125
- The plan content IS the execution instructions. Follow exactly. If plan references CONTEXT.md: honor user's vision throughout.
126
-
127
- The plan content is already in memory from the load_plan_from_github step (loaded from the GitHub Issue comment passed by the orchestrator).
128
- </step>
129
-
130
- <step name="pre_execution_gates">
131
- Validate requirements before execution. These gates ensure spec-driven development.
132
-
133
- **Gate G1: Requirement Existence** — All requirement IDs from the plan's frontmatter must exist in REQUIREMENTS.md.
134
-
135
- ```bash
136
- # Extract requirement IDs from plan frontmatter (in memory if loaded from GitHub, or from file)
137
- REQ_IDS=$(grep "^requirements:" "$PLAN_PATH" | sed 's/requirements:\s*\[//;s/\]//;s/,/ /g;s/"//g;s/'\''//g' | tr -s ' ')
138
- if [ -n "$REQ_IDS" ]; then
139
- G1_RESULT=$(node ~/.claude/maxsim/bin/maxsim-tools.cjs verify requirement-existence $REQ_IDS)
140
- G1_VALID=$(echo "$G1_RESULT" | node -e "process.stdin.on('data',d=>console.log(JSON.parse(d).valid))")
141
- if [ "$G1_VALID" != "true" ]; then
142
- G1_MISSING=$(echo "$G1_RESULT" | node -e "process.stdin.on('data',d=>console.log(JSON.parse(d).missing.join(', ')))")
143
- echo "GATE G1 FAILED: Requirements not found in REQUIREMENTS.md: $G1_MISSING"
144
- echo "Fix: Add missing requirements to REQUIREMENTS.md or update plan frontmatter."
145
- # STOP execution — this is a hard gate
146
- fi
147
- fi
148
- ```
149
-
150
- **Gate G2: Requirement Status** — Requirement IDs must not already be marked Complete.
151
-
152
- ```bash
153
- if [ -n "$REQ_IDS" ]; then
154
- G2_RESULT=$(node ~/.claude/maxsim/bin/maxsim-tools.cjs verify requirement-status $REQ_IDS)
155
- G2_VALID=$(echo "$G2_RESULT" | node -e "process.stdin.on('data',d=>console.log(JSON.parse(d).valid))")
156
- if [ "$G2_VALID" != "true" ]; then
157
- G2_COMPLETE=$(echo "$G2_RESULT" | node -e "process.stdin.on('data',d=>console.log(JSON.parse(d).already_complete.join(', ')))")
158
- echo "GATE G2 WARNING: Requirements already marked complete: $G2_COMPLETE"
159
- echo "This plan may be re-implementing completed work. Proceeding with warning."
160
- # WARNING only — log but continue (re-execution scenarios are valid)
161
- fi
162
- fi
163
- ```
164
- </step>
165
-
166
- <step name="previous_phase_check">
167
- ```bash
168
- node ~/.claude/maxsim/bin/maxsim-tools.cjs phases list --type summaries --raw
169
- # Extract the second-to-last summary from the JSON result
170
- ```
171
- If previous phase has unresolved issues (check summary comments on phase issue for "Issues Encountered" / "Next Phase Readiness" blockers): AskUserQuestion(header="Previous Issues", options: "Proceed anyway" | "Address first" | "Review previous").
172
- </step>
173
-
174
- <step name="execute">
175
- Deviations are normal — handle via rules below.
176
-
177
- 1. Read @context files from prompt
178
- 2. Per task:
179
-
180
- **Before starting each task (WIRE-04 board transition):**
181
- - Look up the task's sub-issue number from `task_mappings` in the GitHub context.
182
- - Move the task sub-issue to "In Progress":
183
- ```bash
184
- node ~/.claude/maxsim/bin/maxsim-tools.cjs github move-issue --issue-number $TASK_SUB_ISSUE_NUMBER --status "In Progress"
185
- ```
186
-
187
- - `type="auto"`: if `tdd="true"` → TDD execution. Implement with deviation rules + auth gates. Verify done criteria. Commit (see task_commit). Track hash for Summary.
188
- - `type="checkpoint:*"`: STOP → checkpoint_protocol → wait for user → continue only after confirmation.
189
-
190
- **After each task completes successfully (WIRE-04 board transition):**
191
- - Post task completion details on the task sub-issue:
192
- ```bash
193
- node ~/.claude/maxsim/bin/maxsim-tools.cjs github post-completion --issue-number $TASK_SUB_ISSUE_NUMBER --commit-sha "$TASK_COMMIT" --files-changed "file1.ts,file2.ts"
194
- ```
195
- - Close the task sub-issue and move to "Done":
196
- ```bash
197
- node ~/.claude/maxsim/bin/maxsim-tools.cjs github close-issue --issue-number $TASK_SUB_ISSUE_NUMBER
198
- node ~/.claude/maxsim/bin/maxsim-tools.cjs github move-issue --issue-number $TASK_SUB_ISSUE_NUMBER --status "Done"
199
- ```
200
-
201
- 3. Run `<verification>` checks
202
- 4. Confirm `<success_criteria>` met
203
- 5. Document deviations in Summary
204
- </step>
205
-
206
- <authentication_gates>
207
-
208
- ## Authentication Gates
209
-
210
- Auth errors during execution are NOT failures — they're expected interaction points.
211
-
212
- **Indicators:** "Not authenticated", "Unauthorized", 401/403, "Please run {tool} login", "Set {ENV_VAR}"
213
-
214
- **Protocol:**
215
- 1. Recognize auth gate (not a bug)
216
- 2. STOP task execution
217
- 3. Create dynamic checkpoint:human-action with exact auth steps
218
- 4. Wait for user to authenticate
219
- 5. Verify credentials work
220
- 6. Retry original task
221
- 7. Continue normally
222
-
223
- **Example:** `vercel --yes` → "Not authenticated" → checkpoint asking user to `vercel login` → verify with `vercel whoami` → retry deploy → continue
224
-
225
- **In Summary:** Document as normal flow under "## Authentication Gates", not as deviations.
226
-
227
- </authentication_gates>
228
-
229
- <deviation_rules>
230
-
231
- ## Deviation Rules
232
-
233
- You WILL discover unplanned work. Apply automatically, track all for Summary.
234
-
235
- | Rule | Trigger | Action | Permission |
236
- |------|---------|--------|------------|
237
- | **1: Bug** | Broken behavior, errors, wrong queries, type errors, security vulns, race conditions, leaks | Fix → test → verify → track `[Rule 1 - Bug]` | Auto |
238
- | **2: Missing Critical** | Missing essentials: error handling, validation, auth, CSRF/CORS, rate limiting, indexes, logging | Add → test → verify → track `[Rule 2 - Missing Critical]` | Auto |
239
- | **3: Blocking** | Prevents completion: missing deps, wrong types, broken imports, missing env/config/files, circular deps | Fix blocker → verify proceeds → track `[Rule 3 - Blocking]` | Auto |
240
- | **4: Architectural** | Structural change: new DB table, schema change, new service, switching libs, breaking API, new infra | STOP → present decision (below) → track `[Rule 4 - Architectural]` | Ask user |
241
-
242
- **Rule 4 format:**
61
+ node ~/.claude/maxsim/bin/maxsim-tools.cjs github move-issue \
62
+ --issue-number {task_issue_number} --status "In Progress"
243
63
  ```
244
- ⚠️ Architectural Decision Needed
245
-
246
- Current task: [task name]
247
- Discovery: [what prompted this]
248
- Proposed change: [modification]
249
- Why needed: [rationale]
250
- Impact: [what this affects]
251
- Alternatives: [other approaches]
252
64
 
253
- Proceed with proposed change? (yes / different approach / defer)
65
+ Display:
254
66
  ```
255
-
256
- **Priority:** Rule 4 (STOP) > Rules 1-3 (auto) > unsure → Rule 4
257
- **Edge cases:** missing validation → R2 | null crash → R1 | new table → R4 | new column → R1/2
258
- **Heuristic:** Affects correctness/security/completion? → R1-3. Maybe? → R4.
259
-
260
- </deviation_rules>
261
-
262
- <deviation_documentation>
263
-
264
- ## Documenting Deviations
265
-
266
- Summary MUST include deviations section. None? → `## Deviations from Plan\n\nNone - plan executed exactly as written.`
267
-
268
- Per deviation: **[Rule N - Category] Title** — Found during: Task X | Issue | Fix | Files modified | Verification | Commit hash
269
-
270
- End with: **Total deviations:** N auto-fixed (breakdown). **Impact:** assessment.
271
-
272
- </deviation_documentation>
273
-
274
- <tdd_plan_execution>
275
- ## TDD Execution
276
-
277
- For `type: tdd` plans — RED-GREEN-REFACTOR:
278
-
279
- 1. **Infrastructure** (first TDD plan only): detect project, install framework, config, verify empty suite
280
- 2. **RED:** Read `<behavior>` → failing test(s) → run (MUST fail) → commit: `test({phase}-{plan}): add failing test for [feature]`
281
- 3. **GREEN:** Read `<implementation>` → minimal code → run (MUST pass) → commit: `feat({phase}-{plan}): implement [feature]`
282
- 4. **REFACTOR:** Clean up → tests MUST pass → commit: `refactor({phase}-{plan}): clean up [feature]`
283
-
284
- Errors: RED doesn't fail → investigate test/existing feature. GREEN doesn't pass → debug, iterate. REFACTOR breaks → undo.
285
-
286
- See `~/.claude/maxsim/references/tdd.md` for structure.
287
- </tdd_plan_execution>
288
-
289
- <task_commit>
290
- ## Task Commit Protocol
291
-
292
- After each task (verification passed, done criteria met), commit immediately.
293
-
294
- **1. Check:** `git status --short`
295
-
296
- **2. Stage individually** (NEVER `git add .` or `git add -A`):
297
- ```bash
298
- git add src/api/auth.ts
299
- git add src/types/user.ts
300
- ```
301
-
302
- **3. Commit type:**
303
-
304
- | Type | When | Example |
305
- |------|------|---------|
306
- | `feat` | New functionality | feat(08-02): create user registration endpoint |
307
- | `fix` | Bug fix | fix(08-02): correct email validation regex |
308
- | `test` | Test-only (TDD RED) | test(08-02): add failing test for password hashing |
309
- | `refactor` | No behavior change (TDD REFACTOR) | refactor(08-02): extract validation to helper |
310
- | `perf` | Performance | perf(08-02): add database index |
311
- | `docs` | Documentation | docs(08-02): add API docs |
312
- | `style` | Formatting | style(08-02): format auth module |
313
- | `chore` | Config/deps | chore(08-02): add bcrypt dependency |
314
-
315
- **4. Format:** `{type}({phase}-{plan}): {description}` with bullet points for key changes.
316
-
317
- **5. Record hash:**
318
- ```bash
319
- TASK_COMMIT=$(git rev-parse --short HEAD)
320
- TASK_COMMITS+=("Task ${TASK_NUM}: ${TASK_COMMIT}")
67
+ ## Task {N}/{total}: {task_name}
68
+ Files: {files_to_modify}
321
69
  ```
322
70
 
323
- </task_commit>
324
-
325
- <step name="checkpoint_protocol">
326
- On `type="checkpoint:*"`: automate everything possible first. Checkpoints are for verification/decisions only.
327
-
328
- Display: `CHECKPOINT: [Type]` box → Progress {X}/{Y} → Task name → type-specific content → `YOUR ACTION: [signal]`
329
-
330
- | Type | Content | Resume signal |
331
- |------|---------|---------------|
332
- | human-verify (90%) | What was built + verification steps (commands/URLs) | "approved" or describe issues |
333
- | decision (9%) | Decision needed + context + options with pros/cons | "Select: option-id" |
334
- | human-action (1%) | What was automated + ONE manual step + verification plan | "done" |
71
+ ### 3b — Implement task
335
72
 
336
- After response: verify if specified. Pass continue. Fail inform, wait. WAIT for user — do NOT hallucinate completion.
73
+ Read all files listed in the task's `files_to_modify` list using the Read tool.
337
74
 
338
- See ~/.claude/maxsim/references/checkpoints.md for details.
339
- </step>
75
+ Implement the changes required by the task description and acceptance criteria.
340
76
 
341
- <step name="checkpoint_return_for_orchestrator">
342
- When spawned via Task and hitting checkpoint: return structured state (cannot interact with user directly).
77
+ Conventions (from CLAUDE.md if present, otherwise defaults):
78
+ - Follow existing code style and patterns
79
+ - No dead code, no placeholder comments
80
+ - All logic must be complete and functional (no TODOs)
81
+ - Handle errors explicitly
82
+ - Write tests if the task requires them or if the project has a test suite
343
83
 
344
- **Required return:** 1) Completed Tasks table (hashes + files) 2) Current Task (what's blocking) 3) Checkpoint Details (user-facing content) 4) Awaiting (what's needed from user)
84
+ ### 3c Verify before commit
345
85
 
346
- Orchestrator parses presents to user spawns fresh continuation with your completed tasks state. You will NOT be resumed. In main context: use checkpoint_protocol above.
347
- </step>
348
-
349
- <step name="verification_failure_gate">
350
- If verification fails: STOP. Present: "Verification failed for Task [X]: [name]. Expected: [criteria]. Actual: [result]." Options: Retry | Skip (mark incomplete) | Stop (investigate). If skipped → SUMMARY "Issues Encountered".
351
-
352
- **On review failure (WIRE-07):** If the task sub-issue was already moved to "Done", reopen and move back:
86
+ Run tests relevant to the changed files:
353
87
  ```bash
354
- node ~/.claude/maxsim/bin/maxsim-tools.cjs github reopen-issue --issue-number $TASK_SUB_ISSUE_NUMBER
355
- node ~/.claude/maxsim/bin/maxsim-tools.cjs github move-issue --issue-number $TASK_SUB_ISSUE_NUMBER --status "In Progress"
356
- TMPFILE=$(mktemp)
357
- cat > "$TMPFILE" << 'BODY_EOF'
358
- ## Review Failure
359
-
360
- Verification failed for this task. Moving back to In Progress.
361
-
362
- **Reason:** {failure details}
363
- **Action needed:** {what needs to be fixed}
364
- BODY_EOF
365
- node ~/.claude/maxsim/bin/maxsim-tools.cjs github post-comment --issue-number $TASK_SUB_ISSUE_NUMBER --body-file "$TMPFILE"
366
- ```
367
- </step>
368
-
369
- <step name="record_completion_time">
370
- ```bash
371
- PLAN_END_TIME=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
372
- PLAN_END_EPOCH=$(date +%s)
373
-
374
- DURATION_SEC=$(( PLAN_END_EPOCH - PLAN_START_EPOCH ))
375
- DURATION_MIN=$(( DURATION_SEC / 60 ))
376
-
377
- if [[ $DURATION_MIN -ge 60 ]]; then
378
- HRS=$(( DURATION_MIN / 60 ))
379
- MIN=$(( DURATION_MIN % 60 ))
380
- DURATION="${HRS}h ${MIN}m"
381
- else
382
- DURATION="${DURATION_MIN} min"
88
+ # Detect and run test runner
89
+ if [ -f package.json ]; then
90
+ # Check for test script
91
+ node -e "const p=require('./package.json'); process.exit(p.scripts?.test ? 0 : 1)" && npm test 2>&1 | tail -20
383
92
  fi
384
93
  ```
385
- </step>
386
-
387
- <step name="generate_user_setup">
388
- If plan frontmatter contains a `user_setup` field: create `{phase}-USER-SETUP.md` using template `~/.claude/maxsim/templates/user-setup.md`. Per service: env vars table, account setup checklist, dashboard config, local dev notes, verification commands. Status "Incomplete". Set `USER_SETUP_CREATED=true`. If empty/missing: skip.
389
-
390
- Also post a reminder comment on the phase issue:
391
- ```bash
392
- TMPFILE=$(mktemp)
393
- cat > "$TMPFILE" << 'BODY_EOF'
394
- ## User Setup Required
395
-
396
- This plan created a USER-SETUP.md with manual steps needed before proceeding.
397
-
398
- **File:** {phase}-USER-SETUP.md
399
- **Services:** {list of services requiring setup}
400
- BODY_EOF
401
- node ~/.claude/maxsim/bin/maxsim-tools.cjs github post-comment --issue-number $PHASE_ISSUE_NUMBER --body-file "$TMPFILE"
402
- ```
403
- </step>
404
94
 
405
- <step name="create_summary">
95
+ Check for anti-patterns in changed files:
96
+ - No `TODO`, `FIXME`, `XXX`, `HACK` comments introduced
97
+ - No placeholder content ("coming soon", "will be here")
98
+ - No stub functions (functions that only `console.log` or `return null`)
99
+ - No empty error handlers
406
100
 
407
- ## Post Summary as GitHub Comment (WIRE-02)
101
+ If tests fail: diagnose and fix. Retry up to 2 times before reporting failure.
408
102
 
409
- Do NOT write a local SUMMARY.md file to `.planning/phases/`. Instead, build the summary content in memory and post it as a GitHub comment.
103
+ ### 3d Commit atomically
410
104
 
411
- Build summary content using the same structure as `~/.claude/maxsim/templates/summary.md`:
105
+ Stage only the specific files changed by this task (NEVER `git add .` or `git add -A`):
412
106
 
413
- **Content to include:**
414
- - `<!-- maxsim:type=summary -->` HTML marker at the top (required for detection)
415
- - Frontmatter: phase, plan, subsystem, tags | requires/provides/affects | tech-stack.added/patterns | key-files.created/modified | key-decisions | requirements-completed (MUST copy `requirements` array from plan frontmatter verbatim) | duration ($DURATION), completed ($PLAN_END_TIME date)
416
- - Title: `# Phase [X] Plan [Y]: [Name] Summary`
417
- - One-liner SUBSTANTIVE: "JWT auth with refresh rotation using jose library" not "Authentication implemented"
418
- - Duration, start/end times, task count, file count
419
- - Next: more plans → "Ready for {next-plan}" | last → "Phase complete, ready for transition"
420
- - Deviations section (required, even if "None")
421
- - Review Cycle section (added after review cycle completes)
422
- - Self-Check result
423
-
424
- Post to the phase issue:
425
107
  ```bash
426
- TMPFILE=$(mktemp)
427
- echo "$SUMMARY_CONTENT" > "$TMPFILE"
428
- node ~/.claude/maxsim/bin/maxsim-tools.cjs github post-comment --issue-number $PHASE_ISSUE_NUMBER --body-file "$TMPFILE" --type summary
429
- ```
430
-
431
- Record the comment URL/ID as `SUMMARY_COMMENT_ID` for future reference.
432
-
433
- GitHub Issues is the source of truth -- summaries are always posted as GitHub comments.
434
- </step>
435
-
436
- <step name="review_cycle">
437
- ## Execute-Review-Simplify-Review Cycle
438
-
439
- After implementation is complete and summary is drafted (not yet posted), run the full review cycle before posting. All four stages must pass before the plan is considered done.
440
-
441
- ### Retry Counter Initialization
442
-
443
- ```
444
- SPEC_ATTEMPTS=0
445
- CODE_ATTEMPTS=0
446
- SIMPLIFY_ATTEMPTS=0
447
- FINAL_ATTEMPTS=0
448
- MAX_REVIEW_ATTEMPTS=3
449
- REVIEW_ESCALATIONS=0
450
- REVIEW_ESCALATION_DETAILS=""
451
- REVIEW_CYCLE_START=$(date +%s)
452
- ```
453
-
454
- ---
455
-
456
- ### Stage 1: Spec Review — Verify implementation matches plan spec.
457
-
108
+ git add {specific_files_changed_by_this_task}
109
+ git commit -m "{type}({phase_number}-{plan_id}): {task_description_as_commit_message}"
110
+ TASK_COMMIT=$(git rev-parse HEAD)
458
111
  ```
459
- SPEC_STAGE_START=$(date +%s)
460
- SPEC_RESULT="PENDING"
461
- ```
462
-
463
- **Retry loop (max MAX_REVIEW_ATTEMPTS):**
464
-
465
- 1. Increment `SPEC_ATTEMPTS`
466
- 2. Spawn verifier:
467
-
468
- ```
469
- Task(
470
- subagent_type="verifier",
471
- prompt="
472
- ## Task: Review for spec compliance
473
-
474
- ## Suggested Skills: verification-gates, evidence-collection
475
-
476
- <objective>
477
- Review plan {phase}-{plan} for spec compliance.
478
- </objective>
479
-
480
- <plan_spec>
481
- Plan content: {plan_content_in_memory or plan file path: {phase_dir}/{phase}-{plan}-PLAN.md}
482
- Summary content: {summary_content_in_memory}
483
- </plan_spec>
484
-
485
- <task_specs>
486
- {For each task in the plan: task number, name, done criteria, files modified}
487
- </task_specs>
488
-
489
- <files_modified>
490
- {List all files created/modified during execution from summary key-files}
491
- </files_modified>
492
-
493
- <instructions>
494
- 1. Read the plan content and extract every task requirement
495
- 2. For each requirement, verify the implementation exists and matches the spec
496
- 3. Check that nothing was added beyond scope
497
- 4. Report: PASS (all requirements met) or FAIL (list unmet requirements)
498
- </instructions>
499
- "
500
- )
501
- ```
502
-
503
- 3. **If PASS:** Set `SPEC_RESULT="PASS"`, record `SPEC_STAGE_END=$(date +%s)`, proceed to Stage 2.
504
-
505
- 4. **If FAIL and SPEC_ATTEMPTS < MAX_REVIEW_ATTEMPTS:** Fix the unmet requirements identified by the verifier, re-stage and commit fixes (`fix({phase}-{plan}): address spec review findings`), update summary content in memory, then loop back to step 1.
506
112
 
507
- 5. **If FAIL and SPEC_ATTEMPTS >= MAX_REVIEW_ATTEMPTS:** Escalate to user:
113
+ Commit type conventions:
114
+ - `feat` — new feature or capability
115
+ - `fix` — bug fix
116
+ - `refactor` — code restructure without behavior change
117
+ - `test` — adding or updating tests
118
+ - `docs` — documentation only
119
+ - `chore` — tooling, config, dependencies
508
120
 
509
- ```markdown
510
- ## Review Escalation: Spec Review Failed After 3 Attempts
121
+ ### 3e — Close task on board
511
122
 
512
- **Stage:** Spec Review
513
- **Attempts:** 3/3
514
- **Last failure reason:** {failure details from verifier}
515
-
516
- The spec review has failed 3 times. This may indicate a fundamental mismatch between the plan spec and the implementation.
517
-
518
- **Options:**
519
- 1. Fix manually and type "retry" to re-run spec review (resets attempt counter)
520
- 2. Type "override" to skip spec review (will be flagged in summary)
521
- 3. Type "abort" to stop execution
522
- ```
523
-
524
- Wait for user response:
525
- - **"retry":** Reset `SPEC_ATTEMPTS=0`, loop back to step 1.
526
- - **"override":** Set `SPEC_RESULT="OVERRIDDEN"`, increment `REVIEW_ESCALATIONS`, record `SPEC_STAGE_END=$(date +%s)`, proceed to Stage 2.
527
- - **"abort":** Stop execution, post partial summary with review status.
528
-
529
- ---
530
-
531
- ### Stage 2: Code Review — Check code quality, security, error handling.
532
-
533
- ```
534
- CODE_STAGE_START=$(date +%s)
535
- CODE_RESULT="PENDING"
123
+ Move task sub-issue to Done and close it:
124
+ ```bash
125
+ node ~/.claude/maxsim/bin/maxsim-tools.cjs github move-issue \
126
+ --issue-number {task_issue_number} --status "Done"
127
+ node ~/.claude/maxsim/bin/maxsim-tools.cjs github close-issue \
128
+ --issue-number {task_issue_number}
536
129
  ```
537
130
 
538
- **Retry loop (max MAX_REVIEW_ATTEMPTS):**
539
-
540
- 1. Increment `CODE_ATTEMPTS`
541
- 2. Spawn verifier:
542
-
131
+ Record task result:
543
132
  ```
544
- Task(
545
- subagent_type="verifier",
546
- prompt="
547
- ## Task: Review code quality
548
-
549
- ## Suggested Skills: code-review
550
-
551
- <objective>
552
- Review plan {phase}-{plan} code quality. Spec compliance already verified.
553
- </objective>
554
-
555
- <files_modified>
556
- {List all files created/modified during execution from summary key-files}
557
- </files_modified>
558
-
559
- <instructions>
560
- 1. Read CLAUDE.md for project conventions
561
- 2. Review every modified file for: correctness, conventions, error handling, security, maintainability
562
- 3. Categorize findings: BLOCKER (must fix), HIGH (should fix), MEDIUM (file for follow-up)
563
- 4. Report: APPROVED (no blockers/high) or BLOCKED (list blocking issues)
564
- </instructions>
565
- "
566
- )
133
+ Task {N}: {task_name} — DONE
134
+ Commit: {TASK_COMMIT}
135
+ Files: {files_changed}
567
136
  ```
568
137
 
569
- 3. **If APPROVED:** Set `CODE_RESULT="APPROVED"`, record `CODE_STAGE_END=$(date +%s)`, proceed to Stage 3.
570
-
571
- 4. **If BLOCKED and CODE_ATTEMPTS < MAX_REVIEW_ATTEMPTS:** Fix all blocker and high-severity issues, re-stage and commit fixes (`fix({phase}-{plan}): address code review findings`), then loop back to step 1.
138
+ ### 3f Repeat for next task
572
139
 
573
- 5. **If BLOCKED and CODE_ATTEMPTS >= MAX_REVIEW_ATTEMPTS:** Escalate to user:
140
+ Pass only the commit hash and files-modified list to the next task context. Do NOT carry forward full diffs or task agent conversations.
574
141
 
575
- ```markdown
576
- ## Review Escalation: Code Review Failed After 3 Attempts
142
+ ## Step 4 — Execute Tasks (Pattern B — Segmented)
577
143
 
578
- **Stage:** Code Review
579
- **Attempts:** 3/3
580
- **Last failure reason:** {blocking issues from verifier}
144
+ For plans with checkpoint markers:
581
145
 
582
- The code review has been blocked 3 times. Remaining issues may require architectural changes or user guidance.
146
+ Execute each segment autonomously (tasks before the checkpoint). At each checkpoint:
147
+ - Pause and surface the checkpoint to the orchestrator
148
+ - Wait for orchestrator/user response before continuing
149
+ - Resume with user feedback as additional context
583
150
 
584
- **Options:**
585
- 1. Fix manually and type "retry" to re-run code review (resets attempt counter)
586
- 2. Type "override" to skip code review (will be flagged in summary)
587
- 3. Type "abort" to stop execution
588
- ```
151
+ After all segments complete, aggregate results for the summary step.
589
152
 
590
- Wait for user response:
591
- - **"retry":** Reset `CODE_ATTEMPTS=0`, loop back to step 1.
592
- - **"override":** Set `CODE_RESULT="OVERRIDDEN"`, increment `REVIEW_ESCALATIONS`, record `CODE_STAGE_END=$(date +%s)`, proceed to Stage 3.
593
- - **"abort":** Stop execution, post partial summary with review status.
153
+ ## Step 5 — Self-Check
594
154
 
595
- **On review failure -- reopen affected task sub-issues (WIRE-07):**
155
+ Before posting the summary, run self-verification:
596
156
 
597
- If the code review identifies failures tied to specific tasks, and those task sub-issues were already closed:
598
157
  ```bash
599
- node ~/.claude/maxsim/bin/maxsim-tools.cjs github reopen-issue --issue-number $TASK_SUB_ISSUE_NUMBER
600
- node ~/.claude/maxsim/bin/maxsim-tools.cjs github move-issue --issue-number $TASK_SUB_ISSUE_NUMBER --status "In Progress"
601
- TMPFILE=$(mktemp)
602
- cat > "$TMPFILE" << 'BODY_EOF'
603
- ## Code Review Failure
604
-
605
- This task's code review was blocked. Moving back to In Progress.
606
-
607
- **Blocking issues:**
608
- {list of blocker/high issues from verifier}
609
- BODY_EOF
610
- node ~/.claude/maxsim/bin/maxsim-tools.cjs github post-comment --issue-number $TASK_SUB_ISSUE_NUMBER --body-file "$TMPFILE"
611
- ```
612
-
613
- ---
158
+ # Verify key files from task list exist on disk
159
+ for file in {key_files_created_or_modified}; do
160
+ [ -f "$file" ] && echo "EXISTS: $file" || echo "MISSING: $file"
161
+ done
614
162
 
615
- ### Stage 3: Simplify Config-gated, spawn 3 parallel reviewers.
163
+ # Verify commits exist for this plan
164
+ git log --oneline --all --grep="{phase_number}-{plan_id}" 2>/dev/null
616
165
 
617
- **Config gate check:**
618
- ```bash
619
- SIMPLIFY_ENABLED=$(node ~/.claude/maxsim/bin/maxsim-tools.cjs config-get review.simplify_review 2>/dev/null || echo "true")
620
- ```
621
-
622
- **If `SIMPLIFY_ENABLED` is "false":** Skip Stage 3 and Stage 4 entirely. Log: "Simplify stage skipped (disabled in config)". Set `SIMPLIFY_RESULT="SKIPPED"`, `FINAL_RESULT="N/A"`. Proceed to review cycle tracking.
623
-
624
- **If `SIMPLIFY_ENABLED` is "true" (default):**
625
-
626
- ```
627
- SIMPLIFY_STAGE_START=$(date +%s)
628
- SIMPLIFY_RESULT="PENDING"
629
- SIMPLIFY_ATTEMPTS=0
630
- ```
631
-
632
- **Reviewer 1 -- Code Reuse:**
633
-
634
- ```
635
- Task(
636
- subagent_type="verifier",
637
- prompt="
638
- ## Task: Review for code reuse opportunities
639
-
640
- ## Suggested Skills: code-review
641
-
642
- <objective>
643
- Review plan {phase}-{plan} for code reuse opportunities.
644
- </objective>
645
-
646
- <files_to_review>
647
- {List all files created/modified during execution from summary key-files}
648
- </files_to_review>
649
-
650
- <instructions>
651
- 1. Scan all changed files for duplicated patterns
652
- 2. Cross-reference against existing shared utilities and helpers
653
- 3. Flag any logic that appears 3+ times without extraction
654
- 4. Check if existing utilities could replace new code
655
- 5. Output: list of reuse opportunities with file paths and line ranges
656
- 6. Verdict: CLEAN (no issues) or ISSUES_FOUND (list)
657
- </instructions>
658
- "
659
- )
660
- ```
661
-
662
- **Reviewer 2 -- Code Quality:**
663
-
664
- ```
665
- Task(
666
- subagent_type="verifier",
667
- prompt="
668
- ## Task: Review for code quality issues
669
-
670
- ## Suggested Skills: code-review
671
-
672
- <objective>
673
- Review plan {phase}-{plan} for code quality issues.
674
- </objective>
675
-
676
- <files_to_review>
677
- {List all files created/modified during execution from summary key-files}
678
- </files_to_review>
679
-
680
- <instructions>
681
- 1. Check naming consistency with codebase conventions
682
- 2. Verify error handling covers all external calls
683
- 3. Look for dead code: unused imports, unreachable branches, commented-out code
684
- 4. Check for unnecessary abstractions or premature generalizations
685
- 5. Output: list of quality issues categorized by severity (BLOCKER/HIGH/MEDIUM)
686
- 6. Verdict: CLEAN (no issues) or ISSUES_FOUND (list)
687
- </instructions>
688
- "
689
- )
166
+ # Verify all task sub-issues are closed
167
+ node ~/.claude/maxsim/bin/maxsim-tools.cjs github list-sub-issues \
168
+ --phase-issue-number {phase_issue_number}
690
169
  ```
691
170
 
692
- **Reviewer 3 -- Efficiency:**
171
+ Self-check result:
172
+ - All key files exist + all commits found + all sub-issues closed → `## Self-Check: PASSED`
173
+ - Any miss → `## Self-Check: FAILED — {reason}`
693
174
 
694
- ```
695
- Task(
696
- subagent_type="verifier",
697
- prompt="
698
- ## Task: Review for efficiency issues
699
-
700
- ## Suggested Skills: code-review
701
-
702
- <objective>
703
- Review plan {phase}-{plan} for efficiency issues.
704
- </objective>
705
-
706
- <files_to_review>
707
- {List all files created/modified during execution from summary key-files}
708
- </files_to_review>
709
-
710
- <instructions>
711
- 1. Find over-engineered solutions (parametrization serving one case, generic interfaces with one implementor)
712
- 2. Identify repeated computations that could be cached or hoisted
713
- 3. Check for unnecessary allocations in hot paths
714
- 4. Look for redundant data transformations
715
- 5. Output: list of efficiency issues with suggested removals
716
- 6. Verdict: CLEAN (no issues) or ISSUES_FOUND (list)
717
- </instructions>
718
- "
719
- )
720
- ```
175
+ ## Step 6 — Post Summary to GitHub
721
176
 
722
- **Consolidation (after all 3 reviewers complete):**
177
+ Build summary content and post as a comment on the phase issue.
723
178
 
724
- After all three reviewers report:
725
- - If ALL returned CLEAN: Set `SIMPLIFY_RESULT="CLEAN"`, record `SIMPLIFY_STAGE_END=$(date +%s)`, skip Stage 4. Set `FINAL_RESULT="N/A"`.
726
- - If ANY returned ISSUES_FOUND:
727
- 1. Increment `SIMPLIFY_ATTEMPTS`
728
- 2. Merge findings into deduplicated list
729
- 3. Spawn single executor to apply fixes:
179
+ The summary comment IS the completion record. No local SUMMARY.md file is written.
730
180
 
731
- ```
732
- Task(
733
- subagent_type="executor",
734
- prompt="
735
- <objective>
736
- Apply simplification fixes for plan {phase}-{plan} based on reviewer findings.
737
- </objective>
738
-
739
- <findings>
740
- {Merged deduplicated list of ISSUES_FOUND from all reviewers — BLOCKER and HIGH first, skip speculative optimizations}
741
- </findings>
742
-
743
- <files_to_review>
744
- {List all files created/modified during execution from summary key-files}
745
- </files_to_review>
746
-
747
- <instructions>
748
- 1. Apply fixes for all actionable items (BLOCKER and HIGH severity first)
749
- 2. Skip speculative optimizations that lack clear evidence
750
- 3. Run tests to confirm fixes do not break anything
751
- 4. Report: FIXED (issues found and resolved) or BLOCKED (cannot fix without architectural change)
752
- </instructions>
753
- "
754
- )
755
- ```
756
-
757
- 4. **If FIXED:** Set `SIMPLIFY_RESULT="FIXED"`, record `SIMPLIFY_STAGE_END=$(date +%s)`, proceed to Stage 4.
758
-
759
- 5. **If BLOCKED and SIMPLIFY_ATTEMPTS < MAX_REVIEW_ATTEMPTS:** Re-run the 3 reviewers to find alternative fixes, then loop.
760
-
761
- 6. **If BLOCKED and SIMPLIFY_ATTEMPTS >= MAX_REVIEW_ATTEMPTS:** Escalate to user:
762
-
763
- ```markdown
764
- ## Review Escalation: Simplify Stage Blocked After 3 Attempts
765
-
766
- **Stage:** Simplify
767
- **Attempts:** 3/3
768
- **Last failure reason:** {architectural issues from executor}
769
-
770
- The simplify stage has been blocked 3 times. Remaining issues require architectural changes.
771
-
772
- **Options:**
773
- 1. Fix manually and type "retry" to re-run simplify (resets attempt counter)
774
- 2. Type "override" to skip simplify (will be flagged in summary)
775
- 3. Type "abort" to stop execution
776
- ```
777
-
778
- Wait for user response:
779
- - **"retry":** Reset `SIMPLIFY_ATTEMPTS=0`, re-run 3 reviewers.
780
- - **"override":** Set `SIMPLIFY_RESULT="OVERRIDDEN"`, increment `REVIEW_ESCALATIONS`, record `SIMPLIFY_STAGE_END=$(date +%s)`, skip Stage 4. Set `FINAL_RESULT="N/A"`.
781
- - **"abort":** Stop execution, post partial summary with review status.
181
+ ```bash
182
+ PLAN_END_EPOCH=$(date +%s)
183
+ PLAN_DURATION=$(( (PLAN_END_EPOCH - PLAN_START_EPOCH) / 60 ))m
782
184
 
185
+ SUMMARY_FILE=$(mktemp)
186
+ cat > "$SUMMARY_FILE" << 'SUMMARY_EOF'
783
187
  ---
784
-
785
- ### Stage 4: Final Review — If simplify made changes, one more code review pass.
786
-
787
- Run this stage ONLY if Stage 3 reported FIXED (i.e., simplify found and applied fixes). If Stage 3 was CLEAN, SKIPPED, or OVERRIDDEN: set `FINAL_RESULT="N/A"`, skip to review cycle tracking.
788
-
789
- ```
790
- FINAL_STAGE_START=$(date +%s)
791
- FINAL_RESULT="PENDING"
792
- ```
793
-
794
- **Retry loop (max MAX_REVIEW_ATTEMPTS):**
795
-
796
- 1. Increment `FINAL_ATTEMPTS`
797
- 2. Spawn verifier:
798
-
799
- ```
800
- Task(
801
- subagent_type="verifier",
802
- prompt="
803
- ## Task: Final review after simplification
804
-
805
- ## Suggested Skills: code-review
806
-
807
- <objective>
808
- Final review pass after simplification changes on plan {phase}-{plan}.
809
- Verify simplification fixes did not introduce regressions.
810
- </objective>
811
-
812
- <context>
813
- Previous code review: APPROVED
814
- Simplification: FIXED — changes were applied
815
- This is a focused re-review of simplification changes only.
816
- </context>
817
-
818
- <files_modified>
819
- {List files changed by simplification stage}
820
- </files_modified>
821
-
822
- <instructions>
823
- 1. Review only the changes made during simplification
824
- 2. Verify no regressions were introduced
825
- 3. Check that simplification changes follow project conventions
826
- 4. Report: APPROVED or BLOCKED (list issues)
827
- </instructions>
828
- "
829
- )
830
- ```
831
-
832
- 3. **If APPROVED:** Set `FINAL_RESULT="APPROVED"`, record `FINAL_STAGE_END=$(date +%s)`, proceed to review cycle tracking.
833
-
834
- 4. **If BLOCKED and FINAL_ATTEMPTS < MAX_REVIEW_ATTEMPTS:** Fix issues, re-stage and commit fixes (`fix({phase}-{plan}): address final review findings`), then loop back to step 1.
835
-
836
- 5. **If BLOCKED and FINAL_ATTEMPTS >= MAX_REVIEW_ATTEMPTS:** Escalate to user:
837
-
838
- ```markdown
839
- ## Review Escalation: Final Review Blocked After 3 Attempts
840
-
841
- **Stage:** Final Review
842
- **Attempts:** 3/3
843
- **Last failure reason:** {blocking issues from verifier}
844
-
845
- The final review has been blocked 3 times after simplification changes.
846
-
847
- **Options:**
848
- 1. Fix manually and type "retry" to re-run final review (resets attempt counter)
849
- 2. Type "override" to skip final review (will be flagged in summary)
850
- 3. Type "abort" to stop execution
851
- ```
852
-
853
- Wait for user response:
854
- - **"retry":** Reset `FINAL_ATTEMPTS=0`, loop back to step 1.
855
- - **"override":** Set `FINAL_RESULT="OVERRIDDEN"`, increment `REVIEW_ESCALATIONS`, record `FINAL_STAGE_END=$(date +%s)`, proceed to review cycle tracking.
856
- - **"abort":** Stop execution, post partial summary with review status.
857
-
188
+ phase: {phase_number}
189
+ plan: {plan_id}
190
+ objective: {objective}
191
+ wave: {wave_number}
192
+ completed: {ISO timestamp}
193
+ duration: {PLAN_DURATION}
194
+ key_files_created:
195
+ {list of files created}
196
+ key_files_modified:
197
+ {list of files modified}
198
+ key_decisions:
199
+ {list of any architectural decisions made during execution}
858
200
  ---
859
201
 
860
- ### Review Cycle Tracking
861
-
862
- ```
863
- REVIEW_CYCLE_END=$(date +%s)
864
- REVIEW_CYCLE_TOTAL=$(( REVIEW_CYCLE_END - REVIEW_CYCLE_START ))
865
- ```
866
-
867
- Calculate per-stage durations:
868
- ```
869
- SPEC_DURATION=$(( SPEC_STAGE_END - SPEC_STAGE_START ))
870
- CODE_DURATION=$(( CODE_STAGE_END - CODE_STAGE_START ))
871
- # Only if simplify ran:
872
- SIMPLIFY_DURATION=$(( SIMPLIFY_STAGE_END - SIMPLIFY_STAGE_START )) # or "N/A" if skipped
873
- # Only if final review ran:
874
- FINAL_DURATION=$(( FINAL_STAGE_END - FINAL_STAGE_START )) # or "N/A" if skipped
875
- ```
876
-
877
- Add review cycle results to the summary content in memory (under a `## Review Cycle` section):
878
- ```markdown
879
- ## Review Cycle
202
+ ## {Plan ID}: {Objective}
880
203
 
881
- | Stage | Result | Attempts | Duration | Findings |
882
- |-------|--------|----------|----------|----------|
883
- | Spec Review | {PASS|FAIL|OVERRIDDEN} | {SPEC_ATTEMPTS}/3 | {SPEC_DURATION}s | {summary or "All requirements met"} |
884
- | Code Review | {APPROVED|BLOCKED|OVERRIDDEN} | {CODE_ATTEMPTS}/3 | {CODE_DURATION}s | {summary or "No blocking issues"} |
885
- | Simplify | {CLEAN|FIXED|BLOCKED|SKIPPED|OVERRIDDEN} | {SIMPLIFY_ATTEMPTS}/3 | {SIMPLIFY_DURATION}s | {summary or "N/A"} |
886
- | Final Review | {APPROVED|BLOCKED|SKIPPED|N/A|OVERRIDDEN} | {FINAL_ATTEMPTS}/3 | {FINAL_DURATION}s | {summary or "N/A"} |
204
+ {One-liner: substantive description of what was built and how it works}
887
205
 
888
- **Total review time:** {REVIEW_CYCLE_TOTAL}s
889
- **Escalations:** {REVIEW_ESCALATIONS} ({REVIEW_ESCALATION_DETAILS or "None"})
890
- ```
206
+ ## Task Execution
891
207
 
892
- Now post the complete summary (with review cycle included) to GitHub:
893
- ```bash
894
- TMPFILE=$(mktemp)
895
- echo "$COMPLETE_SUMMARY_CONTENT" > "$TMPFILE"
896
- node ~/.claude/maxsim/bin/maxsim-tools.cjs github post-comment --issue-number $PHASE_ISSUE_NUMBER --body-file "$TMPFILE" --type summary
897
- ```
208
+ | Task | Name | Status | Commit | Notes |
209
+ |------|------|--------|--------|-------|
210
+ | 1 | {name} | PASS | {hash} | |
211
+ | 2 | {name} | PASS | {hash} | {deviation if any} |
898
212
 
899
- After posting, commit any review-cycle metadata:
900
- ```bash
901
- node ~/.claude/maxsim/bin/maxsim-tools.cjs commit "docs({phase}-{plan}): add review cycle results" --files .planning/STATE.md .planning/ROADMAP.md
902
- ```
903
- </step>
213
+ ## Deviations
214
+ {List any departures from the plan spec, with rationale. "None." if no deviations.}
904
215
 
905
- <step name="evidence_gate">
906
- **Gate G6: Evidence Completeness** Summary must have evidence for each requirement.
216
+ ## Issues Encountered
217
+ {List any problems hit during execution and how they were resolved. "None." if clean.}
907
218
 
908
- After the review cycle and before finalizing, validate that the summary content contains requirement evidence for all requirements in the plan's frontmatter.
219
+ {self_check_result}
220
+ <!-- maxsim:type=summary -->
221
+ SUMMARY_EOF
909
222
 
910
- ```bash
911
- if [ -n "$REQ_IDS" ]; then
912
- # Write summary content to a temp file for verification
913
- echo "$SUMMARY_CONTENT" > /tmp/summary-check.md
914
- G6_RESULT=$(node ~/.claude/maxsim/bin/maxsim-tools.cjs verify evidence-completeness "/tmp/summary-check.md" $REQ_IDS)
915
- G6_VALID=$(echo "$G6_RESULT" | node -e "process.stdin.on('data',d=>console.log(JSON.parse(d).valid))")
916
- if [ "$G6_VALID" != "true" ]; then
917
- G6_MISSING=$(echo "$G6_RESULT" | node -e "process.stdin.on('data',d=>console.log(JSON.parse(d).missing_evidence.join(', ')))")
918
- echo "GATE G6: Missing requirement evidence for: $G6_MISSING"
919
- echo "Add Requirement Evidence rows to summary for these requirements before posting."
920
- # Present as warning with instruction to fix — executor should add evidence
921
- fi
922
- fi
223
+ node ~/.claude/maxsim/bin/maxsim-tools.cjs github post-comment \
224
+ --issue-number {phase_issue_number} \
225
+ --body-file "$SUMMARY_FILE" \
226
+ --type summary
923
227
  ```
924
- </step>
925
228
 
926
- <step name="update_current_position">
927
- Update STATE.md using maxsim-tools:
229
+ ## Step 7 — Update State Files
928
230
 
929
231
  ```bash
930
- # Advance plan counter (handles last-plan edge case)
232
+ # Advance plan counter
931
233
  node ~/.claude/maxsim/bin/maxsim-tools.cjs state advance-plan
932
234
 
933
- # Recalculate progress bar from disk state
235
+ # Recalculate progress
934
236
  node ~/.claude/maxsim/bin/maxsim-tools.cjs state update-progress
935
237
 
936
- # Record execution metrics
238
+ # Record session metrics
937
239
  node ~/.claude/maxsim/bin/maxsim-tools.cjs state record-metric \
938
- --phase "${PHASE}" --plan "${PLAN}" --duration "${DURATION}" \
939
- --tasks "${TASK_COUNT}" --files "${FILE_COUNT}"
940
- ```
941
- </step>
240
+ --phase "{PHASE_NUMBER}" --plan "{PLAN_ID}" --duration "{PLAN_DURATION}" \
241
+ --tasks "{TASK_COUNT}" --files "{FILE_COUNT}"
942
242
 
943
- <step name="extract_decisions_and_issues">
944
- From summary content: Extract decisions and add to STATE.md:
945
-
946
- ```bash
947
- # Add each decision from summary key-decisions
948
- # Prefer file inputs for shell-safe text (preserves `$`, `*`, etc. exactly)
949
- node ~/.claude/maxsim/bin/maxsim-tools.cjs state add-decision \
950
- --phase "${PHASE}" --summary-file "${DECISION_TEXT_FILE}" --rationale-file "${RATIONALE_FILE}"
951
-
952
- # Add blockers if any found
953
- node ~/.claude/maxsim/bin/maxsim-tools.cjs state add-blocker --text-file "${BLOCKER_TEXT_FILE}"
954
- ```
955
- </step>
956
-
957
- <step name="update_session_continuity">
958
- Update session info using maxsim-tools:
959
-
960
- ```bash
243
+ # Record session stop position
961
244
  node ~/.claude/maxsim/bin/maxsim-tools.cjs state record-session \
962
- --stopped-at "Completed ${PHASE}-${PLAN}-PLAN.md" \
245
+ --stopped-at "Completed {PHASE_NUMBER}-{PLAN_ID} (execute-plan)" \
963
246
  --resume-file "None"
964
- ```
965
-
966
- Keep STATE.md under 150 lines.
967
- </step>
968
-
969
- <step name="issues_review_gate">
970
- If summary "Issues Encountered" ≠ "None": yolo → log and continue. Interactive → present issues, wait for acknowledgment.
971
- </step>
972
-
973
- <step name="update_roadmap">
974
- ```bash
975
- node ~/.claude/maxsim/bin/maxsim-tools.cjs roadmap update-plan-progress "${PHASE}"
976
- ```
977
- Counts completed task sub-issues (or PLAN vs SUMMARY files in fallback mode) on disk. Updates progress table row with correct count and status (`In Progress` or `Complete` with date).
978
- </step>
979
-
980
- <step name="update_requirements">
981
- Mark completed requirements from the plan's frontmatter `requirements:` field:
982
-
983
- ```bash
984
- node ~/.claude/maxsim/bin/maxsim-tools.cjs requirements mark-complete ${REQ_IDS}
985
- ```
986
-
987
- Extract requirement IDs from the plan frontmatter (e.g., `requirements: [AUTH-01, AUTH-02]`). If no requirements field, skip.
988
- </step>
989
-
990
- <step name="git_commit_metadata">
991
- Task code already committed per-task. Commit plan metadata:
992
-
993
- ```bash
994
- node ~/.claude/maxsim/bin/maxsim-tools.cjs commit "docs({phase}-{plan}): complete [plan-name] plan" --files .planning/STATE.md .planning/ROADMAP.md .planning/REQUIREMENTS.md
995
- ```
996
-
997
- Note: No local SUMMARY.md is committed -- summary was posted to GitHub as a comment.
998
- </step>
999
-
1000
- <step name="post_verification_to_github">
1001
-
1002
- ## Post Verification Results as GitHub Comment
1003
-
1004
- If the plan includes verification criteria (from `<verification>` section of plan content):
1005
-
1006
- Build verification results content in memory with `<!-- maxsim:type=verification -->` marker.
1007
-
1008
- ```bash
1009
- TMPFILE=$(mktemp)
1010
- cat > "$TMPFILE" << 'BODY_EOF'
1011
- <!-- maxsim:type=verification -->
1012
- ## Plan {plan_number} Verification
1013
-
1014
- {verification_results}
1015
-
1016
- **Status:** {passed|failed}
1017
- **Timestamp:** {ISO timestamp}
1018
- BODY_EOF
1019
- node ~/.claude/maxsim/bin/maxsim-tools.cjs github post-comment --issue-number $PHASE_ISSUE_NUMBER --body-file "$TMPFILE" --type verification
1020
- ```
1021
247
 
1022
- If the plan includes UAT criteria (from `<uat>` section):
1023
-
1024
- ```bash
1025
- TMPFILE=$(mktemp)
1026
- cat > "$TMPFILE" << 'BODY_EOF'
1027
- <!-- maxsim:type=uat -->
1028
- ## Plan {plan_number} UAT
1029
-
1030
- {uat_criteria_and_results}
1031
-
1032
- **Status:** {pending|passed|failed}
1033
- **Timestamp:** {ISO timestamp}
1034
- BODY_EOF
1035
- node ~/.claude/maxsim/bin/maxsim-tools.cjs github post-comment --issue-number $PHASE_ISSUE_NUMBER --body-file "$TMPFILE" --type uat
1036
- ```
1037
-
1038
- GitHub Issues is the source of truth -- verification and UAT results are always posted as GitHub comments.
1039
- </step>
1040
-
1041
- <step name="update_codebase_map">
1042
- If .planning/codebase/ doesn't exist: skip.
1043
-
1044
- ```bash
1045
- FIRST_TASK=$(git log --oneline --grep="feat({phase}-{plan}):" --grep="fix({phase}-{plan}):" --grep="test({phase}-{plan}):" --reverse | head -1 | cut -d' ' -f1)
1046
- git diff --name-only ${FIRST_TASK}^..HEAD 2>/dev/null
1047
- ```
1048
-
1049
- Update only structural changes: new src/ dir → STRUCTURE.md | deps → STACK.md | file pattern → CONVENTIONS.md | API client → INTEGRATIONS.md | config → STACK.md | renamed → update paths. Skip code-only/bugfix/content changes.
1050
-
1051
- ```bash
1052
- node ~/.claude/maxsim/bin/maxsim-tools.cjs commit "" --files .planning/codebase/*.md --amend
248
+ # Update roadmap progress
249
+ node ~/.claude/maxsim/bin/maxsim-tools.cjs roadmap update-plan-progress "{PHASE_NUMBER}"
1053
250
  ```
1054
- </step>
1055
-
1056
- <step name="offer_next">
1057
- If `USER_SETUP_CREATED=true`: display `⚠️ USER SETUP REQUIRED` with path + env/config tasks at TOP.
1058
251
 
1059
- Check completion by querying the phase issue's task sub-issues:
252
+ Commit planning metadata (task code was already committed per-task):
1060
253
  ```bash
1061
- node ~/.claude/maxsim/bin/maxsim-tools.cjs github list-sub-issues --phase-issue-number $PHASE_ISSUE_NUMBER
254
+ node ~/.claude/maxsim/bin/maxsim-tools.cjs commit \
255
+ "docs({phase_number}-{plan_id}): complete plan execution" \
256
+ --files .planning/STATE.md .planning/ROADMAP.md .planning/REQUIREMENTS.md
1062
257
  ```
1063
258
 
1064
- Count open vs closed sub-issues. Map closed count to plans complete.
259
+ ## Step 8 Return Result
1065
260
 
1066
- | Condition | Route | Action |
1067
- |-----------|-------|--------|
1068
- | open task sub-issues remain | **A: More plans** | Find next incomplete plan (by open sub-issues or missing summary comment). Yolo: auto-continue. Interactive: show next plan, suggest `/maxsim:execute {phase}`. STOP here. |
1069
- | all sub-issues closed, current < highest phase | **B: Phase done** | Show completion, suggest `/maxsim:plan {Z+1}`. |
1070
- | all sub-issues closed, current = highest phase | **C: Milestone done** | Show banner, suggest `/maxsim:progress`. |
261
+ The final line of output MUST be exactly one of:
262
+ - `RESULT: PASS`
263
+ - `RESULT: FAIL {specific reason}`
1071
264
 
1072
- All routes: `/clear` first for fresh context.
1073
- </step>
265
+ Do not add text after the RESULT line.
1074
266
 
1075
267
  </process>
1076
268
 
1077
- <success_criteria>
269
+ <verification_checklist>
270
+ Before returning RESULT: PASS, confirm ALL of the following:
271
+ - [ ] All tasks in the plan were executed
272
+ - [ ] Each task has exactly one atomic commit with a conventional commit message
273
+ - [ ] No task was committed with `git add .` or `git add -A`
274
+ - [ ] Tests were run and pass (or no test runner detected)
275
+ - [ ] No TODOs, stubs, or placeholder content introduced
276
+ - [ ] All task sub-issues are closed on GitHub
277
+ - [ ] Summary comment posted to phase issue with <!-- maxsim:type=summary -->
278
+ - [ ] Self-check ran and result appended to summary
279
+ - [ ] STATE.md and ROADMAP.md updated
280
+ </verification_checklist>
281
+
282
+ <failure_handling>
283
+ - **Task tests fail after 2 retries:** Diagnose root cause. If cannot fix, return `RESULT: FAIL — task {N} tests failing: {error}`
284
+ - **File cannot be found:** Check path relative to worktree root. If genuinely missing, create it as specified in the task.
285
+ - **Sub-issue board transition fails:** Log the error, continue execution. Include note in summary.
286
+ - **GitHub post-comment fails:** Retry once with exponential backoff. If still failing, write summary to `.planning/phases/{phase_dir}/{plan_id}-SUMMARY.md` as fallback and report error.
287
+ - **Commit fails (merge conflict):** You are in an isolated worktree. Conflicts indicate unexpected overlap. Report immediately: `RESULT: FAIL — merge conflict in worktree: {files}`
288
+ </failure_handling>
1078
289
 
1079
- - All tasks from plan completed
1080
- - All verifications pass
1081
- - USER-SETUP.md generated if user_setup in frontmatter
1082
- - Summary posted as GitHub comment with `<!-- maxsim:type=summary -->` marker (not written to local SUMMARY.md)
1083
- - Verification and UAT posted as GitHub comments with appropriate type markers
1084
- - Task sub-issues moved: In Progress when started, Done when completed (WIRE-04)
1085
- - On review failure: task sub-issues reopened and moved back to In Progress (WIRE-07)
1086
- - STATE.md updated (position, decisions, issues, session)
1087
- - ROADMAP.md updated
1088
- - If codebase map exists: map updated with execution changes (or skipped if no significant changes)
1089
- - If USER-SETUP.md created: prominently surfaced in completion output
290
+ <success_criteria>
291
+ - [ ] Plan content parsed from GitHub context (not from local PLAN.md)
292
+ - [ ] External edit detection checked before execution begins
293
+ - [ ] All tasks executed in order
294
+ - [ ] Each task committed individually with conventional commit message
295
+ - [ ] Board transitions: In Progress when task starts, Done+closed when task completes
296
+ - [ ] Self-check ran and result recorded in summary
297
+ - [ ] Summary posted as GitHub comment (<!-- maxsim:type=summary -->) — no local SUMMARY.md written
298
+ - [ ] State files updated
299
+ - [ ] Final output line is exactly RESULT: PASS or RESULT: FAIL {reason}
1090
300
  </success_criteria>