test-driven-development

Guide developers through red-green-refactor cycles for test-first implementation.

Updated Sep 8, 2025
One-click install
npx skills add https://github.com/randalmurphal/claude-config --skill test-driven-development-randalmurphal
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: test-driven-development
Source: https://github.com/randalmurphal/claude-config/tree/main/skills/test-driven-development
Command: npx skills add https://github.com/randalmurphal/claude-config --skill test-driven-development-randalmurphal

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires pytest, pytest-watch, and includes references (resource) components.

What problem does it solve?

This Skill guides developers through Test-Driven Development (TDD) workflows, ensuring code correctness, enabling confident refactoring, and fostering better software design. It helps prevent bugs, clarifies requirements upfront, and provides a safety net for continuous code improvement.

Core Features & Use Cases

  • Red-Green-Refactor Cycle: Master the core TDD loop: write a failing test, make it pass with minimal code, then refactor.
  • Test-First Implementation: Drive new feature development by writing tests before implementation, clarifying requirements and design.
  • TDD for Refactoring & Debugging: Safely refactor existing code and efficiently fix bugs by first writing tests that capture current behavior or reproduce issues.
  • Use Case: When implementing a new user registration feature, use this skill to guide the process by first writing a test for a valid registration, then minimal code to pass, and iteratively adding tests for error cases like duplicate emails or weak passwords.

Quick Start

Use the test-driven-development skill to guide me through the Red-Green-Refactor cycle for implementing a new calculate_discount function.

Frequently Asked Questions about test-driven-development

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

FAQPage Schema
How do I implement test-driven development with the red-green-refactor cycle?

Test-driven development follows three steps: write a failing test (red), write minimal code to pass it (green), then improve the code without changing behavior (refactor). This cycle ensures tests drive design and code changes remain safe.

When should I write tests before implementing code?

Write tests first when starting new features, APIs, or refactoring existing code. Test-first implementation clarifies requirements upfront, prevents bugs, and provides a safety net for continuous improvement across unit, integration, and acceptance testing levels.

Can I use TDD to fix bugs and debug code?

Yes. Write a test that reproduces the bug or captures current behavior, then fix the code to pass. This approach isolates the issue and prevents regression while providing confidence during refactoring.

What testing frameworks does test-driven development work with?

TDD integrates with pytest and pytest-watch for Python projects. These tools support unit, integration, and acceptance-level testing with fixture patterns and test progression control required for red-green-refactor workflows.

Why does test-driven development improve software design?

Writing tests first forces you to design testable interfaces and clarify requirements before implementation. This produces loosely-coupled, modular code that's easier to refactor, maintain, and extend.