agentleFS
HM-IT-CODEHM-IT-CODE/forge-skills/skills/engineering/tdd-loop/SKILL.md

tdd-loop

Skill0 starsChanged 6 months agoMITView on GitHub

Drives a strict test-driven development loop for any new behavior or bug fix. Use when the user asks to implement a feature, add functionality, fix a bug, or says "use TDD" / "write tests first". Forbids writing production code before a failing test exists.

6 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

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

  • 0

    Common

    Most of the 6 edited versions we read keep these.

  • 11

    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:

    Write the test before any implementation.

    line 16
  2. Distinctive:

    Run the suite. Confirm the new test fails, and that it fails because the behavior is missing — not because of a typo, import error, or …

    line 17
  3. Distinctive:

    Write the minimum production code to pass the failing test.

    line 20
  4. Distinctive:

    Run the full suite. All tests must pass before you continue.

    line 21
  5. Distinctive:

    Run the suite again after each change.

    line 25
  6. Distinctive:

    Never: write production code that isn't demanded by a failing test.

    line 31
  7. Distinctive:

    If a test is hard to write, that's a design signal — the unit under test is probably doing too much.

    line 33
  8. Distinctive:

    Don't delete or weaken a test to get green.

    line 34
  9. Distinctive:

    Keep tests fast and isolated.

    line 35
  10. Distinctive:

    Before the first test, identify the test runner from the project:

    line 39
  11. Distinctive:

    Use the existing convention in the repo.

    line 45

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

You are pairing with an engineer who wants behavior built test-first. Follow the loop below without skipping steps. Do not write production code until a test for it fails for the right reason.

The loop

For each unit of behavior, run Red → Green → Refactor:

  1. Red — write one failing test.
    • Pick the smallest next behavior. One assertion's worth of new intent.
    • Write the test before any implementation. It must describe what the code should do, not how.
    • Run the suite. Confirm the new test fails, and that it fails because the behavior is missing — not because of a typo, import error, or compile error. Read the failure message out loud (in your reasoning) and verify it's the expected one.
  2. Green — make it pass with the least code.
    • Write the minimum production code to pass the failing test. Hardcoding a return value is acceptable at this stage if it's genuinely the simplest thing.
    • Run the full suite. All tests must pass before you continue.
  3. Refactor — clean up under green.
    • With every test passing, improve names, remove duplication, and clarify structure.
    • Run the suite again after each change. Never refactor on a red bar.

Then repeat for the next behavior. Small loops beat big ones — aim for cycles of minutes, not hours.

Rules

  • Never write production code that isn't demanded by a failing test.
  • One failing test at a time. Don't write five tests then implement.
  • If a test is hard to write, that's a design signal — the unit under test is probably doing too much. Pause and tell the user before forcing it.
  • Don't delete or weaken a test to get green. If a test is wrong, say so explicitly and explain why before changing it.
  • Keep tests fast and isolated. No network, no real clock, no shared mutable state unless the behavior under test is that integration.

Detect the stack first

Before the first test, identify the test runner from the project:

  • Node/TS: vitest, jest, node:test — check package.json.
  • Python: pytest, unittest.
  • Rust: cargo test (#[cfg(test)] modules or tests/).
  • Go: go test with _test.go files and table-driven cases.

Use the existing convention in the repo. If none exists, propose one and wait for confirmation.

Output discipline

At each step state which phase you're in (RED / GREEN / REFACTOR), show the test or diff, and report the suite result. End the task only when the suite is fully green and you've offered the next behavior to drive.

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.