Test coverage

From ariadoss/superskills · View interactive version

Test coverage is an AI agent skill from the GitHub repository ariadoss/superskills. Finds complex business logic, edge cases, corner cases, and past regressions that lack tests, then writes the missing unit tests (and integration/E2E tests when the risk genuinely crosses a boundary) — enforcing Google's Testing on the Toilet best practices (real > fake > mock, don't mock types you

How to use this skill

Skill file

/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

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.

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.

this is not optional flavor text, it's the acceptance bar for the tests this

skill produces.

E2E only per the pyramid rule in Step 4 — don't reach for Playwright to

cover a pure function.

specific input class missing coverage, and (for regressions) the commit that

introduced the bug.

Step 1: Scope

  1. If $ARGUMENTS gives 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).

  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.

  1. 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:

return different values or take different side-effecting actions.

pagination.

and rules about which transitions are legal.

permissions/authorization, rate limiting, parsing/serialization, validation.

/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:

loop/array edge

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

  1. git log the in-scope files for commits whose message matches

fix|bug|regression|hotfix|revert (case-insensitive).

  1. 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.

  1. 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

objects/pure functions and no I/O. This is nearly everything from Steps 2–4.

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

(see CODE0);

reach for a mock only when no hermetic option exists.

where the risk is the wiring between already-unit-tested pieces, not any

single piece's logic. Use /playwright for browser E2E — don't hand-roll a

driver here.

artifact a reviewer checks when they ask "why is this an integration test."

Step 6: Google testing best practices (apply to every test you write)

These are Google's Testing on the Toilet rules that close real gaps in most

test suites. Each is a short standalone file under rules/ — a rule plus a

concrete good/bad example — so you pull in the detail only for the rule that's

actually in play, instead of re-reading all eleven every run. Skim the

one-liners below; open a file when its situation applies to the test you're

about to write. When you're already touching an existing test for a nearby

reason, fix violations you see rather than adding a TODO.

| Rule | Applies when |

|---|---|

| CODE0 | About to reach for a mock — check real/fake first |

| CODE0 | The dependency is a third-party type, not your own |

| CODE0 | About to verify()/assert-called-with on any call |

| CODE0 | Choosing what the assertion should check |

| CODE0 | The test's structure is starting to mirror the code's branches |

| CODE0 | Picking which kind of double to use |

| CODE0 | The test already has 2+ mocks |

| CODE0 | Tempted to extract a shared fixture/setup helper |

| CODE0 | Naming a test or deciding how many tests one function needs |

| CODE0 | The gap traces back to a singleton/static/Date.now() |

| CODE0 | Naming a test or building its fixture data |

Step 7: Write the tests

For each confirmed gap (Steps 2–4), at the chosen level (Step 5), following

the Step 6 rules/ checklist:

  1. Write the test. Run it. If it's testing genuinely new behavior it should

fail first (red) against a stubbed-out expectation, or pass immediately

because the behavior already exists and you're only closing a coverage

gap — either is fine, but run it and read the actual result, don't

assume.

  1. If a new test fails against unmodified production code, stop and report it

as a bug/regression finding (see Hard rules) instead of silently adjusting

the assertion.

  1. Apply the test file changes (this skill writes and commits to the working

tree).

Step 8: Run the related tests and report

Run the tests that cover the files you changed and every test file you added or edited, by name. Do not run the whole suite: it runs once at the merge gate (suite-stamp.sh ensure). Put that command in Runner:. When git config --local superskills.suiteCommand is empty, end with one plain sentence: "No whole-suite gate is set up here. Run the whole suite once before merging, or run suite-stamp.sh init '<command>' so it runs once per tree." Then report:

# Test coverage — <scope> @ <date>

Runner: <command>   Files scoped: N   New tests added: M

## Gaps closed
- <file:line> <function> — <input class(es) covered> — <unit|integration|e2e> — <test file:line>

## Regressions pinned
- <original bug commit> — <file:line> — reproduces: <what broke> — <test file:line>

## Bugs found while writing tests (not fixed here)
- <file:line> — <test that exposes it> — <why it's a real defect, not a bad test>

## Best-practice fixes applied to existing tests touched
- <file:line> — <which rules/ file> — <what changed>

## Suite result
<pass/fail summary from the related-test run>

Anti-patterns (do not do)

thing or a fake (rules/real-fake-mock-hierarchy.md).

(rules/dont-mock-types-you-dont-own.md).

expected value — that's not a test, it's a mirror

(rules/avoid-change-detector-tests.md).

covers in milliseconds (Step 5).

without telling the user (Hard rules).

complex branch stays untested — risk-driven prioritization (Step 2).

Related commands

new code. /test-coverage runs after* code exists, to close gaps in what

already landed.

for gaps, runs /test-coverage to close them, then re-runs the suite. New

public surface still untested afterwards is a ship blocker.

a gap needs browser-level coverage.

complementary "does the diff have adequate tests" pass, and can be run right

after a /code-review pass identifies risky logic.

root-cause and fix it (this skill reports the bug, it doesn't fix production

code).

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.