crap-score
Skill0 starsChanged 3 months agoMITView on GitHub
Regenerates a Python project's METRICS.md (CRAP scores + test-quality scan) in place by running the suite and radon, then writes the Findings section's analysis itself — auto-detects source/test dirs, works on any pytest project, no per-project setup required.
2 other projects use a version of this.
Adopted by
Most recently taken up by
- microsoft/testfxtheir own version, first seen Oct 9, 2026
- VincentH-Net/dotnet-agentic-engineeringtheir own version, first seen May 12, 2026
Other versions2 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 2
- microsoft/testfx★ 1.1ksame name
- VincentH-Net/dotnet-agentic-engineering★ 9same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
The file
We split this skill into the rules it gives an agent
5 rules. About 0 are common, 0 are distinctive, and 5 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 25
If METRICS.md doesn't exist yet for this project, it's created with a minimal skeleton (title, methodology blurb, an empty "Findings" …
- Very specific: line 31
Auto-detection, and how to override it: if a project's layout is unusual (monorepo, non-standard test dir, etc.) — add a [tool.crap_score] …
- Very specific: line 53
After the script writes the SUMMARY/QUALITY/CRAP_TABLE regions, read them and update the "## Findings" section yourself — this is not the …
- Very specific: line 69
Don't paste the whole file into the conversation — a one- or two-line delta is enough.
- Very specific: line 73
Never hand-edit content inside the <!-- AUTOGEN:...
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Regenerates the data-derived sections of a Python project's METRICS.md — CRAP scores
(cyclomatic complexity × test coverage risk) and a static test-quality scan (assertion
density, mock usage). Works on any project using pytest + pytest-cov + radon; source
dirs, test files, the interpreter, and the METRICS.md location are all auto-detected from
the current project's layout.
Steps
- Run:
Omitpython3 ~/.claude/skills/crap-score/scripts/regen_metrics.py [repo_root]repo_rootto auto-detect it from the current working directory (walks upward for the nearest.gitorpyproject.toml). This runs the target project's test suite using its own interpreter (auto-detected from.venv/bin/pythonorvenv/bin/pythonin the target repo — falls back tosys.executableif neither exists), sopytest,pytest-cov, andradonmust already be installed there. This script itself only needs Python 3.11+ (fortomllib) — it doesn't need those packages in its own environment. - If
METRICS.mddoesn't exist yet for this project, it's created with a minimal skeleton (title, methodology blurb, an empty "Findings" section, and the three<!-- AUTOGEN:... -->regions). On later runs, only the marked regions are rewritten by the script — "Findings" is rewritten by you (see step 5 below), and any other hand-added prose elsewhere in the file is preserved untouched. - Auto-detection, and how to override it if a project's layout is unusual (monorepo,
non-standard test dir, etc.) — add a
[tool.crap_score]table to the target project'spyproject.toml:
Without this, source dirs are found by looking for[tool.crap_score] source_dirs = ["src/myapp"] # dirs to run radon/coverage over python = ".venv/bin/python" # interpreter to run pytest with metrics_file = "tests/METRICS.md" test_paths = ["tests"] # explicit pytest target(s); omit for pytest's own discovery__init__.py-containing directories one or two levels deep (skippingtests/,.venv/,node_modules/,build/, etc.); test files are found by recursively globbingtest_*.py/*_test.py;METRICS.mddefaults to living alongside the most common test directory found. - Known limitation: auto-detection resolves one project root per run — a monorepo with
a nested Python subproject (e.g.
backend/with its ownpyproject.toml, imported viafrom backend.x import yrather than self-relative imports, sitting next to a non-Pythonfrontend/) needs the[tool.crap_score]override in the outerpyproject.toml(there usually isn't one yet — create it) rather than relying on auto-detection to guess which directory is "the" project root. - After the script writes the
SUMMARY/QUALITY/CRAP_TABLEregions, read them and update the "## Findings" section yourself — this is not the end user's manual upkeep, and it's deliberately outside theAUTOGENmarkers because it needs judgment a static script can't apply. Write a handful of concrete, actionable bullets, each referencing a specificfile:line:- Highest-risk functions (CRAP > 30, or newly crossing that line since the last run — use
git diff <path-to-METRICS.md>on the oldCRAP_TABLEregion if the file is tracked). - For each, whether it reads as a refactor signal (high complexity, already well-covered) or a testing-gap signal (low coverage driving the score).
- Any assertion-free tests or heavily-mocked clusters from the
QUALITYregion worth calling out. Replace the prior Findings content rather than appending — it should reflect current state, not accumulate history. Skip it only if nothing crosses a threshold worth flagging.
- Highest-risk functions (CRAP > 30, or newly crossing that line since the last run — use
- Report back concisely: whether the file changed, and if so, what moved (a new function
crossed the CRAP4J threshold of 30, coverage shifted, assertion-free-test count changed).
Don't paste the whole file into the conversation — a one- or two-line delta is enough. Use
git diff <path-to-METRICS.md>if the file is tracked, rather than re-deriving the delta by eye. - Never hand-edit content inside the
<!-- AUTOGEN:... -->regions — the script owns them and will overwrite manual edits on the next run.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

