test-driven-development

Enforce a red-green-refactor workflow with failing tests before production code.

5|Updated Feb 8, 2026
One-click install
npx skills add https://github.com/tiancaiamao/ai --skill test-driven-development-tiancaiamao
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: test-driven-development
Source: https://github.com/tiancaiamao/ai/tree/main/skills/test-driven-development
Command: npx skills add https://github.com/tiancaiamao/ai --skill test-driven-development-tiancaiamao

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Test-driven development helps you prove behavior before you build it. It reduces regressions, clarifies requirements, and makes refactoring safer.

Core Features & Use Cases

  • Write a failing test before production code.
  • Implement the smallest change needed to make the test pass.
  • Refactor confidently while keeping the test suite green.
  • Apply it to new features, bug fixes, and behavior-preserving cleanup.
  • Use the anti-pattern guidance to avoid testing mocks, adding test-only methods, or over-mocking dependencies.

Quick Start

Use this skill to implement a change by writing the failing test first, confirming it fails, and then adding the smallest code change that makes it pass.

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 unit tests before implementing new features?

Unit tests before implementing new features require a red-green-refactor workflow: create a failing test that defines expected behavior, write the minimal code to pass it, then refactor while keeping the suite green.

What is the red-green-refactor workflow in test-driven development?

The red-green-refactor workflow in test-driven development is a cycle of writing a failing test, implementing the smallest code change to make it pass, and then cleaning up the code while ensuring behavior remains validated.

How do I reproduce a bug with a failing test before fixing it?

To reproduce a bug with a failing test, write a test that explicitly demonstrates the defect before touching production code, confirming the test fails for the right reason, then apply the smallest fix to make it pass.

Why does over-mocking dependencies make unit tests fragile?

Over-mocking dependencies makes unit tests fragile because it decouples tests from real behavior, leading to false positives; tests should validate actual outcomes rather than interaction details or test-only production methods.

Can I use test-driven development for refactoring existing code?

Yes, you can use test-driven development for refactoring existing code by relying on a green test suite to validate that behavior-preserving cleanup and structural changes do not introduce regressions.

What is the best way to avoid adding test-only methods during TDD?

The best way to avoid adding test-only methods during TDD is to enforce minimal implementations that rely on public behavior validation rather than exposing internal methods solely for unit test coverage.