agentleFS
foomoonfoomoon/crap-score/SKILL.md

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

  • Other versions2 projects use a version of this.

    Word for word · 0

    None found.

    Edited · 0

    None found.

    Wrote their own version · 2

    1. microsoft/testfx★ 1.1ksame name
    2. 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
  1. Very specific:

    If METRICS.md doesn't exist yet for this project, it's created with a minimal skeleton (title, methodology blurb, an empty "Findings" …

    line 25
  2. Very specific:

    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] …

    line 31
  3. Very specific:

    After the script writes the SUMMARY/QUALITY/CRAP_TABLE regions, read them and update the "## Findings" section yourself — this is not the …

    line 53
  4. Very specific:

    Don't paste the whole file into the conversation — a one- or two-line delta is enough.

    line 69
  5. Very specific:

    Never hand-edit content inside the <!-- AUTOGEN:...

    line 73

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

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

  1. Run:
    python3 ~/.claude/skills/crap-score/scripts/regen_metrics.py [repo_root]
    Omit repo_root to auto-detect it from the current working directory (walks upward for the nearest .git or pyproject.toml). This runs the target project's test suite using its own interpreter (auto-detected from .venv/bin/python or venv/bin/python in the target repo — falls back to sys.executable if neither exists), so pytest, pytest-cov, and radon must already be installed there. This script itself only needs Python 3.11+ (for tomllib) — it doesn't need those packages in its own environment.
  2. If METRICS.md doesn'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.
  3. 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's pyproject.toml:
    [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
    Without this, source dirs are found by looking for __init__.py-containing directories one or two levels deep (skipping tests/, .venv/, node_modules/, build/, etc.); test files are found by recursively globbing test_*.py/*_test.py; METRICS.md defaults to living alongside the most common test directory found.
  4. Known limitation: auto-detection resolves one project root per run — a monorepo with a nested Python subproject (e.g. backend/ with its own pyproject.toml, imported via from backend.x import y rather than self-relative imports, sitting next to a non-Python frontend/) needs the [tool.crap_score] override in the outer pyproject.toml (there usually isn't one yet — create it) rather than relying on auto-detection to guess which directory is "the" project root.
  5. After the script writes the SUMMARY/QUALITY/CRAP_TABLE regions, read them and update the "## Findings" section yourself — this is not the end user's manual upkeep, and it's deliberately outside the AUTOGEN markers because it needs judgment a static script can't apply. Write a handful of concrete, actionable bullets, each referencing a specific file:line:
    • Highest-risk functions (CRAP > 30, or newly crossing that line since the last run — use git diff <path-to-METRICS.md> on the old CRAP_TABLE region 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 QUALITY region 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.
  6. 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.
  7. Never hand-edit content inside the <!-- AUTOGEN:... --> regions — the script owns them and will overwrite manual edits on the next run.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.