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 spec

Structured loop spec

FieldValue
NameBehavior Ladder TDD
CategoryEngineering
TriggerWhen implementing logic-heavy features
ObjectiveUse tests as the prompt, one behavior at a time.
Allowed inputsRelevant files, source notes, logs, tests, screenshots, metrics, or task state for this loop
Allowed actionsConvert 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.
VerificationEach behavior test fails before implementation, passes after the smallest change, and remains green through final refactor.
Stop conditionStop when the verifier passes, the budget is exhausted, no progress is made, a blocker appears, or approval is required.
BudgetSet a time, turn, token, retry, file, or dollar cap before running the loop.
Approval boundaryHuman approval required before public, destructive, financial, legal, account, or production-impacting actions.
Safe outputPull request, patch, report, or evidence log
Works withClaude Code, OpenAI Codex, Cursor, Gemini CLI, any tool-using coding agent
Runbook

Steps

  1. Convert business rules into an ordered checklist of behaviors, starting with the simplest valuable case.
  2. Write one failing test for the next behavior and confirm it fails for the expected reason.
  3. Implement only enough code to pass that test.
  4. Run the focused test and the nearest related test set before adding the next behavior.
  5. Refactor only after the ladder is green, and rerun the full relevant suite.
Copy prompt

Prompt

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.
Metadata

Tags

TDDtestsbusiness rulesagent coding
Next loops

Related