tdd
Skill9 starsChanged 5 months agoMITView on GitHub
Red-green-refactor cycle for /build full Phase 5. Internal skill — invoked by phases.md, not by the user. Governs HOW each test gets written, not WHICH tests to write (that's phase-plan.md).
193 other projects use a version of this.
Adopted by
Most recently taken up by
- mattpocock/skillstheir own version, first seen Oct 8, 2026
- rafaelob/pragmatic-agent-skillstheir own version, first seen Oct 5, 2026
- AlexisBalayre/claude-code-configtheir own version, first seen Oct 5, 2026
- KroxiDev/engineering-skillstheir own version, first seen Oct 5, 2026
- gaia-react/gaiatheir own version, first seen Oct 5, 2026
- uzairansaruzi/p3-stacktheir own version, first seen Oct 5, 2026
Used with
Projects with it also use make-bot-ui, Poteto Mode and 10 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
eryzerzSkillmake-bot-ui
Use when building a custom UI (page, dashboard, buttons) that should wake a Grok Bot over a webhook, when the user must provide a webhook sender key, or when exposing that UI on Tailscale.
Also in 8 projects that use this
jtarorehSkillPoteto Mode
poteto's agent style for concise, detailed responses, deliberate subagents, unslopped prose, simple code, and verified work. Use for poteto, /poteto-mode, or requests to work in this style.
Also in 5 projects that use this
risadamsSkillwhich-skill
Router over this pack's skills and flows. Ask it "which skill fits X" when you don't remember what's available.
Also in 7 projects that use this
TheOnlyFusionCubeSkillprinciple-attack-the-premise
Inventory who actually owns or exhibits the imbalance, then challenge the shared premise before writing another patch. Use when two or more fixes that share one premise have failed the same gate.
Also in 11 projects that use this
TheOnlyFusionCubeSkillprinciple-test-behavior-not-implementation
Call the system the way its consumer does and assert meaningful observable output; avoid mocks or assertions that only mirror internal calls. Use when when writing or evaluating tests.
Also in 11 projects that use this
shreyT19Skillprinciple-laziness-protocol
Apply when refactoring, evaluating diff size, or tempted to add abstractions, layers, or signal threading. Bias toward deletion and the smallest change that solves the problem.
Also in 22 projects that use this
Other versions193 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 193
- mattpocock/skills★ 335ksame name
- Yeachan-Heo/oh-my-claudecode★ 40ksame name
- open-metadata/OpenMetadata★ 15ksame name
- vinvcn/mattpocock-skills-zh-CN★ 4.6ksame name
- parcadei/Continuous-Claude-v3★ 3.9ksame name
- rohitg00/pro-workflow★ 2.9ksame name
- crbnos/carbon★ 2.7ksame name
- codeaholicguy/ai-devkit★ 1.6ksame name
- backnotprop/pstack★ 991same name
- kdlbs/kandev★ 899same name
183 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository15 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- vera-system/CLAUDE.mdCLAUDE.md
- buildSkill
- code-reviewSkill
- consultSkill
- curateSkill
- doc-syncSkill
- frameSkill
- gap-handlerSkill
- improveSkill
- panelSkill
- researchSkill
- scoutSkill
- start-vagueSkill
- wireframe-firstSkill
The file
We split this skill into the rules it gives an agent
11 rules. 0 are common, 9 are distinctive, and 2 are very specific to this project.
0
Common
Most of the 177 edited versions we read keep these.
9
Distinctive
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 31
Write the test file (or append to an existing one).
- Distinctive: line 32
Run the test. See it fail.
- Distinctive: line 37
Write the smallest possible implementation that makes the test pass.
- Distinctive: line 38
Run the test. See it pass.
- Distinctive: line 39
Run the rest of the suite.
- Distinctive: line 40
Tripwire: if green required more than ~10 lines, the test was probably too coarse.
- Distinctive: line 46
After each refactor edit, re-run the test.
- Distinctive: line 47
Tripwire: if a refactor turns the test red, you changed behavior, not structure.
- Very specific: line 59
EARS-compatible when the acceptance criterion is EARS: If the criterion in handoff.md ## Invariants is When <event>, the system shall …
- Distinctive: line 62
If a test would need to read multiple files, mock multiple services, or set up half the system — the unit is wrong.
- Distinctive: line 82
After every green, before the next red.
“Common” is measured: kept by at least 6 in 10 of the 177 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
TDD — Red-Green-Refactor
Phase 5 already prescribes test-first; this skill enforces the loop.
When this fires
/build full Phase 5 entry. The phase-plan.md test spec for the current phase is already written — it names WHICH behaviors to test. This skill governs how each one gets implemented.
Skip this skill for:
- V0 builds (
/build new) — validation is browser/command/validator-agent, not red-green-refactor. - Targeted Fix path of
/build full— no Phase 5, no test spec, fast change. - Phases 1-4 (PRD / Tech Design / Arch Review / Phase Plan) — no code written.
The cycle
For each behavior in the phase's test spec, complete one full RED → GREEN → REFACTOR loop before starting the next.
RED — Write the failing test
- Pick ONE behavior from the test spec. Not the easiest, not the hardest — the next in the spec's order.
- Write the test file (or append to an existing one). Test name reads as the expected outcome:
returns_normalized_path_when_given_relative_inputovertest_one. - Run the test. See it fail. Read the failure message.
- Tripwire: failure says "module not found," "no such function," or "import error" — you haven't actually tested the behavior, you've tested that code doesn't exist yet. Fix that: add the minimum scaffolding so the failure becomes an assertion failure (function exists, returns wrong thing). The first real RED is an assertion failure.
GREEN — Smallest code that passes
- Write the smallest possible implementation that makes the test pass. Hard-coded return values are allowed when only one case is tested.
- Run the test. See it pass.
- Run the rest of the suite. Confirm nothing else broke.
- Tripwire: if green required more than ~10 lines, the test was probably too coarse. Note this — the next test will refine, but flag it in the build-spec output so reviewers can see why.
REFACTOR — Improve structure on green
- Tests are green. Now improve the code without changing behavior.
- Rename misleading identifiers. Extract duplication. Simplify conditionals.
- After each refactor edit, re-run the test. Stay green.
- Tripwire: if a refactor turns the test red, you changed behavior, not structure. Revert and try again.
- Skip refactor only when the next test in the spec will obviously restructure this code (e.g., next test forces extraction into a function). Note "deferred to next cycle" in the build-spec.
Then return to RED with the next behavior.
What makes a good failing test
- One observable behavior per test. Not "the whole feature works" — one input → one expected output, or one event → one expected state change.
- Names the outcome, not the mechanism.
rejects_when_path_escapes_rootovertest_path_validation. - Fails for the right reason. Assertion failure on the value being tested. Not
ImportError, not syntax error, not test-runner config drift. - EARS-compatible when the acceptance criterion is EARS. If the criterion in
handoff.md ## InvariantsisWhen <event>, the system shall <response>, the test name and assertion mirror that:when_<event>_shall_<response>. EARS notation reference lives in.claude/skills/build/v0-stages.md. - Independent. Doesn't depend on test execution order. Setup and teardown are explicit.
If a test would need to read multiple files, mock multiple services, or set up half the system — the unit is wrong. Move it to integration tests or shrink the unit.
Smallest code that passes
The point of "smallest" is to force the next test to do the generalization work, not your imagination.
- One test covers one input → return that value hard-coded.
- Two tests cover two inputs → add an
if. - Three tests with the same shape → extract the pattern.
This is sometimes called "fake it 'til you make it" or "triangulation." Either is fine. What's not fine: writing the full generalized implementation when only one test exists. That's speculative abstraction — the next test might force a different shape and the abstraction wastes effort.
Exception: if the implementation is genuinely one line (return x + y), write it. Don't ceremoniously hard-code return 5 first when the real implementation is obvious and equally short.
When to refactor
After every green, before the next red. The green test is the safety net — refactor while it's there.
Refactor when:
- A name reads wrong on second look.
- Two blocks of code do the same thing.
- A function has grown past one screen.
- A conditional has more than two branches and the branches share structure.
Skip refactor when:
- The next test in the spec will obviously restructure this code anyway. Refactoring now means refactoring again in 5 minutes. Note "deferred" and move on.
- The structure is already clean. Don't refactor for the sake of it. Tripwire: "what specifically am I improving?" If you can't name it, skip.
Anti-patterns
| Anti-pattern | Fix |
| Writing all tests first, then all code | Waterfall in TDD clothing. One test, one implementation, one refactor — then the next test. |
| Testing implementation, not behavior | Tests asserting "function X called function Y" instead of "given input X, output is Y" couple tests to refactors and break on every cleanup. |
| Refactoring while red | The safety net is gone. Get to green first, then refactor. |
| Modifying tests after they pass to match what the code actually does | This is weakening tests. Covered by .claude/rules/test-integrity.md — don't do it, fix the code instead. |
| Skipping the "see it fail" step | If you didn't watch the test fail, you don't know it can fail. Run it once on no implementation. |
| Tests that pass without the implementation existing | The test isn't actually exercising the unit under test. Verify by deleting the implementation — the test must now fail. |
What this skill does NOT cover
- Test selection — which behaviors to test. That's
.claude/skills/build/templates/phase-plan.mdtest specs, written in Phase 4. - Test infrastructure setup — which runner, which assertion library, which fixtures pattern. That's Phase 2 Tech Design, decided per-project.
- EARS criteria writing —
while/when/shallnotation. Reference:.claude/skills/build/v0-stages.md§ handoff.md Invariants. - Integration tests across multiple components — TDD applies, but the cycle is slower and the "smallest code that passes" rule loosens. This skill is calibrated to unit tests. For integration, use the same loop but expect each red→green to take longer.
- Test integrity (don't weaken tests) —
.claude/rules/test-integrity.mdcovers this. Skill references, doesn't duplicate.
Author: Shareef Ellis · @shareefatwork
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

