Comprehensive guidance for test-driven development (TDD) across greenfield work, bug fixes, refactors, and legacy modernization. Use when Codex needs to translate requirements into failing tests, execute strict Red-Green-Refactor loops, choose and combine test levels (unit/integration/contract/e2e), design APIs through tests, control mocking strategy, stabilize flaky tests, or incrementally improve code quality without regressions.
Use this skill to deliver behavior through small, test-first increments. Treat tests as executable specifications and design feedback, not just verification.
references/foundations-and-principles.md to align on TDD goals, values, and constraints.references/red-green-refactor-workflow.md to run disciplined micro-cycles and commit strategy.references/test-design-techniques.md to derive cases using equivalence classes, boundaries, and property checks.references/test-levels-and-architecture.md to choose unit vs integration vs contract vs e2e coverage.references/mocks-fakes-and-test-doubles.md to decide when to mock, fake, or use real collaborators.references/refactoring-and-design-feedback.md to use tests to improve structure and API shape.references/legacy-code-and-characterization.md to introduce TDD into hard-to-test systems.references/flaky-tests-and-debugging.md to diagnose nondeterminism and restore trust.references/framework-recipes.md for language-specific starter commands and conventions.references/tdd-anti-patterns.md to detect and correct common failure modes.Use this structure when reporting TDD work progress:
Behavior: the exact behavior implemented in this cycle.Red: failing test added and why it failed.Green: minimal code change that made it pass.Refactor: cleanup performed while preserving behavior.Risk: unresolved edge cases, tradeoffs, or follow-up tests.