tdd

Test-driven development, or TDD, is a way to build software by writing a test that fails first, writing the simplest code that passes it, and then cleaning up the code.

In plain words
What is it for?
Use it for a feature or bug fix to drive each behavior through the fail, pass, and cleanup cycle, then verify the individual test and full test suite.
Why use it?
It prevents production code from being written without a test and checks that each test would catch the intended break.

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/azrtydxb/procoder/tdd
Clone the repo
git clone --depth 1 https://github.com/azrtydxb/procoder
Per session 28 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 653 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.00028 $0.00653
Opus 5 $0.00014 $0.00327
Sonnet 5 $0.00006 $0.00131
Haiku 4.5 $0.00003 $0.00065

Measured 2d ago against content hash d3bfb787b4a6, 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 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.

.kilo/commands/tdd.md · 58 lines

What it actually says

The user invoked /procoder:tdd with arguments:

The command below is the procoder binary on PATH.

The iron law: no production code without a failing test first. Wrote code before the test? Delete it and start over — don't keep it "as reference". Violating the letter of this rule is violating its spirit. The arguments (if any) name the feature or fix to drive; apply the cycle to it.

The cycle, every behaviour:

  1. RED — write one minimal test for one behaviour, then RUN it and watch it fail. This step is mandatory evidence, not ceremony: a test that passes immediately is testing existing behaviour (fix the test); a test that errors isn't failing for the right reason (fix it until it fails on the assertion you meant).
  2. GREEN — the simplest code that passes. No options, no flags, no flexibility nobody asked for. Run the test (pass), run the suite (pass), output pristine — a new warning is a finding.
  3. REFACTOR — only on green, no new behaviour, suite green after.

Writing tests that earn their keep:

  • Name the break: before writing the body, answer "what production change makes this test fail — and is that change a bug?" No answer → redesign the test around observable behaviour. Asserting a constant equals itself, or that source text contains a line, catches decisions, not bugs.
  • Derive expectations independently: literal expected values, not values computed by the same code path being tested — mirror assertions always pass.
  • Test your code, not the framework: constructors, getters, and trivial forwarding earn tests only when they validate, normalise, default, or cause side effects.
  • Mocks: mock the slow or external edge, keep what the test actually depends on real; a mock mirrors the real data completely (a partial mock passes the test and fails the integration); mock setup outgrowing the test logic means you want an integration test.
  • The mutation check (before calling the work done): mentally break the production code — wrong constant, flipped branch, missing side effect, empty return, dropped validation. At least one test must fail for each realistic mutation; a mutation nothing catches marks that behaviour as unprotected.

Exceptions (throwaway spikes, generated code) exist — but ask the user first; "skip TDD just this once" arriving mid-task is rationalisation, not an exception. When stuck: hard to test = hard to use; a test needing heavy mocking is telling you the design is too coupled.

Evidence discipline: the RED command + failing output and the GREEN command + passing output go into the task's ## Evidence section — that is exactly what procoder todo close will ask you for.

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 · 58 lines · 28 tokens per session scan A d3bfb787b4a6

Subscribe to this mod's changes

tdd is a command published in the GitHub repository azrtydxb/procoder (196 stars, last pushed 2d ago), licensed Apache-2.0. It adds 28 tokens to every session and 653 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-30.