Audits and strengthens existing test suites by finding tautological, vacuous, weak, brittle, mislabeled, and missing tests. Applies mutation-testing thought experiments to ensure tests would actually catch real bugs.
Ships in refine-tests. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Audit an existing test suite with fresh eyes and make it strictly more powerful. The goal is not more tests for their own sake — it is tests that would actually fail if the code under them were broken.
For every test, ask the Mutant Question — the mutation-testing thought experiment:
If a competent junior developer introduced a subtle but serious bug in the code this test covers — flipped a comparison, dropped a branch, inverted a condition, hardcoded a return value, ignored an argument — would this test fail?
If no assertion would fail, the test is decorative. Coverage tools cannot see this: a test can execute every line and detect nothing. Reaching the code is not the same as checking an observable result that would reveal the defect.
The strongest form of the question: could the function under test be replaced with a constant (return ok: true, return [], a no-op) and the test still pass? Verified checkers, validators, filters, and guards deserve this exact question — a tamper-detection suite where every test asserts ok: true is passed by a checker that unconditionally returns ok: true.
AGENTS.md, CLAUDE.md, testing conventions) before judging anything. Note the test runner and the command to run a single file.Severity: H = a vacuous or absent test on a money, auth, data-integrity, or concurrency path; M = weak assertions or an untested branch in real logic; L = naming, hygiene, or incidental gaps.
For large suites, work in batches by directory and carry the findings ledger across batches so late batches benefit from patterns found early. Fan out to parallel reviewers only if the user asks for parallelism.
The assertions pass for a reason unrelated to the behavior the test claims to verify.
The neutralized negative. A "must not leak / must not include" test whose fixture is stripped, empty, or normalized away by an earlier stage, so the guard under test never runs. A secrets-don't-flow test using empty-string credentials passes even if the config leaks them, because an env compactor drops empties regardless.
// ❌ Vacuous: empty strings are stripped by compactEnv before the guard runs,
// so this passes even if the config leaks credentials
const env = buildTraderEnv({ apiKey: "", apiSecret: "" });
expect(env).not.toHaveProperty("API_KEY");
// ✅ Real values that would survive compaction; assert none reach the env
const env = buildTraderEnv({ apiKey: "k-live-1", apiSecret: "s-live-1" });
expect(Object.values(env)).not.toContain("k-live-1");
expect(Object.values(env)).not.toContain("s-live-1");
The pre-empted negative. In a combined-filter test, the negative fixture is rejected by an earlier filter than the one under test. Filter N could be deleted and the test passes. Each negative fixture must differ from a passing fixture in exactly the dimension under test.
Fixture equals derived value. The input fixture happens to equal the expected computed output, so copy-instead-of-compute passes.
Asserting against a hand-written mock of the unit itself. The behavior "verified" is the mock author's imagination, not real code.
Bug class that slips through: the guard, filter, or computation is entirely broken or bypassed; the suite stays green.
The assertion is true by construction and cannot fail.
expect(x).toEqual(literal) where x is that local literal./expected message|^$/ matches everything including empty.ok: true. Inject a real disagreement and assert the exact mismatch record.Bug class: anything. These tests catch nothing by definition.
The test exercises real code but checks too little of the result.
.toThrow() when callers branch on error type — a decode error regressing from a typed 400 to a generic 500 passes.toMatchObject verifying 3 of 12 fields on a persistence round-trip; the unchecked mapper fields can silently drop.ok: false without the error code, status, or message that consumers dispatch on.limit=500) without asserting the clamped value (limit=100) reached the downstream call.Bug class: wrong error taxonomy, dropped fields, ignored parameters, silent contract drift.
Coupled to implementation details that can change without affecting correctness — while the actual contract goes unpinned.
stop() still passes). Use injected clocks and real synchronization points.Bug class: refactors cause false alarms until someone "fixes" the test by weakening it; real behavior changes pass unnoticed.
Important paths with zero coverage. Highest-severity findings usually live here.
already_exists guard double-submits live orders silently.finally that releases a lease after a throw, the catch that releases then rethrows.Bug class: exactly the production incidents that hurt most — silent data corruption, duplicate side effects, stuck lifecycles.
State that leaks between tests, masking failures or making passes order-dependent.
await, hiding real failures.Bug class: races and atomicity bugs invisible in tests; a test that fails only when run alone (or only in suite).
The name promises something the body doesn't do. Names are documentation; a lying name actively misleads the next maintainer into believing a behavior is covered.
describe named for function X containing tests of Y and Z.Fix: rename to what is actually proven, or better, make the body earn the name.
Where weak tests cluster. Check these first:
| Ground | What to ask |
|---|---|
| Negative tests | Does the fixture reach the guard under test, or is it pre-empted/normalized away earlier? Would it pass with the guard deleted? |
| Validator/checker/tamper tests | Is a disagreement ever actually injected? Would return ok:true pass? |
| Concurrency tests | Do operations actually interleave, or does shared infrastructure serialize them? |
| Error paths | Are throw/cleanup/release branches executed, or only the happy path? |
| Timeouts and timers | Fired, or merely forwarded? |
| Boundaries | Tested at the edge and one step past, on both sides? |
| Money/auth/admin surfaces | Any coverage at all? |
| Round-trips | All fields asserted, or a toMatchObject subset? |
| Mock-heavy files | Is anything real still executing? Does any assertion touch non-mock output? |
toEqual the full mapped object on round-trips, or assert every field the mapper writes.Strengthening tests will surface cases where the code is wrong. Do not silently fix production code mid-review, and do not silently assert the broken behavior either. Pin it:
// SUSPECTED BUG: decimal() emits "-0.0" for small negatives; the canonical-form
// check rejects that form, so equal values can hash-split. Pinned at current
// behavior pending a decision.
expect(decimal(-0.0004, 1)).toBe("-0.0");
The pinned test is what lands — never a red test. Write the intended-contract assertions as comments beside the pin, ready to flip once the human decides. The suite stays green, the anomaly is impossible to miss, and the human decides. List every pinned bug prominently in the report.
# Test Refinement Report
Scope: files scanned / deep-read / clean
Counts: N tests → M tests; suite green; typecheck/lint status
Findings:
| ID | File:Line | Cat | Sev | Issue | Bug class that slipped through | Fix |
Suspected production bugs (pinned, not fixed):
1. file:line — behavior, why it looks wrong, decision needed
Residual risks / coverage still missing:
Every finding carries the why — the class of real bug the weakness would let through. A finding without a bug class is taste, not a finding.
| Excuse | Reality |
|---|---|
| "The test passes, so it's fine" | Passing is the weakest possible signal. Decorative tests pass forever. |
| "Adding assertions makes tests brittle" | Brittleness comes from coupling to implementation, not from assertion strength. Assert outputs harder, internals less. |
| "This error branch can't happen" | Untested error branches are where silent corruption lives. If it truly can't happen, delete the branch, not the test. |
| "The mock is simpler than the real path" | A test of a mock proves the mock. Mock at the boundary; keep the unit under test real. |
| "I'll just relax the tolerance to fix the flake" | That's weakening. Remove the nondeterminism instead. |
| "Coverage is already 90%" | Coverage measures execution, not detection. The Mutant Question measures detection. |
| "Renaming is cosmetic" | A lying test name is documentation asserting coverage that doesn't exist. |
.toThrow() with no argument; toMatchObject on a round-trip; regex with |^$What SKILL.md sets; muted values are Claude Code's defaults
/refine-tests:refine-testsfrom refine-tests
npx claudepluginhub ratacat/ratacats-skills --plugin refine-testsOther plugins' skills for the same job