write-tests

write-tests is a skill for Claude Code, Codex from dzhng/skills. It costs 63 tokens per session (2,259 once invoked), scanned A, original, MIT.

A guide for writing tests that check what software does from the user's or caller's point of view, rather than checking internal implementation details. It recommends writing and proving one test at a time.

In plain words
What is it for?
Use it when adding tests, fixing behavior, reviewing test changes, or updating tests after a refactor. It helps choose meaningful assertions, verify that a test can catch a regression, and run the full suite as a final check.
Why use it?
It reduces brittle tests that fail after harmless refactoring or pass while the real behavior is broken. Focused runs and checking exit codes also make failures easier to interpret.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it when adding tests, fixing behavior, reviewing test changes, or updating tests after a refactor. It helps choose meaningful assertions, verify that a test can catch a regression, and run the full suite as a final check.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/dzhng/skills/write-tests
View source ↗ dzhng/skills
About the project

dzhng/skills is a collection of reusable instructions that guide AI coding agents through software work. Agents use the skills to explore ideas, write specifications, implement and review code, and conduct autonomous research; the catalogue lists 30 of these skills.

dzhng/skills · 1,372 stars · on GitHub

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add dzhng/skills --skill write-tests
Clone the repo
git clone --depth 1 https://github.com/dzhng/skills

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for write-tests

README.md
[![agentmods](https://agentmods.dev/badge/skills/dzhng/skills/write-tests/github.svg)](https://agentmods.dev/skills/dzhng/skills/write-tests)
Your own site
<a href="https://agentmods.dev/skills/dzhng/skills/write-tests"><img src="https://agentmods.dev/badge/skills/dzhng/skills/write-tests/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for write-tests

Your own site · 80×15
<a href="https://agentmods.dev/skills/dzhng/skills/write-tests"><img src="https://agentmods.dev/badge/skills/dzhng/skills/write-tests.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 63 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,259 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00063 $0.02259
Opus 5.5 $0.00025 $0.00904
Sonnet 5.5 $0.00013 $0.00452
Haiku 4.5 $0.00006 $0.00226

Measured 4d ago against content hash 8b01e20e0f46, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

write-tests scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 4d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

Origin

Copies of this mod

1 near-identical copy found in the catalogue:

skills/engineering/write-tests/SKILL.md · 172 lines

How it starts

The opening of the file, as written. The whole thing — 172 lines — stays where its author put it; the contents beside it link to each section on GitHub.

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.

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

  1. 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.
  2. 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.
  3. Before calling it done, prove the test can fail (below) and walk the review checklist.

What to assert

  • Observable behavior through the outermost practical entry point — return values, exit codes, persisted rows, HTTP responses, rendered output — never which internal functions ran or how a value is computed. A test on the public surface survives a rewrite of everything underneath; a test that reaches into internals breaks on every refactor and pins implementation, not behavior. Reserve isolated unit tests for genuinely tricky pure logic (parsers, schedulers, state machines).
  • Nothing the compiler already guarantees. A test that re-asserts a type signature — field shapes, rejected argument types — can only fail if the compiler failed first. Spend the budget on business rules, arithmetic, branching, ordering, edge cases, side effects.
  • Actual values, not collection sizes. For dedup/normalize/idempotency paths, length == 1 passes even when normalization is broken; also assert the stored value equals the expected canonical form.
  • The smallest scale that can show the behavior. Two entities and one mechanism before crowds and integration; small tests fail fast with readable state and don't entangle five behaviors in one assert.
  • The design contract, not current behavior. When a test goes red, the reflex is to re-measure and pin the new number — resist it: a bar calibrated to whatever the code currently does silently encodes bugs as baseline. Write the assert from the stated contract and make the code earn it; if no contract exists, that's a question for the owner, not a number to measure-and-pin. Recalibrating is legitimate only when the contract itself changed.
  • Deterministic claims tight, stochastic claims as distributions. An invariant that holds every run gets an exact threshold. Anything noisy or tuning-dependent ("A usually beats B", "load balances evenly") must be asserted over a set of runs/seeds as a band — a single-sample pin on a stochastic outcome is not a weak test, it is a blind one: it certifies whatever the lucky sample did and can mask a systematic bias for months. If you must assert a noisy differential, widen the margin and name it chaos-marginal in a comment.

Read the full file on GitHub · 172 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 4d ago Changed · +8 lines 8b01e20e0f46
  2. 20d ago Changed · +3 lines 40fae6ef816f
  3. 1mo ago Changed · +27 lines cd22479072ca
  4. 1mo ago First seen · 134 lines · 63 tokens per session scan A 8c19362fbb8a

Subscribe to this mod's changes

write-tests is a skill published in the GitHub repository dzhng/skills (1,372 stars, last pushed yesterday), licensed MIT. It adds 63 tokens to every session and 2,259 once invoked, about $0.0003 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

codex-autoresearch

Triage improvement work and run or resume accepted measured loops in a local project. Architecture, documentation, UX, product study, open research, taste, and one-shot fixes stay direct unless the user explicitly requests repeated measurement with a complete experiment contract.

TheGreenCedar/codex-autoresearch · 55 tokens

arbor-agent-merge-eval

Merge and evaluation discipline for Arbor. Use for TreeSetMeta metadata, Bdev/Btest separation, eval command templates, score parsing, GitMergeBranch behavior, protected paths, required outputs, metricdirection, trunk/test score updates, medal detection, and final evaluation before stopping.

RUC-NLPIR/Arbor · 63 tokens

Autonomous Agent Testing

Testing patterns for autonomous AI coding agents like Devin and SWE-Agent including task verification, output validation, sandboxed execution, regression testing for agent behavior, and safety guardrails for autonomous code generation.

PramodDutta/qaskills · 43 tokens

Pair Programming

AI-assisted pair programming with multiple modes (driver$navigator$switch), real-time verification, quality monitoring, and comprehensive testing. Supports TDD, debugging, refactoring, and learning sessions. Features automatic role switching, continuous code review, security scanning, and performance optimization with…

ruvnet/ruflo · 61 tokens

Test-first

Use before implementing a feature or bugfix — write the failing test before the code.

Kilbex/Vigla · 20 tokens

Verify before done

Use before claiming work is complete — prove it with commands, do not assume.

Kilbex/Vigla · 20 tokens