test-driven-development

A guide for Test-Driven Development, or TDD: write a test that fails, add the smallest code that makes it pass, then improve the code. It applies this red-green-refactor cycle to features and bug fixes.

In plain words
What is it for?
Use it when implementing features or fixing bugs to write one failing test, verify the failure, implement the minimum solution, and refactor after the test passes.
Why use it?
It catches incorrect behaviour early and keeps each code change tied to a clearly described requirement.

Skill for Claude CodeCodex

Part of the pxp plugin — 3 skills 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 skills/infews/pxp_skill/test-driven-development
Any agent
npx skills add infews/pxp_skill --skill test-driven-development
Clone the repo
git clone --depth 1 https://github.com/infews/pxp_skill

Made for: Claude Code, Codex.

Or install pxp, the plugin that ships this one along with the rest of its 3 skills.

Per session 55 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 642 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.00055 $0.00642
Opus 5 $0.00028 $0.00321
Sonnet 5 $0.00011 $0.00128
Haiku 4.5 $0.00006 $0.00064

Measured 3d ago against content hash d18a297ff986, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

test-driven-development 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.

skills/test-driven-development/SKILL.md · 72 lines

How it starts

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

Test-Driven Development

A disciplined cycle for writing code one behavior at a time: red (failing test) → green (minimal code) → refactor.

The Iron Law

No production code without a failing test first. Not even one line. Not even "I'll just sketch this out." Not even "the test is obvious — I'll add it after."

The Cycle

1. Write the failing test

Write a single test for one behavior. The test should:

  • Describe what you want, not how it's done.
  • Fail in a meaningful way (assertion error — not syntax error, not missing import).
  • Be small — favor one method's behavior over a whole class.

2. Confirm red

Run the test. Confirm it fails for the expected reason.

  • Unexpected failure reason: diagnose first; don't paper over with implementation.
  • Passes without any implementation: the behavior already exists, or the test isn't testing what you think. Investigate.

3. Write the minimal implementation

Write the simplest code that makes the test pass. Resist the urge to add more.

  • No "while I'm here" additions.
  • No defensive code for cases not yet tested.
  • No abstractions for hypothetical future tests.

4. Confirm green

Run the test. Confirm it passes. Run the full suite to check for regressions.

5. Refactor

Look at the code you just wrote and the code around it:

  • Is there duplication to extract?
  • Are names clear and intention-revealing?
  • Is the code as simple as it can be while remaining clear?
  • Any code smells?

If you see an improvement, make it. Re-run tests. If nothing needs refactoring, say so out loud and move on.

Common Rationalizations

Excuse Reality
"Test is trivial, I'll skip it" Trivial tests catch real regressions later. Write it.
"I already manually tested it" Manual tests don't run in CI. Write the automated test.
"I'll write the test after" Tests-after asks "what does this do?" Tests-first asks "what should this do?" Different exercises.
"Refactor isn't needed here" Say so explicitly. Don't silently skip Step 5.
"I'll batch the refactor at the end" Refactor with context fresh, not after you've moved on.

Read the full file on GitHub · 72 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 · 72 lines · 55 tokens per session scan A d18a297ff986

Subscribe to this mod's changes

test-driven-development is a skill published in the GitHub repository infews/pxp_skill (20 stars, last pushed 2mo ago), licensed MIT. It adds 55 tokens to every session and 642 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-30.

Related

Other skills, from other repositories

agent-integration

Run all three agent integration phases sequentially: research, write-tests, and implement using E2E-first TDD (unit tests written last). For individual phases, use /agent-integration:research, /agent-integration:write-tests, or /agent-integration:implement. Use when the user says "integrate agent", "add agent…

entireio/cli · 89 tokens

engram-testing-coverage

TDD and coverage standards for Engram. Trigger: When implementing behavior changes in any package.

Gentleman-Programming/engram · 25 tokens

code-assist

Guides implementation of code tasks using test-driven development in an Explore, Plan, Code, Commit workflow. Acts as a Technical Implementation Partner and TDD Coach — following existing patterns, avoiding over-engineering, and producing idiomatic, modern code.

mikeyobrien/ralph-orchestrator · 53 tokens

tdd

Test-driven development. Use when the user wants to build features or fix bugs test-first, mentions "red-green-refactor", or wants integration tests.

GreyDGL/PentestGPT · 33 tokens

css-design-tdd

Test-driven CSS design system modifications. Run checks before/after CSS changes to verify token usage, variable definitions, fallbacks, and consistency. Use when modifying CSS tokens, fixing design inconsistencies, or auditing CSS architecture.

xiaolai/vmark · 49 tokens

mobiai-mobile-tdd

You MUST use this before writing any implementation code for a mobile feature, bug fix, refactor, or behavior change. Tests come before implementation — no exceptions.

ArisGuimera/MobiAI-Core · 38 tokens