test-driven-development

Write failing tests before production code using a red-green-refactor workflow.

6|Updated Aug 19, 2025
One-click install
npx skills add https://github.com/lv416e/dotfiles --skill test-driven-development-lv416e
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: test-driven-development
Source: https://github.com/lv416e/dotfiles/tree/main/dot_claude/skills/test-driven-development
Command: npx skills add https://github.com/lv416e/dotfiles --skill test-driven-development-lv416e

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Developers often write code first, then tests, leading to untested edge cases, fragile code, and difficulty distinguishing new bugs from old ones. This skill enforces a rigorous Test-Driven Development (TDD) cycle, ensuring every piece of code is verified by a failing test first.

Core Features & Use Cases

  • Red-Green-Refactor Cycle: Guides you through writing failing tests, implementing minimal code to pass, and then refactoring for clean design.
  • Iron Law Enforcement: Mandates "NO PRODUCTION CODE WITHOUT A FAILING TEST FIRST," preventing untested code from entering the codebase.
  • Anti-Rationalization: Explicitly counters common excuses for skipping TDD, ensuring disciplined adherence even under pressure.
  • Bug Fix Integration: Requires writing a failing test to reproduce any bug before fixing it, proving the fix and preventing regressions.

Quick Start

I'm implementing a new user authentication feature. Use the test-driven-development skill to guide me through the process, starting with a failing test.

Frequently Asked Questions about test-driven-development

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write tests before implementing code?

Test-driven development starts by writing a failing test that describes the desired behavior, then writing minimal production code to make it pass, and finally refactoring for clarity. This red-green-refactor cycle ensures every line of code is verified by a test before it enters the codebase.

What's the best way to prevent bugs during development?

TDD prevents bugs by enforcing a failing test before any production code is written. This catches edge cases early, makes regressions obvious when tests break, and creates a safety net for refactoring, reducing the likelihood of introducing new defects.

How do I use TDD when fixing bugs?

Write a failing test that reproduces the bug first, then fix the code to make the test pass. This proves the fix works and prevents the same bug from reoccurring later, since the test becomes part of your permanent regression suite.

Can I apply test-driven development to refactoring?

Yes. TDD supports refactoring by requiring passing tests before you change code. Refactor with confidence knowing your tests will catch any behavior changes, ensuring the code improves in design without altering its functionality.

Why should I write tests first instead of after coding?

Writing tests first forces you to think through expected behavior upfront, leading to better API design and fewer untested edge cases. It also prevents the common rationalization of skipping tests when deadlines pressure you, maintaining code quality consistently.

Does test-driven development work for quality assurance?

Yes. TDD is a quality assurance practice that embeds verification into the development cycle. Every feature, fix, and refactor is validated by tests written first, creating a continuous safety net that reduces defects and makes the codebase more maintainable.