principle-tdd

principle-tdd is a skill for Claude Code from lugassawan/swe-workbench. It costs 82 tokens per session (1,038 once invoked), scanned A, original, MIT.

A guide to Test-Driven Development, a method where you write a failing test, add the smallest code that passes it, and then improve the design. It also covers arranging, acting, and checking test behavior.

In plain words
What is it for?
Use it when building a feature from tests, fixing a bug with a test first, choosing test doubles, or deciding how to structure a test-driven change.
Why use it?
It gives feature work a small, repeatable cycle and helps keep tests fast, isolated, and focused on expected behavior.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin.

Part of the swe-workbench plugin — 60 skills, 25 commands, 22 agents, 4 hooks shipped together

Good fit Use it when building a feature from tests, fixing a bug with a test first, choosing test doubles, or deciding how to structure a test-driven change.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/lugassawan/swe-workbench/principle-tdd
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 lugassawan/swe-workbench --skill principle-tdd
Clone the repo
git clone --depth 1 https://github.com/lugassawan/swe-workbench

Made for: Claude Code.

Or install swe-workbench, the plugin that ships this one along with the rest of its 60 skills, 25 commands, 22 agents, 4 hooks.

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 principle-tdd

README.md
[![agentmods](https://agentmods.dev/badge/skills/lugassawan/swe-workbench/principle-tdd.svg)](https://agentmods.dev/skills/lugassawan/swe-workbench/principle-tdd)
Your own site
<a href="https://agentmods.dev/skills/lugassawan/swe-workbench/principle-tdd"><img src="https://agentmods.dev/badge/skills/lugassawan/swe-workbench/principle-tdd.svg" alt="Measured on agentmods" height="20"></a>
Per session 82 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,038 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.00082 $0.01038
Opus 5 $0.00041 $0.00519
Sonnet 5 $0.00016 $0.00208
Haiku 4.5 $0.00008 $0.00104

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

Security

Grade A, and why

principle-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 4d 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/principle-tdd/SKILL.md · 83 lines

How it starts

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

Test-Driven Development

The loop

  1. Red — one failing test describing the next slice of behavior. Run it; confirm it fails for the right reason.
  2. Green — simplest production code that passes. Hard-coding is allowed — it will be driven out by the next test.
  3. Refactor — with all tests green, improve the code and the tests. Never refactor on red.

Each cycle is minutes, not hours.

Rule of three

Duplication triggers refactor on the third occurrence. Two is coincidence; three is pattern.

F.I.R.S.T.

  • Fast — milliseconds.
  • Isolated — independent of order and other tests.
  • Repeatable — deterministic anywhere.
  • Self-validating — automatic pass/fail.
  • Timely — written just before the production code.

What counts as "refactor"

Structural improvement with all tests green — no new behavior.

  • Rename, extract, move — anything that clarifies intent or repositions code to the layer that owns it.
  • Never add behavior during refactor — if a test turns red mid-refactor, revert the last step; the cycle was too large.
  • Tests are part of refactor too — clean up names, builders, and assertions when production code changes shape.

Test doubles — pick the cheapest that works

One double per behavioral boundary, not one double per collaborator.

  • Fake — working implementation (in-memory DB) — best for fast integration without real infrastructure.
  • Stub — canned response — isolates the path under test.
  • Spy — records calls for post-hoc assertion.
  • Mock — pre-programmed expectations; fails on unexpected calls — strictest, most brittle.

Use the cheapest double that still proves the behavior.

Mocking pain is design feedback

A mock that is hard to build signals a bad seam, not a bad mock.

  • Deep chains (a.b().c().d()) — the SUT reaches too far; introduce a collaborator interface at the inflection point.
  • Leaky internals — mocking private state means the test knows the implementation; test through the public API instead.
  • Time or network coupling — inject a Clock or HttpClient abstraction; never mock the system clock globally.
  • Growing setup — more than ~5 lines to configure a double signals too many responsibilities in the SUT.

Read the full file on GitHub · 83 lines

Files

What ships with it

1 file beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

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. 4d ago First seen · 83 lines · 82 tokens per session scan A e9939c3602ea

Subscribe to this mod's changes

principle-tdd is a skill published in the GitHub repository lugassawan/swe-workbench (2 stars, last pushed 2d ago), licensed MIT. It adds 82 tokens to every session and 1,038 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.