/coverage-gaps - Coverage Gap Detector
Identify untested code paths introduced by recent changes and generate focused test cases to close gaps. Cross-references diffs against coverage data to find precisely what needs testing.
System Prompt
EXECUTION DIRECTIVE: When the user invokes this command, you MUST:
- IMMEDIATELY execute - no questions first
- Load the agent
coverage-gap-detector - Detect changes via git diff against base
- Run coverage if available, or analyze test files statically
- Map gaps between changed code and test coverage
- Classify gaps by risk level
- Generate focused test cases for each gap
- Output gap analysis with generated tests
Usage
# Default: diff against main
/coverage-gaps
# Specific base
/coverage-gaps --base develop
# Only critical/high risk gaps
/coverage-gaps --min-risk high
# Generate tests and write to files
/coverage-gaps --output-dir tests/generated/
# Run generated tests to validate
/coverage-gaps --run-generated
# Specific test framework
/coverage-gaps --framework jest
Options
| Option | Description | Default |
|---|---|---|
--base | Base reference for diff | main |
--min-risk | Minimum risk level to report | medium |
--generate-tests | Auto-generate test code | true |
--run-generated | Run generated tests to validate | false |
--output-dir | Write test files to directory | none |
--framework | Test framework (pytest, jest, etc.) | auto-detect |
Related Commands
/test-generate- Generate tests for specific functions/test-coverage- View overall coverage metrics/flaky-tests- Ensure generated tests are stable/bug-scan- Identify which gaps are in bug-prone code
Success Output
COMMAND COMPLETE: /coverage-gaps
Base: main | Head: HEAD
Files Changed: 8 | Functions Modified: 12
Gaps Found: 14 (3 critical, 5 high, 4 medium, 2 low)
Tests Generated: 20
Coverage Impact: +7.6% (projected)
Completion Checklist
- Changed files detected
- Coverage data collected or estimated
- Gaps mapped to functions/branches
- Gaps classified by risk
- Tests generated for each gap
- Coverage impact estimated
Failure Indicators
- No changes detected against base
- Cannot run coverage tool
- Test framework not detected
When NOT to Use
- Measuring overall coverage (use
/test-coverage) - Writing tests from scratch (use
/test-generate) - Fixing failing tests (use
/ci-analyze)
Anti-Patterns
| Anti-Pattern | Problem | Solution |
|---|---|---|
| 100% coverage target | Diminishing returns | Focus on critical paths |
| Test implementation details | Brittle tests | Test behavior |
| Generate without running | Broken tests | Validate generated tests |
Principles
- #3 Complete Execution - Detect, classify, generate, validate
- #9 Based on Facts - Gaps from actual coverage data
Full Standard: CODITECT-STANDARD-AUTOMATION.md