agentleFS
nfeuernfeuer/project-foundation-kit/.claude/skills/coverage-ratchet/SKILL.md

coverage-ratchet

Skill0 starsChanged 4 months agoMITView on GitHub

Prevent test coverage from silently eroding — compare the current run against a stored baseline, fail if it dropped, and offer to lock in a higher baseline when it rose

1 other project uses a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

4 rules. About 0 are common, 2 are distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    If the file does not exist, treat baseline as 0.0 and proceed — the first run will create it.

    line 27
  2. Distinctive:

    If coverage dropped, the author must either:

    line 64
  3. Distinctive:

    Add tests to restore it (preferred), or

    line 65
  4. Very specific:

    Do not silently lower the baseline.

    line 70

≈ “Common” is an estimate: at least 1 in 5 of the 364,980 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

Coverage Ratchet

Coverage numbers that can only go up (or stay flat) are a one-way gate. This skill reads the project's baseline from .claude/kit.yaml and the stored baseline file, runs the test suite with coverage, and enforces the floor. It does not reason about which paths are covered — use the test-gap-analyzer agent for that. This enforces the number. It does not edit source or tests; its only write is the sanctioned baseline-file update in step 3, made only with author confirmation.

Workflow

1. Read the baseline path

Open .claude/kit.yaml and read capabilities.coverage.baseline_file (default: .coverage-baseline). That file contains a single float, e.g. 82.4.

If the file does not exist, treat baseline as 0.0 and proceed — the first run will create it.

2. Run the test suite with coverage

# Python / uv — adjust to your toolchain (kit.yaml → toolchain.test)
uv run pytest tests/unit/ -m "not slow and not llm" \
  --cov=src --cov-report=term-missing --cov-report=json -q

Parse the total line coverage percentage from coverage.json → .totals.percent_covered (or from the terminal summary line TOTAL ... XX%).

3. Compare and decide

OutcomeAction
Current < baselineFAIL — report the delta; do not update the baseline. List files with the largest drops to guide the author.
Current == baselinePASS — no action needed.
Current > baselinePASS — offer to ratchet the baseline UP to the new value. Never lower it automatically.

Strictness (gates.strictness in kit.yaml, see docs/PROFILE.md): at prototype, a drop is reported as ADVISORY instead of FAIL and does not block the PR — the numbers are informational until there is a baseline worth defending. At production, ratchet_enabled: true with a missing baseline file is a FAIL rather than a first-run bootstrap — generate the baseline before gating.

To ratchet up: write the new percentage (two decimal places) to the baseline file and stage it:

echo "87.30" > .coverage-baseline
git add .coverage-baseline

Confirm with the author before committing a baseline change — it's a deliberate policy update, not a mechanical fix.

4. Coverage drops are always intentional or a bug

If coverage dropped, the author must either:

  • Add tests to restore it (preferred), or
  • Explicitly acknowledge that the deleted/changed code was over-counted and the real-world coverage is unchanged — in which case update the baseline with a commit message explaining why.

Do not silently lower the baseline. Do not bypass with # pragma: no cover without a comment explaining why.

Notes

  • This skill complements test-gap-analyzer, which reasons about meaningful gaps (untested branches, missing edge cases). Run that agent after this one passes to catch coverage that is numerically present but logically shallow.
  • Baseline file path is read from .claude/kit.yaml every run, so changing the project's coverage configuration requires updating kit.yaml, not this skill.

Output

## Coverage Ratchet

- Current:   <XX.XX %>
- Baseline:  <XX.XX %> (from <.coverage-baseline>)
- Delta:     <+N.NN % | -N.NN % | 0.00 %>
- Verdict:   PASS | FAIL — coverage dropped N.NN % below baseline

Ratchet action: <none | offered to raise baseline to XX.XX %>

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.