From godmode
Automates TDD RED-GREEN-REFACTOR loop to achieve target test coverage (default 80%), writing one test per iteration for Vitest, Pytest, or Go Test runners. Use for systematic coverage improvement.
How this skill is triggered — by the user, by Claude, or both
Slash command
/godmode:testThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
- `/godmode:test`, "write tests", "test coverage"
/godmode:test, "write tests", "test coverage"# Measure current coverage
npx vitest --coverage 2>&1 | tail -5
# Or: pytest --cov=src --cov-report=term | grep TOTAL
# Or: go test -cover ./...
coverage = measure_coverage()
target = user_target OR 80
current_iteration = 0
WHILE coverage < target:
current_iteration += 1
# 1. FIND — coverage report, untested lines
# Priority: happy > error > edge > integration
# 2. RED — write ONE test. It MUST fail.
# IF passes immediately: wrong test, delete
# 3. GREEN — write minimum code -> PASS
# 4. REFACTOR — remove test duplication
# Run ALL tests. IF unrelated breaks -> revert
# 5. COMMIT: git add {file} && git commit
# 6. MEASURE: coverage = measure_coverage()
# 7. LOG to .godmode/test-results.tsv
IF current_iteration % 5 == 0:
print "Iter {N}: {coverage}% (target: {target}%)"
Print: "Coverage: {start}% -> {final}% in {N} iters"
Print: Test: coverage {start}% -> {final}% (target: {target}%). {N} tests added in {iters} iterations. Status: {DONE|PARTIAL}.
test: cover {function/path}.SKILL.md §14. Principles prelude, pre-commit audit (agents/tester.md step 11a), terse/stdio/tokens, DispatchContext validation, Progressive Disclosure routing, discard cost hierarchy all fire by default.should_{verb}_when_{condition}.KEEP if: coverage increased AND all existing tests pass
DISCARD if: coverage unchanged OR existing test broke
On discard: git reset --hard HEAD~1
Log reason. Move to next uncovered path.
Tests must cover behavior, not implementation. If a test breaks when internals change but behavior is preserved → test is overfitted. Rewrite it.
STOP when FIRST of:
- coverage >= target (default 80%)
- 50 iterations reached (safety limit)
- 3 consecutive iterations with <0.5% gain
- >5 consecutive discards on different paths
| Failure | Action |
|---|---|
| Test passes immediately | Delete. Rewrite to test specific uncovered behavior. |
| Coverage unchanged | Check coverage report line-by-line. May hit covered paths. |
| Unrelated test breaks | Revert. Check shared state or import side effects. Fix isolation. |
| Coverage plateaus | Switch to integration tests. Check for dead code inflating denominator. |
Append to .godmode/test-results.tsv:
iteration\ttest_file\tlines_covered\tcoverage_before\tcoverage_after\tdelta\tstatus
Status: kept, discarded, plateau.
npx claudepluginhub arbazkhan971/godmodeGuides coverage-driven test writing for existing codebases: discovers untested user-facing behavior via coverage reports, writes one meaningful test per iteration, marks low-value code with ignore annotations.
Executes testing tasks: writes colocated test files, runs tests, and summarizes coverage. Includes TDD variant with rationalization counters and red flags.