tdd

A Test-Driven Development (TDD) command that requires writing a failing test before implementation, then making it pass and improving the code. TDD follows a RED-GREEN-REFACTOR cycle: fail first, pass with minimal code, then clean up.

In plain words
What is it for?
Use it to develop features through documented test cycles. It creates a state file, records the expected failure, verifies the passing implementation, and checks that refactoring does not break the tests.
Why use it?
It prevents tests from merely describing code after it has been written and makes the expected behavior explicit before implementation starts.

Command

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 commands/drag88/claude-dev-framework/tdd
Clone the repo
git clone --depth 1 https://github.com/drag88/claude-dev-framework
Per session 15 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
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.00015 $0.00839
Opus 5 $0.00008 $0.00419
Sonnet 5 $0.00003 $0.00168
Haiku 4.5 $0.00002 $0.00084

Measured yesterday against content hash 97a3726c8ca3, 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 yesterday.

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.

commands/tdd.md · 134 lines

How it starts

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

/cdf:tdd — Test-Driven Development

The TDD invariant

Write the failing test before any implementation code. Verify the test fails for the expected reason. Then write the minimum code to pass it.

This invariant is enforced because TDD's value comes from the RED phase — if you skip it, you have tests-after-code, not TDD.

First actions (per feature)

  1. Create the TDD state file at dev/active/[feature-slug]/tdd-state.md:
---
feature: "[feature description]"
created: [ISO timestamp]
current_phase: red
cycle: 1
tests_written: 0
coverage_target: 80
---

# TDD: [Feature]

## Cycle 1
- [ ] RED: Write failing test
- [ ] RED: Verify test fails correctly
- [ ] GREEN: Write minimal implementation
- [ ] GREEN: Verify test passes
- [ ] REFACTOR: Improve code quality
- [ ] REFACTOR: Verify still green
  1. Write the test file first. Create a failing test before any implementation exists.

  2. Verify RED. Run the test and confirm it fails for the expected reason. Paste the failure output. Do not proceed to GREEN until the failure is documented.

Anti-patterns

  • Writing implementation before the test exists (no RED state to verify)
  • Writing a test that passes immediately (no failing baseline)
  • Skipping failure verification (the RED output is the contract)
  • Proceeding to GREEN without a documented RED phase
  • Refactoring without re-running the full test suite

Triggers

  • TDD workflow requests for new features or bug fixes
  • Test-first development methodology needs
  • Code quality improvement through testing discipline
  • Coverage gate enforcement requirements

Usage

/cdf:tdd [feature-description] [--coverage <percentage>] [--strict]

Arguments

  • feature-description: What you want to implement using TDD
  • --coverage <percentage>: Minimum coverage required (default: 80%)
  • --strict: Enforce strict TDD - fail if tests written after code

Cycle Iteration

After completing RED → GREEN → REFACTOR:

  1. Add next test case (edge cases, error conditions)
  2. Repeat the cycle
  3. Continue until feature is complete

Read the full file on GitHub · 134 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. yesterday First seen · 134 lines · 15 tokens per session scan A 97a3726c8ca3

Subscribe to this mod's changes

tdd is a command published in the GitHub repository drag88/claude-dev-framework (2 stars, last pushed 1mo ago), licensed MIT. It adds 15 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.