Test-Driven Development (TDD)
- Understand the exact requirement or bug and identify the narrowest executable check.
- Write the failing test first. Ensure it fails for the expected reason, not a setup or syntax error.
- Implement the minimal production code needed to make the failing test pass. Avoid speculative features.
- Re-run the test to confirm green.
- Refactor: clean up names, remove duplication, and simplify structure while keeping tests green.
- Verify adjacent tests and broader contracts to ensure no regressions.