Implement using TDD: $ARGUMENTS
Follow the red-green-refactor cycle strictly.
Phase 1 — RED: Write Failing Tests
- •Understand the requirement: What should the feature/fix do?
- •Choose test file: Use the test file mapping in project config
- •Write tests BEFORE any implementation code:
- •Success path test — what should happen with valid input
- •Validation error test — what should happen with invalid input
- •Service/device error test — what should happen when external resource is unavailable
- •Run tests — they MUST fail. If tests pass without implementation, they're testing nothing.
Test Conventions
- •Class:
Test<Feature> - •Method:
test_<action>_<expected_outcome> - •Fixtures with proper type hints and cleanup
- •Test HTTP client configured for proper error testing (no automatic error propagation)
- •Audit log tests with log capture mechanism (see stack concepts) on the project's audit logger
Phase 2 — GREEN: Minimal Implementation
- •Write the minimum code to make tests pass — nothing more
- •Follow project standards:
- •Future annotations pattern (see stack concepts)
- •Typed exceptions from the exception hierarchy
- •Thread safety in service layer
- •Typed schemas for API shapes (see stack concepts)
- •Thin route handlers with DI injection (see stack concepts)
- •Run tests — they MUST now pass
Phase 3 — REFACTOR: Clean Up
- •Remove duplication
- •Improve naming
- •Extract helpers if three or more similar patterns exist
- •Ensure layer boundaries are respected
- •Run full suite — nothing must break. Run test and type-check commands (see project config).
Phase 4 — Complete
- •Verify audit logging if state changes were added
- •Update OpenAPI metadata (summary, description, responses)
- •Update project documentation if new endpoints or config were added
- •Run final verification with the test and type-check commands