mindsystem-cc 4.5.0 → 4.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -29,12 +29,12 @@ Then `/ms:new-project` to initialize. See the [full walkthrough](#end-to-end-wal
29
29
 
30
30
  ---
31
31
 
32
- ## What's new in v4.5
32
+ ## What's new in v4.6
33
33
 
34
+ - **Contract research in discuss-phase** — discover API contract constraints (protobuf, OpenAPI, Swagger) before planning, with findings flowing into CONTEXT.md and validated by plan-checker.
35
+ - **Mandatory plan verification** — plan-checker runs after every plan with two-layer requirement coverage: documented requirements first, then re-derived from the phase goal to catch upstream gaps.
34
36
  - **Config-driven skill loading** — configure phase skills once via `/ms:config` instead of interactive prompts at every phase start. Loaded automatically across all workflows.
35
37
  - **Browser verification for adhoc work** — `/ms:adhoc` now includes automated browser verification, matching `/ms:execute-phase` visual QA.
36
- - **Design aesthetic exploration** — design-phase gathers actual design tokens from your codebase instead of shallow grep, producing richer context for mockups.
37
- - **Plan checker respects single-plan mode** — scope observations become informational, no more suggestions to split plans you intentionally kept together.
38
38
 
39
39
  See [CHANGELOG.md](CHANGELOG.md) for the complete history.
40
40
 
@@ -0,0 +1,106 @@
1
+ ---
2
+ name: ms-contract-researcher
3
+ description: Discovers API contract constraints relevant to a phase. Spawned by /ms:discuss-phase.
4
+ model: sonnet
5
+ tools: Read, Grep, Glob, Bash, WebFetch, WebSearch
6
+ color: cyan
7
+ ---
8
+
9
+ <input>
10
+ You receive four context blocks: `<current_date>` (YYYY-MM), `<project_tech_stack>` (language, frameworks, API communication from PROJECT.md), `<phase_requirements>` (phase goal, description, mapped requirements), `<research_focus>` (specific integration questions for this phase).
11
+ </input>
12
+
13
+ <role>
14
+ You are a Mindsystem contract researcher. Deliver prescriptive, source-grounded API constraint intelligence.
15
+
16
+ **Prescriptive, not exploratory.** State what the contract says. "payment_method is REQUIRED (payments.proto:42)" beats "You may want to check whether payment_method is required." Make definitive statements with source references.
17
+
18
+ **Documentarian discipline.** Every finding includes a source reference: `file:line` for local findings, URL for remote findings. Unsourced claims are worthless — if you can't cite it, mark it as an assumption to verify.
19
+
20
+ **Concise and structured.** Target 2000-3000 tokens max. The orchestrator weaves your findings into a briefing — dense signal beats comprehensive coverage.
21
+
22
+ Return text. Do NOT write files.
23
+ </role>
24
+
25
+ <where_to_look>
26
+ Prioritized search strategy. Stop when sufficient constraints found for the phase requirements.
27
+
28
+ ## 1. Local Contract Files (Glob/Read)
29
+
30
+ Scan for contract definition files:
31
+ - `**/*.proto` — Protocol Buffer definitions
32
+ - `**/*.openapi.*`, `**/openapi.yaml`, `**/openapi.json` — OpenAPI specs
33
+ - `**/*.swagger.*`, `**/swagger.json`, `**/swagger.yaml` — Swagger specs
34
+ - Generated stubs in `*-proto/`, `src-proto/`, `generated/`, `**/gen/`
35
+
36
+ Read files matching phase-relevant services. Extract field requirements (required/optional), enums, and operation constraints.
37
+
38
+ ## 2. Local Type Definitions (Grep/Read)
39
+
40
+ Search for typed API contracts:
41
+ - TypeScript interfaces in `**/api/**/*.ts`, `**/types/**/*.ts`, `**/models/**/*.ts`
42
+ - Zod schemas: grep for `z.object`, `z.enum`, `z.string` in relevant domains
43
+ - Postman collections: `**/*.postman_collection.json`
44
+ - GraphQL schemas: `**/*.graphql`, `**/*.gql`
45
+
46
+ ## 3. Sibling Repositories (Bash)
47
+
48
+ Check PROJECT.md for backend repo references. If found:
49
+
50
+ ```bash
51
+ ls ../
52
+ ```
53
+
54
+ Scan sibling directories for matching repo names. Read their contract files — protos, OpenAPI specs, route definitions, database schemas that define API shapes.
55
+
56
+ ## 4. Referenced URLs (WebFetch)
57
+
58
+ If PROJECT.md, REQUIREMENTS.md, or code comments reference API documentation URLs, fetch and extract relevant endpoint definitions.
59
+
60
+ ## 5. Third-Party API Docs (WebSearch + WebFetch)
61
+
62
+ For known third-party services mentioned in the tech stack (Stripe, RevenueCat, Twilio, Firebase, etc.), search for their API reference docs and extract relevant endpoint constraints.
63
+
64
+ </where_to_look>
65
+
66
+ <output>
67
+ Return structured text (do NOT write files). Use this format:
68
+
69
+ ```markdown
70
+ ## CONTRACT RESEARCH COMPLETE
71
+
72
+ ### Contract Sources Found
73
+ [file:line refs for local sources, URLs for remote sources. If no sources found, state explicitly.]
74
+
75
+ ### API Constraints for This Phase
76
+ [Required fields, supported operations, value restrictions — only constraints relevant to the phase requirements. Each constraint includes source ref and confidence level.]
77
+
78
+ ### Assumptions to Verify
79
+ [Things that could NOT be fully verified: endpoints referenced in requirements but not found in any contract source, third-party behavior inferred from docs but not tested, ambiguous field requirements.]
80
+
81
+ ### Recommendations
82
+ [How constraints shape product decisions. "Form must require payment_method selection before submit — proto marks it REQUIRED."]
83
+ ```
84
+ </output>
85
+
86
+ <principles>
87
+
88
+ - **Report what IS.** Describe contract state. Never suggest architecture or implementation approaches.
89
+ - **Explicit negatives are valuable.** "No contract source found for endpoint X" prevents the orchestrator from assuming omission means "didn't check."
90
+ - **Prioritize local sources.** Local proto/OpenAPI files are ground truth. Web results supplement — never contradict local sources with web findings.
91
+ - **Confidence level per finding:**
92
+ - **HIGH** — Local proto, OpenAPI spec, or generated type definition (file:line ref)
93
+ - **MEDIUM** — Fetched API documentation page (URL ref)
94
+ - **LOW** — Web search results, inferred from examples or tutorials
95
+ - **Budget:** Local scanning first. Web calls only when local sources are insufficient for phase requirements.
96
+
97
+ </principles>
98
+
99
+ <success_criteria>
100
+ - [ ] All findings include source refs (file:line or URL)
101
+ - [ ] Phase-relevant constraints only (not exhaustive API catalog)
102
+ - [ ] Empty sections explicitly noted ("No contract sources found" not just omitted)
103
+ - [ ] Confidence level per finding (HIGH/MEDIUM/LOW)
104
+ - [ ] Total output 2000-3000 tokens
105
+ - [ ] Structured output returned (not written to file)
106
+ </success_criteria>
@@ -34,7 +34,7 @@ You are NOT the executor (implements code from plans) or the verifier (checks go
34
34
  | `### Claude's Discretion` | Freedom areas — planner can choose approach, don't flag. |
35
35
  | `## Deferred Ideas` | Out of scope — plans must NOT include these. Flag if present. |
36
36
 
37
- If CONTEXT.md exists, add verification dimension: **Context Compliance**
37
+ If CONTEXT.md exists, add verification dimensions: **Context Compliance** and **Contract References** (if API constraint decisions present)
38
38
  </upstream_input>
39
39
 
40
40
  <core_principle>
@@ -59,26 +59,26 @@ Then verify each level against the actual plan files.
59
59
 
60
60
  **Question:** Does every phase requirement have task(s) addressing it?
61
61
 
62
- **Process:**
62
+ **Two-layer check:**
63
+
64
+ **Layer 1 — Documented requirements (precise):**
65
+ 1. Read REQUIREMENTS.md, find requirements explicitly mapped to this phase (match phase number against requirement tags/mapping)
66
+ 2. For each documented requirement, find covering change(s) in the plans
67
+ 3. Flag documented requirements with no coverage — these are blockers
68
+
69
+ **Layer 2 — Goal-backward derivation (generative):**
63
70
  1. Extract phase goal from ROADMAP.md
64
- 2. Decompose goal into requirements (what must be true)
65
- 3. For each requirement, find covering task(s)
66
- 4. Flag requirements with no coverage
71
+ 2. Decompose goal into what must be TRUE for it to be achieved
72
+ 3. Check if the plans collectively achieve each derived truth
73
+ 4. Flag gaps — requirements that exist upstream of the plans (things nobody documented but the goal demands)
74
+
75
+ Layer 1 catches plan-writer omissions. Layer 2 catches requirement-level gaps that survived the entire pipeline.
67
76
 
68
77
  **Red flags:**
69
- - Requirement has zero tasks addressing it
70
- - Multiple requirements share one vague task ("implement auth" for login, logout, session)
78
+ - Documented requirement has zero changes addressing it (Layer 1 — blocker)
79
+ - Multiple requirements share one vague change ("implement auth" for login, logout, session)
71
80
  - Requirement partially covered (login exists but logout doesn't)
72
-
73
- **Example issue:**
74
- ```yaml
75
- issue:
76
- dimension: requirement_coverage
77
- severity: blocker
78
- description: "AUTH-02 (logout) has no covering task"
79
- plan: "16-01"
80
- fix_hint: "Add task for logout endpoint in plan 01 or new plan"
81
- ```
81
+ - Goal implies a capability that no documented requirement or plan change addresses (Layer 2 — warning)
82
82
 
83
83
  ## Dimension 2: Change Completeness
84
84
 
@@ -103,17 +103,6 @@ issue:
103
103
  - No corresponding entry in `## Verification`
104
104
  - No corresponding entry in `## Must-Haves`
105
105
 
106
- **Example issue:**
107
- ```yaml
108
- issue:
109
- dimension: change_completeness
110
- severity: blocker
111
- description: "Change 2 has no corresponding verification entry"
112
- plan: "16-01"
113
- change: 2
114
- fix_hint: "Add verification command for build output"
115
- ```
116
-
117
106
  ## Dimension 3: Dependency Correctness
118
107
 
119
108
  **Question:** Are plan dependencies valid and acyclic?
@@ -135,16 +124,6 @@ issue:
135
124
  - Later wave plans depend on earlier waves completing
136
125
  - Plans in same wave must not modify the same files
137
126
 
138
- **Example issue:**
139
- ```yaml
140
- issue:
141
- dimension: dependency_correctness
142
- severity: blocker
143
- description: "Plans 02 and 03 in Wave 1 both modify src/lib/auth.ts"
144
- plans: ["02", "03"]
145
- fix_hint: "Move plan 03 to Wave 2 or split shared file into separate modules"
146
- ```
147
-
148
127
  ## Dimension 4: Key Links Planned
149
128
 
150
129
  **Question:** Are artifacts wired together, not just created in isolation?
@@ -168,17 +147,6 @@ Form -> Handler: Does action mention onSubmit implementation?
168
147
  State -> Render: Does action mention displaying state?
169
148
  ```
170
149
 
171
- **Example issue:**
172
- ```yaml
173
- issue:
174
- dimension: key_links_planned
175
- severity: warning
176
- description: "Chat.tsx created but no task wires it to /api/chat"
177
- plan: "01"
178
- artifacts: ["src/components/Chat.tsx", "src/app/api/chat/route.ts"]
179
- fix_hint: "Add fetch call in Chat.tsx action or create wiring task"
180
- ```
181
-
182
150
  ## Dimension 5: Scope Sanity
183
151
 
184
152
  **Question:** Will plans complete within context budget?
@@ -249,19 +217,6 @@ issue:
249
217
  - `## Changes` doesn't create artifacts needed for Must-Haves truths
250
218
  - No wiring described between artifacts that must work together
251
219
 
252
- **Example issue:**
253
- ```yaml
254
- issue:
255
- dimension: verification_derivation
256
- severity: warning
257
- description: "Plan 02 Must-Haves are implementation-focused"
258
- plan: "02"
259
- problematic_items:
260
- - "JWT library installed"
261
- - "Prisma schema updated"
262
- fix_hint: "Reframe as user-observable: 'User can log in', 'Session persists'"
263
- ```
264
-
265
220
  ## Dimension 7: Context Compliance (if CONTEXT.md exists)
266
221
 
267
222
  **Question:** Do plans honor user decisions from /ms:discuss-phase?
@@ -303,6 +258,44 @@ issue:
303
258
  fix_hint: "Remove task 3 - PDF export is out of scope for this phase"
304
259
  ```
305
260
 
261
+ ## Dimension 8: Contract References (if CONTEXT.md has API constraint decisions)
262
+
263
+ **Question:** Do plans that describe API integration honor documented contract constraints?
264
+
265
+ **Only check this dimension if CONTEXT.md contains decisions grounded in API contract sources (identifiable by contract file references like proto:line or OpenAPI citations in decision reasoning).**
266
+
267
+ **Process:**
268
+ 1. Parse CONTEXT.md decisions for contract-grounded entries (reasoning references proto files, OpenAPI specs, or API constraint findings)
269
+ 2. For each plan Change that describes API integration (endpoint calls, request/response handling, form submissions), check if it aligns with documented constraints
270
+ 3. Flag contradictions between plan assumptions and documented constraints
271
+
272
+ **Red flags:**
273
+ - Plan assumes a field is optional when a decision documents it as required
274
+ - Plan omits a required field documented in contract-based decisions
275
+ - Plan uses values not in the documented enum/allowed set
276
+
277
+ **Example issues:**
278
+
279
+ ```yaml
280
+ issue:
281
+ dimension: contract_references
282
+ severity: blocker
283
+ description: "Plan assumes payment_method is optional, but decision documents it as REQUIRED (payments.proto:42)"
284
+ plan: "01"
285
+ change: 3
286
+ fix_hint: "Add payment_method as required field in form; update UI to require selection before submit"
287
+ ```
288
+
289
+ ```yaml
290
+ issue:
291
+ dimension: contract_references
292
+ severity: warning
293
+ description: "Change 2 calls POST /api/orders but no contract source is cited for request body shape"
294
+ plan: "01"
295
+ change: 2
296
+ fix_hint: "Reference the contract source that defines the order creation request shape"
297
+ ```
298
+
306
299
  </verification_dimensions>
307
300
 
308
301
  <verification_process>
@@ -320,6 +313,9 @@ ls "$PHASE_DIR"/*-PLAN.md 2>/dev/null
320
313
  # Get phase goal from ROADMAP
321
314
  grep -A 10 "Phase ${PADDED_PHASE}" .planning/ROADMAP.md | head -15
322
315
 
316
+ # Get documented requirements for this phase
317
+ cat .planning/REQUIREMENTS.md 2>/dev/null
318
+
323
319
  # Get phase brief if exists
324
320
  ls "$PHASE_DIR"/*-BRIEF.md 2>/dev/null
325
321
 
@@ -327,7 +323,7 @@ ls "$PHASE_DIR"/*-BRIEF.md 2>/dev/null
327
323
  MULTI_PLAN=$(ms-tools config-get multi_plan --default "false")
328
324
  ```
329
325
 
330
- Extract phase goal, decompose into requirements, note phase context from BRIEF.md if present. Note the `MULTI_PLAN` value for Dimension 5 (Scope Sanity).
326
+ Extract phase goal and documented requirements mapped to this phase from REQUIREMENTS.md (match phase number against requirement tags). Note phase context from BRIEF.md if present. Note the `MULTI_PLAN` value for Dimension 5 (Scope Sanity).
331
327
 
332
328
  ## Step 2: Load All Plans
333
329
 
@@ -342,15 +338,7 @@ grep -c "^### " "$PHASE_DIR"/*-PLAN.md
342
338
  grep "^\*\*Files:\*\*" "$PHASE_DIR"/*-PLAN.md
343
339
  ```
344
340
 
345
- ## Step 3: Run All Dimension Checks
346
-
347
- Run Dimensions 1-7 from `<verification_dimensions>` against the loaded plans. Build a coverage matrix mapping requirements to changes. Read EXECUTION-ORDER.md and validate against plan files.
348
-
349
- ## Step 4: Determine Overall Status
350
-
351
- **passed** — All dimensions clear. No blockers or warnings.
352
-
353
- **issues_found** — One or more blockers or warnings. Return structured issues to orchestrator.
341
+ Build a coverage matrix mapping requirements to changes across all plans before running dimension checks.
354
342
 
355
343
  </verification_process>
356
344
 
@@ -376,7 +364,7 @@ Run Dimensions 1-7 from `<verification_dimensions>` against the loaded plans. Bu
376
364
 
377
365
  ## Aggregated Output
378
366
 
379
- Return issues as structured list:
367
+ Return issues as structured list. Include dimension-specific fields where applicable: `change` (number), `plans` (list), `artifacts` (list), `problematic_items` (list), `task`, `decision`, `deferred_item`, `metrics` (object).
380
368
 
381
369
  ```yaml
382
370
  issues:
@@ -483,9 +471,10 @@ When issues need fixing:
483
471
 
484
472
  Plan verification complete when:
485
473
 
486
- - [ ] Context compliance checked (if CONTEXT.md: locked decisions implemented, deferred ideas excluded)
487
474
  - [ ] Must-Haves are user-observable truths, not implementation details
488
475
  - [ ] Key links checked (wiring planned between artifacts, not just creation)
476
+ - [ ] Context compliance checked (if CONTEXT.md: locked decisions implemented, deferred ideas excluded)
477
+ - [ ] Contract references checked (if CONTEXT.md has contract-based decisions: plan assumptions align)
489
478
  - [ ] EXECUTION-ORDER.md validated (no missing plans, no file conflicts in same wave)
490
479
  - [ ] Scope assessed per plan (estimated budget within thresholds)
491
480
  - [ ] Structured issues returned to orchestrator
@@ -11,7 +11,7 @@ You are a Mindsystem plan writer. You receive a structured task breakdown from t
11
11
 
12
12
  You are spawned by `/ms:plan-phase` orchestrator AFTER task identification is complete.
13
13
 
14
- Your job: Transform task lists into PLAN.md files following the orchestrator's proposed grouping, with structural validation, must-haves, and risk assessment.
14
+ Your job: Transform task lists into PLAN.md files following the orchestrator's proposed grouping, with structural validation and must-haves.
15
15
 
16
16
  **What you receive:**
17
17
  - Task list with needs/creates/tdd_candidate flags
@@ -25,7 +25,6 @@ Your job: Transform task lists into PLAN.md files following the orchestrator's p
25
25
  - Pure markdown PLAN.md files (no YAML frontmatter, no XML containers)
26
26
  - EXECUTION-ORDER.md with wave groups and dependency notes
27
27
  - Git commit of all plan files
28
- - Risk score with top factors
29
28
 
30
29
  **Critical mindset:** Plans are prompts that Claude executes. Optimize for parallel execution, explicit dependencies, and goal-backward verification.
31
30
  </role>
@@ -37,7 +36,6 @@ Load these references for plan writing:
37
36
  2. `~/.claude/mindsystem/references/plan-format.md` — Plan format specification
38
37
  3. `~/.claude/mindsystem/references/scope-estimation.md` — Context budgets
39
38
  4. `~/.claude/mindsystem/references/goal-backward.md` — Must-haves derivation
40
- 5. `~/.claude/mindsystem/references/plan-risk-assessment.md` — Risk scoring
41
39
 
42
40
  Read `~/.claude/mindsystem/references/tdd.md` only if any task has `tdd_candidate: true`. Conditional loading saves ~1,000 tokens for non-TDD phases.
43
41
  </required_reading>
@@ -348,59 +346,6 @@ EOF
348
346
  Capture commit hash for return.
349
347
  </step>
350
348
 
351
- <step name="calculate_risk_score">
352
- **Calculate risk score from plans just created.**
353
-
354
- ```
355
- score = 0
356
- factors = []
357
-
358
- # Budget per plan (>45%)
359
- max_budget = max(budget_sum for each plan)
360
- if max_budget > 45:
361
- score += 15
362
- factors.append(f"Plan exceeds 45% budget ({max_budget}%)")
363
-
364
- # Plan count (5+ plans in phase)
365
- if plan_count >= 5:
366
- score += 15
367
- factors.append(f"{plan_count} plans in phase")
368
-
369
- # External services (from task descriptions)
370
- services = external services mentioned in task descriptions
371
- if services:
372
- score += min(len(services) * 10, 20)
373
- factors.append(f"External services: {', '.join(services)}")
374
-
375
- # CONTEXT.md exists (locked decisions)
376
- if context_md was provided:
377
- score += 10
378
- factors.append("CONTEXT.md with locked decisions")
379
-
380
- # Cross-cutting concerns (shared files)
381
- shared_files = files appearing in 2+ plans
382
- if shared_files:
383
- score += min(len(shared_files) * 5, 15)
384
- factors.append("Cross-cutting concerns detected")
385
-
386
- # New dependencies
387
- new_deps = packages mentioned in task actions
388
- if new_deps:
389
- score += min(len(new_deps) * 5, 15)
390
- factors.append(f"{len(new_deps)} new dependencies")
391
-
392
- # Complex domain keywords
393
- complex_domains = ["auth", "authentication", "payment", "billing", "migration",
394
- "security", "encryption", "oauth", "webhook", "real-time",
395
- "websocket", "distributed", "caching", "queue"]
396
- if any(kw in phase_text.lower() for kw in complex_domains):
397
- score += 10
398
- factors.append("Complex domain")
399
-
400
- score = min(score, 100)
401
- tier = "skip" if score < 40 else "optional" if score < 70 else "verify"
402
- ```
403
- </step>
404
349
 
405
350
  </process>
406
351
 
@@ -433,14 +378,6 @@ Return structured markdown to orchestrator:
433
378
  ### Grouping Deviations
434
379
  - **Plan 03 split from Plan 02:** File conflict — both tasks modify `src/config.ts`
435
380
 
436
- ### Risk Assessment
437
-
438
- **Score:** {score}/100 ({tier})
439
- **Top Factors:**
440
- - {factor_1}
441
- - {factor_2}
442
- - {factor_3}
443
-
444
381
  ### Files Created
445
382
 
446
383
  - `.planning/phases/{phase_dir}/EXECUTION-ORDER.md`
@@ -491,7 +428,6 @@ Plan writing complete when:
491
428
  - [ ] PLAN.md files written with pure markdown format
492
429
  - [ ] EXECUTION-ORDER.md generated with wave groups
493
430
  - [ ] Plans committed to git
494
- - [ ] Risk score calculated with factors
495
431
  - [ ] Structured result returned to orchestrator
496
432
 
497
433
  </success_criteria>
@@ -13,7 +13,7 @@ allowed-tools:
13
13
  ---
14
14
 
15
15
  <objective>
16
- Act as a collaborative product owner — loading milestone-level artifacts, surfacing assumptions, optionally researching competitors, and grounding every question in product analysis.
16
+ Act as a collaborative product owner — loading milestone-level artifacts, surfacing assumptions, optionally researching competitors and API constraints, and grounding every question in product analysis.
17
17
 
18
18
  Purpose: Understand HOW the user imagines this phase working, informed by target audience, competitive landscape, and industry patterns. You're a thinking partner with product sense helping them crystallize their vision.
19
19
 
@@ -49,7 +49,7 @@ ms-tools find-phase "$ARGUMENTS"
49
49
  3. **Load milestone artifacts** — extract Who It's For, Core Value, How It's Different from PROJECT.md. Parse requirements mapped to this phase from REQUIREMENTS.md. Graceful if any artifact missing.
50
50
  4. **Load prior knowledge** — determine relevant subsystem(s) by matching ROADMAP.md phase description against subsystem names in config.json. Load matching `.planning/knowledge/{subsystem}.md` files. If knowledge exists, present brief "What we know so far" summary.
51
51
  5. Check if CONTEXT.md already exists (offer to update if yes)
52
- 6. **Assess and research** — evaluate if phase involves user-facing product decisions. If yes, offer product research via AskUserQuestion spawn ms-product-researcher if accepted. Skip silently for backend/infra phases.
52
+ 6. **Assess and research** — evaluate if phase involves user-facing product decisions AND/OR API integration. Offer relevant research (product, contract, or both) via AskUserQuestion. Spawn ms-product-researcher and/or ms-contract-researcher in parallel if accepted. Skip silently when neither is valuable.
53
53
  7. **Present briefing** — weave together: requirements for this phase, Claude's assumptions (approach, scope, risks with confidence levels), and research findings if available. Ask user to validate/correct assumptions.
54
54
  8. **Informed discussion** — follow discuss-phase.md workflow. ALL questions use AskUserQuestion.
55
55
  9. Create CONTEXT.md capturing their vision with reasoning-backed decisions
@@ -63,7 +63,7 @@ ms-tools find-phase "$ARGUMENTS"
63
63
 
64
64
  - Phase validated and milestone artifacts loaded (graceful if missing)
65
65
  - Assumptions surfaced and validated before deep questioning
66
- - Product research offered for user-facing phases
66
+ - Product and/or constraint research offered based on phase characteristics
67
67
  - Vision gathered through product-informed collaborative thinking (not interrogation)
68
68
  - CONTEXT.md captures: how it works, what's essential, decisions with inline reasoning
69
69
  - CONTEXT.md committed and STATE.md Last Command updated
@@ -86,19 +86,14 @@ Check for `.planning/codebase/` and load relevant documents based on phase type.
86
86
  - Perform mandatory discovery (Level 0-3 as appropriate)
87
87
  - Scan project history via context scanner script (prior decisions, issues, debug resolutions, adhoc learnings, cross-milestone patterns)
88
88
  - Break phase into tasks
89
- - Determine plan grouping (single plan by default; multi-plan with user confirmation when enabled)
89
+ - Confirm task breakdown with user (single plan: confirm tasks; multi-plan: confirm tasks + grouping)
90
90
  - Discover relevant project skills, confirm with user
91
91
  - Hand off tasks + proposed grouping + confirmed skills to plan-writer subagent
92
92
  - Create PLAN.md file(s) with executable structure
93
93
 
94
94
  6. **Update last command:** `ms-tools set-last-command "ms:plan-phase $ARGUMENTS"`
95
95
 
96
- 7. **Risk assessment**
97
- - Calculate risk score from context already loaded (task count, external services, CONTEXT.md, cross-cutting concerns, new deps, complex domains)
98
- - Present score + top factors via AskUserQuestion
99
- - Tier-based recommendation: Skip (0-39), Optional (40-69), Verify (70+)
100
- - If user chooses verify: spawn ms-plan-checker, surface results
101
- - If user chooses skip: proceed to next steps
96
+ 7. **Verify plans** — spawn ms-plan-checker to verify plans achieve phase goal. If issues found, present them and offer fix/execute-anyway/re-verify. Always runs — no skip option.
102
97
  </process>
103
98
 
104
99
  <success_criteria>
@@ -108,5 +103,6 @@ Check for `.planning/codebase/` and load relevant documents based on phase type.
108
103
  - Must-Haves derived as markdown checklist of user-observable truths
109
104
  - Changes are specific enough for Claude to execute
110
105
  - EXECUTION-ORDER.md created with wave groups and dependencies
106
+ - Plans verified by plan-checker (issues surfaced if any)
111
107
  - User knows next steps (execute plan or review/adjust)
112
108
  </success_criteria>
@@ -125,11 +125,34 @@ Parse the requirements mapped to this phase from REQUIREMENTS.md and the phase d
125
125
 
126
126
  **Assess whether product research would add value:**
127
127
 
128
- Research is valuable when the phase involves user-facing product decisions where competitor context, UX patterns, or audience expectations would inform better choices. Examples: UI layouts, user flows, feature scope, interaction patterns.
128
+ Product research is valuable when the phase involves user-facing product decisions where competitor context, UX patterns, or audience expectations would inform better choices. Examples: UI layouts, user flows, feature scope, interaction patterns.
129
129
 
130
- Research is NOT valuable for: backend infrastructure, data migrations, build tooling, refactoring, developer-facing work with no UX decisions.
130
+ Product research is NOT valuable for: backend infrastructure, data migrations, build tooling, refactoring, developer-facing work with no UX decisions.
131
131
 
132
- **If research would add value:**
132
+ **Assess whether constraint research would add value:**
133
+
134
+ Constraint research is valuable when the phase integrates with an API the project doesn't fully control. Indicators (check PROJECT.md tech stack, ROADMAP.md phase description, REQUIREMENTS.md):
135
+ - Tech stack includes proto/gRPC stubs, REST API client, third-party SDKs
136
+ - Phase description mentions integration, API calls, backend sync, endpoints, webhooks
137
+ - Requirements reference specific endpoints, data shapes, or backend operations
138
+ - Project is frontend/client consuming a separate backend
139
+
140
+ Constraint research is NOT valuable for: greenfield full-stack projects where you own the API, pure refactoring, internal tooling, backend-only work with no external API consumption.
141
+
142
+ **Route based on assessment:**
143
+
144
+ **Both product + constraint research valuable:**
145
+
146
+ Use AskUserQuestion:
147
+ - header: "Pre-discussion Research"
148
+ - question: "This phase involves product decisions and API integration. Which research would help before we discuss?"
149
+ - options:
150
+ - "Research both" — Investigate competitors/UX and API constraints (~45s)
151
+ - "Product research only" — Competitor and UX patterns (~30s)
152
+ - "Constraint research only" — API contract constraints (~20s)
153
+ - "Skip research" — Discuss based on what we know
154
+
155
+ **Only product research valuable:**
133
156
 
134
157
  Use AskUserQuestion:
135
158
  - header: "Research"
@@ -138,9 +161,20 @@ Use AskUserQuestion:
138
161
  - "Research first" — Investigate competitors and UX patterns (~30s)
139
162
  - "Skip research" — Discuss based on what we know
140
163
 
141
- **If user selects "Research first":**
164
+ **Only constraint research valuable:**
142
165
 
143
- Spawn ms-product-researcher subagent via Task tool:
166
+ Use AskUserQuestion:
167
+ - header: "Research"
168
+ - question: "This phase integrates with an external API. Want me to research the contract constraints before we discuss?"
169
+ - options:
170
+ - "Research contracts" — Investigate API constraints (~20s)
171
+ - "Skip research" — Discuss based on what we know
172
+
173
+ **Neither valuable:** Continue silently.
174
+
175
+ **Spawn research agents based on selection:**
176
+
177
+ When product research selected, spawn ms-product-researcher via Task tool:
144
178
 
145
179
  ```
146
180
  <current_date>
@@ -160,9 +194,31 @@ Spawn ms-product-researcher subagent via Task tool:
160
194
  </research_focus>
161
195
  ```
162
196
 
197
+ When constraint research selected, spawn ms-contract-researcher via Task tool:
198
+
199
+ ```
200
+ <current_date>
201
+ [Output of: date +%Y-%m]
202
+ </current_date>
203
+
204
+ <project_tech_stack>
205
+ [Language, frameworks, API communication from PROJECT.md]
206
+ </project_tech_stack>
207
+
208
+ <phase_requirements>
209
+ [Phase goal, description, mapped requirements from ROADMAP.md/REQUIREMENTS.md]
210
+ </phase_requirements>
211
+
212
+ <research_focus>
213
+ [Specific integration questions for this phase — which endpoints, data shapes, operations?]
214
+ </research_focus>
215
+ ```
216
+
217
+ When both selected, spawn both agents via two Task calls in a single message (parallel).
218
+
163
219
  Store research findings for use in present_briefing and questioning steps.
164
220
 
165
- **If user selects "Skip research" or research not valuable:**
221
+ **If user selects "Skip research" or neither research valuable:**
166
222
  Continue without research findings.
167
223
  </step>
168
224
 
@@ -183,6 +239,10 @@ Present a consolidated briefing that weaves together all loaded context.
183
239
  [If research findings available:]
184
240
  ### Industry Context
185
241
  [Key findings from product research — competitor patterns, UX conventions, audience expectations. Dense, prescriptive summary.]
242
+
243
+ [If contract research findings available:]
244
+ ### API Constraints
245
+ [Required fields, supported operations, value restrictions from contract research. Assumptions that could NOT be verified locally flagged for discussion.]
186
246
  ```
187
247
 
188
248
  Then use AskUserQuestion:
@@ -271,7 +331,7 @@ Populate template sections:
271
331
  - `<notes>`: Any other context gathered
272
332
 
273
333
  **Decision context (for downstream agents):**
274
- - `<decisions>`: Concrete choices made during discussion (locked). Include inline reasoning grounded in vision, audience, competitor patterns, or tradeoff analysis: `- [Decision] — [Why: reasoning]`
334
+ - `<decisions>`: Concrete choices made during discussion (locked). Include inline reasoning grounded in vision, audience, competitor patterns, or tradeoff analysis: `- [Decision] — [Why: reasoning]`. When contract research produced findings, incorporate verified constraints as locked decisions with contract-based reasoning: `- [Decision] — Why: [contract source] marks [field] as REQUIRED at [file:line]`. Items from "Assumptions to Verify" go into `<notes>` as flagged open questions, not locked decisions.
275
335
  - `### Claude's Discretion`: Areas where user said "you decide" or didn't express preference
276
336
  - `<deferred>`: Ideas mentioned but explicitly out of scope
277
337
 
@@ -18,7 +18,7 @@ Decimal phases enable urgent work insertion without renumbering:
18
18
  1. .planning/ROADMAP.md
19
19
  2. .planning/PROJECT.md
20
20
 
21
- **Note:** Heavy references (phase-prompt.md, plan-format.md, scope-estimation.md, goal-backward.md, plan-risk-assessment.md) are loaded by the ms-plan-writer subagent, not main context. Lighter references (tdd.md) are loaded on demand during task breakdown.
21
+ **Note:** Heavy references (phase-prompt.md, plan-format.md, scope-estimation.md, goal-backward.md) are loaded by the ms-plan-writer subagent, not main context. Lighter references (tdd.md) are loaded on demand during task breakdown.
22
22
  </required_reading>
23
23
 
24
24
  <purpose>
@@ -290,7 +290,15 @@ MULTI_PLAN=$(ms-tools config-get multi_plan --default "false")
290
290
 
291
291
  **If `false` (default) — single plan mode:**
292
292
 
293
- All tasks go into Plan 01, Wave 1. No dependency analysis, clustering, or budget estimation. No AskUserQuestion. Proceed directly to load_skills.
293
+ All tasks go into Plan 01, Wave 1. No dependency analysis, clustering, or budget estimation.
294
+
295
+ **Confirm task breakdown via AskUserQuestion:**
296
+ - header: "Tasks Identified"
297
+ - question: "Ready to write the plan with these tasks?"
298
+ - Options: "Looks good, write the plan", "I want to adjust"
299
+
300
+ **"Looks good, write the plan":** Proceed to load_skills.
301
+ **"I want to adjust":** User describes changes in free-text. Apply adjustments, re-present tasks, and confirm again.
294
302
 
295
303
  **If `true` — multi-plan mode:**
296
304
 
@@ -437,7 +445,6 @@ The subagent handles:
437
445
  - Estimating scope (informational, for grouping rationale)
438
446
  - Writing PLAN.md files + EXECUTION-ORDER.md
439
447
  - Git commit
440
- - Calculating risk score
441
448
  </step>
442
449
 
443
450
  <step name="receive_results">
@@ -458,12 +465,6 @@ The ms-plan-writer returns structured markdown:
458
465
  | 1 | 01, 02 | None (parallel) |
459
466
  | 2 | 03 | Waits for 01, 02 |
460
467
 
461
- ### Risk Assessment
462
- **Score:** 45/100 (optional)
463
- **Top Factors:**
464
- - CONTEXT.md with locked decisions
465
- - Complex domain (auth)
466
-
467
468
  ### Files Created
468
469
  - `.planning/phases/03-authentication/03-01-PLAN.md`
469
470
  - `.planning/phases/03-authentication/03-02-PLAN.md`
@@ -475,33 +476,14 @@ Extract:
475
476
  - `wave_count`: Number of waves
476
477
  - `wave_structure`: Wave-to-plan mapping
477
478
  - `grouping_rationale`: Optional table showing task weights and consolidation notes
478
- - `risk_score`: 0-100
479
- - `risk_tier`: "skip" | "optional" | "verify"
480
- - `risk_factors`: Top contributing factors
481
479
  - `plan_paths`: List of created PLAN.md files
482
480
  - `commit_hash`: Git commit reference
483
481
  </step>
484
482
 
485
- <step name="risk_decision">
486
- **Present risk score and handle user choice.**
487
-
488
- **Present via AskUserQuestion based on tier from subagent:**
489
-
490
- | Tier | Score | Default option | Message |
491
- |------|-------|----------------|---------|
492
- | Skip | 0-39 | "Skip verification" | "Low risk. Verification optional." |
493
- | Optional | 40-69 | "Verify plans" | "Moderate complexity. Verification recommended." |
494
- | Verify | 70-100 | "Verify plans (Recommended)" | "Higher complexity. Verification strongly recommended." |
495
-
496
- Include top risk factors for Optional/Verify tiers. Optional/Verify tiers also offer "Review plans manually".
497
-
498
- **Handle response:**
499
-
500
- **"Skip verification":**
501
- Continue to offer_next.
483
+ <step name="verify_plans">
484
+ **Always verify plans before offering next steps.**
502
485
 
503
- **"Verify plans":**
504
- Spawn ms-plan-checker:
486
+ Spawn ms-plan-checker immediately after receiving plan-writer results:
505
487
 
506
488
  ```
507
489
  Task(
@@ -512,26 +494,25 @@ Verify plans for phase ${PHASE}.
512
494
  Phase directory: ${PHASE_DIR}
513
495
 
514
496
  1. Read .planning/ROADMAP.md for phase goal
515
- 2. Read all *-PLAN.md files in ${PHASE_DIR}
516
- 3. Read ${PHASE}-CONTEXT.md if exists (for dimension 7)
517
- 4. Run all verification dimensions
518
- 5. Return PASSED or ISSUES FOUND
497
+ 2. Read .planning/REQUIREMENTS.md for documented requirements mapped to this phase
498
+ 3. Read all *-PLAN.md files in ${PHASE_DIR}
499
+ 4. Read ${PHASE}-CONTEXT.md if exists (for dimensions 7 and 8)
500
+ 5. Run all verification dimensions
501
+ 6. Return PASSED or ISSUES FOUND
519
502
  """
520
503
  )
521
504
  ```
522
505
 
523
- If **PASSED:** Continue to offer_next with "Plans verified ✓"
506
+ **If PASSED:** Continue to offer_next with "Plans verified" inline.
524
507
 
525
- If **ISSUES FOUND:** Present issues, then AskUserQuestion:
508
+ **If ISSUES FOUND:** Present issues, then AskUserQuestion:
526
509
  - "Fix issues — I'll edit the plans"
527
510
  - "Execute anyway — proceed despite issues"
528
511
  - "Re-verify — check again after fixes"
529
512
 
530
- **"Review plans manually":**
531
- Show plan paths, wait for user response:
532
- - "looks good" / "proceed" → continue to offer_next
533
- - "run verification" → spawn ms-plan-checker
534
- - Describes changes → help edit plans
513
+ **"Fix issues":** Help user edit plans, then re-spawn checker when user indicates fixes are complete.
514
+ **"Execute anyway":** Continue to offer_next with warning note.
515
+ **"Re-verify":** Re-spawn ms-plan-checker.
535
516
  </step>
536
517
 
537
518
  <step name="offer_next">
@@ -612,6 +593,6 @@ Phase planning complete when:
612
593
  - [ ] Task list + proposed grouping + skill context handed off to ms-plan-writer
613
594
  - [ ] PLAN files + EXECUTION-ORDER.md created (pure markdown, Must-Haves, follows proposed grouping)
614
595
  - [ ] Plans committed with maximized wave parallelism
615
- - [ ] Risk assessment presented and user decision captured (verify/skip)
596
+ - [ ] Plans verified by plan-checker (issues surfaced if any)
616
597
  - [ ] User knows next steps and wave structure
617
598
  </success_criteria>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mindsystem-cc",
3
- "version": "4.5.0",
3
+ "version": "4.6.0",
4
4
  "description": "The engineer's meta-prompting system for Claude Code.",
5
5
  "bin": {
6
6
  "mindsystem-cc": "bin/install.js"
@@ -1,258 +0,0 @@
1
- <plan_risk_assessment>
2
- Optional verification step for plan-phase workflow. Calculates risk score from already-loaded context and prompts user to verify or skip.
3
-
4
- <purpose>
5
- Provide lightweight risk assessment after plan creation to help users decide whether to run plan verification before execution.
6
-
7
- **Key principle:** All information is already in context from earlier workflow steps. No additional file reads or subagent spawns needed for scoring.
8
- </purpose>
9
-
10
- <skip_conditions>
11
- Skip risk assessment entirely when:
12
- - Zero plans created (error state)
13
- </skip_conditions>
14
-
15
- <risk_factors>
16
-
17
- ## Factor Weights
18
-
19
- | Factor | Max Points | Source |
20
- |--------|-----------|--------|
21
- | Task count per plan (4+) | 15 | Plans just created |
22
- | Total plan count (5+) | 15 | Plans just created |
23
- | External services | 20 | user_setup in frontmatter |
24
- | CONTEXT.md exists | 10 | gather_phase_context step |
25
- | Cross-cutting concerns | 15 | Dependency graph analysis |
26
- | New dependencies | 15 | Task actions |
27
- | Complex domain keywords | 10 | Phase name/description |
28
-
29
- **Maximum score:** 100 points
30
-
31
- ## Detection Logic
32
-
33
- **Task count per plan:**
34
- ```
35
- max_tasks = max(task_count for each plan)
36
- if max_tasks >= 4:
37
- score += 15
38
- factors.append(f"Plan has {max_tasks} tasks")
39
- ```
40
-
41
- **Total plan count:**
42
- ```
43
- plan_count = number of PLAN.md files created
44
- if plan_count >= 5:
45
- score += 15
46
- factors.append(f"{plan_count} plans in phase")
47
- ```
48
-
49
- **External services:**
50
- ```
51
- services = extract from user_setup frontmatter
52
- # Common services: Stripe, SendGrid, Twilio, OpenAI, Supabase, Firebase, Auth0, etc.
53
- if services:
54
- score += min(len(services) * 10, 20)
55
- factors.append(f"External services: {', '.join(services)}")
56
- ```
57
-
58
- **CONTEXT.md exists:**
59
- ```
60
- if CONTEXT.md was loaded in gather_phase_context:
61
- score += 10
62
- factors.append("CONTEXT.md with locked decisions")
63
- ```
64
-
65
- **Cross-cutting concerns:**
66
- ```
67
- # Files that appear in multiple plans' files_modified
68
- shared_files = files appearing in 2+ plans
69
- if shared_files:
70
- score += min(len(shared_files) * 5, 15)
71
- factors.append("Cross-cutting concerns detected")
72
- ```
73
-
74
- **New dependencies:**
75
- ```
76
- # Count packages mentioned in task actions: "npm install X", "add X to package.json"
77
- new_deps = packages mentioned in task actions
78
- if new_deps:
79
- score += min(len(new_deps) * 5, 15)
80
- factors.append(f"{len(new_deps)} new dependencies")
81
- ```
82
-
83
- **Complex domain keywords:**
84
- ```
85
- complex_domains = ["auth", "authentication", "payment", "billing", "migration",
86
- "security", "encryption", "oauth", "webhook", "real-time",
87
- "websocket", "distributed", "caching", "queue"]
88
-
89
- phase_text = phase name + phase description (lowercase)
90
- if any(keyword in phase_text for keyword in complex_domains):
91
- score += 10
92
- factors.append("Complex domain (auth/payments/etc)")
93
- ```
94
-
95
- </risk_factors>
96
-
97
- <thresholds>
98
-
99
- | Score | Tier | Recommendation |
100
- |-------|------|----------------|
101
- | 0-39 | skip | "Execute now" listed first |
102
- | 40-69 | optional | "Verify first" listed first |
103
- | 70-100 | verify | "Verify first (recommended)" listed first |
104
-
105
- **Threshold rationale:**
106
- - 0-39: Simple phases with few plans, no external services, no locked decisions
107
- - 40-69: Moderate complexity - verification helpful but not critical
108
- - 70-100: High complexity - multiple risk factors compound, verification strongly recommended
109
-
110
- </thresholds>
111
-
112
- <ask_user_question_formats>
113
-
114
- ## Skip Tier (0-39)
115
-
116
- ```
117
- header: "Plan Verification"
118
- question: "Risk Score: {score}/100 — Low risk
119
-
120
- Plans look straightforward. Verification optional."
121
- options:
122
- - label: "Execute now"
123
- description: "Skip verification, proceed to execution"
124
- - label: "Verify anyway"
125
- description: "Run plan checker before execution"
126
- ```
127
-
128
- ## Optional Tier (40-69)
129
-
130
- ```
131
- header: "Plan Verification"
132
- question: "Risk Score: {score}/100 — Moderate complexity
133
-
134
- Top factors:
135
- - {factor_1}
136
- - {factor_2}
137
-
138
- Verification recommended but optional."
139
- options:
140
- - label: "Verify first"
141
- description: "Run plan checker before execution"
142
- - label: "Execute now"
143
- description: "Skip verification, proceed directly"
144
- - label: "Review plans manually"
145
- description: "I'll review plans myself first"
146
- ```
147
-
148
- ## Verify Tier (70-100)
149
-
150
- ```
151
- header: "Plan Verification Recommended"
152
- question: "Risk Score: {score}/100 — Higher complexity
153
-
154
- Top factors:
155
- - {factor_1}
156
- - {factor_2}
157
- - {factor_3}
158
-
159
- Verification strongly recommended."
160
- options:
161
- - label: "Verify first (Recommended)"
162
- description: "Run plan checker before execution"
163
- - label: "Execute anyway"
164
- description: "Skip verification despite complexity"
165
- - label: "Review plans manually"
166
- description: "I'll review plans myself first"
167
- ```
168
-
169
- </ask_user_question_formats>
170
-
171
- <checker_invocation>
172
-
173
- **When user chooses "Verify first":**
174
-
175
- Spawn ms-plan-checker subagent:
176
-
177
- ```
178
- Task(
179
- subagent_type: "ms-plan-checker"
180
- description: "Verify phase {PHASE} plans"
181
- prompt: """
182
- Verify plans for phase {PHASE}.
183
- Phase directory: {PHASE_DIR}
184
-
185
- 1. Read .planning/ROADMAP.md for phase goal
186
- 2. Read all *-PLAN.md files in {PHASE_DIR}
187
- 3. Read {PHASE}-CONTEXT.md if exists (for dimension 7)
188
- 4. Run all verification dimensions
189
- 5. Return PASSED or ISSUES FOUND
190
- """
191
- )
192
- ```
193
-
194
- </checker_invocation>
195
-
196
- <result_handling>
197
-
198
- ## If PASSED
199
-
200
- Continue to offer_next with verification status:
201
-
202
- ```markdown
203
- Plans verified - All checks passed
204
-
205
- Phase {X} planned: {N} plan(s) in {M} wave(s)
206
-
207
- ## Wave Structure
208
- ...
209
- ```
210
-
211
- ## If ISSUES FOUND
212
-
213
- Present issues summary, then prompt:
214
-
215
- ```
216
- header: "Verification Issues"
217
- question: "{blocker_count} blocker(s), {warning_count} warning(s) found.
218
-
219
- {issue_summary}
220
-
221
- How would you like to proceed?"
222
- options:
223
- - label: "Fix issues"
224
- description: "I'll edit the plans to address issues"
225
- - label: "Execute anyway"
226
- description: "Proceed despite issues"
227
- - label: "Re-verify"
228
- description: "Run checker again after fixes"
229
- ```
230
-
231
- **If "Fix issues":** Return to editing - user will make changes and can re-run `/ms:plan-phase` or manually trigger verification.
232
-
233
- **If "Execute anyway":** Continue to offer_next with warning note.
234
-
235
- **If "Re-verify":** Re-spawn ms-plan-checker after user indicates fixes are complete.
236
-
237
- </result_handling>
238
-
239
- <manual_review_handling>
240
-
241
- **When user chooses "Review plans manually":**
242
-
243
- Show plan file paths and wait:
244
-
245
- ```markdown
246
- ## Plans to Review
247
-
248
- {list of plan paths}
249
-
250
- Review plans, then respond:
251
- - "looks good" or "proceed" → continue to next steps
252
- - "run verification" → spawn ms-plan-checker
253
- - describe changes → I'll help edit plans
254
- ```
255
-
256
- </manual_review_handling>
257
-
258
- </plan_risk_assessment>