@pharaoh-so/mcp 0.3.26 → 0.3.28
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/commands/plan.md +13 -5
- package/commands/review.md +4 -2
- package/commands/vision.md +184 -0
- package/inspect-tools.json +164 -138
- package/package.json +1 -1
- package/skills/pharaoh/SKILL.md +12 -1
- package/skills/plan/SKILL.md +13 -5
- package/skills/review/SKILL.md +4 -2
- package/skills/vision/SKILL.md +185 -0
package/commands/plan.md
CHANGED
|
@@ -39,11 +39,12 @@ Do NOT review from memory or assumptions. Query the actual codebase first.
|
|
|
39
39
|
### If Pharaoh MCP tools are available:
|
|
40
40
|
|
|
41
41
|
1. `get_codebase_map` — current modules, hot files, dependency graph
|
|
42
|
-
2. `
|
|
43
|
-
3. `
|
|
44
|
-
4. `
|
|
45
|
-
5. `
|
|
46
|
-
6. `
|
|
42
|
+
2. `get_vision_docs` — read the repo's architectural contract. If the plan touches a domain with a MUST-bullet, the assertion is a hard constraint on the plan. Raise it explicitly in Section 1. If `get_vision_docs` returns an empty-state scaffold, flag that the repo needs `/pharaoh:vision` before planning anything architectural.
|
|
43
|
+
3. `search_functions` for keywords related to the plan — find existing code to reuse/extend
|
|
44
|
+
4. `get_module_context` on affected modules — entry points, patterns, conventions
|
|
45
|
+
5. `query_dependencies` between affected modules — coupling, circular deps
|
|
46
|
+
6. `get_blast_radius` on the primary target of the change — know what breaks
|
|
47
|
+
7. `check_reachability` on the primary target — verify it's actually reachable from entry points before worrying about it
|
|
47
48
|
|
|
48
49
|
### Without Pharaoh (graceful fallback):
|
|
49
50
|
|
|
@@ -71,10 +72,17 @@ Adapt depth to change size. Skip sections that don't apply. **After each section
|
|
|
71
72
|
|
|
72
73
|
### Section 1 — Architecture (skip for small/single-file changes)
|
|
73
74
|
|
|
75
|
+
- **Vision alignment (check FIRST).** Does this plan touch a domain
|
|
76
|
+
governed by a MUST-bullet in `docs/VISION.md`? If yes, quote the
|
|
77
|
+
assertion and verify the plan doesn't violate it. If the plan would
|
|
78
|
+
violate a MUST, STOP and raise with the user — either the plan changes
|
|
79
|
+
or VISION.md needs an update first (with user approval).
|
|
74
80
|
- Component boundaries and coupling concerns
|
|
75
81
|
- Dependency graph: does this change shrink or expand surface area?
|
|
76
82
|
- Data flow bottlenecks and single points of failure
|
|
77
83
|
- Does this need new code at all, or can a human process / existing pattern solve it?
|
|
84
|
+
- **If this plan introduces a new invariant**, call it out and include a
|
|
85
|
+
step in Section 6 to add a `### assertion` to VISION.md with a pairing TEST.
|
|
78
86
|
|
|
79
87
|
### Section 2 — Code Quality (always)
|
|
80
88
|
|
package/commands/review.md
CHANGED
|
@@ -65,7 +65,8 @@ Then call these additional tools for data recon doesn't cover:
|
|
|
65
65
|
- `get_regression_risk` — overall change risk score for the repo
|
|
66
66
|
- `get_consolidation_opportunities` — duplicate logic the PR may introduce
|
|
67
67
|
- `check_reachability` — are new exports wired to entry points?
|
|
68
|
-
- `
|
|
68
|
+
- `get_vision_docs` — read the repo's architectural contract. For every touched module, pull its relevant assertions. Any change touching code governed by a MUST-bullet must be checked against that assertion — if the change would violate the MUST, the verdict tips toward BLOCK unless VISION.md is updated in the same PR with user approval.
|
|
69
|
+
- `get_vision_gaps` — do changes align with or drift from specs? New complex functions without a matching assertion are flagged; retired specs with implementing code are flagged.
|
|
69
70
|
|
|
70
71
|
**Output of Phase 1:** Architecture map, module profiles for every touched module, blast radius for high-risk changes, dependency paths between coupled modules, regression risk level, duplication findings, reachability status, and spec alignment.
|
|
71
72
|
|
|
@@ -249,7 +250,8 @@ If none of these triggers are met, **skip Phase 3** and proceed to Phase 4.
|
|
|
249
250
|
- Unreachable exports (new public code with zero callers)
|
|
250
251
|
- New circular dependencies between modules
|
|
251
252
|
- HIGH regression risk without corresponding test coverage
|
|
252
|
-
-
|
|
253
|
+
- **A MUST-bullet in `docs/VISION.md` is violated by this change** (without VISION.md being updated in the same PR with user approval)
|
|
254
|
+
- Vision spec drift: new complex function has no matching assertion AND the domain it lives in has existing assertions (implies invariants are expected here)
|
|
253
255
|
- Any CRITICAL finding from Phase 2 or Phase 3 that is confirmed and unfixed
|
|
254
256
|
- DISAGREE verdict from adversarial review on security-sensitive code, confirmed after verification
|
|
255
257
|
- Unanchored Cypher query (MATCH without traversing through `Repo {name: $repo}`)
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Draft a VISION.md for this repo by filling a graph-derived scaffold
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Vision Drafting
|
|
6
|
+
|
|
7
|
+
Author a VISION.md that captures this repo's invariants — what must always be
|
|
8
|
+
true about its behavior. The file becomes a machine-readable contract that
|
|
9
|
+
Pharaoh's linter, PR Guard, and MCP tools reason against on every change.
|
|
10
|
+
|
|
11
|
+
## Why this matters (explain this to the user before drafting)
|
|
12
|
+
|
|
13
|
+
A VISION.md is leverage, not paperwork. Once the repo has one:
|
|
14
|
+
|
|
15
|
+
- **PR Guard** checks every pull request against its assertions. Changes that
|
|
16
|
+
contradict a MUST-bullet surface as a Check on the PR — the team sees drift
|
|
17
|
+
from intent at the exact moment it happens, not months later.
|
|
18
|
+
- **`get_vision_gaps`** becomes useful. Pharaoh cross-references every spec
|
|
19
|
+
against the function graph and surfaces both sides of the drift: specs
|
|
20
|
+
without implementing code (dead intent) and complex functions with no spec
|
|
21
|
+
(invisible invariants).
|
|
22
|
+
- **`get_vision_docs`** returns spec-to-code traceability. Each assertion
|
|
23
|
+
shows the functions that implement it — a direct map from intent → code.
|
|
24
|
+
- **CI enforces it.** Every MUST bullet pairs with a TEST reference. The
|
|
25
|
+
linter fails when an assertion has no enforcing test. No more wishlist
|
|
26
|
+
specs that drift over time.
|
|
27
|
+
|
|
28
|
+
Without a VISION.md, the tools above return empty. The graph sees code; it
|
|
29
|
+
doesn't see intent. The file is the bridge.
|
|
30
|
+
|
|
31
|
+
## When to Use
|
|
32
|
+
|
|
33
|
+
- The repo has no `docs/VISION.md` yet and the user wants Pharaoh's full
|
|
34
|
+
value — PR Guard, vision-gaps, spec traceability all depend on the file.
|
|
35
|
+
- `get_vision_docs` returned the "No VISION.md yet" onboarding response.
|
|
36
|
+
- The user said "draft a vision doc", "add a VISION.md", or "scaffold vision".
|
|
37
|
+
- A user is new to Pharaoh and asking what they should do next.
|
|
38
|
+
|
|
39
|
+
## The flow — collaborative, not solo
|
|
40
|
+
|
|
41
|
+
This is a short working session with the user. Do not solo-fill the scaffold
|
|
42
|
+
— the graph can tell you the shape of the code, but only the user knows what
|
|
43
|
+
must not break. Ask questions, propose, let them steer.
|
|
44
|
+
|
|
45
|
+
1. **Get the scaffold.** Call `get_vision_docs` with the repo name. When no
|
|
46
|
+
vision doc exists, the tool returns a deterministic scaffold plus the
|
|
47
|
+
agent directive. Use that as your starting structure. Never invent a
|
|
48
|
+
scaffold from scratch; the archetypes encode Pharaoh's framework shape
|
|
49
|
+
and drift is surfaced by the framework-linter.
|
|
50
|
+
|
|
51
|
+
2. **Interview the user.** Before filling anything, ask: *"What are the 3-5
|
|
52
|
+
things about this repo that must not break, no matter what?"* Their
|
|
53
|
+
answer drives the assertions. If they can't articulate it, probe with
|
|
54
|
+
follow-ups — "what would a P0 incident look like here?", "what would
|
|
55
|
+
wake you up on a weekend?". The goal is to extract real invariants, not
|
|
56
|
+
to generate plausible-sounding ones from graph evidence.
|
|
57
|
+
|
|
58
|
+
3. **Ground each domain in real code.** For every `## Domain` the scaffold
|
|
59
|
+
rendered, call `get_module_context` for the module(s) that back that
|
|
60
|
+
domain. For example, an "Authentication and Authorization" domain →
|
|
61
|
+
`get_module_context` on the auth module + any session/token modules.
|
|
62
|
+
Read the exported functions, endpoints, env vars, and DB access.
|
|
63
|
+
|
|
64
|
+
4. **Replace TODOs with WHAT statements.**
|
|
65
|
+
- Every `### TODO:` heading becomes a real assertion title. Describe the
|
|
66
|
+
invariant in plain language — "Sessions expire after 30 minutes of
|
|
67
|
+
inactivity", not "checkSession() returns null after timeout".
|
|
68
|
+
- Every `- MUST: TODO —` bullet becomes a WHAT statement. Banned
|
|
69
|
+
content: function names, file paths, class names, identifiers.
|
|
70
|
+
- Add a `- TEST: path/to/test.ts` line for every assertion. If the test
|
|
71
|
+
doesn't exist yet, write it before committing. A MUST without a TEST
|
|
72
|
+
is not an invariant, it's a wish.
|
|
73
|
+
|
|
74
|
+
5. **Trim irrelevant domains.** If a rendered `## Domain` doesn't match
|
|
75
|
+
anything real in this repo, delete that whole section. The scaffold is a
|
|
76
|
+
starting point, not a contract to honor exhaustively.
|
|
77
|
+
|
|
78
|
+
6. **Write the file.** Save to `docs/VISION.md` in the repo. Remove the
|
|
79
|
+
`<!-- scaffold-generated -->` marker and the `<!-- AGENT DIRECTIVE -->`
|
|
80
|
+
block once every TODO is resolved.
|
|
81
|
+
|
|
82
|
+
7. **Wire it into CLAUDE.md.** This is non-negotiable — it's what turns the
|
|
83
|
+
vision doc from a file on disk into a contract future sessions respect.
|
|
84
|
+
If `CLAUDE.md` exists at the repo root, append (or edit) a section:
|
|
85
|
+
|
|
86
|
+
```markdown
|
|
87
|
+
## Vision docs
|
|
88
|
+
|
|
89
|
+
`docs/VISION.md` is this repo's architectural contract. Before any
|
|
90
|
+
non-trivial change, call `get_vision_docs` to read the relevant
|
|
91
|
+
assertions. After any large refactor, run `get_vision_gaps` to surface
|
|
92
|
+
drift between intent and implementation. When adding a new invariant,
|
|
93
|
+
open `docs/VISION.md`, add a `### assertion` under the right `##` domain,
|
|
94
|
+
and pair every `- MUST:` with a `- TEST:` referencing the enforcing test.
|
|
95
|
+
|
|
96
|
+
Never introduce code that would violate a MUST-bullet without first
|
|
97
|
+
updating `docs/VISION.md` (with the user's approval).
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
If no `CLAUDE.md` exists, create a minimal one with the section above
|
|
101
|
+
plus any project-specific instructions you already have context for.
|
|
102
|
+
|
|
103
|
+
8. **Verify.** Run `pharaoh vision lint --framework` (or instruct the user
|
|
104
|
+
to). Zero errors. Zero TODO warnings. Zero unresolved placeholders.
|
|
105
|
+
|
|
106
|
+
## Hard rules
|
|
107
|
+
|
|
108
|
+
- **No HOW in MUST bullets.** Banned: function names, file paths, camelCase
|
|
109
|
+
identifiers, backtick-wrapped code. The linter enforces this as a warning;
|
|
110
|
+
treat it as a hard rule.
|
|
111
|
+
- **Every MUST needs a TEST.** The format-linter errors if a MUST bullet
|
|
112
|
+
has no matching TEST reference to an existing file.
|
|
113
|
+
- **One MUST per line.** Don't pack multiple invariants into a single bullet.
|
|
114
|
+
- **Max 10 prose lines per assertion.** Keep each `###` section tight.
|
|
115
|
+
- **Mirror Pharaoh's canonical domains when they fit.** Rename only when the
|
|
116
|
+
user's project truly has a different shape. The framework-linter warns on
|
|
117
|
+
unrecognized domains so drift is visible.
|
|
118
|
+
|
|
119
|
+
## What to avoid
|
|
120
|
+
|
|
121
|
+
- **Do NOT** write VISION.md from scratch without calling `get_vision_docs`
|
|
122
|
+
first — you'll miss domains the graph detected and duplicate ones it
|
|
123
|
+
already included.
|
|
124
|
+
- **Do NOT** carry forward the AGENT DIRECTIVE or scaffold-generated marker
|
|
125
|
+
into the committed file. Those are drafting aids, not document content.
|
|
126
|
+
- **Do NOT** write speculative assertions ("sessions will expire someday").
|
|
127
|
+
Only assert what the code enforces today or what you'll commit a test for.
|
|
128
|
+
- **Do NOT** use `pharaoh vision init` — that only drops the format guide,
|
|
129
|
+
not a graph-grounded scaffold. Always go through `get_vision_docs`.
|
|
130
|
+
|
|
131
|
+
## Completion checklist
|
|
132
|
+
|
|
133
|
+
- [ ] User was interviewed for their real invariants (not graph-guessed)
|
|
134
|
+
- [ ] Every rendered `## Domain` either has ≥1 real assertion or was deleted
|
|
135
|
+
- [ ] Every `### TODO:` heading replaced with a real title
|
|
136
|
+
- [ ] Every `- MUST: TODO —` replaced with a WHAT statement
|
|
137
|
+
- [ ] Every assertion has a `- TEST:` line pointing at an existing test file
|
|
138
|
+
- [ ] Scaffold marker + AGENT DIRECTIVE block removed
|
|
139
|
+
- [ ] `CLAUDE.md` updated (or created) with the Vision docs section
|
|
140
|
+
- [ ] `pharaoh vision lint --framework` exits clean
|
|
141
|
+
|
|
142
|
+
## After it ships — tell the user what they unlocked
|
|
143
|
+
|
|
144
|
+
Once `docs/VISION.md` is committed, call out the new capabilities concretely:
|
|
145
|
+
|
|
146
|
+
1. **Every future AI session reads it.** Because CLAUDE.md now references
|
|
147
|
+
`docs/VISION.md`, any agent working in this repo (Claude Code, Cursor,
|
|
148
|
+
anyone else connecting Pharaoh) will consult the file before touching
|
|
149
|
+
architecture. Continuity across sessions, across people, across tools.
|
|
150
|
+
2. **`get_vision_docs`** now returns spec-to-code traceability per
|
|
151
|
+
assertion. The user can see which functions implement each invariant.
|
|
152
|
+
3. **`get_vision_gaps`** surfaces drift. Unspecified complex functions
|
|
153
|
+
get flagged; specs with no implementing code get flagged for review
|
|
154
|
+
(either write the code or retire the spec).
|
|
155
|
+
4. **Their next PR is checked.** PR Guard now evaluates touched code
|
|
156
|
+
against relevant assertions. First-time use often catches real drift.
|
|
157
|
+
5. **`/pharaoh:plan`** will surface relevant assertions during reconnaissance.
|
|
158
|
+
6. **`/pharaoh:review`** will flag PRs that touch code governed by a MUST.
|
|
159
|
+
|
|
160
|
+
The bigger payoff: architectural invariants are now enforced in CI the same
|
|
161
|
+
way unit tests enforce behavior. Intent and implementation stop drifting.
|
|
162
|
+
|
|
163
|
+
## Ongoing maintenance — it's a living file
|
|
164
|
+
|
|
165
|
+
VISION.md rots if it's not maintained. Part of your job in future sessions
|
|
166
|
+
(even ones that aren't about vision directly) is to keep it current:
|
|
167
|
+
|
|
168
|
+
- **When a MUST changes**, update VISION.md in the same PR as the code
|
|
169
|
+
change. Don't let the file lag — stale assertions are worse than none.
|
|
170
|
+
- **When a new architectural decision lands**, add a new `###` assertion
|
|
171
|
+
under the right `##` domain with a pairing TEST. One assertion per
|
|
172
|
+
decision, not batches.
|
|
173
|
+
- **When an assertion stops being load-bearing**, delete it. Retirement is
|
|
174
|
+
as important as addition.
|
|
175
|
+
- **When `get_vision_gaps` shows >5 unimplemented specs**, the doc has
|
|
176
|
+
drifted into wishlist territory. Prune.
|
|
177
|
+
- **Quarterly**: run `pharaoh vision lint --framework` and address warnings.
|
|
178
|
+
|
|
179
|
+
Format reference: https://pharaoh.so/vision-format.md
|
|
180
|
+
---
|
|
181
|
+
|
|
182
|
+
Here is any additional context for the vision draft:
|
|
183
|
+
|
|
184
|
+
$ARGUMENTS
|
package/inspect-tools.json
CHANGED
|
@@ -155,8 +155,8 @@
|
|
|
155
155
|
}
|
|
156
156
|
},
|
|
157
157
|
{
|
|
158
|
-
"name": "
|
|
159
|
-
"description": "Check
|
|
158
|
+
"name": "get_blast_radius",
|
|
159
|
+
"description": "Check what breaks BEFORE refactoring, renaming, or deleting a function, file, or module.\n\nCALL THIS WHEN:\n• You're about to refactor or rename a function — see every caller that needs updating\n• You want to know if a change is safe — check if anything depends on this code\n• A PR modifies a shared utility — trace all downstream consumers\n• You need to assess risk level before a change (LOW/MEDIUM/HIGH)\n\nRETURNS: Risk assessment (LOW/MEDIUM/HIGH), all affected callers grouped by module with file paths, impacted HTTP endpoints, impacted cron jobs, and affected DB operations. Traces up to 5 hops deep through the call graph.\n\nEXAMPLES:\n• \"What breaks if I change the formatMessage function?\"\n• \"How many callers does this utility have across the codebase?\"\n• \"Is it safe to delete this file or do other modules use it?\"\n• \"Which API endpoints are affected if I modify the db module?\"\n\nWHY NOT JUST READ FILES: You can grep for direct callers, but you'll miss indirect callers 2-3 hops away, and you won't see affected endpoints or cron jobs. This traces the full transitive dependency chain automatically.",
|
|
160
160
|
"inputSchema": {
|
|
161
161
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
162
162
|
"type": "object",
|
|
@@ -165,39 +165,72 @@
|
|
|
165
165
|
"type": "string",
|
|
166
166
|
"description": "Repository name. Works with your connected repos or any public open source repo by GitHub slug (e.g., 'vercel/next.js')."
|
|
167
167
|
},
|
|
168
|
-
"
|
|
168
|
+
"entity": {
|
|
169
169
|
"type": "string",
|
|
170
|
-
"
|
|
171
|
-
|
|
170
|
+
"description": "Function name, file path, or module name"
|
|
171
|
+
},
|
|
172
|
+
"entity_type": {
|
|
173
|
+
"type": "string",
|
|
174
|
+
"enum": [
|
|
175
|
+
"function",
|
|
176
|
+
"file",
|
|
177
|
+
"module"
|
|
178
|
+
],
|
|
179
|
+
"description": "Type of entity"
|
|
180
|
+
},
|
|
181
|
+
"depth": {
|
|
182
|
+
"description": "How many hops to trace (default: 3, max: 5)",
|
|
183
|
+
"type": "number"
|
|
184
|
+
}
|
|
185
|
+
},
|
|
186
|
+
"required": [
|
|
187
|
+
"repo",
|
|
188
|
+
"entity",
|
|
189
|
+
"entity_type"
|
|
190
|
+
]
|
|
191
|
+
},
|
|
192
|
+
"annotations": {
|
|
193
|
+
"title": "Change Blast Radius",
|
|
194
|
+
"readOnlyHint": true,
|
|
195
|
+
"destructiveHint": false
|
|
196
|
+
},
|
|
197
|
+
"execution": {
|
|
198
|
+
"taskSupport": "forbidden"
|
|
199
|
+
}
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
"name": "check_reachability",
|
|
203
|
+
"description": "Check if functions are reachable from production entry points (API endpoints, CLI commands, cron jobs, event handlers, MCP tools).\n\nCALL THIS WHEN:\n• After implementing a feature — verify new code is wired into the app\n• Reviewing a PR — are all new functions actually reachable?\n• Cleaning up dead code — find functions only called by tests\n• Before opening a PR — run this as a pre-flight check\n\nRETURNS: For each exported function, whether it's reachable from a production entry point,\nthe path from entry point to function, and classification (entry_point / reachable / unreachable).\n\nTIER: Pharaoh Pro — free tier receives a preview. Summarize what the preview reveals, explain what full data would show for this task, then include the upgrade link.",
|
|
204
|
+
"inputSchema": {
|
|
205
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
206
|
+
"type": "object",
|
|
207
|
+
"properties": {
|
|
208
|
+
"repo": {
|
|
209
|
+
"type": "string",
|
|
210
|
+
"description": "Repository name. Works with your connected repos or any public open source repo by GitHub slug (e.g., 'vercel/next.js')."
|
|
211
|
+
},
|
|
212
|
+
"functions": {
|
|
213
|
+
"description": "Function names to check (checks all exported if omitted)",
|
|
214
|
+
"type": "array",
|
|
215
|
+
"items": {
|
|
216
|
+
"type": "string"
|
|
217
|
+
}
|
|
172
218
|
},
|
|
173
219
|
"module": {
|
|
174
220
|
"description": "Filter to a specific module",
|
|
175
221
|
"type": "string"
|
|
176
222
|
},
|
|
177
|
-
"
|
|
178
|
-
"description": "
|
|
179
|
-
"type": "string"
|
|
180
|
-
},
|
|
181
|
-
"exported_only": {
|
|
182
|
-
"description": "Only show exported functions (default: false)",
|
|
223
|
+
"include_paths": {
|
|
224
|
+
"description": "Include full reachability paths (default: false)",
|
|
183
225
|
"type": "boolean"
|
|
184
|
-
},
|
|
185
|
-
"offset": {
|
|
186
|
-
"description": "Skip first N results for pagination (default: 0)",
|
|
187
|
-
"type": "number"
|
|
188
|
-
},
|
|
189
|
-
"limit": {
|
|
190
|
-
"description": "Max results to return (default: 20, max: 50)",
|
|
191
|
-
"type": "number"
|
|
192
226
|
}
|
|
193
227
|
},
|
|
194
228
|
"required": [
|
|
195
|
-
"repo"
|
|
196
|
-
"query"
|
|
229
|
+
"repo"
|
|
197
230
|
]
|
|
198
231
|
},
|
|
199
232
|
"annotations": {
|
|
200
|
-
"title": "
|
|
233
|
+
"title": "Reachability Check",
|
|
201
234
|
"readOnlyHint": true,
|
|
202
235
|
"destructiveHint": false
|
|
203
236
|
},
|
|
@@ -206,8 +239,8 @@
|
|
|
206
239
|
}
|
|
207
240
|
},
|
|
208
241
|
{
|
|
209
|
-
"name": "
|
|
210
|
-
"description": "
|
|
242
|
+
"name": "get_vision_docs",
|
|
243
|
+
"description": "Get the documented intent — CLAUDE.md files, PRDs, roadmaps, skill specs — to understand WHY code exists, not just what it does.\n\nCALL THIS WHEN:\n• You're implementing a feature and need to check if a PRD or spec exists for it\n• You want to understand the original design intent behind existing code\n• You need to verify your implementation matches documented requirements\n• You're reviewing code and want to check it against the documented vision\n\nRETURNS: All vision documents grouped by type (claude_md, prd, skill, roadmap), with each spec's title, section ID, and implementation status showing which functions implement each spec.\n\nEXAMPLES:\n• \"Is there a PRD for the notification system?\"\n• \"What does the CLAUDE.md say about the auth module?\"\n• \"What specs exist for the slack integration?\"\n• \"Which specs are already implemented vs still pending?\"\n\nWHY NOT JUST READ FILES: Vision docs are scattered across CLAUDE.md files, PRDs, and roadmaps in different directories. This aggregates them all AND cross-references against actual implementations so you can see spec-to-code alignment in one call.\n\nTIER: Pharaoh Pro — free tier receives a preview. Summarize what the preview reveals, explain what full data would show for this task, then include the upgrade link.",
|
|
211
244
|
"inputSchema": {
|
|
212
245
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
213
246
|
"type": "object",
|
|
@@ -216,21 +249,20 @@
|
|
|
216
249
|
"type": "string",
|
|
217
250
|
"description": "Repository name"
|
|
218
251
|
},
|
|
219
|
-
"
|
|
220
|
-
"
|
|
221
|
-
"
|
|
252
|
+
"module": {
|
|
253
|
+
"description": "Filter to specs related to this module",
|
|
254
|
+
"type": "string"
|
|
255
|
+
},
|
|
256
|
+
"doc_type": {
|
|
257
|
+
"description": "Filter by document type",
|
|
222
258
|
"type": "string",
|
|
223
259
|
"enum": [
|
|
224
|
-
"
|
|
225
|
-
"
|
|
226
|
-
"
|
|
260
|
+
"claude_md",
|
|
261
|
+
"prd",
|
|
262
|
+
"skill",
|
|
263
|
+
"roadmap",
|
|
227
264
|
"all"
|
|
228
265
|
]
|
|
229
|
-
},
|
|
230
|
-
"include_screens": {
|
|
231
|
-
"default": false,
|
|
232
|
-
"description": "Include screen/page components (*Screen, *Page, *View, *Route) that are typically app-level consumers, not reusable primitives",
|
|
233
|
-
"type": "boolean"
|
|
234
266
|
}
|
|
235
267
|
},
|
|
236
268
|
"required": [
|
|
@@ -238,7 +270,7 @@
|
|
|
238
270
|
]
|
|
239
271
|
},
|
|
240
272
|
"annotations": {
|
|
241
|
-
"title": "
|
|
273
|
+
"title": "Vision Documents",
|
|
242
274
|
"readOnlyHint": true,
|
|
243
275
|
"destructiveHint": false
|
|
244
276
|
},
|
|
@@ -247,42 +279,31 @@
|
|
|
247
279
|
}
|
|
248
280
|
},
|
|
249
281
|
{
|
|
250
|
-
"name": "
|
|
251
|
-
"description": "
|
|
282
|
+
"name": "get_vision_gaps",
|
|
283
|
+
"description": "Find what's missing — specs without code AND complex code without specs. Call this to prioritize what to build or document next.\n\nCALL THIS WHEN:\n• You're planning work and need to find unimplemented features from PRDs\n• You want to find complex undocumented functions that need specs or tests\n• You need to audit spec-to-code alignment for a module\n• Someone asks \"what's left to build?\" or \"what's undocumented?\"\n\nRETURNS: Two lists — (1) specified-but-not-built: PRD specs with no implementing functions, and (2) built-but-not-specified: complex functions above a threshold with no vision spec. Includes function names, complexity scores, file paths, and spec references.\n\nEXAMPLES:\n• \"What features from the PRDs haven't been built yet?\"\n• \"Which complex functions lack documentation?\"\n• \"What's the spec coverage for the auth module?\"\n• \"Are there any orphaned specs or undocumented behaviors?\"\n\nWHY NOT JUST READ FILES: Manually diffing PRD bullets against code is error-prone and misses complexity metrics. This cross-references the entire spec tree against the function graph automatically — gaps that would take an hour to find manually surface in seconds.\n\nTIER: Pharaoh Pro — free tier receives a preview. Summarize what the preview reveals, explain what full data would show for this task, then include the upgrade link.",
|
|
252
284
|
"inputSchema": {
|
|
253
285
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
254
286
|
"type": "object",
|
|
255
287
|
"properties": {
|
|
256
288
|
"repo": {
|
|
257
289
|
"type": "string",
|
|
258
|
-
"description": "Repository name
|
|
259
|
-
},
|
|
260
|
-
"entity": {
|
|
261
|
-
"type": "string",
|
|
262
|
-
"description": "Function name, file path, or module name"
|
|
290
|
+
"description": "Repository name"
|
|
263
291
|
},
|
|
264
|
-
"
|
|
265
|
-
"
|
|
266
|
-
"
|
|
267
|
-
"function",
|
|
268
|
-
"file",
|
|
269
|
-
"module"
|
|
270
|
-
],
|
|
271
|
-
"description": "Type of entity"
|
|
292
|
+
"module": {
|
|
293
|
+
"description": "Filter to a specific module",
|
|
294
|
+
"type": "string"
|
|
272
295
|
},
|
|
273
|
-
"
|
|
274
|
-
"description": "
|
|
296
|
+
"complexity_threshold": {
|
|
297
|
+
"description": "Min complexity for undocumented function flag (default: 15)",
|
|
275
298
|
"type": "number"
|
|
276
299
|
}
|
|
277
300
|
},
|
|
278
301
|
"required": [
|
|
279
|
-
"repo"
|
|
280
|
-
"entity",
|
|
281
|
-
"entity_type"
|
|
302
|
+
"repo"
|
|
282
303
|
]
|
|
283
304
|
},
|
|
284
305
|
"annotations": {
|
|
285
|
-
"title": "
|
|
306
|
+
"title": "Vision Gap Analysis",
|
|
286
307
|
"readOnlyHint": true,
|
|
287
308
|
"destructiveHint": false
|
|
288
309
|
},
|
|
@@ -364,8 +385,8 @@
|
|
|
364
385
|
}
|
|
365
386
|
},
|
|
366
387
|
{
|
|
367
|
-
"name": "
|
|
368
|
-
"description": "Check if
|
|
388
|
+
"name": "search_functions",
|
|
389
|
+
"description": "Check if functionality already exists BEFORE writing any new function, utility, or helper.\n\nCALL THIS WHEN:\n• You're about to create a new function — search first to prevent duplicates\n• You need to find where a concept is implemented (e.g., 'notify', 'validate', 'parse')\n• You're looking for the right function to import instead of reimplementing\n• A task says 'add X functionality' — verify X doesn't already exist\n\nRETURNS: Matching functions with file paths, line numbers, module, export status, async flag, complexity scores, and full signatures. Searches all functions across the entire codebase.\n\nEXAMPLES:\n• \"Is there already a function that sends Slack notifications?\"\n• \"What validation utilities exist?\"\n• \"Where is email formatting handled?\"\n• \"Does a retry wrapper already exist somewhere?\"\n\nWHY NOT JUST READ FILES: grep only finds exact string matches and misses re-exports, aliases, and barrel-file indirection. This searches the full resolved dependency graph — if it exists anywhere in the codebase, this finds it.",
|
|
369
390
|
"inputSchema": {
|
|
370
391
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
371
392
|
"type": "object",
|
|
@@ -374,101 +395,39 @@
|
|
|
374
395
|
"type": "string",
|
|
375
396
|
"description": "Repository name. Works with your connected repos or any public open source repo by GitHub slug (e.g., 'vercel/next.js')."
|
|
376
397
|
},
|
|
377
|
-
"
|
|
378
|
-
"
|
|
379
|
-
"
|
|
380
|
-
"
|
|
381
|
-
"type": "string"
|
|
382
|
-
}
|
|
398
|
+
"query": {
|
|
399
|
+
"type": "string",
|
|
400
|
+
"maxLength": 500,
|
|
401
|
+
"description": "Function name or partial match (e.g., \"notify\", \"fetch\", \"transform\")"
|
|
383
402
|
},
|
|
384
403
|
"module": {
|
|
385
404
|
"description": "Filter to a specific module",
|
|
386
405
|
"type": "string"
|
|
387
406
|
},
|
|
388
|
-
"
|
|
389
|
-
"description": "
|
|
390
|
-
"type": "boolean"
|
|
391
|
-
}
|
|
392
|
-
},
|
|
393
|
-
"required": [
|
|
394
|
-
"repo"
|
|
395
|
-
]
|
|
396
|
-
},
|
|
397
|
-
"annotations": {
|
|
398
|
-
"title": "Reachability Check",
|
|
399
|
-
"readOnlyHint": true,
|
|
400
|
-
"destructiveHint": false
|
|
401
|
-
},
|
|
402
|
-
"execution": {
|
|
403
|
-
"taskSupport": "forbidden"
|
|
404
|
-
}
|
|
405
|
-
},
|
|
406
|
-
{
|
|
407
|
-
"name": "get_vision_docs",
|
|
408
|
-
"description": "Get the documented intent — CLAUDE.md files, PRDs, roadmaps, skill specs — to understand WHY code exists, not just what it does.\n\nCALL THIS WHEN:\n• You're implementing a feature and need to check if a PRD or spec exists for it\n• You want to understand the original design intent behind existing code\n• You need to verify your implementation matches documented requirements\n• You're reviewing code and want to check it against the documented vision\n\nRETURNS: All vision documents grouped by type (claude_md, prd, skill, roadmap), with each spec's title, section ID, and implementation status showing which functions implement each spec.\n\nEXAMPLES:\n• \"Is there a PRD for the notification system?\"\n• \"What does the CLAUDE.md say about the auth module?\"\n• \"What specs exist for the slack integration?\"\n• \"Which specs are already implemented vs still pending?\"\n\nWHY NOT JUST READ FILES: Vision docs are scattered across CLAUDE.md files, PRDs, and roadmaps in different directories. This aggregates them all AND cross-references against actual implementations so you can see spec-to-code alignment in one call.\n\nTIER: Pharaoh Pro — free tier receives a preview. Summarize what the preview reveals, explain what full data would show for this task, then include the upgrade link.",
|
|
409
|
-
"inputSchema": {
|
|
410
|
-
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
411
|
-
"type": "object",
|
|
412
|
-
"properties": {
|
|
413
|
-
"repo": {
|
|
414
|
-
"type": "string",
|
|
415
|
-
"description": "Repository name"
|
|
416
|
-
},
|
|
417
|
-
"module": {
|
|
418
|
-
"description": "Filter to specs related to this module",
|
|
407
|
+
"file": {
|
|
408
|
+
"description": "Filter to functions in a specific file (full path for exact match, filename for substring match)",
|
|
419
409
|
"type": "string"
|
|
420
410
|
},
|
|
421
|
-
"
|
|
422
|
-
"description": "
|
|
423
|
-
"type": "
|
|
424
|
-
"enum": [
|
|
425
|
-
"claude_md",
|
|
426
|
-
"prd",
|
|
427
|
-
"skill",
|
|
428
|
-
"roadmap",
|
|
429
|
-
"all"
|
|
430
|
-
]
|
|
431
|
-
}
|
|
432
|
-
},
|
|
433
|
-
"required": [
|
|
434
|
-
"repo"
|
|
435
|
-
]
|
|
436
|
-
},
|
|
437
|
-
"annotations": {
|
|
438
|
-
"title": "Vision Documents",
|
|
439
|
-
"readOnlyHint": true,
|
|
440
|
-
"destructiveHint": false
|
|
441
|
-
},
|
|
442
|
-
"execution": {
|
|
443
|
-
"taskSupport": "forbidden"
|
|
444
|
-
}
|
|
445
|
-
},
|
|
446
|
-
{
|
|
447
|
-
"name": "get_vision_gaps",
|
|
448
|
-
"description": "Find what's missing — specs without code AND complex code without specs. Call this to prioritize what to build or document next.\n\nCALL THIS WHEN:\n• You're planning work and need to find unimplemented features from PRDs\n• You want to find complex undocumented functions that need specs or tests\n• You need to audit spec-to-code alignment for a module\n• Someone asks \"what's left to build?\" or \"what's undocumented?\"\n\nRETURNS: Two lists — (1) specified-but-not-built: PRD specs with no implementing functions, and (2) built-but-not-specified: complex functions above a threshold with no vision spec. Includes function names, complexity scores, file paths, and spec references.\n\nEXAMPLES:\n• \"What features from the PRDs haven't been built yet?\"\n• \"Which complex functions lack documentation?\"\n• \"What's the spec coverage for the auth module?\"\n• \"Are there any orphaned specs or undocumented behaviors?\"\n\nWHY NOT JUST READ FILES: Manually diffing PRD bullets against code is error-prone and misses complexity metrics. This cross-references the entire spec tree against the function graph automatically — gaps that would take an hour to find manually surface in seconds.\n\nTIER: Pharaoh Pro — free tier receives a preview. Summarize what the preview reveals, explain what full data would show for this task, then include the upgrade link.",
|
|
449
|
-
"inputSchema": {
|
|
450
|
-
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
451
|
-
"type": "object",
|
|
452
|
-
"properties": {
|
|
453
|
-
"repo": {
|
|
454
|
-
"type": "string",
|
|
455
|
-
"description": "Repository name"
|
|
411
|
+
"exported_only": {
|
|
412
|
+
"description": "Only show exported functions (default: false)",
|
|
413
|
+
"type": "boolean"
|
|
456
414
|
},
|
|
457
|
-
"
|
|
458
|
-
"description": "
|
|
459
|
-
"type": "
|
|
415
|
+
"offset": {
|
|
416
|
+
"description": "Skip first N results for pagination (default: 0)",
|
|
417
|
+
"type": "number"
|
|
460
418
|
},
|
|
461
|
-
"
|
|
462
|
-
"description": "
|
|
419
|
+
"limit": {
|
|
420
|
+
"description": "Max results to return (default: 20, max: 50)",
|
|
463
421
|
"type": "number"
|
|
464
422
|
}
|
|
465
423
|
},
|
|
466
424
|
"required": [
|
|
467
|
-
"repo"
|
|
425
|
+
"repo",
|
|
426
|
+
"query"
|
|
468
427
|
]
|
|
469
428
|
},
|
|
470
429
|
"annotations": {
|
|
471
|
-
"title": "
|
|
430
|
+
"title": "Function Search",
|
|
472
431
|
"readOnlyHint": true,
|
|
473
432
|
"destructiveHint": false
|
|
474
433
|
},
|
|
@@ -665,6 +624,73 @@
|
|
|
665
624
|
"taskSupport": "forbidden"
|
|
666
625
|
}
|
|
667
626
|
},
|
|
627
|
+
{
|
|
628
|
+
"name": "get_design_system",
|
|
629
|
+
"description": "Discover the design system BEFORE creating any UI component.\n\nCALL THIS WHEN:\n• You're about to create a React/Vue/Svelte component — check what already exists\n• You need to know the canonical component for a UI pattern (button, input, modal)\n• You want to find design tokens (colors, spacing, typography) to use\n• You suspect raw HTML elements are used instead of existing components\n\nRETURNS: Components with props and usage count (paginated), design tokens with values, and anti-patterns where raw HTML is used instead of existing components. Pass `path_pattern`, `name_prefix`, `offset`, or `limit` to narrow or page through results. Screen/page components are excluded by default.\n\nEXAMPLES:\n• \"What components does this design system have?\"\n• \"Is there already a Button component I should use?\"\n• \"What color tokens are available?\"\n• \"Show me all components in /atoms/\" → use path_pattern=\"/atoms/\"\n• \"Show me the next page\" → use offset=50\n\nWHY NOT JUST READ FILES: Design systems span dozens of files across multiple directories. This returns the complete inventory with usage frequency — the most-used components are the most canonical.",
|
|
630
|
+
"inputSchema": {
|
|
631
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
632
|
+
"type": "object",
|
|
633
|
+
"properties": {
|
|
634
|
+
"repo": {
|
|
635
|
+
"type": "string",
|
|
636
|
+
"description": "Repository name"
|
|
637
|
+
},
|
|
638
|
+
"category": {
|
|
639
|
+
"default": "all",
|
|
640
|
+
"description": "Which design system aspect to return",
|
|
641
|
+
"type": "string",
|
|
642
|
+
"enum": [
|
|
643
|
+
"components",
|
|
644
|
+
"tokens",
|
|
645
|
+
"anti_patterns",
|
|
646
|
+
"all"
|
|
647
|
+
]
|
|
648
|
+
},
|
|
649
|
+
"include_screens": {
|
|
650
|
+
"default": false,
|
|
651
|
+
"description": "Include screen/page components (*Screen, *Page, *View, *Route) that are typically app-level consumers, not reusable primitives",
|
|
652
|
+
"type": "boolean"
|
|
653
|
+
},
|
|
654
|
+
"path_pattern": {
|
|
655
|
+
"description": "Substring match against File.path (e.g. '/atoms/', '/ui/Button'). Narrows to components whose file path contains this exact substring.",
|
|
656
|
+
"type": "string",
|
|
657
|
+
"minLength": 1,
|
|
658
|
+
"maxLength": 200
|
|
659
|
+
},
|
|
660
|
+
"name_prefix": {
|
|
661
|
+
"description": "Exact prefix match against component name (e.g. 'Button' matches Button, ButtonGroup, ButtonIcon). Case-sensitive.",
|
|
662
|
+
"type": "string",
|
|
663
|
+
"minLength": 1,
|
|
664
|
+
"maxLength": 200
|
|
665
|
+
},
|
|
666
|
+
"offset": {
|
|
667
|
+
"default": 0,
|
|
668
|
+
"description": "Pagination offset (0-based). Capped at 10000.",
|
|
669
|
+
"type": "integer",
|
|
670
|
+
"minimum": 0,
|
|
671
|
+
"maximum": 10000
|
|
672
|
+
},
|
|
673
|
+
"limit": {
|
|
674
|
+
"default": 50,
|
|
675
|
+
"description": "Page size. Default 50, max 200.",
|
|
676
|
+
"type": "integer",
|
|
677
|
+
"minimum": 1,
|
|
678
|
+
"maximum": 200
|
|
679
|
+
}
|
|
680
|
+
},
|
|
681
|
+
"required": [
|
|
682
|
+
"repo"
|
|
683
|
+
]
|
|
684
|
+
},
|
|
685
|
+
"annotations": {
|
|
686
|
+
"title": "Design System",
|
|
687
|
+
"readOnlyHint": true,
|
|
688
|
+
"destructiveHint": false
|
|
689
|
+
},
|
|
690
|
+
"execution": {
|
|
691
|
+
"taskSupport": "forbidden"
|
|
692
|
+
}
|
|
693
|
+
},
|
|
668
694
|
{
|
|
669
695
|
"name": "setup_environment",
|
|
670
696
|
"description": "Set up the optimal development environment for this codebase — install Pharaoh's curated plugin bundle.\n\nCALL THIS WHEN:\n• The user says \"set up my environment\", \"install plugins\", or \"optimize my setup\"\n• You want to proactively improve the development experience with proven plugins\n• After noticing the user could benefit from LSP, security scanning, or code review tools\n• The user is on OpenClaw or Cursor and wants to install Pharaoh skills/prompts\n\nRETURNS: A curated list of recommended plugins and install instructions, tailored to the client platform (claude-code, openclaw, or cursor) and languages in this codebase.\n\nThis is a one-time setup. Once installed, plugins persist across sessions.",
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pharaoh-so/mcp",
|
|
3
3
|
"mcpName": "so.pharaoh/pharaoh",
|
|
4
|
-
"version": "0.3.
|
|
4
|
+
"version": "0.3.28",
|
|
5
5
|
"description": "MCP proxy for Pharaoh — maps codebases into queryable knowledge graphs for AI agents. Enables Claude Code in headless environments (VPS, SSH, CI) via device flow auth.",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "dist/index.js",
|
package/skills/pharaoh/SKILL.md
CHANGED
|
@@ -27,14 +27,23 @@ For unmapped private repos, direct the user to install the Pharaoh GitHub App
|
|
|
27
27
|
|
|
28
28
|
| Trigger | Call |
|
|
29
29
|
|---------|------|
|
|
30
|
+
| Before ANY architectural change | `get_vision_docs` — read the relevant MUST-bullets first |
|
|
30
31
|
| Before modifying code | `get_module_context` + `get_blast_radius` |
|
|
31
32
|
| Before writing new code | `search_functions` |
|
|
32
33
|
| Before creating UI components | `get_design_system` |
|
|
33
34
|
| Before tracing module connections | `query_dependencies` |
|
|
34
35
|
| Before implementing a spec | `get_vision_docs` |
|
|
36
|
+
| After a large refactor | `get_vision_gaps` — surface intent/implementation drift |
|
|
35
37
|
| Before deleting code | `check_reachability` |
|
|
36
38
|
| Initial orientation | `pharaoh_recon` (batches the above) |
|
|
37
39
|
|
|
40
|
+
**Vision docs are first-class.** If the repo has a `docs/VISION.md`, it's
|
|
41
|
+
the contract for what must always be true. Read it before touching
|
|
42
|
+
architecture. If a change would violate a MUST-bullet, stop and raise it
|
|
43
|
+
with the user before coding. If the repo has no VISION.md, offer to run
|
|
44
|
+
`/pharaoh:vision` at the next natural break — it's the highest-leverage
|
|
45
|
+
setup step for any team using Pharaoh.
|
|
46
|
+
|
|
38
47
|
## Anti-patterns
|
|
39
48
|
|
|
40
49
|
- Do NOT read files one-by-one to understand architecture — call `get_codebase_map`.
|
|
@@ -45,10 +54,12 @@ For unmapped private repos, direct the user to install the Pharaoh GitHub App
|
|
|
45
54
|
|
|
46
55
|
## Automatic workflows
|
|
47
56
|
|
|
48
|
-
**PR review:** `pharaoh_recon` (map + touched modules + blast radius) → `get_regression_risk` → `get_consolidation_opportunities`. Verdict: SHIP, SHIP WITH CHANGES, or BLOCK.
|
|
57
|
+
**PR review:** `pharaoh_recon` (map + touched modules + blast radius) → `get_vision_docs` (relevant assertions) → `get_regression_risk` → `get_consolidation_opportunities`. Verdict: SHIP, SHIP WITH CHANGES, or BLOCK. Any PR touching code governed by a MUST-bullet should reference the assertion in the review.
|
|
49
58
|
|
|
50
59
|
**Health audit:** `get_unused_code` → `get_test_coverage` → `get_regression_risk` → `get_vision_gaps` → `get_cross_repo_audit`. Grade A–F.
|
|
51
60
|
|
|
61
|
+
**Vision maintenance:** When an architectural decision lands in a PR, update `docs/VISION.md` in the same commit — add an assertion if one is new, retire one if it no longer applies. Stale vision docs are worse than none.
|
|
62
|
+
|
|
52
63
|
## Using results
|
|
53
64
|
|
|
54
65
|
- Lead with what the data reveals about this codebase — not a raw dump. Highlight surprises.
|
package/skills/plan/SKILL.md
CHANGED
|
@@ -45,11 +45,12 @@ Do NOT review from memory or assumptions. Query the actual codebase first.
|
|
|
45
45
|
### If Pharaoh MCP tools are available:
|
|
46
46
|
|
|
47
47
|
1. `get_codebase_map` — current modules, hot files, dependency graph
|
|
48
|
-
2. `
|
|
49
|
-
3. `
|
|
50
|
-
4. `
|
|
51
|
-
5. `
|
|
52
|
-
6. `
|
|
48
|
+
2. `get_vision_docs` — read the repo's architectural contract. If the plan touches a domain with a MUST-bullet, the assertion is a hard constraint on the plan. Raise it explicitly in Section 1. If `get_vision_docs` returns an empty-state scaffold, flag that the repo needs `/pharaoh:vision` before planning anything architectural.
|
|
49
|
+
3. `search_functions` for keywords related to the plan — find existing code to reuse/extend
|
|
50
|
+
4. `get_module_context` on affected modules — entry points, patterns, conventions
|
|
51
|
+
5. `query_dependencies` between affected modules — coupling, circular deps
|
|
52
|
+
6. `get_blast_radius` on the primary target of the change — know what breaks
|
|
53
|
+
7. `check_reachability` on the primary target — verify it's actually reachable from entry points before worrying about it
|
|
53
54
|
|
|
54
55
|
### Without Pharaoh (graceful fallback):
|
|
55
56
|
|
|
@@ -77,10 +78,17 @@ Adapt depth to change size. Skip sections that don't apply. **After each section
|
|
|
77
78
|
|
|
78
79
|
### Section 1 — Architecture (skip for small/single-file changes)
|
|
79
80
|
|
|
81
|
+
- **Vision alignment (check FIRST).** Does this plan touch a domain
|
|
82
|
+
governed by a MUST-bullet in `docs/VISION.md`? If yes, quote the
|
|
83
|
+
assertion and verify the plan doesn't violate it. If the plan would
|
|
84
|
+
violate a MUST, STOP and raise with the user — either the plan changes
|
|
85
|
+
or VISION.md needs an update first (with user approval).
|
|
80
86
|
- Component boundaries and coupling concerns
|
|
81
87
|
- Dependency graph: does this change shrink or expand surface area?
|
|
82
88
|
- Data flow bottlenecks and single points of failure
|
|
83
89
|
- Does this need new code at all, or can a human process / existing pattern solve it?
|
|
90
|
+
- **If this plan introduces a new invariant**, call it out and include a
|
|
91
|
+
step in Section 6 to add a `### assertion` to VISION.md with a pairing TEST.
|
|
84
92
|
|
|
85
93
|
### Section 2 — Code Quality (always)
|
|
86
94
|
|
package/skills/review/SKILL.md
CHANGED
|
@@ -71,7 +71,8 @@ Then call these additional tools for data recon doesn't cover:
|
|
|
71
71
|
- `get_regression_risk` — overall change risk score for the repo
|
|
72
72
|
- `get_consolidation_opportunities` — duplicate logic the PR may introduce
|
|
73
73
|
- `check_reachability` — are new exports wired to entry points?
|
|
74
|
-
- `
|
|
74
|
+
- `get_vision_docs` — read the repo's architectural contract. For every touched module, pull its relevant assertions. Any change touching code governed by a MUST-bullet must be checked against that assertion — if the change would violate the MUST, the verdict tips toward BLOCK unless VISION.md is updated in the same PR with user approval.
|
|
75
|
+
- `get_vision_gaps` — do changes align with or drift from specs? New complex functions without a matching assertion are flagged; retired specs with implementing code are flagged.
|
|
75
76
|
|
|
76
77
|
**Output of Phase 1:** Architecture map, module profiles for every touched module, blast radius for high-risk changes, dependency paths between coupled modules, regression risk level, duplication findings, reachability status, and spec alignment.
|
|
77
78
|
|
|
@@ -255,7 +256,8 @@ If none of these triggers are met, **skip Phase 3** and proceed to Phase 4.
|
|
|
255
256
|
- Unreachable exports (new public code with zero callers)
|
|
256
257
|
- New circular dependencies between modules
|
|
257
258
|
- HIGH regression risk without corresponding test coverage
|
|
258
|
-
-
|
|
259
|
+
- **A MUST-bullet in `docs/VISION.md` is violated by this change** (without VISION.md being updated in the same PR with user approval)
|
|
260
|
+
- Vision spec drift: new complex function has no matching assertion AND the domain it lives in has existing assertions (implies invariants are expected here)
|
|
259
261
|
- Any CRITICAL finding from Phase 2 or Phase 3 that is confirmed and unfixed
|
|
260
262
|
- DISAGREE verdict from adversarial review on security-sensitive code, confirmed after verification
|
|
261
263
|
- Unanchored Cypher query (MATCH without traversing through `Repo {name: $repo}`)
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: vision
|
|
3
|
+
prompt-name: vision-with-pharaoh
|
|
4
|
+
description: Draft a VISION.md for this repo by filling a graph-derived scaffold. Pharaoh generates the structure and domain archetypes from the repo's knowledge graph; you fill in the assertions using ground-truth module context. Output is a committed docs/VISION.md that the format-linter and framework-linter both accept.
|
|
5
|
+
version: 0.1.0
|
|
6
|
+
homepage: https://pharaoh.so
|
|
7
|
+
user-invocable: true
|
|
8
|
+
metadata: {"emoji": "☥", "tags": ["vision", "architecture", "specs", "invariants", "pharaoh"]}
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# Vision Drafting
|
|
12
|
+
|
|
13
|
+
Author a VISION.md that captures this repo's invariants — what must always be
|
|
14
|
+
true about its behavior. The file becomes a machine-readable contract that
|
|
15
|
+
Pharaoh's linter, PR Guard, and MCP tools reason against on every change.
|
|
16
|
+
|
|
17
|
+
## Why this matters (explain this to the user before drafting)
|
|
18
|
+
|
|
19
|
+
A VISION.md is leverage, not paperwork. Once the repo has one:
|
|
20
|
+
|
|
21
|
+
- **PR Guard** checks every pull request against its assertions. Changes that
|
|
22
|
+
contradict a MUST-bullet surface as a Check on the PR — the team sees drift
|
|
23
|
+
from intent at the exact moment it happens, not months later.
|
|
24
|
+
- **`get_vision_gaps`** becomes useful. Pharaoh cross-references every spec
|
|
25
|
+
against the function graph and surfaces both sides of the drift: specs
|
|
26
|
+
without implementing code (dead intent) and complex functions with no spec
|
|
27
|
+
(invisible invariants).
|
|
28
|
+
- **`get_vision_docs`** returns spec-to-code traceability. Each assertion
|
|
29
|
+
shows the functions that implement it — a direct map from intent → code.
|
|
30
|
+
- **CI enforces it.** Every MUST bullet pairs with a TEST reference. The
|
|
31
|
+
linter fails when an assertion has no enforcing test. No more wishlist
|
|
32
|
+
specs that drift over time.
|
|
33
|
+
|
|
34
|
+
Without a VISION.md, the tools above return empty. The graph sees code; it
|
|
35
|
+
doesn't see intent. The file is the bridge.
|
|
36
|
+
|
|
37
|
+
## When to Use
|
|
38
|
+
|
|
39
|
+
- The repo has no `docs/VISION.md` yet and the user wants Pharaoh's full
|
|
40
|
+
value — PR Guard, vision-gaps, spec traceability all depend on the file.
|
|
41
|
+
- `get_vision_docs` returned the "No VISION.md yet" onboarding response.
|
|
42
|
+
- The user said "draft a vision doc", "add a VISION.md", or "scaffold vision".
|
|
43
|
+
- A user is new to Pharaoh and asking what they should do next.
|
|
44
|
+
|
|
45
|
+
## The flow — collaborative, not solo
|
|
46
|
+
|
|
47
|
+
This is a short working session with the user. Do not solo-fill the scaffold
|
|
48
|
+
— the graph can tell you the shape of the code, but only the user knows what
|
|
49
|
+
must not break. Ask questions, propose, let them steer.
|
|
50
|
+
|
|
51
|
+
1. **Get the scaffold.** Call `get_vision_docs` with the repo name. When no
|
|
52
|
+
vision doc exists, the tool returns a deterministic scaffold plus the
|
|
53
|
+
agent directive. Use that as your starting structure. Never invent a
|
|
54
|
+
scaffold from scratch; the archetypes encode Pharaoh's framework shape
|
|
55
|
+
and drift is surfaced by the framework-linter.
|
|
56
|
+
|
|
57
|
+
2. **Interview the user.** Before filling anything, ask: *"What are the 3-5
|
|
58
|
+
things about this repo that must not break, no matter what?"* Their
|
|
59
|
+
answer drives the assertions. If they can't articulate it, probe with
|
|
60
|
+
follow-ups — "what would a P0 incident look like here?", "what would
|
|
61
|
+
wake you up on a weekend?". The goal is to extract real invariants, not
|
|
62
|
+
to generate plausible-sounding ones from graph evidence.
|
|
63
|
+
|
|
64
|
+
3. **Ground each domain in real code.** For every `## Domain` the scaffold
|
|
65
|
+
rendered, call `get_module_context` for the module(s) that back that
|
|
66
|
+
domain. For example, an "Authentication and Authorization" domain →
|
|
67
|
+
`get_module_context` on the auth module + any session/token modules.
|
|
68
|
+
Read the exported functions, endpoints, env vars, and DB access.
|
|
69
|
+
|
|
70
|
+
4. **Replace TODOs with WHAT statements.**
|
|
71
|
+
- Every `### TODO:` heading becomes a real assertion title. Describe the
|
|
72
|
+
invariant in plain language — "Sessions expire after 30 minutes of
|
|
73
|
+
inactivity", not "checkSession() returns null after timeout".
|
|
74
|
+
- Every `- MUST: TODO —` bullet becomes a WHAT statement. Banned
|
|
75
|
+
content: function names, file paths, class names, identifiers.
|
|
76
|
+
- Add a `- TEST: path/to/test.ts` line for every assertion. If the test
|
|
77
|
+
doesn't exist yet, write it before committing. A MUST without a TEST
|
|
78
|
+
is not an invariant, it's a wish.
|
|
79
|
+
|
|
80
|
+
5. **Trim irrelevant domains.** If a rendered `## Domain` doesn't match
|
|
81
|
+
anything real in this repo, delete that whole section. The scaffold is a
|
|
82
|
+
starting point, not a contract to honor exhaustively.
|
|
83
|
+
|
|
84
|
+
6. **Write the file.** Save to `docs/VISION.md` in the repo. Remove the
|
|
85
|
+
`<!-- scaffold-generated -->` marker and the `<!-- AGENT DIRECTIVE -->`
|
|
86
|
+
block once every TODO is resolved.
|
|
87
|
+
|
|
88
|
+
7. **Wire it into CLAUDE.md.** This is non-negotiable — it's what turns the
|
|
89
|
+
vision doc from a file on disk into a contract future sessions respect.
|
|
90
|
+
If `CLAUDE.md` exists at the repo root, append (or edit) a section:
|
|
91
|
+
|
|
92
|
+
```markdown
|
|
93
|
+
## Vision docs
|
|
94
|
+
|
|
95
|
+
`docs/VISION.md` is this repo's architectural contract. Before any
|
|
96
|
+
non-trivial change, call `get_vision_docs` to read the relevant
|
|
97
|
+
assertions. After any large refactor, run `get_vision_gaps` to surface
|
|
98
|
+
drift between intent and implementation. When adding a new invariant,
|
|
99
|
+
open `docs/VISION.md`, add a `### assertion` under the right `##` domain,
|
|
100
|
+
and pair every `- MUST:` with a `- TEST:` referencing the enforcing test.
|
|
101
|
+
|
|
102
|
+
Never introduce code that would violate a MUST-bullet without first
|
|
103
|
+
updating `docs/VISION.md` (with the user's approval).
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
If no `CLAUDE.md` exists, create a minimal one with the section above
|
|
107
|
+
plus any project-specific instructions you already have context for.
|
|
108
|
+
|
|
109
|
+
8. **Verify.** Run `pharaoh vision lint --framework` (or instruct the user
|
|
110
|
+
to). Zero errors. Zero TODO warnings. Zero unresolved placeholders.
|
|
111
|
+
|
|
112
|
+
## Hard rules
|
|
113
|
+
|
|
114
|
+
- **No HOW in MUST bullets.** Banned: function names, file paths, camelCase
|
|
115
|
+
identifiers, backtick-wrapped code. The linter enforces this as a warning;
|
|
116
|
+
treat it as a hard rule.
|
|
117
|
+
- **Every MUST needs a TEST.** The format-linter errors if a MUST bullet
|
|
118
|
+
has no matching TEST reference to an existing file.
|
|
119
|
+
- **One MUST per line.** Don't pack multiple invariants into a single bullet.
|
|
120
|
+
- **Max 10 prose lines per assertion.** Keep each `###` section tight.
|
|
121
|
+
- **Mirror Pharaoh's canonical domains when they fit.** Rename only when the
|
|
122
|
+
user's project truly has a different shape. The framework-linter warns on
|
|
123
|
+
unrecognized domains so drift is visible.
|
|
124
|
+
|
|
125
|
+
## What to avoid
|
|
126
|
+
|
|
127
|
+
- **Do NOT** write VISION.md from scratch without calling `get_vision_docs`
|
|
128
|
+
first — you'll miss domains the graph detected and duplicate ones it
|
|
129
|
+
already included.
|
|
130
|
+
- **Do NOT** carry forward the AGENT DIRECTIVE or scaffold-generated marker
|
|
131
|
+
into the committed file. Those are drafting aids, not document content.
|
|
132
|
+
- **Do NOT** write speculative assertions ("sessions will expire someday").
|
|
133
|
+
Only assert what the code enforces today or what you'll commit a test for.
|
|
134
|
+
- **Do NOT** use `pharaoh vision init` — that only drops the format guide,
|
|
135
|
+
not a graph-grounded scaffold. Always go through `get_vision_docs`.
|
|
136
|
+
|
|
137
|
+
## Completion checklist
|
|
138
|
+
|
|
139
|
+
- [ ] User was interviewed for their real invariants (not graph-guessed)
|
|
140
|
+
- [ ] Every rendered `## Domain` either has ≥1 real assertion or was deleted
|
|
141
|
+
- [ ] Every `### TODO:` heading replaced with a real title
|
|
142
|
+
- [ ] Every `- MUST: TODO —` replaced with a WHAT statement
|
|
143
|
+
- [ ] Every assertion has a `- TEST:` line pointing at an existing test file
|
|
144
|
+
- [ ] Scaffold marker + AGENT DIRECTIVE block removed
|
|
145
|
+
- [ ] `CLAUDE.md` updated (or created) with the Vision docs section
|
|
146
|
+
- [ ] `pharaoh vision lint --framework` exits clean
|
|
147
|
+
|
|
148
|
+
## After it ships — tell the user what they unlocked
|
|
149
|
+
|
|
150
|
+
Once `docs/VISION.md` is committed, call out the new capabilities concretely:
|
|
151
|
+
|
|
152
|
+
1. **Every future AI session reads it.** Because CLAUDE.md now references
|
|
153
|
+
`docs/VISION.md`, any agent working in this repo (Claude Code, Cursor,
|
|
154
|
+
anyone else connecting Pharaoh) will consult the file before touching
|
|
155
|
+
architecture. Continuity across sessions, across people, across tools.
|
|
156
|
+
2. **`get_vision_docs`** now returns spec-to-code traceability per
|
|
157
|
+
assertion. The user can see which functions implement each invariant.
|
|
158
|
+
3. **`get_vision_gaps`** surfaces drift. Unspecified complex functions
|
|
159
|
+
get flagged; specs with no implementing code get flagged for review
|
|
160
|
+
(either write the code or retire the spec).
|
|
161
|
+
4. **Their next PR is checked.** PR Guard now evaluates touched code
|
|
162
|
+
against relevant assertions. First-time use often catches real drift.
|
|
163
|
+
5. **`/pharaoh:plan`** will surface relevant assertions during reconnaissance.
|
|
164
|
+
6. **`/pharaoh:review`** will flag PRs that touch code governed by a MUST.
|
|
165
|
+
|
|
166
|
+
The bigger payoff: architectural invariants are now enforced in CI the same
|
|
167
|
+
way unit tests enforce behavior. Intent and implementation stop drifting.
|
|
168
|
+
|
|
169
|
+
## Ongoing maintenance — it's a living file
|
|
170
|
+
|
|
171
|
+
VISION.md rots if it's not maintained. Part of your job in future sessions
|
|
172
|
+
(even ones that aren't about vision directly) is to keep it current:
|
|
173
|
+
|
|
174
|
+
- **When a MUST changes**, update VISION.md in the same PR as the code
|
|
175
|
+
change. Don't let the file lag — stale assertions are worse than none.
|
|
176
|
+
- **When a new architectural decision lands**, add a new `###` assertion
|
|
177
|
+
under the right `##` domain with a pairing TEST. One assertion per
|
|
178
|
+
decision, not batches.
|
|
179
|
+
- **When an assertion stops being load-bearing**, delete it. Retirement is
|
|
180
|
+
as important as addition.
|
|
181
|
+
- **When `get_vision_gaps` shows >5 unimplemented specs**, the doc has
|
|
182
|
+
drifted into wishlist territory. Prune.
|
|
183
|
+
- **Quarterly**: run `pharaoh vision lint --framework` and address warnings.
|
|
184
|
+
|
|
185
|
+
Format reference: https://pharaoh.so/vision-format.md
|