agentleFS
csmarvzcsmarvz/claude-resume/.claude/skills/crap-score/SKILL.md

crap-score

Skill4 starsChanged 33 days agoMITView on GitHub

Use when changing Go code in claude-resume and checking whether a function is too complex for its test coverage, when asked for CRAP scores, or when looking for the riskiest functions to test or split.

4 other projects use a version of this.

Adopted by

Most recently taken up by

  • Other versions4 projects use a version of this.

    Word for word · 0

    None found.

    Edited · 0

    None found.

    Wrote their own version · 4

    1. microsoft/testfx★ 1.1ksame name
    2. VincentH-Net/dotnet-agentic-engineering★ 11same name
    3. foomoon/crap-score★ 0same name
    4. przemyslawkowalski-dashdevs/claude-code-setup★ 0same 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

1 rule. 0 are common, 1 is distinctive, and 0 are very specific to this project.

  • 0

    Common

    Most of the 4 edited versions we read keep these.

  • 1

    Distinctive

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Run it before the change and keep the rows for the functions you will touch.

    line 30

“Common” is measured: kept by at least 6 in 10 of the 4 edited versions of this file we could read. “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

CRAP score

tools/crap gives each function in the main package a CRAP score:

CRAP = CC² × (1 − coverage)³ + CC

CC is cyclomatic complexity: 1, plus one for each if, for, range, case or select clause other than default, && and ||. The rules are the Go rules of crapper. Coverage is the function's statement coverage from go test.

Below 5 is low risk, 5 to 30 is worth a look, and above 30 is complex and under-tested.

Run

From the repository root:

go run ./tools/crap

It runs go test -coverprofile on the main package, so the tests must pass; on a failure it prints the test output and exits 1. The table goes to stdout, worst score first, with the go test output on stderr. Only files that build on the current OS are scored: sys_windows.go on Windows, sys_unix.go elsewhere.

Using the scores

  1. Run it before the change and keep the rows for the functions you will touch.
  2. Make the change, run it again, and compare those rows.
  3. A function you touched that is at 10 or more: test it, split it, or both. A test calls the function the way its caller does and checks the result the caller sees.
  4. Report the before and after scores of the touched functions in the PR description.

There is no CI threshold. The 44 functions at 10 or more on 0.0.13-alpha (measured on Linux) predate the tool, so lower them when you are already changing them rather than in a separate cleanup.

Functions that read the terminal (pick, command) or the network (update, download) score high because tests cannot reach them. Lowering those means moving the logic into functions that take plain values and return results, then testing those.

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.