write-tests
Skill2 starsChanged 6 days agoMITView on GitHub
Author a quality test suite for EXISTING code — convention-matching, test plan confirmed before any writing, pins current behavior but flags suspicious-as-bug. Use on /write-tests or \"write / add tests for existing code\". Mode A — never auto-fires.
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 repository47 other files it gives its agents.
- AGENTS.mdAGENTS.md
- .github/copilot-instructions.mdCopilot instructions
- autonomizeSkill
- blueprintSkill
- brainstormSkill
- captureSkill
- checkpointSkill
- close-outSkill
- coordinateSkill
- cycleSkill
- deliverSkill
- design-proposalSkill
- discoverSkill
- dispatchSkill
- draft-planSkill
- envisionSkill
- executeSkill
- extract-conventionsSkill
- glossarySkill
- humanizeSkill
- human-viewSkill
- improve-promptSkill
- memory-auditSkill
- new-agentSkill
- new-agents-mdSkill
- new-hookSkill
- new-mcpSkill
- orchestrateSkill
- pr-authorSkill
- prepSkill
- pre-pushSkill
- pr-triageSkill
- recapSkill
- retrospect-coreSkill
- reviewSkill
- rulesSkill
- shortcutsSkill
- specSkill
- systematic-debuggingSkill
- test-driven-developmentSkill
- update-changelogSkill
- update-codemapSkill
- using-git-worktreesSkill
- visualise-codemapSkill
- visualSkill
- work-stateSkill
- wrapSkill
The file
We split this skill into the rules it gives an agent
3 rules. 0 are common, 3 are distinctive, and 0 are very specific to this project.
0
Common
Most of the 71 edited versions we read keep these.
3
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 90
When no language-pro agent exists for the language, the skill authors the tests itself to the same standard — delegation is an …
- Distinctive: line 96
After writing, optionally run the authored suite (ask, or run when the framework's test command is known and cheap).
- Distinctive: line 107
Never imply exhaustiveness.
“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
The test-authoring organ. Fills the hole between test-driven-development (the test-first workflow for new code) and the testability design rule (the code-side rule for making code testable): pointed at existing code, it authors a quality suite to a standard. It writes to universal/test-quality.md — the standard /review also audits against.
When to run
- User types
/write-tests <target>(or no arg → prompt for a target). - Natural language: "write tests for this", "add tests for
Invoice", "I need a test suite for the billing module". - Do not auto-fire. Mode A, user-invoked. Authoring tests is a deliberate act. No hook, no session trigger. (Distinct from
test-driven-development, which is the workflow you follow while writing new code — that one is invoked when you're about to build a feature; this one is pointed at code that already exists.)
Inputs
Target — a function, class, module, file, or directory. With no arg, prompt:
What should I write tests for? A function, class, file, or module.
- Working directory —
$CLAUDE_PROJECT_DIRorcwd. Anchors framework detection, the extracted test-convention lookup, and where tests are written. - Per-plan and per-flag confirmations — collected at the plan gate (§4) and on flagged-as-suspicious behaviors (§5). Collaborator principle — never author blind, never enshrine a suspected bug silently.
Procedure
1. Resolve the target
Resolve the target argument to concrete code: a file, a symbol within a file (grep for the declaration), a directory (each file), or a module. If ambiguous, list candidates and ask. If the target has no testable surface (a pure constant file, generated code), say so and stop rather than authoring vacuous tests.
2. Detect framework + conventions
Determine how this project tests, in this precedence:
- Extracted test conventions — if
<project>/.claude/rules/<lang>/conventions.mdexists and has a test-conventions section, use it. It is the project's own observed style; conform to it. - Existing tests — read the project's existing test files. Detect the framework (xUnit / NUnit / MSTest, Jest / vitest / mocha, pytest / unittest, cargo test, GoogleTest, …), the layout (where tests live, file naming), and the conventions (test naming pattern, fixture/setup style, assertion library).
Inference + confirm — when neither is present, infer the most idiomatic framework + conventions for the language and surface them explicitly:
No existing tests or extracted conventions found. I'd use
<framework>with <naming/layout convention> — confirm or correct before I plan?- Zero-tests repo — propose a framework + minimal setup (the dependency + a test directory + one example) as part of the confirm, so the user opts into the testing foundation deliberately.
Never infer silently — when detection falls to inference (step 3/4), the "I inferred these, confirm" note is mandatory.
3. Analyze the target → propose a confirmable test plan
Analyze the target for its testable surface: behaviors, inputs, output/effects, boundaries (empty / one / max / off-by-one edges), error paths, and branches. Then propose a test plan — the cases, each with a one-line rationale — for accept/edit/reject before any test is written (the propose-confirm-commit gate):
## Test plan for <target> (framework: <fw>, conventions: <source>)
Proposed cases:
1. <happy path> — <rationale: the nominal contract>
2. <boundary: empty input> — <rationale: edge the branch at L… guards>
3. <boundary: max / off-by-one> — <rationale>
4. <error path: invalid arg> — <rationale: the throw at L…>
5. <branch: the X==null path> — <rationale: uncovered branch>
Deliberately NOT covering:
- <thing> — <why: trivial getter / framework-guaranteed / out of scope>
Accept / edit (add, drop, or reword cases) / reject?The plan puts coverage depth in the user's hands per-target — consistent with the planning-depth rule's rejection of a fixed test-count ratio. Nothing is authored until the plan is accepted. Reject → nothing written.
4. Characterization-with-flags stance
For existing, untested code, the default stance is characterization-with-flags:
- Pin current behavior as the expected values — this is what makes the suite a safe-refactoring net: it captures what the code does now so a later change that alters behavior is caught.
BUT flag anything that looks like a bug for the user to confirm, rather than silently asserting it correct. When the current behavior is plausibly wrong (an off-by-one that happens to "work", a swallowed error, a boundary that returns the wrong edge), the plan marks it:
⚠
calculateRetryBudget(0)currently returns-1. That looks like a bug (a budget shouldn't be negative). Options: (p)in — assert-1as current behavior with a// FIXME: looks wrong, pinned to characterizenote (f)ix-first — stop; you fix the code, then I test the corrected behavior (e)xpected —-1is actually correct here (tell me why; I assert it plainly)
Never bake a suspected bug into a test as "expected" silently. Characterization pins behavior to enable refactoring; it does not bless behavior as correct. The flag is what keeps the suite from quietly enshrining a defect.
5. Author the tests (language-pro delegated)
On accept, the skill owns what to test, to what standard, the plan; the idiomatic how dispatches to the scope's language-pro agent (c-sharp-pro, cpp-pro, rust-pro, react-pro, …) where one exists.
Dispatch protocol — hard scope enforcement (worktree/allowlist, not prompt fences) and recursion caps (orchestrator-only spawning, max depth 2):
- Positive scope + hard placement, never a "do NOT" fence. The prompt carries: the accepted test plan (cases + expected values, including any pinned-with-FIXME flags), the detected framework + conventions, and the
test-quality.mdstandard. "Write xUnit tests for this C# class implementing exactly these cases with these expected values. Follow the project's convention: <…>. Standard: behavior-not-implementation, intention-revealing names, AAA, no interdependence. Output only the test file." - No further spawn — the language-pro agent is a leaf (recursion cap).
- Pass the plan, not a re-analysis mandate — the agent writes the agreed cases idiomatically; it does not redesign the coverage or re-judge the flags.
- When no language-pro agent exists for the language, the skill authors the tests itself to the same standard — delegation is an idiom-quality optimization, not a hard dependency.
The skill validates the returned tests implement the accepted plan (case-for-case, expected values intact, flags preserved as FIXME-pinned) before writing them.
6. Optional run + report (surface-not-auto-fix, coverage honesty)
After writing, optionally run the authored suite (ask, or run when the framework's test command is known and cheap). Report pass/fail. On a failure, surface the discrepancy — never auto-adjust the test to match the code:
Test
Withdraw_Overdraft_Throwsfailed: expectedInsufficientFundsException, got a-50balance (no throw). The test encodes the plan's intent; the code doesn't throw. Which is correct — should the code throw (code bug), or should the test expect the silent overdraft (my plan was wrong)?
This is the systematic-debugging posture: a failing test is a question about which side is right, not a prompt to paper over the test. Auto-changing the expected value to match observed output would defeat the entire purpose — it makes any code "pass."
Coverage honesty — an audit is complete only for the classes it enumerated, so list what was checked: the report ends by stating what was covered and what was deliberately not, with reasons:
Covered: happy path, empty-input boundary, the null-customer branch, the overdraft error path. Did NOT cover: the logging side-effect (framework-guaranteed), the private
normalizehelper (tested via its public callers), concurrent access (out of scope — flag if you want it).
Never imply exhaustiveness. "Tests pass" means the authored cases pass, not that the target is fully verified.
7. Stop
Do not invoke /review, do not commit. The authored tests are the user's to run in CI and commit. Do not auto-run /write-tests again. If authoring hit testability friction (couldn't test a behavior without reaching into internals), surface that as a testability signal in the code (a testability-design finding) rather than lowering the test standard to work around it.
What write-tests does NOT do
- Does not auto-fire. Mode A only.
- Does not author blind. The confirmable test plan (§3) gates every write.
- Does not enshrine suspected bugs. Characterization pins behavior to enable refactoring; suspicious behavior is flagged for confirmation, never silently asserted correct.
- Does not auto-adjust a failing test to match the code. A failure surfaces a code-vs-test question (§6). Auto-matching defeats the purpose.
- Does not claim exhaustiveness. Reports covered AND deliberately-not-covered.
- Does not re-judge coverage inside the language-pro agent. The agent writes the accepted plan idiomatically; it does not redesign it.
- Does not lower the standard to dodge testability friction. Surfaces the friction as a code-design signal instead.
- Does not replace
test-driven-development. That's the test-first workflow for new code; this authors tests for code that already exists.
Relationship to other organs
- test-driven-development — the sibling workflow: test-first for new code.
/write-testsis test-after, pointed at existing code. Both honor the sametest-quality.mdstandard; within an authored suite the order is one behavior per cycle — a test, then its implementation, before the next test. - testability design rule — the code-side pair.
test-quality.mdis the test side; testability is the code side. When authoring hits friction, surface a testability finding rather than working around it. - review — audits existing tests against
test-quality.md(the same standard this writes to)./write-testsauthors;/reviewaudits. - extract-conventions — supplies the project's extracted test conventions (framework, naming, layout) this conforms to where present.
- rule-prime-hook — primes
test-quality.mdunderwhen-writing-tests, so the standard is in context before the suite is written. - language-pro agents — own idiomatic test authoring (§5). Dispatched with positive scope + hard placement, no further spawn.
Debug
- Framework misdetected — point
/write-testsat the convention source explicitly, or add an extracted test-conventions entry. The "I inferred these, confirm" note is the catch-point. - Language-pro returned tests that drift from the plan — the skill re-authors to the accepted plan rather than writing drifted tests; flag a recurring drift via
/capture. - A flagged behavior keeps re-flagging — if the user said "expected, here's why", that reason belongs in the test as a comment and, if durable, in the extracted conventions or a
/capturenote so the next run doesn't re-flag it.
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.

