test-driven-development

Installation
SKILL.md

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:

  1. Understand the requirement -- clarify what behavior needs to be implemented
  2. Write the test first -- create a test that describes the desired behavior
  3. Use descriptive test names -- the test name should read as a specification of behavior (e.g., TestCalculateTotal_WithEmptyCart_ReturnsZero), because vague names like TestCalc make failures impossible to diagnose without reading the test body
  4. Write minimal test setup -- only create fixtures/mocks needed for THIS test
  5. Assert expected behavior -- use specific assertions (not just "no error"), because weak assertions like assert result != nil pass for wrong reasons and provide false confidence
Related skills
Installs
7
GitHub Stars
366
First Seen
Mar 23, 2026