Skill: Test-Driven Development
Trigger
Load this skill whenever:
- Writing a new function, hook, component, or module
- Fixing a bug (the bug must have a test that reproduces it before the fix)
- Refactoring existing code
- Adding a new API endpoint or store action
Type
Rigid — The RED → GREEN → REFACTOR cycle is non-negotiable. Never write implementation code before a failing test exists.
Instructions
Phase 1 — RED (Write a failing test)
- Identify the smallest possible unit of behavior to implement.
- Write a test that describes the expected behavior. The test must:
- Have a descriptive name (
it('returns zero when no transactions exist', ...)) - Test one thing only
- Currently fail (you have not written the implementation yet)
- Have a descriptive name (
- Run the test. Confirm it fails with the expected error, not an import error or syntax error.
- Do not proceed to Phase 2 until the test fails for the right reason.
Phase 2 — GREEN (Make the test pass with minimal code)
- Write the simplest possible implementation that makes the test pass.
- Do not add logic the test does not require. Resist the urge to generalize.
- Run the test. Confirm it passes.
- Do not proceed to Phase 3 if any other tests are broken.
Phase 3 — REFACTOR (Clean up without changing behavior)
- Improve the implementation: extract duplication, rename variables, simplify logic.
- Run the full test suite after every change. All tests must stay green.
- Do not add new behavior during refactor. If you think of something new, write a new test first (return to Phase 1).
Repeating the cycle
- For each additional behavior, return to Phase 1. One cycle per behavior unit.
Verification
- A failing test exists before any implementation is written.
- The test name describes behavior, not implementation details.
- After GREEN, no other tests are broken.
- After REFACTOR, the test suite is fully green and the code is cleaner than before.
- At no point was implementation written without a corresponding test.
Skills similaires
Expert Next.js App Router
Developpement
Un skill qui transforme Claude en expert Next.js App Router.
Claude CodeCursoradvanced
890
234
3,226
Générateur de README
Developpement
Crée des README.md professionnels et complets pour vos projets.
claudeCursorWindsurfbeginner
259
72
1,129
Rédacteur de Documentation API
Developpement
Génère de la documentation API complète au format OpenAPI/Swagger.
claudeCursorWindsurfintermediate
156
44
999