analyzing-test-coverage
Analyze code coverage metrics and identify untested code paths. Use when analyzing untested code or coverage gaps. Trigger with phrases like "analyze coverage", "check test coverage", or "find untested code".
Best use case
analyzing-test-coverage is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Analyze code coverage metrics and identify untested code paths. Use when analyzing untested code or coverage gaps. Trigger with phrases like "analyze coverage", "check test coverage", or "find untested code".
Teams using analyzing-test-coverage should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/analyzing-test-coverage/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How analyzing-test-coverage Compares
| Feature / Agent | analyzing-test-coverage | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Analyze code coverage metrics and identify untested code paths. Use when analyzing untested code or coverage gaps. Trigger with phrases like "analyze coverage", "check test coverage", or "find untested code".
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
Related Guides
AI Agents for Coding
Browse AI agent skills for coding, debugging, testing, refactoring, code review, and developer workflows across Claude, Cursor, and Codex.
Best AI Skills for Claude
Explore the best AI skills for Claude and Claude Code across coding, research, workflow automation, documentation, and agent operations.
ChatGPT vs Claude for Agent Skills
Compare ChatGPT and Claude for AI agent skills across coding, writing, research, and reusable workflow execution.
SKILL.md Source
# Test Coverage Analyzer
## Current State
!`ls package.json pyproject.toml Cargo.toml go.mod 2>/dev/null || echo 'No project manifest found'`
!`node -v 2>/dev/null || python3 --version 2>/dev/null || echo 'No runtime detected'`
## Overview
Analyze code coverage metrics to identify untested code paths, dead code, and coverage gaps across line, branch, function, and statement dimensions. Supports Istanbul/nyc (JavaScript/TypeScript), coverage.py (Python), JaCoCo (Java), and Go coverage tools.
## Prerequisites
- Coverage tool installed and configured (Istanbul/nyc, c8, coverage.py, JaCoCo, or `go test -cover`)
- Test suite that can run with coverage instrumentation enabled
- Coverage threshold targets defined (recommended: 80% lines, 70% branches)
- Coverage output format set to JSON or LCOV for programmatic analysis
- Git history available for coverage trend comparison
## Instructions
1. Run the test suite with coverage instrumentation enabled:
- JavaScript: `npx jest --coverage --coverageReporters=json-summary,lcov`
- Python: `pytest --cov=src --cov-report=json --cov-report=term-missing`
- Go: `go test -coverprofile=coverage.out ./...`
- Java: Configure JaCoCo Maven/Gradle plugin with XML report output.
2. Parse the coverage report and extract per-file metrics:
- Line coverage percentage per file.
- Branch coverage percentage per file.
- Function coverage percentage per file.
- Uncovered line ranges (specific line numbers).
3. Identify critical coverage gaps by prioritizing:
- Files with coverage below the threshold (sort ascending by coverage %).
- Files with high complexity but low coverage (use cyclomatic complexity if available).
- Recently modified files with decreasing coverage trends.
- Public API functions and exported modules lacking any tests.
4. Analyze uncovered branches specifically:
- Find `if/else` blocks where only one branch is tested.
- Identify `switch/case` statements with missing case coverage.
- Locate error handling paths (`catch`, `except`) never exercised.
- Check `||` and `&&` short-circuit conditions.
5. Generate a prioritized action plan:
- List top 10 files needing coverage improvement with specific line ranges.
- Suggest test scenarios for each uncovered branch.
- Estimate effort (small/medium/large) for each coverage improvement.
6. Compare current coverage against the previous commit or baseline:
- Calculate coverage delta per file.
- Flag files where coverage decreased.
- Verify new code added since baseline has adequate coverage.
7. Write coverage enforcement configuration (coverage thresholds in Jest config, `.coveragerc`, or CI checks).
## Output
- Coverage summary report with overall and per-file metrics
- Prioritized list of uncovered code paths with file:line references
- Coverage delta report comparing against baseline
- Suggested test cases for top coverage gaps
- Coverage threshold configuration file for CI enforcement
## Error Handling
| Error | Cause | Solution |
|-------|-------|---------|
| Coverage report shows 0% | Tests ran but coverage instrumentation was not enabled | Verify `--coverage` flag is passed; check that source files are not excluded by config |
| Coverage includes `node_modules` | Coverage collection scope too broad | Add `collectCoverageFrom` in Jest config; set `--cov=src` in pytest; exclude vendor dirs |
| Branch coverage much lower than line coverage | Conditional logic is only partially tested | Write tests for both truthy and falsy conditions on each branch; focus on edge cases |
| Coverage drops after refactor | New code added without corresponding tests | Set `coverageThreshold` with `global` minimums; add `--changedSince` for incremental checks |
| Flaky coverage numbers between runs | Non-deterministic test execution skipping code paths | Sort tests deterministically; run coverage with `--runInBand` for consistent results |
## Examples
**Jest coverage configuration with thresholds:**
```json
{
"jest": {
"coverageThreshold": {
"global": {
"branches": 70,
"functions": 80,
"lines": 80,
"statements": 80
},
"src/utils/": {
"branches": 90,
"lines": 95
}
},
"collectCoverageFrom": [
"src/**/*.{ts,tsx}",
"!src/**/*.d.ts",
"!src/**/index.ts"
]
}
}
```
**Coverage gap analysis output:**
```
Coverage Gaps (sorted by impact):
1. src/auth/oauth.ts Lines: 45% Branches: 30% [Lines 42-67, 89-103 uncovered]
Suggestion: Add tests for token refresh failure and expired session handling
2. src/api/middleware.ts Lines: 62% Branches: 41% [Lines 28-35, 71-80 uncovered]
Suggestion: Test rate limiting edge cases and malformed header handling
3. src/utils/parser.ts Lines: 71% Branches: 55% [Lines 112-130 uncovered]
Suggestion: Test malformed input, empty string, and encoding edge cases
```
## Resources
- Istanbul/nyc: https://istanbul.js.org/
- c8 (Node.js native coverage): https://github.com/bcoe/c8
- coverage.py: https://coverage.readthedocs.io/
- JaCoCo: https://www.jacoco.org/jacoco/
- Go test coverage: https://go.dev/blog/cover
- Code coverage best practices: https://testing.googleblog.com/2020/08/code-coverage-best-practices.htmlRelated Skills
test-skill
Test skill for E2E validation. Trigger with "run test skill" or "execute test". Use this skill when testing skill activation and tool permissions.
testing-visual-regression
Detect visual changes in UI components using screenshot comparison. Use when detecting unintended UI changes or pixel differences. Trigger with phrases like "test visual changes", "compare screenshots", or "detect UI regressions".
generating-unit-tests
Test automatically generate comprehensive unit tests from source code covering happy paths, edge cases, and error conditions. Use when creating test coverage for functions, classes, or modules. Trigger with phrases like "generate unit tests", "create tests for", or "add test coverage".
generating-test-reports
Generate comprehensive test reports with metrics, coverage, and visualizations. Use when performing specialized testing. Trigger with phrases like "generate test report", "create test documentation", or "show test metrics".
orchestrating-test-execution
Test coordinate parallel test execution across multiple environments and frameworks. Use when performing specialized testing. Trigger with phrases like "orchestrate tests", "run parallel tests", or "coordinate test execution".
managing-test-environments
Test provision and manage isolated test environments with configuration and data. Use when performing specialized testing. Trigger with phrases like "manage test environment", "provision test env", or "setup test infrastructure".
generating-test-doubles
Generate mocks, stubs, spies, and fakes for dependency isolation. Use when creating mocks, stubs, or test isolation fixtures. Trigger with phrases like "generate mocks", "create test doubles", or "setup stubs".
generating-test-data
Generate realistic test data including edge cases and boundary conditions. Use when creating realistic fixtures or edge case test data. Trigger with phrases like "generate test data", "create fixtures", or "setup test database".
managing-snapshot-tests
Create and validate component snapshots for UI regression testing. Use when performing specialized testing. Trigger with phrases like "update snapshots", "test UI snapshots", or "validate component snapshots".
running-smoke-tests
Execute fast smoke tests validating critical functionality after deployment. Use when performing specialized testing. Trigger with phrases like "run smoke tests", "quick validation", or "test critical paths".
performing-security-testing
Test automate security vulnerability testing covering OWASP Top 10, SQL injection, XSS, CSRF, and authentication issues. Use when performing security assessments, penetration tests, or vulnerability scans. Trigger with phrases like "scan for vulnerabilities", "test security", or "run penetration test".
tracking-regression-tests
Track and manage regression test suites across releases. Use when performing specialized testing. Trigger with phrases like "track regressions", "manage regression suite", or "validate against baseline".