tdd-workflow

A test-driven development workflow, or TDD, where tests are written before the code and guide the implementation. It covers unit tests for individual pieces, integration tests for connected parts, and end-to-end tests for complete user flows.

In plain words
What is it for?
Use it when building features, fixing bugs, refactoring code, adding API endpoints, or creating components that need tests across multiple levels.
Why use it?
It makes expected behavior and edge cases explicit while requiring verification of the resulting code, including a stated minimum of 80% test coverage.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/codelably/harmony-claude-code/tdd-workflow
Any agent
npx skills add codelably/harmony-claude-code --skill tdd-workflow
Clone the repo
git clone --depth 1 https://github.com/codelably/harmony-claude-code

Made for: Claude Code, Codex.

Per session 43 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,945 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00043 $0.02945
Opus 5 $0.00022 $0.01473
Sonnet 5 $0.00009 $0.00589
Haiku 4.5 $0.00004 $0.00295

Measured 2d ago against content hash 67b7874a9a54, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

tdd-workflow scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

docs/zh-TW/skills/tdd-workflow/SKILL.md · 410 lines

How it starts

The opening of the file, as written. The whole thing — 410 lines — stays where its author put it; the contents beside it link to each section on GitHub.

測試驅動開發工作流程

此技能確保所有程式碼開發遵循 TDD 原則,並具有完整的測試覆蓋率。

何時啟用

  • 撰寫新功能或功能性程式碼
  • 修復 Bug 或問題
  • 重構現有程式碼
  • 新增 API 端點
  • 建立新元件

核心原則

1. 測試先於程式碼

總是先寫測試,然後實作程式碼使測試通過。

2. 覆蓋率要求

  • 最低 80% 覆蓋率(單元 + 整合 + E2E)
  • 涵蓋所有邊界案例
  • 測試錯誤情境
  • 驗證邊界條件

3. 測試類型

單元測試
  • 個別函式和工具
  • 元件邏輯
  • 純函式
  • 輔助函式和工具
整合測試
  • API 端點
  • 資料庫操作
  • 服務互動
  • 外部 API 呼叫
E2E 測試(Playwright)
  • 關鍵使用者流程
  • 完整工作流程
  • 瀏覽器自動化
  • UI 互動

TDD 工作流程步驟

步驟 1:撰寫使用者旅程

身為 [角色],我想要 [動作],以便 [好處]

範例:
身為使用者,我想要語意搜尋市場,
以便即使沒有精確關鍵字也能找到相關市場。

步驟 2:產生測試案例

為每個使用者旅程建立完整的測試案例:

describe('Semantic Search', () => {
  it('returns relevant markets for query', async () => {
    // 測試實作
  })

  it('handles empty query gracefully', async () => {
    // 測試邊界案例
  })

  it('falls back to substring search when Redis unavailable', async () => {
    // 測試回退行為
  })

  it('sorts results by similarity score', async () => {
    // 測試排序邏輯
  })
})

步驟 3:執行測試(應該失敗)

npm test
# 測試應該失敗 - 我們還沒實作

步驟 4:實作程式碼

撰寫最少的程式碼使測試通過:

// 由測試引導的實作
export async function searchMarkets(query: string) {
  // 實作在此
}

步驟 5:再次執行測試

npm test
# 測試現在應該通過

步驟 6:重構

在保持測試通過的同時改善程式碼品質:

  • 移除重複
  • 改善命名
  • 優化效能
  • 增強可讀性

步驟 7:驗證覆蓋率

npm run test:coverage
# 驗證達到 80%+ 覆蓋率

測試模式

單元測試模式(Jest/Vitest)

import { render, screen, fireEvent } from '@testing-library/react'
import { Button } from './Button'

describe('Button Component', () => {
  it('renders with correct text', () => {
    render(<Button>Click me</Button>)
    expect(screen.getByText('Click me')).toBeInTheDocument()
  })

  it('calls onClick when clicked', () => {
    const handleClick = jest.fn()
    render(<Button onClick={handleClick}>Click</Button>)

    fireEvent.click(screen.getByRole('button'))

    expect(handleClick).toHaveBeenCalledTimes(1)
  })

  it('is disabled when disabled prop is true', () => {
    render(<Button disabled>Click</Button>)
    expect(screen.getByRole('button')).toBeDisabled()
  })
})

Read the full file on GitHub · 410 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 410 lines · 43 tokens per session scan A 67b7874a9a54

Subscribe to this mod's changes

tdd-workflow is a skill published in the GitHub repository codelably/harmony-claude-code (42 stars, last pushed 6mo ago), licensed MIT. It adds 43 tokens to every session and 2,945 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

systematic-debugging

Use when encountering any bug, test failure, or unexpected behavior, before proposing fixes.

obra/superpowers · 21 tokens

next-cache-components-adoption

Turn on Cache Components in a Next.js app and resolve the blocking routes it surfaces. Use when the user wants to enable, adopt, or migrate to Cache Components, flip the cacheComponents flag, work through a flood of blocking-prerender / instant validation errors, run the cache-components-instant-false codemod, or…

vercel/next.js · 95 tokens

babysit-pr

Babysit a GitHub pull request after creation by continuously polling review comments, CI checks/workflow runs, and mergeability state until the PR is merged/closed or user help is required. Diagnose failures, retry likely flaky failures up to 3 times, auto-fix/push branch-related issues when appropriate, and keep…

openai/codex · 114 tokens

imagegen

Generate or edit raster images when the task benefits from AI-created bitmap visuals such as photos, illustrations, textures, sprites, mockups, or transparent-background cutouts. Use when Codex should create a brand-new image, transform an existing image, or derive visual variants from references, and the output…

openai/codex · 113 tokens

cpu-profile-analysis

Analyze V8/Chrome CPU profiles (.cpuprofile) and DevTools trace files (Trace-.json). Use when: profiling performance, investigating slow functions, comparing code paths, finding bottlenecks, analyzing timeToRequest, understanding call trees from sampling profiler data, analyzing layout/paint/rendering, investigating…

microsoft/vscode · 71 tokens

next-cache-components-optimizer

Drive a Next.js route to instant navigation by setting up an agentic loop, under Cache Components / PPR, on initial load (hard navigation) and client-side navigation (soft navigation). Encode the goal as a failing @next/playwright instant() e2e and work it to green, one verified route at a time; the shipped test then…

vercel/next.js · 170 tokens