Agent Skill

Test-Driven Development
Disciplined TDD methodology enforcing write-test-first workflow with red-green-refactor cycle for all features and bugfixes
What is Test-Driven Development?
This skill enforces a rigorous test-driven development methodology where agents must write failing tests before any implementation code. The skill mandates a strict red-green-refactor cycle: write a test that fails, write minimal code to make it pass, refactor while keeping tests green, then repeat. It covers writing unit tests that verify specific behaviors, watching tests fail to confirm they test the right thing, implementing only enough code to pass the current test, refactoring with confidence due to comprehensive test coverage, and integrating TDD into the broader development workflow. The agent learns that violating the letter of TDD rules violates the spirit—no shortcuts, no implementation before tests, no assuming tests work without seeing them fail. The skill establishes boundaries around what constitutes a proper test versus a sanity check, when to write integration tests versus unit tests, and how to handle external dependencies through mocking or test doubles. Trade-offs include the upfront time investment in writing tests against the long-term benefits of maintainability and bug prevention, choosing granularity of tests to balance coverage with test suite execution time, and deciding when to refactor tests themselves as the codebase evolves. The skill emphasizes that TDD is a discipline that builds better software through enforced verification.
Key capabilities
Strict red-green-refactor enforcement
Mandates writing a failing test first, implementing minimal code to pass, then refactoring while maintaining green tests, with no deviations from this cycle
Fail-first verification requirement
Requires watching every test fail before implementation to ensure tests actually verify the intended behavior rather than passing accidentally
Minimal implementation principle
Guides agents to write only the code necessary to pass the current test, avoiding premature optimization or feature creep beyond current requirements
Refactoring with test safety net
Enables confident refactoring by maintaining comprehensive test coverage that catches regressions immediately during code restructuring
Use cases
Building new features with verified behavior
Implement new features by writing tests for each expected behavior first, ensuring every feature is fully tested before merging and preventing untested code paths
Bug fixing with regression prevention
Fix bugs by first writing a test that reproduces the issue (fails), then implementing the fix to make the test pass, permanently preventing regression of that bug
Refactoring legacy code safely
Add comprehensive test coverage to existing code before refactoring, ensuring behavioral equivalence is maintained throughout the restructuring process
API contract verification
Design and verify API contracts through tests before implementation, ensuring the interface meets requirements and handles edge cases correctly
