What problem does it solve?
This Skill enforces the Test-Driven Development (TDD) cycle, preventing common pitfalls like writing tests after code, which often leads to unreliable tests that don't truly verify behavior. It ensures every piece of code is backed by a proven test.
Core Features & Use Cases
- Red-Green-Refactor Cycle: Guides you through the disciplined process of writing a failing test, then minimal code to pass it, and finally refactoring for cleanliness.
- Mandatory Failure Verification: Ensures you always see a test fail before making it pass, proving that your test actually verifies the intended behavior.
- Anti-Rationalization: Explicitly counters common excuses for skipping TDD, ensuring a consistent and high-quality development practice.
- Use Case: When implementing any new feature or fixing a bug, this skill ensures you start with a failing test, guaranteeing that your solution addresses the problem and is properly verified, preventing regressions.
Quick Start
1. Write a failing test (RED)
test('adds two numbers', () => {
expect(add(1, 2)).toBe(3);
});
2. Run test (it should fail)
npm test my-test.test.ts
3. Write minimal code to pass (GREEN)
function add(a, b) {
return a + b;
}
4. Run test (it should pass)
npm test my-test.test.ts
5. Refactor (clean up code while keeping tests green)