
test-audit
Invoke whenever writing, changing, reviewing, or sweeping tests in this project. Provides an authoring gate that every new or changed test must pass, plus an audit workflow for finding and removing low-value, implementation-coupled, or duplicative tests and the test-only production seams they keep alive.
- version
- 1.0.1
- GitHub stars
- 2
Install
/plugin install test-audit@million-views-skillsRun it inside Claude Code after adding the marketplace with /plugin marketplace add million-views/skills.
Contents
Agents 1
Test Audit
Three modes, one value bar.
- Authoring mode gates every new or changed test at write time.
- Audit mode runs focused sweeps for tests that re-assert source, duplicate stronger proof, couple behavior to implementation, or keep test-only production seams alive. Continue broad audits as separate, coherent follow-up changes; optimize for confidence, not deletion count.
- Campaign mode prunes one whole subsystem's test surface (every test file a module, package, or feature area owns). Before starting one, read CAMPAIGN.md.
Before you start
Discover how this project works rather than assuming:
- Read the project's contributor and agent guidance (for example
README,CONTRIBUTING,AGENTS.md,CLAUDE.md, or equivalent), including any scoped copies in subdirectories. - Identify the test runner, how to run a single file or filter, the formatter/linter, and the CI configuration that decides which tests run.
- Identify the project's module or package boundaries: these are the "owner boundaries" referred to throughout this skill.
Authoring gate
Before adding any test, answer four questions. A missing answer means do not add it yet:
- What observable behavior, invariant, or independent contract does it protect?
- What credible regression makes it fail?
- Why does existing coverage not already catch that failure? Each contract has one primary test owner at the strongest boundary; another layer needs its own distinct risk, such as a transport or lifecycle failure the owner cannot reach. Prefer extending a table-driven/parameterized case or shared fixture over a near-duplicate test; consolidate duplicated setup in the same change.
- Does it need a production seam (export, flag, wrapper, injection hook) that no production caller needs? If yes, move the test to the real boundary instead.
Then check the test against every junk pattern; a match fails the gate unless the retention bar names the contract it independently guards. A test that would break under behavior-preserving refactoring is asserting implementation, not behavior; rewrite it at the owning boundary before landing it.
Bug regression tests must fail on the pre-fix code for the intended reason and pass after the owner-boundary repair. A regression test that never demonstrably failed proves the mock, not the fix. One regression at the owner boundary covers the bug; do not replay the same scenario at every layer it crosses.
Junk patterns
The shared checklist for all modes: the authoring gate rejects a new test that matches one, and audits hunt for existing tests that do.
- assertion-free coverage probes;
- self-comparisons and identity copiers;
- copied fixtures, inventories, manifests, or export lists;
- exact source, import, or string greps;
- private predicate or call-shape tests duplicated at real boundaries;
- duplicate invocations of the same contract;
- per-module replays of shared helpers already tested at their owner;
- tests whose only purpose is preserving test-only exports, globals, or wrappers;
- dead production code whose only callers are tests;
- expected values produced by the helper or renderer under test;
- mocks that implement the asserted behavior, or one identical mock standing in for different APIs;
- fixtures that supply the result, ordering, or callback sequence the code under test should produce, or persistence asserted against a store the code path never writes;
- capability tests that restate declared flags or configuration instead of exercising the behavior the flag promises;
- negative controls that pass for an unrelated reason, such as a denial from a different guard or a rejection the production path never reaches;
- names or fixtures that promise more than the input exercises, such as a "clears the cache" test that asserts the cache was not cleared.
Value bar
Tests justify their maintenance cost by protecting behavior, a credible regression, or an independently meaningful contract. In an audit, an existing test that must change for behavior-preserving source reorganization is suspect, not automatically deletable; the authoring gate still rejects new ones.
Before judging a candidate, read the complete test and its production owner, the owner's entry point, callers, callees, sibling implementations, overlapping tests, CI routing, and relevant version-control history. When the test claims dependency-backed behavior, inspect the dependency's source or type definitions directly.
Discovery
Keep discovery read-only and report evidence before editing. For broad scope, run parallel discovery lanes when available, split along the project's own boundaries, for example:
- core library or domain code;
- plugins, extensions, or integrations;
- UI, apps, CLIs, scripts, and tooling;
- a cross-cutting pattern sweep for the junk patterns.
Outside campaign mode, prefer a few high-confidence candidates over a large speculative inventory.
Retention bar
Keep a test when it independently enforces a public API, protocol, wire or file format, configuration, migration, storage, security, platform, default value, generated or cross-language, packaging, release, or architecture contract. Also keep:
- call ordering when order is observable behavior;
- regressions with a credible failure mode;
- source inspection when it is the cheapest independent guard: it fails when the contract changes (the user-facing key, byte, or path) and survives an identifier-only refactor;
- a retained test that fails on the baseline: treat it as a possible product bug, reproduce it, and repair the owner rather than deleting it.
Static or slow is not a deletion reason. A test that resembles implementation may still be the independent contract; prove otherwise before removing it.
Candidate evidence
Record every field below before editing. A missing field means the candidate is not ready for deletion:
- exact test name and location;
- what failure it can actually detect;
- non-test callers of the covered production or support seam;
- stronger remaining owner-boundary proof, or why no proof is needed;
- relevant history and the reason the test or seam exists;
- production or test-support deletion unlocked;
- risk and the focused validation command.
Edit shape
Choose one coherent owner-boundary batch. Delete obsolete test-only exports, globals, wrappers, and dead production paths instead of preserving aliases. Move retained regressions to their canonical owners. Consolidate repeated package or dependency assertions into one generic contract.
Prefer net-negative production lines of code. Do not add replacement tests that restate the same implementation, and do not convert uncertain candidates into cleanup to increase deletion counts.
Validation
Never edit source or tests while a test runner or watcher is running against the working tree.
- Run the smallest owner and sibling tests using the project's test runner with a path or name filter.
- For removed source greps or plan assertions, run the executable, script, or dry-run that owns the real contract.
- Run the project's formatter/linter on changed files, then
git diff --check(or the equivalent whitespace check for your VCS). - Run whatever changed-files or pre-merge gate the project's policy requires (CI-equivalent lint, type check, and affected test suites).
- Inspect
git diff --numstat; report production/tooling changes separately from tests and test support. - After final audit edits, request or perform an independent review of the diff before landing.
Landing and continuation
Commit, push, open a pull request, or merge only when authorized, following the project's contribution workflow. Land one coherent change at a time; after landing, refresh from the current main branch and rerun read-only discovery for the next high-confidence batch.
Handoff
Report:
- root cause and removed low-value categories;
- production owner simplifications;
- retained false positives and why they remain valuable;
- focused and full proof actually run;
- production versus test lines of code;
- pull request and merge state;
- named follow-ups.
Sponsors
Details
- Marketplace
- million-views/skills
- Source
- test-audit
- Category
- Developer Tools
- Keywords
- testing, test-audit, test-maintenance, regression-tests, test-architecture