AgentSkillsCN

validate-coverage-threshold

验证测试覆盖率是否达到最低阈值(默认整体覆盖率为80%,语句覆盖率为80%,分支覆盖率为75%,函数覆盖率为80%)。从coverage/coverage-summary.json或测试输出中解析覆盖率报告。返回通过/失败的状态,并附带详细指标,同时标记未被覆盖的文件。

SKILL.md
--- frontmatter
name: validate-coverage-threshold
description: Validate test coverage meets minimum thresholds (default 80% overall, 80% statements, 75% branches, 80% functions). Parses coverage reports from coverage/coverage-summary.json or test output. Returns pass/fail status with detailed metrics and identifies uncovered files.

Validate Coverage Threshold

Parses test coverage reports and validates that coverage meets minimum thresholds for quality assurance.

Usage

This skill checks test coverage data against configurable thresholds and returns structured validation results.

Default Thresholds

json
{
  "overall": 80,
  "statements": 80,
  "branches": 75,
  "functions": 80
}

Output Format

All Thresholds Met

json
{
  "status": "success",
  "coverage": {
    "overall": 87.5,
    "statements": 88.2,
    "branches": 84.1,
    "functions": 89.3
  },
  "thresholds": {
    "overall": 80,
    "statements": 80,
    "branches": 75,
    "functions": 80
  },
  "passed": true,
  "failures": [],
  "canProceed": true
}

Below Threshold

json
{
  "status": "warning",
  "coverage": {
    "overall": 75.3,
    "statements": 76.1,
    "branches": 72.8,
    "functions": 78.2
  },
  "thresholds": {
    "overall": 80,
    "statements": 80,
    "branches": 75,
    "functions": 80
  },
  "passed": false,
  "failures": [
    "overall:75.3%<80%",
    "statements:76.1%<80%"
  ],
  "uncoveredFiles": [
    {"file": "src/utils/helpers.ts", "coverage": 45.2}
  ],
  "canProceed": false,
  "details": "Coverage below threshold: 4 metric(s) failed"
}

When to Use

  • Quality gate validation (Conductor Phase 3)
  • After running tests with coverage
  • Pre-commit checks
  • CI/CD pipeline validation

Coverage Data Sources

  • coverage/coverage-summary.json (preferred - c8/Istanbul)
  • Test output text (fallback)

Requirements

  • Coverage data generated by test run
  • Run npm run test -- --coverage first