Prune Tests That Guard No Behavior
Once per codebase, when the test suite has grown bloated — delete or rewrite every test that guards no behavior so each remaining test fails on a regression and only on a regression.
- existing
- quality
- #testing
- #refactoring
- #tech-debt
- #agents
- by Maze (@mazeincoding)
- github.com
## Context
The codebase is already built and running. The test suite has accumulated tests
that guard no behavior — they churn on every refactor, yet would stay green
through a real regression.
Keep a test only if it depends on the intended behavior: it should change only
when that behavior changes, and fail only when it regresses.
## Goal
Prune every test that guards no behavior, so that each remaining test would fail
on a regression — and only on a regression.
## Inputs
`{{TARGET_PATH}}` — optional path to a file or directory. If none is given,
prune the whole test suite. Everything else is discovered from the repository
itself.
## Instructions
### 1. Find what each test depends on
Keep a test only if it depends on the intended behavior: it should change only
when that behavior changes, and fail only when it regresses.
If another test already guards the same behavior, prune the copy.
Prune tests that depend on:
**The past:** it asserts that removed code stays gone. Bringing it back would be
a decision, not a regression.
For example:
- A feature was removed, and tests assert it's gone.
- A module was moved, and a test asserts it's absent from its old path.
**Nothing:** no change to the code can make it fail, so it has no reason of its
own to change.
For example:
- It tests the browser: a `<button>` renders, or a click event fires. The
browser is already tested.
- It mocks the unit under test, then asserts what the mock returns.
- It asserts what the type system already guarantees.
**The implementation:** it changes whenever the code does, even when behavior
didn't.
For example:
- The expected value is derived from the same logic as the code, so a wrong
result still passes.
- It asserts private state, internal call order, or which helper was invoked.
### 2. Prune
- Delete every test that isn't anchored to intended behavior.
- Where one also covers behavior something relies on, rewrite it against that
behavior instead.
- Delete production code that only existed for the tests you removed.
### 3. Check against what done looks like
- Every test left is anchored to intended behavior.
- Each one would fail on a regression, and only on a regression.
- No test asserts code that no longer exists.
- No two tests guard the same behavior.
- No production code exists only for tests.
### Example
```diff
--- a/pricing.test.ts
+++ b/pricing.test.ts
@@ rewritten: the expected value repeated the code's logic @@
test("applies the discount", () => {
- const price = 100;
- expect(applyDiscount(price, 0.2)).toBe(price - price * 0.2);
+ expect(applyDiscount(100, 0.2)).toBe(80);
});
--- a/cart.test.ts
+++ b/cart.test.ts
@@ rewritten against what callers see: it asserted private state @@
test("adds an item to the cart", () => {
const cart = new Cart();
cart.add(book);
- expect(cart._items.length).toBe(1);
+ expect(cart.total()).toBe(book.price);
});
@@ deleted: checkout.test.ts already guards the same total @@
-test("total includes tax", () => {
- expect(cartTotal([book], { tax: 0.1 })).toBe(11);
-});
--- a/export.test.ts
+++ b/export.test.ts
@@ deleted: it guards code that no longer exists @@
-test("legacy exporter is gone", () => {
- expect(existsSync("src/export/legacy.ts")).toBe(false);
-});
--- a/session.test.ts
+++ b/session.test.ts
@@ deleted, with the production code that only existed for it @@
-test("clears the cache", () => {
- _resetCacheForTests();
- expect(_getCacheSize()).toBe(0);
-});
--- a/session.ts
+++ b/session.ts
@@ @@
-export function _resetCacheForTests() { cache.clear(); }
-export function _getCacheSize() { return cache.size; }
```
## Output format
- The pruned test suite and any removed test-only production code, landed
through the repository's normal change flow (commits or PRs matching its
conventions).
- A report written to `prune-tests-report.md` at the repository root listing:
- each deleted test, with which category it fell into (past, nothing,
implementation, or duplicate);
- each rewritten test, with the behavior it now guards;
- each piece of production code removed because it only existed for tests;
- a final count of tests before and after, and confirmation that the suite
still passes.
## Guardrails
- You may modify repository files — deleting and rewriting tests is the point.
- Never add new tests. Rewrite or delete; do not grow the suite.
- Do not weaken an assertion to make a test pass — rewrite it against intended
behavior or delete it.
- Do not delete production code that anything besides the removed tests uses.
- Every test that remains must fail on a regression and only on a regression.More prompts
## Context You are making this repository's CI as fast as possible without letting it lie. This isa ONE-TIME restructure task. The repository already exists and has a running CI pipelinewith real history to mine. **The rules in the Guardrails section outrank speed. Read them before starting.** ## Goal
Optimize CI Speed Without Weakening Checks
Once per repository, when CI feedback is too slow — audit where pipeline time goes and restructure it toward sub-minute PR results without hiding or dropping any check.
- #ci
- #performance
- #testing
- #bun
pBy @pontusab
## Context You are setting up an automated gate that blocks sloppy, AI-generated Go code. This is aONE-TIME setup task. The repository already exists and builds; nothing has been gated yet. **The ground rules in the Guardrails section are binding. Read them before starting.** Work in the phases below, in order. Do not write any config before Phase 1 is complete andyou have evidence from this codebase.
Set Up a Self-Improving Quality Gate for a Go Repository
Once per Go repository, when the code is already built and you want an automated gate that blocks sloppy, AI-generated Go code and gets stricter over time.
- #go
- #quality
- #ci
- #linting
- #agents
By Claude Sonnet 5.5 Medium
## Context This is a live site that already renders correctly. You are optimizing its web fonts:shrink font bytes as far as possible while keeping rendering identical. This is aONE-TIME optimization task. **The rules in the Guardrails section outrank byte savings. Read them beforestarting.**
Optimize Web Font Loading Without Changing Rendering
Once per site, when web fonts are slowing page loads — subset, split and preload fonts to shrink font bytes as far as possible while keeping rendering pixel-identical.
- #fonts
- #performance
- #web-fonts
- #subsetting
- #frontend
sBy @shuding