Engineering
Behavior Ladder TDD
Use tests as the prompt, one behavior at a time.
Use when
A pricing rule, validator, parser, permissions rule, workflow state machine, or other logic-heavy feature could balloon if implemented all at once.
Cadence
When implementing logic-heavy features
Verification
Each behavior test fails before implementation, passes after the smallest change, and remains green through final refactor.
Advanced specStructured loop spec
| Field | Value |
|---|---|
| Name | Behavior Ladder TDD |
| Category | Engineering |
| Trigger | When implementing logic-heavy features |
| Objective | Use tests as the prompt, one behavior at a time. |
| Allowed inputs | Relevant files, source notes, logs, tests, screenshots, metrics, or task state for this loop |
| Allowed actions | Convert business rules into an ordered checklist of behaviors, starting with the simplest valuable case.; Write one failing test for the next behavior and confirm it fails for the expected reason.; Implement only enough code to pass that test.; Run the focused test and the nearest related test set before adding the next behavior.; Refactor only after the ladder is green, and rerun the full relevant suite. |
| Verification | Each behavior test fails before implementation, passes after the smallest change, and remains green through final refactor. |
| Stop condition | Stop when the verifier passes, the budget is exhausted, no progress is made, a blocker appears, or approval is required. |
| Budget | Set a time, turn, token, retry, file, or dollar cap before running the loop. |
| Approval boundary | Human approval required before public, destructive, financial, legal, account, or production-impacting actions. |
| Safe output | Pull request, patch, report, or evidence log |
| Works with | Claude Code, OpenAI Codex, Cursor, Gemini CLI, any tool-using coding agent |
RunbookSteps
- Convert business rules into an ordered checklist of behaviors, starting with the simplest valuable case.
- Write one failing test for the next behavior and confirm it fails for the expected reason.
- Implement only enough code to pass that test.
- Run the focused test and the nearest related test set before adding the next behavior.
- Refactor only after the ladder is green, and rerun the full relevant suite.
Copy promptPrompt
Run the Behavior Ladder TDD loop. Convert the business rules into an ordered checklist of small behaviors. For each step, write one failing test first, confirm the expected failure, implement only enough code to pass, then run the focused and related tests. Do not add later rules early. Refactor only after the behavior ladder is green, and rerun the full relevant suite before reporting evidence.