Command Palette

Search for a command to run...

UnylyUnyly
Back to skills

test-coverage

FreeNo executable scriptsNot checked

Raise measured test coverage where it matters most, by writing tests for the least-covered, most-changed code and keeping only tests that pass strict…

motlinby motlin★ 20 GitHub stars

About this skill

Test Coverage

Write tests that cover behavior nobody tested, in the code that changes most. Coverage is the measure, not the goal: a test that raises the number without checking behavior is worse than no test, because it hides the gap.

Load code:test-assertions, code:test-data and code:test-speed alongside this skill. New tests follow their shape: strict whole-value assertions, self-evidently fake literals, and extending an existing test file before creating one.

Resolve <plugin-root> first: in Claude Code use ${CLAUDE_PLUGIN_ROOT}; in Codex use the plugin root that contains this skills/test-coverage/SKILL.md file. The scripts below need Python 3.9 or later.

Arguments

  • Scope: a file, a directory, or the whole repo (the default). Only files in scope are ranked.
  • unattended: passed by callers such as burn. An unattended run asks the user nothing. Every question it would have asked becomes a queued finding instead (see Report).

Measure the baseline

Detect the coverage tooling, then run it once and save the normalized report:

python3 <plugin-root>/scripts/coverage_baseline.py --root . detect
python3 <plugin-root>/scripts/coverage_baseline.py --root . run > "$WORKDIR/coverage-before.json"

detect recognizes Vitest, Jest, pytest-cov, Go, cargo tarpaulin, JaCoCo through Maven or Gradle, plus any just coverage recipe that writes coverage/lcov.info, and prints the command it would run. Pass --ecosystem <name> to run to pick one when several are detected. Put $WORKDIR outside the repository so reports are never committed.

When the project uses a tool detect does not know, or needs different flags, run the project's own coverage command and normalize what it writes with coverage_baseline.py parse --format lcov|cobertura|gocover|jacoco <report>.... When the project has no coverage provider at all, add one temporarily, and revert the dependency and lockfile changes before committing. An interactive run asks before adding one; an unattended run queues the question and stops.

The baseline must pass. If the suite fails before any change, stop and report it: this skill never fixes a broken build.

Pick targets

Rank files by churn times the uncovered share:

python3 <plugin-root>/scripts/churn_rank.py "$WORKDIR/coverage-before.json" --root . --paths <scope>...

The script skips generated, vendored, test, trivial and fully covered files, and files with no commits in the window (--since, default one year), and lists each skip with its reason. Work through the targets from the top.

Within a target file, the unit of work is the smallest public function or class that encloses uncovered or partially covered lines, about 50 lines at most. Split a larger unit by its public methods. Show the agent writing the tests that unit's source with its coverage tags, plus the existing test file for it so new tests match its style:

python3 <plugin-root>/scripts/coverage_baseline.py --root . annotate "$WORKDIR/coverage-before.json" <path>

! marks an uncovered line and ~ a line with an untaken branch. Without these hints, models write many more tests and most of them add no coverage.

Write the tests

Test the unit's public behavior: given these inputs, this output or this observable effect. Add new cases to an existing test file that already covers the area; create a test file only when none fits, at the lowest level of the pyramid that proves the behavior.

Never do any of these:

  • write a test without assertions, a test that only calls getters, or a snapshot-only test;
  • mock the unit under test;
  • add coverage-ignore comments, or lower a coverage threshold;
  • edit or delete an existing test;
  • change production code, except a tiny refactor that makes a unit testable, which the report flags.

When covering a line would need one of these, skip the target and record why.

Accept or reject each test

Keep a new test only when all of these hold. Check them in this order, and drop the test at the first failure:

  • It builds.
  • It passes.
  • It passes 5 repeated runs, plus a random-order or isolated run where the framework supports one. Repeating runs to find flakiness is measurement, not a retry.
  • It lowers the target's uncovered or partially covered lines: rerun coverage for the test file and check with coverage_baseline.py compare.
  • It is not a duplicate of an existing test: it checks something no existing test already checks.

Do not rewrite a rejected test and try again. Record the target as skipped with the reason (randomness, I/O, unreachable code, a failed acceptance check) and move on to the next target. Studies of generated tests found that only about a quarter raise coverage, so rejection is the normal case and these checks do real work.

Gate the result

When the targets are done, run the full suite and coverage again, then compare against the baseline:

python3 <plugin-root>/scripts/coverage_baseline.py --roo
Full SKILL.md on GitHub

Install test-coverage in Claude Code & Claude Desktop

Sign up to install this skill

Create a free account to reveal the install command and save the skill to your library.

  • Reveal the one-line install command
  • Save skills to your synced library
  • Get notified when skills update
Sign up freeI already have an account

Allowed tools

Tools this skill is permitted to call.

No restriction — this skill can use any tool.

FAQ

What does the test-coverage skill do?

Raise measured test coverage where it matters most, by writing tests for the least-covered, most-changed code and keeping only tests that pass strict acceptance checks. Use when the user asks to grow, raise, or improve test coverage for a file, a directory, or the whole repo, or when a caller such as burn runs it unattended.

How do I install the test-coverage skill?

Copy the skill folder into ~/.claude/skills (the Claude Code tab above does this in one command), or install it as a plugin.

Does the test-coverage skill run scripts?

No, this skill is instructions only (SKILL.md) with no executable scripts.

Related skills

Compare test-coverage with