test-coverage — Claude Code command: what it does, how to install
A Claude slash command that measures test coverage, finds uncovered branches and suggests which tests to add.
npx claude-code-templates@latest --command testing/test-coverageWhat test-coverage does
The command runs a coverage analysis inside your project. It starts by looking around: finds Jest and NYC configs, coverage.xml, a coverage directory, and counts test files matching *.test.* and *.spec.*. Then it produces a report for lines, branches, functions or statements, depending on the argument you pass.
Six steps sit behind it: tool setup (Jest, NYC, Istanbul, Coverage.py, JaCoCo), measurement, gap analysis, threshold and quality gate configuration, reporting with trend tracking, and an improvement plan. Differential coverage is covered too, so you can see what changed against a baseline branch. Tool access is limited to Read, Write, Edit and Bash.
Thresholds are configured during the run; no default numbers are applied for you. If the project has no coverage config at all, step one turns into creating one, which is worth checking before you run it, since the toolchain for Python or Java looks nothing like the JavaScript one.
What it helps with
- see which branches your tests never touch
- wire a coverage threshold into CI as a quality gate
- produce a line, function or statement coverage report
- spot uncovered paths in business logic
- decide which tests to write next
Example prompts for the agent
- /test-coverage --branch
- /test-coverage --report
- /test-coverage --line
How to install test-coverage
1claude-code-templates
npx claude-code-templates@latest --command testing/test-coverage2Manually: put the files in place
.claude/commands/test-coverage.mdCall it with /test-coverage. For all projects use ~/.claude/commands/
Manually: put the files in place
~/.codex/prompts/test-coverage.mdCall it with /prompts:test-coverage. Codex marks this format deprecated in favour of skills
Manually: put the files in place
.github/prompts/test-coverage.prompt.mdManually: put the files in place
.gemini/commands/test-coverage.tomlGemini stores commands as TOML: the prompt text goes into the prompt field
Questions about test-coverage
How do I install test-coverage in Claude?
Run npx claude-code-templates@latest --command testing/test-coverage. The command lands at .claude/commands/test-coverage.md.
What does test-coverage do?
It measures coverage for the type you pick, lists uncovered code paths and recommends test additions. It also handles thresholds and trend monitoring.
What arguments does test-coverage take?
--line, --branch, --function, --statement or --report. With no argument it follows the general analysis flow.
Source text
test-coverage.md · MIT
--- allowed-tools: Read, Write, Edit, Bash argument-hint: "[coverage-type] | --line | --branch | --function | --statement | --report" description: Analyze and improve test coverage with comprehensive reporting and gap identification --- # Test Coverage Analyze and improve test coverage with detailed reporting and gap analysis: **$ARGUMENTS** ## Current Coverage Context - Test framework: !`find . -name "jest.config.*" -o -name ".nycrc*" -o -name "coverage.xml" | head -1 || echo "Detect framework"` - Coverage tools: !`npm ls nyc jest @jest/core 2>/dev/null | grep -E "nyc|jest" | head -2 || echo "No JS coverage tools"` - Existing coverage: !`find . -name "coverage" -type d | head -1 && echo "Coverage data exists" || echo "No coverage data"` - Test files: !`find . -name "*.test.*" -o -name "*.spec.*" | wc -l` test files ## Task Execute comprehensive coverage analysis with improvement recommendations and reporting: **Coverage Type**: Use $ARGUMENTS to focus on line coverage, branch coverage, function coverage, statement coverage, or comprehensive reporting **Coverage Analysis Framework**: 1. **Coverage Tool Setup** - Configure appropriate tools (Jest, NYC, Istanbul, Coverage.py, JaCoCo), setup collection settings, optimize performance, enable reporting 2. **Coverage Measurement** - Generate line coverage, branch coverage, function coverage, statement coverage reports, identify uncovered code paths 3. **Gap Analysis** - Identify critical uncovered paths, analyze coverage quality, assess business logic coverage, evaluate edge case handling 4. **Threshold Management** - Configure coverage thresholds, implement quality gates, setup trend monitoring, enforce minimum standards 5. **Reporting & Visualization** - Generate detailed reports, create coverage dashboards, implement trend analysis, setup automated notifications 6. **Improvement Planning** - Prioritize coverage gaps, recommend test additions, identify refactoring opportunities, plan coverage enhancement **Advanced Features**: Differential coverage analysis, coverage trend monitoring, integration with code review, automated coverage alerts, performance impact assessment. **Quality Insights**: Coverage quality assessment, test effectiveness analysis, maintainability correlation, risk area identification. **Output**: Comprehensive coverage analysis with detailed reports, gap identification, improvement recommendations, and quality metrics tracking.
© davila7 · MIT · davila7/claude-code-templates