agentleFS
jaktestowacjaktestowac/awesome-copilot-for-testers/skills/verifying-change-coverage/SKILL.md

verifying-change-coverage

Skill118 starsChanged 2 months agoMITView on GitHub

Verifies that the lines and branches a change actually touched are executed by tests, using LCOV or Cobertura diff coverage instead of whole-repo percentages, and escalates uncovered high-risk changes into a blocking finding. Use when a pull request needs a coverage gate that unrelated tests cannot satisfy, when total coverage looks healthy but the diff is untested, when wiring diff coverage into CI, or when someone claims a change is covered because the suite is green.

We split this skill into the rules it gives an agent

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

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈4

    Distinctive · estimate

    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:

    Use this skill to answer one question honestly: were the lines this change introduced actually executed by a test?

    line 10
  2. Distinctive:

    If no artifact can be produced: stop and say so. Report static linkage instead, labelled as static linkage, and state what it cannot tell …

    line 57
  3. Distinctive:

    Never hand over a raw list.

    line 74
  4. Distinctive:

    every uncovered group is classified and judged, not listed raw

    line 152

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

Verifying Change Coverage

Use this skill to answer one question honestly: were the lines this change introduced actually executed by a test?

Repo-wide coverage cannot answer it. A repo at 84% can merge an untested payment path and stay at 84%, because a big denominator absorbs a small numerator. Diff coverage changes the denominator to the lines you just wrote, which is the only denominator that maps to the risk you just added.

The distinction that runs through this skill: configured is not verified. A test runner in package.json proves the practice exists. Executed lines prove this change was tested. Report which of the two you measured.

When to Use

  • a PR gate needs a coverage signal that cannot be gamed by unrelated tests
  • total coverage is stable but defects keep escaping in new code
  • diff coverage has to be wired into CI for the first time
  • a reviewer needs to know which specific new lines nothing executes
  • an agent wrote tests and someone needs to know whether they exercise the new code
  • coverage numbers are being quoted in a release decision and nobody knows what they measure

Operating Principles

  • Executed lines, not configured tools. The whole point. Say plainly which one you have.
  • No artifact, no verdict. Without a coverage report you have static linkage - "a test file exists that imports this module" - which is weaker evidence and must be labelled as such. Never present it as coverage.
  • Branches matter more than lines on changed code. New code is where new conditionals live. A line hit once with the if never taken is half-tested.
  • Uncovered is a question, not a verdict. Some uncovered lines are fine: logging, type guards, unreachable defaults. The output is a list of uncovered changed lines with a judgement per group, not a percentage with a pass stamp.
  • Coverage proves execution, never correctness. An assertion-free test covers everything and verifies nothing. Pair this with unslop-tests - a diff-coverage gate is exactly the pressure that produces coverage theatre.
  • Escalate by risk, not by count. Three uncovered lines in auth outrank thirty in a formatter.
  • The gate belongs on changed lines only. Demanding a repo-wide floor on a legacy codebase produces a permanently red gate that gets disabled within a month.

Workflow

Phase 0: Get the two inputs

The changed lines.

git diff <base>...HEAD --unified=0 -- '***.ts' '***.tsx'

--unified=0 gives added-line ranges with no context, which is what you want to intersect against coverage. Keep the file → line-numbers map; discard removed lines, generated files, and anything the contract excludes.

The coverage artifact. Produce one if it does not exist:

npx vitest run --coverage --coverage.reporter=lcov   # → coverage/lcov.info
npx jest --coverage --coverageReporters=lcov
npx playwright test    # + c8/istanbul instrumentation for E2E coverage

See ./resources/coverage-artifacts.md for the formats, the merge problem across suites, and the monorepo path pitfalls.

If no artifact can be produced: stop and say so. Report static linkage instead, labelled as static linkage, and state what it cannot tell you. Then make producing an artifact the first remediation item - this is the single highest-leverage change to a coverage story.

Phase 1: Intersect

For each changed source file, intersect its added-line numbers with the executed lines in the report. Produce, per file:

  • changed lines - added or modified executable lines (exclude blank lines, comments, pure type declarations, and import statements)
  • covered - changed lines the report marks as executed at least once
  • uncovered - changed lines with zero hits
  • partial branches - changed lines with branch data where at least one path was never taken

Diff coverage = covered ÷ changed executable lines, per file and overall. Compute branch coverage on changed lines separately; do not average it into the line number.

The exclusions matter and are the most common source of a wrong figure - see ./resources/coverage-artifacts.md for what counts as an executable line in TypeScript once it has been compiled or transformed.

Phase 2: Classify each uncovered group

Never hand over a raw list. Group contiguous uncovered lines and judge each group:

ClassWhat it isAction
Untested logicbranches, calculations, validation, error pathswrite the test - this is the finding
Untested integrationcode only reachable with a real dependencyintegration test, or a documented exception
Defensivedefault: on an exhaustive switch, never guards, invariant throwsacceptable; record why
Instrumentationlogging, metrics, tracing callsacceptable
Unreachabledead codedelete it rather than test it
Hard to reachneeds an exotic environment or a failure that cannot be simulatedexception with an owner and an expiry

The first two are findings. The rest are exceptions and must be recorded, not silently subtracted - see ./resources/exceptions-and-thresholds.md.

Phase 3: Set the verdict

Combine diff coverage with the risk tags from scoping-change-relevance:

ConditionVerdict
Changed lines below threshold and the file carries an escalation tag (auth, critical-path, db-migration, new-endpoint)BLOCK
Changed lines below threshold on ordinary sourceWARN
Threshold met but changed branches materially uncoveredWARN
Threshold met, uncovered lines all classified as acceptable exceptionsOK with the exceptions listed
No coverage artifact availableINFO - static linkage only, artifact required

The escalation rule is the reason this beats a flat percentage: 70% on a logging module and 70% on session handling are not the same result, and one number cannot say so.

Phase 4: Report

Report per file, worst first: changed lines, diff coverage, branch coverage on changed lines, and the uncovered groups with their class and a one-line judgement. Point at exact line ranges - src/pricing.ts:142-149 - so the fix needs no hunting.

Finish with the two sentences that make the report honest:

  1. What this measured: executed lines on the diff, from <artifact>, produced by <which suites>.
  2. What it did not measure: whether the executing tests assert anything meaningful.

Wiring It Into CI

./resources/ci-wiring.md has working GitHub Actions and GitLab CI jobs, the base-ref fetch depth that trips everyone up on the first attempt, artifact merging across suites, and the sticky-PR-comment pattern.

Three rules for the gate itself:

  • Gate on changed lines, never on a repo-wide floor.
  • Fail loudly or not at all. || true on a coverage step is worse than no gate, because it reports green.
  • Ship the gate as a warning for one iteration, then turn it blocking. A gate introduced blocking on a legacy repo gets removed; one introduced as a warning gets fixed.

Common Failure Modes

  • Quoting repo coverage in a change conversation. The single most common error, and the reason untested code merges into well-covered repos.
  • Counting non-executable lines. Imports, types, and interfaces inflate the denominator and hide real gaps.
  • One suite's artifact, many suites' tests. Unit-only LCOV makes integration-covered code look uncovered. Merge, or say which suites the number represents.
  • Monorepo path mismatch. Relative paths in the report that do not match the paths in the diff produce 0% coverage and a fake emergency.
  • Chasing the number. A gate met by asserting nothing. This is the predictable failure of any coverage gate; read unslop-tests before celebrating.
  • Silent /* istanbul ignore */. An exclusion with no reason and no owner is a waiver that skipped the register.
  • Treating uncovered as automatically bad. Uncovered logging lines are fine. Reporting them as findings trains people to ignore the report.

Resource Map

  • ./resources/coverage-artifacts.md - LCOV and Cobertura formats, generating them per runner, merging across suites, what counts as an executable line, monorepo path pitfalls
  • ./resources/exceptions-and-thresholds.md - thresholds by profile, legitimate exception classes, how to record an exclusion with an owner and an expiry
  • ./resources/ci-wiring.md - GitHub Actions and GitLab CI jobs, base-ref fetching, artifact merge, sticky PR comment, warn-then-block rollout

Related Skills

  • scoping-change-relevance - supplies the risk tags that turn a below-threshold result into BLOCK rather than WARN
  • unslop-tests - the necessary counterweight: coverage proves execution, this proves the tests assert something
  • writing-unit-tests - when the finding is untested logic and tests have to be written
  • deriving-a-quality-contract - where the diff-coverage threshold for this project is set
  • governing-quality-waivers - when an uncovered area needs a recorded, dated exception
  • analyzing-quality-metrics - for coverage's caveats as a metric and what to report alongside it

Definition of Done

This skill is complete when:

  • the changed-line set and the coverage artifact are both identified, with the suites the artifact represents
  • diff coverage is computed on executable changed lines only, per file and overall
  • branch coverage on changed lines is reported separately from line coverage
  • every uncovered group is classified and judged, not listed raw
  • the verdict accounts for the risk tags of the files involved, not only the percentage
  • exceptions are recorded with a reason and an owner, never silently excluded
  • the report states what was measured and, explicitly, that coverage does not prove correctness

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.

Reviews can't be read right now.

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.