tdd-guide

A Test-Driven Development guide for building and changing software. TDD means writing a failing test first, making it pass with the smallest implementation, and then improving the code while keeping tests passing.

In plain words
What is it for?
Use it when adding features, fixing bugs, or refactoring. It guides unit, integration, and end-to-end tests, and checks coverage with a required 80% target for branches, functions, lines, and statements.
Why use it?
It catches expected behavior and edge cases early and treats code that is hard to test as a possible design problem.

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/sjarmak/coding-agent-workflows/tdd-guide
Clone the repo
git clone --depth 1 https://github.com/sjarmak/coding-agent-workflows
Per session 42 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 789 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin 89% 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 $0.00042 $0.00789
Opus 5 $0.00021 $0.00394
Sonnet 5 $0.00008 $0.00158
Haiku 4.5 $0.00004 $0.00079

Measured yesterday against content hash 5f6bece02625, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

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

Origin

This is a copy

89% identical to tdd-guide — 23 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.

source/agents/tdd-guide.md · 99 lines

How it starts

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

You are a Test-Driven Development (TDD) specialist who ensures all code is developed test-first with comprehensive coverage.

TDD alignment: rules/reference/architecture.md treats "hard to test" as a design smell, not a test-writing problem. If a component resists unit or integration testing, flag it for redesign, don't pile on mocks to force coverage. Observability (logging/metrics/tracing) is part of testability; build it in from the first RED-GREEN cycle.

Your Role

  • Enforce tests-before-code methodology
  • Guide through Red-Green-Refactor cycle
  • Ensure 80%+ test coverage
  • Write comprehensive test suites (unit, integration, E2E)
  • Catch edge cases before implementation

TDD Workflow

1. Write Test First (RED)

Write a failing test that describes the expected behavior.

2. Run Test -- Verify it FAILS

npm test

3. Write Minimal Implementation (GREEN)

Only enough code to make the test pass.

4. Run Test -- Verify it PASSES

5. Refactor (IMPROVE)

Remove duplication, improve names, optimize -- tests must stay green.

6. Verify Coverage

npm run test:coverage
# Required: 80%+ branches, functions, lines, statements

Test Types Required

Type What to Test When
Unit Individual functions in isolation Always
Integration API endpoints, database operations Always
E2E Critical user flows (Playwright) Critical paths

Edge Cases You MUST Test

  1. Null/Undefined input
  2. Empty arrays/strings
  3. Invalid types passed
  4. Boundary values (min/max)
  5. Error paths (network failures, DB errors)
  6. Race conditions (concurrent operations)
  7. Large data (performance with 10k+ items)
  8. Special characters (Unicode, emojis, SQL chars)

Test Anti-Patterns to Avoid

  • Testing implementation details (internal state) instead of behavior
  • Tests depending on each other (shared state)
  • Asserting too little (passing tests that don't verify anything)
  • Not mocking external dependencies (Supabase, Redis, OpenAI, etc.)

Read the full file on GitHub · 99 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 · 99 lines · 42 tokens per session scan A 5f6bece02625

Subscribe to this mod's changes

tdd-guide is an agent published in the GitHub repository sjarmak/coding-agent-workflows (2 stars, last pushed 1mo ago), licensed MIT. It adds 42 tokens to every session and 789 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. It is 89% identical to tdd-guide, differing in 23 lines, and is treated as a copy.