/testing:cleanup <<folder>|<repo root>> [--max <n>] [--flaky <test> ...] [--cannot-fail-only] [--repo <repo> ...]from testing
Rewrites, quarantines, or deletes low-value, tautological, vacuous, or flaky tests in a folder or entire repo. Uses mutation gate or cannot-fail-only mode. Never commits unattended.
Ships in testing. 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.
Run each command below as its own Bash call, all sent together in one message (worktree isolation).
Keep any bound in the command's own pipe (output limits).
Unless this section says otherwise, treat a failure (not a repository, git unavailable) as an unknown value and carry on. Keep these as body calls, never ## Pre-computed context lines (gather-block convention).
git branch --show-currentgit symbolic-ref --short refs/remotes/origin/HEAD (unset: ask, unless the
user named it)git status --porcelain | head -20$ARGUMENTS: <folder> (required, one folder per batch; the repository root runs the
Repository plan instead of the steps), --max <n> (the recording run's mutant
cap, default 100), --flaky <test> (repeatable; flaky tests the user names, also taken from the
conversation), --cannot-fail-only (run Cannot-fail-only mode instead of
steps 1 to 6). No folder: run the plan when the user asked for the whole repository, otherwise ask
for one. A target form (--repo, --repos-from, --owner, --fleet, --skip, or the same
request in words) runs Over several repositories.
Every step reads and writes <work> = .work/testing-cleanup/<folder-slug>/ in the repository
root, <folder-slug> being the folder path lowercased with every character outside [a-z0-9._-]
replaced by -. It holds before.tsv and after.tsv (the mutant records), classifier-brief.md,
classifier-answer.md (in cannot-fail-only mode, skeptic-brief-<n>.md and
skeptic-answer-<n>.md instead), decisions.md (the decision table, each item's approval state,
the step reached, and each edited file's git hash-object after its last edit) and pr-body.md.
Right after each edit to a test file (the step 2 quarantine, each rewrite, deletion or merge in
step 5 or cannot-fail-only step 4, each revert the user makes in step 6), run
git hash-object "<path>" and record the hash and the step reached in decisions.md; step 0's
resume check reads them.
Read the working files from that path at every step, never from conversation memory, so a
compacted or resumed session continues where the files say it stopped. Before the first write,
confirm .work/ is ignored (git check-ignore -q .work/x); when it is not, create
.work/.gitignore holding *, and say so.
For the repository root (git rev-parse --show-toplevel), plan one batch per test project, then
run each through the single-folder steps below. The plan edits and runs no test. Its files live in
.work/testing-cleanup-plan/, read at every batch boundary, never from conversation memory.
CANT_FAIL_SCAN_ROOT set to the
repository root, and save its table as findings.md there.project: names a .csproj belongs to that
file's directory; any other row to its own file's directory. A folder inside another listed
folder of the same language (the adapters' language, as step 0 reads it) joins that folder's
batch, since a batch scans its whole folder; one holding a folder of another language is marked
skip: mixed languages, which step 0 would refuse. The repository root is never a batch: list
its own rows as not planned. A project with no finding gets no batch. Mark a batch
skip: kind <kind> when any of its rows has kind live or operational.plan.md there, one row per batch ordered by finding count, most first:
folder, findings, kind, ci, state (pending, skip: <reason>, then the outcome). Show it,
ask whether any unknown-kind batch's tests reach live or shared environments (outside C#,
every kind is unknown), mark each one the user names skip: kind live, and ask which
batches to run; the default is every pending row in order. A skip: kind batch runs only
when the user names its folder, and then only in
Cannot-fail-only mode: never run a live or operational project's
tests, a baseline included.--max and --cannot-fail-only and the --flaky tests under that folder: each batch has its
own <work>, diff and per-item approvals. The next batch starts only after step 7 commits
this one, since step 0 refuses a dirty tree. Record each outcome in plan.md; a batch
that stops records why, and the plan goes on only on the user's yes. Unattended, run only the first pending batch whose kind
is not unknown.With no target form, cleanup runs on the folder or repository root given. A
target form selects several repositories, which resolve and count as
${CLAUDE_PLUGIN_ROOT}/reference/target-scope.md "Target
forms" and "Resolving repositories" say; their writes follow its "Writes stay per repository".
What differs here:
origin/HEAD, on a non-default branch, never its main checkout.
That worktree's root is <root> below.<root>; a repository that lacks it is reported skipped. With no folder, each repository
runs the Repository plan for its own <root>. Plan step 1's scans may fan
out, one subagent per repository as the contract's "Fan-out" says, each running the scanner
with CANT_FAIL_SCAN_ROOT=<root> and returning its table; the main thread writes each
repository's findings.md./mutation-testing:audit (if enabled) and the test-weaken
hook read the session's own project, so steps 0 to 7 for a repository run in a session whose
project is its <root>. This session's project is the checkout it started in, never a <root>
created above, the invoking repository's own included, so under a target form this session runs
the plans and no batch. For every repository, this one included, list its chosen batches with
the /testing:cleanup <folder> command to run in a session opened in that repository's
<root>, one repository at a time; that session runs them with no target form.<work>, .work/testing-cleanup-plan/ and the step 7 findings file
live under that repository's <root>, never the invoking repository's.owner/name, ordered by finding count as plan step 3 orders one repository.pending batch whose kind is not unknown, the one plan step 4 lets an unattended run take.Stop, naming the remedy, when any of these holds; check them all before step 1:
<work>/decisions.md
exists and every changed path's git hash-object "<path>" equals the hash it recorded for that
path after its last edit, continue at the step it records, in cannot-fail-only mode when
decisions.md holds the mode: cannot-fail-only line. A path with a different hash carries
an edit the batch did not make: refuse.mutation-testing plugin is not enabled; the mutation gate needs it.mutation-testing has no config for the repository, or its test-command is missing or lacks a
standalone, unquoted {tests} word: both mutation runs use it. Point to
/mutation-testing:setup apply (if enabled)./testing:audit --file <path> claims no file under it.language), such as a
*.test.sh harness beside Python tests. The one test-command cannot run them all, so the
baseline would be red. Name a subfolder per language and ask for one.The two mutation-testing checks and the language check guard the mutation runs only; they do not
apply under --cannot-fail-only. When every check that holds is one of those three, at least one
being a mutation-testing check, and --cannot-fail-only was not given, name each remedy, then offer
Cannot-fail-only mode and continue in it only on the user's yes.
Unattended, or on a no, stop.
Gather all four before any edit, and write the candidate list to decisions.md:
env CANT_FAIL_SCAN_ROOT="<absolute folder>" bash "${CLAUDE_PLUGIN_ROOT}/skills/audit/scripts/cant-fail-scan.sh" --findings.
Quote every path in a command, each as its own argument. Every row is a candidate, report-only
rules included. Location is repo-relative./testing:audit --judge --persist-findings wrote any. Read every
<memory_dir>/reviews/*/*.md (<memory_dir> is .work/ unless the project's instructions
declare another root, as /testing:audit resolves it) whose frontmatter has
type: review-findings and a branch: equal to
the current branch exactly (the frontmatter, not the directory, proves the branch), and keep
the testing/judge/rule-restated-expectation rows whose Location is under the folder. A FLAG
makes its test a candidate; a PASS clears no scanner finding.mock-only-oracle rows from input 1 are
where layer replays usually surface.Then sweep the folder's existing quarantines: grep -rn -- "test-change: quarantined" "<folder>".
A quarantine whose date is today or earlier is expired. List each expired one in decisions.md
with its owner and tracking issue (none when its reason has neither), and ask the user, per
item, to re-enable it (step 2 removes the skip) or escalate it (the skip stays, and the report
names the owner and issue that must act). Renew a date only on the user's yes, writing the new
date and why into the reason. Never re-enable, renew or delete a quarantine on your own;
unattended, list the expired ones and change none.
No candidate and no expired quarantine: report nothing to clean in <folder> and stop.
Skip each named flaky test with the framework's own skip form, the test_skip or body_skip
vocabulary of the adapter that claims its file (${CLAUDE_PLUGIN_ROOT}/skills/audit/adapters/),
with the reason test-change: quarantined <YYYY-MM-DD>: flaky, <evidence>, owner <who>, tracked <issue>. The date, 7 days out, is the expiry the step 1 sweep reads. Write none for an owner or
issue the user did not give, and report that quarantine as untracked. The test-change: prefix is
the marker the test-weaken hook accepts, so the edit is not denied under
test-weaken-block: error. For each expired quarantine the user chose to re-enable, remove the
skip and leave a test-change: quarantine lifted <YYYY-MM-DD>, tracked <issue> comment at the
edit; a re-enabled test that still fails turns step 3's baseline red. Quarantine comes first so
both mutation runs skip these tests.
A quarantine keeps a flaky test off the blocking path while an owner tracks it to a fix; a skip with no owner or expiry turns it off for good. Basis, MEDIUM (two independent primaries): Google's auto-quarantine files a bug (Flaky Tests at Google, 2016, Google's internal CI; the post also warns quarantine can mask a real race condition), and Azure Pipelines pairs suppression with a bug and resets the flag when it resolves (flaky test management).
Invoke /mutation-testing:audit --exercised <folder> --max <n> --record-mutants <work>/before.tsv (if enabled)
through the Skill tool, with no --paths. Then read its report:
K0 empty, no mapping: scope empty, or a refusal after the user declines both the audit's
install command and its tool: manual offer: the gated batch stops, since nothing the tests
kill can be gated. Name the result, then offer Cannot-fail-only mode
and continue in it only on the user's yes, keeping the step 2 quarantines in the batch.
Unattended, or on a no, stop.--max.Write <work>/classifier-brief.md from context/classifier-brief.md,
with <plugin-root> rendered as ${CLAUDE_PLUGIN_ROOT}, and dispatch a fresh-context
general-purpose subagent with model: opus (for the cases where that alias resolves to the
session's own model, see
sub-agents: choose a model). Opus, not the judge pass's default
sonnet, because a wrong deletion costs more than a wrong verdict. Write its table to
<work>/classifier-answer.md and apply that file's reading rules.
Every brief this skill writes keeps the rendered plugin root, with no resolver or fallback path, relying on how the harness retires a plugin's superseded version directory after an update.
This skill relies on the per-call model it passes taking effect; how that ranks against the
agent's frontmatter and operator overrides is set by
https://code.claude.com/docs/en/sub-agents#choose-a-model.
Fill decisions.md with one row per candidate: test, row, evidence, K citation or no-contract
statement, action, gate-blind, approved-by.
block_model: file (bash-harness) is rewrite-only: never delete or
merge it, or checks inside it.bash "${CLAUDE_PLUGIN_ROOT}/scripts/resolve-config.sh" prints rules.test-weaken-block
error, each deletion carries a test-change: cleanup row <n>: <reason> comment at the edit.before.tsv row is
marked gate-blind and needs the user's yes, even for a rewrite. A test's production files are
the files defining the code it reaches: what it calls directly, through a helper, an interface
or dependency injection, read from the code. Read the calls, not the imports.Unattended, apply only the row 2 and 3 rewrites that are not gate-blind, and leave every yes-gated item listed and unapplied.
First re-scan each file the batch rewrote with the step 1 command plus --file "<path>". A finding
step 1 did not list is a rewrite that cannot fail or checks little (a weak oracle, a recomputed
expectation): the batch stops and names it until the rewrite is repaired. The re-scan sees only
the scanner's rules; the judgment-only shapes in test-value §5 stay with each rewrite's row
review.
Then invoke
/mutation-testing:audit --exercised <folder> --replay-mutants <work>/before.tsv --record-mutants <work>/after.tsv (if enabled)
through the Skill tool and read its Gate: line. The replay
reapplies each before.tsv mutant and compares the records mutant by mutant: one detected before
and not after is newly surviving.
Gate: block: the batch stops. For each newly-surviving <path>:<line> <operator> line, list the
candidate changes: the batch's changed tests whose production files (step 5) include <path>,
or every changed test when none does, since each mutant ran against the whole test set. The
user reverts the ones they choose; then replay again. Cleanup reverts nothing itself.Gate: pass: go on.Gate: line, a refusal, a compare that could not run) stops the batch.
Only Gate: pass reaches step 7.Write the decision table and the gate result (K0 and K1, each newly surviving mutant with its
triage) to <work>/pr-body.md, and the findings file to the branch's findings directory,
.work/reviews/<branch-slug>/<YYYYMMDDTHHMMSSZ>-testing-cleanup.md, the slug and home as
/review:fanout (if enabled) "Shared inputs" defines them. One row per candidate that a rule selected, in the
shape plugins/review/reference/findings-file-shape.md gives: Tier and Confidence copied from
the source row, Surface(s) testing:cleanup, Finding the source row's Finding (rule id and
threshold first) followed by cleanup row <n>: <action>, Action reading
applied by /testing:cleanup in this branch; review, do not re-apply (or kept: <reason>). Quarantined tests have no rule and appear in
pr-body.md only, each with its expiry, owner and tracking issue, beside each expired quarantine
and the user's choice for it (re-enabled, escalated, renewed to a date, or undecided).
Show the batch. While a yes-gated item is still unanswered, stop there and list it. Otherwise
commit the batch's files only (named paths, never git add -A) without waiting for a
batch-level approval: every yes-gated item in it already had the user's answer, and the commit
is local. Report the commit's SHA and how to undo it (while it is the branch's latest commit,
git reset --soft HEAD~1 drops it and keeps its changes staged; later, git revert <sha>),
then delete before.tsv and after.tsv. Push and open the pull request only when the user
asks, through /source-control:pull-request (if enabled). Unattended runs stop
before the commit.
For a folder no usable mutation tool can gate. Deleting a test that cannot fail loses no kill a mutation run could record, so this mode deletes only such tests and needs no gate. It runs no test and no mutation tool, so it is safe on suites whose tests reach live systems. It proposes no quarantine, rewrite or merge. Step 0's branch, tree and folder checks still apply; these steps replace steps 1 to 6, and step 7 follows unchanged.
mode: cannot-fail-only to decisions.md, and record each step reached
as cannot-fail-only <n>. Run the step 1 scanner command and quarantine sweep, and record the
scanner's test blocks parsed count in decisions.md. An in-scope row is one whose rule is
rule-zero-assertion, rule-recomputed-expectation or rule-inert-assertion (section 5 of
${CLAUDE_PLUGIN_ROOT}/skills/test-value/SKILL.md says what each means). The last two flag one
statement, so a test is a candidate only when it has no assertion at all or every assertion in
it is an in-scope row; a test with any other assertion is not in this mode. Every other row is
out of scope, rule-conditional-assertion included (its assertion runs, and can fail, when the
branch is taken), as are judge verdicts and tests the user names as flaky or duplicate: list each in decisions.md as not in this mode and leave it. So is a test in a
block_model: file adapter's file, and a test holding a catch ... when (...) guard, such as a
trial-license check: neither is deleted or edited. List expired quarantines found by the sweep,
and change none. No candidate: report nothing to clean in <folder> and stop, unless step 2
quarantined or re-enabled a test in this batch; then go to step 7 with those alone.<work>/skeptic-brief-<n>.md from
context/skeptic-brief.md, with <plugin-root> rendered as
${CLAUDE_PLUGIN_ROOT}, and dispatch a fresh-context general-purpose subagent with
model: opus, for the reason step 4 (Classify) gives. Write its table to
<work>/skeptic-answer-<n>.md and apply that file's reading rules: only a cleared row is a
deletion candidate. Before the first skeptic, run
bash "${CLAUDE_PLUGIN_ROOT}/lib/read-verification.sh" --plugin testing --skill cleanup --file docs/conventions/testing.yaml and copy
its line into decisions.md (levels);
standard and strict are this step as written. Under light, and off, which acts as light
here, dispatch no skeptic and never clear a candidate in this context instead: each row's skeptic
verdict reads verification: skipped (<level>), no row is cleared, and this mode deletes nothing.decisions.md with one row per candidate: test, rule, quoted line, skeptic
verdict, action, approved-by. A cleared row is a row 4 deletion whose no-contract statement is
the skeptic's reason, unless a reference it quotes as naming a symbol elsewhere lies inside
another cleared test: skeptics run per file, so two candidates can each be the other's only
witness. That row is keep: compile-time reference only in another candidate (<file:line>).
Any other row is keep; when the skeptic names a statement that can throw, the action reads keep: throw is the only oracle (<file:line>), which a gated run or a
cant-fail-ok: <why> annotation can settle later./code-tidying:audit-dead-code (if enabled). Keep the file's line endings: a file whose every line ended in
CRLF before the edit
(grep -c $'\r$' -- "<path>" equals wc -l < "<path>") still does after it. The
test-change: cleanup row 4: <reason> comment rule of step 5 applies.test blocks parsed count must be the count
decisions.md recorded in step 1 minus the approved deletions, and git status --porcelain
must list only files under the folder. Any other result stops the batch and names the difference.Step 7's report states that the batch ran in this mode, which step 0 check or step 3 result led to it, if any, and that no mutation gate ran; it has no K1, and no K0 beyond that step 3 result. Every deletion here is gate-blind by construction. It also states that nothing was built or linted: a helper the deleted test alone used can trip an unused-code check, so ask the user to build and lint the test project before pushing the batch.
test-weaken hook off.pr-body.md as its body: /source-control:pull-request createWhat SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub melodic-software/claude-code-plugins --plugin testing9 skills in this plugin
/auditportability-ok: R6 kept-adapter operation - cant-fail-scan.shRead-only: find tests that cannot fail (assertion-free, tautological, vacuous, mock-only, dead asserts, snapshot-only, change detectors, retry-masking configs, test.only). JS/TS, Python, C#, Bash, PowerShell, Go. Use when: 'find tests that prove nothing', 'audit test quality', can't-fail CI gate (--check, --strict), or --persist-findings. Load it to judge any test, even a pasted one./check-visual-parityCheck visual parityHold UI pixel-for-pixel steady through a change: PNG screenshots of listed states before first edit (baseline), then at each green checkpoint counting differing pixels vs pixel_tolerance (compare). Never edits baseline. Use when plan phase has Parity contract line, refactor must leave UI unchanged, 'check visual parity', 'did this change the UI'./fix-failingFix failingFind why tests fail, then fix them: test triage, root-cause (never retry blindly), reproduce-fix-retest; `diagnose` changes no code. Use when: 'why does this fail', 'fix the failing tests', 'why is this test flaky', failing/flaky tests, stack traces. Not for authoring: /testing:write; runs: /toolchain:check; profiles: /debugging:analyze-profile.Other plugins' skills for the same job