code-health
它能做什么
这项技能帮助你的 AI 判断代码库的健康程度,以及哪些文件最难维护。适合希望基于证据规划清理或重构工作的开发者。
适用场景
- ✓当你询问代码库的健康状况,或下一步应清理什么的时候。
- ✓当你计划或完成一次重构,并想做前后对比的时候。
- ✓当你想知道某个文件为何被标记为有风险或难以维护的时候。
技能链接
https://github.com/repowise-dev/repowise/blob/main/plugins/claude-code/skills/code-health/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请给我看这个项目中风险最高的文件,以及我应该先重构哪些。”
每周 5 个新技能,1 分钟读完。
工作原理
技能运行 Repowise 健康检查,依据复杂度和未测试热点等可衡量的信号,为每个文件打 1 到 10 分。它返回一份按优先级排序的修复清单,或指定文件的详细结果。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Code Health with Repowise
Repowise scores every file 1–10 from deterministic markers — McCabe complexity, deep nesting, brain methods, class cohesion (LCOM4), god classes, clone detection, untested hotspots, function-level churn, ownership dispersion, and more. Zero LLM calls; pure local analysis. The weights are calibrated against a real defect corpus, so a low score means more likely to harbour bugs, not just bigger.
Pick the mode by what you pass
- Dashboard:
get_health()(no targets):fix_first, the ranked list of what to fix first, then repo-level KPIs and the lowest-scoring files. Start here for "how healthy is this codebase?" or "what should we clean up?". - Targeted —
get_health(targets=["src/x.py", "src/y.py"]): per-file score and the specific marker findings driving it. Use before/after a refactor, or to explain why a file is flagged.
Useful include flags
get_health(targets=[...], include=[...]):
"biomarkers"— always return the findings list (what's wrong, where)."refactoring"— deterministic, ranked refactoring suggestions (by impact/effort)."coverage"— surface coverage data when it's been ingested."trend"— recent health snapshots + declining / predicted-decline signal.
include adds blocks; only=[...] subtracts them.
How to use the results
- For "what should I refactor?" → dashboard mode, lead with
fix_first; open an item withget_health(fix_id=...)for its steps and the tests to run, and present the plan, not just the scores. - Rank by
weighted_deficit, notscore— the score floors at 1.0. - For a specific file → report the score, the top 2–3 marker findings, and what each one means in plain language. Avoid dumping the raw payload.
- Check
unresolvedbefore calling a file clean: a target listed there matched nothing, andnot_indexedmeans runrepowise update. - Before editing a flagged file → cross-check
get_risk(targets=[...]); a file that is both low-health and a churn hotspot deserves the most care. - Untested-hotspot / coverage questions → tell the user coverage markers
light up once they ingest a report:
repowise coverage add cov.lcov(LCOV / Cobertura / Clover; a coverage.py.coveragealso builds the per-test map), thenrepowise health --recomputeto fold it into the scores.
CLI equivalents
repowise health— KPIs + lowest-scoring filesrepowise health --refactoring-targets— ranked by impact / effortrepowise health --trend— snapshots + declining alertsrepowise coverage add <file>— ingest coverage, light up untested-hotspot
Error handling
If get_health reports no repository, suggest /repowise:init. Code health is
computed even with a template-rendered wiki (no LLM needed), so it should be available
whenever the repo is indexed.
常见问题
分数低意味着什么?
技能说明,分数低表示该文件更可能隐藏错误,而不仅仅是因为它很大。
我可以只检查几个文件吗?
可以。你可以指定文件,获取它们的分数以及背后的发现。
它会用 AI 模型来评判代码吗?
不会。技能说明,这种分析是确定性的、在本地进行的,不调用任何模型。
详情
作者的原始描述
Use when the user asks about code health, code quality, complexity, technical debt, which files are risky or hard to maintain, what to refactor next, untested hotspots, or coverage gaps in a Repowise-indexed codebase (.repowise/ directory exists). Also use to get a before/after health read when planning or finishing a refactor.
repo: repowise-dev/repowise
热度
- GitHub 星标
- 8.1k
- 排名
- #12566
- 许可证
- AGPL-3.0
- 更新时间
- 2026/11/2
评论
- …