/test-coverage
Finds where complex business logic, edge cases, corner cases, and past
regressions are undertested, then writes and applies the missing tests.
/qa-full Step 9 runs this skill as the fix phase of its coverage check, then
re-runs the suite to verify.
Hard rules
- The bar is
ENGINEERING_STANDARDS.md's TDD section (referenced, not
restated): every new public function, branch, and error path needs a test;
≥90% lines on new/changed modules is the default target; a test that can't
run in the project's real runner doesn't count.
- A failing test against existing code is a finding, not noise. If a test
you write to cover a "should never happen" case actually fails, you found a
real bug or an already-broken regression — report it with repro evidence and
do not rewrite the test to match the broken behavior. Fix the test's
scope only when the spec was wrong, never to paper over a real defect
without telling the user.
- Every test you write or touch follows the Google practices in Step 5 —
this is not optional flavor text, it's the acceptance bar for the tests this
skill produces.
- Smallest correct test level. Default to unit. Escalate to integration or
E2E only per the pyramid rule in Step 4 — don't reach for Playwright to
cover a pure function.
- Ground every gap in evidence: file:line of the untested logic, the
specific input class missing coverage, and (for regressions) the commit that
introduced the bug.
Step 1: Scope
- If
$ARGUMENTSgives paths/globs, scope to those. If it says--full,
scope to the whole repo. Otherwise default to the current branch's diff:
git diff --name-only <base>...HEAD plus git status --porcelain
(same base-branch detection as /qa-full Step 1).
- Detect the test framework and runner from the project (
package.json
scripts, pytest.ini/pyproject.toml, go test, bats, *.csproj,
Gemfile). If ambiguous, ask rather than guess — writing tests against the
wrong runner is worse than asking one question.
- Record scope, runner, and command at the top of your working notes.
If the scope is empty, say so and stop — there's nothing to cover.
Step 2: Find undertested complex logic
For each in-scope file, flag functions/methods that are "complex" by any of:
- Multiple branches — 2+
if/switch/ternary paths, especially ones that
return different values or take different side-effecting actions.
- Loops with accumulation or early exit — aggregation, search, dedup,
pagination.
- State machines / status transitions — anything with an enum of states
and rules about which transitions are legal.
- Calculations with domain rules — money/currency, dates/timezones,
permissions/authorization, rate limiting, parsing/serialization, validation.
- Recursive functions.
- **Anything already flagged by
/db-optimize,/perf-profile, or a prior
/code-review as high-risk** — risk-driven prioritization: spend the
budget here first, not on trivial getters.
For each, grep the test tree for a reference to that function/class name. No
reference (or only a shallow "doesn't throw" smoke test) ⇒ gap.
Step 3: Enumerate edge and corner cases per gap
For each gap from Step 2, work out the input-partition classes relevant to
that logic — don't apply a rote checklist blindly, reason about what this
function actually branches on. Common classes to check against:
- null / undefined / missing-key vs. present-but-empty (
"",[],{},0) - boundary values: zero, negative, max/min of the type, off-by-one at a
loop/array edge
- single-element and duplicate-element collections
- malformed / unexpected-shape input (extra fields, wrong type, truncated)
- concurrent or repeated calls (double-submit, idempotency)
- unicode/encoding edge cases in string handling
- timezone/DST boundaries and leap years in date logic
- floating-point precision in money/percentage math
- combinations of two+ conditions that individually pass but together hit an
unhandled branch (the actual "corner" case, not just one axis at a time)
Only list classes that are reachable through the function's real callers —
don't invent tests for input shapes the type system or a validator already
rules out upstream.
Step 4: Regression coverage
git logthe in-scope files for commits whose message matches
fix|bug|regression|hotfix|revert (case-insensitive).
- For each match, check whether that commit (or a nearby one) added or
modified a test. No test touched ⇒ regression gap: the bug could
reappear silently.
- For each regression gap, write a test that reproduces the original
failure mode (read the pre-fix diff to know what broke) and pins the fixed
behavior — the classic "this test would have caught it" test.
Step 5: Decide the test level — pyramid, not instinct
- Unit (default). The logic's correctness can be verified with real
objects/pure functions and no I/O. This is nearly everything from Steps 2–4.
- Integration. Escalate only when the real risk lives at a boundary a
unit test would fake away — an actual SQL query's behavior, a real
filesystem/queue interaction, a multi-module contract. Prefer a real
dependency or an in-process fake/hermetic server over mocking the boundary