
prune-tests
Test pruning skill that removes dead, tautological, implementation-coupled, and duplicate tests safely.
- version
- 1.0.9
- GitHub stars
- 94
What it does
- Adds the
/prune-testsskill, which deletes or rewrites tests that guard no real behaviour - Covers four categories: tests of the past, tests of nothing, tests of implementation, and duplicate copies
- Requires a green baseline and runs a break-it check on close calls before any deletion is kept
- Designed for teams with large suites, and leaves changes uncommitted with a ledger of every deletion
Prune tests that guard no behaviour - dead, tautological, implementation-coupled or duplicated - in one cheap read-and-judge pass, with a green suite before and after and a ledger of every deletion.
Add marketplace
/plugin marketplace add henkisdabro/wookstar-claude-pluginsRun it inside Claude Code once, then install the plugin below.
Install
/plugin install prune-tests@wookstar-claude-pluginsRun it inside Claude Code after adding the marketplace.
Files
Discovered from sourcePrune tests
A test earns its place when it is anchored: it depends on intended behaviour, so it changes only when that behaviour changes and goes red only when it regresses. Prune every test that is not anchored.
This is the 80/20 pass: the test, the code under it and its callers, plus a break on each close call and on every deletion.
Steps
-
Scope. Use the path given. With none, take the whole suite; over about 30 test files or 5,000 lines, propose one package or directory and confirm it before reading.
-
Baseline. Run the suite for that scope and record the pass count. If it is already red, stop and report: a red suite cannot tell a broken test from a pruned one.
-
Classify. Read every test in scope and give it one verdict from the categories below: keep, rewrite or delete. Done when every test has a verdict and a category.
-
Break-it check on each close call:
- a test you would delete but suspect is the sole guard of something callers rely on;
- a test you would delete whose origin - the commit that added it (
git log --reverse -S'<test name>' --format='%h %s' -- <file>, first line) - is a fix or names a ticket; - a copy whose partner runs other inputs (another call, method, entry, type or value, or a field left out), or whose partner you doubt;
- a test you would keep whose assertion looks weaker than its name.
Break the production line its call reaches, so that only its case changes, the way its assertion would notice - an edge moved (
>to>=), its one member dropped from a set or range, a failure swallowed into an empty result, a configured value hard-coded, the bug its origin or ticket names. A break runs real code: a broken guard in front of a client the test does not stub reaches live services on whatever credentials the code finds, so break it only where the client is stubbed. Script the breaks: apply one, check the diff reaches the test's own input, run the scoped suite and any outside partner, then reverse just that edit -git checkoutwould drop this prune's edits. A crash that reddens unrelated tests is no break.- No such break turns it red: it guards nothing. Delete it, or rewrite it if the behaviour it names is real and nothing else guards it.
- Red with a partner: delete it.
- Red alone: it is the sole guard, so keep it - unless no caller can tell the broken result from the right one (a slower one, from a dropped index, they can). A branch no production caller reaches is older dead code (step 5).
-
Prune.
- Before deleting or rewriting a test, check each of its assertions against the tests that stay: move any that no survivor makes into one with the same setup, or trim the test down to it. Leave the assertions inside a test you keep.
- Rewrite each rewrite test against the behaviour at its seam, with an exact, independent expected value - a literal, a worked example, the spec - that goes red on every break the old test caught.
- Delete this prune's orphans: production code whose only callers were the removed tests (test-only resets, getters, exports), and the fixtures and helpers it left unused; repoint comments and docs that name a deleted test. Older dead code is listed, not deleted, and so are the tests whose only subject it is.
-
Verify. Run the scoped suite again: green, with the count of test ids the runner executes for the scope (parametrised cases expanded) down by exactly what the ledger removes. Then attack every deletion with the step-4 script, aiming the break only that test would catch (its own value, member or call, or its origin's bug - not the line's general behaviour) at the unpruned tree:
- It turns that test red: run the same break on the pruned tree; when no survivor goes red, restore the test. Deleted cases may share a break; list the groups and check their counts sum to the deleted total.
- Only a test deleted as Nothing or The past may stay green under its break. Its ledger evidence is that break, aimed at its own assertion and at its origin's bug, or, for code that never runs, the proof (no production caller, the flag's fixed value, the runner not collecting it). Any other deletion that stays green, or one you cannot give this evidence, is restored.
If the prune touched code outside the test files in scope, also run everything that can reach it, the type-check included. Run the repo's coverage gate too, where it has one.
-
Report in these sections, writing "none" in an empty one:
- Ledger - one line per pruned or rewritten test, with its category and a few words of evidence (group parametrised cases and long ledgers), then the counts, taken from the ledger: before, after, deleted and rewritten.
- Break-its - each step-4 check (break, red tests, verdict), then the step-6 groups and every test restored.
- Listed - decisions left in place, follow-ups, older dead code, and weaker partners outside the scope.
Categories
The past - it guards code that is gone or will never run again (a backfill already applied, a flag that is permanently off), or never runs itself: skipped, commented out or never collected, unless the skip is a decision.
- Asserts a removed feature is gone, a file is absent, or a module left its old path - unless the removal fixed a fault or code still refuses the old form, which it then guards.
Nothing - no plausible change to the production code can make it fail.
- Asserts only existence or no-throw (
toBeDefined, truthy,not.toThrow) on code that cannot return nothing or throw. - Bounds so loose no plausible bug crosses them (
x >= 0,x < 1000), or an expected set that admits every outcome (exit in (0, 1)).
A check on a fixture, list, sample or helper that other tests rely on is not Nothing: when it breaks, those tests pass while testing nothing. Nor is a check over a registry or repo data that is empty today.
The implementation - it changes whenever the code does, even when behaviour did not.
- Tautological: the expected value is computed the way the code computes it.
- Asserts private state, internal call order or which helper ran, or what a mock of a collaborator the project owns received or returned; a stub that only trims the setup is no verdict. Mock only at system boundaries (network, clock, randomness, third-party services, or the project's thin wrapper around one).
- A snapshot or pinned literal of whatever the code currently emits, re-recorded whenever the code changes (the git log shows it). Rewrite to assert the few values a caller depends on.
A copy - another test already guards the same behaviour.
-
The partner counts only if it goes red on every regression the copy catches and survives this prune itself (of two tests that name each other, delete one). It must:
- assert the behaviour succeeding;
- run inputs that tell the cases apart - a default fixture cannot tell a configured value from a hard-coded one;
- expect a value not derived the way the code derives it.
Where the guarding assertion is incidental to the partner's subject, add a comment beside it naming what it guards, so a later prune keeps it.
-
Keep the one at the higher seam, closest to what a caller sees; at the same seam, the one with an independent expected value, then the easier to read. Delete the rest. Except: a lower function with production callers besides that seam is a seam of its own, so its tests are not copies; and where a layer adds no branch of its own for a rule (a command line, a route, a wrapper method, a loader that only gathers the service's inputs), keep the layer's wiring tests (any that alone go red when the layer hard-codes what it forwards) and the rule tests at the service - layer tests that re-check those rules are copies.
-
A test holding two implementations equal (two copies of a pattern, a port and its source) is no copy of either side's tests.
-
A partner outside the scope counts as a guard when the checks that run on a change to the code under the rule run it too. Where the outside one is the weaker copy, list it rather than widening the scope.
-
Table-driven cases count as one only when a step-4 break shows their values interchangeable: no break changes one case's result without the others' (another interpreter, flag order or sibling flag is its own case until a break says otherwise). Keep the boundaries and one ordinary case on each side. Each member of a set a condition admits (
status in (warning, critical, missing)) is a boundary, and so is each lookalike the condition must not admit (--forcedbeside--force, a/users/settingsroute beside/users/:id). Failures of the same call that fall straight into the same catch (a rejected fetch, a throwing parse) count as one; another call's failure is its own case, as is a failure with its own branch. A case per entry of a lookup table guards that entry; keep each, unless a partner guards it.
Decisions. A skip or expected-fail with a comment or ticket, a platform guard, a skip-list entry, or a snapshot the repo keeps on purpose to flag changes is a decision, not waste: leave it and list it. A comment or ticket explaining an ordinary test is not; judge the test.
Follow-ups. When a rewrite needs more than the test itself - a seam that does not exist, a new fixture - keep the test as it is and list it as a follow-up.
Done
- Every deleted test has its step-6 evidence.
- Apart from listed follow-ups, no test left asserts absent code, a mock's own return value or a value derived from the code under test, and no two tests guard the same behaviour at the same seam. No orphans remain.
Readme
prune-tests
Test suites gather tests that look like coverage but guard nothing: they assert a deleted feature is gone, check what the type system already guarantees, recompute the expected value the way the code does, or repeat another test. This plugin finds and removes them in one cheap pass, and rewrites the ones that cover real behaviour.
It is the 80/20 pass. The evidence is the test, the code it names, and at most one deliberate break of the code for a test it is unsure of. No mutation campaign, no kill matrix, no new property or E2E suites - run those separately once the obvious waste is gone.
What it prunes
A test stays when it is anchored: it changes only when intended behaviour changes, and fails only when that behaviour regresses. Everything else falls into one of four categories:
| Category | Examples |
|---|---|
| The past | Asserts a removed feature is gone or a module left its old path; tests a spent one-off migration or backfill; a refactor's equivalence suite once the refactor has shipped; skipped, commented-out or .only-shadowed tests; test files the runner never picks up |
| Nothing | Tests the browser, framework or type system; mocks the unit under test and asserts the mock; only toBeDefined or not.toThrow on code that cannot fail that way; bounds too loose for any plausible bug to cross |
| The implementation | Tautological expected values; private state, call order or internal mocks; large snapshots updated wholesale |
| A copy | Another test guards the same behaviour - the one closest to what a caller sees is kept, once that partner is shown to catch the regression |
It also deletes production code, fixtures and helpers that the removed tests leave unused. Dead code that was already there is reported, not deleted.
How a run goes
It is Chesterton's fence with a test harness: rather than asking why a test was written, it breaks the code to see whether the test still guards anything - and where a fix commit added the test, the bug that commit fixed is the first break it tries.
- Scope - the path you give, or the whole suite. Over about 30 test files with no path, it proposes a scope and asks first.
- Baseline - runs the suite. A suite that is already failing stops the run: a pruned test and a broken one would look the same.
- Classify every test in scope as keep, rewrite or delete. Lint rules the repo already has for skipped, focused or assertion-less tests run first, so judgement goes only where a reader is needed.
- Break-it check for close calls only - a suspected sole guard, a test a fix commit added, or a copy's doubtful partner: break the behaviour once at its boundary (
>to>=, off by one), see whether the test fails, revert. - Prune and rewrite.
- Verify - suite green (the full suite too when production code or shared helpers changed), the test count down by exactly the deletions, the coverage gate still passing, and every deletion attacked once more: a surviving test must catch its break, or the ledger must show why nothing could.
- Report a ledger of every deletion and rewrite, with the close calls listed separately and the lint rules that would stop each category coming back.
Changes are left uncommitted so you review the diff before keeping it, unless you ask for a commit.
Install
/plugin install prune-tests@wookstar-claude-plugins
On Claude Code 2.1.275 or later, in one step without adding the marketplace first: /plugin install prune-tests --marketplace henkisdabro/wookstar-claude-plugins
Usage
The skill runs only when you type it - deleting tests should be a deliberate act, so Claude never starts it on its own.
/prune-tests:prune-tests # whole suite (asks for a scope if it is large)
/prune-tests:prune-tests src/billing # one directory
Start on a clean working tree so the diff holds only the pruning.
Model and effort
The skill sets model: opus and effort: high for its turn; your session model returns on your next message. Judging whether a test is tautological or a copy is careful reading, and a wrong deletion costs more than the tokens saved by a smaller model. To run it on your session model instead, change model to inherit in the installed SKILL.md. CLAUDE_CODE_EFFORT_LEVEL, when set, overrides the effort.
Works well with
The skill uses the vocabulary of Matt Pocock's /tdd skill - seam, tautological, implementation-coupled - and points to it for rewrites and to /codebase-design when a test has no seam to rewrite against. Neither is required.
Credit
Built on caldoai's /prune-tests - its three categories (the past, nothing, the implementation) and its examples. This version adds dead and skipped tests, copies, a green baseline and verify step, the break-it check and the ledger.
Details
- Marketplace
- henkisdabro/wookstar-claude-plugins
- Source
- plugins/prune-tests
- Author
- henkisdabro
- Category
- Development
- Keywords
- testing, tests, test-pruning, tautological-tests, dead-code, refactoring
More from henkisdabro/wookstar-claude-plugins
All 43- quarto-revealjsv1.0.1
- react-best-practicesv1.1.0
- shopify-developerv3.1.0
- tampermonkeyv2.1.1
- timezone-toolsv2.0.0
- typstv1.0.1
- ultimate-skill-creatorv2.0.0
- claudecodev3.1.0
- codexv2.0.0
- developerv4.0.1
- documentsv2.0.1
- ffmpegv1.0.2
- geminiv2.0.0
- git-githubv1.0.1
- git-worktreesv1.0.0
- google-ads-scriptsv1.1.1
- google-analyticsv3.0.1
- google-apps-scriptv1.1.1
- google-tagmanagerv3.0.0
- humanisev4.7.0
- humanizerv3.0.0
- lsp-bashv1.0.2
- lsp-cssv1.0.2
- lsp-htmlv1.0.2
Similar to prune-tests
More Development Tools
reamorluto/rea466.8K starsReverse engineer anything with agents, from app behavior down to native binaries.
superpowersobra/superpowers319.5K starsCore skills library for Claude Code: TDD, debugging, collaboration patterns, and proven techniques
claude-apianthropics/skills196.9K starsClaude API and SDK documentation skill for building LLM-powered applications
prompts.chatf/prompts.chat178.2K starsAccess thousands of AI prompts and skills directly in your AI coding assistant. Search prompts, discover skills, save your own, and improve prompts with AI.
agent-sdk-devanthropics/claude-code156.1K starsDevelopment kit for working with the Claude Agent SDK
ui-ux-pro-maxnextlevelbuilder/ui-ux-pro-max-skill152.6K starsProfessional UI/UX design intelligence for AI coding assistants. Includes searchable databases of styles, colors, typography, charts, and UX guidelines for Reac