write-tests
Skill4 starsChanged 17 days agoMITView on GitHub
Write tests worth having: choose what deserves coverage and what doesn't, decide when the test goes before the code, cover the painful case before the happy one, keep them deterministic and validate them in the negative. Use when tests have to be added to something that has none, when you add new behaviour, when you fix a bug and want it not to come back, when you are about to refactor something with no safety net, or when asked to raise coverage.
76 other projects use a version of this.
Adopted by
Most recently taken up by
- Doist/todoist-aitheir own version, first seen Nov 9, 2026
- CheckPickerUpper/skillstheir own version, first seen Nov 8, 2026
- Doist/todoist-clitheir own version, first seen Nov 8, 2026
- aniketshukla1/sdlc-kittheir own version, first seen Nov 8, 2026
- helmut-hoffer-von-ankershoffen/heinzeltheir own version, first seen Nov 8, 2026
- unlockers-ai/unlockers-skills-librarytheir own version, first seen Nov 8, 2026
Used with
Projects with it also use close-spec, design-with-images 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.
dzhngSkillclose-spec
When a spec under specs/<feature>/ is done shipping (a write-spec build, or any planned task that produced a spec), archive it to specs/done/ and rewrite it from a build-plan into a durable rationale — the why, the principles, the invariants — pointing back to the real code for the how. Use when implementation has landed and the plan no longer matches what shipped, or the user says a feature/spec is finished. Pairs with [write-spec](../write-spec/SKILL.md) (the plan this closes) and [review](../review/SKILL.md) (run before closing).
Also in 5 projects that use this
dzhngSkilldesign-with-images
Explore UI and visual design with image generation, then iterate the real implementation against the user-selected concept. Use when brainstorming visual directions, offering mockup variants, or implementing an approved generated design; do not stop at the mockups or the first code approximation.
Also in 5 projects that use this
transitive-bullshitSkillcompare-screenshots
Compare screenshots against the intended design, distinguishing approved references from historical baselines. Use for iterative implementation matching, before/after visual review, objective image telemetry, or checking a lone capture for flat, empty, or badly framed content.
Also in 5 projects that use this
LucasMatuszewskiSkillaudit-agents
Audit and maintain agent configuration files (.claude/agents, AGENTS.md, CLAUDE.md, agent-memory). Checks for duplicates, outdated info, naming conflicts, wrong technical facts, and files over 200 lines. Fixes all issues and commits.
Also in 5 projects that use this
wolverin0Skillaudit-decisions
Standardize remediation decisions, baseline-policy entries, and legal-review banners for accepted, deferred, or policy-blocked audit findings.
Also in 4 projects that use this
rhnfzlSkillexplore-unknowns
Walk the user through mapping the unknowns of a task before, during, and after they build it, and hand them a four-quadrant map (settled ground, open decisions, taste, and landmines) they keep. Reach for this eagerly whenever a request is ambiguous or underspecified, the codebase or domain is unfamiliar, the user will "know it when they see it", a reference implementation must be understood before porting, a build-queue or architecture-changing task is about to start, a mid-build deviation needs capturing, or a finished change needs buy-in or verified understanding before merge. Trigger even when the skill is not named: "do a blindspot pass", "find my unknown unknowns", "interview me about this change", "brainstorm the approach for a task I am about to build", "help me scope this", "what am I missing here", "plan this before I build", "I know nothing about X in this codebase". When a territory profile is present it reads memory and the graph first and feeds the map into the build pipeline; without one it degrades to a plain general map. Not for trivial or mechanical tasks with clear acceptance criteria, single-fact lookups, pure debugging of a known symptom, or pure code review, those have their own tools. Do not use it to run the build itself; the map is the deliverable and implementation remains a separate task, whether it has not started or is already underway.
Also in 5 projects that use this
- +5 more from dzhng
Other versions76 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 76
- remix-run/remix★ 33ksame name
- elie222/inbox-zero★ 13ksame name
- getsentry/sentry-javascript★ 8.8ksame name
- dzhng/jevgrep★ 3.2ksame name
- meta-pytorch/OpenEnv★ 2.8ksame name
- huggingface/OpenEnv★ 2.8ksame name
- JamieMason/syncpack★ 2.1ksame name
- dzhng/skills★ 1.5ksame name
- clice-io/clice★ 1.4ksame name
- ryokun6/ryos★ 1.3ksame name
66 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 repository46 other files it gives its agents.
- AGENTS.mdAGENTS.md
- add-repo-to-docsSkill
- adrSkill
- auth-bypass-localSkill
- before-afterSkill
- bug-huntSkill
- carry-envSkill
- code-healthSkill
- crux-doctorSkill
- crux-initSkill
- css-to-componentsSkill
- deploy-fallbackSkill
- deploy-watchSkill
- device-loopSkill
- drive-browserSkill
- e2eSkill
- end-sessionSkill
- eval-fixturesSkill
- explain-planSkill
- flowSkill
- grillSkill
- merge-conflictsSkill
- motion-videoSkill
- oauth-reauthorizeSkill
- prod-signalsSkill
- promote-to-docsSkill
- prose-checkSkill
- read-documentSkill
- render-loopSkill
- repo-mapSkill
- review-prSkill
- root-causeSkill
- runbookSkill
- security-auditSkill
- share-localSkill
- shipSkill
- skill-auditSkill
- skill-creatorSkill
- teachSkill
- ui-behaviourSkill
- ui-tellsSkill
- visual-diffSkill
- visual-testSkill
- wizardSkill
- workspaceSkill
- x-postsSkill
The file
We split this skill into the rules it gives an agent
8 rules. 0 are common, 8 are distinctive, and 0 are very specific to this project.
0
Common
Most of the 71 edited versions we read keep these.
8
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 56
If you are only going to write three tests, make them from here.
- Distinctive: line 78
After writing it: deliberately break what it tests, check that the test goes red for the right reason (not because of some other error), …
- Distinctive: line 89
Before building the scaffolding, try extracting the pure logic and testing that.
- Distinctive: line 105
Do they pass in random order and in parallel?
- Distinctive: line 106
Do they pass on a clean machine, without your cache or your database?
- Distinctive: line 111
Testing the implementation instead of the behaviour: If the test breaks on every refactor without anything observable changing, it is badly …
- Distinctive: line 113
One giant test that tests everything: When it fails you don't know what failed.
- Distinctive: line 117
Doubles that return whatever suits the test: If the double doesn't look like the real response, the test passes and production fails.
“Common” is measured: kept by at least 6 in 10 of the 71 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
write-tests
Writing tests is easy. Writing the ones worth having is not. The reason behind
when the test goes first: <this-skill-directory>/references/why.md.
The criterion: test what hurts if it fails
You don't test for coverage, you test for consequence. Before writing a test, ask what happens if that breaks in production and nobody notices.
| Deserves a test | Doesn't |
| Calculations with business rules | Getters, trivial mappings |
| Transformation of external data | A framework doing what it promises |
| Edge cases and boundary values | A constant having the value it has |
| Every bug that has already happened once | Private implementation details |
| Contracts between modules or services | Layout, unless it is measurable |
| Logic a refactor is going to move | Code that will be gone next week |
One test per real bug. It is the rule with the best return there is: the bug already proved that path breaks, so the probability of it coming back is not theoretical.
When the test goes first
Two cases, and only these two:
- A bug that can be reproduced. First the test that fails because of the bug, then the fix.
- Logic whose contract is known before the code: a calculation, a parser, a validation, a conversion between formats. You know what goes in and what has to come out, so write that down first.
It goes red for the reason you expect before writing the code: a red caused by an import or a typo proves nothing.
Everything else (exploring an approach, an interface still taking shape, glue code) is written first and tested afterwards, with the criterion above.
Start with the painful case
The happy path is usually covered incidentally by use. What nobody tests is the rest:
- Empty, null, zero, empty string, empty list.
- The maximum and the minimum, and one past each.
- Malformed input, in the wrong format, with accents, very long.
- Duplicates, reverse order, concurrency.
- The external service's error: timeout, 500, a response with a changed shape.
If you are only going to write three tests, make them from here.
A test has to be deterministic
A test that fails one time in twenty is worse than not having it: it teaches the team to retry without looking, and the day it fails for real nobody will believe it.
The four sources of nondeterminism, and what to do about them:
| Source | What to do |
| Time and dates | Inject the clock, never read it inside the logic |
| Randomness | Fixed seed, or inject the generator |
| Network and external services | Doubles with fixed responses; the fixture is the contract |
| Execution order and shared state | Each test creates and destroys its own |
Validate it in the negative
A test you have never seen fail is worthless. It is the most common mistake and the most expensive, because it produces false confidence.
After writing it: deliberately break what it tests, check that the test goes red for the right reason (not because of some other error), and revert. Thirty seconds that tell you whether the safety net exists. If it went red before the code, as in the test-first cases, this is already done.
What to do when it is hard to write
A test that is hard to write is almost never a problem with the test: it is the design giving a warning. If you need to simulate five dependencies to test one function, that function does five things.
Before building the scaffolding, try extracting the pure logic and testing that. The part that talks to the world stays thin and logic-free, and stops needing complicated tests.
Names
The test name is the first thing read when it fails in a log, months later. Make it state the condition and the expectation, not the function name:
- Bad:
test_calculate,it("works") - Good:
returns zero when the list is empty,rejects the date if the end is before the start
Before accepting a batch
- Does any fail if I deliberately break what they test?
- Do they pass in random order and in parallel?
- Do they pass on a clean machine, without your cache or your database?
- Is any so slow that people will start skipping them?
Anti-patterns
- Testing the implementation instead of the behaviour. If the test breaks on every refactor without anything observable changing, it is badly written.
- One giant test that tests everything. When it fails you don't know what failed.
- Too many assertions. Checking twenty fields just in case turns any legitimate change into a broken test.
- Doubles that return whatever suits the test. If the double doesn't look like the real response, the test passes and production fails.
- Writing tests to raise a number. Coverage is a signal, not a goal. You can have 90% and test nothing that matters.
Related
/ship: gates 1 and 5, which are these tests/root-cause: before writing the test for a bug, understand the bug/explain-plan: the plan's review focus says which failures no test covers
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.

