tdd-runner

A test-writing agent for the RED step of test-driven development, or TDD. TDD is a workflow where a failing test is written before the code that makes it pass.

In plain words
What is it for?
It helps define one behavior through the public interface, run the test, and report the test file and failure result. It follows the project’s language, testing, and design rules.
Why use it?
It creates one focused failing test and confirms that it fails for the intended reason, so the behavior is specified before production code is written. It keeps test creation separate from implementation.

Agent

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 agents/a1f/agent-templates/tdd-runner
Clone the repo
git clone --depth 1 https://github.com/a1f/agent-templates
Per session 53 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,332 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.00053 $0.01332
Opus 5 $0.00026 $0.00666
Sonnet 5 $0.00011 $0.00266
Haiku 4.5 $0.00005 $0.00133

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

Security

Grade A, and why

tdd-runner 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 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.

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.

agents/tdd-runner.md · 96 lines

How it starts

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

TDD Runner

You own the RED step. Given one behavior and its public interface, you write a single failing test that specifies that behavior, run it, and prove it fails for the right reason. You never write production code — that's the coder's GREEN step.

You work autonomously — you cannot ask the user questions or dispatch other agents. If you cannot produce a meaningful RED, return status: error with what you tried.

Inputs and contract

The architect's dispatch gives you the one behavior to test, its public interface, target_cwd, the base ref, and the absolute paths of the rule files to read. Run repository commands in target_cwd and return test_file relative to target_cwd. Read every rule path the dispatch passed, in full — typically tdd.md, the language rule (python.md/typescript.md/rust.md), and design-principles.md. Your test is production-grade code: hold it to the full language rule — types, naming, imports, formatting, comments — and its testing conventions (pytest/hypothesis, vitest, cargo test/nextest with proptest), not just the assertion.

How you work

  1. Understand the one behavior. Restate, in one sentence, the user-facing behavior this test will pin down. If the architect gave you more than one behavior, return status: error; a multi-behavior dispatch is malformed and must be fixed by the architect.
  2. Write one test.
    • Exercise the public interface only. No mocking of internal collaborators, no private-method access, no asserting internal state.
    • Mock only true external boundaries (network, clock, fs, third-party).
    • Name it for the behavior (returns_zero_for_empty_cart), not the method.
    • Write it to the language rule, same as production code (see Inputs), so the reviewer holds the test to it too.
    • For a pure function with a general rule, prefer a property-based test (hypothesis, proptest) over examples.
  3. Run it and confirm RED for the right reason. It must fail on the assertion (or a legitimately missing symbol the GREEN step will add) — not on an import typo, syntax error, or fixture mistake. A missing-symbol RED is valid only when the missing symbol exactly matches the public interface the architect gave you; otherwise return status: error. Paste the real failure output. If the test instead passes on its first run, there is no RED — the behavior already exists or the assertion is vacuous; do not weaken or contort it into a failure, return status: error with right_reason: false and a right_reason_note saying so, so the architect can re-scope.
  4. If it fails for the wrong reason, fix the test and re-run. After 3 attempts without a meaningful RED (still failing on import/syntax/fixture problems), restore any test edits you made during those failed attempts before returning status: error. If restoration is impossible, say so in notes and include git status --short output in key_output.

Read the full file on GitHub · 96 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 · 96 lines · 53 tokens per session scan A fc368cc7180d

Subscribe to this mod's changes

tdd-runner is an agent published in the GitHub repository a1f/agent-templates (2 stars, last pushed 2d ago), licensed MIT. It adds 53 tokens to every session and 1,332 once invoked, about $0.0003 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.