agentleFS
ethosagentethosagent/ethos/skills/software-development/tdd/SKILL.md

tdd

Skill22 starsChanged 10 days agoMITView on GitHub

Enforce RED → GREEN → REFACTOR. Write a failing test before any production code; make it pass with the minimum change; then refactor. Refuses to start with a broken baseline.

194 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use capture-learning-tools, design-frontend-dev and 10 more.

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.
  • The-Vibe-CompanySkill

    capture-learning-tools

    Turn technical conversations, bugs, CI failures, review comments,

    Also in 5 projects that use this

  • The-Vibe-CompanySkill

    design-frontend-dev

    Clean Impeccable frontend design skill. Use when the user wants to

    Also in 5 projects that use this

  • tristanphvnSkill

    ketchup-video

    Catch the user up like /keel:ketchup, with a short silent video of slides for what happened and the waiting calls as text under it. Use for /keel:ketchup-video.

    Also in 14 projects that use this

  • jaydubya818Skill

    figure-it-out

    Use when novel or multi-phase work needs an auditable workflow and no narrower playbook fits.

    Also in 54 projects that use this

  • jaydubya818Skill

    principle-laziness-protocol

    Apply when a refactor is adding wrappers or abstractions instead of simplifying.

    Also in 45 projects that use this

  • +2 more from The-Vibe-Company
  • +5 more from jaydubya818

The file

Show its rules and text

We split this skill into the rules it gives an agent

17 rules. 0 are common, 14 are distinctive, and 3 are very specific to this project.

  • 0

    Common

    Most of the 186 edited versions we read keep these.

  • 14

    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. Distinctive:

    When the change is purely mechanical (rename, formatting, dead-code removal) tests are not the right gate — skip TDD.

    line 39
  2. Distinctive:

    Before doing anything else, find the project's test runner:

    line 43
  3. Very specific:

    Use the run_tests tool when available.

    line 53
  4. Distinctive:

    Run the test suite once before writing anything new.

    line 57
  5. Distinctive:

    Write the failing test. One concrete assertion at a time.

    line 67
  6. Distinctive:

    Run the suite. The new test must fail.

    line 68
  7. Distinctive:

    If it fails for the wrong reason, fix that and re-run before continuing.

    line 70
  8. Distinctive:

    Write the smallest production change that makes the new test pass.

    line 73
  9. Distinctive:

    Run the suite. The new test plus all prior tests must be green.

    line 74
  10. Distinctive:

    If anything regresses, the GREEN step is incomplete — keep going.

    line 75
  11. Distinctive:

    Run the suite after each refactor — refactors that break tests are no longer refactors, they're behaviour changes.

    line 79
  12. Distinctive:

    Stop refactoring when no further improvement is obvious.

    line 80
  13. Very specific:

    If the todo tool is available, write each RED-GREEN-REFACTOR as a todo item.

    line 84
  14. Distinctive:

    Run the full test suite.

    line 90
  15. Very specific:

    Run the project's check command (lint + typecheck + test in one) if it exists.

    line 91
  16. Distinctive:

    No production code without a test that drove it: If you find yourself editing production code with no failing test that needs it, stop — …

    line 96
  17. Distinctive:

    One cycle, one behaviour: If a single test forces you to write four new methods, the test is too broad — split it.

    line 98

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

Discipline, not vibes. Every behaviour change goes through one full RED → GREEN → REFACTOR cycle before the next behaviour begins.

When to use this skill

  • The user mentioned TDD, tests-first, "write the test first".
  • You are adding behaviour to a codebase that already has tests. Match the established discipline.
  • You are about to write production code for a non-trivial change and there is no test that will catch a regression.

When the change is purely mechanical (rename, formatting, dead-code removal) tests are not the right gate — skip TDD.

Step 0 — detect the test command

Before doing anything else, find the project's test runner:

Marker fileTest command
package.json with scripts.testrun that script (pnpm test / npm test)
package.json with scripts.checkrun that script first if it composes test + lint + typecheck
pyproject.toml with pytest configpytest
Cargo.tomlcargo test
go.modgo test ./...

Use the run_tests tool when available; fall back to terminal otherwise.

Step 1 — confirm baseline green

Run the test suite once before writing anything new.

  • All green → proceed.
  • Any failure → stop. Tell the user: "baseline is red — fix existing tests first or pass baseline_red: true to override". Refuse to start a TDD cycle on top of pre-existing failures, because GREEN will be ambiguous.

Step 2 — the cycle

For each behaviour:

🔴 RED

  1. Write the failing test. One concrete assertion at a time.
  2. Run the suite. The new test must fail. Inspect why it failed:
    • It must fail for the expected reason (assertion mismatch), not a syntax error or a missing import.
    • If it fails for the wrong reason, fix that and re-run before continuing.

🟢 GREEN

  1. Write the smallest production change that makes the new test pass. Hardcoding a return value is acceptable here — multiple tests will force generalization.
  2. Run the suite. The new test plus all prior tests must be green.
  3. If anything regresses, the GREEN step is incomplete — keep going.

🧹 REFACTOR

  1. Improve the code without changing behaviour. Extract, rename, simplify.
  2. Run the suite after each refactor — refactors that break tests are no longer refactors, they're behaviour changes.
  3. Stop refactoring when no further improvement is obvious.

Step 3 — track the cycle

If the todo tool is available, write each RED-GREEN-REFACTOR as a todo item. The user can see exactly what behaviour each cycle covered. This also forces small, focused cycles.

Step 4 — final pass

Once all behaviours are covered:

  1. Run the full test suite.
  2. Run the project's check command (lint + typecheck + test in one) if it exists.
  3. Report: number of cycles, files touched, tests added.

Hard rules

  • No production code without a test that drove it. If you find yourself editing production code with no failing test that needs it, stop — write the test first.
  • No fix lands with a red baseline. Override with baseline_red: true only when explicitly told.
  • One cycle, one behaviour. If a single test forces you to write four new methods, the test is too broad — split it.

Integrates with

  • process tool — start pnpm test --watch (or the project equivalent) once at the top of the cycle, leave it running, watch the output between iterations. Kill it with process_stop at the end.
  • run_tests — use the typed tool when available; cleaner output and better error reporting than parsing terminal.

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.