Command Palette

Search for a command to run...

UnylyUnyly
Back to skills

coverage-diff-reporter

FreeNo executable scriptsNot checked

Use when a pull request needs readable coverage feedback rather than one total. Compares current and baseline coverage (LCOV, Cobertura or JSON) and reports…

testlandby testland★ 18 GitHub stars

About this skill

coverage-diff-reporter

Overview

An aggregate coverage number hides where coverage moved: -0.4pp overall can be one file at -12pp. This skill turns two parsed coverage runs (PR head and merge-target baseline) into a per-file delta report and a one-line PR summary. It does not decide pass/fail; the gate in lcov-analysis does that. This skill makes the diff legible.

Inputs: the current run's LCOV or Cobertura file and the baseline's. Output: diff.md (full report) posted as one sticky PR comment.

Step 1 - Parse both runs with the same parser

Use the parser from lcov-analysis (its "Parse" section; Cobertura parser in its references/cobertura.md), saved in your repo as scripts/parse_lcov.py or scripts/parse_cobertura.py. Each emits a list of per-file dicts with path, lf, lh, brf, brh - the LCOV LF/LH (lines found / hit) and BRF/BRH (branches found / hit) counters ([lcov][lcov]).

Existing reporter Use
LCOV .info lcov-analysis LCOV parser
Cobertura XML lcov-analysis Cobertura parser (references/cobertura.md)
Jest / V8 coverage Emit LCOV first (jest --coverageReporters=lcov)
JaCoCo XML jacoco-analysis, or convert to Cobertura
coverage.py coverage xml (Cobertura) or coverage lcov (LCOV)

Run the same parser on both files, so both sides use identical path and counting rules.

Step 2 - Get the baseline

Pattern A (default) - cached artifact. The merge target's last green CI run uploads its coverage file; the PR job downloads it with [dawidd6/action-download-artifact][dl] (workflow, branch and name select the run and artifact; if_no_artifact_found defaults to fail):

- name: Restore baseline
  uses: dawidd6/action-download-artifact@v3
  with:
    workflow: coverage.yml
    branch: main
    name: coverage-baseline
    path: baseline/
    if_no_artifact_found: warn

- name: Parse both runs
  run: |
    python scripts/parse_lcov.py coverage/lcov.info > current.json
    python scripts/parse_lcov.py baseline/lcov.info > baseline.json

Pattern B (fallback) - recompute. Check out the merge target, run the tests with coverage, save the file, then check out the PR head and run again. About twice the runtime; use it when the artifact has expired or the baseline run is not deterministic.

Step 3 - Check the inputs before diffing

Stop and fix the inputs if any check fails; a diff of bad inputs is worse than no report.

  1. Both JSON files exist and hold at least one file entry. If the baseline is missing (Pattern A warned), post "no baseline - report skipped" instead of a diff that shows every file as new.
  2. Paths use the same root on both sides. If more than half of the current files have no baseline match, the paths differ (absolute vs repo-relative, different checkout dirs): strip the common prefix and re-run.
  3. Record the baseline commit and its age; print both in the report header (Step 6).

Step 4 - Compute the per-file delta

# scripts/coverage_diff.py
def pct(hit, found):
    return round(100.0 * hit / found, 1) if found else None

def delta(now, then):
    return None if now is None or then is None else round(now - then, 1)

def compute_diff(current, baseline):
    base_idx = {f['path']: f for f in baseline}
    cur_paths = {f['path'] for f in current}
    rows = []
    for f in current:
        b = base_idx.get(f['path'])
        line_now, branch_now = pct(f['lh'], f['lf']), pct(f['brh'], f['brf'])
        line_then = pct(b['lh'], b['lf']) if b else None
        branch_then = pct(b['brh'], b['brf']) if b else None
        rows.append({'path': f['path'], 'is_new': b is None,
                     'line_now': line_now, 'line_delta': delta(line_now, line_then),
                     'branch_now': branch_now, 'branch_delta': delta(branch_now, branch_then)})
    for path, b in base_idx.items():          # deleted files
        if path not in cur_paths:
            rows.append({'path': path, 'is_deleted': True,
                         'line_then': pct(b['lh'], b['lf'])})
    return rows

Step 5 - Classify and sort

NEW_FILE_MIN, REGRESSION_PP, NOISE_PP = 80, -5, 0.5   # tune per repo

def classify(row):
    if row.get('is_deleted'):
        return 'deleted'
    if row['is_new']:
        return 'new_below_threshold' if (row['line_now'] or 0) < NEW_FILE_MIN else 'new_ok'
    d = row['line_delta']
    if d is None or abs(d) < NOISE_PP:
        return 'unchanged'
    return 'regressed' if d <= REGRESSION_PP else 'declined' if d < 0 else 'improved'

Sort regressions by line_delta ascending (largest drop first) and put new below-threshold files at the top. Leave unchanged rows out of the tables; report

Full SKILL.md on GitHub

Install coverage-diff-reporter 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.

Bundled files

.tessl-plugin/plugin.json

FAQ

What does the coverage-diff-reporter skill do?

Use when a pull request needs readable coverage feedback rather than one total. Compares current and baseline coverage (LCOV, Cobertura or JSON) and reports per-file line and branch deltas, new files and hidden drops, with a one-line summary for the PR comment.

How do I install the coverage-diff-reporter 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 coverage-diff-reporter skill run scripts?

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

Related skills

Compare coverage-diff-reporter with