
Write Tests
Write tests that pin real behavior instead of implementation details, config values, or...
Install
npx skills add dzhng/skills --skill write-tests -g -a claude-code -y- Repository
- dzhng/skills1.4k
- Category
- Testing
- Updated
- 3d ago
- License
- MIT
- Context cost
- Mediumabout 2,442 tokens
- Runs scripts
- No, instructions only
What it does
Write tests that pin real behavior instead of implementation details, config values, or lucky samples. Use when adding tests for new behavior, writing a regression test, fixing a brittle or flaky test, reviewing a test diff, or when a test breaks after a refactor or config change that didn't change behavior.
Write Tests
A good test fails only when real behavior breaks, and passes through every refactor or config change that preserves it. Most bad tests fail the opposite way: red on harmless changes, green while the real path is broken. Every rule below serves that one goal.
Default to end-to-end or system-level tests for regression coverage; use a unit test only for specific, complex business logic when fast feedback will materially speed development.
For deciding whether coverage adds independent proof, where it belongs, or which existing tests can go, use audit-tests.
Workflow: tracer bullets, not a batch
- Write ONE test at a time. Assert first, watch it go red on the un-fixed code, make the code earn green, learn, then write the next. Never a batch up front: a batch written against imagined behavior pins what you guessed, those tests pass when the mechanism breaks and fail when it's fine. Each green cycle tells you what the next test should actually assert.
- Iterate on the fastest focused runner (one file, one test name), and run the full suite only as a final gate before handing off. Check the exit code, not just the output, a runner that prints nothing and a green run look the same. On failures, read EVERY red test before fixing one; they often share a root cause.
- Before calling it done, prove the test can fail (below) and walk the review checklist.


