mindsystem-cc 4.1.0 → 4.1.2

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
@@ -2,9 +2,9 @@
2
2
 
3
3
  # MINDSYSTEM
4
4
 
5
- **A meta-prompting and context engineering system for Claude Code.**
5
+ **The engineer's meta-prompting system for Claude Code.**
6
6
 
7
- Every piece of work makes the next one better. Mindsystem structures your Claude Code sessions into plannable, executable, verifiable phases, and compounds what it learns into persistent knowledge files that survive `/clear`. Context rot stops being the bottleneck. Every prompt in the system is tested against research on how LLMs actually follow instructions, so quality stays consistent from phase 1 to phase 20.
7
+ Amplifies every step of the development workflow you already follow discovery, research, design, planning, execution, verification. Each one refined, parallelized, and compounded into persistent knowledge. Built for engineers who want to multiply their output without giving up control.
8
8
 
9
9
  ```bash
10
10
  npx mindsystem-cc
@@ -19,12 +19,32 @@ npx mindsystem-cc
19
19
 
20
20
  <br>
21
21
 
22
- [How it works](#how-it-works) · [Walkthrough](#end-to-end-walkthrough) · [Features](#features) · [Quick start](#quick-start) · [.planning](#the-planning-directory) · [Config](#configuration) · [Commands](#command-reference) · [Troubleshooting](#troubleshooting)
22
+ [Why Mindsystem](#why-mindsystem) · [How it works](#how-it-works) · [Walkthrough](#end-to-end-walkthrough) · [Features](#features) · [Quick start](#quick-start) · [.planning](#the-planning-directory) · [Config](#configuration) · [Commands](#command-reference) · [Troubleshooting](#troubleshooting)
23
23
 
24
24
  </div>
25
25
 
26
26
  ---
27
27
 
28
+ ## Why Mindsystem
29
+
30
+ Fully autonomous coding tools take a spec and run for hours until a product emerges. That works for prototypes and one-shot projects.
31
+
32
+ Mindsystem takes the opposite approach. It follows the same workflow a thorough engineer already uses — and amplifies each step:
33
+
34
+ | What you'd do manually | What Mindsystem does |
35
+ |---|---|
36
+ | Talk through requirements, catch misalignment early | **Discuss phase** surfaces assumptions with confidence levels, forces tradeoff decisions before any code gets written |
37
+ | Google libraries, read a few docs | **Research phase** runs 3 parallel agents across documentation, your codebase, and community practices — 10x more sources, synthesized in minutes |
38
+ | Try design directions, pick the best one | **Design phase** generates parallel HTML/CSS mockups with side-by-side comparison and exact design tokens |
39
+ | Plan from what you remember about the codebase | **Plan phase** loads knowledge files capturing every decision, pattern, and pitfall from prior phases |
40
+ | Figure out what states to test, mock them manually | **Verify work** determines mock states automatically — you validate visually or programmatically |
41
+
42
+ The workflow stays yours. Each step finishes in minutes instead of hours. Everything learned compounds into knowledge that survives context resets — phase 10 starts with everything the project learned from phases 1–9.
43
+
44
+ This is not an autopilot. It's a force multiplier.
45
+
46
+ ---
47
+
28
48
  ## How it works
29
49
 
30
50
  ```
@@ -75,6 +95,12 @@ Execution happens in fresh subagent contexts, so each plan gets up to 200k token
75
95
 
76
96
  ## End-to-end walkthrough
77
97
 
98
+ ### Project setup
99
+
100
+ Before building features, initialize the project once with `/ms:new-project`. For existing codebases, also run `/ms:map-codebase` (analyzes your stack, conventions, and architecture into 7 structured documents) and `/ms:doctor` (validates config and generates per-subsystem knowledge files from source code). See [Quick start](#quick-start) for the exact sequences.
101
+
102
+ Everything below is the feature-building loop, identical for new and existing projects.
103
+
78
104
  ### 1. New milestone
79
105
 
80
106
  ```
@@ -274,31 +300,37 @@ Requirements you want but haven't shipped yet are tracked in `PROJECT.md` with o
274
300
 
275
301
  ## Quick start
276
302
 
277
- ### New project
303
+ ### Project setup (one-time)
304
+
305
+ **New project:**
278
306
 
279
307
  ```
280
308
  /ms:new-project
281
- /ms:new-milestone
282
- /ms:create-roadmap
283
- /ms:plan-phase 1
284
- /ms:execute-phase 1
285
- /ms:verify-work 1
286
309
  ```
287
310
 
288
- You'll get `.planning/` with your project vision, milestone context, requirements, roadmap, and the first phase implemented with commits, patch files, and knowledge files.
311
+ **Existing codebase:**
312
+
313
+ ```
314
+ /ms:new-project # Business context and vision
315
+ /ms:map-codebase # Analyze code → 7 structured documents
316
+ /ms:doctor # Validate config, generate knowledge files
317
+ ```
318
+
319
+ Optional: `/ms:config` — configure code reviewers, gitignore, and other preferences.
289
320
 
290
- ### Existing project
321
+ ### Building features
322
+
323
+ Once the project is set up, the workflow is the same for new and existing codebases:
291
324
 
292
325
  ```
293
- /ms:new-project
294
- /ms:map-codebase
295
- /ms:new-milestone
296
- /ms:create-roadmap
297
- /ms:plan-phase 1
298
- /ms:execute-phase 1
326
+ /ms:new-milestone # Discover what to build next
327
+ /ms:create-roadmap # Define requirements, map to phases
328
+ /ms:plan-phase 1 # Create detailed plan
329
+ /ms:execute-phase 1 # Run in fresh subagents
330
+ /ms:verify-work 1 # Manual acceptance testing
299
331
  ```
300
332
 
301
- Codebase mapping produces 7 documents covering your stack, conventions, and architecture. Then you define what to build, and all downstream planning respects what's already there.
333
+ Repeat for each milestone. All downstream planning automatically loads codebase docs and knowledge files.
302
334
 
303
335
  **Returning after a break?** Run `/ms:progress` to see where you left off and what to do next.
304
336
 
@@ -315,6 +347,7 @@ Every artifact Mindsystem generates lives in `.planning/` — a markdown knowled
315
347
 
316
348
  ├── STATE.md # Active phase, blockers, recent decisions
317
349
  ├── MILESTONE-CONTEXT.md # new-milestone → brainstorm that grounds the roadmap
350
+ ├── MILESTONE-RESEARCH.md # research-milestone → domain research before roadmapping
318
351
  ├── ROADMAP.md # Phase breakdown with goals and success criteria
319
352
  ├── REQUIREMENTS.md # Checkable REQ-IDs mapped to phases
320
353
 
@@ -359,9 +392,6 @@ Every artifact Mindsystem generates lives in `.planning/` — a markdown knowled
359
392
  │ ├── CONTEXT.md # discussed, not yet planned
360
393
  │ └── 02-01-PLAN.md # planned, not yet executed
361
394
 
362
- ├── MILESTONE-RESEARCH.md # /ms:research-milestone → domain ecosystem
363
- │ # Technology, product landscape, architecture, risks
364
-
365
395
  ├── adhoc/ # /ms:adhoc → out-of-pipeline work
366
396
  │ └── 2026-01-15-fix-token/
367
397
  │ ├── adhoc-01-SUMMARY.md # Execution results and learnings
@@ -523,4 +553,4 @@ MIT License. See [LICENSE](LICENSE) for details.
523
553
 
524
554
  ---
525
555
 
526
- Inspired by [GSD](https://github.com/gsd-build/get-shit-done) and [Compound Engineering](https://github.com/EveryInc/compound-engineering-plugin).
556
+ Originally rooted in [GSD](https://github.com/gsd-build/get-shit-done), now an independent system with its own philosophy. Knowledge compounding inspired by [Compound Engineering](https://github.com/EveryInc/compound-engineering-plugin).
@@ -15,6 +15,8 @@ You are spawned by:
15
15
  - `/ms:research-milestone` orchestrator (milestone-scoped research before roadmap)
16
16
 
17
17
  Your job: Answer research questions with verified, actionable findings. Produce structured output files that inform quality planning.
18
+
19
+ **Tool selection:** Match tool to question type. Library API docs → `ms-lookup docs`. Deep synthesis → `ms-lookup deep` (3-4 calls max). Discovery/trends → WebSearch. Follow the orchestrator's `<focus>` rules.
18
20
  </role>
19
21
 
20
22
  <upstream_input>
package/bin/install.js CHANGED
@@ -471,8 +471,8 @@ function ensurePathHook(claudeDir, isGlobal, configDir) {
471
471
  });
472
472
 
473
473
  fs.writeFileSync(settingsPath, JSON.stringify(settings, null, 2));
474
- if (removed > 0) {
475
- console.log(` ${green}✓${reset} Configured PATH hook (cleaned ${removed} duplicate(s))`);
474
+ if (removed > 1) {
475
+ console.log(` ${green}✓${reset} Configured PATH hook (cleaned ${removed - 1} duplicate(s))`);
476
476
  } else {
477
477
  console.log(` ${green}✓${reset} Configured PATH hook`);
478
478
  }
@@ -300,25 +300,9 @@ Requirements and roadmap created:
300
300
  - Roadmap: .planning/ROADMAP.md
301
301
  - State: .planning/STATE.md
302
302
  - [X] v1 requirements, [M] phases defined
303
-
304
- ---
305
-
306
- ## ▶ Next Up
307
-
308
- **Phase 1: [Name]** — [Goal from ROADMAP.md]
309
-
310
- `/ms:plan-phase 1`
311
-
312
- <sub>`/clear` first → fresh context window</sub>
313
-
314
- ---
315
-
316
- **Also available:**
317
- - `/ms:discuss-phase 1` — gather context first
318
- - `/ms:research-phase 1` — investigate unknowns
319
-
320
- ---
321
303
  ```
304
+
305
+ Read `~/.claude/mindsystem/references/routing/next-phase-routing.md` and follow its instructions to present "Next Up" with pre-work context for Phase $START_PHASE.
322
306
  </step>
323
307
 
324
308
  <step name="update_last_command">
@@ -26,21 +26,29 @@ Output ONLY the reference content below. Do NOT add:
26
26
 
27
27
  ## Quick Start
28
28
 
29
- ### Greenfield (new project)
29
+ ### Project setup (one-time)
30
+
31
+ **New project:**
30
32
 
31
33
  1. `/ms:new-project` — Initialize project with brief
32
- 2. `/ms:config` — (optional) Configure code reviewers and gitignore
33
- 3. `/ms:research-milestone` — (optional) Research domain ecosystem
34
- 4. `/ms:create-roadmap` — Define requirements and create roadmap
35
- 5. `/ms:plan-phase 1` — Create detailed plan for first phase
36
- 6. `/ms:execute-phase 1` — Execute with parallel agents
37
34
 
38
- ### Brownfield (existing codebase)
35
+ **Existing codebase:**
39
36
 
40
37
  1. `/ms:new-project` — Questions focus on business context and vision
41
- 2. `/ms:map-codebase` — Analyze existing code
42
- 3. `/ms:config` — (optional) Configure code reviewers and gitignore
43
- 4. Continue with research/roadmap/plan/execute
38
+ 2. `/ms:map-codebase` — Analyze existing code for patterns and conventions
39
+ 3. `/ms:doctor` — Validate config and generate knowledge files from source code
40
+
41
+ Optional: `/ms:config` — Configure code reviewers, gitignore, and other preferences
42
+
43
+ ### Building features (repeat per milestone)
44
+
45
+ 1. `/ms:new-milestone` — Discover what to build next
46
+ 2. `/ms:research-milestone` — Research domain ecosystem (recommended)
47
+ 3. `/ms:create-roadmap` — Define requirements and create roadmap
48
+ 4. `/ms:discuss-phase 1` — Gather context before planning (recommended)
49
+ 5. `/ms:plan-phase 1` — Create detailed plan for first phase
50
+ 6. `/ms:execute-phase 1` — Execute with parallel agents
51
+ 7. `/ms:verify-work 1` — (optional) Manual acceptance testing
44
52
 
45
53
  ## Staying Updated
46
54
 
@@ -56,14 +64,14 @@ Release notes: `/ms:release-notes`
56
64
  ## Core Workflow
57
65
 
58
66
  ```
59
- Initialize → (Optional Research) → Roadmap → Plan → Execute → Verify → Milestone
67
+ Initialize → Research → Roadmap → Discuss → Plan → Execute → Verify → Milestone
60
68
  ```
61
69
 
62
70
  Common deviations:
63
71
  - Existing repo: `/ms:map-codebase` after `/ms:new-project` (or before — either works)
64
- - Plan looks wrong: `/ms:discuss-phase <phase>`
65
- - Unknown domain: `/ms:research-milestone` before roadmap, or `/ms:research-phase <phase>` before planning
66
- - Phase prep: `/ms:discuss-phase` → `/ms:design-phase` → `/ms:research-phase` → `/ms:plan-phase` (all optional before plan)
72
+ - Skip research-milestone: domain is familiar, no external APIs or new patterns
73
+ - Skip discuss-phase: purely mechanical work (config-only, rename-only, version bump)
74
+ - Phase prep: `/ms:discuss-phase` → `/ms:design-phase` → `/ms:research-phase` → `/ms:plan-phase` (discuss recommended, others when flagged)
67
75
  - New urgent work: `/ms:insert-phase <after> "<desc>"`
68
76
  - New non-urgent work: `/ms:add-todo "<desc>"`
69
77
 
@@ -455,27 +463,32 @@ Usage: `/ms:release-notes`
455
463
 
456
464
  ## Common Workflows
457
465
 
458
- **Starting a new project (greenfield):**
466
+ **Project setup new project:**
459
467
 
460
468
  ```
461
469
  /ms:new-project # Extract your idea through questions
462
- /ms:config # (optional) Configure code reviewers and gitignore
463
- /ms:research-milestone # (recommended) Research domain ecosystem
464
- /ms:create-roadmap # Define requirements and create phases
465
- /ms:plan-phase 1 # Create detailed plan
466
- /ms:execute-phase 1 # Execute with parallel agents
467
470
  ```
468
471
 
469
- **Starting with existing code (brownfield):**
472
+ **Project setup existing codebase:**
470
473
 
471
474
  ```
472
- /ms:new-project # Step 1: Questions focus on business context and vision
473
- /ms:map-codebase # Step 2: Analyze existing code
474
- /ms:config # (optional) Configure code reviewers and gitignore
475
- /ms:research-milestone # (optional) Research new domain areas
476
- /ms:create-roadmap # Define requirements and create roadmap
477
- /ms:plan-phase 1 # Codebase docs load automatically
478
- /ms:execute-phase 1 # Claude knows your patterns & conventions
475
+ /ms:new-project # Business context and vision
476
+ /ms:map-codebase # Analyze code 7 structured documents
477
+ /ms:doctor # Validate config, generate knowledge files
478
+ ```
479
+
480
+ Optional: `/ms:config` configure code reviewers, gitignore, and other preferences
481
+
482
+ **Building features (repeat per milestone):**
483
+
484
+ ```
485
+ /ms:new-milestone # Discover what to build next
486
+ /ms:research-milestone # Research domain ecosystem (recommended)
487
+ /ms:create-roadmap # Define requirements and create phases
488
+ /ms:discuss-phase 1 # Gather context before planning (recommended)
489
+ /ms:plan-phase 1 # Create detailed plan
490
+ /ms:execute-phase 1 # Execute with parallel agents
491
+ /ms:verify-work 1 # (optional) Manual acceptance testing
479
492
  ```
480
493
 
481
494
  **Not sure what to do next / returning after a break:**
@@ -526,8 +539,9 @@ Common options:
526
539
 
527
540
  ```
528
541
  /ms:new-milestone # Discover what to build, update PROJECT.md
529
- /ms:research-milestone # (optional) Domain / stack research
542
+ /ms:research-milestone # Research domain ecosystem (recommended)
530
543
  /ms:create-roadmap # New phases mapped to requirements
544
+ /ms:discuss-phase <phase> # Gather context before planning (recommended)
531
545
  /ms:plan-phase # Auto-detect next unplanned phase
532
546
  /ms:execute-phase <phase>
533
547
  ```
@@ -59,7 +59,7 @@ Check for .planning/STATE.md - loads context if project already initialized
59
59
  4. Wait for agents to complete, collect confirmations (NOT document contents)
60
60
  5. Verify all 7 documents exist with line counts
61
61
  6. Commit codebase map
62
- 7. Offer next steps (typically: /ms:new-project or /ms:plan-phase)
62
+ 7. Offer next steps (adapts: /ms:new-project if no PROJECT.md, /ms:doctor if PROJECT.md exists)
63
63
  8. **Update last command:** `ms-tools set-last-command "ms:map-codebase $ARGUMENTS"`
64
64
  </process>
65
65
 
@@ -278,7 +278,7 @@ Milestone name: $ARGUMENTS (optional — will emerge during discovery if not pro
278
278
 
279
279
  19. **Route to next step:**
280
280
 
281
- Based on the conversation, recommend ONE path. If unfamiliar domains or open questions surfaced during discovery, recommend `/ms:research-milestone`. Otherwise recommend `/ms:create-roadmap`.
281
+ Default to `/ms:research-milestone` domain research improves roadmap quality for most milestones. Only recommend `/ms:create-roadmap` directly when the domain is clearly familiar, no open questions surfaced, and there are no external APIs, new libraries, or unfamiliar patterns involved.
282
282
 
283
283
  ```
284
284
  Milestone [Name] initialized.
@@ -311,5 +311,5 @@ Milestone name: $ARGUMENTS (optional — will emerge during discovery if not pro
311
311
  - MILESTONE-CONTEXT.md created with vision, features, scope, priorities
312
312
  - STATE.md reset for new milestone
313
313
  - Git commit made
314
- - User routed to create-roadmap (or research-milestone if unknowns surfaced)
314
+ - User routed to research-milestone (or create-roadmap if domain is clearly familiar)
315
315
  </success_criteria>
@@ -242,13 +242,16 @@ Project updated:
242
242
  - Config: .planning/config.json
243
243
  ```
244
244
 
245
- **Routing (both modes):**
245
+ **Routing:**
246
246
 
247
247
  ```
248
248
  ---
249
249
 
250
250
  ## ▶ Next Up
251
251
 
252
+ [If brownfield detected and no codebase map:]
253
+ `/ms:map-codebase` — Analyze existing codebase for technical context
254
+ [Otherwise:]
252
255
  `/ms:new-milestone` — Discover what to build first, create requirements and roadmap
253
256
 
254
257
  <sub>`/clear` first → fresh context window</sub>
@@ -257,7 +260,8 @@ Project updated:
257
260
 
258
261
  **Also available:**
259
262
  - `/ms:config` — Configure code reviewers, gitignore, and other preferences
260
- [If brownfield detected and no codebase map:] - `/ms:map-codebase` — Analyze existing codebase for technical context
263
+ - `/ms:doctor` — Health check and fix project configuration
264
+ [If brownfield detected and no codebase map:] - `/ms:new-milestone` — Discover what to build first, create requirements and roadmap
261
265
 
262
266
  ---
263
267
  ```
@@ -123,12 +123,12 @@ Phase Research — External Documentation focus.
123
123
 
124
124
  <focus>
125
125
  Library documentation, APIs, version-specific behavior, verified code examples.
126
- Use the ms-lookup CLI for library docs and deep research:
127
- ms-lookup docs <library> '<query>'
128
- ms-lookup deep '<query>'
129
- Use WebSearch for ecosystem discovery.
130
- Focus on finding authoritative, current documentation for the libraries and tools
131
- needed to implement this phase.
126
+ Focus on finding authoritative, current documentation for the libraries and tools needed to implement this phase.
127
+
128
+ Tool selection rules:
129
+ - Library API docs, syntax, configuration → `ms-lookup docs <library> '<query>'`
130
+ - Complex architecture/approach synthesis `ms-lookup deep '<query>'` (limit: 3-4 calls)
131
+ - Library discovery, trends, ecosystem survey → WebSearch
132
132
  </focus>
133
133
 
134
134
  <existing_tech>
@@ -225,10 +225,12 @@ Phase Research — Best Practices & Community Consensus focus.
225
225
 
226
226
  <focus>
227
227
  Community consensus, common pitfalls, proven approaches, state of the art.
228
- Use the ms-lookup CLI for deep research on high-value questions:
229
- ms-lookup deep '<query>'
230
- Use WebSearch for community articles, blog posts, Stack Overflow patterns.
231
228
  Focus on what practitioners recommend and what mistakes to avoid.
229
+
230
+ Tool selection rules:
231
+ - Complex best-practices synthesis, architecture decisions → `ms-lookup deep '<query>'` (limit: 3-4 calls)
232
+ - Community opinions, blog posts, trends, library discovery → WebSearch
233
+ - Library-specific API verification (when confirming a recommendation) → `ms-lookup docs <library> '<query>'`
232
234
  </focus>
233
235
 
234
236
  <existing_tech>
@@ -32,12 +32,12 @@ Phase Research — External Documentation focus.
32
32
 
33
33
  <focus>
34
34
  Library documentation, APIs, version-specific behavior, verified code examples.
35
- Use the ms-lookup CLI for library docs and deep research:
36
- ms-lookup docs <library> '<query>'
37
- ms-lookup deep '<query>'
38
- Use WebSearch for ecosystem discovery.
39
- Focus on finding authoritative, current documentation for the libraries and tools
40
- needed to implement this phase.
35
+ Focus on finding authoritative, current documentation for the libraries and tools needed to implement this phase.
36
+
37
+ Tool selection rules:
38
+ - Library API docs, syntax, configuration → `ms-lookup docs <library> '<query>'`
39
+ - Complex architecture/approach synthesis `ms-lookup deep '<query>'` (limit: 3-4 calls)
40
+ - Library discovery, trends, ecosystem survey → WebSearch
41
41
  </focus>
42
42
 
43
43
  <existing_tech>
@@ -128,10 +128,12 @@ Phase Research — Best Practices & Community Consensus focus.
128
128
 
129
129
  <focus>
130
130
  Community consensus, common pitfalls, proven approaches, state of the art.
131
- Use the ms-lookup CLI for deep research on high-value questions:
132
- ms-lookup deep '<query>'
133
- Use WebSearch for community articles, blog posts, Stack Overflow patterns.
134
131
  Focus on what practitioners recommend and what mistakes to avoid.
132
+
133
+ Tool selection rules:
134
+ - Complex best-practices synthesis, architecture decisions → `ms-lookup deep '<query>'` (limit: 3-4 calls)
135
+ - Community opinions, blog posts, trends, library discovery → WebSearch
136
+ - Library-specific API verification (when confirming a recommendation) → `ms-lookup docs <library> '<query>'`
135
137
  </focus>
136
138
 
137
139
  <existing_tech>
@@ -239,14 +239,63 @@ EOF
239
239
  <step name="fix_knowledge">
240
240
  **Only if Knowledge Files failed.**
241
241
 
242
- Spawn a `general-purpose` subagent (Task tool) to generate knowledge files retroactively. Provide the subagent with:
242
+ ### 1. Detect knowledge source
243
243
 
244
- - Subsystem vocabulary from config.json
245
- - Instructions to read all PHASE-SUMMARIES.md from `milestones/*/PHASE-SUMMARIES.md` AND any remaining SUMMARY files in `phases/`
246
- - The knowledge template at `~/.claude/mindsystem/templates/knowledge.md`
247
- - Instructions to read any existing knowledge files and merge (rewrite semantics — current state, not append)
248
- - Instructions to create `.planning/knowledge/` directory if missing
249
- - Instructions to write `.planning/knowledge/{subsystem}.md` for each missing subsystem
244
+ Run in main context before spawning agent:
245
+
246
+ ```bash
247
+ SUMMARIES=$(ls .planning/milestones/*/PHASE-SUMMARIES.md .planning/phases/*/*-SUMMARY.md 2>/dev/null | wc -l | tr -d ' ')
248
+ HAS_CODEBASE_DOCS=$([ -d .planning/codebase ] && echo "yes" || echo "no")
249
+ HAS_PROJECT=$([ -f .planning/PROJECT.md ] && echo "yes" || echo "no")
250
+ ```
251
+
252
+ If `SUMMARIES > 0`: **artifact mode**. If `SUMMARIES == 0`: **source code mode**.
253
+
254
+ ### 2. Spawn subagent
255
+
256
+ Spawn a `general-purpose` subagent (Task tool) with the following structured prompt. Inject detected mode, subsystem list from config.json, and environment flags into the prompt.
257
+
258
+ ---
259
+
260
+ **Prompt content for subagent:**
261
+
262
+ > **Task:** Generate `.planning/knowledge/{subsystem}.md` for each subsystem listed below.
263
+ >
264
+ > **Subsystems:** {inject list from config.json}
265
+ >
266
+ > **Knowledge template:** Read `~/.claude/mindsystem/templates/knowledge.md` for format reference.
267
+ >
268
+ > **Mode: {artifact | source code}**
269
+ >
270
+ > **If artifact mode:** Read all PHASE-SUMMARIES.md from `milestones/*/PHASE-SUMMARIES.md` and any remaining `*-SUMMARY.md` in `phases/`. {If HAS_CODEBASE_DOCS=yes: "Also read `.planning/codebase/ARCHITECTURE.md`, `STACK.md`, `STRUCTURE.md` for structural context."} {If HAS_PROJECT=yes: "Read `.planning/PROJECT.md` for product context."}
271
+ >
272
+ > **If source code mode:** No pipeline artifacts exist. {If HAS_CODEBASE_DOCS=yes: "Read `.planning/codebase/ARCHITECTURE.md`, `STACK.md`, `STRUCTURE.md` first for orientation, then dive into source code per subsystem."} {If HAS_CODEBASE_DOCS=no: "Explore from package manifests (package.json, pubspec.yaml, Cargo.toml, etc.) and directory structure to understand the codebase, then analyze source code per subsystem."} {If HAS_PROJECT=yes: "Read `.planning/PROJECT.md` for product context."}
273
+ >
274
+ > **Extraction guide — what to extract per subsystem:**
275
+ >
276
+ > | Source Signal | Target Knowledge Section |
277
+ > |--------------|------------------------|
278
+ > | Library/framework choices, version constraints | Decisions |
279
+ > | Component structure, data flow, API contracts | Architecture |
280
+ > | UI patterns, design tokens, interaction behaviors | Design |
281
+ > | Error handling patterns, edge cases, workarounds | Pitfalls |
282
+ > | Main modules, entry points, config files | Key Files |
283
+ >
284
+ > **Critical rules:**
285
+ > - Extract knowledge, not descriptions. "Has login endpoint" is a description. "POST /auth/login with bcrypt + JWT httpOnly cookie" is architecture knowledge.
286
+ > - Preserve rationale when visible in code comments or config. Do not fabricate reasons.
287
+ > - Do not fabricate specific numbers (limits, thresholds, counts) — read from source or omit.
288
+ > - Omit empty sections. No Design section if subsystem has no UI.
289
+ > - Rewrite semantics — if existing knowledge files exist, merge by producing current state.
290
+ > - Cross-reference between subsystems where relevant: "(see api subsystem)".
291
+ > - Decisions table: 5-10 words per cell. Source column: `"existing"` for source code mode, artifact reference for artifact mode.
292
+ > - Key files must reference actual paths verified to exist.
293
+ > - `mkdir -p .planning/knowledge/` before writing.
294
+ > - No commits.
295
+
296
+ ---
297
+
298
+ ### 3. Verify and commit
250
299
 
251
300
  After subagent completes, verify files exist:
252
301
 
@@ -254,7 +303,7 @@ After subagent completes, verify files exist:
254
303
  ls .planning/knowledge/*.md
255
304
  ```
256
305
 
257
- Commit:
306
+ Commit (use detected mode in message):
258
307
 
259
308
  ```bash
260
309
  git add .planning/knowledge/
@@ -264,10 +313,12 @@ git add .planning/knowledge/
264
313
  git commit -m "$(cat <<'EOF'
265
314
  chore(doctor): generate knowledge files
266
315
 
267
- Created per-subsystem knowledge files from phase summaries.
316
+ Created per-subsystem knowledge files from {phase summaries|source code analysis}.
268
317
  EOF
269
318
  )"
270
319
  ```
320
+
321
+ Replace `{phase summaries|source code analysis}` with the appropriate phrase based on detected mode.
271
322
  </step>
272
323
 
273
324
  </process>
@@ -246,6 +246,11 @@ Present completion summary and next steps.
246
246
  wc -l .planning/codebase/*.md
247
247
  ```
248
248
 
249
+ **Detect project state:**
250
+ ```bash
251
+ [ -f .planning/PROJECT.md ] && echo "HAS_PROJECT=true" || echo "HAS_PROJECT=false"
252
+ ```
253
+
249
254
  **Output format:**
250
255
 
251
256
  ```
@@ -259,22 +264,40 @@ Created .planning/codebase/:
259
264
  - TESTING.md ([N] lines) - Test structure and practices
260
265
  - INTEGRATIONS.md ([N] lines) - External services and APIs
261
266
  - CONCERNS.md ([N] lines) - Technical debt and issues
267
+ ```
268
+
269
+ **Routing (based on project state):**
270
+
271
+ **If HAS_PROJECT=false** (map-codebase ran before new-project):
272
+
273
+ ```
274
+ ---
262
275
 
276
+ ## ▶ Next Up
277
+
278
+ `/ms:new-project` — initialize project with business context (codebase docs load automatically)
263
279
 
280
+ <sub>`/clear` first → fresh context window</sub>
281
+
282
+ ---
283
+ ```
284
+
285
+ **If HAS_PROJECT=true** (map-codebase ran after new-project):
286
+
287
+ ```
264
288
  ---
265
289
 
266
290
  ## ▶ Next Up
267
291
 
268
- `/ms:new-project` — use codebase context for planning
292
+ `/ms:doctor` — validate project configuration and generate knowledge files
269
293
 
270
294
  <sub>`/clear` first → fresh context window</sub>
271
295
 
272
296
  ---
273
297
 
274
298
  **Also available:**
275
- - Re-run mapping: `/ms:map-codebase`
276
- - Review specific file: `cat .planning/codebase/STACK.md`
277
- - Edit any document before proceeding
299
+ - `/ms:config` — configure code reviewers, gitignore, and other preferences
300
+ - `/ms:new-milestone` skip doctor, go straight to defining what to build
278
301
 
279
302
  ---
280
303
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mindsystem-cc",
3
- "version": "4.1.0",
3
+ "version": "4.1.2",
4
4
  "description": "A meta-prompting, context engineering and spec-driven development system for Claude Code by TÂCHES.",
5
5
  "bin": {
6
6
  "mindsystem-cc": "bin/install.js"