agentleFS
dgalarzadgalarza/agent-skills/skills/tdd/SKILL.md

tdd

Skill72 starsChanged 6 months agoMITView on GitHub

Use this skill when implementing or changing behavior with test-driven development. Follow red-green-refactor one behavior at a time, confirm a real failure before writing production code, and keep the test command the project's own.

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

23 rules. 0 are common, 22 are distinctive, and 1 is very specific to this project.

  • 0

    Common

    Most of the 186 edited versions we read keep these.

  • 22

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

    Use this skill when:

    line 14
  2. Distinctive:

    Read the repository instructions (AGENTS.md, CLAUDE.md, or the equivalent) and find the test command.

    line 24
  3. Very specific:

    If no command is documented, detect it from the project: task runner scripts, Makefile, pytest / go test / cargo test / mvn test / gradle …

    line 25
  4. Distinctive:

    Run the existing suite, or the relevant subset, once.

    line 26
  5. Distinctive:

    If the test command cannot be found or cannot be executed, stop and say so.

    line 29
  6. Distinctive:

    Write the smallest test that expresses the next behavior and nothing else.

    line 37
  7. Distinctive:

    Use the project's existing test style.

    line 41
  8. Distinctive:

    Run that test alone when the runner allows it.

    line 43
  9. Distinctive:

    If the new test passes immediately, the behavior already exists or the test does not exercise it.

    line 47
  10. Distinctive:

    Write the minimum production code that makes this test pass.

    line 51
  11. Distinctive:

    Only refactor while the tests are green.

    line 59
  12. Distinctive:

    Remove duplication introduced by the last green step.

    line 61
  13. Distinctive:

    Leave behavior unchanged. A refactor that needs a new test is a new behavior.

    line 63
  14. Distinctive:

    Run the same tests again after refactoring.

    line 65
  15. Distinctive:

    Keep a short list of behaviors, ordered so each test teaches one new fact.

    line 69
  16. Distinctive:

    Do not write that list as a finished test file.

    line 76
  17. Distinctive:

    Prefer several small cycles over one test that asserts an entire feature.

    line 78
  18. Distinctive:

    Never write a full test file up front and then implement against it.

    line 82
  19. Distinctive:

    Never implement more than the current failing test requires.

    line 83
  20. Distinctive:

    Never delete or skip a failing test to get to green.

    line 84
  21. Distinctive:

    Never change a test and the production code in the same step unless the test itself was wrong (bad assertion, wrong setup).

    line 85
  22. Distinctive:

    Keep tests deterministic. No sleeps, no order dependence, no hidden network calls unless the project already uses a fake or fixture for …

    line 86
  23. Distinctive:

    Leave the suite green at the end of every cycle, including the last one.

    line 87

“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

Test-Driven Development

Implement behavior one failing test at a time. The cycle is red, green, refactor. Do not write the production code for a behavior before a test has failed for that behavior, and do not start the next behavior until the current one is green and cleaned up.

This skill is agent-neutral. It does not install hooks, slash commands, or a required subagent. Run the project's existing test command from the current agent.

When to use

Use this skill when:

  • Adding a feature, bugfix, or behavior change that can be expressed as an executable check
  • The user asks for TDD, red-green-refactor, or "test first"
  • A change is small enough to slice into separately verifiable behaviors

Skip the cycle only when the user explicitly asks for a spike or a non-behavioral change (formatting, comments, generated files). Say that the cycle was skipped and why.

Before the first test

  1. Read the repository instructions (AGENTS.md, CLAUDE.md, or the equivalent) and find the test command. Prefer a documented command over guessing.
  2. If no command is documented, detect it from the project: task runner scripts, Makefile, pytest / go test / cargo test / mvn test / gradle test / phpunit / bin/rspec, or the language's usual runner. Run the narrowest command that executes one example or one file.
  3. Run the existing suite, or the relevant subset, once. If it is already red, stop and report that. Do not stack new work on a broken baseline unless the user asks to fix that baseline first.
  4. Name the next behavior in one sentence: the input, the observable output, and the boundary that makes it the smallest next step.

If the test command cannot be found or cannot be executed, stop and say so. Do not claim a cycle completed without a run.

The cycle

Repeat until the requested behavior is complete. Each iteration covers exactly one behavior.

1. Red

Write the smallest test that expresses the next behavior and nothing else.

  • One new example, case, or assertion. Do not scaffold the rest of the file "while here."
  • Assert on observable behavior (return value, state change, response, emitted event), not on private structure.
  • Use the project's existing test style. Match names, fixtures, and helpers already in the tree.

Run that test alone when the runner allows it.

The test must fail, and it must fail because the behavior is missing or wrong — not because of a typo, a missing import, a wrong path, or a setup error. Read the failure. If the failure is not the expected one, fix the test and run it again before writing production code.

If the new test passes immediately, the behavior already exists or the test does not exercise it. Do not treat that as success. Adjust the test or choose a behavior that is not already covered, then re-run until the failure is real.

2. Green

Write the minimum production code that makes this test pass. Do not implement the next behavior, the general case, or "what we'll need later."

Hard-coding a single return value is acceptable when it is the smallest change that turns this test green. The following test is what forces the code to become general.

Run the same test again. It must pass. If it fails, change the production code or correct a bad test — do not weaken the assertion to hide a real miss. Then run the relevant surrounding tests to confirm the change did not break an existing behavior.

3. Refactor

Only refactor while the tests are green.

  • Remove duplication introduced by the last green step.
  • Rename for the domain language already used in the code.
  • Leave behavior unchanged. A refactor that needs a new test is a new behavior; stop and start another red step.

Run the same tests again after refactoring. If they fail, undo the refactor or fix it before continuing. Do not begin the next behavior on a red suite.

Slicing work

Keep a short list of behaviors, ordered so each test teaches one new fact. Typical order:

  1. The simplest happy path
  2. The next variation that forces the hard-coded branch to become real logic
  3. Boundaries (empty, zero, one, limits)
  4. Failure and error paths the caller can actually hit

Do not write that list as a finished test file. Track it as a plan, then turn one item into a test at a time.

Prefer several small cycles over one test that asserts an entire feature. A cycle that touches many files is a signal to slice again.

Rules

  • Never write a full test file up front and then implement against it.
  • Never implement more than the current failing test requires.
  • Never delete or skip a failing test to get to green.
  • Never change a test and the production code in the same step unless the test itself was wrong (bad assertion, wrong setup). When the test was wrong, return to red and show the corrected failure before continuing.
  • Keep tests deterministic. No sleeps, no order dependence, no hidden network calls unless the project already uses a fake or fixture for that dependency.
  • Leave the suite green at the end of every cycle, including the last one.

Done

The work is done when every requested behavior has been through red, green, and refactor, the tests that cover those behaviors pass, and the relevant existing suite still passes. Summarize the behaviors added and the command used to run them. Do not claim coverage that was not executed.

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.