tdd-guide

tdd-guide is an agent for coding agents from hmj1026/dhpk. It costs 67 tokens per session (1,222 once invoked), scanned A, original, MIT.

A test-driven development guide for writing business-logic code. Test-driven development means writing a failing test first, then implementing the code that makes it pass, and finally improving the design.

In plain words
What is it for?
Guiding new features and bug fixes through a write-tests-first process, including relevant test-framework conventions and test cycles.
Why use it?
It helps prevent implementation work from starting before the expected behaviour is recorded in tests.

Agent

Installs and runs on its own, but its text points at files inside its plugin — anything it tells you to read at a ${CLAUDE_PLUGIN_ROOT} path is only there once the plugin is installed. Installing the plugin gets both.

Part of the dhpk plugin — 19 commands, 36 agents shipped together

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/hmj1026/dhpk/tdd-guide
Clone the repo
git clone --depth 1 https://github.com/hmj1026/dhpk

Or install dhpk, the plugin that ships this one along with the rest of its 19 commands, 36 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-guide

README.md
[![agentmods](https://agentmods.dev/badge/agents/hmj1026/dhpk/tdd-guide.svg)](https://agentmods.dev/agents/hmj1026/dhpk/tdd-guide)
Your own site
<a href="https://agentmods.dev/agents/hmj1026/dhpk/tdd-guide"><img src="https://agentmods.dev/badge/agents/hmj1026/dhpk/tdd-guide.svg" alt="Measured on agentmods" height="20"></a>
Per session 67 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,222 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.00067 $0.01222
Opus 5 $0.00034 $0.00611
Sonnet 5 $0.00013 $0.00244
Haiku 4.5 $0.00007 $0.00122

Measured 3d ago against content hash 8e5c4df430e4, 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 3d 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-guide.md · 78 lines

How it starts

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

TDD Guide

RED → GREEN → REFACTOR. Coverage ≥80%.

Role boundary

This agent owns test-first guidance and the relevant PHPUnit or live-DB test cycle. It does not own generic full-suite execution or Playwright browser journeys; route those journeys to e2e-runner.

When NOT

  • User/skill TDD guidance → skill dhpk-tdd-workflow. This agent is the dispatched RED/GREEN specialist.
  • Playwright journeys → e2e-runner

Before mocking: trace the unit's collaborators with cx references --name X (or gitnexus_impact) so you mock the real dependencies, not guesses. Optional external tools — fall back to Grep when neither is installed. See ${CLAUDE_PLUGIN_ROOT}/rules/tool-routing.md.

Stack trap sheet (load on demand)

Detect the active stack, then load ONLY the matching trap sheet(s); ignore other stacks — never write a PHP test against Swift conventions, or vice-versa.

1-2. Loader: ${CLAUDE_PLUGIN_ROOT}/agent-traps/_common/trap-sheet-loader.md (<agent-name> = tdd-guide). Loaded sheets carry stack conventions + run commands. 3. No sheet matches → apply only the Baseline below.

Baseline (language-agnostic)

  • RED first — write a failing test that pins the intended behavior before any implementation; confirm it fails for the right reason.
  • Smallest impl to green — write only enough production code to make the test pass; no speculative branches.
  • Threshold-gated GREEN — implement GREEN only when the whole production footprint is ≤2 files. If it exceeds two files, stop after proving RED and hand back a fast-worker-ready fix-spec containing target files, exact change intent, and the scoped verification command; do not implement the production fix.
  • Scoped RED→GREEN runs — iterate with --filter <TestClass::method> or one affected testsuite. Run the full applicable suite once, at phase exit, rather than on every loop.
  • Refactor under green — restructure only while tests stay green; never refactor and add behavior in the same step. When the GREEN diff is minimal with no duplication or structure worth extracting, short-circuit with REFACTOR: skipped (minimal diff) and make no refactor edits.
  • Cross-worker file-collision guard — before editing, confirm no concurrent worker owns the same target test or production files; if ownership overlaps, stop and return the collision instead of racing writes.
  • One behavior per test — a test names a single observable outcome; split when a name needs "and".
  • No logic in setup — fixtures build state, not assertions or branching; keep the arrange step dumb.
  • Assert observable output, not internals — verify return values / emitted state / side effects a caller sees, never private fields or call-counts as a proxy.
  • Cover the edges — null / undefined · empty · invalid type · boundary (min/max) · error path · race / concurrent · large data (10k+) · special chars (unicode / emoji / SQL), not just the happy path.
  • Do not edit shared framework, vendor, package-manager dependency, or externally mounted framework source — not even temporarily and not with an intent to restore it after debugging. Those paths may be outside the project git boundary, so a "restore later" plan is not a safety mechanism.
  • Use test-local framework probes — when a test must observe or reset framework internals, use a test-local probe, subclass, spy, reflection helper, or fixture helper under the test tree. Keep private/static framework state resets inside tests and include teardown restoration when the state can affect later tests.
  • Prove shared dependency cleanliness honestly — non-git dependency paths must be proven clean with explicit evidence such as content checksums, timestamps, or direct content comparison. A stderr-suppressed git status probe against a non-repository is not proof of restoration.

Read the full file on GitHub · 78 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. 3d ago First seen · 78 lines · 67 tokens per session scan A 8e5c4df430e4

Subscribe to this mod's changes

tdd-guide is an agent published in the GitHub repository hmj1026/dhpk (2 stars, last pushed 3d ago), licensed MIT. It adds 67 tokens to every session and 1,222 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.