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.
In this repository5 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- project-bootstrapSkill
- reviewer-responseSkill
- security-auditSkill
- skeptical-reviewerSkill
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
- Very specific: line 17
Always use red/green/refactor TDD.
- Distinctive: line 18
Never write implementation code before tests.
- Distinctive: line 19
Never move to a new TODO item until I explicitly approve.
- Distinctive: line 21
Only the final STOP requires human review.
- Distinctive: line 23
Use selective test running to reduce cycle time:
- Distinctive: line 35
Write the entire test function in one edit, including:
- Distinctive: line 42
Do not split test creation across multiple edits.
- Distinctive: line 54
Do not attempt to fix missing symbols during RED.
- Distinctive: line 67
always write imports + test code in the same edit
- Distinctive: line 68
never write imports alone
- Distinctive: line 69
never write test bodies alone
- Distinctive: line 76
Only RED requires the “single edit” rule.
- Very specific: line 82
Read the next task from @TODO.md.
- Distinctive: line 83
Write ONLY the failing test(s) required for this task.
- Distinctive: line 84
Follow the Editor & Hook Interaction Rules above.
- Distinctive: line 85
Run only the newly written tests, confirming they fail for the correct reason.
- Distinctive: line 86
When tests are written and confirmed failing, STOP and output exactly:
- Distinctive: line 94
After outputting this message, automatically begin PHASE 2.
- Distinctive: line 102
Run only the newly written tests, confirming they now pass.
- Distinctive: line 103
When the new tests pass, STOP and output exactly:
- Distinctive: line 119
Keep tests passing at all times.
- Very specific: line 120
Run the full test suite using make verify to ensure no regressions.
- Distinctive: line 122
Before ending the phase, you must:
- Distinctive: line 126
Remove or modify the relevant TODO entry as appropriate.
- Distinctive: line 127
Ensure the TODO list reflects the new project state so the session can be safely restarted.
- Distinctive: line 148
Do not begin a new task until I explicitly approve.
- Distinctive: line 154
Never write implementation code in PHASE 1.
- Distinctive: line 155
Never refactor in PHASE 2.
- Distinctive: line 156
Never start a new TODO item without explicit approval.
- Distinctive: line 157
Always respect the RED -> GREEN -> REFACTOR order.
- Distinctive: line 158
Always run tests before claiming a phase is complete.
- Very specific: line 159
Always update @TODO.md at the end of PHASE 3 before stopping.
- Distinctive: line 160
Only the final STOP requires human approval.
- Distinctive: line 161
Only produce a commit message at the end of PHASE 3.
- Distinctive: line 162
Follow the Editor & Hook Interaction Rules strictly during RED.
≈ “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.
Files
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
- Always use red/green/refactor TDD.
- Never write implementation code before tests.
- Never move to a new TODO item until I explicitly approve.
- You may automatically proceed from RED -> GREEN -> REFACTOR without waiting for approval.
- Only the final STOP requires human review.
- I will commit manually; you must not commit or proceed on your own.
- 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 verifyto 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.mdat 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.
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
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.

