Skip to content
Back to skills

Test Slop

ASecurity

Audit and safely prune a bloated Laravel test suite (Pest or PHPUnit), especially one grown by AI agents — copy-pasted tests, status-only checks, circular expectations, change-detectors, silent skips, slow setup. Every removal is gated on mutation testing (no mutant the old tests killed may survive), work goes one folder at a time, and an authoring gate stops the slop growing back. Use when a suite has thousands of tests nobody trusts, CI is slow, or AI-written tests need a cleanup. Triggers ...

  • 2 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added December 2, 2026
ai-agentstypescriptpythonrustgophpbashspringtestinggitdatabase

Security analysis

A100/100

Pro scans all 18 files and shows the line behind each finding

Scanned December 2, 2026

npx -y skills add airshell/laravel-php-to-rust --skill test-slop --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Test Slop?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Test Slop
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/airshell-test-slop/badge)](https://www.skillsdirectory.com/skills/airshell-test-slop)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: test-slop
description: Audit and safely prune a bloated Laravel test suite (Pest or PHPUnit), especially one grown by AI agents — copy-pasted tests, status-only checks, circular expectations, change-detectors, silent skips, slow setup. Every removal is gated on mutation testing (no mutant the old tests killed may survive), work goes one folder at a time, and an authoring gate stops the slop growing back. Use when a suite has thousands of tests nobody trusts, CI is slow, or AI-written tests need a cleanup. Triggers on "clean up tests", "prune test suite", "test slop", "too many tests", "remove useless tests", "audit tests", "tests are slow". Not for Laravel for Rust apps (laravel-rust crate).
license: MIT
metadata:
  author: agent-skills
  version: "1.0.2"
---

# Test Slop: Audit and Prune a Laravel Test Suite

Cleans a test suite without losing protection. Contains 34 rules across 9 categories, three bundled scripts (a scanner, a slowest-tests report, and a mutation gate for Pest or Infection), and a workflow that never deletes a test on a smell alone. Where [`code-slop`](../code-slop) flags AI patterns in code (with four test rules) and [`laravel-testing`](../laravel-testing) / [`testing-best-practices`](../testing-best-practices) teach how to write tests, this skill is for the suite that already exists: thousands of tests, many written by agents, and nobody sure which ones still guard anything.

## Metadata

- **Version:** 1.0.2
- **Scope:** Laravel 10+ with Pest 3–5 or PHPUnit 10–13; frontend tests (Vitest / Jest / Playwright) in Inertia or Livewire apps are scanned too
- **Rule Count:** 34 rules across 9 categories
- **Scripts:** `$TEST_SLOP/scripts/scan.py`, `$TEST_SLOP/scripts/slowest.py` (Python 3.9+, standard library only), `$TEST_SLOP/scripts/mutate-gate.sh` (bash)
- **License:** MIT

## Why this skill exists

- **Coverage is a weak signal.** Test suites have been measured at 100% coverage with a 4% mutation score (arXiv 2506.02954). Agent-grown suites, cheap to write and rarely read, widen that gap.
- **Coverage-based pruning loses bugs.** Reducing a suite by statement coverage kept coverage flat and lost up to 20.5% of the killed mutants; mutation-based reduction kept them (Gyori et al., FSE 2014).
- **Agents over-generate and then rewrite tests to match broken code.** Practitioners pruning agent-grown suites report hundreds of thousands of deletable lines with little coverage change, and name "the agent edited the expected value" as the main way tests lose their value.
- **Smell names are weak evidence.** Several classic smells (Assertion Roulette, Eager Test) are contested and detected inaccurately (Panichella et al., 2022), so a smell is a lead, not a verdict.

The core rule: **a test leaves the suite only when the tests that remain still kill every mutant it killed.**

**Not for Laravel for Rust.** If the project is a Laravel for Rust app (its `Cargo.toml` depends on the `laravel-rust` crate), this skill does not apply: its workflow and mutation gate assume a Pest or PHPUnit suite. Use the agent skills the app ships in `.agents/skills/` and the version-matched docs bundled with the crate.

## Modes

| Mode | When | Changes files? | Output |
|---|---|---|---|
| **Audit** (default) | "audit the tests", "how bad is it" | No | Scan summary + ledger (KEEP / MERGE / STRENGTHEN / DELETE per test, with evidence) |
| **Campaign** | "clean up tests/Feature/Orders", "prune the suite" | Yes, one folder per step, after the ledger is approved | Changed tests, gate results, `.test-slop/CAMPAIGN.md`, one commit per folder |
| **Authoring gate** | Writing or reviewing new tests | No (review) | The four answers per new test, or "extend test X instead" |

Never start a campaign without an approved ledger for that folder. Never commit or push unless the user asks.

## Workflow

### Step 1: Detect the setup

| Signal | Meaning |
|---|---|
| `vendor/pestphp/pest` | Pest (runs PHPUnit classes too) |
| `vendor/pestphp/pest-plugin-mutate` | Mutation gate engine: Pest (`--mutate`) |
| `vendor/bin/infection` | Mutation gate engine: Infection (plain PHPUnit) |
| neither mutation tool | Suggest `composer require --dev pestphp/pest-plugin-mutate` (Pest) or `infection/infection` (PHPUnit); audit still runs, campaign does not delete |
| `php -m` lists `xdebug` or `pcov` | Coverage driver present (required for mutation) |
| `package.json` with vitest / jest / @playwright/test | Frontend tests: scanned; mutation via Stryker (manual) |
| `.test-slop/protected.txt` | Project's own protected list (one path or test-name fragment per line) |
| `.test-slop/CAMPAIGN.md` | A campaign is in progress: read it first and continue from it |

### Step 2: Scan (changes nothing)

Commands run from the project root. `$TEST_SLOP` is the folder this skill is installed in, for example `TEST_SLOP=.claude/skills/test-slop` (project install) or `TEST_SLOP=~/.claude/skills/test-slop` (global).

```bash
python3 $TEST_SLOP/scripts/scan.py . --json .test-slop/scan.json          # whole suite
python3 $TEST_SLOP/scripts/scan.py . --tests tests/Feature/Orders          # one folder
```

Flags: `same-shape` groups, `status-only`, `no-assertion`, `type-only`, `reads-source`, `exact-copy` (sentences that exist in the lang files), `long`, `sleeps`, `skipped`, giant and comment-heavy files. Tests matching `.test-slop/protected.txt` are marked `[protected]`. Every flag is a candidate to read, not a verdict.

### Step 3: Measure

```bash
vendor/bin/pest --parallel --log-junit .test-slop/junit.xml     # or: vendor/bin/phpunit --log-junit .test-slop/junit.xml
python3 $TEST_SLOP/scripts/slowest.py .test-slop/junit.xml --top 20
bash $TEST_SLOP/scripts/mutate-gate.sh baseline 'App\Services\OrderService' tests/Feature/Orders
```

Large controllers make slow runs (hundreds of mutants, several minutes each), so start from the class the flagged test is about and the test file next to it. Take a baseline for **every app class the tests you will change cover**: the controller, the service, the policy, the FormRequest, the middleware. That is usually a handful per folder, not the whole app. Route files and config are not mutated, so a merged access test must keep every route as a dataset row (diff the URIs before and after). Change only tests between `baseline` and `check`; deleting a feature's own code is `dead-removed-feature`, outside the gate.

### Step 4: Write the ledger

In audit mode you can prove a DELETE without editing anything: arguments after `--` go to the test runner, so the check leaves the candidate out.

```bash
bash $TEST_SLOP/scripts/mutate-gate.sh check 'App\Http\Controllers\OrderController' tests/Feature/Orders \
  -- --exclude-filter='customer can view the orders page'
```

Read every flagged test and its neighbours. One line per test that changes; KEEP lines only where there was doubt:

```markdown
## Ledger: tests/Feature/Orders (2026-11-30)

| Test | Verdict | Reason | Holder / change | Gate |
|---|---|---|---|---|
| OrdersPageTest.php:14 "turns a guest away" | MERGE | 1 of 12 identical guest checks | → Auth/GuestAccessTest dataset row `orders` | Authenticate middleware: killed 18 → 18 |
| OrdersPageTest.php:40 "admin views orders" | STRENGTHEN | only assertOk | + assertInertia on count and totals, + other-branch row | OrderController: killed 31 → 39 |
| OrderTotalTest.php:22 "displays the total" | DELETE | subset of :10 (same request, fewer assertions) | holder OrderTotalTest.php:10 | Order: killed 44 → 44 |
| ExportTest.php:40 "csv header" | KEEP (doubt) | partner may read the CSV | ask: is this CSV imported elsewhere? | — |
```

Save it as `.test-slop/ledger-<folder>.md` and show it to the user before changing anything.

### Step 5: Apply one folder (campaign only)

1. Apply the approved lines only. MERGE keeps every case as a dataset row. STRENGTHEN uses literal expected values.
2. `$TEST_SLOP/scripts/mutate-gate.sh check '<Class>' <paths>` for every class with a baseline. Exit 1 = a kill was lost: put the test back or strengthen another.
3. Run the folder's tests (`--parallel`), then the whole suite before the commit.
4. Update `.test-slop/CAMPAIGN.md` (before/after counts, killed before → after, time) and commit that folder alone, when the user asks.

### Step 6: Report

Tests before → after, killed mutants per gated class (never lower), suite wall time before → after, doubts left open, next folder.

## Rule Categories by Priority

| Priority | Category | Impact | Prefix |
|----------|----------|--------|--------|
| 1 | Gates | CRITICAL | `gate-` |
| 2 | Keep | CRITICAL | `keep-` |
| 3 | Redundant | HIGH | `redundant-` |
| 4 | Weak | HIGH | `weak-` |
| 5 | Circular | HIGH | `circular-` |
| 6 | Change-detector | MEDIUM | `brittle-` |
| 7 | Dead | MEDIUM | `dead-` |
| 8 | Bloat | MEDIUM | `bloat-` |
| 9 | Slow | MEDIUM | `slow-` |

## Quick Reference

### 1. Gates (CRITICAL)

- `gate-evidence-ladder` — Flag → reason → holder → mutation → green; no rung, no DELETE
- `gate-mutation-before-delete` — No mutant killed in the baseline may survive the check (same run identity); never the score, never coverage alone
- `gate-one-folder-at-a-time` — Stated target, one folder per step, `CAMPAIGN.md`, one commit per folder
- `gate-authoring-four-questions` — Behaviour, failure, gap, seam: answer before adding a test

### 2. Keep (CRITICAL)

- `keep-protected-contracts` — Money, permissions, data shape, external contracts, real-bug regressions: MERGE or STRENGTHEN only
- `keep-when-unsure` — `KEEP (doubt: …)` with the question written down

### 3. Redundant (HIGH)

- `redundant-same-shape-dataset` — Copy-pasted tests become one dataset that keeps every case
- `redundant-coverage-subset` — A test whose kills are all killed by another
- `redundant-same-flow-twice` — The rule at the fastest layer; one wiring case per upper layer
- `redundant-framework-behaviour` — Relations, `create()`, `required`: Laravel's tests, not yours

### 4. Weak (HIGH)

- `weak-status-only` — A 200 is not a test of the page (403 / 404 / redirect checks are fine)
- `weak-no-assertion` — Calls the code and checks nothing
- `weak-type-only` — `toBeInstanceOf` / `toBeArray` / `not->toBeNull` instead of the value
- `weak-asserts-the-fixture` — Reads back the value the factory or the mock was given
- `weak-silent-skip` — `try/catch → markTestSkipped`, skips that depend on the code's outcome

### 5. Circular (HIGH)

- `circular-expected-from-formula` — Expected value computed like the code (or from the code's constants)
- `circular-mock-is-the-behaviour` — The unit under test is mocked or partially mocked
- `circular-rewritten-to-pass` — Expected value edited to match changed code, with no rule change

### 6. Change-detector (MEDIUM)

- `brittle-copy-pinned` — Full sentences from the lang files instead of the key and its values
- `brittle-source-grep` — `file_get_contents(app_path(...))` instead of behaviour or `arch()` tests
- `brittle-implementation-calls` — `shouldReceive` on own internals, reflection on private methods
- `brittle-incidental-detail` — Exact ids, order, timestamps, whole payloads
- `brittle-snapshot` — Big snapshots re-recorded on every change

### 7. Dead (MEDIUM)

- `dead-removed-feature` — Tests that keep a removed feature's code alive
- `dead-long-skipped` — Skips and todos older than a month with no owner
- `dead-flaky` — Fix the cause (clock, randomness, order, shared state) or quarantine with an owner

### 8. Bloat (MEDIUM)

- `bloat-narration-comments` — `// Arrange` / `// Act` / docblocks repeating the name
- `bloat-long-test` — One test, five rules; split by rule (length alone is not the smell)
- `bloat-giant-file` — 1,000+ lines with no `describe`
- `bloat-copied-setup` — Same setup pasted everywhere → factory states and helpers

### 9. Slow (MEDIUM)

- `slow-sleep-real-time` — `sleep()` and real clocks → `Sleep::fake()`, `travel()`, fake timers
- `slow-real-network` — `Http::preventStrayRequests()` for the whole suite
- `slow-heavy-setup` — Whole-database seeding, `count(200)`, the app booted for pure functions
- `slow-not-parallel` — `--parallel`, `--shard`, `--dirty`

## Verdicts

| Verdict | Means | Evidence needed |
|---|---|---|
| **KEEP** | Leave as is | — (write the doubt if there was one) |
| **MERGE** | Fold into a dataset or another test, keeping every case | reason, mutation gate, green |
| **STRENGTHEN** | Add the missing assertion, case or fake | reason, green; killed should rise |
| **DELETE** | Remove | reason, holder, mutation gate, green; never for `[protected]` or `keep-*` tests |

Slow, long, static or ugly is never on its own a reason for DELETE.

## Scripts

| Script | Does | Needs |
|---|---|---|
| `$TEST_SLOP/scripts/scan.py [root] [--tests DIR] [--json FILE] [--top N] [--long N]` | Lists candidates per flag; never touches tests or app code (writes only the `--json` file you name) | Python 3.9+ |
| `$TEST_SLOP/scripts/slowest.py junit.xml [--top N]` | Slowest tests and files from any JUnit log | Python 3.9+ |
| `$TEST_SLOP/scripts/mutate-gate.sh baseline\|check '<Class>' <test paths…>` | Mutation baseline and check per class; exit 0 pass, 1 lost a kill, 2 could not run | Pest mutate plugin or Infection; Xdebug or PCOV |

`mutate-gate.sh` environment: `TEST_SLOP_ENGINE=pest|infection` (else auto), `TEST_SLOP_PHP_FLAGS` (coverage driver flags), `TEST_SLOP_DIR` (where baselines go; default `.test-slop/mutate`), `TEST_SLOP_MEMORY` (Pest memory limit; default 2G). It compares the set of surviving mutants, so change only tests between `baseline` and `check`, never app code. With Infection, test paths become a PHPUnit `--filter` on their namespace (`tests/Feature/Orders` → `Tests\Feature\Orders\`), which assumes the Laravel default `Tests\` → `tests/` mapping.

Add `.test-slop/` to `.gitignore` except `CAMPAIGN.md` and `protected.txt`, which the team should see.

## How to Use

Read individual rule files for detail and examples:

```
rules/gate-evidence-ladder.md
rules/gate-mutation-before-delete.md
rules/keep-protected-contracts.md
rules/redundant-same-shape-dataset.md
rules/weak-status-only.md
rules/circular-rewritten-to-pass.md
```

Each rule file contains:
- YAML frontmatter (title, impact, tags)
- Why the pattern costs the suite
- "Incorrect" and "Correct" examples (Pest; TypeScript where the frontend matters)
- The verdict and the evidence it needs
- Detection (scanner flag, grep, or tool)
- References

## References

- [Pest — Mutation Testing](https://pestphp.com/docs/mutation-testing) · [Pest — Architecture Testing](https://pestphp.com/docs/arch-testing) · [Pest — Datasets](https://pestphp.com/docs/datasets)
- [Infection](https://infection.github.io/) · [Stryker](https://stryker-mutator.io/)
- [Gyori et al. — Comparing coverage- and mutation-based test-suite reduction (FSE 2014)](https://mir.cs.illinois.edu/gyori/pubs/fse14reduction.pdf)
- [arXiv 2506.02954 — Mutation-guided unit test generation](https://arxiv.org/abs/2506.02954)
- [Panichella et al. — Test smells 20 years later](https://link.springer.com/article/10.1007/s10664-022-10207-5)
- [Google Testing Blog — Change-detector tests considered harmful](https://testing.googleblog.com/2015/01/testing-on-toilet-change-detector-tests.html)
- [Kent Beck — Test Desiderata](https://medium.com/@kentbeck_7670/test-desiderata-94150638a4b3)
- [explainx — A test-audit skill that pruned 400K lines of tests](https://explainx.ai/blog/openclaw-test-audit-skill-deleted-400k-lines-tests-2026) · [qa.tech — When to kill a test](https://qa.tech/blog/when-kill-test-how-prune-test-suite-that-s-slowing)

## Full Compiled Document

For the complete guide with all rules expanded: `AGENTS.md`

Files in this skill

  • .DS_Store6 KB
  • README.md3.7 KB
  • SKILL.md15.5 KB
  • rules/_sections.md3.2 KB
  • rules/_template.md798 B
  • rules/bloat-copied-setup.md2.7 KB
  • rules/bloat-giant-file.md2.1 KB
  • rules/bloat-long-test.md2.9 KB
  • rules/bloat-narration-comments.md2.4 KB
  • rules/brittle-copy-pinned.md3 KB
  • rules/brittle-implementation-calls.md3.3 KB
  • rules/brittle-incidental-detail.md2.9 KB
  • rules/brittle-snapshot.md2.6 KB
  • rules/brittle-source-grep.md3.1 KB
  • rules/circular-expected-from-formula.md3.2 KB
  • rules/circular-mock-is-the-behaviour.md3.1 KB
  • rules/circular-rewritten-to-pass.md3.1 KB
  • rules/dead-flaky.md3 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.