smithery.ai

tdd-cycle

执行 TDD 红绿重构循环(RED→GREEN→REFACTOR→REPEAT),通过?

First seen Mar 21, 2026

Installation

$ npx skills add https://smithery.ai

Similar popular skills

Related neighbors and high-traction skills in the same topics — useful to compare before installing.

Also in this package

Other skills from smithery.ai · top by installs.

npx skills add https://smithery.ai

Browse all from smithery.ai

More details

Agent compatibility

Declared targets from SKILL.md / docs. Unmarked agents are not listed — the skill may still install via the CLI.

Claude Code Not declared
Cursor Not declared
Codex Not declared
GitHub Copilot Not declared
Windsurf Not declared
Gemini CLI Not declared
Cline Not declared
OpenCode Not declared

Package contents

Files included with this skill beyond the listing page.

  • skill md SKILL.md 3,709 B
  • docs SUMMARY.md 320 B

History

  1. First seen on skills.sh
  2. First recorded snapshot · 3 installs

SKILL.md

TDD Cycle Skill

Scope: EXECSPEC_FULFILL — Fulfill ExecSpec(落实 ExecSpec)

版本: 0.1.0(占位)| 创建日期: 2025-11-27


概述

TDD Cycle 是测试驱动开发的核心循环:

┌─────────────────────────────────────────────────────┐
│              🔄 TDD Cycle                           │
├─────────────────────────────────────────────────────┤
│       ┌─────┐                                      │
│       │ RED │ ← 写失败的测试                        │
│       └──┬──┘                                      │
│          ↓                                         │
│       ┌─────┐                                      │
│       │GREEN│ ← 最小代码让测试通过                  │
│       └──┬──┘                                      │
│          ↓                                         │
│    ┌──────────┐                                    │
│    │REFACTOR │ ← 重构,保持测试绿色                 │
│    └────┬─────┘                                    │
│         └──────→ REPEAT                            │
└─────────────────────────────────────────────────────┘

核心节奏

  • 🔴 RED: 先写失败的测试
  • 🟢 GREEN: 写最小代码让测试通过
  • 🔵 REFACTOR: 重构代码,保持测试绿色
  • 🔁 REPEAT: 循环直到功能完成

L1-STREAMLINED

检查清单

  • 测试先于实现代码编写
  • 每次 GREEN 后立即考虑重构
  • 单元测试覆盖率 ≥ 80%
  • 测试金字塔比例合理(60%单元/30%集成/10%E2E)
  • GOAL 注释已添加到测试文件

通过标准

  • 5 项中 4 项通过(≥80%)

>> 命令

>>tdd_check_l1         # 检查 TDD 节奏
>>coverage_report_l1   # 测试覆盖率报告

GOAL 注释规范

// GOAL: GOAL-XXX-001
describe('功能描述', () => {
  it('should ...', () => {
    // 测试代码
  });
});

常见问题

🔴 RED 阶段

问题:测试写得太大 解决:每个测试只验证一个行为

问题:不知道先测什么 解决:从最简单的 Happy Path 开始

🟢 GREEN 阶段

问题:写了太多代码 解决:只写让测试通过的最小代码

问题:想一步到位 解决:接受"丑陋"的代码,重构阶段再优化

🔵 REFACTOR 阶段

问题:跳过重构 解决:每次 GREEN 后强制问自己"能更简单吗?"

问题:重构时破坏测试 解决:小步重构,每步都运行测试


相关 Skills

  • 前置: bdd-scenario(BDD 场景已定义)
  • 并行: code-quality(质量门禁)
  • 原则: principle-dry, principle-kiss

TODO: 待细化覆盖率检查脚本和 TDD 节奏监控