tdd-best-practices

tdd-best-practices is a skill for Claude Code, Codex from OKHP3/skillz. It costs 89 tokens per session (2,094 once invoked), scanned A, original, MIT.

A Test-Driven Development guide for building software by writing a failing test, making it pass with the smallest change, and then cleaning up the code. TDD is a method of using tests to define behavior before implementation.

In plain words
What is it for?
Use it when writing tests before code, organizing a test suite, or adding tests to a codebase where implementation came first.
Why use it?
It gives structure to test-first development and helps prevent tests from depending on private implementation details. It also covers testing common domain and data-boundary designs.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it when writing tests before code, organizing a test suite, or adding tests to a codebase where implementation came first.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/okhp3/skillz/tdd-best-practices
View source ↗ OKHP3/skillz
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.

Any agent
npx skills add OKHP3/skillz --skill tdd-best-practices
Clone the repo
git clone --depth 1 https://github.com/OKHP3/skillz

Made for: Claude Code, Codex.

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-best-practices

README.md
[![agentmods](https://agentmods.dev/badge/skills/okhp3/skillz/tdd-best-practices/github.svg)](https://agentmods.dev/skills/okhp3/skillz/tdd-best-practices)
Your own site
<a href="https://agentmods.dev/skills/okhp3/skillz/tdd-best-practices"><img src="https://agentmods.dev/badge/skills/okhp3/skillz/tdd-best-practices/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-best-practices

Your own site · 80×15
<a href="https://agentmods.dev/skills/okhp3/skillz/tdd-best-practices"><img src="https://agentmods.dev/badge/skills/okhp3/skillz/tdd-best-practices.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 89 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,094 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 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.1 $0.00089 $0.02094
Opus 5 $0.00044 $0.01047
Sonnet 5 $0.00018 $0.00419
Haiku 4.5 $0.00009 $0.00209

Measured 6d ago against content hash dc2804a69220, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-10, from the pricing page.

Security

Grade A, and why

tdd-best-practices 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 6d 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.

community/tdd-best-practices/SKILL.md · 133 lines

How it starts

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

TDD Best Practices

Use this skill when the main question is how to drive implementation from tests, how to structure a test suite, or how to recover discipline in a codebase where tests were written after the fact.

Working Style

  1. Write one failing test, then make it pass with the minimum code needed.
  2. Refactor only when all tests are green.
  3. Test behaviors, not implementations — the public API, not private methods.
  4. Keep tests as simple as the production code they verify.
  5. A test suite that is hard to change is as expensive as production code that is hard to change.

The Red-Green-Refactor Cycle

RED    → Write a failing test that describes the next behavior.
GREEN  → Write the minimum code to make it pass.
REFACTOR → Clean up both the code and the test — no new behavior.

The discipline is in the order. Never refactor on Red. On Green, add only the behavior demanded by the current failing test.

The 3 Laws (Uncle Bob)

  1. You may not write production code unless you have a failing unit test.
  2. You may not write more of a unit test than is sufficient to fail. An intentionally missing public API/type can be a valid first Red; unrelated compilation or setup failures are not.
  3. You may not write more production code than is sufficient to make the currently failing test pass.

Design Workflow

  1. Describe the behavior — what should the system do? Write the test name first.
  2. Write a failing test — make it fail for the right reason (assertion, not setup error).
  3. Make it pass — take the simplest path; you can clean up after.
  4. Refactor — remove duplication, improve names, reduce complexity.
  5. Repeat — the next test should be the smallest step forward.

Choosing Test Granularity

Level Tests Speed Confidence
Unit Single class/function in isolation Milliseconds Behavior of one unit
Integration Multiple real collaborators Seconds Module boundaries work
Acceptance / E2E Full system from user perspective Minutes Feature works end-to-end

Read the full file on GitHub · 133 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. 6d ago First seen · 133 lines · 89 tokens per session scan A dc2804a69220

Subscribe to this mod's changes

tdd-best-practices is a skill published in the GitHub repository OKHP3/skillz (3 stars, last pushed yesterday), licensed MIT. It adds 89 tokens to every session and 2,094 once invoked, about $0.0004 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-09-03.