tdd

A test-first development workflow, commonly called TDD, where an automated test is written to fail before the implementation is added. The implementation is then made to pass the test and later cleaned up.

In plain words
What is it for?
Use it before implementing testable behavior, especially when fixing bugs or adding features. Follow the red, green, refactor cycle: failing test, smallest passing change, then cleanup.
Why use it?
It helps prevent code from being written without a clear, repeatable definition of correct behavior. The tests also preserve regression coverage, meaning they can detect when later changes break existing behavior.

Skill for Claude CodeCodex

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/chipfighter/coding-discipline/tdd
Any agent
npx skills add chipfighter/coding-discipline --skill tdd
Clone the repo
git clone --depth 1 https://github.com/chipfighter/coding-discipline

Made for: Claude Code, Codex.

Per session 85 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 828 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.00085 $0.00828
Opus 5 $0.00043 $0.00414
Sonnet 5 $0.00017 $0.00166
Haiku 4.5 $0.00009 $0.00083

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

plugins/coding-discipline/skills/tdd/SKILL.md · 40 lines

How it starts

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

Hard rule: write no implementation code without a test that failed first. Did you just write the implementation in this turn without delivering it? Remove it and restart from the test—do not keep it as a "reference" or look at it while adding tests. But never delete the user's existing code or someone else's workspace changes: when working with an existing implementation, add tests that record and protect its current behavior before making the smallest change.

Excuses to stop as soon as they appear

What you tell yourself Reality
"Write the implementation first and add tests later." Tests written afterward to match the implementation only prove that "the code does what it does," not that it is correct.
"Keep this as a reference; do not really remove it." The time is already spent; it is a sunk cost. If you keep it, you will shape the tests around it. Remove it (only if you wrote it this turn; never delete the user's existing code).
"It is too simple to be worth testing." "Simple" means an assumption you have not stated, which is exactly where failures happen.

Red → Green → Refactor

  1. Red: write the smallest failing test for one behavior. Give it a name that says what it tests, and test real code rather than mocks (use mocks only when unavoidable).
  2. Verify red (you must run it): watch it fail, specifically because the behavior is not implemented yet—not because of a typo, bad import, or syntax error.
    • It passes immediately = you are testing behavior that already exists. The test has no value; rewrite it.
    • The program errors instead of failing an assertion = fix the error and rerun until it "fails correctly."
  3. Green: write the minimum code needed to make it pass. Do not slip in features that are not needed yet or change anything else.
  4. Verify green (you must run it): the test passes, every other test still passes, and the output is clean (no errors or warnings). If it fails, change the code, not the test.
  5. Refactor: only after everything is green—remove duplication, improve names, extract functions. Keep the suite green throughout and add no new behavior.
  6. For the next behavior, return to red.

Read the full file on GitHub · 40 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. 2d ago First seen · 40 lines · 85 tokens per session scan A 61b6b0727f0f

Subscribe to this mod's changes

tdd is a skill published in the GitHub repository chipfighter/coding-discipline (6 stars, last pushed 1mo ago), licensed MIT. It adds 85 tokens to every session and 828 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-08-31.

Related

Other skills, from other repositories

rulesync

Generates and syncs AI rule configuration files (.cursorrules, CLAUDE.md, copilot-instructions.md) across 20+ coding tools from a single source. Use when syncing AI rules, running rulesync commands, importing or generating rule files, or managing shared AI coding configurations.

dyoshikawa/rulesync · 64 tokens

establishing-project-context

Use when the user asks to establish shared project language, or project work exposes a conflicting, renamed, or deprecated domain term that needs active semantic modeling. Routine small tasks stay on the fast path.

GanyuanRan/Aegis · 45 tokens

autoprompt

Explicit-only useful-first orchestration. Invoke /autoprompt to turn a mission into one executable roadmap, build dependency-safe lanes, and verify the result with independent reviewers. Never infer invocation from ordinary requests. Never resume from leftover artifacts without an explicit resume instruction.

Spielewoy/autoprompt-skill · 56 tokens

office-hours

YC Office Hours — two modes. Startup mode: six forcing questions that expose demand reality, status quo, desperate specificity, narrowest wedge, observation, and future-fit. Builder mode: design thinking brainstorming for side projects, hackathons, learning, and open source. Saves a design doc. Use when asked to…

GCWing/BitFun · 168 tokens

memstack-business-gdpr

Use this skill when the user says 'GDPR', 'data protection', 'privacy compliance', 'DPA', 'DSAR', 'data subject request', 'cookie consent', 'privacy audit', 'CCPA', or asks 'do I need GDPR for this repo'. Scans the repository to detect what personal data is collected, classifies sensitivity, determines whether GDPR…

cwinvestments/memstack · 121 tokens

echo

Use when the user references past sessions, asks 'what did we do', 'do you remember', 'last session', 'recall', or 'continue from'.

cwinvestments/memstack · 35 tokens