test-driven-development

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

Updated Jun 30, 2026
One-click install
npx skills add https://github.com/JiangAustin/Money_Never_Sleep --skill test-driven-development-jiangaustin
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: test-driven-development
Source: https://github.com/JiangAustin/Money_Never_Sleep/tree/main/.claude/skills/test-driven-development
Command: npx skills add https://github.com/JiangAustin/Money_Never_Sleep --skill test-driven-development-jiangaustin

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

这个 Skill 解决的是“先写代码再补测试”带来的低信心和回归风险,帮助你在实现前先明确行为、验证失败点,并用可重复的测试驱动开发过程。

Core Features & Use Cases

  • 先写测试再实现:适用于新功能、Bug 修复、重构和行为变更,确保每一步都有可验证的预期。
  • 红-绿-重构流程:通过先看到失败、再用最少代码通过、最后安全重构,降低复杂改动带来的风险。
  • 真实行为优先:强调测试真实代码路径而不是测试 mock 本身,避免虚假通过和脆弱测试。
  • Use Case:当你要修复一个排序逻辑 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 a bug fix?

To start test-driven development for a bug fix, write a failing test that reproduces the bug, implement minimal code to pass it, and then refactor safely. This red-green-refactor sequencing prevents regression.

What is the red-green-refactor sequence in unit testing?

The red-green-refactor sequence in unit testing means writing a failing test first, implementing minimal production code to make it pass, and then safely refactoring the implementation without changing behavior.

Why should I write tests before production code?

Writing tests before production code prevents unverified implementation by forcing you to define expected behavior first. This reduces false positives from excessive mocking and ensures real behavior verification.

Does test-driven development work for refactoring existing software?

Yes, test-driven development works for refactoring existing software by requiring regression coverage first. You verify current behavior with tests, make minimal changes to pass them, and safely refactor the implementation.

How do I avoid brittle tests when using mock objects?

To avoid brittle tests when using mock objects, prioritize testing real code paths and real behavior verification over testing the mocks themselves. This prevents false confidence and ensures your tests validate actual software behavior.