test-driven-development

Write failing tests before implementing minimal production code.

Updated Apr 12, 2026
One-click install
npx skills add https://github.com/zhuyingcoder/cc-demo --skill test-driven-development-zhuyingcoder
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: test-driven-development
Source: https://github.com/zhuyingcoder/cc-demo/tree/main/.claude/skills/test-driven-development
Command: npx skills add https://github.com/zhuyingcoder/cc-demo --skill test-driven-development-zhuyingcoder

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

使用测试驱动开发(TDD)的方法,在实现任何功能或修复 bug 时先编写测试,从而确保需求真正被验证,减少回归风险。

Core Features & Use Cases

  • 先写失败的测试再实现代码,确保测试能够捕捉到预期行为。
  • 通过红-绿-重构循环改善代码可维护性与设计质量。
  • 适用于新功能开发、Bug 修复和重构等场景。

Quick Start

先编写一个明确的测试用例来描述你期望的行为,然后实现最少的生产代码使测试通过。

Frequently Asked Questions about test-driven-development

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

FAQPage Schema
How do I start test-driven development for new features?

Test-driven development starts by writing a failing test case that describes expected behavior, then implementing minimal production code to make it pass. This enforces requirement validation before functional implementation.

What is the red-green-refactor cycle in TDD?

The red-green-refactor cycle in TDD involves writing a failing test, writing code to pass the test, then refactoring for maintainability. This iterative workflow improves software design quality while ensuring expectations are met.

Can I use TDD for bug fixes and refactoring?

TDD applies to bug fixes and refactoring by writing tests that capture expected behavior or reproduce the bug. Implement minimal code changes to pass these tests, reducing regression risk during software maintenance.

Why write failing unit tests before implementation?

Writing failing unit tests before implementation ensures tests genuinely capture expected behavior rather than mirroring existing logic. This validates requirements upfront and guides minimal code development to pass the test suite.

Does test-driven development slow down feature development?

Test-driven development requires upfront time writing clear tests first, but reduces regression risk and improves maintainability. Applying TDD across feature work validates expectations before implementation, minimizing future debugging overhead.

What's the best way to write TDD tests for expected behavior?

The best way to write TDD tests is creating clear test cases describing exact expected behavior before any production code exists. Implement just enough code to pass, ensuring unit-testing validates software engineering requirements.