agentleFS
justinzapantajustinzapanta/claude-reliable-kit/skills/tdd-loop/SKILL.md

tdd-loop

Skill1 starsChanged 6 days agoMITView on GitHub

Test-first fixes. Use when fixing a reproducible bug or failing test, adding behavior with a runnable test suite, or when asked for TDD, a regression test, or to verify a fix.

10 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

4 rules. 0 are common, 3 are distinctive, and 1 is very specific to this project.

  • 0

    Common

    Most of the 10 edited versions we read keep these.

  • 3

    Distinctive

    This author's own choices. Worth a look.

  • 1

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Read the nearest implementation and tests.

    line 12
  2. Distinctive:

    Write the smallest implementation that makes it pass.

    line 15
  3. Distinctive:

    Prefer one meaningful test over many redundant ones.

    line 27
  4. Distinctive:

    If a test is impractical, say why and use the closest honest check.

    line 31

“Common” is measured: kept by at least 6 in 10 of the 10 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

TDD Loop

Turn the intended behavior into a failing test before writing the implementation. Keep each loop small enough that every failure is easy to explain.

Red, green, refactor

  1. Read the nearest implementation and tests. Find the project's test command and conventions. If the suite prints a lot, run it as python ${CLAUDE_SKILL_DIR}/../lean-navigation/scripts/squeeze.py -- <test command> so only failures and the summary come back.
  2. State the behavior and its important boundaries. Name the production change that would make the test fail; if none would, the test is useless.
  3. Write one focused test at the layer that owns the behavior. Run it before touching production code. It must fail because the behavior is missing, not because of a typo, fixture, or environment problem. Optionally record the red run as evidence: python ${CLAUDE_SKILL_DIR}/../task-ledger/scripts/ledger.py fact "red: <behavior>" --run "<test command>" --expect-exit 1. If it already passes, rethink the test.
  4. Write the smallest implementation that makes it pass. No unrelated cleanup or speculative abstraction.
  5. Rerun the focused test and see it pass (python ${CLAUDE_SKILL_DIR}/../task-ledger/scripts/ledger.py fact "green: <behavior>" --run "<test command>" --proves <req id>). Then run the suite for the code you touched, or the full suite when a shared contract changed.
  6. Refactor only to improve clarity or remove duplication, and rerun the same checks.

Work in vertical slices: one test, then its code, then the next. Never write all the tests first.

Test quality

  • No tautologies: the expected value must come from the requirement or a hand-worked example, never from the same formula the code uses.
  • Mock only at system boundaries (network, clock, payment provider, filesystem when needed). Never mock the behavior under test.
  • Regression proof for a bug fix: temporarily revert the fix and confirm the new test fails, then restore it.
  • A test that is hard to write often signals an unclear design; say so rather than forcing it.
  • Prefer one meaningful test over many redundant ones.

When TDD doesn't fit

If a test is impractical, say why and use the closest honest check. If the user asks not to run tests, respect it and report the behavior as unverified. Never report an unrun test as passing.

Report

The behavior covered, the exact test command, and its observed result (red, then green), plus any remaining gap.

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.