/howtoai-builder:test-driven-developmentfrom How to AI — Builder
Drives implementation with test-first discipline: write a failing test, watch it fail for the right reason, pass it minimally, then refactor. Includes guidance on when test-first is a poor fit.
Ships in How to AI — Builder. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Write the test, watch it fail, make it pass with the least code that works, then clean up.
The tests are not the point — you can get those afterwards. The point is that a test you watched fail has proven it can fail. A test that has never been red proves nothing about the code it supposedly guards; it may be asserting on a mock, exercising a path that isn't reached, or passing for a reason unrelated to the behavior. Watching the failure is the only thing that rules that out, and it is the one step that cannot be recovered later.
Strong fit — reach for TDD without asking:
Poor fit — do the thing on the right instead:
| Situation | Better move |
|---|---|
| Exploratory spike; the shape is unknown | Explore freely, throw the spike away, rebuild it test-first |
| Visual/layout work — "does it look right" | Look at it. Test the logic behind the view, not the pixels |
| One-off script or migration you run once and delete | Dry-run it against a copy and check the result |
| Thin glue: wiring, config, passthrough with no branching | Test the first downstream behavior that depends on it |
Stop test-firsting when the test would only restate the implementation line by line. No behavior to pin down means no test worth keeping — write the code.
1. Red — write one failing test. One behavior. A name that states the behavior, not the function ("retries three times before giving up", not "testRetry"). Assert against real code; a mock is a last resort, not a default.
2. Verify red — run it and read the failure. Non-negotiable. The failure must be the absence of the behavior, not a typo, import error, or crash.
| What you see | What it means | Do |
|---|---|---|
| Passes immediately | You're testing behavior that already exists, or asserting nothing real | Make it assert the new behavior, or delete it |
| Errors instead of failing (import/syntax/nil crash) | Test harness problem, not a spec | Fix the test until it fails cleanly |
| Fails with a message you didn't predict | You don't understand the code yet | Investigate before implementing |
| Fails exactly as predicted | The test can catch this break | Proceed to green |
3. Green — the least code that passes. No options parameters you don't need, no generalizing to cases no test covers, no "while I'm in here" refactors of neighbouring code. Under-building is recoverable in one cycle; over-building ships untested branches immediately.
4. Verify green — run it, and run the rest. The new test passes, everything else still passes, and the output is clean. If a test fails now, fix the code, not the test — changing an assertion to match the output you got is how a suite stops meaning anything.
5. Refactor — only while green. Rename, deduplicate, extract. No new behavior. Re-run after each move; if you're not sure the suite still passes, you have already left the cycle.
Then the next behavior, next test. Cycles should be minutes, not hours — if red has been red for an hour, the test was too big.
Before writing the body, answer: what production change would make this test fail — and is that change a bug or a decision? If nothing realistic makes it fail, it's decoration. If only an intentional decision makes it fail (a constant's value, exact wording, private structure), it's a change detector: it fires on every refactor and sleeps through real bugs.
When you're writing mocks, fixtures, or test helpers — or the suite is green but
you don't trust it — read references/test-quality.md for the mocking rules, the
mutation check, and the warning-sign list.
A fix without a test that failed before it isn't finished. Order matters: reproduce as a test → watch it fail → fix → watch it pass. Skipping the red half means you never proved the test catches the bug, and the regression it exists to prevent will come back silently.
If a fix is already written when you notice this, verify it backwards: revert the fix, confirm the new test goes red, restore, confirm green.
The difficulty is information about the design, not about testing.
| Symptom | What it's telling you |
|---|---|
| Can't figure out how to test it | Write the call you wish existed, then build toward it |
| Setup is enormous | Too many collaborators — inject dependencies or split the unit |
| Have to mock everything | The unit is coupled to the world; push I/O to the edges |
| Test needs to reach into internals | The behavior has no public surface yet; give it one |
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
7 skills in this plugin
/code-reviewReviews someone's code, and handles feedback on yours — intent first, issues ranked by consequence, blocking vs non-blocking labeled. Use for "review this code", "review my PR", "look at this diff", or "how should I respond to this review comment"./debug-systematicallyFinds the root cause of a bug instead of patching symptoms — reproduce, hypothesize, bisect, explain the mechanism. Use for "debug this", "why is this failing", "this test is flaky", "works locally but not in prod", or "I can't figure out why"./git-worktreesRuns work in an isolated git worktree and closes the branch out cleanly. Use for "git worktree", "work on this in isolation", "finish this branch", "clean up my branch", "how do I merge this back", or removing a worktree without losing work.npx claudepluginhub rubenhassid1/howtoai-skills --plugin howtoai-builderOther plugins' skills for the same job