agentleFS
rosslevinskyrosslevinsky/portable-agent-skills/skills/tdd/SKILL.md

tdd

Skill12 starsChanged 43 days agoApache-2.0View on GitHub

Test-driven development workflow. Enforces red/green/refactor discipline: write failing tests first, implement the minimum code to pass, then clean up. Use when the user invokes /tdd with a feature to implement (e.g., "/tdd implement the vocab export endpoint", "/tdd add useMyHook"). Never skips ahead to implementation before confirming tests fail.

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

Show its rules and text

We split this skill into the rules it gives an agent

23 rules. 0 are common, 22 are distinctive, and 1 is very specific to this project.

  • 0

    Common

    Most of the 186 edited versions we read keep these.

  • 22

    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:

    Read the code and tests nearest the feature before writing anything.

    line 28
  2. Distinctive:

    Write tests before any implementation

    line 39
  3. Distinctive:

    Run tests; confirm the failure is caused by that absent behavior, not by a broken test

    line 41
  4. Distinctive:

    If tests pass immediately, the feature already exists — stop and report that to the user

    line 42
  5. Distinctive:

    Write the tests in the appropriate location following the project's existing conventions for test file placement and naming.

    line 44
  6. Distinctive:

    Write the minimum code to make the failing tests pass:

    line 70
  7. Distinctive:

    No extra features, no future-proofing

    line 72
  8. Distinctive:

    No refactoring of adjacent code

    line 73
  9. Distinctive:

    Follow existing patterns in the same file/module (naming, error handling, async style)

    line 74
  10. Distinctive:

    All tests in the new file must pass.

    line 78
  11. Distinctive:

    Run the full test suite (or at minimum the affected layer) to confirm no regressions.

    line 79
  12. Distinctive:

    When this loop runs inside a plan that sets its own rule for which tests to run while working, that rule wins.

    line 80
  13. Distinctive:

    If tests still fail, fix the implementation — do not modify the tests to make them pass.

    line 83
  14. Distinctive:

    If the implementation has obvious duplication, poor naming, or violates project conventions:

    line 89
  15. Distinctive:

    Run tests again to confirm they still pass

    line 92
  16. Distinctive:

    Do not add new behavior during refactor

    line 93
  17. Distinctive:

    If nothing needs cleanup, skip this phase.

    line 95
  18. Distinctive:

    After tests are green, report what the new tests cover and what they leave out, which files they live in, the exact command that runs them, …

    line 101
  19. Distinctive:

    Do not skip running tests between phases — the red→green transition is the whole point

    line 109
  20. Very specific:

    Do not add eslint-disable, # noqa, or test-specific conditionals in production code to make tests pass

    line 110
  21. Distinctive:

    Do not modify tests to make them pass — fix the implementation instead

    line 112
  22. Distinctive:

    Use existing test utilities and fixtures — do not duplicate infrastructure that already exists

    line 113
  23. Distinctive:

    Follow the project's CLAUDE.md / AGENTS.md conventions (whichever exists) throughout

    line 114

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

Overview

Phases run in strict order. Never proceed to the next phase without running tests and confirming the expected outcome.

  1. Understand — read existing code, tests, and project structure before writing anything
  2. Red — write failing test(s); confirm they fail for the right reason
  3. Green — write the minimum implementation to make tests pass
  4. Refactor — clean up; confirm tests still pass
  5. Report — summarize what's covered and what's missing

Phase 1 — Understand

Read the code and tests nearest the feature before writing anything. Work out what behavior must exist, which layer it lives in (pure function, API/DB, hook, component, full flow), and which runner and command test that layer in this project. Follow the nearest existing tests' placement, naming, fixtures and assertion style, and reuse the project's test helpers (conftest.py fixtures, MSW handlers, render wrappers) instead of adding new infrastructure.


Phase 2 — Red (write failing tests)

Rules:

  • Write tests before any implementation
  • Tests must exercise behavior that does not exist yet — this is intentional
  • Run tests; confirm the failure is caused by that absent behavior, not by a broken test
  • If tests pass immediately, the feature already exists — stop and report that to the user

Write the tests in the appropriate location following the project's existing conventions for test file placement and naming.

After writing tests — run them and confirm RED:

Show the failure output. A correct red takes either shape:

  • Something that does not exist yet — the name, the attribute, or the signature you are calling has nothing behind it: ImportError, ModuleNotFoundError, Cannot find module, AttributeError, a TypeError naming an argument the function does not accept yet, or a NotImplementedError raised by a stub. These are the common shapes, not a closed set: what makes a red correct is that the behavior is absent, not which exception carries the news. Adding a parameter to an existing function reds as a TypeError, and that is a legitimate red — not a broken test to be repaired.
  • New behavior on an API that already exists — a failing assertion: the call runs and returns the old answer. This is the usual red when extending existing code, and it is a valid red, not a broken test.

Either one means proceed to Phase 3. If it fails for any other reason (syntax error, wrong import path, fixture or setup error), fix the test first — the test must be correct before the implementation begins.


Phase 3 — Green (minimum implementation)

Write the minimum code to make the failing tests pass:

  • No extra features, no future-proofing
  • No refactoring of adjacent code
  • Follow existing patterns in the same file/module (naming, error handling, async style)

After implementing — run tests and confirm GREEN:

All tests in the new file must pass. No previously passing tests may regress. Run the full test suite (or at minimum the affected layer) to confirm no regressions. When this loop runs inside a plan that sets its own rule for which tests to run while working, that rule wins.

If tests still fail, fix the implementation — do not modify the tests to make them pass.


Phase 4 — Refactor (optional)

If the implementation has obvious duplication, poor naming, or violates project conventions:

  • Clean it up
  • Run tests again to confirm they still pass
  • Do not add new behavior during refactor

If nothing needs cleanup, skip this phase.


Phase 5 — Report

After tests are green, report what the new tests cover and what they leave out, which files they live in, the exact command that runs them, and which tests you ran to check for breakage and whether they passed.


Important constraints

  • Do not skip running tests between phases — the red→green transition is the whole point
  • Do not add eslint-disable, # noqa, or test-specific conditionals in production code to make tests pass
  • Do not modify tests to make them pass — fix the implementation instead
  • Use existing test utilities and fixtures — do not duplicate infrastructure that already exists
  • Follow the project's CLAUDE.md / AGENTS.md conventions (whichever exists) throughout

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.