Master the foundational TDD methodology - write tests first, watch them fail, write minimal code to pass, and refactor. Learn the Red-Green-Refactor cycle and why this discipline prevents bugs, improves design, and eliminates rationalizations that lead to untested code.
clawd add obra/test-driven-developmentTest-Driven Development
This skill teaches the complete Test-Driven Development methodology - one of the most effective practices for writing reliable, maintainable code. The core principle is simple but transformative: "Write the test first. Watch it fail. Write minimal code to pass."
Key Concepts
The skill covers the Red-Green-Refactor cycle:
- RED: Create one minimal failing test demonstrating desired behavior
- GREEN: Write the simplest code that satisfies the test
- REFACTOR: Clean up code while maintaining test success
Why TDD Matters
Writing tests after code is written means they pass immediately, proving nothing. TDD forces you to think about the API and requirements before implementation, catches edge cases early, and prevents common rationalizations that lead to untested code.
When to Apply
Use TDD for all new features, bug fixes, refactoring, and behavior changes. Only exceptions (requiring partner approval) are throwaway prototypes, generated code, and configuration files.
The skill directly addresses common excuses like "too simple to test," "I'll test after," and "deleting code is wasteful," treating each as a signal to restart with actual TDD.