tdd

tdd is a skill for Claude Code, Codex from huzaifa525/claude-code-optimizer. It costs 23 tokens per session (839 once invoked), scanned A, original, MIT.

A test-first coding workflow in which you write a failing automated test before writing the code that makes it pass. TDD means test-driven development.

In plain words
What is it for?
Writing tests before implementation, confirming they fail, adding the smallest passing change, and then cleaning up the code without changing its behavior.
Why use it?
It helps prevent untested behavior and keeps each change limited to what the test requires.

Skill for Claude CodeCodex

Part of the claude-code-optimizer plugin — 25 skills, 4 hooks shipped together

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

Made for: Claude Code, Codex.

Or install claude-code-optimizer, the plugin that ships this one along with the rest of its 25 skills, 4 hooks.

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/huzaifa525/claude-code-optimizer/tdd.svg)](https://agentmods.dev/skills/huzaifa525/claude-code-optimizer/tdd)
Your own site
<a href="https://agentmods.dev/skills/huzaifa525/claude-code-optimizer/tdd"><img src="https://agentmods.dev/badge/skills/huzaifa525/claude-code-optimizer/tdd.svg" alt="Measured on agentmods" height="20"></a>
Per session 23 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 839 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.00023 $0.00839
Opus 5 $0.00012 $0.00419
Sonnet 5 $0.00005 $0.00168
Haiku 4.5 $0.00002 $0.00084

Measured 3d ago against content hash f36c53fca0cf, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, 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 3d 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/.claude/skills/tdd/SKILL.md · 88 lines

How it starts

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

Implement $ARGUMENTS using strict TDD.

Iron Laws

1. No production code exists without a failing test. If you write code before a test, DELETE it. Not "keep as reference." Not "adapt it." DELETE it.

2. Write the MINIMUM code to pass the test. If the test passes, STOP writing code. More code = more bugs = more maintenance.

3. Delete means delete. If you wrote code before the test: don't keep it as reference, don't paste it somewhere, don't look at it. Delete it and write the test first. Your memory of the solution will make reimplementation fast.

Cycle

1. RED — Write a Failing Test

  • Find existing test files to match the naming pattern
  • Write ONE test that describes ONE specific behavior
  • Run it — confirm it FAILS
    [test command]
    
  • If it passes without new code, your test is wrong — it's testing something that already exists

2. GREEN — Write Minimum Code

  • Write the simplest possible code that makes the test pass
  • No extra features, no "while I'm here" additions, no premature optimization
  • Run the test — confirm it PASSES
    [test command]
    

3. REFACTOR — Clean Up

  • Improve code quality without changing behavior
  • Remove duplication, improve naming, simplify logic
  • Run ALL tests — confirm nothing broke
    [test command]
    

4. REPEAT

If the feature needs more behavior:

  • Go back to step 1 with the next test case
  • Continue until all requirements from $ARGUMENTS are covered
  • Each cycle should be small: one test, one behavior

Anti-Rationalization

Excuse Rebuttal
"I already know the implementation, writing a test first is wasteful" The test isn't just for verification — it's a specification. Write it.
"This is too simple to need TDD" Simple code is the EASIEST to TDD. No excuse to skip it.
"I'll write the tests after" Tests written after code are weaker — they test what you wrote, not what you should have written.
"The test framework isn't set up yet" Set it up. That's step 0, not a reason to skip testing.
"I wrote code first but I can just add a test now" Delete the code. Write the test. Watch it fail. THEN rewrite the code. This is the discipline.
"I need to see the implementation to know what to test" You need to see the REQUIREMENTS to know what to test. Read the spec, not the code.
"Refactoring isn't needed for this small change" Small changes accumulate. Refactor now while context is fresh.

Read the full file on GitHub · 88 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. 3d ago First seen · 88 lines · 23 tokens per session scan A f36c53fca0cf

Subscribe to this mod's changes

tdd is a skill published in the GitHub repository huzaifa525/claude-code-optimizer (9 stars, last pushed 5mo ago), licensed MIT. It adds 23 tokens to every session and 839 once invoked, about $0.0001 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.