tdd

tdd is a skill for Codex from asherzj/ashers-agent-skills. It costs 40 tokens per session (904 once invoked), scanned A, original, MIT.

A guide to test-driven development (TDD), a method where you write a test, make it pass with code, and then improve the code.

In plain words
What is it for?
Use it when building a feature or fixing a bug, especially when working in small red-green-refactor cycles or adding integration tests.
Why use it?
It helps keep tests focused on user-visible behavior instead of fragile implementation details or tests that merely repeat the code.

Skill for Codex

Written for Codex: agents/openai.yaml present.

Good fit Use it when building a feature or fixing a bug, especially when working in small red-green-refactor cycles or adding integration tests.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/asherzj/ashers-agent-skills/tdd
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.

Any agent
npx skills add asherzj/ashers-agent-skills --skill tdd
Clone the repo
git clone --depth 1 https://github.com/asherzj/ashers-agent-skills

Made for: Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for tdd

README.md
[![agentmods](https://agentmods.dev/badge/skills/asherzj/ashers-agent-skills/tdd/github.svg)](https://agentmods.dev/skills/asherzj/ashers-agent-skills/tdd)
Your own site
<a href="https://agentmods.dev/skills/asherzj/ashers-agent-skills/tdd"><img src="https://agentmods.dev/badge/skills/asherzj/ashers-agent-skills/tdd/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for tdd

Your own site · 80×15
<a href="https://agentmods.dev/skills/asherzj/ashers-agent-skills/tdd"><img src="https://agentmods.dev/badge/skills/asherzj/ashers-agent-skills/tdd.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 40 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 904 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
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.1 $0.00040 $0.00904
Opus 5 $0.00020 $0.00452
Sonnet 5 $0.00008 $0.00181
Haiku 4.5 $0.00004 $0.00090

Measured 9d ago against content hash 1d17b9495dd3, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-09, from the pricing page.

Security

Grade A, and why

tdd 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 9d 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.

coding/tdd/SKILL.md · 39 lines

What it actually says

测试驱动开发

TDD 就是红 → 绿循环。本 skill 是让这个循环产出值得保留的测试的参考手册:什么是好测试、测试放在哪里、反模式,以及循环的规则。每一节都适用于每个循环:在循环之前和进行中查阅它们,而不是事后。

探索代码库时,先阅读 CONTEXT.md(如果存在),让测试名称和接口(interface)词汇与项目的领域语言保持一致,并遵守你所改动区域内的 ADR(架构决策记录)。

什么是好测试

测试通过公共接口验证行为,而不是实现细节。代码可以彻底重写;测试不应随之改变。好测试读起来像一份规格说明:"user can checkout with valid cart" 准确告诉你存在什么能力,而且它在重构后依然成立,因为它不关心内部结构。

示例见 tests.md,mock 指南见 mocking.md

接缝(seam):测试放在哪里

接缝是你进行测试的公共边界:在不深入内部的情况下观察行为的接口。测试位于接缝处,绝不针对内部实现。

只在事先约定的接缝处测试。 在写任何测试之前,先写下被测接缝并与用户确认。任何测试都不写在未经确认的接缝上。你无法测试所有东西,所以事先约定接缝,才能让测试精力落在关键路径和复杂逻辑上,而不是每一个边缘情况。

问一句:"公共接口是什么?我们应该测试哪些接缝?"

当接口本身的形态尚存疑问时(模块有多深、接缝属于哪里、接口应该暴露什么),用 Skill 工具调用 "codebase-design" 获取相应词汇。它是模块(module)、接口(interface)、深度(depth)、接缝(seam)、适配器(adapter)、杠杆(leverage)、局部性(locality)这些术语的共享出处,是供查阅的参考,而不是要运行的会话。

反模式

  • 实现耦合:mock 内部协作者、测试私有方法,或通过旁路渠道验证(查询数据库而不是使用接口)。识别信号:重构后行为没变,测试却挂了。
  • 同义反复:断言用与代码相同的方式重新计算期望值(expect(add(a, b)).toBe(a + b)、用同样方式手工推导出的快照、断言常量等于自身),因此它构造上必然通过,永远无法与代码不一致。期望值必须来自独立的真相来源:已知正确的字面值、算好的例子、spec(规格说明)。
  • 水平切片:先写完所有测试,再写全部实现。批量测试验证的是想象出来的行为:你测试的是事物的形状而非面向用户的行为,测试对真实变化失去敏感,而且你在理解实现之前就敲定了测试结构。改用垂直切片(vertical slice):一个测试 → 一个实现 → 重复,每个测试都是一颗曳光弹(tracer bullet),回应上一个循环教给你的东西。

循环的规则

  • 先红后绿。 先写失败的测试,再只写刚好让它通过的代码。不要预判未来的测试或添加投机性功能。
  • 一次一个切片。 每个循环一个接缝、一个测试、一个最小实现。
  • 重构不属于循环。 它属于评审阶段(见 code-review skill),不属于红 → 绿的实现循环。
Files

What ships with it

3 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

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. 9d ago First seen · 39 lines · 40 tokens per session scan A 1d17b9495dd3

Subscribe to this mod's changes

tdd is a skill published in the GitHub repository asherzj/ashers-agent-skills (2 stars, last pushed 12d ago), licensed MIT. It adds 40 tokens to every session and 904 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-31.