tdd
Skill3 starsChanged 31 days agoMITView on GitHub
Red-green-refactor TDD loop for a single behavior. Writes a failing test first, runs it to confirm red, implements minimum code to make it green, then refactors with the test as a safety net. Use when user says "tdd", "test first", "red green refactor", "write the test first", or wants a disciplined test-first cycle. For bulk test backfill, use /test; for debugging existing failures, use /investigate; for planning a feature, use /plan.
194 other projects use a version of this.
Adopted by
Most recently taken up by
- ishandutta2007/Awesome-Claude-Skillstheir own version, first seen Nov 8, 2026
- trpc/trpctheir own version, first seen Nov 8, 2026
- wowyuarm/dsh-agent-teamtheir own version, first seen Nov 8, 2026
- Contexera/dsh-agent-teamtheir own version, first seen Nov 8, 2026
- Dimon94/dveritytheir own version, first seen Nov 8, 2026
- Dimon94/skillstheir own version, first seen Nov 8, 2026
Used with
Projects with it also use capture-learning-tools, design-frontend-dev 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.
The-Vibe-CompanySkillcapture-learning-tools
Turn technical conversations, bugs, CI failures, review comments,
Also in 5 projects that use this
The-Vibe-CompanySkilldesign-frontend-dev
Clean Impeccable frontend design skill. Use when the user wants to
Also in 5 projects that use this
tristanphvnSkillketchup-video
Catch the user up like /keel:ketchup, with a short silent video of slides for what happened and the waiting calls as text under it. Use for /keel:ketchup-video.
Also in 14 projects that use this
jaydubya818Skillfigure-it-out
Use when novel or multi-phase work needs an auditable workflow and no narrower playbook fits.
Also in 54 projects that use this
jaydubya818Skillprinciple-laziness-protocol
Apply when a refactor is adding wrappers or abstractions instead of simplifying.
Also in 45 projects that use this
- +2 more from The-Vibe-Company
- +5 more from jaydubya818
Other versions194 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 194
- mattpocock/skills★ 309ksame name
- trpc/trpc★ 41ksame name
- Yeachan-Heo/oh-my-claude-sisyphus★ 41ksame name
- Yeachan-Heo/oh-my-claudecode★ 41ksame name
- QuivrHQ/quivr★ 40ksame name
- The-Vibe-Company/quivr★ 40ksame name
- ccusage/ccusage★ 19ksame name
- ryoppippi/ccusage★ 19ksame name
- MODSetter/SurfSense★ 17ksame name
- GreyDGL/PentestGPT★ 16ksame name
184 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 repository42 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- asideSkill
- assessmentSkill
- auditSkill
- benchmarkSkill
- brainSkill
- checkpointSkill
- cleanupSkill
- concise-modeSkill
- cross-modelSkill
- deploySkill
- designSkill
- explainSkill
- fix-issueSkill
- ganSkill
- guardSkill
- hotfixSkill
- incidentSkill
- infraSkill
- interview-meSkill
- investigateSkill
- migrateSkill
- module-auditSkill
- morningSkill
- onboardSkill
- planSkill
- profileSkill
- pr-summarySkill
- readmeSkill
- refactorSkill
- researchSkill
- resolveSkill
- respondSkill
- retroSkill
- reviewSkill
- session-logSkill
- setupSkill
- shipSkill
- skill-newSkill
- spikeSkill
- testSkill
- zoom-outSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
20 rules. 0 are common, 16 are distinctive, and 4 are very specific to this project.
0
Common
Most of the 186 edited versions we read keep these.
16
Distinctive
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 30
Always work in vertical slices: one test, then the smallest implementation that turns the test green, then the next test.
- Very specific: line 48
When tests use domain terms (createCustomer, applyDiscount), pull the terms from the project glossary if one exists.
- Distinctive: line 67
If the function, the input, or the outcome is unclear, ask one question and stop.
- Distinctive: line 77
Add the test file if missing.
- Very specific: line 82
Use the most specific assertion available.
- Distinctive: line 85
Run the single test. Confirm it fails.
- Distinctive: line 95
Write the smallest change that makes the test pass.
- Distinctive: line 97
No new error handling beyond what the test asserts.
- Distinctive: line 102
Run the test. Confirm it passes.
- Distinctive: line 115
Run the full test file after every refactor change.
- Distinctive: line 136
Test must fail before production code is written.
- Distinctive: line 138
Never refactor while red. Get to green first.
- Very specific: line 139
Test what a user would notice broken, and never what the type system already proves.
- Distinctive: line 140
Use the project's real test infrastructure.
- Distinctive: line 145
Stop and reassess the test when it passes on its first run.
- Distinctive: line 146
Stop and fix the test setup when the red step fails on a compile or import error rather than an assertion.
- Very specific: line 147
Stop and split into separate /tdd runs when the behavior sentence needs "and" to describe two outcomes.
- Distinctive: line 148
Stop and revert to the minimum when the green diff adds error handling, an abstraction, or cleanup the test does not assert.
- Distinctive: line 149
Stop and ask one question when the function, the input, or the expected outcome is unclear.
- Distinctive: line 150
Stop the refactor and return to green when any test turns red mid-refactor.
“Common” is measured: kept by at least 6 in 10 of the 186 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
Overview
Red-green-refactor loop. One behavior at a time. The test must fail before any production code is written.
When to Use
- The user says "tdd", "test first", "red green refactor", or "write the test first".
- One behavior is small enough to state in a single sentence with a single observable outcome, such as
/tdd user.create rejects empty email. - A bug fix needs a reproduction test that fails before the fix lands.
For backfilling tests over existing code, use /test; for diagnosing a failure that already exists, use /investigate; for designing a feature before the first cycle, use /plan.
Anti-pattern: write-all-tests-then-all-code
Never write the full test suite first and then implement against it in one batch. That pattern produces tests that describe an imagined shape, not the actual behavior the code ends up needing. The tests pass on shape and fail on behavior; they fail on shape and pass on behavior. Either way they stop being a safety net.
Always work in vertical slices: one test, then the smallest implementation that turns the test green, then the next test.
flowchart LR
A[test 1 red] --> B[impl 1 green]
B --> C[test 2 red]
C --> D[impl 2 green]
D --> E[test 3 red]
E --> F[impl 3 green]Not this:
flowchart LR
A[test 1 red] --> B[test 2 red] --> C[test 3 red] --> D[impl 1+2+3 green]When tests use domain terms (createCustomer, applyDiscount), pull the terms from the project glossary if one exists. See rules/project-glossary.md.
Arguments
<description>: the behavior to implement, in plain English. Example:/tdd user.create rejects empty email.--no-refactor: skip the refactor step. Useful when the green code is already minimal.
Process
1. Clarify the behavior
State the behavior in one sentence. If it covers more than one assertion, split into multiple /tdd runs. One behavior, one test.
Identify:
- The function or class under test.
- The input that triggers the behavior.
- The expected observable outcome, return value, thrown error, side effect.
- The seams under test: the public boundaries where the test observes the behavior. Give each seam a one-line note on what it catches and what it misses, e.g. "HTTP handler: catches validation and serialization, misses the queue consumer".
If the function, the input, or the outcome is unclear, ask one question and stop. When an approved plan already names the seams, use them without asking; otherwise confirm the seam list with the user before writing the test.
2. Locate or create the test file
Match the project's test colocation pattern. Read 2 nearby tests to confirm:
- Naming convention,
*.test.ts,*_test.go,test_*.py. - Test runner imports.
- Setup and teardown style.
- Fake data approach. Apply the Test Data section of
standards/testing.md.
Add the test file if missing. Match the existing folder layout exactly.
3. Red: write the failing test
- Shape the body per the Test Structure section of
standards/testing.md: three blocks opened by the bare markersArrange,Act,Assertin the language's comment syntax, one blank line between them, exactly one call to the unit under test with its result bound to a name. The markers are the only comments; the test name states the behavior. An expected throw binds the pending call in Act and asserts on it. - Use the most specific assertion available. No
toBeTruthy. Apply the Assertion Specificity section ofstandards/testing.md. - Seed any fake data generator deterministically.
Run the single test. Confirm it fails.
| Failure type | What it means |
| Assertion failure | Expected. Proceed to step 4 |
| Compile or import error | Test setup is wrong. Fix before continuing |
| Test passes | The behavior already exists, or the test does not exercise it. Stop and reassess |
4. Green: minimum production code
Write the smallest change that makes the test pass. Resist the urge to add nearby features, generalize, or refactor at this step.
- No new error handling beyond what the test asserts.
- No new abstractions.
- No "while I'm here" cleanup.
- Stay surgical. See
rules/surgical-edits.md.
Run the test. Confirm it passes. Run the full test file to confirm no regressions on neighbors.
5. Refactor: improve with the test as safety net
Skip if --no-refactor was passed.
Refactor only on green. When any test is red, return to step 4 and make it pass before changing structure, because a refactor under a red test cannot tell a broken behavior from a broken refactor.
Look for:
- Duplication introduced in step 4.
- Names that no longer match the new behavior.
- Functions that grew past the file's typical size.
Run the full test file after every refactor change. The bar is zero failing tests, zero new warnings.
6. Verify gates
- Format, lint, typecheck, full test suite, build. Apply the Local Quality Gate section of
standards/git-workflow.md. - Coverage for the changed file at 100%. Apply the Coverage section of
standards/testing.md.
Report a one-line summary: behavior implemented, test name, files changed, coverage on changed file.
Anti-patterns
- Writing production code before the failing test. The whole point is the red step proves the test exercises the behavior.
- Writing a test that passes on the first run. The test is not measuring what you think.
- Writing a tautological assertion that recomputes the expected value the way the code does, such as
expect(add(a, b)).toBe(a + b). It passes by construction. Take the expected value from a known-good literal, a worked example, or the spec. Applystandards/testing.mdTautological Assertions. - Adding multiple assertions for unrelated behaviors in one test. Split into separate
/tddruns. - Skipping the refactor step on every cycle. The codebase decays without it.
- Mocking internal infrastructure to make the test cheap. Apply the Mocks Policy section of
standards/testing.md.
Rules
- One behavior per cycle. No exceptions.
- Test must fail before production code is written. No exceptions.
- The green step writes the minimum. Generalization belongs in refactor or in a later cycle.
- Never refactor while red. Get to green first.
- Test what a user would notice broken, and never what the type system already proves. Apply
standards/testing.mdWhat To Test. - Use the project's real test infrastructure. Never mock the database, queue, or your own services.
- Apply existing rules:
rules/testing.md,rules/surgical-edits.md,rules/git-workflow.md.
Red Flags
- Stop and reassess the test when it passes on its first run.
- Stop and fix the test setup when the red step fails on a compile or import error rather than an assertion.
- Stop and split into separate
/tddruns when the behavior sentence needs "and" to describe two outcomes. - Stop and revert to the minimum when the green diff adds error handling, an abstraction, or cleanup the test does not assert.
- Stop and ask one question when the function, the input, or the expected outcome is unclear.
- Stop the refactor and return to green when any test turns red mid-refactor.
Verification
- The red run output shows an assertion failure for the new test, captured before any production edit.
- The green run output shows the new test passing and the full test file passing.
- The test body has three blocks opened by the bare
Arrange,Act,Assertmarkers, separated by single blank lines, and no other comment. - Format, lint, type check, the full suite, and the build exit 0, with zero new warnings.
- Coverage on the changed file is 100%.
Related skills
/testfor running the suite, coverage, lint, scan./investigatefor debugging an existing failure rather than writing a new test./planfor designing a feature before any TDD cycle starts.
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.

