TDD Workflow
Consult python3-core for standing defaults. Load python3-testing for detailed test patterns.
Input
Task: $ARGUMENTS
Phases
1. Design Interface
- Define function signatures with full type annotations
- Create Protocol classes for dependencies
- Write docstrings before implementation
- Load
python3-typingwhen boundary types or models are involved
2. Write Failing Tests
- Load
python3-testingfor fixture patterns and test structure - Tests must fail initially (RED)
- AAA pattern; behavioral naming
- Run
uv run pytest -v— confirm failures
3. Implement to Pass
- Minimal code to make tests pass (GREEN)
- Run
uv run pytest -vafter each change - Refactor only while tests stay green
4. Verify
# Linting, formatting, and type checking
uv run prek run --files src/ tests/
# Fallback when no .pre-commit-config.yaml:
# uv run ruff check src/ tests/
# uv run ruff format --check src/ tests/
# Tests with coverage
uv run pytest --cov=src --cov-report=term-missing
5. Quality Gate
- [ ] All tests pass
- [ ] No lint errors
- [ ] No type errors
- [ ] Coverage ≥80%
- [ ] Shebang validated on scripts