Skill: dev-tdd
TDD development with Red-Green-Refactor cycle. Use to implement a feature by writing tests BEFORE the code. Trigger automatically when the user asks for TDD, wants to write tests first, mentions "test first", or asks to implement, add, create, fix, correct code, a new feature, a bugfix, or a functionality.
Configuration
| Property | Value |
|---|---|
| Context | fork |
| Allowed tools | Read, Write, Edit, Bash, Glob, Grep |
| Keywords | dev, tdd, as a reference, adapt, improve, it worked when i tried, waste |
Detailed description
Test-Driven Development (TDD)
Iron Law
NO PRODUCTION CODE WITHOUT A FAILING TEST FIRST
If code was written before the test: delete it. Start over with TDD.
- Don't keep it "as a reference"
- Don't "adapt" it by writing the tests
- Don't look at it
- Delete = delete
Implement from scratch starting from the tests. Period.
TDD Cycle
┌─────────┐ ┌─────────┐ ┌──────────┐
│ RED │ ──▶ │ GREEN │ ──▶ │ REFACTOR │
│ Test │ │ Code │ │ Clean │
│ fail │ │ pass │ │ up │
└─────────┘ └─────────┘ └──────────┘
▲ │
└──────────────────────────────┘
Phase 1: RED - Write a failing test
Write ONE minimal test showing the expected behavior
describe('Module', () => {
describe('function', () => {
it('should [behavior] when [condition]', () => {
// Arrange - Prepare
// Act - Execute
// Assert - Verify
});
});
});