@soleri/forge 9.3.1 → 9.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/dist/compose-claude-md.js +118 -7
  2. package/dist/compose-claude-md.js.map +1 -1
  3. package/dist/scaffolder.js +39 -1
  4. package/dist/scaffolder.js.map +1 -1
  5. package/dist/skills/agent-dev/SKILL.md +122 -0
  6. package/dist/skills/agent-guide/SKILL.md +116 -0
  7. package/dist/skills/agent-issues/SKILL.md +268 -0
  8. package/dist/skills/agent-persona/SKILL.md +66 -0
  9. package/dist/skills/deep-review/SKILL.md +12 -0
  10. package/dist/skills/deliver-and-ship/SKILL.md +123 -0
  11. package/dist/skills/discovery-phase/SKILL.md +69 -0
  12. package/dist/skills/env-setup/SKILL.md +151 -0
  13. package/dist/skills/executing-plans/SKILL.md +12 -0
  14. package/dist/skills/finishing-a-development-branch/SKILL.md +76 -0
  15. package/dist/skills/fix-and-learn/SKILL.md +12 -0
  16. package/dist/skills/mcp-doctor/SKILL.md +154 -0
  17. package/dist/skills/subagent-driven-development/SKILL.md +77 -0
  18. package/dist/skills/using-git-worktrees/SKILL.md +80 -0
  19. package/dist/skills/vault-curate/SKILL.md +99 -0
  20. package/dist/skills/verification-before-completion/SKILL.md +12 -0
  21. package/dist/skills/yolo-mode/SKILL.md +80 -0
  22. package/dist/templates/clean-worktrees.d.ts +5 -0
  23. package/dist/templates/clean-worktrees.js +59 -0
  24. package/dist/templates/clean-worktrees.js.map +1 -0
  25. package/dist/templates/setup-script.js +26 -1
  26. package/dist/templates/setup-script.js.map +1 -1
  27. package/dist/templates/shared-rules.js +128 -5
  28. package/dist/templates/shared-rules.js.map +1 -1
  29. package/dist/templates/skills.js +3 -29
  30. package/dist/templates/skills.js.map +1 -1
  31. package/dist/templates/vitest-config.js +1 -0
  32. package/dist/templates/vitest-config.js.map +1 -1
  33. package/package.json +1 -1
  34. package/src/compose-claude-md.ts +126 -9
  35. package/src/scaffolder.ts +41 -1
  36. package/src/skills/agent-dev/SKILL.md +122 -0
  37. package/src/skills/agent-guide/SKILL.md +116 -0
  38. package/src/skills/agent-issues/SKILL.md +268 -0
  39. package/src/skills/agent-persona/SKILL.md +66 -0
  40. package/src/skills/deep-review/SKILL.md +12 -0
  41. package/src/skills/deliver-and-ship/SKILL.md +123 -0
  42. package/src/skills/discovery-phase/SKILL.md +69 -0
  43. package/src/skills/env-setup/SKILL.md +151 -0
  44. package/src/skills/executing-plans/SKILL.md +12 -0
  45. package/src/skills/finishing-a-development-branch/SKILL.md +76 -0
  46. package/src/skills/fix-and-learn/SKILL.md +12 -0
  47. package/src/skills/mcp-doctor/SKILL.md +154 -0
  48. package/src/skills/subagent-driven-development/SKILL.md +77 -0
  49. package/src/skills/using-git-worktrees/SKILL.md +80 -0
  50. package/src/skills/vault-curate/SKILL.md +99 -0
  51. package/src/skills/verification-before-completion/SKILL.md +12 -0
  52. package/src/skills/yolo-mode/SKILL.md +80 -0
  53. package/src/templates/clean-worktrees.ts +58 -0
  54. package/src/templates/setup-script.ts +26 -1
  55. package/src/templates/shared-rules.ts +130 -5
  56. package/src/templates/skills.ts +3 -29
  57. package/src/templates/vitest-config.ts +1 -0
  58. package/vitest.config.ts +1 -0
@@ -0,0 +1,123 @@
1
+ ---
2
+ name: deliver-and-ship
3
+ description: >
4
+ Use when the user says "ship it", "ready to deploy", "package", "release",
5
+ "pre-PR check", "delivery checklist", "is this ready", "final review", or mentions
6
+ shipping, deploying, packaging, or releasing work. Runs pre-delivery quality gates
7
+ to ensure nothing ships without passing stability, knowledge capture, and code quality checks.
8
+ ---
9
+
10
+ # Deliver & Ship — Quality Gate Runner
11
+
12
+ Run all pre-delivery quality gates before shipping. This ensures nothing leaves without passing stability checks, knowledge capture, and code quality verification.
13
+
14
+ ## When to Use
15
+
16
+ When work is considered "done" and ready to be committed, PR'd, or deployed. This is the last checkpoint before code leaves the developer's hands.
17
+
18
+ ## Orchestration Sequence
19
+
20
+ ### Step 1: Code Quality
21
+
22
+ Run the project's linter, formatter, and type checker on all modified files:
23
+
24
+ 1. Check for lint/format scripts in `package.json` (or equivalent)
25
+ 2. Run `typecheck` / `tsc --noEmit` if TypeScript
26
+ 3. Run any project-specific quality gates (clippy for Rust, mypy for Python, etc.)
27
+
28
+ Any type error or lint failure is a blocker.
29
+
30
+ ### Step 2: Test Suite
31
+
32
+ Run the full test suite to catch regressions:
33
+
34
+ ```
35
+ YOUR_AGENT_core op:admin_health
36
+ ```
37
+
38
+ Verify the agent itself is healthy, then run project tests. All tests must pass.
39
+
40
+ ### Step 3: Stability Assessment
41
+
42
+ Classify the changes as safe or breaking:
43
+
44
+ - **Safe**: Internal refactors, bug fixes, additive features (new exports, new ops)
45
+ - **Breaking**: Removed exports, changed signatures, renamed public APIs, schema migrations
46
+ - Breaking changes need migration guidance in the commit/PR description
47
+
48
+ ### Step 4: Knowledge Audit
49
+
50
+ Check if patterns discovered during this work session should be captured before shipping:
51
+
52
+ ```
53
+ YOUR_AGENT_core op:memory_search
54
+ params: { query: "current session" }
55
+ ```
56
+
57
+ ```
58
+ YOUR_AGENT_core op:brain_stats
59
+ ```
60
+
61
+ Look for:
62
+
63
+ - Bug fixes that reveal an anti-pattern worth capturing
64
+ - New patterns that should be in the vault for next time
65
+ - Architectural decisions that need documenting
66
+
67
+ Uncaptured knowledge is lost knowledge. If something should be captured:
68
+
69
+ ```
70
+ YOUR_AGENT_core op:capture_knowledge
71
+ params: {
72
+ title: "<what was learned>",
73
+ description: "<the pattern or anti-pattern>",
74
+ type: "pattern",
75
+ tags: ["<relevant-tags>"]
76
+ }
77
+ ```
78
+
79
+ ### Step 5: Commit Quality
80
+
81
+ Verify commit messages follow conventional commits:
82
+
83
+ - `feat:` for new features
84
+ - `fix:` for bug fixes
85
+ - `refactor:` for refactors
86
+ - `chore:` for maintenance
87
+ - No AI attribution (blocked by engine rules)
88
+
89
+ ### Step 6: Delivery Report
90
+
91
+ Present a checklist:
92
+
93
+ - [ ] Code quality: pass/fail (Step 1)
94
+ - [ ] Tests: pass/fail (Step 2)
95
+ - [ ] Stability: safe change / breaking change (Step 3)
96
+ - [ ] Knowledge: captured / needs capture (Step 4)
97
+ - [ ] Commits: clean / needs cleanup (Step 5)
98
+
99
+ All items must pass before recommending "ship it."
100
+
101
+ ## Domain-Specific Gates
102
+
103
+ Agents with domain-specific facades may add extra gates. For example:
104
+
105
+ - **Design system agents**: token validation, contrast checks, accessibility audit
106
+ - **API agents**: schema validation, backward compatibility checks
107
+ - **Security agents**: dependency audit, secret scanning
108
+
109
+ These are additive — they don't replace the generic gates above.
110
+
111
+ ## Exit Criteria
112
+
113
+ Delivery is approved when all gates pass. If any gate fails, report the failure and recommend fixes before shipping. Never approve delivery with blocking issues.
114
+
115
+ ## Agent Tools Reference
116
+
117
+ | Op | When to Use |
118
+ | ------------------- | -------------------------------------- |
119
+ | `admin_health` | Verify agent/system health |
120
+ | `memory_search` | Check for uncaptured session knowledge |
121
+ | `brain_stats` | Review learning state |
122
+ | `capture_knowledge` | Persist patterns before shipping |
123
+ | `capture_quick` | Fast capture for simple learnings |
@@ -0,0 +1,69 @@
1
+ ---
2
+ name: discovery-phase
3
+ description: >
4
+ Use for structured exploration before committing to a plan — "I don't know where to start",
5
+ "what are our options", "investigate", "research this", "explore options", "discovery". Ideal
6
+ when requirements are unclear, entering a new domain, or facing architectural decisions. Produces
7
+ a discovery document with options, tradeoffs, and a recommendation.
8
+ ---
9
+
10
+ # Discovery Phase
11
+
12
+ Structured exploration before committing to a plan. Define the question, research prior art, explore the codebase, identify constraints, draft options with tradeoffs, and recommend a path forward.
13
+
14
+ <HARD-GATE>
15
+ Do NOT create a plan, write code, or take any implementation action until the discovery document is complete and the user has reviewed it. Discovery produces knowledge, not artifacts.
16
+ </HARD-GATE>
17
+
18
+ ## Checklist
19
+
20
+ 1. **Define the question** — restate what we're exploring as one specific, answerable sentence
21
+ 2. **Search vault for prior art** — `YOUR_AGENT_core op:search_intelligent params: { query: "<question>", mode: "scan" }`. Also `op:memory_search` with `crossProject: true`.
22
+ 3. **Explore codebase** — read relevant files, configs, architecture, recent commits
23
+ 4. **Identify constraints** — hard (must-haves) vs soft (nice-to-haves), unknowns that block a decision
24
+ 5. **Draft 2-4 options** — each with pros, cons, risk, and effort (S/M/L)
25
+ 6. **Recommend** — pick one, state the primary reason, note what would change the answer
26
+ 7. **Capture to vault** — persist the discovery finding
27
+ 8. **Transition** — hand off to brainstorming or writing-plans skill
28
+
29
+ ## Option Format
30
+
31
+ For each option:
32
+
33
+ | Field | Content |
34
+ | ----- | ------- |
35
+ | **Approach** | One-sentence summary |
36
+ | **Pros** | What it gives us |
37
+ | **Cons** | What it costs |
38
+ | **Risk** | What could go wrong |
39
+ | **Effort** | S / M / L |
40
+
41
+ ## After Discovery
42
+
43
+ ```
44
+ YOUR_AGENT_core op:capture_knowledge
45
+ params: {
46
+ title: "<topic> — discovery finding",
47
+ description: "<question, options considered, recommendation, rationale>",
48
+ type: "decision",
49
+ category: "<domain>",
50
+ tags: ["discovery", "decision"]
51
+ }
52
+ ```
53
+
54
+ Save to `docs/discoveries/YYYY-MM-DD-<topic>.md` and commit. Then transition to the next skill.
55
+
56
+ ## Anti-Patterns
57
+
58
+ - **Skipping discovery** — jumping to implementation when the problem space is unclear
59
+ - **Analysis paralysis** — timebox to 30-60 min; if no clear winner, pick the most reversible option
60
+ - **Boiling the ocean** — scope to one question; split compound questions into separate discoveries
61
+
62
+ ## Quick Reference
63
+
64
+ | Op | When to Use |
65
+ | -------------------- | ---------------------------------- |
66
+ | `search_intelligent` | Search vault for prior art |
67
+ | `memory_search` | Check session history and projects |
68
+ | `capture_knowledge` | Persist discovery finding |
69
+ | `route_intent` | Classify what comes after |
@@ -0,0 +1,151 @@
1
+ ---
2
+ name: env-setup
3
+ description: >
4
+ Use when a developer needs to set up, fix, or restore a local development environment.
5
+ Triggers on post-clone setup, project onboarding, first-time running a repo, pulled changes
6
+ that broke the build, missing or misconfigured dependencies, MODULE_NOT_FOUND or Cannot find
7
+ module errors, gyp ERR or native module build failures, missing .env files or unknown required
8
+ environment variables, database setup, Docker compose issues, or connection refused during
9
+ local dev. Covers Node.js, Python, Rust, Go, Ruby, PHP, and Docker-based projects.
10
+ ---
11
+
12
+ # Environment Setup
13
+
14
+ Detect what a project needs, diagnose what's missing, and produce an actionable setup checklist.
15
+
16
+ ## Overview
17
+
18
+ Scan the project root for configuration files, detect the tech stack and dependencies, identify gaps between what's required and what's present, then generate ordered setup steps. Offer to execute each step.
19
+
20
+ ## When to Use
21
+
22
+ - Just cloned a repo and need to get it running
23
+ - Getting errors after pulling changes (missing deps, env vars, DB migrations)
24
+ - Onboarding to an unfamiliar project
25
+ - Setting up a project on a new machine
26
+ - Docker/container environment not starting
27
+ - Missing `.env` file or environment variables
28
+
29
+ ## Detection Phase
30
+
31
+ Scan the project root and identify:
32
+
33
+ ### Package Managers & Dependencies
34
+
35
+ | File | Stack | Install Command |
36
+ | ------------------ | ------- | ------------------------------------------------------------ |
37
+ | `package.json` | Node.js | `npm install` / `yarn` / `pnpm install` (check for lockfile) |
38
+ | `requirements.txt` | Python | `pip install -r requirements.txt` |
39
+ | `pyproject.toml` | Python | `pip install -e .` or `poetry install` or `uv sync` |
40
+ | `Pipfile` | Python | `pipenv install` |
41
+ | `Cargo.toml` | Rust | `cargo build` |
42
+ | `go.mod` | Go | `go mod download` |
43
+ | `Gemfile` | Ruby | `bundle install` |
44
+ | `composer.json` | PHP | `composer install` |
45
+
46
+ **Lockfile priority:** If a lockfile exists (`package-lock.json`, `yarn.lock`, `pnpm-lock.yaml`, `Pipfile.lock`, `poetry.lock`), use the matching package manager. Don't mix.
47
+
48
+ ### Environment Variables
49
+
50
+ 1. Check for `.env.example`, `.env.sample`, `.env.template`
51
+ 2. Check for existing `.env` — if missing, copy from template
52
+ 3. Parse template for required variables (lines without defaults or with placeholder values)
53
+ 4. Flag variables that need real values (API keys, secrets, database URLs)
54
+ 5. **If no template exists:** grep source for `process.env.`, `os.environ`, `env::var`, `os.Getenv` to discover env vars the project actually uses.
55
+
56
+ ### Native Dependencies
57
+
58
+ | Indicator | What It Means |
59
+ | ---------------------------------------- | -------------------------------------- |
60
+ | `better-sqlite3`, `sqlite3` in deps | Needs C++ compiler |
61
+ | `node-gyp` in deps or scripts | Needs Python 3 + C++ toolchain |
62
+ | `sharp` in deps | Needs `libvips` |
63
+ | `Cargo.toml` with `[build-dependencies]` | Needs Rust toolchain for build scripts |
64
+ | `setup.py` with `ext_modules` | Needs C compiler for Python extensions |
65
+
66
+ ### Databases
67
+
68
+ | File/Config | Database | Setup Needed |
69
+ | ---------------------------------------- | ---------------- | ---------------------------- |
70
+ | `docker-compose.yml` with postgres/mysql | PostgreSQL/MySQL | Container + migrations |
71
+ | `prisma/schema.prisma` | Prisma-managed | `npx prisma migrate dev` |
72
+ | `drizzle.config.*` | Drizzle-managed | `npx drizzle-kit push` |
73
+ | `alembic.ini` | SQLAlchemy | `alembic upgrade head` |
74
+ | `config/database.yml` | Rails | `rails db:create db:migrate` |
75
+
76
+ ### Infrastructure
77
+
78
+ | File | What It Means |
79
+ | --------------------------------------------- | ------------------------------------------- |
80
+ | `docker-compose.yml` | Services to start with `docker compose up` |
81
+ | `Dockerfile` | Can build container locally |
82
+ | `Makefile` | Check for `setup`, `install`, `dev` targets |
83
+ | `.tool-versions` / `.node-version` / `.nvmrc` | Required runtime version |
84
+ | `turbo.json` / `nx.json` / `lerna.json` | Monorepo setup |
85
+
86
+ ### IDE & Tool Integration
87
+
88
+ | File | Integration |
89
+ | ------------------------ | ---------------------------- |
90
+ | `.vscode/` | VS Code settings, extensions |
91
+ | `.mcp.json` / `mcp.json` | MCP server config |
92
+ | `.editorconfig` | Cross-editor formatting |
93
+
94
+ ## Diagnosis Phase
95
+
96
+ After detection, check what's present vs needed:
97
+
98
+ 1. **Runtime version** — does installed version match version files?
99
+ 2. **Dependencies installed?** — does `node_modules/`, `venv/`, `vendor/` exist?
100
+ 3. **Native build tools?** — are compilers available?
101
+ 4. **Env file present?** — does `.env` exist when a template does?
102
+ 5. **Database reachable?** — can the configured DB URL connect?
103
+ 6. **Docker running?** — is Docker daemon running if needed?
104
+ 7. **Build artifacts** — does the project need an initial build step?
105
+
106
+ ## Checklist Generation
107
+
108
+ Produce steps in dependency order:
109
+
110
+ ```
111
+ ## Setup Checklist
112
+
113
+ 1. [ ] Install runtime (Node 20.x via nvm)
114
+ 2. [ ] Install dependencies (pnpm install)
115
+ 3. [ ] Copy environment file (cp .env.example .env)
116
+ 4. [ ] Fill in required env vars: DATABASE_URL, API_KEY
117
+ 5. [ ] Start Docker services (docker compose up -d)
118
+ 6. [ ] Run database migrations (npx prisma migrate dev)
119
+ 7. [ ] Build the project (pnpm build)
120
+ 8. [ ] Start dev server (pnpm dev)
121
+ ```
122
+
123
+ **Order matters:** runtime -> deps -> env -> infrastructure -> migrations -> build -> run.
124
+
125
+ After presenting the checklist, offer: "Want me to run these steps for you?"
126
+
127
+ ## Execution Phase
128
+
129
+ If the user says yes, execute steps sequentially. Stop and ask if:
130
+
131
+ - A step fails
132
+ - A step requires manual input (API keys, passwords)
133
+ - A step would modify system-level config (global installs, PATH changes)
134
+
135
+ ## Monorepo Handling
136
+
137
+ If monorepo detected (turbo.json, nx.json, pnpm-workspace.yaml):
138
+
139
+ 1. Install root dependencies first
140
+ 2. Ask which package/app the user wants to work on
141
+ 3. Check for package-specific setup
142
+ 4. Run package-specific setup after root
143
+
144
+ ## Common Mistakes
145
+
146
+ - **Wrong package manager** — using `npm install` when `yarn.lock` exists. Always check lockfiles first.
147
+ - **Skipping env file** — project crashes on first API call. Always check for templates.
148
+ - **Missing native build tools** — `npm install` fails with gyp errors. Check before installing.
149
+ - **Missing runtime version** — subtle bugs from wrong Node/Python version.
150
+ - **Docker not running** — cryptic "connection refused" errors.
151
+ - **Stale dependencies** — after `git pull`, always re-install if lockfile changed.
@@ -77,6 +77,18 @@ Capture mid-execution learnings with `op:capture_quick` as they happen — don't
77
77
  - Forgetting to reconcile the plan after execution (drift data improves future plans)
78
78
  - Starting implementation on main/master without explicit consent
79
79
 
80
+ ## Rationalization Prevention
81
+
82
+ Do NOT rationalize away failures. If a verification step fails, the task is not complete.
83
+
84
+ - **HARD-GATE: Each task's verification must pass before marking it `completed`.**
85
+ - **HARD-GATE: Final verification (Step 6) must pass before `plan_reconcile`. Do not reconcile a failing plan.**
86
+ - Do not say "this task is basically done" when its verification has not run.
87
+ - Do not skip verification steps "to save time" -- they exist for a reason.
88
+ - Do not mark a task `completed` while its tests fail, even if the code "looks right."
89
+ - If a task is blocked or failing, leave it `in_progress` and report honestly.
90
+ - Do not treat reconciliation drift as permission to ignore failures.
91
+
80
92
  ## Quick Reference
81
93
 
82
94
  | Op | When to Use |
@@ -0,0 +1,76 @@
1
+ ---
2
+ name: finishing-a-development-branch
3
+ description: >
4
+ Use when the user says "finish branch", "merge branch", "ready to merge", "PR ready",
5
+ "close branch", "submit PR", or wants to finalize a development branch for merge into
6
+ the base branch.
7
+ ---
8
+
9
+ # Finishing a Development Branch
10
+
11
+ Pre-merge checks, PR creation, merge strategy, and branch cleanup.
12
+
13
+ **Announce at start:** "I'm using the finishing-a-development-branch skill to prepare this branch for merge."
14
+
15
+ ## Step 1: Pre-Merge Checklist
16
+
17
+ Run all checks before creating a PR. Stop on any failure.
18
+
19
+ ```bash
20
+ npm test # all tests pass
21
+ npx tsc --noEmit # typecheck clean
22
+ npm run lint # no lint errors (if configured)
23
+ ```
24
+
25
+ Verify no uncommitted changes: `git status` should be clean. Commit or stash before proceeding.
26
+
27
+ ## Step 2: Create the Pull Request
28
+
29
+ 1. Push the branch: `git push -u origin <branch>`
30
+ 2. Create PR with `gh pr create`:
31
+ - **Title**: under 70 chars, conventional format (`feat:`, `fix:`, `refactor:`)
32
+ - **Body**: summary (what + why), test plan, breaking changes if any
33
+ - **Reviewers**: add if the user specifies or the repo has CODEOWNERS
34
+ - **Labels/milestone**: add if relevant
35
+
36
+ Keep the description focused on *why* the change exists, not a file-by-file diff recap.
37
+
38
+ ## Step 3: Squash vs Merge Commit
39
+
40
+ | Signal | Strategy | Rationale |
41
+ |--------|----------|-----------|
42
+ | Many WIP/fixup commits | **Squash** | Clean history, one logical change |
43
+ | Each commit is a meaningful unit | **Merge commit** | Preserves granular history |
44
+ | Single commit on branch | Either | No difference |
45
+ | Team convention exists | **Follow it** | Consistency wins |
46
+
47
+ Default to **squash** unless the user or repo convention says otherwise.
48
+
49
+ ## Step 4: Handle Merge Conflicts
50
+
51
+ If the base branch has diverged:
52
+
53
+ 1. `git fetch origin && git rebase origin/<base>` — preferred, keeps history linear
54
+ 2. Resolve conflicts file by file, run the full checklist (Step 1) again after resolving
55
+ 3. `git rebase --continue` after each resolution
56
+ 4. If rebase is too complex, `git merge origin/<base>` is acceptable — ask the user
57
+
58
+ Never force-push a rebased branch that others are working on.
59
+
60
+ ## Step 5: Branch Cleanup
61
+
62
+ After merge is confirmed:
63
+
64
+ 1. `git checkout <base> && git pull`
65
+ 2. `git branch -d <branch>` — delete local branch
66
+ 3. If remote branch not auto-deleted: `git push origin --delete <branch>`
67
+
68
+ ## Anti-Patterns
69
+
70
+ - **Force-pushing to shared branches** — destroys others' history; only force-push personal branches
71
+ - **Merging without tests passing** — broken main is worse than a delayed merge
72
+ - **Giant PRs** — split if touching 10+ files across unrelated concerns
73
+ - **Empty PR descriptions** — reviewers need context; "fixes stuff" is not a description
74
+ - **Leaving stale branches** — delete after merge; stale branches create confusion
75
+
76
+ **Related skills:** executing-plans, verification-before-completion
@@ -90,6 +90,18 @@ Bug resolved, tests pass, root cause captured in vault. A fix without a capture
90
90
  - Skipping the capture step after fixing
91
91
  - Not running the full test suite to check regressions
92
92
 
93
+ ## Rationalization Prevention
94
+
95
+ Do NOT rationalize away failures. A fix is not done until it is proven done.
96
+
97
+ - **HARD-GATE: The original symptom must be verified as resolved (test passes, error gone) before claiming the bug is fixed.**
98
+ - **HARD-GATE: Full test suite must pass (no regressions) before completing the fix loop.**
99
+ - Do not say "the fix should work" -- reproduce the original issue and confirm it is gone.
100
+ - Do not say "this is unrelated" to dismiss a new test failure without investigation.
101
+ - Do not skip the capture step -- a fix without a vault entry is incomplete.
102
+ - If the fix introduces a new failure, the fix is not done. Do not rationalize it away.
103
+ - If you cannot verify the fix, say so. Never claim success without evidence.
104
+
93
105
  ## Quick Reference
94
106
 
95
107
  | Op | When to Use |
@@ -0,0 +1,154 @@
1
+ ---
2
+ name: mcp-doctor
3
+ description: >
4
+ Use when MCP servers fail to connect, tools are missing, or the user says "check MCP",
5
+ "MCP not working", "server not connecting", "tools missing", "heal MCP", "fix MCP",
6
+ "mcp doctor", "mcp status". Diagnoses and repairs MCP server connectivity issues.
7
+ ---
8
+
9
+ # MCP Doctor — Diagnose and Heal MCP Connections
10
+
11
+ Systematically diagnose why MCP servers are not connecting and attempt to repair them.
12
+
13
+ ## Phase 1: Inventory
14
+
15
+ Read the `.mcp.json` in the project root to get the list of configured servers.
16
+
17
+ ```bash
18
+ cat .mcp.json
19
+ ```
20
+
21
+ For each server entry, record:
22
+ - Server name
23
+ - Command (`command` field)
24
+ - Arguments (`args` field)
25
+ - Working directory (`cwd` field, defaults to `.`)
26
+ - Environment variables (`env` field, if any)
27
+
28
+ ## Phase 2: Diagnose Each Server
29
+
30
+ For each configured server, run these checks in order:
31
+
32
+ ### 2a. Binary exists?
33
+
34
+ ```bash
35
+ which <command>
36
+ # e.g. which node, which uvx, which npx
37
+ ```
38
+
39
+ If the binary is missing, report it and suggest installation.
40
+
41
+ ### 2b. Entry point exists?
42
+
43
+ For `node` commands, check the script file exists:
44
+ ```bash
45
+ ls -la <args[0]>
46
+ ```
47
+
48
+ For `npx`/`uvx` commands, check the package resolves:
49
+ ```bash
50
+ npx --yes <package> --help 2>&1 | head -5
51
+ # or
52
+ uvx --from <source> <command> --help 2>&1 | head -5
53
+ ```
54
+
55
+ ### 2c. Server starts?
56
+
57
+ Attempt to start the server with a timeout to verify it initializes:
58
+
59
+ ```bash
60
+ timeout 10 <full command> 2>&1 &
61
+ sleep 3
62
+ kill %1 2>/dev/null
63
+ ```
64
+
65
+ Look for:
66
+ - Startup success messages (e.g. "Starting MCP server", "tools loaded")
67
+ - Error messages (missing dependencies, port conflicts, config errors)
68
+ - Crash/exit codes
69
+
70
+ ### 2d. Port conflicts?
71
+
72
+ If the server binds to a port, check for conflicts:
73
+
74
+ ```bash
75
+ lsof -i :<port>
76
+ ```
77
+
78
+ If a stale process holds the port, report the PID and suggest killing it.
79
+
80
+ ### 2e. Dependencies met?
81
+
82
+ For Node.js servers, check if `node_modules` exist:
83
+ ```bash
84
+ ls <cwd>/node_modules/.package-lock.json 2>/dev/null
85
+ ```
86
+
87
+ If missing, suggest `npm install`.
88
+
89
+ For Python (uvx) servers, the virtual env is managed by uvx — check if the package installs cleanly.
90
+
91
+ ## Phase 3: Repair
92
+
93
+ For each issue found, apply the appropriate fix:
94
+
95
+ | Issue | Fix |
96
+ |-------|-----|
97
+ | Binary not found | Suggest install command |
98
+ | Entry point missing | `npm run build` or check path |
99
+ | Port conflict (stale process) | `kill <PID>` (ask user first) |
100
+ | Missing node_modules | `npm install` in the right directory |
101
+ | Config error in .mcp.json | Show the fix, apply with user approval |
102
+ | Package resolution failure | Clear cache, retry install |
103
+ | Server crashes on start | Show error log, diagnose root cause |
104
+
105
+ **IMPORTANT:** Never kill processes without user confirmation. Always show the PID and process name first.
106
+
107
+ ## Phase 4: Verify
108
+
109
+ After repairs, instruct the user:
110
+
111
+ > Repairs complete. Please restart MCP connections:
112
+ > 1. Type `/mcp` in the prompt
113
+ > 2. Toggle the repaired server(s) off and back on
114
+ > 3. Verify tools appear with a ToolSearch
115
+
116
+ Note: Claude Code does not support programmatic MCP restarts. The user must use `/mcp` to reconnect.
117
+
118
+ ## Phase 5: Report
119
+
120
+ Present findings as a table:
121
+
122
+ ```
123
+ ## MCP Doctor Report
124
+
125
+ | Server | Binary | Entry Point | Starts | Port | Status |
126
+ |--------|--------|-------------|--------|------|--------|
127
+ | soleri | node OK | dist/index.js OK | OK | — | Healthy |
128
+ | serena | uvx OK | git+... OK | OK | 24285 OK | Healthy |
129
+
130
+ ### Issues Found
131
+ | Server | Issue | Fix Applied |
132
+ |--------|-------|-------------|
133
+ | serena | Stale process on :24285 | Killed PID 1234 |
134
+
135
+ ### Action Required
136
+ - [ ] Run `/mcp` and reconnect repaired servers
137
+ ```
138
+
139
+ ## Common Issues
140
+
141
+ - **uvx servers**: Often fail due to network issues when pulling from git. Check connectivity.
142
+ - **Node servers**: Often fail because `dist/` hasn't been built. Run the build command.
143
+ - **Port conflicts**: Previous server instances that didn't shut down cleanly. Kill and restart.
144
+ - **cwd issues**: Relative `cwd: "."` resolves from where Claude Code launched, not the .mcp.json location.
145
+
146
+ ## Quick Reference
147
+
148
+ | Check | Command | What it tells you |
149
+ |-------|---------|-------------------|
150
+ | Binary exists | `which <cmd>` | Is the runtime installed? |
151
+ | Script exists | `ls <path>` | Is the entry point built? |
152
+ | Port free | `lsof -i :<port>` | Is something blocking the port? |
153
+ | Deps installed | `ls node_modules` | Are npm packages present? |
154
+ | Server starts | `timeout 10 <cmd>` | Does initialization succeed? |