TDD Intelligence
True test-driven development with agentic discipline.
Core Loop
- Understand the desired behavior (read existing code, docs, issues).
- Write the smallest failing test (or characterization test for legacy) that expresses the goal.
- Run the test and confirm it fails for the right reason.
- Implement the minimal code to make the test pass.
- Refactor for cleanliness while keeping tests green.
- Add any additional edge-case or regression tests suggested by the implementation.
- Verify the full relevant test suite still passes.
For Refactors and Legacy Code
- First write characterization tests that lock in current (even if imperfect) behavior.
- Then change implementation.
- Confirm the characterization tests still pass (proving behavior preservation).
Rules
- Never implement before at least one relevant test exists and is failing appropriately.
- Prefer focused unit tests over broad integration tests for the core logic.
- When editing UI or complex flows, combine with
browser-qaor manual verification steps. - Update or add tests in the same diff as the feature when possible.
Subagent Support
Use a subagent to:
- Explore the test surface area before writing tests.
- Generate additional edge cases after the happy path is implemented.
Verification Commands
Always surface the actual commands the project uses:
- Python:
pytest ... -q --tb=short - Next.js:
npm testorvitest - Rust:
cargo test
Discover these via the repo rather than assuming.
Success Criteria
- The new/changed behavior is covered by tests that would have failed before the change.
- All tests in the affected area are green at the end.
- Diff size remains reasonable (tests + implementation together).
Anti-Patterns
- Writing implementation then retrofitting tests.
- Skipping tests "because it's simple".
- Large untested refactors justified by "we'll add tests later".