agentleFS
alexderzalexderz/agentic-toolbox/skills/tdd/SKILL.md

tdd

Skill5 starsChanged 46 days agoMITView on GitHub

use this when implementing a feature or bugfix, changing behavior, or refactoring — write a failing test first, watch it fail for the right reason, then write the smallest code that passes.

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

We split this skill into the rules it gives an agent

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

  • 0

    Common

    Most of the 186 edited versions we read keep these.

  • 8

    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:

    Stop and ask the operator, or someone the operator names in writing, before skipping the cycle for a topic below.

    line 18
  2. Distinctive:

    Red: Write one minimal failing test for the next behavior.

    line 33
  3. Distinctive:

    Green: Write the smallest production code that makes that test pass.

    line 35
  4. Distinctive:

    Refactor: Only after green. Clean names and duplication.

    line 37
  5. Distinctive:

    Test already passes? You are testing existing behavior.

    line 48
  6. Distinctive:

    Test passes on the first run

    line 93
  7. Distinctive:

    All of these mean: delete the production code.

    line 99
  8. Distinctive:

    Before calling the work done:

    line 114

“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

Rewrite of obra/superpowers skills/test-driven-development @ b36e0829c6d0140e93cfef2ca599b1b07d4a7797. Compress, not a paste. skills/tdd/ is the skill home.

The iron law

No production code without a failing test first.

Wrote code first? Delete it. Restart from a failing test. Do not keep it as reference, do not adapt it, do not glance at it while writing tests. Delete means delete.

Ask first

Stop and ask the operator, or someone the operator names in writing, before skipping the cycle for a topic below. Ask per Asking the operator.

TopicWhy it is a stop
Renames / mechanical movesEasy to treat as "no behavior" and skip the proof
Configuration-only changesConfig can still change runtime behavior
Throwaway / prototypeFine to explore; throw the exploration away and rebuild the change with TDD if it ships
Generated codeConfirm it is generated and not behavior you owe a test

Thinking "skip TDD just this once"? Stop. That is rationalization. Ask first — do not self-except.

Red → green → refactor

One behavior at a time. Text cycle, not a diagram.

  1. Red. Write one minimal failing test for the next behavior. Name the behavior. Prefer real code over mocks.
  2. Watch it fail for the right reason. Run the test. Confirm it fails because the feature is missing — not a typo, import error, or assertion on existing behavior. If it passes immediately, the test is wrong. If it errors, fix the harness until it is a real failure.
  3. Green. Write the smallest production code that makes that test pass. No extra features. No drive-by refactors.
  4. Watch it pass. The new test is green; the rest of the suite stays green; output is clean.
  5. Refactor. Only after green. Clean names and duplication. Do not add behavior. Stay green.
  6. Repeat for the next behavior.

Watch the fail

Mandatory. If you did not watch the test fail, you do not know it tests the right thing.

  • Fail (assertion), not crash (syntax / import)
  • Failure message matches what you expected
  • Cause is "feature missing," not a broken test

Test already passes? You are testing existing behavior. Fix the test.

Green is minimal

YAGNI. Hard-code if that is enough for this test. Do not add options, retries, or helpers the test does not require.

Good tests

QualityDoDon't
MinimalOne behavior. "And" in the name? Split.validates email and domain and whitespace
ClearName the behaviortest1, works
RealAssert on the code's behaviorAssert that a mock was called
IntentShow the API you wantHide the contract behind fixtures

Example: bug fix

Bug: empty email accepted.

Red — rejects empty email calls submitForm({ email: '' }) and expects error: 'Email required'.

Watch the fail — assertion fails because the error is missing, not because the test cannot import the function.

Green — reject blank email. Nothing else.

Refactor — extract shared validation only if a later test demands it.

Rationalizations (all false)

ExcuseReality
Too simple to testSimple code still breaks. The test is cheaper than the bug.
I'll test afterAfter-the-fact tests pass immediately and prove nothing. You never watched them catch the miss.
Same goals, skip the ritualTests-after ask "what does this do?"; tests-first ask "what should this do?"
Already manually testedNo record, no rerun, easy to miss edges.
Deleting hours of code is wasteSunk cost. Untrusted code is the waste.
Keep as referenceYou will adapt it. That is testing after. Delete.
Need to explore firstExplore, then throw it away and start at red.
Hard to testThe design is wrong. Simplify the interface.
TDD will slow me downDebugging in production is slower.

Red flags — delete and restart

  • Production code before a failing test
  • Tests written after the implementation
  • Test passes on the first run
  • Cannot explain why it failed
  • "Just this once"
  • "Keep as reference" / "adapt the existing code"
  • "Spirit not ritual" / "I'm being pragmatic"

All of these mean: delete the production code. Start over at red.

When stuck

ProblemMove
Don't know how to testWrite the wished-for API and the assertion first. Ask.
Test is a novelDesign is a novel. Shrink the interface.
Everything needs a mockToo coupled. Inject dependencies.
Setup is hugeExtract helpers; if still huge, simplify.

Bug found later? Reproduce with a failing test, then follow the cycle. Never ship a bugfix with no test.

Checklist

Before calling the work done:

  • Each new behavior has a test
  • Each test was watched failing for the right reason
  • Production code was the minimum to go green
  • Suite is green and output is clean
  • Mocks only when unavoidable
  • Edges and error paths covered

Missing a box? You skipped TDD. Restart.

Final rule

Production code exists only after a test existed and failed first. Otherwise it is not TDD. No self-exceptions — Ask first.

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.