agentleFS
itsmuskanagarwalitsmuskanagarwal/claude-pack/skills/tdd-loop/SKILL.md

tdd-loop

Skill0 starsChanged 4 months agoMITView on GitHub

Enforce red-green-refactor when implementing a feature from acceptance criteria. Use whenever the user gives acceptance criteria or a spec before any code exists, asks for test-driven development explicitly, or when code-archaeology's plan phase hands off a change with machine-checkable acceptance criteria. Not for legacy code with no spec — that's characterization-tests instead.

9 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

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

  • 0

    Common

    Most of the 9 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:

    Run the tests. Confirm they fail, and confirm they fail for the RIGHT reason (missing implementation), not a setup/typo error.

    line 14
  2. Distinctive:

    Write the minimal implementation to make the failing test(s) pass.

    line 22
  3. Distinctive:

    Hard ban: do not edit the test file during this phase: If the test turns out to be wrong (bad assertion, wrong fixture), STOP, say why, and …

    line 25
  4. Distinctive:

    Run tests again. Confirm green.

    line 29
  5. Distinctive:

    Only after green: refactor for clarity/duplication if warranted.

    line 32
  6. Distinctive:

    Never write implementation before the failing test exists.

    line 40
  7. Distinctive:

    Never edit the test under test during the Green phase to force a pass.

    line 41
  8. Distinctive:

    Never call a suite "green" without having actually run it this session.

    line 42
  9. Distinctive:

    Never skip Phase 1 because "the change is small" — small changes are exactly where skipping the loop is cheapest to regret.

    line 43

“Common” is measured: kept by at least 6 in 10 of the 9 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
<!-- owner: Muskan, added: 2026-07-16, model: claude-sonnet-5, review: quarterly -->

TDD Loop (Red → Green → Refactor)

Phase 1 — Red

  1. Convert acceptance criteria into one or more failing tests BEFORE writing any implementation code. If criteria aren't already stated as concrete input/output pairs, derive them first and confirm with the user if ambiguous.
  2. Run the tests. Confirm they fail, and confirm they fail for the RIGHT reason (missing implementation), not a setup/typo error. A test that errors on a syntax mistake is not "red" in the useful sense — fix the test's own bugs first, re-run, and only proceed once it fails cleanly against absent/wrong behavior.
  3. Report the failing output before moving on.

Phase 2 — Green

  1. Write the minimal implementation to make the failing test(s) pass. Minimal means: don't implement adjacent features the criteria didn't ask for.
  2. Hard ban: do not edit the test file during this phase. If the test turns out to be wrong (bad assertion, wrong fixture), STOP, say why, and get explicit confirmation before touching it — editing your own test to make it pass defeats the entire point of the loop.
  3. Run tests again. Confirm green. Report the passing output.

Phase 3 — Refactor gate

  1. Only after green: refactor for clarity/duplication if warranted. Re-run the full test suite after every refactor step — it must stay green throughout. If a refactor step turns a test red, revert that step before trying another approach; don't debug forward on a red refactor.
  2. Report a summary: red output → green output → any refactor steps and their final green confirmation.

Anti-patterns (hard bans)

  • Never write implementation before the failing test exists.
  • Never edit the test under test during the Green phase to force a pass.
  • Never call a suite "green" without having actually run it this session.
  • Never skip Phase 1 because "the change is small" — small changes are exactly where skipping the loop is cheapest to regret.

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.