tdd

A test-first development workflow built around the red-green-refactor loop: write a failing test, make it pass, then improve the code. TDD means Test-Driven Development.

In plain words
What is it for?
Building features, fixing bugs, writing integration tests, or working through test-first development.
Why use it?
It provides a repeatable way to define expected behavior before implementation and helps prevent regressions when code changes.

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/refo/claude-dev-helpers/tdd
Clone the repo
git clone --depth 1 https://github.com/refo/claude-dev-helpers
Per session 45 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,189 The whole file, excluding the scripts and references it only reads on demand.
Security scan B 1 finding. 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.00045 $0.01189
Opus 5 $0.00023 $0.00594
Sonnet 5 $0.00009 $0.00238
Haiku 4.5 $0.00005 $0.00119

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

Security

Grade B, and why

tdd scanned grade B with 1 finding 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.

Reads agent configuration directoriesmediumAgent snooping

.claude/, .codex/, .gemini/ hold keys, settings and other credentials a mod has no legitimate need for.

- Project helpers config (if present): !`cat .claude/helpers.json 2>/dev/null || echo "no helpers.json — infer test command from project files (package.json scripts, pyproject.toml, go.mod, Cargo.toml, Gemfile, etc.) and
plugins/dev-helpers/commands/tdd.md · 124 lines

How it starts

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

Test-Driven Development

Context

  • Project helpers config (if present): !cat .claude/helpers.json 2>/dev/null || echo "no helpers.json — infer test command from project files (package.json scripts, pyproject.toml, go.mod, Cargo.toml, Gemfile, etc.) and ask the user to confirm before running"

Tooling

Use the project's test command. In order of preference:

  1. commands.test from .claude/helpers.json
  2. The script named test in package.json / pyproject.toml / equivalent
  3. The conventional runner for the detected stack (e.g. pytest for Python, go test ./... for Go, cargo test for Rust, mix test for Elixir)

For watch mode, use commands.testWatch from helpers.json if present, otherwise the conventional watch invocation for the runner (e.g. --watch, pytest-watch, cargo watch -x test).

Test files should follow the conventions of the stack (*.test.ts, test_*.py, *_test.go, etc.) and be colocated with the code they test unless the project layout dictates otherwise.

Philosophy

Core principle: Tests should verify behavior through public interfaces, not implementation details. Code can change entirely; tests shouldn't.

Good tests are integration-style: they exercise real code paths through public APIs. They describe what the system does, not how it does it. A good test reads like a specification — "user can checkout with valid cart" tells you exactly what capability exists. These tests survive refactors because they don't care about internal structure.

Bad tests are coupled to implementation. They mock internal collaborators, test private methods, or verify through external means (like querying a database directly instead of using the interface). The warning sign: your test breaks when you refactor, but behavior hasn't changed. If you rename an internal function and tests fail, those tests were testing implementation, not behavior.

Anti-Pattern: Horizontal Slices

DO NOT write all tests first, then all implementation. This is "horizontal slicing" — treating RED as "write all tests" and GREEN as "write all code."

Read the full file on GitHub · 124 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 · 124 lines · 45 tokens per session scan B a71e0b7f2e64

Subscribe to this mod's changes

tdd is a command published in the GitHub repository refo/claude-dev-helpers (2 stars, last pushed 2mo ago), licensed MIT. It adds 45 tokens to every session and 1,189 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it B with 1 finding (reads agent configuration directories). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.