agentleFS
patfornapatforna/core-skills/skills/tdd/SKILL.md

tdd

Skill0 starsChanged 5 months agoMITView on GitHub

Strict test-driven development (Beck-style). Use when writing new code, adding features, or fixing bugs with TDD discipline. TRIGGER when: user asks to use TDD, write tests first, or red/green/refactor. DO NOT TRIGGER when: writing tests after the fact, or user explicitly opts out of TDD.

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

18 rules. 0 are common, 17 are distinctive, and 1 is very specific to this project.

  • 0

    Common

    Most of the 186 edited versions we read keep these.

  • 17

    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:

    Write new code only when an automated test has failed.

    line 12
  2. Distinctive:

    Red: Write a small test that fails (or doesn't compile).

    line 19
  3. Distinctive:

    Refactor: Remove duplication introduced by getting to green.

    line 21
  4. Distinctive:

    Run the relevant test(s) after every Red and Green step — not the full suite.

    line 23
  5. Distinctive:

    First test: Start with the simplest degenerate case — empty input, zero, identity, null.

    line 27
  6. Distinctive:

    Regression test: When a defect is found, write the smallest failing test that reproduces it *before* writing the fix.

    line 31
  7. Distinctive:

    When to delete tests: Only when a test is redundant with another test and removing it does not reduce confidence or clarity.

    line 33
  8. Distinctive:

    Smaller steps: when uncertain, surprised, or dealing with unfamiliar territory.

    line 51
  9. Distinctive:

    Bigger steps: when confident.

    line 52
  10. Distinctive:

    Assert first: Start with the assertion (expected outcome), then work backward to the setup and action needed to produce that outcome.

    line 58
  11. Very specific:

    Evident data: Use literal, readable values so the relationship between input and output is obvious from the test alone (e.g., …

    line 59
  12. Distinctive:

    Stop writing tests: when every branch and boundary condition is exercised and adding more tests teaches you nothing new.

    line 61
  13. Distinctive:

    If a test requires too many changes to get to green, write a smaller child test for one piece, get that green, then return to the original …

    line 67
  14. Distinctive:

    Before modifying something, isolate it (Extract Method, Extract Object, Method Object) so the change is surgical.

    line 79
  15. Distinctive:

    All tests must pass before committing to shared code.

    line 99
  16. Distinctive:

    Do not design ahead. Solve "works" first via red/green, then solve "clean" via refactoring.

    line 112
  17. Distinctive:

    If stuck: backtrack. Revert to the last green state and take a smaller step.

    line 118
  18. Distinctive:

    If a step is pure wiring with no testable behaviour (e.g., bumping a library version, pure refactorings, etc.): implement directly.

    line 122

“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

You write code using strict test-driven development. Follow these rules exactly.

The Two Rules

  1. Write new code only when an automated test has failed.
  2. Eliminate duplication.

These imply: write tests before code, then refactor to remove duplication. Design emerges from this process.

The Cycle: Red → Green → Refactor

  1. Red: Write a small test that fails (or doesn't compile). Run it. Confirm it fails.
  2. Green: Make it pass using the simplest possible change. Shortcuts within the current scope are fine — hardcoded values, copy-paste, temporary variables. The only goal is green.
  3. Refactor: Remove duplication introduced by getting to green. This includes duplication between test and production code (e.g., a constant in both).

Run the relevant test(s) after every Red and Green step — not the full suite. Commit at green. Refactor at green. Never refactor while red.

Choosing Tests

First test: Start with the simplest degenerate case — empty input, zero, identity, null.

Next test: Pick from the to-do list a test you are confident you can get passing in one step and that will teach you something new about the problem.

Regression test: When a defect is found, write the smallest failing test that reproduces it before writing the fix.

When to delete tests: Only when a test is redundant with another test and removing it does not reduce confidence or clarity.

The to-Do List

Maintain a running list of tests to write (as comments in the test file or inline notes). When a tangential idea arises mid-cycle, add it to the list and stay focused on the current test. Cross off items as done. Add new items as discovered.

Three Strategies to Get to Green

Choose based on confidence:

StrategyWhenHow
Fake ItUncertain or complexReturn a constant. The constant duplicates a value in the test — remove that duplication by replacing constants with variables/computation until real code emerges.
TriangulationUnsure how to generalizeWrite a second test that demands different output. Generalize only when 2+ examples force it.
Obvious ImplementationConfident you know the answerType the real implementation directly. If you get an unexpected red, back up to Fake It.

Step Size

  • Smaller steps when uncertain, surprised, or dealing with unfamiliar territory.
  • Bigger steps when confident.
  • An unexpected red bar means: shift down to smaller steps.
  • An unexpected green bar means: review your test — it may be wrong. AI-written tests often mirror what the code does rather than what it should do.

Writing Tests

  • Assert first: Start with the assertion (expected outcome), then work backward to the setup and action needed to produce that outcome.
  • Evident data: Use literal, readable values so the relationship between input and output is obvious from the test alone (e.g., assertEquals(2.5, five.times(0.5))).
  • Test anything that could break: conditionals, loops, operations, polymorphism. Do not test library/framework code or trivial getters/setters.
  • Stop writing tests when every branch and boundary condition is exercised and adding more tests teaches you nothing new.

Key Patterns

Child Test

If a test requires too many changes to get to green, write a smaller child test for one piece, get that green, then return to the original test.

Value Objects

Make objects immutable. Operations return new instances. Implement equality and hashing. Eliminates aliasing bugs.

One to Many

Implement for a single element first, then generalize to a collection.

Isolate Change

Before modifying something, isolate it (Extract Method, Extract Object, Method Object) so the change is surgical.

Reconcile Differences

To unify two similar pieces of code: make them identical through tiny changes, then merge.

Mock Objects

For expensive or slow dependencies (DB, network), use fakes that implement the same interface.

Log String

To verify a sequence of calls, append to a log string in each method and assert the final string.

Crash Test Dummy

To test error paths, create a subclass that overrides a method to throw an exception.

Clean Check-In

All tests must pass before committing to shared code. Always.

Test Quality Signals

These smells indicate design problems, not test problems:

  • Long setup: Objects are too big. Break them apart.
  • Duplicate setup: Too many tightly-coupled objects.
  • Long-running tests: Design problem (usually coupling to slow resources).
  • Fragile tests: Action at a distance — one change breaks distant tests.

Design Emerges

Do not design ahead. Solve "works" first via red/green, then solve "clean" via refactoring. Design patterns emerge naturally from removing duplication. You don't plan them; you discover them.

The Rhythm

The cycle should be fast — minutes (for a human) per cycle, not hours. Run tests constantly.

If stuck: backtrack. Revert to the last green state and take a smaller step. The tests are your safety net — use them.

Pure Wiring Steps

If a step is pure wiring with no testable behaviour (e.g., bumping a library version, pure refactorings, etc.): implement directly. No test needed.

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.