agentleFS
niksavisniksavis/basicly/.agents/skills/test-discipline/SKILL.md

test-discipline

Skill0 starsChanged 57 days agoMITView on GitHub

Writes isolated, order-independent tests that assert what the caller sees, not private helpers. Use for tests with shared fixtures, leaked state or run order.

7 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use {skill-name}.

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.
  • MicrosoftSkill

    {skill-name}

    {what this skill teaches agents}

    Also in 3 projects that use this

The file

We split this skill into the rules it gives an agent

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

  • 0

    Common

    Most of the 7 edited versions we read keep these.

  • 6

    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 suite true as it grows.

    line 9
  2. Distinctive:

    When the code loads its own configuration or environment, put the values where the code reads them: the file, the directory, the …

    line 31
  3. Distinctive:

    When you write a test after its fix, delete the fix and watch the test fail for the stated reason.

    line 37
  4. Distinctive:

    Delete the fix. A test must fail.

    line 42
  5. Distinctive:

    Before you move repeated access behind one shared helper, look at what the tests patch.

    line 64
  6. Distinctive:

    If the change is still correct, move the patch points in the same commit.

    line 67

“Common” is measured: kept by at least 6 in 10 of the 7 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
<!-- Generated by `basicly skills-build` from skill.yaml. Do not edit; edit the source. -->

Test Discipline

Keep a test suite true as it grows. These rules catch a test that passes today and lies, which no formatter, type checker or test runner can see.

Rules

  • A test owns its inputs. Build each fixture it needs and remove it after. A test that reads state it did not make is broken, even when it passes.
  • A test passes alone, in any order and in parallel. Share no mutable state, and do not depend on a sibling test that runs first.
  • Assert on behavior, not internals. Assert on return values, output and visible side effects. A test that breaks on a pure refactor tests the implementation.
  • Remove nondeterminism at the source. Pin the clock, seed randomness, and stub the network and the filesystem. Fix or quarantine a flaky test. Never hide it with a retry.
  • Wait for a condition, not a duration. Measure time with a monotonic clock. Poll the predicate with a generous timeout, so that the assertion says that the event happened.
  • Set a wall-clock limit to twice the time on the slowest runner in the CI matrix. A limit set from a local run fails on a slower runner.
  • Watch a regression test fail before the fix. Then you know that it exercises the defect.

Set up the condition that the code reads

  • When the code loads its own configuration or environment, put the values where the code reads them: the file, the directory, the environment variable. A configuration object that the test gives to a helper never reaches a function that calls its own loader.
  • Prove that the condition is live. Assert that your input changes the value that the code branches on. A threshold at its default or a window too small to trigger stages a case that the code never sees.
  • When you write a test after its fix, delete the fix and watch the test fail for the stated reason.

Mutate the fix in both directions

  1. Delete the fix. A test must fail. This proves that the tests see the fix.
  2. Make the check fire on every input: always warn, always refuse, always the same verdict. A control must fail. If none fails, the suite proves only that the check reacts, not that it discriminates. This direction finds the missing control.
  3. Record which direction found what, so that the next reader can tell a verified check from an exercised one.

Restore from a copy, never with git checkout -- <file>. The working tree usually holds the change under test, and git checkout restores from the index and discards it. Copy the file aside first and copy it back.

An absence needs a positive control

  • A search, scan or query that finds nothing proves nothing alone. Run the same method on a case that you know is present. When that control also finds nothing, the method is wrong.
  • An assertion that something is absent also passes when the locator is wrong. Pin the locator with a case that must match before you trust the case that must not.

A seam is not duplication

  • A module-level alias or thin wrapper around a dependency (a CLI, a clock, an HTTP client) is usually a test seam. Tests replace it.
  • Before you move repeated access behind one shared helper, look at what the tests patch. A new module bypasses each patch of the old alias, and many tests fail for a reason that is not the refactor.
  • If the change is still correct, move the patch points in the same commit. Keep one seam per module, not one for the whole codebase.

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.