tdd
/tdd
[UDS] Reference for Test-Driven Development: the Red-Green-Refactor cycle, FIRST principles, and Arrange-Act-Assert structure. Use when: writing a failing test before implementation, structuring a test with Arrange-Act-Assert, checking tests against FIRST. Not for: driving the RED/GREEN cycle interactively — that moved to the adoption layer (XSPEC-095); measuring how much code the tests cover — use /coverage. Keywords: TDD, test first, Red Green Refactor, FIRST, Arrange Act Assert, unit test, 測試驅動開發, 紅綠重構, 單元測試.
- Author
- AsiaOstrich ↗
- Repository
- universal-dev-standards ↗
- Licence
- MIT
- Last repository change
- 27.10.2026
Assessment and security
- Files in this package
- 4
- Scripts
- 0
- HTML comments
- 1
- URLs in SKILL.md
- 0
No signals detected. Repository changed on 27.10.2026, without references to retired models or APIs.
MIT, open: use and modify while retaining author attribution.
- SKILL.md zawiera komentarze HTML (1). Nie widać ich w podglądzie Markdown, a model je czyta.
What it does and when to use it
[UDS] Reference for Test-Driven Development: the Red-Green-Refactor cycle, FIRST principles, and Arrange-Act-Assert structure. Use when: writing a failing test before implementation, structuring a test with Arrange-Act-Assert, checking tests against FIRST. Not for: driving the RED/GREEN cycle interactively — that moved to the adoption layer (XSPEC-095); measuring how much code the tests cover — use /coverage. Keywords: TDD, test first, Red Green Refactor, FIRST, Arrange Act Assert, unit test, 測試驅動開發, 紅綠重構, 單元測試.
Arguments
/tdd [feature or file | 功能或檔案]
Original author description
[UDS] Reference for Test-Driven Development: the Red-Green-Refactor cycle, FIRST principles, and Arrange-Act-Assert structure. Use when: writing a failing test before implementation, structuring a test with Arrange-Act-Assert, checking tests against FIRST. Not for: driving the RED/GREEN cycle interactively — that moved to the adoption layer (XSPEC-095); measuring how much code the tests cover — use /coverage. Keywords: TDD, test first, Red Green Refactor, FIRST, Arrange Act Assert, unit test, 測試驅動開發, 紅綠重構, 單元測試.
How it works
- TDD Cycle | TDD 循環
- Workflow | 工作流程
- FIRST Principles | FIRST 原則
- Usage | 使用方式
- Next Steps Guidance | 下一步引導
- Reference | 參考
- AI Agent Behavior | AI 代理行為
SKILL.md preview
---
name: tdd
scope: partial
description: |
[UDS] Reference for Test-Driven Development: the Red-Green-Refactor cycle, FIRST principles, and Arrange-Act-Assert structure.
Use when: writing a failing test before implementation, structuring a test with Arrange-Act-Assert, checking tests against FIRST.
Not for: driving the RED/GREEN cycle interactively — that moved to the adoption layer (XSPEC-095); measuring how much code the tests cover — use /coverage.
Keywords: TDD, test first, Red Green Refactor, FIRST, Arrange Act Assert, unit test, 測試驅動開發, 紅綠重構, 單元測試.
allowed-tools: Read, Write, Grep, Glob, Bash(npm test:*), Bash(npx vitest:*)
argument-hint: "[feature or file | 功能或檔案]"
status: reference
---
<!-- DEPRECATION NOTICE (XSPEC-086 Phase 4, 2026-04-28):
TDD flow orchestration (RED→GREEN→REFACTOR cycle, test execution gates) relocated to adoption
layer (XSPEC-095, 2026-04-28). This Skill retains: TDD principles, FIRST rules, AAA format,
language examples, workflow guide.
For enforced interactive cycle, use your adoption layer's toolchain.
-->
# TDD Assistant | TDD 助手
> ⚠️ **Status: Reference(參考用,非可執行流程)** — TDD 流程協調(RED→GREEN→REFACTOR 循環、測試執行 gates)已於 2026-04-28 移至 **adoption layer(XSPEC-095)**。此處保留 TDD 原則、FIRST 規則、AAA 格式、語言範例、流程指南供參考。
> Lifecycle orchestration has moved to the adoption layer (XSPEC-095); this document is **reference-only**. For enforced execution, use your adoption layer's toolchain.
Guide through the Test-Driven Development workflow: Red-Green-Refactor.
引導測試驅動開發(TDD)流程:紅-綠-重構。
## TDD Cycle | TDD 循環
```
┌─────┐ ┌───────┐ ┌──────────┐
│ RED │ ────► │ GREEN │ ────► │ REFACTOR │
└─────┘ └───────┘ └──────────┘
▲ │
└────────────────────────────────┘
```
## Workflow | 工作流程
> 📖 以下為流程的**參考結構**,非可執行步驟;自動化/強制執行請用 adoption layer 工具鏈(XSPEC-095)。
> The steps below are a **reference structure**, not an executable workflow.
### Phase 1: RED - Write Failing Test | 紅燈 - 撰寫失敗測試
- Write a test that describes the desired behavior | 撰寫描述預期行為的測試
- Run tests - confirm it **fails** for the right reason | 執行測試 - 確認正確地失敗
- Use AAA pattern (Arrange-Act-Assert) | 使用 AAA 模式
### Phase 2: GREEN - Make Test Pass | 綠燈 - 讓測試通過
- Write **minimum** code to pass the test | 撰寫最少的程式碼讓測試通過
- Hardcoding is acceptable at this stage | 此階段可以硬編碼
- Run tests - confirm it **passes** | 執行測試 - 確認通過
### Phase 3: REFACTOR - Improve Code | 重構 - 改善程式碼
- Remove duplication (DRY) | 移除重複
- Improve naming and structure | 改善命名與結構
- Run tests after **every** change | 每次變更後執行測試
- No new functionality added | 不新增功能
## FIRST Principles | FIRST 原則
| Principle | Description | 說明 |
|-----------|-------------|------|
| **F**ast | Tests run quickly (< 100ms/unit) | 快速執行 |
| **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 | 在產品程式碼之前撰寫 |
## Usage | 使用方式
- `/tdd` - Start interactive TDD session
- `/tdd calculateTotal` - TDD for specific function
- `/tdd "user can login"` - TDD for user story
## Next Steps Guidance | 下一步引導
After `/tdd` completes, the AI assistant should suggest:
> **TDD 循環完成。建議下一步 / TDD cycle complete. Suggested next steps:**
> - 執行 `/checkin` 通過品質關卡 ⭐ **Recommended / 推薦** — Pass quality gates
> - 執行 `/coverage` 確認測試覆蓋率 — Check test coverage
> - 執行 `/code-review` 自我審查程式碼 — Self-review code quality
## Reference | 參考
- [TDD Language Examples](./language-examples.md) — Read it when you need a concrete example in a specific language.
- [TDD Workflow Guide](./tdd-workflow.md) — Read it when running the red-green-refactor cycle end to end.
- Detailed guide: [guide.md](./guide.md)
- Core standard: [test-driven-development.md](../../core/test-driven-development.md)
## AI Agent Behavior | AI 代理行為
> 完整的 AI 行為定義請參閱對應的命令文件:[`/tdd`](../commands/tdd.md#ai-agent-behavior--ai-代理行為)
>
> For complete AI agent behavior definition, see the corresponding command file: [`/tdd`](../commands/tdd.md#ai-agent-behavior--ai-代理行為)
Files in this package (4)
- SKILL.md 5 KB
- guide.md 12 KB
- language-examples.md 27 KB
- tdd-workflow.md 26 KB
Versions
| Repository | Score | Licence |
|---|---|---|
| This page · AsiaOstrich/universal-dev-standards | 95 | MIT |
| kdlbs/kandev | 100 | AGPL-3.0 |
| sentimony/skills | 100 | MIT |
| sentimony/skills | 100 | MIT |
| TerminalSkills/skills | 100 | Apache-2.0 |
| duronext/jig | 100 | MIT |
| xoai/sage | 100 | MIT |
| rolemodel/skills | 100 | MIT |
| matteocodogno/wellforge | 100 | MIT |
Database snapshot: 13.11.2026 · package version dd586f9990f8 (SHA-256 digest of the entire package)
Downloads in the last 30 days: 2 · ranking
Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.
Similar skills
- 100tdd-assistant
[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… - 84tdd-assistant
[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… - 100rtk-tdd
Enforces TDD (Red-Green-Refactor) for Rust development. Auto-triggers on implementation, testing, refactoring, and bug fixing tasks. Provides Rust-idiomatic testing patterns with anyhow/thiserror, cfg(test), and Arrange-Act-Assert workflow. - 100test-driven-development
Use when implementing new features or logic that requires tests — before writing implementation code. Covers Red-Green-Refactor cycle, stack-specific test patterns, test naming conventions, and mocking. Triggers: "write tests first", "TDD", "test-driven", "failing test",… - 86unit-test
Writes isolated unit tests for a named file using Arrange-Act-Assert. Use when user requests unit tests, test coverage, or missing test cases for a file. - 100red-green-refactor
Guides the red-green-refactor TDD workflow: write a failing test first, implement the minimum code to make it pass, then refactor while keeping tests green. Use when a user asks to practice TDD, write tests first, follow red-green-refactor, do test-driven development, write…