Skip to main content
skill CX Codex

test-audit · mblode — Claude Code skill: prune low-value tests

test-audit — a skill for Claude Code, Cursor, Codex and other agents that removes low-value tests from a suite down to a measured target while keeping coverage. Runs as a focused directory audit or a whole-repo campaign with a numeric goal.

MIT 283 installs ★ 216 updated 2026-11-10

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add mblode/agent-skills --skill test-audit -a claude-code
Open on GitHub

What test-audit does

The skill targets a specific pattern: agents add a test for every small change, most of which restate the source or replay a contract through a mock. Coverage barely shifts when they go; suite time and maintenance cost do.

Two modes are available. Audit sweeps named files or a directory and produces a batch deletion backed by per-candidate evidence, with the suite green afterward. Campaign works across a whole subsystem or repo against a numeric target — for example, “remove 20% of test declarations while holding line and branch coverage within 2 percentage points of the baseline”. If the user does not give a number, the skill proposes one and proceeds. The repo's existing test runner and a coverage tool it already supports are required: Vitest, Jest, c8, pytest-cov, go test -cover, or equivalent. Without a coverage tool the campaign cannot track its budget.

For each candidate the skill reads the full test, its production owner, callers and callees, sibling implementations, and history. Deletions happen in owner-boundary batches, taking along test-only exports, globals, wrappers, and dead production paths those tests kept alive. A final run with re-measured coverage confirms the result.

What it helps with

  • remove tests that cannot catch any real regression
  • cut a suite by a given percentage without losing coverage
  • eliminate duplicate contract invocations across multiple providers
  • find and move tests living in the wrong owner suite
  • clean up test-only exports and wrappers alongside deleted tests

Example prompts for the agent

  • Remove the least useful 20% of test declarations in src/payments, keeping coverage within 2 percentage points of baseline
  • Audit tests/api/ and list deletion candidates with full evidence for each
  • There are too many tests in lib/slug — run a campaign with a 15% target and confirm green after

How to install test-audit

1Skills CLI (Vercel)

npx skills add mblode/agent-skills --skill test-audit -a claude-code

2Manually: put the files in place

~/.claude/skills/test-audit/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/test-audit/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about test-audit

How do I install test-audit in Claude Code?

Run npx skills add mblode/agent-skills --skill test-audit -a claude-code. The skill will be available at ~/.claude/skills/test-audit/SKILL.md.

What does the test-audit skill do?

It scans a codebase for low-value tests — assertion-free coverage probes, self-comparisons, private call-shape checks, and duplicates — then deletes them in coherent batches down to a target, with coverage held throughout.

Which test runners does test-audit work with?

It needs the repo's existing runner and any coverage tool that runner already supports: Vitest, Jest, c8, pytest-cov, go test -cover, or equivalent. Without a coverage tool the campaign cannot enforce its budget.

Source text

SKILL.md · MIT
---
name: test-audit
description: Prunes low-value tests across a whole suite to a measured target while holding coverage. Use when asked to "remove useless tests", "prune the test suite", "we have too many tests", "agents keep writing pointless tests", or "cut 20% of tests without losing coverage".
compatibility: Needs the repository's test runner and a coverage tool it already supports (Vitest, Jest, c8, pytest-cov, go test -cover, or equivalent).
---

# Test Audit

Tests earn their place by catching a credible regression that nothing else catches. Agents write a test for every small change, and most of those re-assert the source, replay a stronger test through a mock, or pin a private call shape. Coverage barely moves when they go; maintenance cost and suite time do.

- **IS:** sweeping a directory for low-value, misplaced, and skipped tests, and campaign-pruning a whole subsystem or repo to a measured target with coverage held, plus deleting the test-only production seams those tests kept alive.
- **IS NOT:** gating a test before it lands or reviewing a feature diff (`tidy`), making CI faster by splitting or sharding (`ci-speedup`), or writing tests for untested code.

## Pick a mode

| Mode | When | Done means |
|------|------|------------|
| **Audit** | A focused sweep of named files or a directory | A handful of high-confidence candidates with full evidence, deleted in one coherent batch with validation green |
| **Campaign** | A subsystem's or repo's whole test surface, or any request with a target ("remove 20%") | The target is met or the ledger shows why it cannot be, coverage held within tolerance, and the preservation review passed. Read `references/campaign.md` first |

## Set a target before starting

An open-ended "clean up the tests" stops after a few obvious deletions, because every remaining candidate looks defensible in isolation. Audit and Campaign need a number to work against. When the user gave one, use it. When they did not, propose one and proceed on it rather than waiting:

> Remove the least useful 20% of test declarations in `<scope>`, keeping line and branch coverage within 2 percentage points of the baseline and every retained test green.

Measure the baseline first (`references/coverage.md`), then keep deleting in order of lowest value until the target is met or the coverage budget is spent. Stopping short is a valid result only with a ledger showing that the remaining candidates each guard a named contract. The target is a floor on effort, not permission to cut uncertain tests: the retention bar below still wins over the number.

## Junk patterns

What an audit or campaign hunts for:

- assertion-free coverage probes, and tests whose only assertion is "does not throw" on a path that cannot throw
- self-comparisons, identity copies, and expected values produced by the helper or renderer under test
- copied fixtures, inventories, manifests, export lists, or snapshots of data the test also defines
- exact source, import, or string greps that fail on a rename and survive a real behavior change
- private predicate or call-shape tests (`toHaveBeenCalledWith` on an internal) duplicated at a real boundary
- duplicate invocations of one contract, and per-provider replays of a shared helper
- tests whose only purpose is keeping a test-only export, global, or wrapper alive, and production code whose only callers are tests
- mocks that implement the asserted behavior, or one mock standing in for several different APIs
- fixtures that supply the ordering, receipt, or callback the code under test should produce, or persistence asserted against a store the path never writes
- capability tests that restate declared flags instead of exercising what the flag promises
- negative controls that pass for an unrelated reason, such as a rejection from a different guard
- names that promise more than the assertions check: judge the test by its assertions, not its title

## Misplaced and skipped tests

Two more finding kinds. Neither is a removal candidate on that fact alone, and a move or an unskip is not a deletion toward the target.

- **Misplaced:** the test lives in one owner's suite but only exercises another's, such as a slug-format check in `routes/posts.test.ts` that never touches the route and only calls `lib/slug.ts`. Move it to the canonical owner's suite, as "Edit shape" says for retained regressions.
- **Skipped:** the test is disabled, such as `it.skip('prorates refunds on downgrade')`, `xit`, `@pytest.mark.skip`, or `t.Skip()`. Unskip it and run it first; never remove it on sight. If it passes, leave it enabled and judge it like any other test. If it fails, treat it as a possible product bug under the retention bar: reproduce it and fix the owner. A conditional skip with a real platform or environment reason is not a finding.

## Retention bar

Keep a test when it independently enforces a public API, protocol, config, migration, storage, security, platform, default value, generated cross-language, package, release, or architecture contract. Also keep:

- call ordering when the order is observable behavior
- a regression with a credible failure mode
- a source inspection when it is the cheapest independent guard: it fails when the user-facing key, byte, or path changes and survives an identifier-only rename
- a retained test that fails on the baseline: treat it as a possible product bug, reproduce it, and fix the owner rather than deleting it

Static or slow is not a reason to delete. A test that resembles implementation may still be the only proof of a contract; show otherwise before removing it.

## Evidence per candidate

Before judging, read the complete test, the production owner, its callers and callees, sibling implementations, overlapping tests, and the history that explains why the test exists. Record for each deletion:

- test name and location, and what failure it can actually detect
- non-test callers of the seam it covers
- the stronger proof that remains (name the keeper test), or why no contract exists
- the production or test-support code the deletion unlocks
- coverage delta from removing it, when measured

A missing field means the candidate is not ready. Prefer a few high-confidence deletions over a long speculative list; do not convert uncertain candidates into deletions to reach the number.

## Edit shape

Delete in coherent owner-boundary batches. With each batch, delete the test-only exports, globals, wrappers, reset hooks, and dead production paths it unlocks instead of keeping aliases. Move retained regressions to their canonical owner and fold duplicated setup into shared fixtures. Aim for net-negative production lines as well as test lines. Do not add replacement tests that restate the same implementation.

## Validation

1. Run the owner and sibling tests for each batch.
2. Where a deleted test grepped source or asserted a plan, run the script or dry-run that owns the real contract.
3. Re-measure coverage with the same command as the baseline and compare against the budget, per file.
4. Report `git diff --numstat` with production and tooling lines separate from test lines.

## Permissions

Running tests and coverage locally, and deleting tests and test-only seams in the working tree, are the task: do them without asking. Commit, push, or open a PR only when asked. A test that meets the retention bar stays; deleting one anyway is the user's call, as is changing coverage thresholds or CI gates.

## Handoff

- target, baseline, and final numbers: declarations or lines, and line and branch coverage
- removed categories and the root cause behind them (what kept producing these tests)
- production simplifications, counted separately from test lines
- retained false positives and why each stays
- validation actually run, with results
- a proposed gate for the repo's `AGENTS.md`, drawn from the patterns this audit actually found, so agents stop writing them

## Gotchas

- Line coverage survives deletions that remove the only assertion on a path, because another test still executes the lines without checking them. Where a deletion looks free on coverage, confirm a keeper asserts the behavior, or run a mutation against the owner (`references/coverage.md`).
- Aggregate coverage hides a subsystem that lost its only proof while an unrelated area gained. Compare per file for every production file the deleted tests touched.
- Ranking candidates by unique line coverage alone deletes the wrong tests: a test with zero unique lines can still hold the only assertion on them. Unique coverage makes a test a candidate; a named keeper makes it a deletion.
- Editing tests while Vitest or Jest runs in watch mode on the same checkout re-runs half-edited files, and the failures read as regressions from the deletion. Stop the watcher before a batch.

## Reference files

| File | Read when |
|------|-----------|
| `references/campaign.md` | Campaign mode, or any target-driven prune larger than one directory |
| `references/coverage.md` | Measuring the baseline, per-file and per-test coverage, the budget check, and mutation spot checks |

Maintenance only: `evals/evals.json` holds scenarios for changing this skill; it never loads during a task.

## Related skills

- `tidy`: gates a test the moment a diff adds or changes it, and reviews the rest of the diff alongside it. This skill only sweeps or campaign-prunes the existing suite; "audit these tests in my PR" routes to `tidy`, not here.

## Credit

Adapted from OpenClaw's `test-audit` skill ([openclaw/openclaw](https://github.com/openclaw/openclaw/tree/main/.agents/skills/test-audit), MIT). Provenance lives in the repository's maintenance notes.

© mblode · MIT · mblode/agent-skills

Similar skills

All skills for Testing and QA →

test-audit by other authors comes first.

test-audit fcakyon The test-audit skill reviews new and changed tests, and helps spot duplicates or low-value checks. Use it when adding tests or auditing an existing suite. CX Codex +1 ★ 1,216repo stars qe-iterative-loop proffesor-for-testing qe-iterative-loop — a skill that runs autonomous red-green-refactor cycles: the agent fixes failing tests, achieves coverage targets, and passes quality gates on its own. CX Codex +1 126installs test-coverage cognitedata test-coverage — a skill that finds coverage gaps in a Flows app and closes them: configures tooling, writes the missing tests, refactors code for testability. CX Codex +1 1,900installs test-guard amElnagdy test-guard reviews generated or edited test code against universal rules before commit or merge. It catches test bloat, over-mocking, and trivial tests in pytest, Jest, Vitest, Go, and PHPUnit suites. CX Codex +1 4,400installs designing-tests CloudAI-X designing-tests is a skill for planning test coverage, choosing test types, and investigating failures during test additions or testing-workflow setup. CX Codex +1 ★ 1,424repo stars test-coverage-improver OneWave-AI test-coverage-improver — a skill that identifies coverage gaps and generates missing tests for critical code paths. CX Codex +1 312installs generate-test-cases davila7 generate-test-cases is a command for Claude Code that generates code tests, including unit, integration, and edge cases. It analyzes function structure and coverage. CX Codex +1 630installs

From the same set28

The whole set →
eli5 eli5 — a skill that decides how to explain something: plain prose, simplified technical English, a diagram, an HTML page or a video. Useful when an answer is full of jargon. CX Codex +1 407installs seo This skill audits technical SEO, researches search demand, and tracks visibility in search and AI answers. Use it to diagnose indexing, plan a fix, or prepare a content brief. CX Codex +1 391installs save-md save-md saves web pages, YouTube videos, Google Docs and PDFs to a .md file with source metadata. Extracts full text through direct export endpoints, bypassing summaries. CX Codex +1 367installs chat-history chat-history searches earlier AI conversations for decisions, fixes, research, and follow-up events, with paths and message evidence to support the result. CX Codex +1 301installs ghostwriter ghostwriter — a Claude Code skill for drafting and editing text in a user's or company's voice. It activates for requests to write messages, documentation, or feedback on a draft. CX Codex +1 299installs agent-ready agent-ready turns agent-readiness reports and 404 logs into site changes, tests, and checks of public responses. Use it when agents struggle to find your documentation. CX Codex +1 257installs ci-speedup ci-speedup finds where changes stall between push and deploy, then guides changes to CI checks and the merge path. Useful when merges back up or main keeps failing. CX Codex +1 250installs app-verification app-verification — a skill for Claude Code, Codex, Cursor and other agents that scaffolds a project-local verification harness — verify, doctor, and seed commands — inside the target repository. CX Codex +1 217installs

Project sponsors

Companies that keep this analytics open