tdd
Skill2 starsChanged 22 days agoMITView on GitHub
Test-driven development: build or fix code one behaviour at a time in a red-green-refactor loop. Use when the user says 'test first', 'TDD', 'test-driven', 'red green refactor', 'write tests', 'build this with tests', 'add test coverage', 'make sure this is tested'. Writes and runs the tests, not a test plan.
194 other projects use a version of this, 30 of them edited.
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 · 30
- GreyDGL/PentestGPT★ 16k20% same
- sanity-io/sanity★ 6.4k21% same
- openstatusHQ/data-table-filters★ 2.3k21% same
- truffle-ai/dexto★ 65921% same
- amazingloft999-droid/mattpocock-skills★ 42220% same
- brianlovin/claude-config★ 37621% same
- ninehills/skills★ 28020% same
- InditexTech/weavejs★ 26620% same
- letehaha/moneymatter★ 22120% same
- heyongjun666/AICU-Graph★ 20020% same
20 more not listed
Wrote their own version · 164
- 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
- open-metadata/OpenMetadata★ 16ksame name
154 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 repository38 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- arenaSkill
- codebase-oracleSkill
- geppettoSkill
- lean-subagent-devSkill
- methodologySkill
- overnight-runSkill
- parallel-worktreesSkill
- dependency-security-auditSkill
- dependency-upgradeSkill
- rule-to-hookSkill
- safe-mergeSkill
- agent-friendly-auditSkill
- architectSkill
- brainstormSkill
- engineering-principlesSkill
- grill-meSkill
- improve-codebase-architectureSkill
- sharpenSkill
- to-issuesSkill
- to-prdSkill
- handoffSkill
- instructions-auditSkill
- project-setupSkill
- retrospectiveSkill
- session-closeSkill
- which-skillSkill
- bug-fixSkill
- ci-cost-and-cadenceSkill
- evaluatorSkill
- flaky-test-huntSkill
- hillclimbSkill
- launch-readinessSkill
- migration-reviewSkill
- mutation-testSkill
- review-triageSkill
- skill-evalSkill
- verify-appSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
17 rules. 0 are common, 17 are distinctive, and 0 are very specific to this project.
0
Common
Most of the 186 edited versions we read keep these.
17
Distinctive
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 30
RED: Write ONE test that describes the next behavior.
- Distinctive: line 31
GREEN: Write the minimum code to make that ONE test pass.
- Distinctive: line 40
Check for existing test patterns: Look at how other tests in the codebase are structured: file location, naming convention, test utilities, …
- Distinctive: line 54
Run all tests: Not just the new one, all of them.
- Distinctive: line 58
Refactor if needed: Only if the code smells. Both the test and the implementation are candidates.
- Distinctive: line 70
Private methods: If you need to test them, the module is probably the wrong shape.
- Distinctive: line 71
Implementation details: Call counts, internal state, execution order, unless those ARE the behavior (e.g., "this endpoint must be called …
- Distinctive: line 72
Framework behavior: Don't test that React renders components or that Express routes requests.
- Distinctive: line 76
Keep a test only when it passes both of these edits:
- Distinctive: line 89
One adapter = don't mock it: If there's only one implementation of an interface, you probably don't need a mock.
- Distinctive: line 91
Two adapters = real seam: If you have a real implementation AND a test double, the seam is earning its keep.
- Distinctive: line 93
Never mock what you own: If you control both sides of the interface, use the real code.
- Distinctive: line 112
Prefer no new test over a bad test: Do not add a test that:
- Distinctive: line 126
One slice at a time: Never write test 2 before test 1's implementation is green.
- Distinctive: line 127
Prefer no new test over a bad test: Keep a test only when it passes the two-edit check.
- Distinctive: line 129
Green bar before moving on: Never leave a failing test to "come back to later."
- Distinctive: line 130
Match the project's patterns: Use the same test framework, file structure, and utilities as the rest of the codebase.
“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
Test-Driven Development
Philosophy
Core principle: Tests should verify behavior through public interfaces, not implementation details. Code can change entirely; tests shouldn't.
Good tests are integration-style: they exercise real code paths through public APIs. They describe what the system does, not how it does it. A good test reads like a specification: "user can checkout with valid cart" tells you exactly what capability exists. These tests survive refactors because they don't care about internal structure.
Bad tests are coupled to implementation. They mock internal collaborators, test private methods, or peek at what no caller can see (a private field, an intermediate value, which helper did the work). The warning sign: your test breaks when you refactor, but behavior hasn't changed.
State a caller can read back is behavior, not implementation. When the promise is "saving an order stores it", reading the stored row back (through the interface, or straight from the database when that row is what other code reads) checks the promise. What makes a check bad is depending on what nobody outside the code relies on, not where the check looks.
See tests.md for examples and mocking.md for mocking guidelines.
Anti-Pattern: Horizontal Slices
DO NOT write all tests first, then all implementation. This is "horizontal slicing": treating RED as a batch phase and GREEN as a batch phase. It causes tests to verify imagined behavior rather than real behavior.
DO use vertical slices. Each slice is one RED-GREEN-REFACTOR cycle:
- RED: Write ONE test that describes the next behavior. Run it. Watch it fail. The failure message should be clear and specific.
- GREEN: Write the minimum code to make that ONE test pass. Nothing more. Don't anticipate future tests.
- REFACTOR: Clean up only if something smells. Both test and implementation are fair game. Run the test again to verify.
Then loop. Pick the next behavior, write the next test.
Before You Start
- Find the test runner. Check package.json scripts, Makefile, or equivalent. Run the existing tests to make sure they pass. If there are no tests and you are building a feature test first, set up the simplest possible test infrastructure (don't over-engineer it). For a small fix in a project with no test path, do not build one from scratch only to satisfy this workflow: prove the fix another way and say what evidence replaces the test (see "When no new test is better" below).
- Check for existing test patterns. Look at how other tests in the codebase are structured: file location, naming convention, test utilities, fixture patterns. Match them.
- Identify the public interface. What module, function, or endpoint are you testing? That's your test surface. Don't go deeper.
During Development
Each vertical slice follows this sequence:
Write the test FIRST. Name it after the behavior: "user can add item to empty cart", not "test addItem function". The test should use the public interface only.
Run it and watch it fail. If it passes immediately, either the behavior already exists (skip this slice) or the test isn't testing what you think. For a bug fix, commit the failing test on your branch before the fix, so anyone can replay red then green from the history.
Write the minimum implementation. Just enough to make the test pass. Hardcode if that's the minimum. The next test will force you to generalize.
Run all tests. Not just the new one, all of them. If an earlier test breaks, your implementation changed existing behavior. Fix it or reconsider.
Check the new test with the two edits (below) before you keep it.
Refactor if needed. Only if the code smells. Both the test and the implementation are candidates. Run tests after refactoring to verify nothing changed.
What to test
- Test behavior, not implementation. "When I do X, Y happens," not "function Z calls function W."
- Test edge cases through the same interface. Empty inputs, error conditions, boundary values: all through the public API.
- Test error paths. What happens when the input is invalid? When the dependency is unavailable? These are behaviors too.
- Take the expected value from the requirement, not from a run of the code. An expected value copied from the output of the code under test passes whether that output is right or wrong.
- Assert what callers rely on. An exact error message pins wording no caller reads; assert the error type or code callers branch on, unless the message itself is the promise (text shown to a user, for example).
What NOT to test
- Private methods. If you need to test them, the module is probably the wrong shape. Extract a new module with its own interface.
- Implementation details. Call counts, internal state, execution order, unless those ARE the behavior (e.g., "this endpoint must be called exactly once" is a real requirement).
- Framework behavior. Don't test that React renders components or that Express routes requests. Test YOUR code.
The two-edit check
Keep a test only when it passes both of these edits:
- Break the behavior. Make the code return a wrong value, skip an effect, or do it twice. The test must fail. If it still passes, it proves nothing: the usual causes are an assertion looser than the promise, an expected value computed by the code under test, or an assertion on data the test built itself.
- Change only the internals. Restructure the code underneath (rename a private helper, inline a variable, reorder independent steps) while every observable result stays the same. The test must still pass. If it fails, it is pinned to the implementation: it will need a rewrite on every refactor and still catches no bug.
Rewrite or delete a test that fails either edit. If the mutation-test skill is installed, run the first edit through its harness, and the second through its refactor mode; for a bug fix, the fix commit reversed is a ready-made first edit. The harness needs the test and the code committed first, changes one file per edit, and takes the file path relative to the repository root (run it, and any git show -R that feeds it, from the root; the test command runs there too). If it is not installed, or the edit spans several files, do both by hand: commit first, make the edit, run the test, look at the result, then restore with git checkout -- <file> and confirm git status is clean.
For the second edit, run all the tests that cover the code, not only the new one. Read any failure before blaming the test: a build error, a syntax error or a missing import means the refactor was wrong, not the test.
Mocking Guidelines
Mock at seams, not at internals. A seam is where your module meets an external system: a database, an HTTP API, a file system. Mock the external system, not internal collaborators.
One adapter = don't mock it. If there's only one implementation of an interface, you probably don't need a mock. Use the real thing.
Two adapters = real seam. If you have a real implementation AND a test double, the seam is earning its keep. The mock should be simple and dumb. Don't reimplement the real thing.
Never mock what you own. If you control both sides of the interface, use the real code. Mocking your own code creates tests that pass when the code is wrong.
Refactoring
Refactoring happens ONLY when tests are green. The rule: change structure, not behavior. If a test breaks during refactoring, either you changed behavior (undo and try again) or the test is pinned to the implementation (it fails the second edit of the two-edit check: rewrite it against the public interface).
Good refactoring targets:
- Duplicate code across the implementation
- Long functions that do multiple things
- Unclear names
- Deep nesting
Bad refactoring targets (during TDD):
- "I might need this later" abstractions
- Performance optimization (unless tests prove it's needed)
- Rewriting tests to match new implementation (if you need to, the test was testing implementation)
When no new test is better
Prefer no new test over a bad test. Do not add a test that:
- mostly tests mocks;
- encodes the current implementation details;
- depends on timing or on unrelated global state;
- needs expensive infrastructure (a broad harness, a slow end-to-end setup, production-only state) for a small fix;
- would be deleted right after proving the fix.
For a fix or a small change where a test like that is the only one on offer, prove the change with the closest executable check instead: a targeted script, a reproduction command, browser automation, a log assertion or a focused integration run. Show it failing before the change and passing after, and say in your report which check replaced the test and why there is no new test.
A feature built test first still starts every slice with a failing test. This rule decides which tests are worth keeping, not whether RED comes first.
Rules
- One slice at a time. Never write test 2 before test 1's implementation is green.
- Prefer no new test over a bad test. Keep a test only when it passes the two-edit check. A redundant or brittle test is a cost, not a safety net.
- Tests are documentation. A new developer should be able to read the test names and understand what the module does.
- Green bar before moving on. Never leave a failing test to "come back to later."
- Match the project's patterns. Use the same test framework, file structure, and utilities as the rest of the codebase.
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.

