agentleFS
elfrostelfrost/ai-patchlab/.agents/skills/tdd/SKILL.md

tdd

Skill1 starsChanged 30 days agoMITView on GitHub

Implement a feature or bugfix following strict Red-Green-Refactor discipline. Use when the user asks for test-driven development, requests TDD on a critical function, asks to reproduce a bug with a failing test first, or wants to lock an API surface before implementing.

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

11 rules. 0 are common, 10 are distinctive, and 1 is very specific to this project.

  • 0

    Common

    Most of the 186 edited versions we read keep these.

  • 10

    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:

    Run a strict Red-Green-Refactor cycle.

    line 8
  2. Distinctive:

    RED: - Write one minimal failing test.

    line 26
  3. Distinctive:

    Verify RED: - Run the test. It must FAIL (not error from syntax/imports) for the expected missing-behavior reason.

    line 27
  4. Distinctive:

    GREEN: - Write the simplest code that satisfies the test.

    line 28
  5. Distinctive:

    Verify GREEN: - All tests pass (new + pre-existing).

    line 29
  6. Distinctive:

    REFACTOR: - Only after green. Remove duplication, improve names, extract helpers.

    line 30
  7. Very specific:

    Read AGENTS.md, CLAUDE.md if present, examples/, tests/conftest.py.

    line 33
  8. Distinctive:

    Run one cycle at a time. Do NOT batch behaviors into one test.

    line 35
  9. Distinctive:

    After all behaviors are green:

    line 36
  10. Distinctive:

    Test passed on first run (behavior already existed)

    line 56
  11. Distinctive:

    Do not skip "Verify RED" - if you cannot say why the test failed, you did not observe red.

    line 86

“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 Implementation

Run a strict Red-Green-Refactor cycle. Production code may not exist without a preceding observed-failing test.

When to use

  • Critical functions (calculations, money, auth, data integrity)
  • Bugfixes (write the failing reproduction first)
  • API design where the surface should be locked before implementing
  • Non-trivial behavior that is precisely specifiable

Skip for prototypes, config files, generated code, doc-only changes.

Iron Law

Production code must never exist without a preceding observed-failing test. If implementation exists without one, DELETE and reimplement from the test. No exceptions for "keep as reference" or "tests after".

The Cycle

For each unit of behavior:

  1. RED - Write one minimal failing test. Real code, avoid mocks unless external. Names describe intent. "and" in a name means split it.
  2. Verify RED - Run the test. It must FAIL (not error from syntax/imports) for the expected missing-behavior reason. If it passes on first run, the behavior already exists somewhere - stop and investigate.
  3. GREEN - Write the simplest code that satisfies the test. No unrelated features. YAGNI ruthlessly.
  4. Verify GREEN - All tests pass (new + pre-existing). Output is clean.
  5. REFACTOR - Only after green. Remove duplication, improve names, extract helpers. Re-run tests after each refactor step.

Workflow

  1. Read AGENTS.md, CLAUDE.md if present, examples/, tests/conftest.py.
  2. Decompose the work into a list of behaviors. Each behavior = one cycle. Start with the simplest happy path, then edges, then errors.
  3. Run one cycle at a time. Do NOT batch behaviors into one test.
  4. After all behaviors are green:
    ruff check src/ tests/
    black --check src/ tests/
    pytest tests/ -v --cov=src/ --cov-report=term-missing
  5. Report tests written, coverage delta, refactorings applied.

Anti-rationalizations

ThoughtCounter
"Too simple to test"Simple code breaks. Test takes 30s.
"Tests after work equally"Post-hoc tests pass by construction - prove nothing.
"Already manually tested"Manual is unsystematic and unreproducible.
"Deleting working code is waste"Sunk cost. Unverified code is debt.

Red flags - restart the cycle if

  • Implemented before writing the test
  • Test passed on first run (behavior already existed)
  • Cannot articulate why the test failed
  • Postponed test creation
  • Kept code "as reference" while writing tests

Output

TDD Report
Feature/Bug: [name]
Cycles run: [count]

Behaviors covered:
- [x] test_name_1
- [x] test_name_2

Verification:
- Each test was observed to FAIL before implementation: yes/no
- Coverage delta: +X%
- All tests pass: yes/no
- Lint/format clean: yes/no

Refactorings applied:
- [Description, tests still green]

Rules

  • One behavior = one test = one cycle. No batching.
  • Production code without a preceding observed-failing test means delete and restart.
  • Mocks only for external dependencies (DB, network, time, randomness).
  • Do not skip "Verify RED" - if you cannot say why the test failed, you did not observe red.
  • This skill does not replace execute-prp. Use TDD when discipline matters more than speed.

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.