agentleFS
ngctongcto/oh-my-pstack/skills/principle-tests-pay-rent/SKILL.md

principle-tests-pay-rent

Skill1 starsChanged 39 days agoMITView on GitHub

Apply when writing, changing, reviewing, or auditing tests, or when a suite feels bloated, duplicated, or coupled to internals. Gate every test on the behavior it protects, the regression that fails it, and why nothing else already covers it; prune tests and test-only seams that do not earn their place.

The file

We split this skill into the rules it gives an agent

1 rule. About 0 are common, 1 is distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    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:

    The authoring gate: Before adding a test, answer four questions.

    line 15

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “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

Tests Pay Rent

A test is a tenant. It occupies CI time, review attention, and refactor friction, and it pays in confidence: it fails when a real defect ships. A test that cannot fail for a defect, or that fails on every harmless rewrite, is a tenant that does not pay. Evict it.

This principle decides whether a test earns its place and where it lives. Test Behavior, Not Implementation decides how a kept test asserts. Run both.

Why: Suites rot by accretion. Each test looks harmless alone, so nobody deletes one, and the pile makes refactors expensive while catching nothing new. Gating at write time is cheap. Pruning later is a campaign.

The authoring gate. Before adding a test, answer four questions. A missing answer means do not add it yet.

  1. What observable behavior, invariant, or independent contract does it protect?
  2. What credible regression makes it fail?
  3. Why does existing coverage not already catch that failure? Each contract has one primary owner at the strongest boundary. A second layer needs its own distinct risk, such as a transport or lifecycle failure the owner cannot reach. Extend a table case or shared fixture before writing a near-duplicate.
  4. Does it demand a production seam (export, flag, wrapper, injection hook) that no real caller needs? If yes, move the test to the real boundary.

Junk patterns. A match fails the gate unless the retention bar names the contract it independently guards.

  • Assertion-free coverage probes, and self-comparisons or identity copiers.
  • Copied fixtures, inventories, manifests, or export lists.
  • Exact source, import, or string greps.
  • Private predicate or call-shape tests that the real boundary already covers.
  • The same contract invoked twice, or a shared helper replayed per provider.
  • Tests whose only job is to keep a test-only export, global, or wrapper alive, and production code whose only callers are tests.
  • Expected values produced by the helper or renderer under test.
  • A mock that implements the asserted behavior, or one identical mock standing in for different APIs.
  • Fixtures that hand over the ordering, receipt, or callback the owner 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 denial from a different guard.
  • Names that promise more than the input exercises: a "retires the window" test that asserts the window was not cleared.

Retention bar. Keep a test that independently enforces a public API, plugin SDK, protocol, config default, migration, storage, security, platform, prompt-byte, generated cross-language, package, release, or architecture contract. Also keep call ordering when order is observable, regressions with a credible failure mode, and source inspection when it is the cheapest guard: it fails when the user-facing key, byte, or path changes and survives an identifier-only rename. Static or slow is not a reason to delete. A retained test that fails on the baseline is a possible product bug: reproduce it and repair the owner.

Regressions. A bug test must fail on the pre-fix code for the intended reason and pass after the owner-level repair. One that never demonstrably failed proves the mock, not the fix. Write one regression at the owner boundary. Do not replay it at every layer the bug crosses.

Refactor check. A behavior-preserving refactor must not break a test. If one does, the test asserted implementation. Rewrite it at the owning boundary before landing it. When auditing, such a test is suspect, not automatically deletable.

Red flags: a suite that grows with every bug and never shrinks, exports added "for tests", three layers asserting the same scenario, deletions resisted because "it's just a test".

To audit an existing suite or prune a whole subsystem, read references/audit-sweeps.md.

See also Small Door, Big Room: tests cross the same seam callers do.

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.