test-driven-development

Enforce the Red-Green-Refactor cycle for all feature work and bug fixes.

3|Updated Oct 18, 2025
One-click install
npx skills add https://github.com/DYAI2025/Stoppclock-page --skill test-driven-development-dyai2025
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: test-driven-development
Source: https://github.com/DYAI2025/Stoppclock-page/tree/main/stoppclock_speckit/.claude/commands/SKILL (20).md
Command: npx skills add https://github.com/DYAI2025/Stoppclock-page --skill test-driven-development-dyai2025

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill enforces the Test-Driven Development (TDD) methodology, ensuring that all production code is backed by reliable tests that verify actual behavior. It prevents the creation of untested or poorly tested code, reducing bugs and technical debt.

Core Features & Use Cases

  • Red-Green-Refactor Cycle: Guides through writing a failing test, then minimal code to pass, then refactoring.
  • Rationalization Prevention: Counters common excuses for skipping TDD, ensuring strict adherence.
  • Use Case: Implement any new feature or bug fix, guaranteeing that the code is thoroughly tested, resilient to changes, and its behavior is clearly documented by the tests themselves.

Quick Start

1. RED: Write a failing test for one minimal behavior.

Example: test('retries failed operations 3 times', ...)

2. Verify RED: Run the test, confirm it fails correctly.

3. GREEN: Write the simplest code to make the test pass.

4. Verify GREEN: Run the test, confirm it passes.

5. REFACTOR: Clean up code while keeping tests green.

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 code to catch bugs early?

Test-driven development writes failing tests first, then minimal production code to pass them, then refactors while keeping tests green. This Red-Green-Refactor cycle ensures behavior is verified before implementation, reducing bugs and technical debt by anchoring code to explicit test requirements.

What's the Red-Green-Refactor cycle and why does it matter?

Red-Green-Refactor is a three-step loop: write a failing test (red), write minimal code to pass it (green), then clean up while tests stay green (refactor). This enforces small, focused implementations backed by tests that document actual behavior and prevent regressions.

Can I use test-driven development for bug fixes and refactoring, not just new features?

Yes. Test-driven development applies to all feature work, bug fixes, and refactors. Write a test that reproduces the bug or specifies the refactor goal, watch it fail, implement the minimal fix or change to pass it, then refactor to keep the suite green.

How does test-driven development prevent untested code?

TDD enforces a mandatory failing test before any production code is written. This constraint ensures every feature or fix has explicit test coverage from the start, eliminating untested paths and making behavior transparent through the test suite itself.

What's the minimal code requirement in test-driven development?

After writing a failing test, write only the simplest code necessary to make that test pass—no extra features, no premature optimization. This keeps implementations focused, maintainable, and directly tied to verified requirements.

Related Skills