graph-review
Audit Aleph's knowledge graph (`.understand-anything/knowledge-graph.json`) for code-health signals — orphan nodes, dead-code candidates, R1 brain-limb separation violations, R10 thin-harness budget overrun. Use when the user types `/graph-review`, asks to "audit the graph", "check redlines", "find orphans", "find dead code", "verify thin harness", or wants a code-health pulse before a release / refactor / merge. Requires the graph file to exist — run `/understand` first if missing. Wraps `scripts/graph-audit.mjs` (no LLM cost, pure deterministic JSON walk).
- License 许可
- MIT
- 所属仓库
- rootazero/Aleph
- 最近更新
- 2026-11-05
- Stars
- ★ 4
- Forks
- 1
01 前言 Front Matter
- name
- graph-review
- description
- Audit Aleph's knowledge graph (`.understand-anything/knowledge-graph.json`) for code-health signals — orphan nodes, dead-code candidates, R1 brain-limb separation violations, R10 thin-harness budget overrun. Use when the user types `/graph-review`, asks to "audit the graph", "check redlines", "find orphans", "find dead code", "verify thin harness", or wants a code-health pulse before a release / refactor / merge. Requires the graph file to exist — run `/understand` first if missing. Wraps `scripts/graph-audit.mjs` (no LLM cost, pure deterministic JSON walk).
03 SKILL.md 正文
graph-review
Run scripts/graph-audit.mjs to surface code-health signals derived from .understand-anything/knowledge-graph.json. Default to the summary rollup; drill into individual audits only when a check is non-zero or the user asks for specifics.
This skill is deterministic: it reads a static JSON and emits counts/lists. No LLM call inside. Use the model's judgment only for interpreting the output and recommending follow-ups.
Preconditions
.understand-anything/knowledge-graph.jsonmust exist at the repo root. If absent, tell the user: "No knowledge graph found. Run/understandfirst." Do NOT try to regenerate it inside this skill —/understandis a separate multi-phase pipeline.nodeavailable on PATH (already required by the project).
Workflow
- Rollup first — get one-line counts per check:
node scripts/graph-audit.mjs summary - Decide drill-in scope based on rollup:
orphans > 0→ runorphans. After Phase 7 cohort-wiring this should always be 0; a non-zero means/understandwas interrupted or the graph is stale.dead-code > 0is expected and noisy — only drill if user explicitly asks. Always preface with the under-capture caveat (see Caveats).redline-r1 > 0→ runredline-r1. Every hit is a real R1 violation (sandbox bridges already excluded).redline-r10 > 0→ runredline-r10. Meanssrc/harness/exceeded 12 files; check whether new file is justified per CLAUDE.md R10 "3 questions before adding code".
- Drill in with the relevant subcommand and
--limit=Nto widen lists:node scripts/graph-audit.mjs redline-r1 --limit=50 node scripts/graph-audit.mjs dead-code --json | jq '.items[] | select(.file | startswith("src/gateway/"))' - Cross-check before recommending fixes — especially for dead-code (see Caveats). Use
rg,cargo machete, or IDE find-usages.
Commands
| Command | Output | Notes |
|---|---|---|
summary |
One-line counts per audit | Default; safe and fast |
orphans |
Nodes with zero edges | Expected: 0. Non-zero = stale or broken graph |
dead-code |
function/class nodes with no inbound calls edge |
CANDIDATES only — see Caveats |
redline-r1 |
src/ files naming platform-native APIs (AppKit / Vision / win32 / objc / cocoa / etc.) |
Violates R1 brain-limb separation. src/sandbox/ + src/bin/aleph-server/ excluded (legitimate bridges) |
redline-r10 |
src/harness/ .rs file count vs. 12-file budget |
R10 thin-harness invariant — see CLAUDE.md §R10 |
Flags: --json (machine output, pipeable to jq), --limit=N (default 30, widens lists in human mode), --graph=path (point at a non-default graph file — useful for subdomain graphs like frontend-knowledge-graph.json), --scope=prefix/ (restrict audit to nodes whose filePath starts with the prefix; trailing / auto-appended).
Module-scoped audits
Use --scope=<path-prefix> to confine any audit to a subtree. Filtering is on the graph node's filePath field, so it covers all 4 audits consistently. Trailing / is auto-appended when the prefix has no . (avoiding src/gateway accidentally matching src/gateway_extras/).
# Only audit src/gateway/
node scripts/graph-audit.mjs summary --scope=src/gateway/
# Only harness dead-code candidates
node scripts/graph-audit.mjs dead-code --scope=src/harness/
# R1 violations under a single feature subtree
node scripts/graph-audit.mjs redline-r1 --scope=src/builtin_tools/browser_tools/
Per-audit behaviour under scope:
| Audit | Scoped behaviour |
|---|---|
orphans |
Only orphans whose filePath is within scope. |
dead-code |
Only function/class nodes within scope. Global call-edge stat in warning stays global (not scope-adjusted) — that's intentional, the under-capture is a project-wide signal. |
redline-r1 |
Only src/ files within scope (still excludes bridge subtrees src/sandbox/ and src/bin/aleph-server/). |
redline-r10 |
If scope doesn't overlap src/harness/, reports N/A and returns 0. Otherwise filters harness files by scope. |
Natural-language triggers map to scope flags. When the user says:
- "审 src/gateway/" →
--scope=src/gateway/ - "只看 harness 的死代码" →
dead-code --scope=src/harness/ - "看看 builtin_tools 里的 R1" →
redline-r1 --scope=src/builtin_tools/
Caveats
- dead-code is severely under-captured. The graph currently captures ~4.5% of true call edges (~159 calls edges across ~3518 function nodes). The dead-code report will show thousands of false positives. Treat output as candidates requiring manual verification, not a deletion list. Always say so when reporting. The fix lives upstream in
/understand's file-analyzer subagent, not here. - redline-r1 token list is conservative. Currently tokens like
use objc::,use cocoa::,use core_graphics::,use core_foundation::,NSWorkspace,AVCaptureDevice,CGEvent,use windows::,use winapi::,CheckNetIsolationEnableLoopback,CreateProcessW. Add new tokens as new platform APIs appear in the codebase (edit theNATIVE_API_TOKENSarray inscripts/graph-audit.mjs). - redline-r10 file budget is wired to CLAUDE.md §R10. Current budget: 12 files. If CLAUDE.md is bumped, update
HARNESS_BUDGETinscripts/graph-audit.mjsin the same commit — the two must stay in sync. - The script writes nothing. Pure read. Safe to run repeatedly, including in CI.
Reporting back to the user
After running, summarise in 3-5 lines max:
- Which checks passed (one bullet, group them).
- Which need attention (one bullet per non-zero check, with the count).
- Top 1-2 candidates worth investigating, if any (with file path).
Do NOT dump full lists into the response. If listing is genuinely needed (e.g., user explicitly asks "show me all R1 violations"), prefer --limit=5 and offer --limit=N to widen.
For R1 / R10 hits, link the redline in CLAUDE.md:
- R1 — brain-limb separation: no platform-native API calls outside
src/sandbox/(OS isolation bridge) andsrc/bin/aleph-server/(libc/process control). - R10 — thin-harness budget:
src/harness/≤ 12 files / ~4900 LOC. Adding a file requires answering the "3 questions before adding code" in CLAUDE.md.
When NOT to use this skill
- User asks "who calls function X?" or "what does file Y depend on?" — this skill doesn't do per-symbol drill-down. Suggest
rg, IDE find-usages, or future MCP server. - User wants the dashboard visualisation — invoke
understand-anything:understand-dashboardinstead. - Graph is stale (commits since last
/understand) — re-run/understandfirst; this skill audits whatever's on disk and won't warn you that the graph is old.
04 同仓库更多 Skills
invalid-yaml
暂无简介
gh-pr-docker
GitHub PR operations (Aleph enhanced with Docker)
echo-basic
Basic echo command (frontmatter smoke fixture)
review-results
暂无简介
review-results
暂无简介
severed-wire-audit
Find and resolve "severed wires" in a codebase — a producer and a consumer both exist and are fully implemented, but the connecting registration / dispatch arm / event subscription / call site between them is missing, so a feature looks broken though both ends are done. dead-code lints CANNOT catch this: the producer isn't dead (it has tests) and the consumer connects to a stub or reads an inert config. Use when a feature "looks unwired / 没接上 / 两端都在但连线断 / 明明写了却调不到"; after a refactor or middleware removal, to verify producers still reach consumers; when asked to "审接缝 / 找断线 / seam audit / wire audit / connection audit"; or when a method returns NOT_FOUND, a tool the model can't call, an event that never fires, or a config field nothing reads. Triages each finding into CONNECT (fix the wire) / CUT (delete the dead abstraction) / DECIDE (ask the human), enforces read-before-write so dead scaffolding is deleted not reconnected, and installs a grep-diff guard against regression.