repo-health
Provides read-only repository health scanning tools for drift detection, module reachability, prompt bloat, evidence calibration, and registration completeness, enabling agents to diagnose repositories via MCP.
README
repo-health
Read-only repository health scanners: definition drift, unwired-module reachability, prompt bloat, evidence-gate calibration, and registration completeness — as a CLI and an MCP server.
A codebase rots silently. The most damaging defects are the ones no test, type checker, or linter catches:
- a concept defined in two places where only one copy gets updated (drift),
- a module written but never wired up (unreachable),
- a fixed-injected prompt segment quietly eating the context (bloat),
- an extension point that exists but is never registered (registration).
repo-health is five read-only scanners that watch for exactly these. It is the extracted, generalized core of the quality-guard tooling behind a large production agent system, repackaged so any repository can run it.
Install
pip install "dsh-repo-health" # CLI
pip install "dsh-repo-health[mcp]" # + MCP server
Requires Python 3.11+ (the registration scanner uses tomllib; the others run on 3.10+).
Quick start
repo-health drift --root /path/to/repo # definition drift report
repo-health reach --root /path/to/repo # unwired-module report
repo-health prompt-bloat --root /path/to/repo # prompt segment shares
repo-health evidence --path logs/evidence_gate.jsonl
repo-health registration --root /path/to/repo --config registration.toml
repo-health all --root /path/to/repo # run every scanner
Every scanner also ships a --selftest that verifies the tool itself against a
synthetic fixture before it is trusted to judge your code — the predecessor of
these scanners shipped versions that produced pretty-but-wrong numbers, and
only known-answer fixtures caught them.
The five scanners
drift — multi-source definition drift
Detects the same name defined in more than one place with overlapping member structure, and flags it when one copy changes but the other does not.
- A class (guarded): same name and structure overlap ≥ 0.5 — watched for drift.
- B class (not guarded): same name, disjoint structure — a name collision, confusing but not a data hazard.
- Sync changes pass. If someone diligently updates both copies, that is correct behavior; a guard that punishes it gets disabled.
repo-health drift --root . # report
repo-health drift --root . --write-baseline # freeze a baseline
repo-health drift --root . --check # exit 1 on drift / new pairs
reach — unwired-module reachability
Builds the import graph and BFS-searches from startup entrypoints
(__main__.py, if __name__ == "__main__" guards, main.py, launch scripts).
Modules that cannot be reached are "wired but dead".
Its baseline carries auditable reasons: every unreachable module needs a
structured {verdict, anchor} entry, validated deterministically (V1–V7) so a
single wrong reason can never permanently hide code from every mechanism.
repo-health reach --root . # report
repo-health reach --root . --write-baseline # freeze
repo-health reach --root . --check # exit 1 on new unwired modules
repo-health reach --root . --audit-reasons # validate baseline reasons
prompt-bloat — prompt segment share baseline
Reads prompt-inspection JSONL logs ({segments: [{name, pct, kind}]}) and
watches the median share per segment, not the absolute size (absolute size
varies naturally with task complexity; share reflects structural bloat).
repo-health prompt-bloat --root . --check --json
evidence — evidence-gate decision log calibration
Summarizes a decision log ({passed, suggested_action, tool, issues} JSONL) to
answer "is the gate calibrated yet?" — insufficient samples or a
false-positive-prone tool block any conclusion.
registration — config-driven registration completeness
Declares your architecture's extension points in a TOML config and verifies
every defined item appears in its registry. See
config/registration.example.toml for an
annotated example covering agent roles, checkers, API routers, sidebar pages,
and LLM providers.
MCP server (DeepSeek Harness & any MCP client)
pip install "dsh-repo-health[mcp]"
python -m repo_health.mcp_server
Exposes the scanners as read-only MCP tools (drift_scan, reach_scan,
reach_reason_audit, prompt_bloat, evidence_calibration, registration).
Register it in DeepSeek Harness's MCP settings (or any MCP client) to let an
agent diagnose its own repository. Large repositories may exceed MCP's default
tool timeout — pass narrower root values or raise the client timeout.
Methodology (why this is not "yet another linter")
The scanners share a discipline learned the hard way:
- Watch events, not states. "Duplicated" is a state; "one side changed and the other didn't" is the event that actually corrupts data.
- Guard must not punish correct behavior. Sync updates pass; else the guard gets disabled within a week.
- Never freeze a baseline from insufficient samples. A median from three records is not a fact — a baseline frozen from it is false confidence.
- Reasons must be checkable. Free-text baseline justifications are how
code permanently hides from every mechanism; make them
{verdict, anchor}. - Self-test the scanner before it judges anything. Known-answer fixtures are the only thing that caught the predecessor's wrong-but-plausible output.
Known limitations
driftscans Python only (.pyunder the configured package dirs).reachis module-granular: a reachable module whose functions are never called is not reported; dynamic imports (importlib, plugin loaders) are invisible and belong in the baseline.evidenceandprompt-bloatconsume a specific JSONL schema; adapt your logger to emit it (examples in the docstrings).
License
MIT © 2026 Chen (Jarry) Pan
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。