WHEN working in TDD Red-Green-Refactor; NOT ad-hoc coding; write tests first, add minimal code to green, then assess refactoring.
View on GitHubplugins/web/skills/tdd/SKILL.md
February 1, 2026
Select agents to install to:
npx add-skill https://github.com/mintuz/claude-plugins/blob/main/plugins/web/skills/tdd/SKILL.md -a claude-code --skill tddInstallation paths:
.claude/skills/tdd/# TDD Best Practices Test-Driven Development with behavior-focused testing, factory patterns, and the Red-Green-Refactor cycle. ## Core Principle **Every single line of production code must be written in response to a failing test.** This is non-negotiable. If you're typing production code without a failing test demanding it, you're not doing TDD. ## The Sacred Cycle: Red → Green → Refactor ### 1. RED - Write a Failing Test Write a test that describes the desired behavior. The test must fail because the behavior doesn't exist yet. **Rules:** - Start with the simplest behavior - Test ONE thing at a time - Focus on business behavior, not implementation - Use descriptive test names that document intent - Use factory functions for test data ### 2. GREEN - Minimal Implementation Write the **minimum** code to make the test pass. Nothing more. **Rules:** - Only enough code to pass the current test - Resist "just in case" logic - No speculative features - If writing more than needed, STOP and question why ### 3. REFACTOR - Assess and Improve With tests green, assess whether refactoring would add value. **Rules:** - Commit working code FIRST - External APIs stay unchanged - All tests must still pass - Commit refactoring separately - Not all code needs refactoring - if clean, move on ## Quick Reference | Topic | Guide | | ---------------------------------------------------------------- | ------------------------------------------------------- | | Red-Green-Refactor examples with step-by-step workflows | [workflow-examples.md](references/workflow-examples.md) | | Factory functions, composition, test organization, 100% coverage | [test-factories.md](references/test-factories.md) | | Critical violations, high priority issues, style improvements | [violations.md](references/violations.md) | | Behavior testing patterns, tes