agentleFS
ykeezyykeezy/skills/tdd/SKILL.md

tdd

Skill1 starsChanged 3 months agoMITView on GitHub

Red-green-refactor loop. Use when user wants to build features using TDD, mentions "red-green-refactor", wants integration tests, or asks for test-first development.

194 other projects use a version of this, 30 of them edited.

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

Show its rules and text

We split this skill into the rules it gives an agent

18 rules. 0 are common, 13 are distinctive, and 5 are very specific to this project.

  • 0

    Common

    Most of the 186 edited versions we read keep these.

  • 13

    Distinctive

    This author's own choices. Worth a look.

  • 5

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    If the user named a blueprint file, use that file.

    line 12
  2. Very specific:

    If no blueprint exists in docs/plans/, tell the user — recommend running /blueprint first, or if they prefer, proceed by driving RED→GREEN …

    line 14
  3. Very specific:

    When every Acceptance Criterion in the slice is green and refactored, tick its TDD done checkbox in the blueprint, then move to the next …

    line 19
  4. Very specific:

    When reading domain terminology, if CONTEXT-MAP.md exists, read it and read each context relevant to the topic.

    line 22
  5. Distinctive:

    If you find yourself writing implementation without a preceding failing test:

    line 29
  6. Distinctive:

    Delete the implementation code you just wrote.

    line 32
  7. Distinctive:

    Write the test first.

    line 33
  8. Distinctive:

    Only then write the implementation again.

    line 35
  9. Distinctive:

    Write ONE test for ONE behaviour from the current slice's Acceptance Criteria.

    line 69
  10. Distinctive:

    Run the test immediately.

    line 73
  11. Distinctive:

    If it passes immediately → the behaviour already exists, rewrite the test.

    line 76
  12. Distinctive:

    If it fails with syntax/import errors → fix those, re-run, re-verify.

    line 77
  13. Very specific:

    Read docs/house-style.md if it exists, then write the minimal code to make this single test pass.

    line 83
  14. Distinctive:

    No anticipating the next test.

    line 87
  15. Distinctive:

    VERIFY: Run the test. It must pass.

    line 89
  16. Distinctive:

    After the test is green, look for refactor opportunities:

    line 93
  17. Distinctive:

    Run tests after each refactor step

    line 102
  18. Very specific:

    When all slices are complete and the full test suite passes, verify every TDD done checkbox in the blueprint is ticked, then tell the user:

    line 122

“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

Before You Start

Select the blueprint

  1. If the user named a blueprint file, use that file.
  2. Otherwise ask the user which blueprint to use, listing what is in docs/plans/. Never guess — /tdd takes exactly one blueprint.
  3. If no blueprint exists in docs/plans/, tell the user — recommend running /blueprint first, or if they prefer, proceed by driving RED→GREEN directly from their description.

Slice completion checkboxes

  • Pick the first slice whose TDD done checkbox is unchecked.
  • When every Acceptance Criterion in the slice is green and refactored, tick its TDD done checkbox in the blueprint, then move to the next slice.
  • No in-progress marker is maintained. After an interruption, resume at the first unchecked slice and re-run its existing tests before continuing.
  • Slices with Blocked by: None may be run in parallel at the agent's discretion; keep one RED→GREEN→REFACTOR cycle per slice and tick each checkbox independently.
  • When reading domain terminology, if CONTEXT-MAP.md exists, read it and read each context relevant to the topic; if unclear which context applies, ask the user.

Non-Negotiable Gate

You must witness a test fail for the expected reason before writing any implementation code.

If you find yourself writing implementation without a preceding failing test:

  1. STOP immediately.
  2. Delete the implementation code you just wrote.
  3. Write the test first.
  4. Watch it fail.
  5. Only then write the implementation again.

This is not advice. This is the rule.

Philosophy

Core principle: Tests should verify behavior through public interfaces, not implementation details. Code can change entirely; tests shouldn't.

Good tests are integration-style: they exercise real code paths through public APIs. They describe what the system does, not how it does it. They survive refactors because they don't care about internal structure.

Bad tests are coupled to implementation. They mock internal collaborators, test private methods, or verify through external means. The warning sign: your test breaks when you refactor, but behavior hasn't changed.

See tests.md for examples and mocking.md for mocking guidelines.

Anti-Pattern: Horizontal Slices

DO NOT write all tests first, then all implementation. This is "horizontal slicing."

WRONG (horizontal):
  RED:   test1, test2, test3, test4
  GREEN: impl1, impl2, impl3, impl4

RIGHT (vertical):
  RED→GREEN: test1→impl1
  RED→GREEN: test2→impl2
  RED→GREEN: test3→impl3
  ...

Workflow

1. RED — Write a Failing Test

Write ONE test for ONE behaviour from the current slice's Acceptance Criteria.

MANDATORY VERIFICATION:

  1. Run the test immediately.
  2. It must fail.
  3. The failure must be because the behaviour is missing — NOT a syntax error, NOT a test setup problem.
  4. If it passes immediately → the behaviour already exists, rewrite the test.
  5. If it fails with syntax/import errors → fix those, re-run, re-verify.

Do not write implementation code until you have witnessed the test fail for the right reason.

2. GREEN — Minimal Code to Pass

Read docs/house-style.md if it exists, then write the minimal code to make this single test pass.

  • No extra features.
  • No "I'll need this later."
  • No anticipating the next test.

VERIFY: Run the test. It must pass. Run all existing tests — they must also pass.

3. REFACTOR — Clean Up

After the test is green, look for refactor opportunities:

  • Duplication → Extract function/class
  • Long methods → Break into private helpers (keep tests on public interface)
  • Shallow modules → Combine or deepen — see /codebase-design for the deletion test, depth assessment, and seam discipline
  • Feature envy → Move logic to where data lives
  • Primitive obsession → Introduce value objects
  • Improve names
  • Existing code the new code reveals as problematic
  • Run tests after each refactor step

Never refactor while RED. Get to GREEN first.

4. Next Behaviour

Return to RED for the next behaviour within this slice. When all Acceptance Criteria for the slice are green and refactored, tick the slice's TDD done checkbox in the blueprint, then move to the next slice.

Checklist Per Cycle

[ ] RED witnessed — test failed for the expected reason before implementation
[ ] Test describes behaviour, not implementation
[ ] Test uses public interface only
[ ] Code is minimal for this test — no speculative additions
[ ] All existing tests still pass

Handoff

When all slices are complete and the full test suite passes, verify every TDD done checkbox in the blueprint is ticked, then tell the user:

"TDD complete for docs/plans/{filename}. All module tests pass. Ready for /integrate — run it without a filename to verify this blueprint."

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.