Skip to content
Back to skills

Tdd Assistant

ASecurity

[UDS] 测试驱动开发(TDD)的参考资料:红-绿-重构循环、FIRST 原则与 Arrange-Act-Assert 结构。 Use when: 在实现前先写一个会失败的测试、用 Arrange-Act-Assert 组织测试、以 FIRST 检视既有测试。 Not for: 交互式地驱动 RED/GREEN 循环——该部分已移至采用层(XSPEC-095);测量测试覆盖了多少代码——请用 /coverage。 Keywords: TDD, test first, Red Green Refactor, FIRST, Arrange Act Assert, unit test, 测试驱动开发, 红绿重构, 单元测试.

  • 75 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added February 8, 2026
developmentcode-review

Security analysis

A100/100

Pro scans all 3 files and shows the line behind each finding

Scanned September 21, 2026

npx -y skills add AsiaOstrich/universal-dev-standards --skill tdd-assistant --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Tdd Assistant?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Tdd Assistant
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/asiaostrich-tdd-assistant/badge)](https://www.skillsdirectory.com/skills/asiaostrich-tdd-assistant)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
source: ../../../../skills/tdd-assistant/SKILL.md
source_version: 1.0.0
translation_version: 1.1.0
last_synced: 2026-08-17
status: current
description: |
  [UDS] 测试驱动开发(TDD)的参考资料:红-绿-重构循环、FIRST 原则与 Arrange-Act-Assert 结构。
  Use when: 在实现前先写一个会失败的测试、用 Arrange-Act-Assert 组织测试、以 FIRST 检视既有测试。
  Not for: 交互式地驱动 RED/GREEN 循环——该部分已移至采用层(XSPEC-095);测量测试覆盖了多少代码——请用 /coverage。
  Keywords: TDD, test first, Red Green Refactor, FIRST, Arrange Act Assert, unit test, 测试驱动开发, 红绿重构, 单元测试.
---

# TDD 助手

> **语言**: [English](../../../../skills/tdd-assistant/SKILL.md) | 简体中文

引导测试驱动开发(TDD)流程:红-绿-重构。

## TDD 循环

```
    ┌─────┐       ┌───────┐       ┌──────────┐
    │ RED │ ────► │ GREEN │ ────► │ REFACTOR │
    └─────┘       └───────┘       └──────────┘
       ▲                                │
       └────────────────────────────────┘
```

## 工作流程

### 阶段 1:RED - 撰写失败测试
- 撰写描述期望行为的测试
- 执行测试 - 确认它因**正确的原因失败**
- 使用 AAA 模式(Arrange-Act-Assert)

### 阶段 2:GREEN - 让测试通过
- 撰写**最少的**代码使测试通过
- 此阶段可以接受硬编码
- 执行测试 - 确认它**通过**

### 阶段 3:REFACTOR - 改善代码
- 消除重复(DRY)
- 改善命名和结构
- **每次**修改后都执行测试
- 不新增功能

## FIRST 原则

| 原则 | 说明 | Description |
|------|------|-------------|
| **F**ast | 测试快速执行(< 100ms/单元) | Tests run quickly |
| **I**ndependent | 测试间无共享状态 | No shared state between tests |
| **R**epeatable | 每次结果相同 | Same result every time |
| **S**elf-validating | 明确的通过/失败结果 | Clear pass/fail result |
| **T**imely | 在产品代码之前撰写 | Written before production code |

## 使用方式

- `/tdd` - 开始互动式 TDD 工作阶段
- `/tdd calculateTotal` - 对特定函数进行 TDD
- `/tdd "user can login"` - 对用户故事进行 TDD

## 下一步引导

`/tdd` 完成后,AI 助手应建议:

> **TDD 循环完成。建议下一步:**
> - 执行 `/checkin` 通过品质关卡
> - 执行 `/coverage` 确认测试覆盖率
> - 执行 `/code-review` 自我审查代码

## 参考

- [TDD 语言範例](./language-examples.md) — 需要某个特定语言的实际范例时读它。
- [TDD 工作流程指南](./tdd-workflow.md) — 要完整跑一轮红-绿-重构时读它。
- 详细指南:[guide.md](./guide.md)
- 核心规范:[test-driven-development.md](../../../../core/test-driven-development.md)

Files in this skill

  • SKILL.md10.1 KB
  • language-examples.md12.5 KB
  • tdd-workflow.md20.6 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…