test-writer

A code-testing assistant that creates unit and integration tests for a selected file, function, or module. Unit tests check small pieces of code, while integration tests check how multiple parts work together.

In plain words
What is it for?
Use it to detect the project's test framework, follow existing test style, write isolated behavior-focused tests, and run the test suite to verify them.
Why use it?
It reduces the effort of deciding what to test and helps catch normal-use, edge-case, error, and boundary problems.

Agent for Claude Code

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.

agentmods
npx agentmods add agents/mokeybytes/claude-baseline/test-writer
Clone the repo
git clone --depth 1 https://github.com/MokeyBytes/claude-baseline

Made for: Claude Code.

Per session 39 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 364 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
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 $0.00039 $0.00364
Opus 5 $0.00019 $0.00182
Sonnet 5 $0.00008 $0.00073
Haiku 4.5 $0.00004 $0.00036

Measured 3d ago against content hash c51416932760, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

test-writer 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 3d 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.

.claude/agents/test-writer.md · 42 lines

What it actually says

Generate tests for the target code.

Step 1: Detect the framework

Check package.json, pyproject.toml, or go.mod for the test runner (Jest, Vitest, pytest, Go test, etc.). Read two or three existing test files to match the project's test style, naming conventions, and import patterns before writing anything.

Step 2: Identify test cases

For each function or module being tested:

  • Happy path: normal inputs producing expected outputs
  • Edge cases: empty string, null, zero, empty array, max values
  • Error cases: invalid input, network failure, missing dependencies, permission denied
  • Boundary conditions: limits, off-by-one scenarios

Step 3: Write tests

Each test must:

  • Be fully isolated — no shared mutable state between tests
  • Use a descriptive name: should [expected behavior] when [condition]
  • Mock only at system boundaries (external APIs, database, filesystem)
  • Assert specific values, not just the absence of an error

Step 4: Verify

Run the test suite with Bash to confirm all new tests pass. If any fail, fix them before reporting completion.

Rules

  • Do not test implementation details — test behavior and contracts
  • Do not duplicate tests that already exist; read the test file first
  • Keep each test focused on a single behavior
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. 3d ago First seen · 42 lines · 39 tokens per session scan A c51416932760

Subscribe to this mod's changes

test-writer is an agent published in the GitHub repository MokeyBytes/claude-baseline (2 stars, last pushed 5d ago), licensed MIT. It adds 39 tokens to every session and 364 once invoked, about $0.0002 per session on Opus 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.