add-unit-test

add-unit-test is a skill for Claude Code, Codex from tmj-90/gaffer. It costs 67 tokens per session (1,148 once invoked), scanned A, original, Apache-2.0.

A workflow for adding focused unit tests, which check one function, module, or component in isolation. It follows the testing tools and style already used in the project.

In plain words
What is it for?
Adding tests for a specific piece of code, covering normal and boundary cases, checking errors, and raising test coverage for a named unit.
Why use it?
It helps turn a ticket's expected behaviour and edge cases into tests without introducing a different testing system. Running the tests confirms whether the new checks pass and may reveal bugs.

Skill for Claude CodeCodex

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

Good fit Adding tests for a specific piece of code, covering normal and boundary cases, checking errors, and raising test coverage for a named unit.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/tmj-90/gaffer/add-unit-test
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 tmj-90/gaffer --skill add-unit-test
Clone the repo
git clone --depth 1 https://github.com/tmj-90/gaffer

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 add-unit-test

README.md
[![agentmods](https://agentmods.dev/badge/skills/tmj-90/gaffer/add-unit-test/github.svg)](https://agentmods.dev/skills/tmj-90/gaffer/add-unit-test)
Your own site
<a href="https://agentmods.dev/skills/tmj-90/gaffer/add-unit-test"><img src="https://agentmods.dev/badge/skills/tmj-90/gaffer/add-unit-test/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 add-unit-test

Your own site · 80×15
<a href="https://agentmods.dev/skills/tmj-90/gaffer/add-unit-test"><img src="https://agentmods.dev/badge/skills/tmj-90/gaffer/add-unit-test.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 67 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,148 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.
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.00067 $0.01148
Opus 5.5 $0.00027 $0.00459
Sonnet 5.5 $0.00013 $0.00230
Haiku 4.5 $0.00007 $0.00115

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

Security

Grade A, and why

add-unit-test 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 20d 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.

runner/skills/add-unit-test/SKILL.md · 83 lines

How it starts

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

Add a unit test

A unit test earns its place when it would fail if the behaviour the acceptance criterion names broke (Kent Beck's "behavioural" and "structure-insensitive" test desiderata). The recurring defect in live runs was not missing test files but tests that never exercised the criterion's own behaviour — they called the function and asserted something incidental, and the reviewer approved.

Procedure

  1. Find the unit and its existing tests. Locate the source file and any sibling test. Read one or two existing tests to copy the framework, file naming, location and assertion style (Vitest/Jest/node:test/pytest/JUnit/go test). Call search_lore for the repo's testing conventions. Never add a second framework or runner.
  2. Map every AC to the behaviour that proves it. For each criterion write one line: input/state → action → observable outcome. That outcome is what the test asserts. An AC that says "rejects duplicate names" is proven by a duplicate being rejected, not by the create function returning something.
  3. Enumerate the cases per behaviour: the happy path, each branch the AC implies, boundary values (0, 1, max, max+1, empty, unicode), and each documented error. If the AC is a rule over many inputs ("round-trips", "never throws"), add a property test (the property-based-test skill).
  4. Write the tests. One behaviour per test, Arrange-Act-Assert, a name that states the behaviour (rejects a duplicate name with 409). Include the AC id or wording in the test or describe name so the reviewer can map test → criterion. Use real collaborators when they are fast and deterministic (a "sociable" unit test); substitute only slow, non-deterministic or external ones (network, clock, randomness, filesystem when not the subject).
  5. Prove each test can fail (the break-it check). For every AC test, temporarily break the behaviour — invert the condition, return early, drop the write — run the test, see it fail for the right reason, then undo the edit and confirm git diff shows only your intended changes. A test that stays green against broken code is deleted or rewritten. (This is manual mutation testing; where the repo has Stryker/mutmut/PIT, run it on the unit instead. An independent tester never edits implementation files and skips this.)
  6. Run the repo's test command from the context packet's verification commands, not the tool directly. Iterate until green. If a test reveals a real bug, fix it only when the ticket scopes it; otherwise note it.
  7. Evidence and stop. Use the record-evidence skill: one test_output row per AC naming the command, the pass summary and the test(s) that prove that AC. The runner — not you — submits for review.

Read the full file on GitHub · 83 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. 20d ago Changed · +33 lines · +13 tokens per session eb780738ef4c
  2. 1mo ago First seen · 50 lines · 54 tokens per session scan A b2038c9ba652

Subscribe to this mod's changes

add-unit-test is a skill published in the GitHub repository tmj-90/gaffer (2 stars, last pushed 20d ago), licensed Apache-2.0. It adds 67 tokens to every session and 1,148 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-31.