mcpField
C
coverage-guard

coverage-guard

github.com/proffesor-for-testingTesting & quality51961 installsUpdated today
Repository

About coverage-guard

A testing skill that checks coverage after test commands and warns when it falls below configured thresholds. It is intended for teams that want coverage changes surfaced without blocking test execution.

Key features

  1. 01Checks coverage after test runs
  2. 02Compares results with configured thresholds
  3. 03Warns when coverage decreases
  4. 04Supports configurable coverage commands

Use cases

  1. 01Spotting a coverage drop after a test run
  2. 02Monitoring statement, branch, function, and line thresholds

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/proffesor-for-testing/agentic-qe --skill coverage-guard

After installing, type/coverage-guardin Claude Code to confirm it loaded.

Bundled filesscripts/check-coverage.sh

Details

From the project README

Coverage Guard Mode

When activated, checks coverage after test runs and warns if it drops below the configured threshold.

What It Does

After any test execution (via Bash tool), compares coverage to the threshold in config.json. Warns (doesn't block) if coverage decreased.

Activation

/coverage-guard

Configuration

Edit config.json in this skill directory to set thresholds:

{
  "thresholds": {
    "statements": 80,
    "branches": 70,
    "functions": 75,
    "lines": 80
  },
  "coverageCommand": "npx jest --coverage --coverageReporters=json-summary",
  "coverageFile": "coverage/coverage-summary.json"
}

Hook Configuration

{
  "hooks": {
    "PostToolUse": [
      {
        "matcher": "Bash",
        "hook": ".claude/skills/coverage-guard/scripts/check-coverage.sh",
        "condition": "command contains 'jest' OR command contains 'vitest' OR command contains 'npm test'"
      }
    ]
  }
}

Enforcement Logic

#!/bin/bash
# check-coverage.sh
COVERAGE_FILE="coverage/coverage-summary.json"
THRESHOLD=80

if [ -f "$COVERAGE_FILE" ]; then
  STATEMENTS=$(jq '.total.statements.pct' "$COVERAGE_FILE")
  BRANCHES=$(jq '.total.branches.pct' "$COVERAGE_FILE")

  if (( $(echo "$STATEMENTS < $THRESHOLD" | bc -l) )); then
    echo "WARNING: Statement coverage ($STATEMENTS%) below threshold ($THRESHOLD%)"
    echo "Coverage dropped — check which files lost coverage."
  fi

  if (( $(echo "$BRANCHES < 70" | bc -l) )); then
    echo "WARNING: Branch coverage ($BRANCHES%) below 70%"
  fi
fi

Gotchas

  • Coverage check runs AFTER the test command — if tests crash, no coverage report is generated
  • Coverage-summary.json must be configured as a reporter — default Jest config may not include it
  • Threshold comparisons use floating point — 79.999% will trigger below 80% threshold
  • Branch coverage is typically 10-15% lower than line coverage — set thresholds accordingly

Comments

Markdown supported