Evaluates whether tests earn their place by protecting observable behavior or credible regressions. Ships a pytest smell scanner and test-only-symbol finder. Use when writing, changing, or reviewing tests, or planning a test-pruning campaign.
Ships in test-audit. 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; scripts run unread.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
test-audit, test-quality, test-maintenance, pytest-smells, test-pruning
/test-audit:test-auditfrom test-audit
npx claudepluginhub dashed/claude-marketplace --plugin test-auditA test costs maintenance, so it has to earn its place: it protects observable behavior, a credible regression, or a contract that matters on its own. This skill applies that one value bar in three modes:
Optimize for confidence, not deletion count.
Relation to test-sloc-cut. test-sloc-cut removes duplicate pins of facts worth keeping, and it refuses to lose a fact. This skill decides whether a fact is worth pinning at all. A consolidation (C in the ledger) goes through test-sloc-cut's fact matrix and coverage diff; a deletion (D) goes through the ledger here.
Before you add or change a test, answer four questions. A missing answer means: do not add it yet.
Then check the test against the low-value patterns. A match fails the gate unless the retention bar names the contract that the test alone guards.
Refactor check. If a behavior-preserving refactor breaks the test — a private helper renamed, internal calls reordered, two modules merged — the test asserts implementation. Rewrite it at the owner boundary before it lands.
A regression test must fail before the fix, for the intended reason. A regression test that never failed proves the mock, not the fix. Keep the new test, put the production files back to the pre-fix revision, run the test, and read the failure: it must be the assertion that names the bug, not an import error, a missing fixture, or a different exception. Then restore the fix.
git stash push -- src/pkg/billing.py # or: git checkout <fix>^ -- src/pkg/billing.py
pytest tests/test_billing.py::test_refund_is_capped -x # must FAIL on the bug's own assertion
git stash pop # or: git checkout HEAD -- src/pkg/billing.py
If the test passes on the pre-fix code, it does not reach the bug: drive the owner boundary the bug went through, or assert the value the bug changed, and do not land it until it fails. One regression test at the owner boundary covers a bug. Do not replay the same scenario at every layer it crosses.
The owner of a contract is the cheapest test that drives the real production path of that contract: the public entry point before a private helper; a real collaborator or a fake transport before a mock that implements the asserted behavior; a pure function before a database test before an end-to-end test, as long as each one runs the same real code. Facts about wiring, persistence, metric emission, or legacy behavior belong to the layer that exercises them. test-sloc-cut uses the same ownership rule.
One checklist for both modes: the gate rejects a new test that matches a pattern, and an audit hunts for existing tests that do. references/patterns.md gives each pattern with a runnable pytest example, the fix, and the detector.
Pins nothing
assert, or an assert on a tuple or a constant;assert sub.interval == sub.interval);Pins the past
Pins its own inputs
expected = slug(t); assert slug(t) == expected);net * (100 + TAX_PERCENT) // 100): a wrong rate moves both sides of the comparison;"" passes key(a) == key(a);Mock that stands in for different APIs — create_autospec makes the mock reject calls the real API rejects;__all__ compared with the production constant — it fails on every legitimate addition and catches nothing else.Pins implementation
inventory._stock, assert_called_once_with on an internal helper) that the real boundary already covers;inspect.getsource, reading a .py file);Pins one thing twice
Pins less than it claims
pytest.raises(ValueError) satisfied by a different guard or by setup code inside the with block, or a denial from a different permission check than the one named;A duplicate body is more often a missing test than a redundant one. In httpx (b5addb6), test_client_decode_text_using_explicit_encoding is a copy of the autodetect test and still passes default_encoding=autodetect, so the explicit-encoding path it is named for has no test. In flask (d73fa1c), test_teardown_request_handler_debug_mode never enables debug mode. Read the name before the body, and repair (F) before you delete (D).
Keep discovery read-only, and report evidence before any edit. Four mechanical passes start it. None of them is a verdict.
# Patterns ruff cannot see: no-assert, self-compare, repeat-call, dup-body, reads-source.
python3 scripts/scan_smells.py tests/ --assert-helper '^get_(success|error)_response$'
# Patterns ruff can see: broad raises (PT011), setup inside raises (PT012), assertions in
# except (PT017), a comparison without assert (B015), assert on a tuple (F631), a name
# compared with itself (PLR0124).
ruff check --isolated --select PT011,PT012,PT017,B015,F631,PLR0124 tests/
# Private names read outside their class (SLF001): a triage list for "pins implementation".
ruff check --isolated --select SLF001 \
--config 'lint.flake8-self.extend-ignore-names = ["_meta", "_get_current_object"]' tests/
# Production symbols that only tests refer to.
python3 scripts/find_seams.py --src src/pkg ../consumer-repo/pkg --tests tests
scan_smells.py sees the helpers and fixtures defined in the same file. A base-class method or an imported helper that asserts — a response helper that checks the status code, a schema validator, a snapshot fixture, a browser wait — stays invisible until you pass it with --assert-helper. Rank the calls inside no-assert hits and add the helpers you confirm assert. On a 33,619-test Django suite, four such patterns took no-assert from 886 hits to 191.dup-body is the most precise signal. It needs the same decorators, arguments and body in one class or module, so every hit is either redundant or a copy that never got its distinguishing input. On the same suite, the 56 hits included a staff-permission test that logs in as a superuser and a "with extra slash" test whose URL has no extra slash.self-compare is usually a bug (a typo for the expected value). repeat-call is usually a deliberate determinism, idempotency or caching test; check that it also pins a value.find_seams.py matches by name. It misses a seam whose name production uses for anything, and it cannot see a codebase you do not pass under --src. decorated, override, string and exported tags mean "check how production reaches it"; start from the untagged candidates. A cluster of candidates in one package, all subclasses of one base, is usually a registry that production loads by name.pytest.raises of a broad type without match=. Triage it by asking whether another guard on the path raises the same type.SLF001 is noisy. It reported 320 sites in six open-source suites and 1,467 on the Django suite. Besides private state, it flags underscore names that are public by contract (Django's _meta was 121 of the 1,467; add the framework's names to extend-ignore-names) and private modules that a suite tests on purpose (click._termui_impl). Apply the refactor check to each site.pytest.raises(ModuleNotFoundError) and not hasattr( assertions pinned live behavior. A tombstone usually landed in the commit that removed what it asserts is gone; git log -S '<test name>' --reverse -- <file> lists that commit first.For a broad scope, split discovery into parallel read-only lanes — core packages, plugins or apps, tooling and scripts, and one cross-cutting pattern sweep. Outside a campaign, prefer a few high-confidence candidates to a large speculative list.
In an audit, an existing test that must change for a behavior-preserving refactor is suspect, not automatically deletable. The gate still rejects a new one.
Before you judge a candidate, read the complete test and its production owner: the entry point, callers, callees, sibling implementations, overlapping tests, CI routing, and the history of both. Read the repository's agent instructions (AGENTS.md, CLAUDE.md) first. When a test claims behavior of a dependency, read the dependency's source or types.
Keep a test that alone enforces a public API, protocol, configuration, migration, storage format, security, platform, default, serialization, generated-code, packaging, release or architecture contract. Also keep:
@given property that the code never raises) — mark it F so its name or a comment states that contract;Static or slow is not a reason to delete. A test that looks like implementation may still be the independent contract; prove otherwise before you remove it.
Record every field for a candidate before you edit. A missing field means the candidate is not ready.
| Field | Content |
|---|---|
| test | node id: tests/test_x.py::TestY::test_z |
| mark | R retain · F fix the assertion or the input · C consolidate into a named owner · D delete |
| detects | the failure it can actually detect; prove a doubtful claim with a mutant |
| owner proof | the stronger owner-boundary test that remains, or why no contract exists |
| seam callers | the non-test callers of the production or support code it drives (find_seams.py, rg -w) |
| history | why it exists: git log --follow -S '<test name>' -- <file>, the commit message, the linked bug |
| unlocks | the production or test-support code the change lets you delete |
| risk and proof | the risk, and the focused command that validates the change |
Judge a test by its assertions, not its name. A C candidate goes through test-sloc-cut: the absorbing test asserts every fact of the absorbed one, and the fact matrix and coverage diff pass. A D candidate that claims a regression needs a mutant: break production the way the regression would, and watch the owner test go red.
A production symbol that only tests use — a reset_for_tests(), an injection parameter, a flag, a setter hook, a dead model method, an RPC method with no caller — is maintenance the product pays for the test. Delete it together with the tests that exist only to keep it, instead of leaving an alias. Where a test must observe or replace something, move it to the real boundary: a fake transport, monkeypatch on the real dependency, tmp_path for the file system, the public API.
Before you delete one, confirm three things: find_seams.py found no production reference by name; rg -w <name> finds no string, configuration, template or other-repository use; and no framework reaches it through a registering decorator, a base-class call, or subclass registration.
F before D: fix a weak assertion that guards a real contract — assert the value, add match=, use create_autospec, give the duplicate its missing input.ptw, pytest-watch, --looponfail) runs in the checkout.git diff --check.git diff --numstat, and report production and tooling lines apart from test lines./code-review, or the repository's review gate) before handoff.Commit, push or open a pull request only when the user authorizes it. Land one coherent batch at a time; after it lands, refresh from the main branch and run read-only discovery again for the next batch.
Report:
scripts/scan_smells.py — per-test no-assert, self-compare, repeat-call, dup-body and reads-source findings for pytest and unittest files; --assert-helper names assertion helpers from other files (stdlib).scripts/find_seams.py — production symbols that only tests refer to, ranked, with reachability tags (stdlib).Related skills: test-sloc-cut for lossless consolidation, comment-slop for the comments in tests, pytest for the runner, ruff for the lint rules above.
Adapted from the OpenClaw test-audit skill (Copyright (c) 2026 OpenClaw Foundation, MIT License), with the pytest detectors, the owner-boundary rule shared with test-sloc-cut, and the evidence from the runs above added here. The tombstone, dependency-only and formula-copy patterns were prompted by the prune-tests skill in caldoai/skills (Copyright (c) 2026 Maze, MIT License); the retention exceptions and the measurements are ours.
Other plugins' skills for the same job