mindsystem-cc 4.0.1 → 4.0.3

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 (44) hide show
  1. package/README.md +224 -90
  2. package/agents/ms-codebase-researcher.md +5 -9
  3. package/agents/ms-debugger.md +2 -3
  4. package/agents/ms-verifier.md +4 -4
  5. package/bin/install.js +9 -1
  6. package/commands/ms/add-todo.md +1 -1
  7. package/commands/ms/audit-milestone.md +1 -1
  8. package/commands/ms/config.md +8 -10
  9. package/commands/ms/debug.md +1 -1
  10. package/commands/ms/design-phase.md +1 -1
  11. package/commands/ms/execute-phase.md +1 -1
  12. package/commands/ms/help.md +30 -10
  13. package/commands/ms/plan-phase.md +3 -17
  14. package/commands/ms/progress.md +9 -5
  15. package/commands/ms/research-phase.md +1 -1
  16. package/mindsystem/references/continuation-format.md +1 -1
  17. package/mindsystem/references/plan-risk-assessment.md +0 -1
  18. package/mindsystem/references/routing/gap-closure-routing.md +44 -18
  19. package/mindsystem/templates/debug-subagent-prompt.md +0 -5
  20. package/mindsystem/workflows/adhoc.md +5 -4
  21. package/mindsystem/workflows/compound.md +2 -2
  22. package/mindsystem/workflows/discuss-phase.md +1 -1
  23. package/mindsystem/workflows/execute-phase.md +3 -37
  24. package/mindsystem/workflows/execute-plan.md +1 -1
  25. package/mindsystem/workflows/mockup-generation.md +1 -1
  26. package/mindsystem/workflows/plan-phase.md +3 -139
  27. package/package.json +5 -2
  28. package/scripts/ms-tools.py +202 -0
  29. package/mindsystem/workflows/diagnose-issues.md +0 -238
  30. package/scripts/__pycache__/ms-tools.cpython-314.pyc +0 -0
  31. package/scripts/__pycache__/test_ms_tools.cpython-314-pytest-9.0.2.pyc +0 -0
  32. package/scripts/fixtures/scan-context/.planning/ROADMAP.md +0 -16
  33. package/scripts/fixtures/scan-context/.planning/adhoc/20260220-fix-token-SUMMARY.md +0 -12
  34. package/scripts/fixtures/scan-context/.planning/adhoc/20260225-refactor-api/adhoc-01-SUMMARY.md +0 -39
  35. package/scripts/fixtures/scan-context/.planning/config.json +0 -3
  36. package/scripts/fixtures/scan-context/.planning/debug/resolved/token-bug.md +0 -11
  37. package/scripts/fixtures/scan-context/.planning/knowledge/auth.md +0 -11
  38. package/scripts/fixtures/scan-context/.planning/phases/02-infra/02-1-SUMMARY.md +0 -20
  39. package/scripts/fixtures/scan-context/.planning/phases/04-setup/04-1-SUMMARY.md +0 -21
  40. package/scripts/fixtures/scan-context/.planning/phases/05-auth/05-1-SUMMARY.md +0 -28
  41. package/scripts/fixtures/scan-context/.planning/todos/add-logout.md +0 -10
  42. package/scripts/fixtures/scan-context/.planning/todos/done/setup-db.md +0 -10
  43. package/scripts/fixtures/scan-context/expected-output.json +0 -271
  44. package/scripts/test_ms_tools.py +0 -1701
@@ -58,7 +58,7 @@ Infer priority, estimate, and subsystem from description and conversation contex
58
58
  | L | 5 | Multi-file feature, new subsystem area |
59
59
  | XL | 8 | Cross-cutting concern, architectural change |
60
60
 
61
- **Subsystem:** Read `jq -r '.subsystems[]' .planning/config.json 2>/dev/null`. Match against description and conversation context. Must match config.json vocabulary.
61
+ **Subsystem:** Read `ms-tools config-get subsystems`. Match against description and conversation context. Must match config.json vocabulary.
62
62
  </step>
63
63
 
64
64
  <step name="confirm">
@@ -191,7 +191,7 @@ Route by status (see `<offer_next>`).
191
191
  Read code review agent from config:
192
192
 
193
193
  ```bash
194
- CODE_REVIEW=$(cat .planning/config.json 2>/dev/null | jq -r '.code_review.milestone // empty')
194
+ CODE_REVIEW=$(ms-tools config-get code_review.milestone)
195
195
  ```
196
196
 
197
197
  **If CODE_REVIEW = "skip":**
@@ -76,12 +76,10 @@ If "Custom": use AskUserQuestion for each tier (adhoc, phase, milestone) individ
76
76
 
77
77
  If "Skip code review": set all three values to `"skip"`.
78
78
 
79
- Update config.json with selected values via jq:
79
+ Update config.json:
80
80
 
81
81
  ```bash
82
- jq '.code_review = {"adhoc": $a, "phase": $p, "milestone": $m}' \
83
- --arg a "$ADHOC" --arg p "$PHASE" --arg m "$MILESTONE" \
84
- .planning/config.json > .planning/config.tmp && mv .planning/config.tmp .planning/config.json
82
+ ms-tools config-set code_review --json '{"adhoc": "'"$ADHOC"'", "phase": "'"$PHASE"'", "milestone": "'"$MILESTONE"'"}'
85
83
  ```
86
84
 
87
85
  </step>
@@ -119,7 +117,7 @@ If no selections: skip gitignore changes.
119
117
  Read current value:
120
118
 
121
119
  ```bash
122
- CURRENT=$(cat .planning/config.json 2>/dev/null | jq -r '.open_mockups // "auto"')
120
+ CURRENT=$(ms-tools config-get open_mockups --default "auto")
123
121
  echo "Current open_mockups: $CURRENT"
124
122
  ```
125
123
 
@@ -136,10 +134,10 @@ Map selection to config value:
136
134
  - "Ask first" → `"ask"`
137
135
  - "Don't open" → `"off"`
138
136
 
139
- Update config.json with selected value via jq:
137
+ Update config.json:
140
138
 
141
139
  ```bash
142
- jq --arg v "$VALUE" '.open_mockups = $v' .planning/config.json > .planning/config.tmp && mv .planning/config.tmp .planning/config.json
140
+ ms-tools config-set open_mockups "$VALUE"
143
141
  ```
144
142
 
145
143
  </step>
@@ -149,7 +147,7 @@ jq --arg v "$VALUE" '.open_mockups = $v' .planning/config.json > .planning/confi
149
147
  Read current value:
150
148
 
151
149
  ```bash
152
- CURRENT=$(cat .planning/config.json 2>/dev/null | jq -r '.task_tracker.type // "not configured"')
150
+ CURRENT=$(ms-tools config-get task_tracker.type --default "not configured")
153
151
  echo "Current task_tracker: $CURRENT"
154
152
  ```
155
153
 
@@ -175,13 +173,13 @@ If "Custom path": ask user for path via AskUserQuestion.
175
173
  Write to config.json:
176
174
 
177
175
  ```bash
178
- jq '.task_tracker = {"type": "linear", "cli": $cli}' --arg cli "$CLI_PATH" .planning/config.json > .planning/config.tmp && mv .planning/config.tmp .planning/config.json
176
+ ms-tools config-set task_tracker --json '{"type": "linear", "cli": "'"$CLI_PATH"'"}'
179
177
  ```
180
178
 
181
179
  If "None / not yet":
182
180
 
183
181
  ```bash
184
- jq '.task_tracker = null' .planning/config.json > .planning/config.tmp && mv .planning/config.tmp .planning/config.json
182
+ ms-tools config-delete task_tracker
185
183
  ```
186
184
 
187
185
  </step>
@@ -93,7 +93,7 @@ Task(
93
93
  - Display root cause and evidence summary
94
94
  - Offer options:
95
95
  - "Fix now" — spawn ms-debugger with `goal: find_and_fix` and the debug file
96
- - "Plan fix" — suggest /ms:plan-phase --gaps
96
+ - "Plan fix" — suggest `/ms:adhoc` for small fixes, `/ms:insert-phase` for larger scope
97
97
  - "Done" — leave the diagnosis
98
98
 
99
99
  **If `## CHECKPOINT REACHED`:**
@@ -132,7 +132,7 @@ If exists, extract:
132
132
  Match subsystem(s) to this phase by comparing ROADMAP phase description against subsystem names in config.json. Load matching knowledge files:
133
133
 
134
134
  ```bash
135
- jq -r '.subsystems[]' .planning/config.json 2>/dev/null
135
+ ms-tools config-get subsystems
136
136
  cat .planning/knowledge/{matched_subsystem}.md 2>/dev/null
137
137
  ```
138
138
 
@@ -75,7 +75,7 @@ ms-tools find-phase "$ARGUMENTS"
75
75
  - Creates VERIFICATION.md with detailed report
76
76
  - Route by status:
77
77
  - `passed` → continue to step 7
78
- - `gaps_found` → present gaps, offer `/ms:plan-phase {X} --gaps`
78
+ - `gaps_found` → present gaps, route via gap-closure-routing.md triage
79
79
 
80
80
  7. **Code review (optional)**
81
81
  - Read `code_review.phase` from config.json (default: `ms-code-simplifier`)
@@ -64,10 +64,29 @@ Common deviations:
64
64
  - Plan looks wrong: `/ms:discuss-phase <phase>`
65
65
  - Unknown domain: `/ms:research-project` or `/ms:research-phase <phase>`
66
66
  - Phase prep: `/ms:discuss-phase` → `/ms:design-phase` → `/ms:research-phase` → `/ms:plan-phase` (all optional before plan)
67
- - Execution gaps: `/ms:plan-phase <phase> --gaps` then `/ms:execute-phase <phase>`
68
67
  - New urgent work: `/ms:insert-phase <after> "<desc>"`
69
68
  - New non-urgent work: `/ms:add-todo "<desc>"`
70
69
 
70
+ ### Choosing the Right Command
71
+
72
+ **"I found something that needs fixing"**
73
+
74
+ | What you know | Best command | Why |
75
+ |--------------|-------------|-----|
76
+ | Quick fix, single context window | `/ms:adhoc` | Full pipeline (plan, execute, consolidate) in one session |
77
+ | Blocking — must happen before next phase | `/ms:insert-phase` | Creates decimal phase (e.g., 5.1) with full plan-execute cycle |
78
+ | Important but not urgent | `/ms:add-phase` | Appends to roadmap end, planned and executed in sequence |
79
+ | Just capture it for later | `/ms:add-todo` | Flat-file capture with priority and estimate |
80
+
81
+ **"I want to prepare before planning"**
82
+
83
+ | What you need | Best command |
84
+ |--------------|-------------|
85
+ | Align on vision, validate assumptions | `/ms:discuss-phase` |
86
+ | UI layouts, component specs, mockups | `/ms:design-phase` |
87
+ | Stack research, ecosystem knowledge | `/ms:research-phase` |
88
+ | All three (UI-heavy feature) | discuss, then design, then research, then plan |
89
+
71
90
  ### Project Initialization
72
91
 
73
92
  **`/ms:new-project`**
@@ -170,10 +189,10 @@ Comprehensive ecosystem research for niche/complex domains.
170
189
 
171
190
  Usage: `/ms:research-phase 3`
172
191
 
173
- **`/ms:plan-phase [number] [--gaps]`**
192
+ **`/ms:plan-phase [number]`**
174
193
  Create detailed execution plan for a specific phase.
175
194
 
176
- - Use when: you're about to start a phase, or you need additional plans (including verifier-driven gap closure via `--gaps`).
195
+ - Use when: you're about to start a phase.
177
196
  - Generates `.planning/phases/XX-phase-name/XX-YY-PLAN.md`
178
197
  - Breaks phase into concrete, actionable tasks
179
198
  - Includes verification criteria and success measures
@@ -470,9 +489,10 @@ Usage: `/ms:release-notes`
470
489
  ```
471
490
  /ms:plan-phase 5 # Create one or more PLAN.md files
472
491
  /ms:execute-phase 5 # Execute; produces SUMMARY + VERIFICATION
473
- # If gaps found during verification:
474
- /ms:plan-phase 5 --gaps # Create additional plans to close verifier gaps
475
- /ms:execute-phase 5 # Re-run until phase verifies cleanly
492
+ # If gaps found during verification, follow triage recommendation:
493
+ # Small gaps: /ms:adhoc "Close phase 5 gaps: ..."
494
+ # Larger gaps: /ms:insert-phase 5 "Close verification gaps"
495
+ # Minor polish: /ms:add-todo "Phase 5 polish: ..."
476
496
  ```
477
497
 
478
498
  **Found a bug:**
@@ -482,9 +502,9 @@ Usage: `/ms:release-notes`
482
502
  # Then decide where the fix belongs:
483
503
  # - If it fits in a single context window:
484
504
  /ms:adhoc "Fix auth token refresh on 401" # Knowledge-aware fix with consolidation
485
- # - If it's required to satisfy the current phase goal: add more plans to the current phase
486
- /ms:plan-phase 5 # (or: /ms:plan-phase 5 --gaps after verification)
487
- /ms:execute-phase 5
505
+ # - If it's required to satisfy the current phase goal:
506
+ /ms:adhoc "Fix auth token refresh on 401" # Small scope single context
507
+ /ms:insert-phase 5 "Close verification gaps" # Larger scope — full plan-execute cycle
488
508
  # - If it's urgent but should happen before the next phase (and not worth renumbering):
489
509
  /ms:insert-phase 5 "Fix critical auth bug" # Creates 05.1
490
510
  /ms:plan-phase 5.1
@@ -496,7 +516,7 @@ Usage: `/ms:release-notes`
496
516
  **Need to adjust scope (new info, new requirements, or a cut):**
497
517
 
498
518
  Common options:
499
- - If the current phase goal can’t be met: add more plans to the current phase (`/ms:plan-phase <current>` or `/ms:plan-phase <current> --gaps`) then `/ms:execute-phase <current>`
519
+ - If the current phase goal can’t be met: `/ms:adhoc` for small gaps, `/ms:insert-phase` for larger gaps, `/ms:add-todo` for minor polish
500
520
  - Add work later: `/ms:add-phase "…"`
501
521
  - Insert urgent work before the next phase: `/ms:insert-phase <after> "…"`
502
522
  - Cut future work: `/ms:remove-phase <phase>`
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: ms:plan-phase
3
3
  description: Create detailed execution plan for a phase (PLAN.md)
4
- argument-hint: "[phase] [--gaps]"
4
+ argument-hint: "[phase]"
5
5
  allowed-tools:
6
6
  - Read
7
7
  - Bash
@@ -21,8 +21,6 @@ Create executable phase prompt with discovery, context injection, and task break
21
21
  Purpose: Break down roadmap phases into concrete, executable PLAN.md files that Claude can execute.
22
22
  Output: One or more PLAN.md files in the phase directory (.planning/phases/XX-name/{phase}-{plan}-PLAN.md)
23
23
 
24
- **Gap closure mode (`--gaps` flag):**
25
- When invoked with `--gaps`, plans address gaps identified by the verifier. Load VERIFICATION.md, create plans to close specific gaps.
26
24
  </objective>
27
25
 
28
26
  <execution_context>
@@ -32,7 +30,6 @@ When invoked with `--gaps`, plans address gaps identified by the verifier. Load
32
30
 
33
31
  <context>
34
32
  Phase number: $ARGUMENTS (optional - auto-detects next unplanned phase if not provided)
35
- Gap closure mode: `--gaps` flag triggers gap closure workflow
36
33
 
37
34
  **Resolve phase if provided:**
38
35
  ```bash
@@ -76,17 +73,14 @@ Check for and read `.planning/TECH-DEBT.md` — prioritized issues for scope sel
76
73
  **Load codebase context if exists:**
77
74
  Check for `.planning/codebase/` and load relevant documents based on phase type.
78
75
 
79
- **If --gaps flag present, also load:**
80
- @.planning/phases/XX-name/{phase}-VERIFICATION.md — contains structured gaps in YAML frontmatter
81
76
  </context>
82
77
 
83
78
  <process>
84
79
  1. Check .planning/ directory exists (error if not - user should run /ms:new-project)
85
- 2. Parse arguments: extract phase number and check for `--gaps` flag
80
+ 2. Parse arguments: extract phase number
86
81
  3. If phase number provided, validate it exists in roadmap
87
82
  4. If no phase number, detect next unplanned phase from roadmap
88
83
 
89
- **Standard mode (no --gaps flag):**
90
84
  5. Follow plan-phase.md workflow:
91
85
  - Load project state and accumulated decisions
92
86
  - Perform mandatory discovery (Level 0-3 as appropriate)
@@ -97,17 +91,9 @@ Check for `.planning/codebase/` and load relevant documents based on phase type.
97
91
  - Hand off tasks + proposed grouping + confirmed skills to plan-writer subagent
98
92
  - Create PLAN.md file(s) with executable structure
99
93
 
100
- **Gap closure mode (--gaps flag):**
101
- 5. Follow plan-phase.md workflow with gap_closure_mode:
102
- - Load VERIFICATION.md and parse `gaps:` YAML from frontmatter
103
- - Read existing SUMMARYs to understand what's already built
104
- - Create tasks from gaps (each gap.missing item → task candidates)
105
- - Number plans sequentially after existing (if 01-03 exist, create 04, 05...)
106
- - Create PLAN.md file(s) focused on closing specific gaps
107
-
108
94
  6. **Update last command:** `ms-tools set-last-command "ms:plan-phase $ARGUMENTS"`
109
95
 
110
- 7. **Risk assessment** (skip if `--gaps` flag present)
96
+ 7. **Risk assessment**
111
97
  - Calculate risk score from context already loaded (task count, plan count, external services, CONTEXT.md, cross-cutting concerns, new deps, complex domains)
112
98
  - Present score + top factors via AskUserQuestion
113
99
  - Tier-based recommendation: Skip (0-39), Optional (40-69), Verify (70+)
@@ -155,23 +155,27 @@ ms-tools list-artifacts [current-phase-number]
155
155
 
156
156
  State: "This phase has {X} plans, {Y} summaries."
157
157
 
158
- **Step 1.5: Check for unaddressed UAT gaps**
158
+ **Step 1.5: Check for unaddressed gaps**
159
159
 
160
- Check for UAT.md files with status "diagnosed" (has gaps needing fixes).
160
+ Check for VERIFICATION.md with gaps or UAT.md with diagnosed gaps.
161
161
 
162
162
  ```bash
163
+ # Check for verification gaps
164
+ grep -l "status: gaps_found" .planning/phases/[current-phase-dir]/*-VERIFICATION.md 2>/dev/null
165
+
163
166
  # Check for diagnosed UAT with gaps
164
167
  grep -l "status: diagnosed" .planning/phases/[current-phase-dir]/*-UAT.md 2>/dev/null
165
168
  ```
166
169
 
167
170
  Track:
171
+ - `verification_gaps`: VERIFICATION.md files with status "gaps_found"
168
172
  - `uat_with_gaps`: UAT.md files with status "diagnosed" (gaps need fixing)
169
173
 
170
174
  **Step 2: Route based on counts**
171
175
 
172
176
  | Condition | Meaning | Action |
173
177
  |-----------|---------|--------|
174
- | uat_with_gaps > 0 | UAT gaps need fix plans | Go to **Route E** |
178
+ | verification_gaps > 0 OR uat_with_gaps > 0 | Gaps need resolution | Go to **Route E** |
175
179
  | summaries < plans | Unexecuted plans exist | Go to **Route A** |
176
180
  | summaries = plans AND plans > 0 | Phase complete | Go to Step 3 |
177
181
  | plans = 0 | Phase not yet planned | Go to **Route B** |
@@ -246,9 +250,9 @@ Check if `{phase}-CONTEXT.md` exists in phase directory.
246
250
 
247
251
  ---
248
252
 
249
- **Route E: UAT gaps need fix plans**
253
+ **Route E: Verification or UAT gaps need resolution**
250
254
 
251
- UAT.md exists with gaps (diagnosed issues). Read `~/.claude/mindsystem/references/routing/gap-closure-routing.md` and follow its instructions to present the gap closure section.
255
+ VERIFICATION.md or UAT.md exists with gaps. Read `~/.claude/mindsystem/references/routing/gap-closure-routing.md` and follow its triage instructions to present gap summary and route to the appropriate primitive.
252
256
 
253
257
  ---
254
258
 
@@ -69,7 +69,7 @@ cat .planning/phases/${PHASE}-*/${PHASE}-DESIGN.md 2>/dev/null
69
69
  grep -A30 "### Decisions Made" .planning/STATE.md 2>/dev/null
70
70
 
71
71
  # Prior knowledge — match subsystem(s) by comparing phase description against config.json names
72
- jq -r '.subsystems[]' .planning/config.json 2>/dev/null
72
+ ms-tools config-get subsystems
73
73
  cat .planning/knowledge/{matched_subsystem}.md 2>/dev/null
74
74
  ```
75
75
 
@@ -33,7 +33,7 @@ When there's meaningful additional context (like a phase identifier), add it as
33
33
  ## Format Rules
34
34
 
35
35
  1. **Command is the anchor** — backtick command + description on one line, no separate bold label restating the command name
36
- 2. **Phase identifiers are additive context** — `**Phase 2: Auth**` carries info the command doesn't; bold labels like `**Plan gap closure**` just restate `/ms:plan-phase --gaps` and should be omitted
36
+ 2. **Phase identifiers are additive context** — `**Phase 2: Auth**` carries info the command doesn't; bold labels that just restate the command name should be omitted
37
37
  3. **Pull context from source** — ROADMAP.md for phases, PLAN.md `<objective>` for plans
38
38
  4. **Command in inline code** — backticks, easy to copy-paste, renders as clickable link
39
39
  5. **`/clear` explanation** — always include, keeps it concise but explains why
@@ -9,7 +9,6 @@ Provide lightweight risk assessment after plan creation to help users decide whe
9
9
 
10
10
  <skip_conditions>
11
11
  Skip risk assessment entirely when:
12
- - `--gaps` flag present (gap closure plans don't need risk assessment)
13
12
  - Zero plans created (error state)
14
13
  </skip_conditions>
15
14
 
@@ -1,10 +1,10 @@
1
1
  # Gap Closure Routing
2
2
 
3
- Reference for presenting "Next Up" guidance when phase verification found gaps. Used by execute-phase and progress commands.
3
+ Reference for triaging verification and UAT gaps by scope and routing to the appropriate primitive. Used by execute-phase and progress commands.
4
4
 
5
5
  ## Purpose
6
6
 
7
- Guide user toward planning gap closure when VERIFICATION.md reports gaps.
7
+ Analyze VERIFICATION.md or UAT.md gaps and recommend the best primitive based on scope and urgency.
8
8
 
9
9
  ## Variables
10
10
 
@@ -14,22 +14,42 @@ From calling context:
14
14
  - `{N}/{M}` — must-haves score from VERIFICATION.md
15
15
  - `{phase_dir}` — phase directory path
16
16
  - `{phase}` — phase identifier (e.g., "04")
17
- - `{gap_summaries}` — extracted gap summaries from VERIFICATION.md
18
17
 
19
18
  ## Information to Extract
20
19
 
21
- Read VERIFICATION.md for the phase:
20
+ Read the gap source for the phase (one or both may exist):
22
21
 
23
22
  ```bash
24
- cat .planning/phases/${phase_dir}/${phase}-VERIFICATION.md
23
+ # Code verification gaps
24
+ cat .planning/phases/${phase_dir}/${phase}-VERIFICATION.md 2>/dev/null
25
+
26
+ # User testing gaps (status: diagnosed means root causes identified)
27
+ cat .planning/phases/${phase_dir}/${phase}-UAT.md 2>/dev/null
25
28
  ```
26
29
 
27
- Extract:
28
- - Score (must-haves verified count)
30
+ Extract from whichever exists (combine if both present):
31
+ - Score (must-haves verified count, from VERIFICATION.md)
32
+ - Gap count and severity (critical vs non-critical)
29
33
  - Gap summaries from gaps section
30
34
 
35
+ ## Triage Table
36
+
37
+ | Scope | Criteria | Route | Rationale |
38
+ |-------|----------|-------|-----------|
39
+ | Small | 1-2 gaps, localized files, quick fixes | `/ms:adhoc` | Single context window, no multi-plan overhead |
40
+ | Larger (blocking) | 3+ gaps OR cross-cutting, blocks next phase | `/ms:insert-phase` | Needs full plan-execute cycle, preserves phase numbering |
41
+ | Larger (non-blocking) | 3+ gaps OR cross-cutting, next phase can proceed | `/ms:add-phase` | Defers to end of milestone, no urgency |
42
+ | Minor | Cosmetic, non-functional, polish items | `/ms:add-todo` | Capture for later, not worth planning now |
43
+
44
+ **Judgment calls:**
45
+ - If all gaps share the same root cause, treat as small regardless of count
46
+ - If gaps span multiple subsystems, prefer insert-phase even if count is low
47
+ - Mix routes when gaps vary: adhoc for quick wins + insert-phase for larger items
48
+
31
49
  ## Output Format
32
50
 
51
+ Present gap summary, then route recommendation using standard "Next Up" format:
52
+
33
53
  ```markdown
34
54
  ---
35
55
 
@@ -46,7 +66,21 @@ Extract:
46
66
 
47
67
  ## ▶ Next Up
48
68
 
49
- `/ms:plan-phase {Z} --gaps` create additional plans to complete the phase
69
+ {Primary recommendation based on triage:}
70
+
71
+ {If adhoc:}
72
+ `/ms:adhoc "Close phase {Z} gaps: {brief description}"` — fix {N} localized gaps in a single context
73
+
74
+ <sub>Reference: `.planning/phases/{phase_dir}/{phase}-VERIFICATION.md`</sub>
75
+
76
+ {If insert-phase:}
77
+ `/ms:insert-phase {Z} "Close verification gaps"` — plan and execute gap closure as phase {Z}.1
78
+
79
+ {If add-phase:}
80
+ `/ms:add-phase "Close phase {Z} verification gaps"` — defer gap closure to end of milestone
81
+
82
+ {If add-todo:}
83
+ `/ms:add-todo "Phase {Z} polish: {brief description}"` — capture for later
50
84
 
51
85
  <sub>`/clear` first → fresh context window</sub>
52
86
 
@@ -54,16 +88,8 @@ Extract:
54
88
 
55
89
  **Also available:**
56
90
  - `cat .planning/phases/{phase_dir}/{phase}-VERIFICATION.md` — see full report
57
- - `/ms:verify-work {Z}` — manual testing before planning
91
+ - `/ms:verify-work {Z}` — manual testing before fixing
92
+ {Include other routes not chosen as alternatives}
58
93
 
59
94
  ---
60
95
  ```
61
-
62
- ## Gap Closure Flow
63
-
64
- After user runs `/ms:plan-phase {Z} --gaps`:
65
- 1. Planner reads VERIFICATION.md gaps
66
- 2. Creates plans 04, 05, etc. to close gaps
67
- 3. User runs `/ms:execute-phase {Z}` again
68
- 4. Execute-phase runs incomplete plans (04, 05...)
69
- 5. Verifier runs again — loop until passed
@@ -60,11 +60,6 @@ Task(
60
60
  )
61
61
  ```
62
62
 
63
- **From diagnose-issues (UAT):**
64
- ```python
65
- Task(prompt=template, subagent_type="ms-debugger", description="Debug UAT-001")
66
- ```
67
-
68
63
  ---
69
64
 
70
65
  ## Continuation
@@ -38,8 +38,8 @@ Read STATE.md for project context (current phase, accumulated decisions, blocker
38
38
  **Ticket detection:** Check `task_tracker` in config.json. If configured and `$ARGUMENTS` matches the ticket ID pattern, lazy-load `~/.claude/mindsystem/references/{type}-cli.md` and follow its **Ticket Detection** process. If no tracker configured or no match, proceed with `$ARGUMENTS` as free-text.
39
39
 
40
40
  ```bash
41
- TRACKER_TYPE=$(jq -r '.task_tracker.type // empty' .planning/config.json 2>/dev/null)
42
- TRACKER_CLI=$(jq -r '.task_tracker.cli // empty' .planning/config.json 2>/dev/null)
41
+ TRACKER_TYPE=$(ms-tools config-get task_tracker.type)
42
+ TRACKER_CLI=$(ms-tools config-get task_tracker.cli)
43
43
  ```
44
44
 
45
45
  **Todo detection:** If `$ARGUMENTS` matches a `.planning/todos/*.md` file path and the file exists, lazy-load `~/.claude/mindsystem/references/todo-file.md` and follow its **Todo Detection** process. Todo detection is independent of ticket detection — both can be inactive.
@@ -50,7 +50,7 @@ Read subsystems and match knowledge files to work description:
50
50
 
51
51
  ```bash
52
52
  # Read subsystems from config
53
- jq -r '.subsystems[]' .planning/config.json 2>/dev/null
53
+ ms-tools config-get subsystems
54
54
  ```
55
55
 
56
56
  Match keywords from work description against subsystem names. Read matching `.planning/knowledge/*.md` files (1-3 most relevant).
@@ -152,7 +152,8 @@ The executor reads the plan, executes tasks with atomic commits, creates SUMMARY
152
152
  Read code review agent from config:
153
153
 
154
154
  ```bash
155
- CODE_REVIEW=$(cat .planning/config.json 2>/dev/null | jq -r '.code_review.adhoc // .code_review.phase // empty')
155
+ CODE_REVIEW=$(ms-tools config-get code_review.adhoc)
156
+ [ -z "$CODE_REVIEW" ] && CODE_REVIEW=$(ms-tools config-get code_review.phase)
156
157
  ```
157
158
 
158
159
  **If CODE_REVIEW = "skip":** Skip to generate_patch.
@@ -55,7 +55,7 @@ Thoroughness: "medium".
55
55
  Read config.json subsystems and match changes:
56
56
 
57
57
  ```bash
58
- jq -r '.subsystems[]' .planning/config.json 2>/dev/null
58
+ ms-tools config-get subsystems
59
59
  ```
60
60
 
61
61
  **Git/file mode:** Match file paths from diff stats against subsystem names via keyword matching.
@@ -94,7 +94,7 @@ Agent reads changes, reads affected knowledge files, writes updates, returns rep
94
94
  **Update config.json** (if new subsystems were confirmed in step 4):
95
95
  ```bash
96
96
  # Add new subsystem to config.json
97
- jq '.subsystems += ["new-subsystem"]' .planning/config.json > tmp.$$.json && mv tmp.$$.json .planning/config.json
97
+ ms-tools config-set subsystems --append "new-subsystem"
98
98
  ```
99
99
 
100
100
  **Commit changes:**
@@ -57,7 +57,7 @@ Load milestone artifacts and prior knowledge. Handle gracefully when any file is
57
57
  cat .planning/PROJECT.md 2>/dev/null
58
58
  cat .planning/MILESTONE-CONTEXT.md 2>/dev/null
59
59
  cat .planning/REQUIREMENTS.md 2>/dev/null
60
- jq -r '.subsystems[]' .planning/config.json 2>/dev/null
60
+ ms-tools config-get subsystems
61
61
  grep -A20 "Phase ${PHASE}:" .planning/ROADMAP.md
62
62
  ```
63
63
 
@@ -274,7 +274,7 @@ grep "^status:" "$PHASE_DIR"/*-VERIFICATION.md | cut -d: -f2 | tr -d ' '
274
274
  | Status | Action |
275
275
  |--------|--------|
276
276
  | `passed` | Continue to code_review |
277
- | `gaps_found` | Present gap summary, offer `/ms:plan-phase {phase} --gaps` |
277
+ | `gaps_found` | Present gap summary, route via gap-closure-routing.md triage |
278
278
 
279
279
  **If passed:**
280
280
 
@@ -288,48 +288,14 @@ If the verifier's return includes "Items Not Verified Programmatically" (uncerta
288
288
 
289
289
  **If gaps_found:**
290
290
 
291
- Present gaps and offer next command:
292
-
293
- ```markdown
294
- ## ⚠ Phase {X}: {Name} — Gaps Found
295
-
296
- **Score:** {N}/{M} must-haves verified
297
- **Report:** {phase_dir}/{phase}-VERIFICATION.md
298
-
299
- ### What's Missing
300
-
301
- {Extract gap summaries from VERIFICATION.md gaps section}
302
-
303
- ---
304
-
305
- ## ▶ Next Up
306
-
307
- `/ms:plan-phase {X} --gaps` — create additional plans to complete the phase
308
-
309
- <sub>`/clear` first → fresh context window</sub>
310
-
311
- ---
312
-
313
- **Also available:**
314
- - `cat {phase_dir}/{phase}-VERIFICATION.md` — see full report
315
- - `/ms:verify-work {X}` — manual testing before planning
316
- ```
317
-
318
- User runs `/ms:plan-phase {X} --gaps` which:
319
- 1. Reads VERIFICATION.md gaps
320
- 2. Creates additional plans (04, 05, etc.) to close gaps
321
- 3. User then runs `/ms:execute-phase {X}` again
322
- 4. Execute-phase runs incomplete plans (04-05)
323
- 5. Verifier runs again after new plans complete
324
-
325
- User stays in control at each decision point.
291
+ Read `~/.claude/mindsystem/references/routing/gap-closure-routing.md` and follow its triage instructions to present gap summary and route to the appropriate primitive based on scope analysis.
326
292
  </step>
327
293
 
328
294
  <step name="code_review">
329
295
  Read code review agent name from config:
330
296
 
331
297
  ```bash
332
- CODE_REVIEW=$(cat .planning/config.json 2>/dev/null | jq -r '.code_review.phase // empty')
298
+ CODE_REVIEW=$(ms-tools config-get code_review.phase)
333
299
  ```
334
300
 
335
301
  **If CODE_REVIEW = "skip":**
@@ -260,7 +260,7 @@ completed: YYYY-MM-DD
260
260
  ---
261
261
  ```
262
262
 
263
- **Subsystem:** Use inline `**Subsystem:**` metadata from plan header if present. Otherwise select from `jq -r '.subsystems[]' .planning/config.json`. If novel, append to config.json and log in decisions.
263
+ **Subsystem:** Use inline `**Subsystem:**` metadata from plan header if present. Otherwise select from `ms-tools config-get subsystems`. If novel, append to config.json and log in decisions.
264
264
 
265
265
  **Mock hints:** Reflect on what you built. If UI with transient states (loading, animations, async transitions) or external data dependencies, populate accordingly. If purely backend or no async UI, write `mock_hints: none # reason`. Always populate.
266
266
 
@@ -111,7 +111,7 @@ ms-compare-mockups "${PHASE_DIR}/mockups"
111
111
  Read the `open_mockups` config setting:
112
112
 
113
113
  ```bash
114
- OPEN_MOCKUPS=$(cat .planning/config.json 2>/dev/null | jq -r '.open_mockups // "auto"')
114
+ OPEN_MOCKUPS=$(ms-tools config-get open_mockups --default "auto")
115
115
  ```
116
116
 
117
117
  Branch on the value: