1075551341/claude_code_config/test-driven-development

Claude Code and agent skill by 1075551341/claude_code_config

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

遵循TDD流程开发功能,RED-GREEN-REFACTOR循环

Install

npx vskill@latest install 1075551341/claude_code_config/test-driven-development

SKILL.md

The same SKILL.md was published earlier as 1075551341/claude_code_config/test-driven-development.

测试驱动开发(TDD)

@Examples

用户: "用TDD实现这个功能"
Claude: /test-driven-development → RED(写失败测试) → GREEN(最小实现) → REFACTOR(优化)
用户: "先写测试"
Claude: /test-driven-development → 设计测试 → 编写失败测试 → 实现功能

核心理念

RED-GREEN-REFACTOR 循环:先写失败测试,再实现功能,最后重构优化。

三阶段循环

RED:写失败测试
bash
# 步骤
1. 理解需求
2. 设计接口(函数签名、输入输出)
3. 编写测试描述预期行为
4. 运行测试 → 必须失败
5. 失败信息验证测试正确

测试结构:

描述测试意图 → 安排测试数据 → 执行被测代码 → 断言结果

原则:

  • 一个测试一个断言
  • 测试名称描述行为,不是"测试 X"
  • 测试应失败并给出清晰原因
GREEN:最小实现
bash
# 步骤
1. 写最简单代码让测试通过
2. 硬编码返回值也行
3. 运行测试 → 必须通过
4. 不提前优化

原则:

  • 最小改变
  • 不添加额外功能
  • "作弊"通过比过度实现好
REFACTOR:优化清理
bash
# 步骤
1. 测试通过后检查代码
2. 消除重复
3. 改善命名
4. 优化结构
5. 每次小重构后运行测试
6. 测试始终通过

重构清单:

  • 重复代码 → 提取函数
  • 长函数 → 拆分
  • 魔法数字 → 常量
  • 复杂条件 → 策略模式

测试命名规范

javascript
// 好命名
describe('Calculator', () => {
it('should add two numbers correctly', () => {})
it('should throw error when dividing by zero', () => {})
it('should return negative result for negative inputs', () => {})
})
// 坏命名
describe('Calculator', () => {
it('testAdd', () => {}) // 不描述行为
it('test1', () => {}) // 无意义
it('works', () => {}) // 太模糊
})

测试框架选择

语言推荐
JavaScript/TypeScriptJest, Vitest
Pythonpytest
Gotesting 包
JavaJUnit 5
Rustcargo test

相关技能

  • 测试规范 → rules/CORE.md 代码规范·测试节
  • systematic-debugging - 调试流程
  • code-refactoring - 重构技巧

Security

  • Security scanPassed, 90 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

7-day trend score
5

Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/1075551341/claude_code_config/test-driven-development/badge)](https://verified-skill.com/skills/1075551341/claude_code_config/test-driven-development)

Something wrong with this skill or its page? Tell us.