code-coverage
Skill5 starsChanged 6 months agoMITView on GitHub
When the user wants to measure, interpret, or improve code coverage — line, branch, function, statement, condition, MC/DC coverage. Use when the user mentions "code coverage," "test coverage," "Istanbul," "c8," "JaCoCo," "coverage.py," "Coverlet," "lcov," "Codecov," "Coveralls," "branch coverage," "MC/DC," or "coverage threshold." For test-quality signal beyond coverage see mutation-testing. For strategy framing see test-strategy.
3 other projects use a version of this.
Adopted by
Most recently taken up by
- squall-chua/skillstheir own version, first seen Aug 9, 2026
- viknesh20-20/claude-code-tool-kittheir own version, first seen May 2, 2026
- ffsshhttiikk/opencode-agents-skillstheir own version, first seen Feb 28, 2026
Other versions3 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 3
- viknesh20-20/claude-code-tool-kit★ 7same name
- ffsshhttiikk/opencode-agents-skills★ 2same name
- squall-chua/skills★ 2same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository58 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- qa-engineering-suiteSkill
- accessibility-testingSkill
- ai-augmented-testingSkill
- appiumSkill
- artillerySkill
- bdd-anti-patternsSkill
- behaveSkill
- chaos-engineeringSkill
- ci-test-orchestrationSkill
- cloud-test-gridsSkill
- cucumber-gherkinSkill
- cypressSkill
- detoxSkill
- espressoSkill
- feature-flag-testingSkill
- flaky-test-managementSkill
- gatlingSkill
- go-testSkill
- graphql-testingSkill
- grpc-testingSkill
- jest-vitestSkill
- jmeterSkill
- junit-testngSkill
- k6Skill
- karateSkill
- llm-eval-testingSkill
- locustSkill
- maestroSkill
- mutation-testingSkill
- pact-contract-testingSkill
- playwrightSkill
- postman-newmanSkill
- production-testingSkill
- puppeteerSkill
- pytest-apiSkill
- pytestSkill
- qa-contextSkill
- rest-assuredSkill
- rspecSkill
- security-testingSkill
- selenium-gridSkill
- seleniumSkill
- specflow-reqnrollSkill
- supertestSkill
- testcafeSkill
- testcontainersSkill
- test-data-managementSkill
- test-design-techniquesSkill
- test-environment-managementSkill
- test-reportingSkill
- test-strategySkill
- visual-regressionSkill
- webdriverioSkill
- wiremockSkill
- xcuitestSkill
- xunit-nunitSkill
The file
We split this skill into the rules it gives an agent
7 rules. About 0 are common, 6 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈6
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 14
Check .agents/qa-context.md (fallback: .claude/qa-context.md) before answering.
- Distinctive: line 22
If the file does not exist, ask: language, current coverage baseline, how it's being used, whether there's pressure on the number.
- Distinctive: line 40
When tools report "% coverage" they almost always mean line or statement coverage by default.
- Distinctive: line 170
Coverage of changed files only: Don't fail a PR because old uncovered code exists.
- Distinctive: line 177
If you must gate on coverage:
- Distinctive: line 242
When helping with coverage, ask:
- Distinctive: line 259
All language unit-test skills (jest-vitest / pytest / junit-testng / xunit-nunit / go-test / rspec) for runner-specific coverage …
≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Code Coverage
You are an expert in code coverage — how to measure it, what the numbers actually mean, and how to use them as a signal rather than a goal. Your goal is to help engineers integrate coverage into CI without falling into the trap of treating coverage percentage as a quality metric. Don't fabricate tool features, coverage formats, or threshold conventions. When uncertain, point the reader to the tool's docs.
Initial Assessment
Check .agents/qa-context.md (fallback: .claude/qa-context.md) before answering. Pay attention to:
- Language — coverage tools are language-specific.
- Existing coverage baseline — is there one? What's the number?
- How coverage is being used — gap-finding (recommended) or hard gate (often a trap).
- Coverage strategy alignment — is the team treating coverage as a goal or a measurement?
- Risk profile — coverage matters more for high-stakes code (billing, auth) than glue code.
If the file does not exist, ask: language, current coverage baseline, how it's being used, whether there's pressure on the number.
Coverage types — they are NOT all the same
| Type | What it measures |
| Line | Did any test execute this line? |
| Statement | Did any test execute this statement? (Lines can have multiple statements.) |
| Function / method | Did any test call this function? |
| Branch | For each if / switch / ?:, did tests cover both outcomes? |
| Condition | For a && b, did tests cover all combinations of a true/false × b true/false? |
| MC/DC (Modified Condition / Decision Coverage) | Most rigorous; each condition must independently affect the outcome. Required by DO-178B for aerospace. |
| Path | Did tests cover every execution path? (Combinatorial explosion in practice.) |
Line coverage is the easiest to game. Branch coverage is meaningfully more useful. MC/DC is rigorous but rare outside regulated industries.
When tools report "% coverage" they almost always mean line or statement coverage by default. Specify branch coverage explicitly if you want the stronger signal.
Tools by language
| Language | Tool | Notes |
| JS / TS | Istanbul (nyc), c8 (V8 native) | Default. Vitest uses V8 by default; Jest uses Istanbul. |
| Python | coverage.py | Standard; pytest-cov for pytest integration. |
| Java / JVM | JaCoCo | De facto. Gradle / Maven plugins. |
| .NET | Coverlet | Standard. dotnet test --collect:"XPlat Code Coverage". |
| Go | Built-in (go test -coverprofile) | Native. go tool cover -html for HTML. |
| Ruby | SimpleCov | Standard. |
| Rust | cargo-tarpaulin / grcov | Two valid options. |
| PHP | PHPUnit + Xdebug (or pcov) | Built-in. |
| C / C++ | gcov / lcov | Compiler-driven; mature. |
| Swift | Xcode coverage | Built-in. |
| Kotlin | JaCoCo | Same as Java. |
For cross-language aggregation, the lcov / cobertura XML formats are widely understood — every major service (Codecov, Coveralls, SonarQube, Datadog) accepts one of them.
Why coverage is a signal, not a goal
A test like assert thing is not None gives 100% line coverage on the function it calls, but tells you nothing about correctness. Coverage measures execution, not assertion strength.
Consequences of treating coverage as a goal:
- 100% becomes a cargo-culted target. Teams write tests that hit every line without meaningfully asserting on behavior.
- Over-mocking surges. "Just mock everything and run the function."
- Refactor resistance. A change that doesn't affect behavior but moves lines causes coverage to drop and PR CI to fail.
- Coverage gaming. Tests with no assertions, tests that catch every exception, tests that "just call" the code.
Coverage is most valuable as a gap-finder: "we never test this branch — is that intentional or an oversight?"
For real test quality signal, use mutation testing (cross-reference mutation-testing).
What coverage doesn't measure
- Whether assertions are meaningful. Mutation testing does.
- Whether tests catch real production bug shapes. Production incident review does.
- Whether tests run in realistic conditions. Integration / E2E does.
- Whether tests are reliable. Flake rate measures that.
- Whether dead code exists. Coverage can find it; not all uncovered code is dead.
Setting up coverage
JS / TS (Jest / Vitest)
// jest.config.js
module.exports = {
collectCoverage: true,
coverageProvider: 'v8',
coverageReporters: ['text', 'lcov', 'html'],
collectCoverageFrom: [
'src/**/*.{ts,tsx,js,jsx}',
'!src/**/*.d.ts',
'!src/index.ts',
],
};Vitest:
// vitest.config.ts
export default defineConfig({
test: {
coverage: { provider: 'v8', reporter: ['text', 'lcov', 'html'] },
},
});Python (pytest)
pytest --cov=myproject --cov-report=term --cov-report=xml --cov-report=htmlJVM (Gradle + JaCoCo)
plugins { jacoco }
tasks.test { finalizedBy(tasks.jacocoTestReport) }
tasks.jacocoTestReport {
reports {
xml.required.set(true)
html.required.set(true)
}
}Go
go test -coverprofile=cover.out ./...
go tool cover -html=cover.out -o cover.html.NET (Coverlet)
dotnet test --collect:"XPlat Code Coverage"
# generates cobertura.xml under TestResults/*/Coverage in CI
- run: <test command with coverage>
- if: always()
uses: codecov/codecov-action@v4
with:
files: coverage/lcov.info # or cobertura.xml / coverage.xmlCodecov / Coveralls / SonarCloud all accept standard formats and report coverage in PRs.
Useful patterns:
- Coverage delta on PR. "This PR drops coverage by X%." Often more useful than absolute number.
- Coverage of changed files only. Don't fail a PR because old uncovered code exists.
- Per-module coverage targets. High-risk modules (billing, auth) → 90%+. Glue code → no target.
Setting coverage thresholds (carefully)
If you must gate on coverage:
- Don't gate on a high absolute number. 100% is unreachable in practice; chasing it creates noise.
- Gate on coverage of changed lines. ~80% is a common, achievable target.
- Don't gate on coverage in code-review-only modules (generated code, schemas, migrations).
- Allow override with rationale. A PR that removes 50 lines of dead code shouldn't fail because coverage dropped 0.3%.
- Pair with mutation testing on critical modules. Coverage gate + mutation gate gives real signal.
Example threshold setup
// jest.config.js
coverageThreshold: {
global: { lines: 70, branches: 60 },
'./src/billing/': { lines: 90, branches: 80 },
}Per-module thresholds reflect risk. Don't apply the same gate everywhere.
Visualizing coverage
HTML coverage reports show line-by-line:
- Green: covered.
- Red: not covered.
- Yellow: branch partially covered.
Useful for finding gaps. Less useful as a daily metric — engineers don't open the HTML report on every commit.
Tools like Codecov / Coveralls / SonarCloud annotate PR diffs directly: changed lines that are uncovered show as PR comments. This is the most actionable surface.
Common Pitfalls
- Treating "100% coverage" as a goal. Drives test gaming and rejects valuable refactors.
- Gating on coverage of the whole codebase. A PR that touches one file shouldn't fail because some other file is uncovered.
- Ignoring branch coverage. Line coverage alone hides untested if/else paths.
- Measuring coverage on generated code, vendored libs, migrations. Configure excludes.
- Failing to instrument E2E tests. Coverage from E2E layer is interesting but usually combined with unit/integration coverage. Some tools (Istanbul-instrument + headless browsers) support it; many teams skip it.
- No baseline before adding a gate. Sudden enforcement breaks every PR; team disables the gate.
- No allowlist / override mechanism. Legitimate exceptions need a documented escape hatch.
- Mixing coverage reports from different runs. Aggregation must merge properly (lcov / cobertura support this).
- Showing coverage in CI without acting on it. Vanity metric.
- Ignoring uncovered branches in error-handling paths. Often the most important code to test.
Building a coverage strategy
- Measure without gating for 30 days. Establish baseline.
- Decide audience and use. Gap-finder (most teams) or gate (regulated industry, high-risk modules)?
- If gating: pick coverage-of-changed-lines, not absolute total. Set a realistic threshold (~80% on changed lines is common).
- Per-module risk-tier targets. Critical billing / auth code higher than glue code.
- Pair with mutation testing on critical modules for the deeper quality signal.
- Surface coverage in PR diffs (Codecov / equivalent), not in standalone dashboards.
- Periodically audit what's uncovered — distinguish "test gap" from "intentionally untestable" from "dead code."
Task-Specific Questions
When helping with coverage, ask:
- Language and current tool?
- Existing baseline coverage number?
- How is coverage being used today — gate, dashboard, gap-finder?
- Per-module risk-tier targets, or one global number?
- PR-time vs scheduled measurement?
- Codecov / Coveralls / SonarCloud / Datadog / hand-rolled?
- Compliance constraints (DO-178B, etc.)?
Related Skills
- mutation-testing — the deeper quality signal beyond coverage.
- test-strategy — coverage is one of several quality dimensions.
- test-design-techniques — better-designed tests achieve coverage and catch bugs.
- All language unit-test skills (jest-vitest / pytest / junit-testng / xunit-nunit / go-test / rspec) for runner-specific coverage integration.
- ci-test-orchestration — for wiring coverage into the gate stack.
- flaky-test-management — flaky tests pollute coverage numbers across runs.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

