agentleFS
fortmortfortmort/jeltz/skills/tdd-phase-loop/SKILL.md

tdd-phase-loop

Skill4 starsChanged 9 months agoMITView on GitHub

Autonomous red/green/refactor TDD with selective test running, explicit stop points, editor & hook interaction rules, automatic TODO updates, and a single final commit message.

The file

Show its rules and text

We split this skill into the rules it gives an agent

35 rules. About 0 are common, 31 are distinctive, and 4 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈31

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 4

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  • could be automatic: a setting could enforce it
  1. Very specific:

    Always use red/green/refactor TDD.

    line 17
  2. Distinctive:

    Never write implementation code before tests.

    line 18
  3. Distinctive:

    Never move to a new TODO item until I explicitly approve.

    line 19
  4. Distinctive:

    Only the final STOP requires human review.

    line 21
  5. Distinctive:

    Use selective test running to reduce cycle time:

    line 23
  6. Distinctive:

    Write the entire test function in one edit, including:

    line 35
  7. Distinctive:

    Do not split test creation across multiple edits.

    line 42
  8. Distinctive:

    Do not attempt to fix missing symbols during RED.

    line 54
  9. Distinctive:

    always write imports + test code in the same edit

    line 67
  10. Distinctive:

    never write imports alone

    line 68
  11. Distinctive:

    never write test bodies alone

    line 69
  12. Distinctive:

    Only RED requires the “single edit” rule.

    line 76
  13. Very specific:

    Read the next task from @TODO.md.

    line 82
  14. Distinctive:

    Write ONLY the failing test(s) required for this task.

    line 83
  15. Distinctive:

    Follow the Editor & Hook Interaction Rules above.

    line 84
  16. Distinctive:

    Run only the newly written tests, confirming they fail for the correct reason.

    line 85
  17. Distinctive:

    When tests are written and confirmed failing, STOP and output exactly:

    line 86
  18. Distinctive:

    After outputting this message, automatically begin PHASE 2.

    line 94
  19. Distinctive:

    Run only the newly written tests, confirming they now pass.

    line 102
  20. Distinctive:

    When the new tests pass, STOP and output exactly:

    line 103
  21. Distinctive:

    Keep tests passing at all times.

    line 119
  22. Very specific:

    Run the full test suite using make verify to ensure no regressions.

    line 120
  23. Distinctive:

    Before ending the phase, you must:

    line 122
  24. Distinctive:

    Remove or modify the relevant TODO entry as appropriate.

    line 126
  25. Distinctive:

    Ensure the TODO list reflects the new project state so the session can be safely restarted.

    line 127
  26. Distinctive:

    Do not begin a new task until I explicitly approve.

    line 148
  27. Distinctive:

    Never write implementation code in PHASE 1.

    line 154
  28. Distinctive:

    Never refactor in PHASE 2.

    line 155
  29. Distinctive:

    Never start a new TODO item without explicit approval.

    line 156
  30. Distinctive:

    Always respect the RED -> GREEN -> REFACTOR order.

    line 157
  31. Distinctive:

    Always run tests before claiming a phase is complete.

    line 158
  32. Very specific:

    Always update @TODO.md at the end of PHASE 3 before stopping.

    line 159
  33. Distinctive:

    Only the final STOP requires human approval.

    line 160
  34. Distinctive:

    Only produce a commit message at the end of PHASE 3.

    line 161
  35. Distinctive:

    Follow the Editor & Hook Interaction Rules strictly during RED.

    line 162

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “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

Your coding norms are defined in @CLAUDE.md. The project specification is in @docs/PROJECT_SPECIFICATION.md. Your task list is in @TODO.md.

You must follow a strict, phase-gated TDD workflow for this project. You are not allowed to skip phases or merge them.


Global Rules

  1. Always use red/green/refactor TDD.
  2. Never write implementation code before tests.
  3. Never move to a new TODO item until I explicitly approve.
  4. You may automatically proceed from RED -> GREEN -> REFACTOR without waiting for approval.
  5. Only the final STOP requires human review.
  6. I will commit manually; you must not commit or proceed on your own.
  7. Use selective test running to reduce cycle time:
    • RED: run only the newly written tests
    • GREEN: run only the newly written tests
    • REFACTOR: run the full test suite via make verify

Editor & Hook Interaction Rules (Critical for RED Phase)

To avoid thrashing with ruff, pre‑commit hooks, and unused‑import stripping, you must follow these rules:

1. All new tests must be added in a single edit

Write the entire test function in one edit, including:

  • imports
  • fixtures
  • mocks
  • assertions
  • test body

Do not split test creation across multiple edits.

2. RED-phase tests may reference missing symbols

It is acceptable for tests to reference:

  • missing functions
  • missing classes
  • missing modules
  • missing imports
  • ImportErrors
  • NameErrors

These are expected in RED. Do not attempt to fix missing symbols during RED.

3. Do not attempt to outsmart the linter

Do not:

  • sequence imports and tests across multiple edits
  • pre-import symbols
  • avoid ImportError
  • make RED tests pass linting

RED tests may fail import, typecheck, and runtime.

4. Ruff will not strip imports used in the same edit

Therefore:

  • always write imports + test code in the same edit
  • never write imports alone
  • never write test bodies alone

5. Never attempt to satisfy the linter in RED

The linter may fail in RED. The only requirement is that the test file is syntactically valid Python.

6. GREEN and REFACTOR may use multi-edit sequences

Only RED requires the “single edit” rule.


PHASE 1 — RED (write failing tests only)

  • Read the next task from @TODO.md.
  • Write ONLY the failing test(s) required for this task.
  • Follow the Editor & Hook Interaction Rules above.
  • Run only the newly written tests, confirming they fail for the correct reason.
  • When tests are written and confirmed failing, STOP and output exactly:

RED PHASE COMPLETE — proceeding to GREEN.

Also include a short GitHub‑style WIP message summarizing:

  • What you tested
  • Why these tests are needed now

After outputting this message, automatically begin PHASE 2.


PHASE 2 — GREEN (write minimum implementation)

  • Implement ONLY the minimum code required to make the new tests pass.
  • Do NOT refactor or clean up beyond what is strictly necessary.
  • Run only the newly written tests, confirming they now pass.
  • When the new tests pass, STOP and output exactly:

GREEN PHASE COMPLETE — proceeding to REFACTOR.

Also include a short GitHub‑style WIP message summarizing:

  • What code you added or changed
  • Which tests are now passing because of it

After outputting this message, automatically begin PHASE 3.


PHASE 3 — REFACTOR (improve design without changing behavior)

  • Refactor the code and tests to improve clarity, structure, and maintainability.
  • Do NOT change externally observable behavior.
  • Keep tests passing at all times.
  • Run the full test suite using make verify to ensure no regressions.

Before ending the phase, you must:

Update @TODO.md

  • Mark the current task as complete.
  • Remove or modify the relevant TODO entry as appropriate.
  • Ensure the TODO list reflects the new project state so the session can be safely restarted.

Generate a single final commit message

Produce one GitHub‑style commit message summarizing the entire task, including:

  • What the feature or fix does
  • The tests added
  • The implementation added
  • The refactoring performed
  • The final behavior of the code

This commit message must describe what the code accomplishes, not just what changed.

Then STOP and output exactly:

REFACTOR PHASE COMPLETE — awaiting review.

Also include a short GitHub‑style WIP message summarizing:

  • What you refactored
  • What the code now does
  • Why the design is better now

Do not begin a new task until I explicitly approve.


Hard Constraints

  • Never write implementation code in PHASE 1.
  • Never refactor in PHASE 2.
  • Never start a new TODO item without explicit approval.
  • Always respect the RED -> GREEN -> REFACTOR order.
  • Always run tests before claiming a phase is complete.
  • Always update @TODO.md at the end of PHASE 3 before stopping.
  • Only the final STOP requires human approval.
  • Only produce a commit message at the end of PHASE 3.
  • Follow the Editor & Hook Interaction Rules strictly during RED.

Begin now with PHASE 1 (RED) for the next task in @TODO.md.

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.