tdd

tdd is a skill for Claude Code, Codex from orlando-japan/claude-code-setting. It costs 32 tokens per session (604 once invoked), scanned A, original, MIT.

A test-driven development guide. Test-driven development, or TDD, means writing a small test first, making the code pass, and then improving the code without changing its behavior.

In plain words
What is it for?
Use it when fixing a bug, working on a clear input-and-output interface, or changing important code that has little test coverage.
Why use it?
It helps catch bugs while code is being written and makes changes safer by checking both new and existing behavior. It also explains when tests are useful and when they may slow exploration.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

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/orlando-japan/claude-code-setting/tdd
Any agent
npx skills add orlando-japan/claude-code-setting --skill tdd
Clone the repo
git clone --depth 1 https://github.com/orlando-japan/claude-code-setting

Made for: Claude Code, 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/orlando-japan/claude-code-setting/tdd.svg)](https://agentmods.dev/skills/orlando-japan/claude-code-setting/tdd)
Your own site
<a href="https://agentmods.dev/skills/orlando-japan/claude-code-setting/tdd"><img src="https://agentmods.dev/badge/skills/orlando-japan/claude-code-setting/tdd.svg" alt="Measured on agentmods" height="20"></a>
Per session 32 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 604 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.1 $0.00032 $0.00604
Opus 5 $0.00016 $0.00302
Sonnet 5 $0.00006 $0.00121
Haiku 4.5 $0.00003 $0.00060

Measured 5d ago against content hash 1a559d254b6d, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, 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 5d 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.

templates/extra/skills/tdd/SKILL.md · 76 lines

How it starts

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

Test-driven development

TDD isn't ideology — it's a tool. Use it where it earns its keep.

Use TDD when

  • The interface is clear (input → output), the algorithm is what's uncertain.
  • You're fixing a bug (write the failing test that reproduces, then fix).
  • You're touching load-bearing code without existing test coverage.

Don't use TDD when

  • The interface itself is exploratory — write a sketch first, then tests once the shape settles.
  • You're doing throwaway research / spikes.
  • The cost of testing exceeds the cost of rewriting (rare in practice, real in prototyping).

The cycle

Red:

  1. Write one test for the next smallest unverified behavior.
  2. Run it. It must fail, and fail for the expected reason ("function not defined" is fine; "typo in import" is not — fix the typo, re-run).

Green:

  1. Write the simplest code that makes this test pass. Not the cleanest, not the most general — the simplest.
  2. Run the test. Green.
  3. Run all the previous tests. Still green.

Refactor:

  1. Look at the code. Can you remove duplication without changing behavior?
  2. Refactor. Run the tests after every change, not at the end.
  3. If a refactor breaks tests, the refactor was wrong — revert.

Repeat.

Rules

  • One test at a time. No batching "let me write ten tests first."
  • One assertion per concept (not per line). A test for "login redirect" can assert location and that the cookie was set — they're one concept.
  • Tests name behaviors, not methods. 'redirects logged-out users to /login' beats 'test_login_handler'.
  • Delete failing-and-never-fixed tests. Don't .skip() and forget. Fix or cut.

Bug-fix TDD

Special case, highly recommended:

  1. Reproduce the bug with a test (red).
  2. Confirm the test fails for the bug's reason, not some other reason.
  3. Fix the bug.
  4. Test goes green.
  5. The test is now a regression test; keep it.

This produces bug fixes that can't silently regress.

When tests are hard to write

Hard-to-test code is usually telling you something:

Read the full file on GitHub · 76 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. 5d ago First seen · 76 lines · 32 tokens per session scan A 1a559d254b6d

Subscribe to this mod's changes

tdd is a skill published in the GitHub repository orlando-japan/claude-code-setting (2 stars, last pushed 3mo ago), licensed MIT. It adds 32 tokens to every session and 604 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.