Find untested files and low coverage areas in your codebase
Finds untested files and low coverage areas in your codebase. Use it to identify testing gaps and prioritize which files need tests first.
/plugin marketplace add zero-copy-labs/zcl-claude-code-plugins/plugin install team-tools@zcl-claude-code-pluginsIdentify files with missing or insufficient test coverage.
/coverage-gaps [threshold] - Find files below coverage threshold (default: 50%)
When invoked, follow these steps:
Check for these configuration files to identify the test framework:
ls -la jest.config.* vitest.config.* pytest.ini pyproject.toml setup.cfg karma.conf.* .rspec phpunit.xml go.mod Cargo.toml 2>/dev/null
| Config File | Framework | Test Pattern |
|---|---|---|
jest.config.* | Jest (JS/TS) | *.test.ts, *.spec.ts, __tests__/ |
vitest.config.* | Vitest (JS/TS) | *.test.ts, *.spec.ts |
pytest.ini, pyproject.toml | Pytest (Python) | test_*.py, *_test.py |
go.mod | Go testing | *_test.go |
Cargo.toml | Rust | tests/, #[test] in source |
.rspec | RSpec (Ruby) | *_spec.rb |
phpunit.xml | PHPUnit | *Test.php |
Look for coverage output in common locations:
find . -maxdepth 3 -type f \( -name "lcov.info" -o -name "coverage.xml" -o -name "cobertura.xml" -o -name ".coverage" -o -name "coverage.json" \) 2>/dev/null
Also check directories:
ls -d coverage/ .nyc_output/ htmlcov/ target/coverage/ 2>/dev/null
If an lcov.info file exists, parse it:
grep -E "^SF:|^LH:|^LF:" coverage/lcov.info | paste - - - | awk -F'[:|]' '{file=$2; hit=$4; total=$6; pct=(total>0)?hit/total*100:0; if(pct<THRESHOLD) print pct"% - "file}' | sort -n
If coverage.xml (Cobertura) exists:
grep -E 'filename=|line-rate=' coverage.xml | paste - - | awk '{...}'
Find source files:
find src lib app -type f \( -name "*.ts" -o -name "*.js" -o -name "*.py" -o -name "*.go" -o -name "*.rb" \) 2>/dev/null | grep -v -E "(test|spec|__test__|_test)"
Find test files:
find . -type f \( -name "*.test.*" -o -name "*.spec.*" -o -name "test_*" -o -name "*_test.*" \) 2>/dev/null
Map each source file to potential test files by name convention:
src/utils/auth.ts → src/utils/auth.test.ts or tests/utils/auth.test.tslib/payments.py → tests/test_payments.py or lib/test_payments.pyFor files with gaps, gather additional context:
wc -l <file> # Line count
git log -1 --format="%ar" -- <file> # Last modified
git log --oneline -- <file> | wc -l # Commit frequency
Present gaps in this format:
COVERAGE GAPS (threshold: {threshold}%)
No tests found:
• src/utils/validation.ts (247 lines, modified 3 days ago)
• src/api/payments.ts (189 lines, modified today) ⚠️
Low coverage (<{threshold}%):
• src/auth/oauth.ts — 34% covered
• src/db/migrations.ts — 12% covered
Summary:
─────────────────────────────
Files with no tests: 12
Files below threshold: 5
Total files analyzed: 87
─────────────────────────────
Suggestion: Start with {highest_priority_file} ({reason})
Rank files by priority using this scoring:
Suggest the highest-scored file first.
COVERAGE GAPS (threshold: 50%)
No tests found:
• src/utils/validation.ts (247 lines, modified 3 days ago)
• src/api/payments.ts (189 lines, modified today) ⚠️
• src/helpers/format.ts (45 lines, modified 2 weeks ago)
Low coverage (<50%):
• src/auth/oauth.ts — 34% covered
• src/db/migrations.ts — 12% covered
Summary:
─────────────────────────────
Files with no tests: 3
Files below threshold: 2
Total files analyzed: 28
─────────────────────────────
Suggestion: Start with src/api/payments.ts (recently modified + no tests + critical path)
After running this command, you can ask: