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

tdd

Skill1 starsChanged 2 months 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.

193 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use make-bot-ui, Poteto Mode 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.
  • eryzerzSkill

    make-bot-ui

    Use when building a custom UI (page, dashboard, buttons) that should wake a Grok Bot over a webhook, when the user must provide a webhook sender key, or when exposing that UI on Tailscale.

    Also in 8 projects that use this

  • jtarorehSkill

    Poteto Mode

    poteto's agent style for concise, detailed responses, deliberate subagents, unslopped prose, simple code, and verified work. Use for poteto, /poteto-mode, or requests to work in this style.

    Also in 5 projects that use this

  • risadamsSkill

    which-skill

    Router over this pack's skills and flows. Ask it "which skill fits X" when you don't remember what's available.

    Also in 7 projects that use this

  • TheOnlyFusionCubeSkill

    principle-attack-the-premise

    Inventory who actually owns or exhibits the imbalance, then challenge the shared premise before writing another patch. Use when two or more fixes that share one premise have failed the same gate.

    Also in 11 projects that use this

  • TheOnlyFusionCubeSkill

    principle-test-behavior-not-implementation

    Call the system the way its consumer does and assert meaningful observable output; avoid mocks or assertions that only mirror internal calls. Use when when writing or evaluating tests.

    Also in 11 projects that use this

  • shreyT19Skill

    principle-laziness-protocol

    Apply when refactoring, evaluating diff size, or tempted to add abstractions, layers, or signal threading. Bias toward deletion and the smallest change that solves the problem.

    Also in 22 projects that use this

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 177 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 177 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.