Implement With TDD
Implement clear behavior one verified slice at a time.
Read These First
docs/engineering/tdd.md— the loop and rulesdocs/engineering/testing.md— test philosophydocs/engineering/mocking.md— when and how to mockdocs/engineering/interface-design.md— designing testable seamsdocs/coding-standards.md— repo-specific conventionsdocs/context.md— glossary and domain language- Relevant
docs/adr/files for the area being touched
Workflow
1. Plan
Before writing code:
- Understand the target behavior from the user's request.
- Propose the interface changes needed (entrypoint, parameters, return type).
- List the behaviors to test, in the order you will tackle them.
- Flag any deep-module, boundary, or mocking concerns.
If the user is present (HITL), present the plan and wait for explicit approval before proceeding. If running unattended (AFK), proceed with the plan directly.
2. Tracer Bullet
One RED → GREEN cycle to prove the path:
- Write one test for the simplest behavior.
- Confirm it fails for the expected reason.
- Write the minimal code to pass.
- Confirm green.
3. Incremental Loop
For each remaining behavior, repeat:
- Red: write one failing test.
- Green: write the minimal code to pass.
- Confirm green before moving on.
Rules:
- One test at a time.
- Only enough code for the current test.
- Do not anticipate future tests.
- Stay on public interfaces. Do not test implementation details.
- Follow
docs/coding-standards.mdfor test naming, structure, and tooling.
4. Refactor
When the current set of tests passes:
- Propose one refactor at a time (naming, duplication, boundaries).
- Confirm green after each change.
- Stop when the code is clear enough for the current purpose.
Never refactor while RED.
Checklist Per Cycle
- Test describes behavior, not implementation
- Test uses public interface only
- Test would survive an internal refactor
- Implementation is minimal for this test
- No speculative features added
- Refactor only from GREEN