Measure test coverage of only the lines a change adds, by joining a unified diff with a Cobertura XML or coverage.py JSON report. Use when asked for diff coverage, patch coverage, or whether the new lines of a PR are tested.
95%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
Low
Low-risk findings worth noting
Answer "are the lines this change adds actually tested?" Whole-project coverage hides a poorly tested patch; this skill measures only the added lines. The bundled script works on its own: nothing to install or build.
Produce the two inputs with the project's own tools.
git diff origin/main...HEAD > change.patch.coverage.xml) or coverage.py
JSON (coverage.json). With coverage.py: coverage run -m pytest, then
coverage xml or coverage json. Other ecosystems that can export Cobertura XML also
work.Run:
python3 scripts/diff_coverage.py --diff change.patch --coverage coverage.xml --fail-under 80Options: --format text|markdown (default text; json is also accepted) and
--fail-under PERCENT. The coverage format is detected from the first character: < is
Cobertura XML, { is coverage.py JSON.
Read the output. Text format:
src/m.py 1/2 missing 3
Diff coverage: 50.0%Each file shows covered/executable changed lines and the missing line numbers (ranges such
as 3-5, 9). The percentage is rounded half up to one decimal. With no executable changed
lines the result is "no executable changed lines" and the run passes.
Report: the overall percentage, each file with missing lines, and any file the report could
not measure. Then open the missing lines in the code and say what test would exercise each
one. Use --format markdown to paste a table into a pull request.
Exit codes: 0 passed (or no threshold), 1 below --fail-under, 2 usage, I/O or parse
error.
Details on matching, inputs and edge cases are in references/how-it-works.md.
unmeasured: check that the report was
produced from the same checkout and that source paths line up with the diff paths.+++ /dev/null) are ignored; only added lines count, not removed ones.<!DOCTYPE or <!ENTITY is refused before parsing.This skill bundles a standard-library copy of the logic implemented by the diff-coverage package: https://github.com/Trysac/u293-diff-coverage
repository in the plugin manifest, or publish from a GitHub Action to verify it.