AgentSkillsCN

coverage-check

利用 git 和文件系统启发式方法进行轻量级测试覆盖率分析。识别无对应测试文件的源文件。无需专门的覆盖率工具——只需通过模式匹配即可适用于任何项目。此项 CHECK 技能类似于文档验证中的 validate-docs。

SKILL.md
--- frontmatter
name: coverage-check
description: Lightweight test coverage analysis using git and file system heuristics. Identifies source files with no corresponding test file. No coverage tools required — works on any project by pattern matching. The CHECK skill for testing, analogous to validate-docs for documentation.
license: MIT
compatibility: opencode
metadata:
  category: testing
  phase: check

Skill: Coverage Check

What This Skill Does

Performs a fast, lightweight coverage check by matching source files against test files using naming conventions. No coverage tools, no test execution, no source file reads — just file system patterns.

Answers: "Which source files have no corresponding test file?"

When to Use

  • At session start (via smart-start) to assess test health
  • Before add-tests to know where to focus
  • As a quick health check: "how's our test coverage?"

Do NOT use this for detailed coverage analysis — use actual coverage tools for that. This is a fast heuristic.

Execution Model

  • Always: the primary agent runs this skill directly.
  • Token budget: ~1-2k tokens. This is intentionally minimal.
  • Output: chat-based coverage report.

Workflow

Step 1: Detect Test Patterns

Identify how the project names test files:

bash
# Find test files and extract naming pattern
find . -name "*.test.*" -o -name "*.spec.*" -o -name "test_*" | head -5

Common patterns:

PatternConvention
src/foo.tssrc/foo.test.tsCo-located
src/foo.tstests/foo.test.tsSeparate directory
src/foo.ts__tests__/foo.test.tsJest convention
src/foo.pytests/test_foo.pyPython convention
src/foo.gosrc/foo_test.goGo convention

Step 2: Map Source to Tests

For each source file, check if a corresponding test file exists:

bash
# Example for Python
for src in $(find src -name "*.py" ! -name "__init__.py" ! -path "*/test*"); do
    base=$(basename "$src" .py)
    if ! find tests -name "test_${base}.py" | grep -q .; then
        echo "UNCOVERED: $src"
    fi
done

Step 3: Generate Report

markdown
## Coverage Check

| Metric | Value |
|--------|-------|
| Source files | N |
| Test files | N |
| Coverage ratio | N% |

### Uncovered Files (no test file found)

| File | Module | Risk |
|------|--------|------|
| src/auth/login.ts | auth | High (handles user input) |
| src/utils/format.ts | utils | Low (pure utility) |

### Well-Covered Modules
- api/ (8/8 files have tests)
- models/ (5/5 files have tests)

### Recommendation
Focus `add-tests` on: auth/login.ts, data/repository.ts

Rules

  1. No test execution: this skill never runs tests. It only checks file existence.
  2. Heuristic, not precise: file-based matching is approximate. A test file existing doesn't mean it has good coverage. Flag this in the report.
  3. Fast: should complete in under 5 seconds. No source file reads.
  4. Convention-aware: detect the project's test naming convention before matching. Don't assume.
  5. No built-in explore agent: do NOT use the built-in explore subagent type.