Red-Green-Refactor
The test-first loop: write a failing test that encodes the requirement, write the minimum code to pass it, then refactor with the test as a safety net.
When to use
Feature and bugfix work in test-capable codebases; the strongest evidence trail per unit of ceremony.
Steps
| Step | What happens | Verification |
|---|---|---|
| Red | Write a test that fails for the right reason. | Test run, observed failing, failure message matches the missing behavior. |
| Green | Write the minimum implementation to pass. | Target test passes; full suite still passes. |
| Refactor | Improve structure without changing behavior. | Suite green after every refactor step. |
Specification
| Verification method | The tests themselves: the loop's own output is its evidence. |
|---|---|
| Recovery behavior | diagnose-then-retry |
| Observability | Test run history is the audit trail. |
| Inputs | Requirement, Test infrastructure |
| Outputs | Tested implementation, Regression net |
| Risk level / maturity | low / established |
Failure modes
- Tests written after code assert the implementation, not the requirement
- Agents modify the test to make it pass
- Setup-heavy stacks tempt skipping straight to code
Assessment
The oldest loop in this library and still the highest evaluation-readiness per step. The agent-specific hazard is test-tampering, which is why boundaries like 'never modify the test to make it pass' appear in serious TDD skills.