Skill

Test Writer

testingunit testsagentic

Save the file as ~/.claude/skills/test-writer/SKILL.md (user-level, available everywhere) or .claude/skills/test-writer/SKILL.md (project-level). Claude Code loads it automatically when its trigger condition matches.

Test Writer Skill: Golden Path, Edges, Real Failures

Most AI-generated tests are noise: ten cases that all assert the happy path, none of them catching the bug you'd actually ship. This skill flips that — it reads the function and its callers, then writes 3–6 tests covering the cases your code is actually going to fail on.

Full Prompt
An installable test-writer skill. Detects your framework, reads the function and its callers, then writes 3-6 targeted tests covering the golden path, empty inputs, nullable params, and the real failure paths.

What It Does

  • Detects the framework — Jest, Vitest, Pytest, Go test, whatever the repo already uses
  • Reads the callers first — types come from real call sites, not optimistic guesses
  • Covers the cases that bite — null, empty, zero, off-by-one, the real thrown error
  • Stops at 3–6 tests — focused is better than comprehensive when the next person has to read them

Install in 30 Seconds

Pick your tool above and download:

  • Claude Code: ~/.claude/skills/test-writer/SKILL.md
  • OpenAI Codex CLI: append to AGENTS.md
  • Cursor: append to .cursorrules

Then point it at a function: "Write tests for parseAmount in src/billing/parse.ts."

Why "3–6 Tests" Is the Right Number

A test suite of 30 cases with no failures is a maintenance tax that never pays back. A suite of 4 cases — golden path + the two empty inputs that break in production + the one boundary case the spec doesn't cover — runs fast, fails for real reasons, and gets read by the next person on call. This skill keeps you in that band.

Install once, ship tests that earn their place.