test-driven-development
Test-Driven Development (TDD) Skill
Enforce the RED-GREEN-REFACTOR cycle for all code changes. Tests are written before implementation code, verified to fail for the right reasons, and maintained through disciplined development cycles.
Instructions
Before starting any TDD cycle, read and follow repository CLAUDE.md files. Project instructions override default TDD behaviors because local conventions (test frameworks, directory layout, naming) vary across codebases.
Phase 1: Write a Failing Test (RED)
The test MUST exist and fail before any implementation code is written, because seeing the test fail first proves it can actually detect the bug or missing feature. A test that has never been seen failing provides no evidence that it tests anything meaningful.
Steps:
- Understand the requirement -- clarify what behavior needs to be implemented
- Write the test first -- create a test that describes the desired behavior
- Use descriptive test names -- the test name should read as a specification of behavior (e.g.,
TestCalculateTotal_WithEmptyCart_ReturnsZero), because vague names likeTestCalcmake failures impossible to diagnose without reading the test body - Write minimal test setup -- only create fixtures/mocks needed for THIS test
- Assert expected behavior -- use specific assertions (not just "no error"), because weak assertions like
assert result != nilpass for wrong reasons and provide false confidence
More from notque/claude-code-toolkit
generate-claudemd
Generate project-specific CLAUDE.md from repo analysis.
12fish-shell-config
Fish shell configuration and PATH management.
12pptx-generator
PPTX presentation generation with visual QA: slides, pitch decks.
12codebase-overview
Systematic codebase exploration and architecture mapping.
10image-to-video
FFmpeg-based video creation from image and audio.
9data-analysis
Decision-first data analysis with statistical rigor gates.
9