agentleFS
dagarre00dagarre00/claude-code-template/.claude/skills/tdd-loop/SKILL.md

tdd-loop

Skill1 starsChanged 27 days agoMITView on GitHub

Subagent-side, preloaded into the developer. Red-green-refactor procedure for implementing one Behavior case at a time before writing any production code.

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

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

  • 0

    Common

    Most of the 9 edited versions we read keep these.

  • 4

    Distinctive

    This author's own choices. Worth a look.

  • 3

    Very specific

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

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

    Run Red → Green → Refactor → Finish for one Behavior case ([ ] not started → [~] failing test confirmed → [x] passing).

    line 18
  2. Very specific:

    Write one focused test mapped to the case ID (B3 in the test name or description).

    line 22
  3. Distinctive:

    Run the test command and confirm the new test fails.

    line 23
  4. Distinctive:

    Verify it fails for the right reason: missing behavior (assertion failure or not-yet-written target symbol), never a syntax error, broken …

    line 24
  5. Very specific:

    Place files in the layer architecture.md § Layers assigns, respecting dependency direction.

    line 33
  6. Distinctive:

    Only while green: one small structural cleanup within the current entity's scope, re-running tests after each change.

    line 38
  7. Distinctive:

    Leave all changes uncommitted (you run no git).

    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

TDD Loop

Read first

  • docs/wiki/commands.md — test command and architecture check.
  • docs/wiki/architecture.md — ## Testing strategy and ## Layers.
  • docs/wiki/gotchas.md — known test pitfalls.
  • The entity page (docs/wiki/entities/<slug>.md or [infra] concepts/<slug>.md) — ## Behavior is the contract.

One case at a time

Run Red → Green → Refactor → Finish for one Behavior case ([ ] not started → [~] failing test confirmed → [x] passing).

Red

  1. Write one focused test mapped to the case ID (B3 in the test name or description).
  2. Run the test command and confirm the new test fails.
  3. Verify it fails for the right reason: missing behavior (assertion failure or not-yet-written target symbol), never a syntax error, broken fixture, or bad import of existing code.
  4. Mark the case [ ] → [~].
  5. Quote the failing assertion line in your report (pass/fail counts alone are rejected).

The conductor re-proves Red after you return by restoring everything except your reported test paths to HEAD~1 and running the focused test command over them. Keep all new test files, fixtures, and test helpers inside the test paths you report.

Green

  1. Climb simplicity-ladder and write the smallest code that makes the test pass.
  2. Place files in the layer architecture.md § Layers assigns, respecting dependency direction.
  3. Run the focused test command (commands.md § Test (focused); the full test command while it is <TBD>) over the new test and every existing test file covering the code you changed, plus the architecture check, until they pass. Breaking another test means you over-reached: narrow the change and retry. The conductor runs the full suite once when the cycle's case loop closes.

Refactor

Only while green: one small structural cleanup within the current entity's scope, re-running tests after each change.

Finish

  1. Tick [~] → [x] and update the entity page's ## Implementation and ## Tests sections.
  2. Leave all changes uncommitted (you run no git).
  3. Report: test paths, implementation paths, the existing test files you ran beside them, wiki paths, quoted Red assertion, final test output, and a one-line summary of any refactor.

Stop and report instead of guessing

  • The test or spec appears to encode wrong behavior (never alter the test to force a pass).
  • Green requires out-of-scope files or a forbidden layer dependency.
  • Unresolved design fork not settled by the wiki.
  • Second failed attempt on the same mechanism (two-strike rule).

Anti-patterns

  • Modifying tests to make them pass.
  • Bulk green (writing multiple cases before implementation).
  • Refactoring before green.
  • Treating broken imports/fixtures as Red.

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.