tdd-loop

tdd-loop is a command for Claude Code from MadeByTokens/bon-cop-bad-cop. It costs 9 tokens per session (5,339 once invoked), scanned A, a copy of tdd-loop, MIT.

A command that runs test-driven development, or TDD, as a repeated process with three agents. TDD means writing tests before or alongside the code and using them to check the implementation.

In plain words
What is it for?
Use it to work through a requirement with adversarial tests, implementation iterations, and saved progress logs.
Why use it?
It provides a recorded loop for testing requirements, writing code, and reviewing whether the tests catch incorrect behavior.

Command for Claude Code

Written for Claude Code: allowed-tools in frontmatter. Also seen: names the AskUserQuestion tool.

Part of the bon-cop-bad-cop plugin — 4 commands, 3 agents shipped together

Good fit Use it to work through a requirement with adversarial tests, implementation iterations, and saved progress logs.

Compare 6 commands from other repositories ↓
Install with agentmods
npx agentmods add commands/madebytokens/bon-cop-bad-cop/tdd-loop
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.

Clone the repo
git clone --depth 1 https://github.com/MadeByTokens/bon-cop-bad-cop

Made for: Claude Code.

Or install bon-cop-bad-cop, the plugin that ships this one along with the rest of its 4 commands, 3 agents.

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-loop

README.md
[![agentmods](https://agentmods.dev/badge/commands/madebytokens/bon-cop-bad-cop/tdd-loop/github.svg)](https://agentmods.dev/commands/madebytokens/bon-cop-bad-cop/tdd-loop)
Your own site
<a href="https://agentmods.dev/commands/madebytokens/bon-cop-bad-cop/tdd-loop"><img src="https://agentmods.dev/badge/commands/madebytokens/bon-cop-bad-cop/tdd-loop/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for tdd-loop

Your own site · 80×15
<a href="https://agentmods.dev/commands/madebytokens/bon-cop-bad-cop/tdd-loop"><img src="https://agentmods.dev/badge/commands/madebytokens/bon-cop-bad-cop/tdd-loop.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 9 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 5,339 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin 100% copy Near-identical to another mod 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.00009 $0.05339
Opus 5 $0.00005 $0.02669
Sonnet 5 $0.00002 $0.01068
Haiku 4.5 $0.00001 $0.00534

Measured 8d ago against content hash 432f6718e841, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-08, from the pricing page.

Security

Grade A, and why

tdd-loop 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 8d 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.

Origin

This is a copy

100% identical to tdd-loop — 0 lines differ, which has more behind it and is treated as the original. This page carries a canonical link to it rather than competing with it.

commands/tdd-loop.md · 556 lines

How it starts

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

/tdd-loop Command

When the user runs /tdd-loop "<requirement>" [options] or /tdd-loop --requirement-file <path> [options], follow these instructions:

Trail Log (REQUIRED) - Primary Record

The .tdd-loop.log file is the AUTHORITATIVE record of all loop activity.

This is critical for context management:

  • Agents write verbose output here, not to their responses
  • Full mutation survivor details go here, not in state file
  • Full feedback text goes here
  • Archived history entries go here when truncated from state
  • The state file and agent responses contain only summaries

Every significant action MUST be logged with timestamp. Use the Write tool to append entries.

Log format:

[YYYY-MM-DD HH:MM:SS] [PHASE] Message

What to log:

Event Log Entry
Plugin version [INIT] Bon Cop Bad Cop v{version}
Loop start [INIT] TDD loop started. Requirement: "<first 100 chars>..."
Language detected [INIT] Language detected: {language} ({testFramework})
State file created [INIT] State file created: .tdd-working/state.json
Phase start [ITER {n}] Starting phase: {WRITING_TESTS|WRITING_CODE|REVIEWING}
Agent invoked [ITER {n}] Invoking {agent} agent...
Agent completed [ITER {n}] {agent} completed. Files: {list}
Agent verbose output [ITER {n}] [{agent}] {detailed analysis, reasoning, progress}
Tests run [ITER {n}] Tests executed: {passed}/{total} passed
Flaky detected [ITER {n}] Flaky tests found: {list}
Cheating detected [ITER {n}] Cheating patterns found: {list}
Mutation score [ITER {n}] Mutation score: {score}% ({killed}/{total} mutants)
Mutation survivors [ITER {n}] Surviving mutants: {full list of survivors}
Verdict issued [ITER {n}] Verdict: {verdict}. Feedback: "{full feedback text}"
Iteration complete [ITER {n}] Iteration complete. Next phase: {phase}
History archived [HISTORY] Archived iteration {n}: verdict={v}, mutationScore={s}, survivors=[...]
Loop complete [COMPLETE] Loop finished: {reason}. Total iterations: {n}
Error [ERROR] {error description}

Read the full file on GitHub · 556 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. 8d ago First seen · 556 lines · 9 tokens per session scan A 432f6718e841

Subscribe to this mod's changes

tdd-loop is a command published in the GitHub repository MadeByTokens/bon-cop-bad-cop (1 stars, last pushed 7mo ago), licensed MIT. It adds 9 tokens to every session and 5,339 once invoked, about $0.0000 per session on Opus 5. A static security scan graded it A with 0 findings. It is 100% identical to tdd-loop, differing in 0 lines, and is treated as a copy.