mindsystem-cc 3.0.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 (139) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +501 -0
  3. package/agents/ms-codebase-mapper.md +739 -0
  4. package/agents/ms-debugger.md +1184 -0
  5. package/agents/ms-designer.md +414 -0
  6. package/agents/ms-executor.md +760 -0
  7. package/agents/ms-integration-checker.md +423 -0
  8. package/agents/ms-milestone-auditor.md +448 -0
  9. package/agents/ms-mock-generator.md +182 -0
  10. package/agents/ms-plan-checker.md +746 -0
  11. package/agents/ms-research-synthesizer.md +248 -0
  12. package/agents/ms-researcher.md +962 -0
  13. package/agents/ms-roadmapper.md +606 -0
  14. package/agents/ms-verifier.md +779 -0
  15. package/agents/ms-verify-fixer.md +124 -0
  16. package/bin/install.js +296 -0
  17. package/commands/ms/add-phase.md +207 -0
  18. package/commands/ms/add-todo.md +182 -0
  19. package/commands/ms/audit-milestone.md +318 -0
  20. package/commands/ms/check-phase.md +162 -0
  21. package/commands/ms/check-todos.md +217 -0
  22. package/commands/ms/complete-milestone.md +137 -0
  23. package/commands/ms/create-roadmap.md +273 -0
  24. package/commands/ms/debug.md +149 -0
  25. package/commands/ms/define-requirements.md +121 -0
  26. package/commands/ms/design-phase.md +341 -0
  27. package/commands/ms/discuss-milestone.md +48 -0
  28. package/commands/ms/discuss-phase.md +60 -0
  29. package/commands/ms/do-work.md +90 -0
  30. package/commands/ms/execute-phase.md +289 -0
  31. package/commands/ms/help.md +623 -0
  32. package/commands/ms/insert-phase.md +227 -0
  33. package/commands/ms/list-phase-assumptions.md +50 -0
  34. package/commands/ms/map-codebase.md +71 -0
  35. package/commands/ms/new-milestone.md +193 -0
  36. package/commands/ms/new-project.md +338 -0
  37. package/commands/ms/pause-work.md +123 -0
  38. package/commands/ms/plan-milestone-gaps.md +285 -0
  39. package/commands/ms/plan-phase.md +105 -0
  40. package/commands/ms/progress.md +370 -0
  41. package/commands/ms/remove-phase.md +338 -0
  42. package/commands/ms/research-phase.md +175 -0
  43. package/commands/ms/research-project.md +339 -0
  44. package/commands/ms/resume-work.md +40 -0
  45. package/commands/ms/review-design.md +484 -0
  46. package/commands/ms/simplify-flutter.md +193 -0
  47. package/commands/ms/update.md +159 -0
  48. package/commands/ms/verify-work.md +92 -0
  49. package/commands/ms/whats-new.md +124 -0
  50. package/mindsystem/references/checkpoints.md +788 -0
  51. package/mindsystem/references/continuation-format.md +255 -0
  52. package/mindsystem/references/debugging/debugging-mindset.md +11 -0
  53. package/mindsystem/references/debugging/hypothesis-testing.md +11 -0
  54. package/mindsystem/references/debugging/investigation-techniques.md +11 -0
  55. package/mindsystem/references/debugging/verification-patterns.md +11 -0
  56. package/mindsystem/references/debugging/when-to-research.md +11 -0
  57. package/mindsystem/references/git-integration.md +254 -0
  58. package/mindsystem/references/goal-backward.md +286 -0
  59. package/mindsystem/references/mock-patterns.md +294 -0
  60. package/mindsystem/references/plan-format.md +473 -0
  61. package/mindsystem/references/principles.md +73 -0
  62. package/mindsystem/references/questioning.md +140 -0
  63. package/mindsystem/references/research-pitfalls.md +233 -0
  64. package/mindsystem/references/scope-estimation.md +256 -0
  65. package/mindsystem/references/tdd.md +263 -0
  66. package/mindsystem/references/verification-patterns.md +595 -0
  67. package/mindsystem/templates/DEBUG.md +159 -0
  68. package/mindsystem/templates/UAT.md +403 -0
  69. package/mindsystem/templates/adhoc-summary.md +153 -0
  70. package/mindsystem/templates/codebase/architecture.md +255 -0
  71. package/mindsystem/templates/codebase/concerns.md +310 -0
  72. package/mindsystem/templates/codebase/conventions.md +307 -0
  73. package/mindsystem/templates/codebase/integrations.md +280 -0
  74. package/mindsystem/templates/codebase/stack.md +186 -0
  75. package/mindsystem/templates/codebase/structure.md +285 -0
  76. package/mindsystem/templates/codebase/testing.md +480 -0
  77. package/mindsystem/templates/config.json +26 -0
  78. package/mindsystem/templates/context.md +140 -0
  79. package/mindsystem/templates/continue-here.md +78 -0
  80. package/mindsystem/templates/debug-subagent-prompt.md +91 -0
  81. package/mindsystem/templates/design-iteration.md +208 -0
  82. package/mindsystem/templates/design.md +417 -0
  83. package/mindsystem/templates/discovery.md +146 -0
  84. package/mindsystem/templates/milestone-archive.md +123 -0
  85. package/mindsystem/templates/milestone-context.md +93 -0
  86. package/mindsystem/templates/milestone.md +115 -0
  87. package/mindsystem/templates/phase-prompt.md +574 -0
  88. package/mindsystem/templates/project.md +184 -0
  89. package/mindsystem/templates/requirements.md +231 -0
  90. package/mindsystem/templates/research-project/ARCHITECTURE.md +204 -0
  91. package/mindsystem/templates/research-project/FEATURES.md +147 -0
  92. package/mindsystem/templates/research-project/PITFALLS.md +200 -0
  93. package/mindsystem/templates/research-project/STACK.md +120 -0
  94. package/mindsystem/templates/research-project/SUMMARY.md +170 -0
  95. package/mindsystem/templates/research-subagent-prompt.md +92 -0
  96. package/mindsystem/templates/research.md +529 -0
  97. package/mindsystem/templates/roadmap.md +214 -0
  98. package/mindsystem/templates/state.md +224 -0
  99. package/mindsystem/templates/summary.md +269 -0
  100. package/mindsystem/templates/user-setup.md +323 -0
  101. package/mindsystem/templates/verification-report.md +322 -0
  102. package/mindsystem/workflows/complete-milestone.md +759 -0
  103. package/mindsystem/workflows/create-milestone.md +203 -0
  104. package/mindsystem/workflows/debug.md +14 -0
  105. package/mindsystem/workflows/define-requirements.md +330 -0
  106. package/mindsystem/workflows/diagnose-issues.md +241 -0
  107. package/mindsystem/workflows/discovery-phase.md +293 -0
  108. package/mindsystem/workflows/discuss-milestone.md +310 -0
  109. package/mindsystem/workflows/discuss-phase.md +237 -0
  110. package/mindsystem/workflows/do-work.md +359 -0
  111. package/mindsystem/workflows/execute-phase.md +644 -0
  112. package/mindsystem/workflows/execute-plan.md +1828 -0
  113. package/mindsystem/workflows/generate-mocks.md +187 -0
  114. package/mindsystem/workflows/list-phase-assumptions.md +178 -0
  115. package/mindsystem/workflows/map-codebase.md +289 -0
  116. package/mindsystem/workflows/plan-phase.md +876 -0
  117. package/mindsystem/workflows/research-phase.md +17 -0
  118. package/mindsystem/workflows/research-project.md +23 -0
  119. package/mindsystem/workflows/resume-project.md +311 -0
  120. package/mindsystem/workflows/transition.md +564 -0
  121. package/mindsystem/workflows/verify-phase.md +629 -0
  122. package/mindsystem/workflows/verify-work.md +823 -0
  123. package/package.json +32 -0
  124. package/scripts/generate-phase-patch.sh +169 -0
  125. package/scripts/ms-lookup/README.md +112 -0
  126. package/scripts/ms-lookup/ms_lookup/__init__.py +3 -0
  127. package/scripts/ms-lookup/ms_lookup/__main__.py +6 -0
  128. package/scripts/ms-lookup/ms_lookup/backends/__init__.py +6 -0
  129. package/scripts/ms-lookup/ms_lookup/backends/context7.py +219 -0
  130. package/scripts/ms-lookup/ms_lookup/backends/perplexity.py +145 -0
  131. package/scripts/ms-lookup/ms_lookup/cache.py +48 -0
  132. package/scripts/ms-lookup/ms_lookup/cli.py +219 -0
  133. package/scripts/ms-lookup/ms_lookup/config.py +23 -0
  134. package/scripts/ms-lookup/ms_lookup/errors.py +24 -0
  135. package/scripts/ms-lookup/ms_lookup/output.py +49 -0
  136. package/scripts/ms-lookup/ms_lookup/tokens.py +56 -0
  137. package/scripts/ms-lookup/pyproject.toml +17 -0
  138. package/scripts/ms-lookup/uv.lock +207 -0
  139. package/scripts/ms-lookup-wrapper.sh +21 -0
@@ -0,0 +1,876 @@
1
+ <decimal_phase_numbering>
2
+ Decimal phases enable urgent work insertion without renumbering:
3
+
4
+ - Integer phases (1, 2, 3) = planned milestone work
5
+ - Decimal phases (2.1, 2.2) = urgent insertions between integers
6
+
7
+ **Rules:**
8
+ - Decimals between consecutive integers (2.1 between 2 and 3)
9
+ - Filesystem sorting works automatically (2 < 2.1 < 2.2 < 3)
10
+ - Directory format: `02.1-description/`, Plan format: `02.1-01-PLAN.md`
11
+
12
+ **Validation:** Integer X must exist and be complete, X+1 must exist, decimal X.Y must not exist, Y >= 1
13
+ </decimal_phase_numbering>
14
+
15
+ <required_reading>
16
+ **Read these files NOW:**
17
+
18
+ 1. ~/.claude/mindsystem/templates/phase-prompt.md
19
+ 2. ~/.claude/mindsystem/references/plan-format.md
20
+ 3. ~/.claude/mindsystem/references/scope-estimation.md
21
+ 4. ~/.claude/mindsystem/references/checkpoints.md
22
+ 5. ~/.claude/mindsystem/references/tdd.md
23
+ 6. .planning/ROADMAP.md
24
+ 7. .planning/PROJECT.md
25
+
26
+ </required_reading>
27
+
28
+ <purpose>
29
+ Create executable phase prompts (PLAN.md files) optimized for parallel execution.
30
+
31
+ PLAN.md IS the prompt that Claude executes. Plans are grouped into execution waves based on dependencies - independent plans run in parallel, dependent plans wait for predecessors.
32
+ </purpose>
33
+
34
+ <planning_principles>
35
+ **Parallel by default:** Think in dependency graphs, not sequential lists. Ask "what does this need?" not "what comes next?"
36
+
37
+ **Vertical slices over horizontal layers:** Group by feature (User: model + API + UI) not by type (all models → all APIs → all UIs).
38
+
39
+ **Explicit dependencies:** Every plan declares what it needs (`depends_on`) and what it touches (`files_modified`). Empty dependencies = parallel candidate.
40
+
41
+ **Secure by design:** Assume hostile input on every boundary. Validate, parameterize, authenticate, fail closed.
42
+
43
+ **Performance by design:** Assume production load, not demo conditions. Plan for efficient data access, appropriate caching, minimal round trips.
44
+
45
+ **Observable by design:** Plan to debug your own work. Include meaningful error messages, appropriate logging, and clear failure states.
46
+ </planning_principles>
47
+
48
+ <process>
49
+
50
+ <step name="load_project_state" priority="first">
51
+ Read `.planning/STATE.md` and parse:
52
+ - Current position (which phase we're planning)
53
+ - Accumulated decisions (constraints on this phase)
54
+ - Pending todos (candidates for inclusion)
55
+ - Blockers/concerns (things this phase may address)
56
+ - Brief alignment status
57
+
58
+ If STATE.md missing but .planning/ exists, offer to reconstruct or continue without.
59
+ </step>
60
+
61
+ <step name="load_codebase_context">
62
+ Check for codebase map:
63
+
64
+ ```bash
65
+ ls .planning/codebase/*.md 2>/dev/null
66
+ ```
67
+
68
+ **If .planning/codebase/ exists:** Load relevant documents based on phase type:
69
+
70
+ | Phase Keywords | Load These |
71
+ |----------------|------------|
72
+ | UI, frontend, components | CONVENTIONS.md, STRUCTURE.md |
73
+ | API, backend, endpoints | ARCHITECTURE.md, CONVENTIONS.md |
74
+ | database, schema, models | ARCHITECTURE.md, STACK.md |
75
+ | testing, tests | TESTING.md, CONVENTIONS.md |
76
+ | integration, external API | INTEGRATIONS.md, STACK.md |
77
+ | refactor, cleanup | CONCERNS.md, ARCHITECTURE.md |
78
+ | setup, config | STACK.md, STRUCTURE.md |
79
+ | (default) | STACK.md, ARCHITECTURE.md |
80
+
81
+ Track extracted constraints for PLAN.md context section.
82
+ </step>
83
+
84
+ <step name="identify_phase">
85
+ Check roadmap and existing phases:
86
+
87
+ ```bash
88
+ cat .planning/ROADMAP.md
89
+ ls .planning/phases/
90
+ ```
91
+
92
+ If multiple phases available, ask which one to plan. If obvious (first incomplete phase), proceed.
93
+
94
+ **Phase number parsing:** Regex `^(\d+)(?:\.(\d+))?$` - Group 1: integer, Group 2: decimal (optional)
95
+
96
+ **If decimal phase:** Validate integer X exists and is complete, X+1 exists in roadmap, decimal X.Y doesn't exist, Y >= 1.
97
+
98
+ Read any existing PLAN.md or DISCOVERY.md in the phase directory.
99
+
100
+ **Check for --gaps flag:**
101
+ If `--gaps` present in arguments, switch to gap_closure_mode (see `<step name="gap_closure_mode">`).
102
+ </step>
103
+
104
+ <step name="gap_closure_mode">
105
+ **Triggered by `--gaps` flag.** Plans address verification gaps OR UAT gaps.
106
+
107
+ **1. Find gap sources:**
108
+
109
+ ```bash
110
+ PHASE_DIR=$(ls -d .planning/phases/${PHASE_ARG}* 2>/dev/null | head -1)
111
+
112
+ # Check for VERIFICATION.md (code verification gaps)
113
+ ls "$PHASE_DIR"/*-VERIFICATION.md 2>/dev/null
114
+
115
+ # Check for UAT.md with diagnosed status (user testing gaps)
116
+ grep -l "status: diagnosed" "$PHASE_DIR"/*-UAT.md 2>/dev/null
117
+ ```
118
+
119
+ **Priority:** If both exist, load both and combine gaps. UAT gaps (user-discovered) may overlap with verification gaps (code-discovered).
120
+
121
+ **2. Parse gaps:**
122
+
123
+ **From VERIFICATION.md** (if exists): Parse `gaps:` from YAML frontmatter.
124
+
125
+ **From UAT.md** (if exists with status: diagnosed): Parse gaps from `## Gaps` section (YAML format).
126
+
127
+ Each gap has:
128
+ - `truth`: The observable behavior that failed
129
+ - `reason`: Why it failed
130
+ - `artifacts`: Files with issues
131
+ - `missing`: Specific things to add/fix
132
+
133
+ **3. Load existing SUMMARYs:**
134
+
135
+ ```bash
136
+ ls "$PHASE_DIR"/*-SUMMARY.md
137
+ ```
138
+
139
+ Understand what's already built. Gap closure plans reference existing work.
140
+
141
+ **4. Find next plan number:**
142
+
143
+ ```bash
144
+ # Get highest existing plan number
145
+ ls "$PHASE_DIR"/*-PLAN.md | sort -V | tail -1
146
+ ```
147
+
148
+ If plans 01, 02, 03 exist, next is 04.
149
+
150
+ **5. Group gaps into plans:**
151
+
152
+ Cluster related gaps by:
153
+ - Same artifact (multiple issues in Chat.tsx → one plan)
154
+ - Same concern (fetch + render → one "wire frontend" plan)
155
+ - Dependency order (can't wire if artifact is stub → fix stub first)
156
+
157
+ **6. Create gap closure tasks:**
158
+
159
+ For each gap:
160
+ ```xml
161
+ <task name="{fix_description}" type="auto">
162
+ <files>{artifact.path}</files>
163
+ <action>
164
+ {For each item in gap.missing:}
165
+ - {missing item}
166
+
167
+ Reference existing code: {from SUMMARYs}
168
+ Gap reason: {gap.reason}
169
+ </action>
170
+ <verify>{How to confirm gap is closed}</verify>
171
+ <done>{Observable truth now achievable}</done>
172
+ </task>
173
+ ```
174
+
175
+ **7. Write PLAN.md files:**
176
+
177
+ Use standard template but note gap closure context:
178
+
179
+ ```yaml
180
+ ---
181
+ phase: XX-name
182
+ plan: NN # Sequential after existing
183
+ type: execute
184
+ wave: 1 # Gap closures typically single wave
185
+ depends_on: [] # Usually independent of each other
186
+ files_modified: [...]
187
+ autonomous: true
188
+ gap_closure: true # Flag for tracking
189
+ ---
190
+ ```
191
+
192
+ **9. Present gap closure summary:**
193
+
194
+ ```markdown
195
+ ## Gap Closure Plans Created
196
+
197
+ **Phase {X}: {Name}** — closing {N} gaps
198
+
199
+ | Plan | Gaps Addressed | Files |
200
+ |------|----------------|-------|
201
+ | {phase}-04 | {gap truths} | {files} |
202
+ | {phase}-05 | {gap truths} | {files} |
203
+
204
+ ---
205
+
206
+ ## ▶ Next Up
207
+
208
+ **Execute gap closure plans**
209
+
210
+ `/ms:execute-phase {X}`
211
+
212
+ <sub>`/clear` first → fresh context window</sub>
213
+
214
+ ---
215
+ ```
216
+
217
+ **Skip directly to git_commit step after creating plans.**
218
+ </step>
219
+
220
+ <step name="mandatory_discovery">
221
+ **Discovery is MANDATORY unless you can prove current context exists.**
222
+
223
+ <discovery_decision>
224
+ **Level 0 - Skip** (pure internal work, existing patterns only)
225
+ - ALL work follows established codebase patterns (grep confirms)
226
+ - No new external dependencies
227
+ - Pure internal refactoring or feature extension
228
+ - Examples: Add delete button, add field to model, create CRUD endpoint
229
+
230
+ **Level 1 - Quick Verification** (2-5 min)
231
+ - Single known library, confirming syntax/version
232
+ - Low-risk decision (easily changed later)
233
+ - Action: Context7 resolve-library-id + query-docs, no DISCOVERY.md needed
234
+
235
+ **Level 2 - Standard Research** (15-30 min)
236
+ - Choosing between 2-3 options
237
+ - New external integration (API, service)
238
+ - Medium-risk decision
239
+ - Action: Route to workflows/discovery-phase.md depth=standard, produces DISCOVERY.md
240
+
241
+ **Level 3 - Deep Dive** (1+ hour)
242
+ - Architectural decision with long-term impact
243
+ - Novel problem without clear patterns
244
+ - High-risk, hard to change later
245
+ - Action: Route to workflows/discovery-phase.md depth=deep, full DISCOVERY.md
246
+
247
+ **Depth indicators:**
248
+ - Level 2+: New library not in package.json, external API, "choose/select/evaluate" in description, roadmap marked Research: Yes
249
+ - Level 3: "architecture/design/system", multiple external services, data modeling, auth design, real-time/distributed
250
+ </discovery_decision>
251
+
252
+ If roadmap flagged `Research: Likely`, Level 0 (skip) is not available.
253
+
254
+ For niche domains (3D, games, audio, shaders, ML), suggest `/ms:research-phase` before plan-phase.
255
+ </step>
256
+
257
+ <step name="read_project_history">
258
+ **Intelligent context assembly from frontmatter dependency graph:**
259
+
260
+ **1. Scan all summary frontmatter (cheap - first ~25 lines):**
261
+
262
+ ```bash
263
+ for f in .planning/phases/*/*-SUMMARY.md; do
264
+ # Extract frontmatter only (between first two --- markers)
265
+ sed -n '1,/^---$/p; /^---$/q' "$f" | head -30
266
+ done
267
+ ```
268
+
269
+ Parse YAML to extract: phase, subsystem, requires, provides, affects, tags, key-decisions, key-files
270
+
271
+ **2. Build dependency graph for current phase:**
272
+
273
+ - **Check affects field:** Which prior phases have current phase in their `affects` list? → Direct dependencies
274
+ - **Check subsystem:** Which prior phases share same subsystem? → Related work
275
+ - **Check requires chains:** If phase X requires phase Y, and we need X, we also need Y → Transitive dependencies
276
+ - **Check roadmap:** Any phases marked as dependencies in ROADMAP.md phase description?
277
+
278
+ **3. Select relevant summaries:**
279
+
280
+ Auto-select phases that match ANY of:
281
+ - Current phase name/number appears in prior phase's `affects` field
282
+ - Same `subsystem` value
283
+ - In `requires` chain (transitive closure)
284
+ - Explicitly mentioned in STATE.md decisions as affecting current phase
285
+
286
+ Typical selection: 2-4 prior phases (immediately prior + related subsystem work)
287
+
288
+ **4. Extract context from frontmatter (WITHOUT opening full summaries yet):**
289
+
290
+ From selected phases' frontmatter, extract:
291
+ - **Tech available:** Union of all tech-stack.added lists
292
+ - **Patterns established:** Union of all tech-stack.patterns and patterns-established
293
+ - **Key files:** Union of all key-files (for @context references)
294
+ - **Decisions:** Extract key-decisions from frontmatter
295
+
296
+ **5. Now read FULL summaries for selected phases:**
297
+
298
+ Only now open and read complete SUMMARY.md files for the selected relevant phases. Extract:
299
+ - Detailed "Accomplishments" section
300
+ - "Next Phase Readiness" warnings/blockers
301
+ - "Issues Encountered" that might affect current phase
302
+ - "Deviations from Plan" for patterns
303
+
304
+ **From STATE.md:** Decisions → constrain approach. Pending todos → candidates. Blockers → may need to address.
305
+
306
+ **From pending todos:**
307
+
308
+ ```bash
309
+ ls .planning/todos/pending/*.md 2>/dev/null
310
+ ```
311
+
312
+ Assess each pending todo - relevant to this phase? Natural to address now?
313
+
314
+ **Answer before proceeding:**
315
+ - Q1: What decisions from previous phases constrain this phase?
316
+ - Q2: Are there pending todos that should become tasks?
317
+ - Q3: Are there concerns from "Next Phase Readiness" that apply?
318
+ - Q4: Given all context, does the roadmap's description still make sense?
319
+
320
+ **Track for PLAN.md context section:**
321
+ - Which summaries were selected (for @context references)
322
+ - Tech stack available (from frontmatter)
323
+ - Established patterns (from frontmatter)
324
+ - Key files to reference (from frontmatter)
325
+ - Applicable decisions (from frontmatter + full summary)
326
+ - Todos being addressed (from pending todos)
327
+ - Concerns being verified (from "Next Phase Readiness")
328
+ </step>
329
+
330
+ <step name="gather_phase_context">
331
+ Understand:
332
+ - Phase goal (from roadmap)
333
+ - What exists already (scan codebase if mid-project)
334
+ - Dependencies met (previous phases complete?)
335
+ - Any {phase}-RESEARCH.md (from /ms:research-phase)
336
+ - Any DISCOVERY.md (from mandatory discovery)
337
+ - Any {phase}-CONTEXT.md (from /ms:discuss-phase)
338
+ - Any {phase}-DESIGN.md (from /ms:design-phase)
339
+
340
+ ```bash
341
+ # If mid-project, understand current state
342
+ ls -la src/ 2>/dev/null
343
+ cat package.json 2>/dev/null | head -20
344
+
345
+ # Check for ecosystem research (from /ms:research-phase)
346
+ cat .planning/phases/XX-name/${PHASE}-RESEARCH.md 2>/dev/null
347
+
348
+ # Check for phase context (from /ms:discuss-phase)
349
+ cat .planning/phases/XX-name/${PHASE}-CONTEXT.md 2>/dev/null
350
+
351
+ # Check for design specs (from /ms:design-phase)
352
+ cat .planning/phases/XX-name/${PHASE}-DESIGN.md 2>/dev/null
353
+ ```
354
+
355
+ **If RESEARCH.md exists:** Use standard_stack (these libraries), architecture_patterns (follow in task structure), dont_hand_roll (NEVER custom solutions for listed problems), common_pitfalls (inform verification), code_examples (reference in actions).
356
+
357
+ **If CONTEXT.md exists:** Honor vision, prioritize essential, respect boundaries, incorporate specifics.
358
+
359
+ **If DESIGN.md exists:**
360
+ - Tasks reference specific screens/components from design
361
+ - Verification criteria include design verification items
362
+ - must_haves include design-specified observable behaviors
363
+ - Task actions specify exact values (colors, spacing) from design
364
+
365
+ **If none exist:** Suggest /ms:research-phase for niche domains, /ms:discuss-phase for simpler domains, or proceed with roadmap only.
366
+ </step>
367
+
368
+ <step name="break_into_tasks">
369
+ Decompose phase into tasks. **Think dependencies first, not sequence.**
370
+
371
+ For each potential task, ask:
372
+ 1. **What does this task NEED?** (files, types, APIs that must exist)
373
+ 2. **What does this task CREATE?** (files, types, APIs others might need)
374
+ 3. **Can this run independently?** (no dependencies = Wave 1 candidate)
375
+
376
+ **Standard tasks need:**
377
+ - **Type**: auto, checkpoint:human-verify, checkpoint:decision (human-action rarely needed)
378
+ - **Task name**: Clear, action-oriented
379
+ - **Files**: Which files created/modified (for auto tasks)
380
+ - **Action**: Specific implementation (including what to avoid and WHY)
381
+ - **Verify**: How to prove it worked
382
+ - **Done**: Acceptance criteria
383
+
384
+ **TDD detection:** For each potential task, evaluate TDD fit:
385
+
386
+ TDD candidates (create dedicated TDD plans):
387
+ - Business logic with defined inputs/outputs
388
+ - API endpoints with request/response contracts
389
+ - Data transformations, parsing, formatting
390
+ - Validation rules and constraints
391
+ - Algorithms with testable behavior
392
+ - State machines and workflows
393
+
394
+ Standard tasks (remain in standard plans):
395
+ - UI layout, styling, visual components
396
+ - Configuration changes
397
+ - Glue code connecting existing components
398
+ - One-off scripts and migrations
399
+ - Simple CRUD with no business logic
400
+
401
+ **Heuristic:** Can you write `expect(fn(input)).toBe(output)` before writing `fn`?
402
+ → Yes: Create a dedicated TDD plan for this feature (one feature per TDD plan)
403
+ → No: Standard task in standard plan
404
+
405
+ **Why TDD gets its own plan:** TDD requires 2-3 execution cycles (RED → GREEN → REFACTOR), each with file reads, test runs, and potential debugging. Embedded in a multi-task plan, TDD work consumes 50-60% of context alone, degrading quality for remaining tasks.
406
+
407
+ **Test framework:** If project has no test setup and TDD plans are needed, the first TDD plan's RED phase handles framework setup as part of writing the first test.
408
+
409
+ See `~/.claude/mindsystem/references/tdd.md` for TDD plan structure.
410
+
411
+ **Checkpoints:** Visual/functional verification → checkpoint:human-verify. Implementation choices → checkpoint:decision. Manual action (email, 2FA) → checkpoint:human-action (rare).
412
+
413
+ **Critical:** If external resource has CLI/API (Vercel, Stripe, etc.), use type="auto" to automate. Only checkpoint for verification AFTER automation.
414
+
415
+ See ~/.claude/mindsystem/references/checkpoints.md for checkpoint structure.
416
+
417
+ **User setup detection:** For tasks involving external services, identify human-required configuration:
418
+
419
+ External service indicators:
420
+ - New SDK: `stripe`, `@sendgrid/mail`, `twilio`, `openai`, `@supabase/supabase-js`
421
+ - Webhook handlers: Files in `**/webhooks/**` or `**/webhook*`
422
+ - OAuth integration: Social login, third-party auth
423
+ - API keys: Code referencing `process.env.SERVICE_*` patterns
424
+
425
+ For each external service, determine:
426
+ 1. **Env vars needed** - What secrets must be retrieved from dashboards?
427
+ 2. **Account setup** - Does user need to create an account?
428
+ 3. **Dashboard config** - What must be configured in external UI?
429
+ 4. **Local dev** - Any CLI tools for local testing?
430
+
431
+ Record in `user_setup` frontmatter (see write_phase_prompt step).
432
+ </step>
433
+
434
+ <step name="build_dependency_graph">
435
+ **Map task dependencies explicitly before grouping into plans.**
436
+
437
+ **1. For each task identified, record:**
438
+ - `needs`: What must exist before this task runs (files, types, prior task outputs)
439
+ - `creates`: What this task produces (files, types, exports)
440
+ - `has_checkpoint`: Does this task require user interaction?
441
+
442
+ **2. Build the dependency graph:**
443
+
444
+ ```
445
+ Example phase with 6 tasks:
446
+
447
+ Task A (User model): needs nothing, creates src/models/user.ts
448
+ Task B (Product model): needs nothing, creates src/models/product.ts
449
+ Task C (User API): needs Task A, creates src/api/users.ts
450
+ Task D (Product API): needs Task B, creates src/api/products.ts
451
+ Task E (Dashboard): needs Task C + D, creates src/components/Dashboard.tsx
452
+ Task F (Verify UI): checkpoint:human-verify, needs Task E
453
+
454
+ Dependency graph:
455
+ A ──→ C ──┐
456
+ ├──→ E ──→ F
457
+ B ──→ D ──┘
458
+
459
+ Wave analysis:
460
+ Wave 1: A, B (independent roots)
461
+ Wave 2: C, D (depend only on Wave 1)
462
+ Wave 3: E (depends on Wave 2)
463
+ Wave 4: F (checkpoint, depends on Wave 3)
464
+ ```
465
+
466
+ **3. Identify parallelization opportunities:**
467
+
468
+ | Pattern | Result |
469
+ |---------|--------|
470
+ | No dependencies | Wave 1 (parallel) |
471
+ | Depends only on Wave 1 | Wave 2 (parallel) |
472
+ | Has checkpoint | Runs in wave, but can pause/resume |
473
+ | Shared file conflict | Must be sequential |
474
+
475
+ **4. Detect and prefer vertical slices:**
476
+
477
+ **Sequential (horizontal layers) - AVOID:**
478
+ ```
479
+ Plan 01: Create User model, Product model, Order model
480
+ Plan 02: Create User API, Product API, Order API
481
+ Plan 03: Create User UI, Product UI, Order UI
482
+ ```
483
+ Result: Fully sequential (02 needs 01, 03 needs 02)
484
+
485
+ **Parallel (vertical slices) - PREFER:**
486
+ ```
487
+ Plan 01: User feature (model + API + UI)
488
+ Plan 02: Product feature (model + API + UI)
489
+ Plan 03: Order feature (model + API + UI)
490
+ ```
491
+ Result: All three can run in parallel (Wave 1)
492
+
493
+ **When vertical slices work:**
494
+ - Features are independent (no shared types/data)
495
+ - Each slice is self-contained
496
+ - No cross-feature dependencies
497
+
498
+ **When horizontal layers are necessary:**
499
+ - Shared foundation required (auth before protected features)
500
+ - Genuine type dependencies (Order needs User type)
501
+ - Infrastructure setup (database before all features)
502
+
503
+ **5. Output: Dependency map for each plan**
504
+
505
+ For each plan, determine:
506
+ - `depends_on: []` - plan IDs this plan requires (empty = parallel candidate)
507
+ - `files_modified: []` - files this plan touches (for conflict detection)
508
+ - `autonomous: true|false` - has checkpoints requiring user interaction?
509
+ </step>
510
+
511
+ <step name="assign_waves">
512
+ **Compute wave numbers before writing plans.**
513
+
514
+ Wave assignment algorithm (run in memory before writing any files):
515
+
516
+ ```
517
+ waves = {} # plan_id -> wave_number
518
+
519
+ for each plan in plan_order:
520
+ if plan.depends_on is empty:
521
+ plan.wave = 1
522
+ else:
523
+ # Wave = max wave of dependencies + 1
524
+ plan.wave = max(waves[dep] for dep in plan.depends_on) + 1
525
+
526
+ waves[plan.id] = plan.wave
527
+ ```
528
+
529
+ **Example:**
530
+
531
+ ```
532
+ Plan 01: depends_on: [] → wave: 1
533
+ Plan 02: depends_on: [] → wave: 1
534
+ Plan 03: depends_on: ["01"] → wave: 2
535
+ Plan 04: depends_on: ["02"] → wave: 2
536
+ Plan 05: depends_on: ["03", "04"] → wave: 3
537
+ ```
538
+
539
+ Store wave number with each plan in memory. Write to frontmatter in next step.
540
+ </step>
541
+
542
+ <step name="group_into_plans">
543
+ **Group tasks into plans based on dependency waves and autonomy.**
544
+
545
+ **Grouping rules:**
546
+
547
+ 1. **Same-wave tasks with no file conflicts → can be in parallel plans**
548
+ 2. **Tasks with shared files → must be in same plan or sequential plans**
549
+ 3. **Checkpoint tasks → mark plan as `autonomous: false`**
550
+ 4. **Each plan: 2-3 tasks max, single concern, ~50% context target**
551
+
552
+ **Plan assignment algorithm:**
553
+
554
+ ```
555
+ 1. Start with Wave 1 tasks (no dependencies)
556
+ 2. Group into plans by:
557
+ - Feature affinity (vertical slice)
558
+ - File ownership (no conflicts)
559
+ - Checkpoint presence (group checkpoints with related auto tasks)
560
+ 3. Move to Wave 2 tasks, repeat
561
+ 4. Continue until all tasks assigned
562
+ ```
563
+
564
+ **Example grouping:**
565
+
566
+ ```
567
+ Tasks identified:
568
+ - A: User model (Wave 1, auto)
569
+ - B: Product model (Wave 1, auto)
570
+ - C: User API (Wave 2, auto)
571
+ - D: Product API (Wave 2, auto)
572
+ - E: Dashboard (Wave 3, auto)
573
+ - F: Verify Dashboard (Wave 3, checkpoint)
574
+
575
+ Grouping into plans:
576
+ Plan 01: [A, C] - User feature (model + API)
577
+ depends_on: [], autonomous: true
578
+
579
+ Plan 02: [B, D] - Product feature (model + API)
580
+ depends_on: [], autonomous: true
581
+
582
+ Plan 03: [E, F] - Dashboard (build + verify)
583
+ depends_on: ["01", "02"], autonomous: false
584
+
585
+ Wave structure:
586
+ Wave 1 (parallel): Plan 01, Plan 02
587
+ Wave 2: Plan 03 (has checkpoint, runs after Wave 1)
588
+ ```
589
+ </step>
590
+
591
+ <step name="estimate_scope">
592
+ After grouping, verify each plan fits context budget.
593
+
594
+ **Check depth setting:**
595
+ ```bash
596
+ cat .planning/config.json 2>/dev/null | grep depth
597
+ ```
598
+
599
+ <depth_aware_splitting>
600
+ **Depth controls compression tolerance, not artificial inflation.**
601
+
602
+ | Depth | Typical Plans/Phase | Tasks/Plan |
603
+ |-------|---------------------|------------|
604
+ | Quick | 1-3 | 2-3 |
605
+ | Standard | 3-5 | 2-3 |
606
+ | Comprehensive | 5-10 | 2-3 |
607
+
608
+ **Key principle:** Derive plans from actual work. Depth determines how aggressively you combine things, not a target to hit.
609
+
610
+ - Comprehensive auth phase = 8 plans (because auth genuinely has 8 concerns)
611
+ - Comprehensive "add config file" phase = 1 plan (because that's all it is)
612
+
613
+ For comprehensive depth:
614
+ - Create MORE plans when the work warrants it, not bigger ones
615
+ - If a phase has 15 tasks, that's 5-8 plans (not 3 plans with 5 tasks each)
616
+ - Each plan stays focused: 2-3 tasks, single concern
617
+
618
+ For quick depth:
619
+ - Combine aggressively into fewer plans
620
+ - 1-3 plans per phase is fine
621
+ - Focus on critical path
622
+ </depth_aware_splitting>
623
+
624
+ **ALWAYS split if:** >3 tasks, multiple subsystems, >5 files in any task, complex domains (auth, payments).
625
+
626
+ **Each plan must be:** 2-3 tasks max, ~50% context target, independently committable.
627
+
628
+ See ~/.claude/mindsystem/references/scope-estimation.md for complete guidance.
629
+ </step>
630
+
631
+ <step name="confirm_breakdown">
632
+ <if mode="yolo">
633
+ Auto-approve and proceed to write_phase_prompt.
634
+ </if>
635
+
636
+ <if mode="interactive">
637
+ Present breakdown with wave structure:
638
+
639
+ ```
640
+ Phase [X] breakdown:
641
+
642
+ ## Execution Waves
643
+
644
+ **Wave 1 (parallel):**
645
+ {phase}-01: [Plan Name] [autonomous]
646
+ - Task: [brief]
647
+ - Task: [brief]
648
+
649
+ {phase}-02: [Plan Name] [autonomous]
650
+ - Task: [brief]
651
+ - Task: [brief]
652
+
653
+ **Wave 2 (parallel):**
654
+ {phase}-03: [Plan Name] (depends: 01, 02) [autonomous]
655
+ - Task: [brief]
656
+
657
+ **Wave 3:**
658
+ {phase}-04: [Plan Name] (depends: 03) [has checkpoint]
659
+ - Task: [brief]
660
+ - Checkpoint: [type]
661
+
662
+ ---
663
+ Total: [N] plans in [M] waves
664
+ Parallel plans: [X]
665
+ Sequential plans: [Y]
666
+
667
+ Does this look right? (yes / adjust / start over)
668
+ ```
669
+
670
+ Wait for confirmation. If "adjust": revise. If "start over": return to gather_phase_context.
671
+ </if>
672
+ </step>
673
+
674
+ <step name="write_phase_prompt">
675
+ Use template from `~/.claude/mindsystem/templates/phase-prompt.md`.
676
+
677
+ **Single plan:** Write to `.planning/phases/XX-name/{phase}-01-PLAN.md`
678
+
679
+ **Multiple plans:** Write separate files ({phase}-01-PLAN.md, {phase}-02-PLAN.md, etc.)
680
+
681
+ Each plan follows template structure with:
682
+ - Frontmatter (phase, plan, type, depends_on, files_modified, autonomous, domain)
683
+ - Objective (plan-specific goal, purpose, output)
684
+ - Execution context (execute-plan.md, summary template, checkpoints.md if needed)
685
+ - Context (@references to PROJECT, ROADMAP, STATE, codebase docs, RESEARCH/DISCOVERY/CONTEXT if exist, prior summaries, source files)
686
+ - Tasks (XML format with types)
687
+ - Verification, Success criteria, Output specification
688
+
689
+ **Plan frontmatter:**
690
+
691
+ ```yaml
692
+ ---
693
+ phase: XX-name
694
+ plan: NN
695
+ type: execute
696
+ wave: N # Execution wave (1, 2, 3...). Computed at plan time.
697
+ depends_on: [] # Plan IDs this plan requires.
698
+ files_modified: [] # Files this plan touches.
699
+ autonomous: true # false if plan has checkpoints requiring user interaction
700
+ domain: [optional]
701
+ user_setup: [] # Human-required setup (omit if empty)
702
+ ---
703
+ ```
704
+
705
+ **User setup frontmatter (when external services involved):**
706
+
707
+ ```yaml
708
+ user_setup:
709
+ - service: stripe
710
+ why: "Payment processing"
711
+ env_vars:
712
+ - name: STRIPE_SECRET_KEY
713
+ source: "Stripe Dashboard → Developers → API keys → Secret key"
714
+ - name: STRIPE_WEBHOOK_SECRET
715
+ source: "Stripe Dashboard → Developers → Webhooks → Signing secret"
716
+ account_setup:
717
+ - url: "https://dashboard.stripe.com/register"
718
+ skip_if: "Already have Stripe account"
719
+ dashboard_config:
720
+ - task: "Create webhook endpoint"
721
+ location: "Stripe Dashboard → Developers → Webhooks → Add endpoint"
722
+ details: "URL: https://[your-domain]/api/webhooks/stripe, Events: checkout.session.completed"
723
+ local_dev:
724
+ - "stripe listen --forward-to localhost:3000/api/webhooks/stripe"
725
+ ```
726
+
727
+ **Automation-first rule:** Only include setup Claude literally cannot do:
728
+ - Account creation (requires human signup)
729
+ - Secret retrieval (requires dashboard access)
730
+ - Dashboard configuration (requires human in browser)
731
+
732
+ Do NOT include: npm install, code changes, file creation, CLI commands Claude can run.
733
+
734
+ **Wave is pre-computed:** Wave numbers are assigned during planning (see `assign_waves` step). `/ms:execute-phase` reads `wave` directly from frontmatter and groups plans by wave number. No runtime dependency analysis needed.
735
+
736
+ **Context section - parallel-aware:**
737
+
738
+ Only include prior plan SUMMARY references if this plan genuinely needs decisions/outputs:
739
+
740
+ ```markdown
741
+ <context>
742
+ @.planning/PROJECT.md
743
+ @.planning/ROADMAP.md
744
+ @.planning/STATE.md
745
+
746
+ # Only reference prior plans if genuinely needed:
747
+ # - This plan uses types/exports from prior plan
748
+ # - This plan continues work from prior plan
749
+ # - Prior plan made decision that affects this plan
750
+ #
751
+ # Do NOT reflexively chain: Plan 02 refs 01, Plan 03 refs 02...
752
+ # Independent plans need no prior SUMMARY references.
753
+
754
+ @path/to/relevant/source.ts
755
+ </context>
756
+ ```
757
+
758
+ **For plans with checkpoints:**
759
+
760
+ Include checkpoint reference in execution_context:
761
+ ```markdown
762
+ <execution_context>
763
+ @~/.claude/mindsystem/workflows/execute-plan.md
764
+ @~/.claude/mindsystem/templates/summary.md
765
+ @~/.claude/mindsystem/references/checkpoints.md
766
+ </execution_context>
767
+ ```
768
+
769
+ Checkpoint plans can still run in parallel waves. When they hit a checkpoint, they pause and return to the orchestrator. User responds, orchestrator resumes the agent.
770
+ </step>
771
+
772
+ <step name="git_commit">
773
+ Commit phase plan(s):
774
+
775
+ ```bash
776
+ # Stage all PLAN.md files for this phase
777
+ git add .planning/phases/${PHASE}-*/${PHASE}-*-PLAN.md
778
+
779
+ # Also stage DISCOVERY.md if it was created during mandatory_discovery
780
+ git add .planning/phases/${PHASE}-*/DISCOVERY.md 2>/dev/null
781
+
782
+ git commit -m "$(cat <<'EOF'
783
+ docs(${PHASE}): create phase plan
784
+
785
+ Phase ${PHASE}: ${PHASE_NAME}
786
+ - [N] plan(s) in [M] wave(s)
787
+ - [X] parallel, [Y] sequential
788
+ - Ready for execution
789
+ EOF
790
+ )"
791
+ ```
792
+
793
+ Confirm: "Committed: docs(${PHASE}): create phase plan"
794
+ </step>
795
+
796
+ <step name="offer_next">
797
+ ```
798
+ Phase {X} planned: {N} plan(s) in {M} wave(s)
799
+
800
+ ## Wave Structure
801
+ Wave 1 (parallel): {plan-01}, {plan-02}
802
+ Wave 2: {plan-03}
803
+ ...
804
+
805
+ ---
806
+
807
+ ## Next Up
808
+
809
+ **Phase {X}: [Phase Name]** - {N} plan(s) in {M} wave(s)
810
+
811
+ `/ms:execute-phase {X}`
812
+
813
+ <sub>`/clear` first - fresh context window</sub>
814
+
815
+ ---
816
+
817
+ **Also available:**
818
+ - Review/adjust plans before executing
819
+ - View all plans: `ls .planning/phases/XX-name/*-PLAN.md`
820
+
821
+ ---
822
+ ```
823
+ </step>
824
+
825
+ </process>
826
+
827
+ <task_quality>
828
+ **Good tasks:** Specific files, actions, verification
829
+ - "Add User model to Prisma schema with email, passwordHash, createdAt"
830
+ - "Create POST /api/auth/login endpoint with bcrypt validation"
831
+
832
+ **Bad tasks:** Vague, not actionable
833
+ - "Set up authentication" / "Make it secure" / "Handle edge cases"
834
+
835
+ If you can't specify Files + Action + Verify + Done, the task is too vague.
836
+
837
+ **TDD candidates get dedicated plans.** If "Create price calculator with discount rules" warrants TDD, create a TDD plan for it. See `~/.claude/mindsystem/references/tdd.md` for TDD plan structure.
838
+ </task_quality>
839
+
840
+ <anti_patterns>
841
+ - No story points or hour estimates
842
+ - No team assignments
843
+ - No acceptance criteria committees
844
+ - No sub-sub-sub tasks
845
+ - **No reflexive sequential chaining** (Plan 02 depends on 01 "just because")
846
+ Tasks are instructions for Claude, not Jira tickets.
847
+ </anti_patterns>
848
+
849
+ <success_criteria>
850
+ **Standard mode** — Phase planning complete when:
851
+ - [ ] STATE.md read, project history absorbed
852
+ - [ ] Mandatory discovery completed (Level 0-3)
853
+ - [ ] Prior decisions, issues, concerns synthesized
854
+ - [ ] Dependency graph built (needs/creates for each task)
855
+ - [ ] Tasks grouped into plans by wave, not by sequence
856
+ - [ ] PLAN file(s) exist with XML structure
857
+ - [ ] Each plan: depends_on, files_modified, autonomous in frontmatter
858
+ - [ ] Each plan: user_setup declared if external services involved
859
+ - [ ] Each plan: Objective, context, tasks, verification, success criteria, output
860
+ - [ ] Each plan: 2-3 tasks (~50% context)
861
+ - [ ] Each task: Type, Files (if auto), Action, Verify, Done
862
+ - [ ] Checkpoints properly structured
863
+ - [ ] Wave structure maximizes parallelism
864
+ - [ ] PLAN file(s) committed to git
865
+ - [ ] User knows next steps and wave structure
866
+
867
+ **Gap closure mode (`--gaps`)** — Planning complete when:
868
+ - [ ] VERIFICATION.md loaded and gaps parsed
869
+ - [ ] Existing SUMMARYs read for context
870
+ - [ ] Gaps clustered into focused plans
871
+ - [ ] Plan numbers sequential after existing (04, 05...)
872
+ - [ ] PLAN file(s) exist with gap_closure: true
873
+ - [ ] Each plan: tasks derived from gap.missing items
874
+ - [ ] PLAN file(s) committed to git
875
+ - [ ] User knows to run `/ms:execute-phase {X}` next
876
+ </success_criteria>