agentleFS
requierequie/endostack/skills/tdd/SKILL.md

tdd

Skill4 starsChanged 14 days agoMITView on GitHub

When a bug can be caught by an inexpensive local test, write that narrow failing test before the fix, check that it fails because of the bug, then fix the code and watch the test pass. Use on /tdd, "write a failing test first", "add a regression test", or when a bug has an obvious inexpensive test location.

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 3 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

  • +2 more from The-Vibe-Company

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:

    No new test is better than a harmful one.

    line 13
  2. Distinctive:

    Pin the defect: Write down the expected behavior, the observed behavior, the code path involved, and the smallest input that reproduces it.

    line 25
  3. Distinctive:

    Pick the tightest check: Use the test style the codebase already uses near that path: unit, component, integration, or a regression suite.

    line 26
  4. Distinctive:

    Never edit a test so it agrees with wrong code.

    line 38
  5. Distinctive:

    Never loosen an existing assertion unless the intended behavior really changed.

    line 39
  6. Distinctive:

    Keep the new test about this defect.

    line 40
  7. Distinctive:

    If the bug hints at a family of related failures, land the narrow regression test first.

    line 42
  8. Distinctive:

    if you could not show a failure first, the reason, and which nearest check you used in its place.

    line 50

“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

Turn the defect into a failing test, watch it fail for the reason you expect, change the code, and watch the same test pass. Do this only when a narrow local test is cheap. When it is not, run the nearest executable check instead of forcing a bad test.

When to skip writing a test

No new test is better than a harmful one. Skip the test, and go to the fallback below, when the test would:

  • mainly assert on mocks rather than on behavior;
  • pin today's internal structure, so any refactor breaks it;
  • depend on timing, ordering, or shared state unrelated to the bug;
  • need heavy infrastructure (a full cluster, a seeded production copy) for a small fix;
  • be thrown away as soon as the fix is shown.

Also skip it when the path to a test is unclear, slow, or integration-heavy and the user did not ask for one.

Procedure

  1. Pin the defect. Write down the expected behavior, the observed behavior, the code path involved, and the smallest input that reproduces it.
  2. Pick the tightest check. Use the test style the codebase already uses near that path: unit, component, integration, or a regression suite. If nothing reasonable exists, do not build new test infrastructure. Go to the fallback.
  3. Write the smallest test that would have caught this bug. Assert what a user of the code should get, not how the code currently computes it. If the bug involves untrusted input (a request body, a file name, a header), make the test feed the hostile value the bug allowed, so the test also documents the attack.
  4. Run it against the unchanged code. It must fail, and the failure message must point at the defect. A pass means the test does not reproduce the bug. A failure for some other reason (a missing import, a fixture error) means the test is wrong. Fix the test before you touch production code.
  5. Make the smallest code change that produces the intended behavior and keeps neighboring contracts intact.
  6. Run the test again. It must pass. Run the surrounding suite too, so you know the fix broke nothing nearby.

Fallback when no practical test exists

Run the closest executable check you can and record it. Options include a short purpose-built script, a shell command that reproduces the symptom, a scripted browser session, a snapshot comparison, an assertion on log output, or a narrow integration run. The same rule applies: observe it showing the bug before the change and showing the fix after.

Guardrails

  • Never edit a test so it agrees with wrong code.
  • Never loosen an existing assertion unless the intended behavior really changed. If it did, record why in the test or the commit message.
  • Keep the new test about this defect. No fixture rewrites, no unrelated coverage.
  • For a flaky or intermittent bug, remove the nondeterminism from the test where you can (fixed seeds, fake clocks, a single worker) and say which signal the test pins.
  • If the bug hints at a family of related failures, land the narrow regression test first. Propose broader coverage as a separate follow-up.

Report

End with evidence:

  • the test or check that failed before the change, and its failure output;
  • the run where it passed after the change, plus any neighboring suites you ran;
  • if you could not show a failure first, the reason, and which nearest check you used in its place.

Related

The typescript-best-practices skill (../typescript-best-practices/SKILL.md) prefers running real code over mocks. The benchmark-checklist skill (../benchmark-checklist/SKILL.md) applies the same evidence discipline to performance claims.

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.