agentleFS
christofferbergjchristofferbergj/agent-skills/skills/engineering/prune-tests/SKILL.md

prune-tests

Skill1 starsChanged 41 days agoMITView on GitHub

Prune tests that guard no behavior.

17 other projects use a version of this, 6 of them edited.

Adopted by

Most recently taken up by

Used with

Projects with it also use simplify.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • Hugging FaceSkill

    simplify

    Refactor code after tests pass. The "Refactor" phase of Red-Green-Refactor.

    Also in 3 projects that use this

The file

We split this skill into the rules it gives an agent

9 rules. 0 are common, 9 are distinctive, and 0 are very specific to this project.

  • 0

    Common

    Most of the 17 edited versions we read keep these.

  • 9

    Distinctive

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    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.

    line 14
  2. Distinctive:

    If another test already guards the same behavior, prune the copy.

    line 16
  3. Distinctive:

    Nothing: no change to the code can make it fail, so it has no reason of its own to change.

    line 27
  4. Distinctive:

    Delete every test that isn't anchored to intended behavior.

    line 44
  5. Distinctive:

    Delete production code that only existed for the tests you removed.

    line 46
  6. Distinctive:

    Every test left is anchored to intended behavior.

    line 50
  7. Distinctive:

    No test asserts code that no longer exists.

    line 52
  8. Distinctive:

    No two tests guard the same behavior.

    line 53
  9. Distinctive:

    No production code exists only for tests.

    line 54

“Common” is measured: kept by at least 6 in 10 of the 17 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Prune every test that guards no behavior.

1. Find what each test depends on

Invoke /principle-test-behavior-not-implementation for the test-quality criteria.

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.

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

--- 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; }

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.