agentleFS
GusevV1987GusevV1987/ai-workspace-kit/skills/tdd/SKILL.md

tdd

Skill2 starsChanged 8 months agoMITView on GitHub

Use when adding new behavior or fixing a bug where a meaningful failing test is possible — write that test first; for code that already exists, add proportionate tests and label them honestly.

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

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

  • 0

    Common

    Most of the 186 edited versions we read keep these.

  • 12

    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:

    Write the test first. Watch it fail.

    line 12
  2. Distinctive:

    Write one small test that describes what the code should do.

    line 34
  3. Distinctive:

    Run the test. Confirm it fails because the feature is missing, not because of a typo.

    line 42
  4. Distinctive:

    If the test passes immediately, you are testing something that already exists.

    line 44
  5. Distinctive:

    Write the simplest code that makes the test pass.

    line 48
  6. Distinctive:

    Do not add features the test does not require.

    line 50
  7. Distinctive:

    Run the test. Confirm it passes.

    line 52
  8. Distinctive:

    Keep running tests after each change.

    line 61
  9. Distinctive:

    Write meaningful tests for the behavior that matters, using real code where you can.

    line 69
  10. Distinctive:

    Every new or changed behavior has a meaningful test, or a proportionate check for a low-impact change

    line 102
  11. Distinctive:

    All tests pass with no errors or warnings, and every check the project requires has run and passed

    line 107
  12. Distinctive:

    If any of these are not true, say so plainly in your handoff.

    line 109

“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 (TDD)

The Rule

Write the test first. Watch it fail. Write minimal code. Watch it pass.

Use that order for new behavior and bug fixes whenever a meaningful failing test is possible. A failing test or check you already have that shows the bug can serve as the failing step. Where no meaningful automated test applies, such as a formatting or configuration change, say so and use the checks that fit; every check the project requires still runs. If working code already exists without tests, keep it: do not delete it, or break a shared or live copy, to recreate a test-first history. Follow "Code That Already Exists" below.

When to Use

Use TDD for (when a meaningful failing test is possible):

  • New features
  • Bug fixes
  • Behavior changes
  • Refactoring existing code (first cover its current behavior with tests; see "Code That Already Exists")

When TDD is optional (say so; use proportionate checks and still run every check the project requires):

  • Throwaway prototypes you will discard
  • Auto-generated code
  • Configuration files
  • Pure visual/styling changes with no logic

The RED-GREEN-REFACTOR Cycle

RED -- Write a Failing Test

Write one small test that describes what the code should do.

A good test:

  • Tests one specific behavior (if the name has "and" in it, split into two tests)
  • Has a clear, descriptive name (not "test1" or "it works")
  • Uses real code, not fakes/mocks (unless absolutely necessary)
  • Shows how the code should be used

Run the test. Confirm it fails because the feature is missing, not because of a typo.

If the test passes immediately, you are testing something that already exists.

GREEN -- Write Minimal Code

Write the simplest code that makes the test pass. Nothing more.

Do not add features the test does not require. Do not optimize. Do not build "for the future."

Run the test. Confirm it passes. Confirm no other tests broke.

REFACTOR -- Clean Up

Now that everything passes, improve the code:

  • Remove duplication
  • Improve names
  • Extract helper functions

Keep running tests after each change. They must stay green.

Then go back to RED with the next behavior you need.

Code That Already Exists

Working code without tests is a gap to close, not a mistake to erase. Do not delete it, and never change a shared or live working copy just to manufacture a test-first history.

  1. Write meaningful tests for the behavior that matters, using real code where you can. Passing tests show coverage, not yet that a test would catch the failure it targets.
  2. Where it is suitable, get that evidence directly: see the test fail against a known failing version or case, such as the original bug, or against an isolated, reversible change in a throwaway copy. A boundary or negative case that has only passed against the current code is coverage, not that evidence.
  3. In your handoff, say which tests were written after the code and which of them you saw fail. Name any remaining gap plainly.
  4. For the next change to that code, start at RED.

What Counts as a Good Test

QualityGoodBad
FocusedTests one thingTests five things at once
Named clearly"rejects empty email""test1" or "validation"
Tests behaviorWhat the code doesHow the code is built internally
Uses real codeCalls actual functionsMocks everything

Common Mistakes

  1. Writing new code before its test -- a test written afterwards passes immediately; until you see it fail when the behavior is wrong, it shows coverage, not that it catches the failure it targets.
  2. Deleting or breaking working code to restart test-first -- it puts working code at risk and adds no evidence. Keep it and follow "Code That Already Exists."
  3. Writing too much code at once -- if you wrote more than a few lines, you skipped a RED step.
  4. Testing implementation instead of behavior -- test what the code does, not how it is built.
  5. Skipping the "watch it fail" step for new behavior -- if you never saw it fail, you do not know if it tests anything.

When Stuck

ProblemWhat it means
Cannot figure out how to test itDesign is unclear -- simplify the interface first
Test requires too much setupCode is too tangled -- break it into smaller parts
Must fake/mock everythingCode depends on too many things -- reduce dependencies
Test is more complex than the codeSplit the test or simplify the design

Before Marking Work Complete

  • Every new or changed behavior has a meaningful test, or a proportionate check for a low-impact change
  • For new behavior, you watched each test fail for the right reason (missing behavior, not a typo)
  • New behavior was written test-first, with only enough code to pass each test
  • For tests added after the code, your handoff labels them as written afterwards and says which ones you saw fail; the rest count as coverage only
  • Where no meaningful automated test applied, your handoff says so
  • All tests pass with no errors or warnings, and every check the project requires has run and passed

If any of these are not true, say so plainly in your handoff. Do not delete or break working code to redo the order.

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.