Scan Python codebases to identify modules without corresponding test files. This skill should be used when enforcing Law 7 (TDD), auditing test coverage gaps, or before starting new development to understand testing debt. Outputs a report of untested modules with recommendations.
View on GitHubboshu2/agentops
domain-kit
January 24, 2026
Select agents to install to:
npx add-skill https://github.com/boshu2/agentops/blob/main/plugins/domain-kit/skills/test-gap-scanner/SKILL.md -a claude-code --skill test-gap-scannerInstallation paths:
.claude/skills/test-gap-scanner/# Test Gap Scanner
## Overview
Scan a Python codebase to find modules that lack corresponding test files. Enforces Law 7 (TDD) by identifying testing gaps before they become technical debt.
## When to Use
- Before starting new development (understand existing gaps)
- After completing a feature (verify tests were created)
- During code review (ensure Law 7 compliance)
- Sprint planning (prioritize testing debt)
- CI/CD integration (fail builds with untested code)
## Quick Start
```bash
# Scan current directory
python scripts/scan_test_gaps.py .
# Scan specific directory with custom test path
python scripts/scan_test_gaps.py ./tools --test-dir ./tests
# Output as JSON for CI integration
python scripts/scan_test_gaps.py . --format json
# Fail if coverage below threshold (for CI)
python scripts/scan_test_gaps.py . --min-coverage 80
# Scan ALL git repositories under a root directory
python scripts/scan_test_gaps.py ~/workspaces --all-repos
```
## How It Works
### Detection Algorithm
1. **Find all Python modules** (excluding `__init__.py`, tests, migrations)
2. **Search for corresponding test files** using patterns:
- `module.py` → `test_module.py`
- `module.py` → `tests/test_module.py`
- `module.py` → `tests/unit/test_module.py`
- `path/to/module.py` → `tests/path/to/test_module.py`
3. **Calculate coverage percentage** (modules with tests / total modules)
4. **Generate report** with gaps and recommendations
### Output Format
**Console (default):**
```
Test Gap Scanner Report
=======================
Directory: ./tools/parallel-learning
Total modules: 12
Modules with tests: 8
Coverage: 66.7%
MISSING TESTS (4 modules):
❌ tools/scripts/validate_context.py
Expected: tests/test_validate_context.py
❌ tools/scripts/check_links.py
Expected: tests/test_check_links.py
❌ memory/__init__.py
Expected: tests/test_memory.py (or skip __init__.py)
❌ utils/helpers.py
Expected: tests/unit/test_helpers.py
RECOMMENDATIONS:
1. Create