AgentSkillsCN

TDD

采用 TDD(测试驱动开发)周期来实现功能或修复缺陷。适用于用户提出 TDD 实施需求时使用。

SKILL.md
--- frontmatter
name: TDD
description: Implement features or fix bugs with TDD (Test-Driven Development) cycle. Use when the user requests TDD implementation.

When implementing features or fixing bugs, follow t-wada's TDD (Test-Driven Development) cycle to ensure high-quality code and maintainable tests.

t-wada's TDD Cycle

Basic 3 Steps

  1. Red - Write a failing test
  2. Green - Write the minimum code to make the test pass
  3. Refactor - Clean up the code

Key Additional Elements

Gradual Evolution from Fake Implementation to Real Implementation

  • First, use "fake implementation" by returning constants to make tests pass
  • Next, apply "triangulation" by adding multiple test cases
  • Finally, move to "obvious implementation" through generalization

Importance of Small Steps

  • Don't implement large features at once; proceed in extremely small increments
  • Confirm tests pass at each step
  • Always maintain working code

Timing of Refactoring

  • Perform refactoring immediately after tests pass
  • Both test code and production code are targets for refactoring
  • Eliminate duplication and clarify intent

Test Naming

  • Express specifications through test method names
  • Actively utilize Japanese naming (in his Japanese context)

t-wada particularly emphasizes "progressing steadily with small steps" and "gradual evolution from fake implementation," which are his main customizations to Kent Beck's original approach. The key insight is his focus on the intermediate steps between Red and Green, breaking down the "make it pass" phase into more granular, manageable steps that reduce risk and maintain momentum.