maxsimcli 4.8.0 → 4.9.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 (161) hide show
  1. package/dist/assets/CHANGELOG.md +13 -0
  2. package/dist/assets/hooks/maxsim-check-update.cjs +38 -0
  3. package/dist/assets/hooks/maxsim-check-update.cjs.map +1 -1
  4. package/dist/assets/hooks/maxsim-statusline.cjs +116 -48
  5. package/dist/assets/hooks/maxsim-statusline.cjs.map +1 -1
  6. package/dist/assets/hooks/maxsim-sync-reminder.cjs +117 -0
  7. package/dist/assets/hooks/maxsim-sync-reminder.cjs.map +1 -0
  8. package/dist/assets/templates/agents/AGENTS.md +78 -106
  9. package/dist/assets/templates/agents/executor.md +101 -0
  10. package/dist/assets/templates/agents/planner.md +86 -0
  11. package/dist/assets/templates/agents/researcher.md +71 -0
  12. package/dist/assets/templates/agents/verifier.md +88 -0
  13. package/dist/assets/templates/commands/maxsim/debug.md +7 -7
  14. package/dist/assets/templates/commands/maxsim/execute.md +45 -0
  15. package/dist/assets/templates/commands/maxsim/go.md +29 -0
  16. package/dist/assets/templates/commands/maxsim/help.md +2 -2
  17. package/dist/assets/templates/commands/maxsim/init.md +52 -0
  18. package/dist/assets/templates/commands/maxsim/plan.md +50 -0
  19. package/dist/assets/templates/commands/maxsim/progress.md +4 -3
  20. package/dist/assets/templates/commands/maxsim/quick.md +6 -4
  21. package/dist/assets/templates/commands/maxsim/settings.md +4 -3
  22. package/dist/assets/templates/references/continuation-format.md +16 -16
  23. package/dist/assets/templates/references/model-profile-resolution.md +1 -1
  24. package/dist/assets/templates/references/model-profiles.md +12 -19
  25. package/dist/assets/templates/rules/conventions.md +51 -0
  26. package/dist/assets/templates/rules/verification-protocol.md +57 -0
  27. package/dist/assets/templates/skills/agent-system-map/SKILL.md +92 -0
  28. package/dist/assets/templates/skills/brainstorming/SKILL.md +48 -36
  29. package/dist/assets/templates/skills/code-review/SKILL.md +40 -61
  30. package/dist/assets/templates/skills/commit-conventions/SKILL.md +75 -0
  31. package/dist/assets/templates/skills/evidence-collection/SKILL.md +87 -0
  32. package/dist/assets/templates/skills/handoff-contract/SKILL.md +70 -0
  33. package/dist/assets/templates/skills/input-validation/SKILL.md +51 -0
  34. package/dist/assets/templates/skills/maxsim-batch/SKILL.md +41 -45
  35. package/dist/assets/templates/skills/maxsim-simplify/SKILL.md +37 -90
  36. package/dist/assets/templates/skills/memory-management/SKILL.md +32 -67
  37. package/dist/assets/templates/skills/research-methodology/SKILL.md +137 -0
  38. package/dist/assets/templates/skills/roadmap-writing/SKILL.md +40 -58
  39. package/dist/assets/templates/skills/sdd/SKILL.md +34 -69
  40. package/dist/assets/templates/skills/systematic-debugging/SKILL.md +20 -26
  41. package/dist/assets/templates/skills/tdd/SKILL.md +25 -33
  42. package/dist/assets/templates/skills/tool-priority-guide/SKILL.md +80 -0
  43. package/dist/assets/templates/skills/using-maxsim/SKILL.md +42 -73
  44. package/dist/assets/templates/skills/verification-before-completion/SKILL.md +12 -24
  45. package/dist/assets/templates/skills/verification-gates/SKILL.md +169 -0
  46. package/dist/assets/templates/templates/UAT.md +3 -3
  47. package/dist/assets/templates/templates/VALIDATION.md +1 -1
  48. package/dist/assets/templates/templates/context.md +4 -4
  49. package/dist/assets/templates/templates/debug-subagent-prompt.md +3 -3
  50. package/dist/assets/templates/templates/discovery.md +2 -2
  51. package/dist/assets/templates/templates/phase-prompt.md +2 -2
  52. package/dist/assets/templates/templates/planner-subagent-prompt.md +7 -7
  53. package/dist/assets/templates/templates/project.md +1 -1
  54. package/dist/assets/templates/templates/research.md +1 -1
  55. package/dist/assets/templates/templates/state.md +2 -2
  56. package/dist/assets/templates/templates/summary.md +41 -0
  57. package/dist/assets/templates/workflows/batch.md +5 -5
  58. package/dist/assets/templates/workflows/diagnose-issues.md +2 -2
  59. package/dist/assets/templates/workflows/discovery-phase.md +3 -3
  60. package/dist/assets/templates/workflows/discuss-phase.md +11 -11
  61. package/dist/assets/templates/workflows/execute-phase.md +205 -11
  62. package/dist/assets/templates/workflows/execute-plan.md +299 -34
  63. package/dist/assets/templates/workflows/execute.md +421 -0
  64. package/dist/assets/templates/workflows/go.md +250 -0
  65. package/dist/assets/templates/workflows/health.md +5 -5
  66. package/dist/assets/templates/workflows/help.md +165 -435
  67. package/dist/assets/templates/workflows/init-existing.md +23 -23
  68. package/dist/assets/templates/workflows/init.md +205 -0
  69. package/dist/assets/templates/workflows/new-milestone.md +9 -9
  70. package/dist/assets/templates/workflows/new-project.md +26 -26
  71. package/dist/assets/templates/workflows/plan-create.md +298 -0
  72. package/dist/assets/templates/workflows/plan-discuss.md +347 -0
  73. package/dist/assets/templates/workflows/plan-phase.md +29 -29
  74. package/dist/assets/templates/workflows/plan-research.md +177 -0
  75. package/dist/assets/templates/workflows/plan.md +231 -0
  76. package/dist/assets/templates/workflows/progress.md +46 -42
  77. package/dist/assets/templates/workflows/quick.md +195 -14
  78. package/dist/assets/templates/workflows/research-phase.md +5 -5
  79. package/dist/assets/templates/workflows/sdd.md +20 -12
  80. package/dist/assets/templates/workflows/settings.md +18 -14
  81. package/dist/assets/templates/workflows/verify-phase.md +1 -1
  82. package/dist/assets/templates/workflows/verify-work.md +16 -16
  83. package/dist/cli.cjs +496 -91
  84. package/dist/cli.cjs.map +1 -1
  85. package/dist/core-D5zUr9cb.cjs.map +1 -1
  86. package/dist/install.cjs +234 -17
  87. package/dist/install.cjs.map +1 -1
  88. package/dist/mcp-server.cjs +21 -2
  89. package/dist/mcp-server.cjs.map +1 -1
  90. package/dist/skills-CjFWZIGM.cjs.map +1 -1
  91. package/package.json +1 -1
  92. package/dist/assets/hooks/maxsim-context-monitor.cjs +0 -121
  93. package/dist/assets/hooks/maxsim-context-monitor.cjs.map +0 -1
  94. package/dist/assets/templates/agents/maxsim-code-reviewer.md +0 -239
  95. package/dist/assets/templates/agents/maxsim-codebase-mapper.md +0 -214
  96. package/dist/assets/templates/agents/maxsim-debugger.md +0 -572
  97. package/dist/assets/templates/agents/maxsim-drift-checker.md +0 -522
  98. package/dist/assets/templates/agents/maxsim-executor.md +0 -504
  99. package/dist/assets/templates/agents/maxsim-integration-checker.md +0 -273
  100. package/dist/assets/templates/agents/maxsim-phase-researcher.md +0 -305
  101. package/dist/assets/templates/agents/maxsim-plan-checker.md +0 -343
  102. package/dist/assets/templates/agents/maxsim-planner.md +0 -610
  103. package/dist/assets/templates/agents/maxsim-project-researcher.md +0 -359
  104. package/dist/assets/templates/agents/maxsim-research-synthesizer.md +0 -263
  105. package/dist/assets/templates/agents/maxsim-roadmapper.md +0 -324
  106. package/dist/assets/templates/agents/maxsim-spec-reviewer.md +0 -245
  107. package/dist/assets/templates/agents/maxsim-verifier.md +0 -393
  108. package/dist/assets/templates/commands/maxsim/add-phase.md +0 -43
  109. package/dist/assets/templates/commands/maxsim/add-tests.md +0 -41
  110. package/dist/assets/templates/commands/maxsim/add-todo.md +0 -57
  111. package/dist/assets/templates/commands/maxsim/artefakte.md +0 -122
  112. package/dist/assets/templates/commands/maxsim/audit-milestone.md +0 -36
  113. package/dist/assets/templates/commands/maxsim/batch.md +0 -42
  114. package/dist/assets/templates/commands/maxsim/check-drift.md +0 -56
  115. package/dist/assets/templates/commands/maxsim/check-todos.md +0 -46
  116. package/dist/assets/templates/commands/maxsim/cleanup.md +0 -18
  117. package/dist/assets/templates/commands/maxsim/complete-milestone.md +0 -136
  118. package/dist/assets/templates/commands/maxsim/discuss-phase.md +0 -87
  119. package/dist/assets/templates/commands/maxsim/discuss.md +0 -70
  120. package/dist/assets/templates/commands/maxsim/execute-phase.md +0 -41
  121. package/dist/assets/templates/commands/maxsim/health.md +0 -22
  122. package/dist/assets/templates/commands/maxsim/init-existing.md +0 -46
  123. package/dist/assets/templates/commands/maxsim/insert-phase.md +0 -32
  124. package/dist/assets/templates/commands/maxsim/list-phase-assumptions.md +0 -46
  125. package/dist/assets/templates/commands/maxsim/map-codebase.md +0 -71
  126. package/dist/assets/templates/commands/maxsim/new-milestone.md +0 -44
  127. package/dist/assets/templates/commands/maxsim/new-project.md +0 -46
  128. package/dist/assets/templates/commands/maxsim/pause-work.md +0 -38
  129. package/dist/assets/templates/commands/maxsim/plan-milestone-gaps.md +0 -34
  130. package/dist/assets/templates/commands/maxsim/plan-phase.md +0 -44
  131. package/dist/assets/templates/commands/maxsim/realign.md +0 -39
  132. package/dist/assets/templates/commands/maxsim/reapply-patches.md +0 -110
  133. package/dist/assets/templates/commands/maxsim/remove-phase.md +0 -31
  134. package/dist/assets/templates/commands/maxsim/research-phase.md +0 -189
  135. package/dist/assets/templates/commands/maxsim/resume-work.md +0 -40
  136. package/dist/assets/templates/commands/maxsim/roadmap.md +0 -19
  137. package/dist/assets/templates/commands/maxsim/sdd.md +0 -39
  138. package/dist/assets/templates/commands/maxsim/set-profile.md +0 -34
  139. package/dist/assets/templates/commands/maxsim/update.md +0 -37
  140. package/dist/assets/templates/commands/maxsim/verify-work.md +0 -38
  141. package/dist/assets/templates/workflows/add-phase.md +0 -111
  142. package/dist/assets/templates/workflows/add-tests.md +0 -351
  143. package/dist/assets/templates/workflows/add-todo.md +0 -247
  144. package/dist/assets/templates/workflows/audit-milestone.md +0 -297
  145. package/dist/assets/templates/workflows/check-drift.md +0 -248
  146. package/dist/assets/templates/workflows/check-todos.md +0 -261
  147. package/dist/assets/templates/workflows/cleanup.md +0 -153
  148. package/dist/assets/templates/workflows/complete-milestone.md +0 -701
  149. package/dist/assets/templates/workflows/discuss.md +0 -343
  150. package/dist/assets/templates/workflows/insert-phase.md +0 -129
  151. package/dist/assets/templates/workflows/list-phase-assumptions.md +0 -178
  152. package/dist/assets/templates/workflows/map-codebase.md +0 -315
  153. package/dist/assets/templates/workflows/pause-work.md +0 -122
  154. package/dist/assets/templates/workflows/plan-milestone-gaps.md +0 -274
  155. package/dist/assets/templates/workflows/realign.md +0 -288
  156. package/dist/assets/templates/workflows/remove-phase.md +0 -154
  157. package/dist/assets/templates/workflows/resume-project.md +0 -306
  158. package/dist/assets/templates/workflows/roadmap.md +0 -130
  159. package/dist/assets/templates/workflows/set-profile.md +0 -81
  160. package/dist/assets/templates/workflows/transition.md +0 -544
  161. package/dist/assets/templates/workflows/update.md +0 -220
@@ -0,0 +1,298 @@
1
+ <purpose>
2
+ Planning stage sub-workflow for /maxsim:plan. Spawns the planner agent to create PLAN.md files, then optionally spawns the planner (in plan-checking mode) for verification with a revision loop.
3
+
4
+ This file is loaded by the plan.md orchestrator. It does NOT handle gate confirmations or stage routing -- the orchestrator handles that. This sub-workflow focuses ONLY on creating and verifying plans.
5
+ </purpose>
6
+
7
+ <process>
8
+
9
+ ## Step 1: Check Prerequisites
10
+
11
+ The orchestrator provides phase context. Verify we have what we need:
12
+
13
+ - `phase_number`, `phase_name`, `phase_dir`, `padded_phase`, `phase_slug`
14
+ - `planner_model`, `checker_model`, `plan_checker_enabled`
15
+ - `commit_docs`
16
+ - `state_path`, `roadmap_path`, `requirements_path`, `context_path`, `research_path`
17
+ - `phase_req_ids` (requirement IDs that this phase must address)
18
+ - `--skip-verify` flag presence
19
+
20
+ ## Step 2: Resolve Models
21
+
22
+ ```bash
23
+ PLANNER_MODEL=$(node .claude/maxsim/bin/maxsim-tools.cjs resolve-model planner --raw)
24
+ CHECKER_MODEL=$(node .claude/maxsim/bin/maxsim-tools.cjs resolve-model planner --raw)
25
+ ```
26
+
27
+ ## Step 3: Check Existing Plans
28
+
29
+ ```bash
30
+ ls "${phase_dir}"/*-PLAN.md 2>/dev/null
31
+ ```
32
+
33
+ **If plans exist:** Offer options via natural conversation:
34
+ ```
35
+ Phase {phase_number} already has plan(s):
36
+ {list of existing plan files}
37
+
38
+ 1. Add more plans (keep existing)
39
+ 2. View existing plans
40
+ 3. Re-plan from scratch (deletes existing plans)
41
+ ```
42
+
43
+ - If "Add more": Continue to Step 4 with existing plans preserved.
44
+ - If "View": Display plan files, then re-offer options.
45
+ - If "Re-plan": Delete existing PLAN.md files, continue to Step 4.
46
+
47
+ **If no plans exist:** Continue to Step 4.
48
+
49
+ ## Step 4: Gather Context Paths
50
+
51
+ Extract file paths from the orchestrator context (provided via init JSON):
52
+
53
+ ```bash
54
+ STATE_PATH=$(echo "$INIT" | jq -r '.state_path // empty')
55
+ ROADMAP_PATH=$(echo "$INIT" | jq -r '.roadmap_path // empty')
56
+ REQUIREMENTS_PATH=$(echo "$INIT" | jq -r '.requirements_path // empty')
57
+ RESEARCH_PATH=$(echo "$INIT" | jq -r '.research_path // empty')
58
+ CONTEXT_PATH=$(echo "$INIT" | jq -r '.context_path // empty')
59
+ ```
60
+
61
+ ## Step 5: Spawn Planner
62
+
63
+ Display:
64
+ ```
65
+ Planning Phase {phase_number}: {phase_name}...
66
+ ```
67
+
68
+ Construct the planner prompt:
69
+
70
+ ```markdown
71
+ <planning_context>
72
+ **Phase:** {phase_number}
73
+ **Mode:** standard
74
+
75
+ <files_to_read>
76
+ - {state_path} (Project State)
77
+ - {roadmap_path} (Roadmap)
78
+ - {requirements_path} (Requirements)
79
+ - {context_path} (USER DECISIONS from discussion stage)
80
+ - {research_path} (Technical Research)
81
+ </files_to_read>
82
+
83
+ **Phase requirement IDs (every ID MUST appear in a plan's `requirements` field):** {phase_req_ids}
84
+
85
+ **Project instructions:** Read ./CLAUDE.md if exists -- follow project-specific guidelines
86
+ **Project skills:** Check .skills/ directory (if exists) -- read SKILL.md files, plans should account for project skill rules
87
+ </planning_context>
88
+
89
+ <downstream_consumer>
90
+ Output consumed by /maxsim:execute. Plans need:
91
+ - Frontmatter (wave, depends_on, files_modified, autonomous)
92
+ - Tasks in XML format
93
+ - Verification criteria
94
+ - must_haves for goal-backward verification
95
+ </downstream_consumer>
96
+
97
+ <quality_gate>
98
+ - [ ] PLAN.md files created in phase directory
99
+ - [ ] Each plan has valid frontmatter
100
+ - [ ] Tasks are specific and actionable
101
+ - [ ] Dependencies correctly identified
102
+ - [ ] Waves assigned for parallel execution
103
+ - [ ] must_haves derived from phase goal
104
+ </quality_gate>
105
+ ```
106
+
107
+ Spawn the planner:
108
+
109
+ ```
110
+ Task(
111
+ prompt=planner_prompt,
112
+ subagent_type="planner",
113
+ model="{planner_model}",
114
+ description="Plan Phase {phase_number}"
115
+ )
116
+ ```
117
+
118
+ ## Step 6: Handle Planner Return
119
+
120
+ Parse the planner's return message:
121
+
122
+ - **`## PLANNING COMPLETE`:**
123
+ Validate PLAN.md files were created:
124
+ ```bash
125
+ ls "${phase_dir}"/*-PLAN.md 2>/dev/null | wc -l
126
+ ```
127
+
128
+ If plans found:
129
+ - Display plan count and filenames.
130
+ - If `--skip-verify` flag is set OR `plan_checker_enabled` is false: skip to Step 9.
131
+ - Otherwise: continue to Step 7 (verification).
132
+
133
+ If no plans found:
134
+ - Error: "Planner reported complete but no PLAN.md files found."
135
+ - Offer: retry or abort.
136
+
137
+ - **`## CHECKPOINT REACHED`:**
138
+ Present checkpoint to user, get response, spawn continuation agent with checkpoint context. If planner needs a decision, relay it to the user.
139
+
140
+ - **`## PLANNING INCONCLUSIVE`:**
141
+ Display what was attempted. Offer:
142
+ ```
143
+ Planning inconclusive after {N} attempts.
144
+
145
+ 1. Provide more context and retry
146
+ 2. Try with different approach
147
+ 3. Abort
148
+ ```
149
+ Handle user choice accordingly.
150
+
151
+ ## Step 7: Spawn Plan Checker
152
+
153
+ Initialize iteration tracking: `iteration_count = 1`.
154
+
155
+ Display:
156
+ ```
157
+ Verifying plans...
158
+ ```
159
+
160
+ Construct the checker prompt:
161
+
162
+ ```markdown
163
+ <verification_context>
164
+ **Phase:** {phase_number}
165
+ **Phase Goal:** {goal from ROADMAP}
166
+
167
+ <files_to_read>
168
+ - {phase_dir}/*-PLAN.md (Plans to verify)
169
+ - {roadmap_path} (Roadmap)
170
+ - {requirements_path} (Requirements)
171
+ - {context_path} (USER DECISIONS from discussion stage)
172
+ - {research_path} (Technical Research)
173
+ </files_to_read>
174
+
175
+ **Phase requirement IDs (MUST ALL be covered):** {phase_req_ids}
176
+
177
+ **Project instructions:** Read ./CLAUDE.md if exists -- verify plans honor project guidelines
178
+ **Project skills:** Check .skills/ directory (if exists) -- verify plans account for project skill rules
179
+ </verification_context>
180
+
181
+ <expected_output>
182
+ - ## VERIFICATION PASSED -- all checks pass
183
+ - ## ISSUES FOUND -- structured issue list
184
+ </expected_output>
185
+ ```
186
+
187
+ Spawn the checker:
188
+
189
+ ```
190
+ Task(
191
+ prompt="## Task: Verify plans achieve phase goal\n\n## Suggested Skills: verification-gates\n\n" + checker_prompt,
192
+ subagent_type="planner",
193
+ model="{checker_model}",
194
+ description="Verify Phase {phase_number} plans"
195
+ )
196
+ ```
197
+
198
+ ## Step 8: Handle Checker Return and Revision Loop
199
+
200
+ - **`## VERIFICATION PASSED`:**
201
+ Display confirmation:
202
+ ```
203
+ Plan verification passed.
204
+ ```
205
+ Continue to Step 9.
206
+
207
+ - **`## ISSUES FOUND`:**
208
+ Display the issues found. Check iteration count.
209
+
210
+ **If iteration_count < 3:**
211
+
212
+ Display:
213
+ ```
214
+ Sending plans back for revision... (iteration {iteration_count}/3)
215
+ ```
216
+
217
+ Construct revision prompt:
218
+
219
+ ```markdown
220
+ <revision_context>
221
+ **Phase:** {phase_number}
222
+ **Mode:** revision
223
+
224
+ <files_to_read>
225
+ - {phase_dir}/*-PLAN.md (Existing plans)
226
+ - {context_path} (USER DECISIONS from discussion stage)
227
+ </files_to_read>
228
+
229
+ **Checker issues:** {structured_issues_from_checker}
230
+ </revision_context>
231
+
232
+ <instructions>
233
+ Make targeted updates to address checker issues.
234
+ Do NOT replan from scratch unless issues are fundamental.
235
+ Return what changed.
236
+ </instructions>
237
+ ```
238
+
239
+ Spawn planner for revision:
240
+
241
+ ```
242
+ Task(
243
+ prompt=revision_prompt,
244
+ subagent_type="planner",
245
+ model="{planner_model}",
246
+ description="Revise Phase {phase_number} plans"
247
+ )
248
+ ```
249
+
250
+ After planner returns: increment `iteration_count`, re-spawn checker (go back to Step 7).
251
+
252
+ **If iteration_count >= 3:**
253
+
254
+ Display:
255
+ ```
256
+ Max verification iterations reached. {N} issues remain:
257
+ {issue list}
258
+
259
+ 1. Force proceed -- accept plans with known issues
260
+ 2. Provide guidance -- give planner hints and retry
261
+ 3. Abort -- stop planning
262
+ ```
263
+
264
+ Wait for user choice.
265
+
266
+ - If "Force proceed": Continue to Step 9.
267
+ - If "Provide guidance": Get user input, re-spawn planner with user guidance, reset iteration_count, go to Step 7.
268
+ - If "Abort": Exit workflow.
269
+
270
+ ## Step 9: Commit Plans
271
+
272
+ If `commit_docs` is true:
273
+
274
+ ```bash
275
+ node .claude/maxsim/bin/maxsim-tools.cjs commit "docs(${padded_phase}): create phase plan" --files "${phase_dir}"
276
+ ```
277
+
278
+ ## Step 10: Return to Orchestrator
279
+
280
+ After plans are created and optionally verified, return control to the plan.md orchestrator. Do NOT show gate confirmation or next steps -- the orchestrator handles the final gate.
281
+
282
+ Display a brief completion message:
283
+ ```
284
+ Planning complete. {plan_count} plan(s) created in {phase_dir}.
285
+ ```
286
+
287
+ </process>
288
+
289
+ <success_criteria>
290
+ - Planner and checker models resolved from config
291
+ - Existing plans detected and handled (add/view/replan options)
292
+ - Planner agent spawned with full context (STATE.md, ROADMAP.md, REQUIREMENTS.md, CONTEXT.md, RESEARCH.md)
293
+ - PLAN.md files created and validated
294
+ - Checker verification loop runs (max 3 iterations) unless --skip-verify
295
+ - Revision loop sends issues back to planner for targeted fixes
296
+ - Plan files committed if commit_docs is true
297
+ - Control returned to orchestrator without showing gate or next steps
298
+ </success_criteria>
@@ -0,0 +1,347 @@
1
+ <purpose>
2
+ Discussion stage sub-workflow for /maxsim:plan. Extracts implementation decisions that downstream agents (researcher, planner) need. Analyzes the phase to identify gray areas, lets the user choose what to discuss, then deep-dives each selected area until satisfied.
3
+
4
+ This file is loaded by the plan.md orchestrator. It does NOT handle gate confirmations or stage routing -- the orchestrator handles that. This sub-workflow focuses ONLY on running the discussion and writing CONTEXT.md.
5
+
6
+ You are a thinking partner, not an interviewer. The user is the visionary -- you are the builder. Your job is to capture decisions that will guide research and planning, not to figure out implementation yourself.
7
+ </purpose>
8
+
9
+ <required_reading>
10
+ @./references/thinking-partner.md
11
+ </required_reading>
12
+
13
+ <downstream_awareness>
14
+ **CONTEXT.md feeds into:**
15
+
16
+ 1. **researcher** -- Reads CONTEXT.md to know WHAT to research
17
+ - "User wants card-based layout" -> researcher investigates card component patterns
18
+ - "Infinite scroll decided" -> researcher looks into virtualization libraries
19
+
20
+ 2. **planner** -- Reads CONTEXT.md to know WHAT decisions are locked
21
+ - "Pull-to-refresh on mobile" -> planner includes that in task specs
22
+ - "Claude's Discretion: loading skeleton" -> planner can decide approach
23
+
24
+ **Your job:** Capture decisions clearly enough that downstream agents can act on them without asking the user again.
25
+
26
+ **Not your job:** Figure out HOW to implement. That's what research and planning do with the decisions you capture.
27
+ </downstream_awareness>
28
+
29
+ <philosophy>
30
+ **User = founder/visionary. Claude = thinking partner and builder.**
31
+
32
+ The user knows:
33
+ - How they imagine it working
34
+ - What it should look/feel like
35
+ - What's essential vs nice-to-have
36
+ - Specific behaviors or references they have in mind
37
+
38
+ The user doesn't know (and shouldn't be asked):
39
+ - Codebase patterns (researcher reads the code)
40
+ - Technical risks (researcher identifies these)
41
+ - Implementation approach (planner figures this out)
42
+ - Success metrics (inferred from the work)
43
+
44
+ Ask about vision and implementation choices. Capture decisions for downstream agents.
45
+
46
+ **Thinking-partner behaviors (from thinking-partner.md):**
47
+ - **Challenge vague answers** -- "Cards" could mean many things. Push for specifics.
48
+ - **Surface unstated assumptions** -- "You're assuming mobile-first -- is that intentional?"
49
+ - **Propose alternatives with trade-offs** -- Don't just accept first choice. Offer 2-3 options.
50
+ - **Make consequences visible** -- "Infinite scroll means no shareable page positions."
51
+ - **Disagree constructively** -- If an approach has risks, name them.
52
+ - **Follow the thread** -- Build on what they just said. Don't jump topics.
53
+
54
+ Apply these behaviors within each discussion area. The user should feel like they're thinking through decisions with a collaborator, not answering a survey.
55
+ </philosophy>
56
+
57
+ <scope_guardrail>
58
+ **CRITICAL: No scope creep.**
59
+
60
+ The phase boundary comes from ROADMAP.md and is FIXED. Discussion clarifies HOW to implement what's scoped, never WHETHER to add new capabilities.
61
+
62
+ **Allowed (clarifying ambiguity):**
63
+ - "How should posts be displayed?" (layout, density, info shown)
64
+ - "What happens on empty state?" (within the feature)
65
+ - "Pull to refresh or manual?" (behavior choice)
66
+
67
+ **Not allowed (scope creep):**
68
+ - "Should we also add comments?" (new capability)
69
+ - "What about search/filtering?" (new capability)
70
+ - "Maybe include bookmarking?" (new capability)
71
+
72
+ **The heuristic:** Does this clarify how we implement what's already in the phase, or does it add a new capability that could be its own phase?
73
+
74
+ **When user suggests scope creep:**
75
+ ```
76
+ "[Feature X] would be a new capability -- that's its own phase.
77
+ Want me to note it for the roadmap backlog?
78
+
79
+ For now, let's focus on [phase domain]."
80
+ ```
81
+
82
+ Capture the idea in a "Deferred Ideas" section. Don't lose it, don't act on it.
83
+ </scope_guardrail>
84
+
85
+ <gray_area_identification>
86
+ Gray areas are **implementation decisions the user cares about** -- things that could go multiple ways and would change the result.
87
+
88
+ **How to identify gray areas:**
89
+
90
+ 1. **Read the phase goal** from ROADMAP.md
91
+ 2. **Understand the domain** -- What kind of thing is being built?
92
+ - Something users SEE -> visual presentation, interactions, states matter
93
+ - Something users CALL -> interface contracts, responses, errors matter
94
+ - Something users RUN -> invocation, output, behavior modes matter
95
+ - Something users READ -> structure, tone, depth, flow matter
96
+ - Something being ORGANIZED -> criteria, grouping, handling exceptions matter
97
+ 3. **Generate phase-specific gray areas** -- Not generic categories, but concrete decisions for THIS phase
98
+
99
+ **Don't use generic category labels** (UI, UX, Behavior). Generate specific gray areas:
100
+
101
+ ```
102
+ Phase: "User authentication"
103
+ -> Session handling, Error responses, Multi-device policy, Recovery flow
104
+
105
+ Phase: "Organize photo library"
106
+ -> Grouping criteria, Duplicate handling, Naming convention, Folder structure
107
+
108
+ Phase: "CLI for database backups"
109
+ -> Output format, Flag design, Progress reporting, Error recovery
110
+
111
+ Phase: "API documentation"
112
+ -> Structure/navigation, Code examples depth, Versioning approach, Interactive elements
113
+ ```
114
+
115
+ **The key question:** What decisions would change the outcome that the user should weigh in on?
116
+
117
+ **Claude handles these (don't ask):**
118
+ - Technical implementation details
119
+ - Architecture patterns
120
+ - Performance optimization
121
+ - Scope (roadmap defines this)
122
+ </gray_area_identification>
123
+
124
+ <process>
125
+
126
+ ## Step 1: Initialize
127
+
128
+ Phase number, name, and directory come from the orchestrator context.
129
+
130
+ ```bash
131
+ INIT=$(node .claude/maxsim/bin/maxsim-tools.cjs init phase-op "${PHASE}")
132
+ ```
133
+
134
+ Parse JSON for: `commit_docs`, `phase_found`, `phase_dir`, `phase_number`, `phase_name`, `phase_slug`, `padded_phase`, `has_research`, `has_context`, `has_plans`, `plan_count`, `roadmap_exists`, `planning_exists`.
135
+
136
+ **If `phase_found` is false:** Error -- the orchestrator should have caught this, but fail safe.
137
+
138
+ ## Step 2: Check Existing Context
139
+
140
+ Check if CONTEXT.md already exists using `has_context` from init.
141
+
142
+ ```bash
143
+ ls ${phase_dir}/*-CONTEXT.md 2>/dev/null
144
+ ```
145
+
146
+ **If exists:**
147
+
148
+ Ask the user (via natural conversation):
149
+ ```
150
+ Phase {phase_number} already has context. What would you like to do?
151
+ 1. Update it -- review and revise existing context
152
+ 2. View it -- show me what's there
153
+ 3. Use as-is -- keep existing context and return to orchestrator
154
+ ```
155
+
156
+ - If "Update": Load existing CONTEXT.md, continue to Step 3.
157
+ - If "View": Display CONTEXT.md contents, then offer update/use-as-is.
158
+ - If "Use as-is": Return control to orchestrator.
159
+
160
+ **If doesn't exist:** Continue to Step 3.
161
+
162
+ ## Step 3: Analyze Phase
163
+
164
+ Analyze the phase to identify gray areas worth discussing.
165
+
166
+ **Read the phase description from ROADMAP.md and determine:**
167
+
168
+ 1. **Domain boundary** -- What capability is this phase delivering? State it clearly.
169
+
170
+ 2. **Gray areas by category** -- For each relevant category, identify 1-2 specific ambiguities that would change implementation.
171
+
172
+ 3. **Skip assessment** -- If no meaningful gray areas exist (pure infrastructure, clear-cut implementation), note this but still present options.
173
+
174
+ **Output your analysis internally, then present to user.**
175
+
176
+ ## Step 4: Present Gray Areas
177
+
178
+ Present the domain boundary and gray areas to the user.
179
+
180
+ **State the boundary:**
181
+ ```
182
+ Phase {phase_number}: {name}
183
+ Domain: {what this phase delivers -- from your analysis}
184
+
185
+ We'll clarify HOW to implement this.
186
+ (New capabilities belong in other phases.)
187
+ ```
188
+
189
+ **Then present gray areas for selection (via natural conversation):**
190
+ ```
191
+ Which areas do you want to discuss for {phase_name}?
192
+
193
+ 1. {Specific area 1} -- {what decisions this covers}
194
+ 2. {Specific area 2} -- {what decisions this covers}
195
+ 3. {Specific area 3} -- {what decisions this covers}
196
+ 4. {Specific area 4} -- {what decisions this covers}
197
+
198
+ Select by number (e.g., "1, 3" or "all").
199
+ ```
200
+
201
+ Generate 3-4 **phase-specific** gray areas, not generic categories. Each should be a concrete decision area.
202
+
203
+ ## Step 5: Discuss Areas
204
+
205
+ For each selected area, conduct a focused discussion loop.
206
+
207
+ **Philosophy: 4 questions, then check.**
208
+
209
+ Ask 4 questions per area before offering to continue or move on. Each answer often reveals the next question.
210
+
211
+ **For each area:**
212
+
213
+ 1. **Announce the area:**
214
+ ```
215
+ Let's talk about {Area}.
216
+ ```
217
+
218
+ 2. **Ask 4 questions via natural conversation:**
219
+ - Specific decisions for this area
220
+ - Offer 2-3 concrete choices per question
221
+ - Include "You decide" as an option when reasonable -- captures Claude discretion
222
+
223
+ 3. **After 4 questions, check:**
224
+ ```
225
+ More questions about {area}, or move to next?
226
+ ```
227
+ - If "More" -> ask 4 more, then check again
228
+ - If "Next" -> proceed to next selected area
229
+
230
+ 4. **After all initially-selected areas complete:**
231
+ - Summarize what was captured from the discussion so far
232
+ ```
233
+ We've discussed {list areas}. Any remaining gray areas to explore, or ready to create context?
234
+
235
+ 1. Explore more gray areas
236
+ 2. Ready to create context
237
+ ```
238
+ - If "Explore more": Identify 2-4 additional gray areas, present for selection, loop.
239
+ - If "Ready": Proceed to Step 6.
240
+
241
+ **Adaptive probing (thinking-partner mode):**
242
+
243
+ Within each area, adapt your questioning based on the user's certainty level:
244
+ - **User is confident** (picks options quickly) -- probe deeper: "You chose X -- have you considered how that interacts with Y?"
245
+ - **User is uncertain** (hedges) -- propose alternatives: "Here are 3 approaches with trade-offs..."
246
+ - **User defers** (picks "You decide") -- accept but name consequences: "I'll go with X because [reason]. That means Y."
247
+
248
+ Challenge decisions that may have hidden costs. If the user picks something that conflicts with an earlier decision, surface it: "Earlier you said A, but this implies B. Which takes priority?"
249
+
250
+ **Question design:**
251
+ - Options should be concrete, not abstract ("Cards" not "Option A")
252
+ - Each answer should inform the next question
253
+ - If user gives free text, reflect it back and confirm
254
+
255
+ **Scope creep handling:**
256
+ If user mentions something outside the phase domain:
257
+ ```
258
+ "[Feature] sounds like a new capability -- that belongs in its own phase.
259
+ I'll note it as a deferred idea.
260
+
261
+ Back to [current area]: [return to current question]"
262
+ ```
263
+
264
+ Track deferred ideas internally.
265
+ </process>
266
+
267
+ ## Step 6: Write Context
268
+
269
+ Create CONTEXT.md capturing decisions made.
270
+
271
+ **Find or create phase directory:**
272
+
273
+ Use values from init: `phase_dir`, `phase_slug`, `padded_phase`.
274
+
275
+ If `phase_dir` is null (phase exists in roadmap but no directory):
276
+ ```bash
277
+ mkdir -p ".planning/phases/${padded_phase}-${phase_slug}"
278
+ ```
279
+
280
+ **File location:** `${phase_dir}/${padded_phase}-CONTEXT.md`
281
+
282
+ **Structure the content by what was discussed:**
283
+
284
+ ```markdown
285
+ # Phase {X} Context: {Name}
286
+
287
+ **Phase Goal:** {goal from ROADMAP.md}
288
+ **Created:** {date}
289
+ **Requirements:** {requirement IDs if any}
290
+
291
+ ## 1. {Category 1 that was discussed}
292
+
293
+ ### {Decision Area}
294
+ - {Decision or preference captured}
295
+ - {Another decision if applicable}
296
+
297
+ ### {Decision Area}
298
+ - {Decision or preference captured}
299
+
300
+ ## 2. {Category 2 that was discussed}
301
+
302
+ ### {Decision Area}
303
+ - {Decision or preference captured}
304
+
305
+ ## {N}. Claude's Discretion
306
+
307
+ {Areas where user said "you decide" -- note that Claude has flexibility here}
308
+
309
+ ## Deferred Ideas (Captured for Future Phases)
310
+
311
+ | Idea | Target |
312
+ |------|--------|
313
+ | {Deferred idea} | {suggested phase} |
314
+
315
+ {If none: "None -- discussion stayed within phase scope"}
316
+
317
+ ---
318
+ *Context created: {date}*
319
+ *Decisions: {N} across {M} areas*
320
+ ```
321
+
322
+ Write the file.
323
+
324
+ **Commit context:**
325
+ ```bash
326
+ node .claude/maxsim/bin/maxsim-tools.cjs commit "docs(${padded_phase}): capture phase context" --files "${phase_dir}/${padded_phase}-CONTEXT.md"
327
+ ```
328
+
329
+ ## Step 7: Return to Orchestrator
330
+
331
+ After writing CONTEXT.md, return control to the plan.md orchestrator. Do NOT show gate confirmation or next steps -- the orchestrator handles the gate between Discussion and Research.
332
+
333
+ Display a brief completion message:
334
+ ```
335
+ Discussion complete. CONTEXT.md written to {path}.
336
+ ```
337
+
338
+ <success_criteria>
339
+ - Phase validated against roadmap
340
+ - Gray areas identified through intelligent analysis (not generic questions)
341
+ - User selected which areas to discuss
342
+ - Each selected area explored until user satisfied
343
+ - Scope creep redirected to deferred ideas
344
+ - CONTEXT.md captures actual decisions, not vague vision
345
+ - Deferred ideas preserved for future phases
346
+ - Control returned to orchestrator without showing gate or next steps
347
+ </success_criteria>