test-writer

test-writer is an agent for Claude Code from smartwhale8/claude-playbook. It costs 47 tokens per session (479 once invoked), scanned A, original, MIT.

A test-writing helper that adds tests for existing code in a separate Git worktree. A worktree is an isolated checkout of the same repository, so test changes do not collide with the main checkout.

In plain words
What is it for?
It is for adding coverage for normal behaviour, reachable errors, boundary inputs, and previously broken cases without changing the code under test.
Why use it?
It reduces interference with ongoing work and bases tests on the code's real branches, existing test style, and current test command.

Agent for Claude Code

Written for Claude Code: installed under .claude/. Also seen: model in frontmatter; mentions Claude Code.

Part of the claude-playbook plugin — 5 skills, 4 agents, 3 hooks shipped together

Good fit It is for adding coverage for normal behaviour, reachable errors, boundary inputs, and previously broken cases without changing the code under test.

Compare 6 agents from other repositories ↓
Install with agentmods
npx agentmods add agents/smartwhale8/claude-playbook/test-writer
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.

Clone the repo
git clone --depth 1 https://github.com/smartwhale8/claude-playbook

Made for: Claude Code.

Or install claude-playbook, the plugin that ships this one along with the rest of its 5 skills, 4 agents, 3 hooks.

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 test-writer

README.md
[![agentmods](https://agentmods.dev/badge/agents/smartwhale8/claude-playbook/test-writer/github.svg)](https://agentmods.dev/agents/smartwhale8/claude-playbook/test-writer)
Your own site
<a href="https://agentmods.dev/agents/smartwhale8/claude-playbook/test-writer"><img src="https://agentmods.dev/badge/agents/smartwhale8/claude-playbook/test-writer/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 test-writer

Your own site · 80×15
<a href="https://agentmods.dev/agents/smartwhale8/claude-playbook/test-writer"><img src="https://agentmods.dev/badge/agents/smartwhale8/claude-playbook/test-writer.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 47 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 479 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.00047 $0.00479
Opus 5.5 $0.00019 $0.00192
Sonnet 5.5 $0.00009 $0.00096
Haiku 4.5 $0.00005 $0.00048

Measured 1mo ago against content hash ec6d3c5b72b2, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, 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 1mo 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 · 41 lines

What it actually says

You write tests for code that already exists. You do not change the code under test.

You run in a temporary git worktree branched from the default branch, so your files do not collide with the main session's checkout. Claude Code removes the worktree automatically if you make no changes.

Before writing

  1. Read the code under test and trace its real branches. Test what it does, not what its name implies.
  2. Read the existing tests in this project and copy their structure exactly: the same runner, the same fixture style, the same naming, the same assertion library. A test file that does not look like its neighbours is a finding against you.
  3. Find the project's test command and confirm the suite passes before you add anything. Starting from a red suite makes your result meaningless.

What to write

Cover, in this order:

  1. The behaviour the code is for, in its normal case.
  2. Each error path a caller can actually reach.
  3. Boundaries: empty input, a single element, the maximum, null and undefined where the type permits.
  4. Anything a comment or an issue says was once broken.

Skip: framework internals, third-party behaviour, getters with no logic, and implementation details that a legitimate refactor would change.

Rules

  • Never change the code under test. If a test fails because the code is wrong, leave the test failing and report it. A passing suite you obtained by editing the implementation hides the bug you found.
  • Each test sets up its own data and cleans up after itself.
  • No sleeps. Poll or use fake timers.
  • Names state the behaviour: returns_empty_list_when_no_matches.

Report

Say which files you added, what each covers, and the exact output of the final test run. Then list every behaviour you chose not to cover and why, and any failure that revealed a bug in the code rather than in the test.

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. 1mo ago First seen · 41 lines · 47 tokens per session scan A ec6d3c5b72b2

Subscribe to this mod's changes

test-writer is an agent published in the GitHub repository smartwhale8/claude-playbook (43 stars, last pushed 1mo ago), licensed MIT. It adds 47 tokens to every session and 479 once invoked, about $0.0002 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-09-21.

Related

Other agents, from other repositories

ring:qa

Senior QA Analyst for financial systems. Supports 6 testing modes — unit (default), fuzz, property, integration, chaos, goroutine-leak. Dispatched by orchestrator with mode parameter; loads mode-specific file from qa-modes/.

LerianStudio/ring · 52 tokens

ring:test-reviewer

Test Quality Review: Reviews test coverage, edge cases, test independence, assertion quality, and test anti-patterns. Runs in parallel with other reviewers at Gate 8.

LerianStudio/ring · 39 tokens

ring:qa-frontend

Senior Frontend QA Analyst for React/Next.js. Supports 5 modes — unit (default), accessibility, visual, e2e, performance. Dispatched with mode parameter; loads mode-specific file from qa-frontend-modes/.

LerianStudio/ring · 53 tokens

delivery-validator

Runtime delivery verification agent. Boots applications, runs smoke tests, verifies developer experience and technology currency. Write access limited to running servers and install commands — never modifies source code.

irahardianto/awesome-agv · 37 tokens

test-automation-engineer

Hands-on test automation engineer. Invoke for writing E2E tests, building test infrastructure, managing test data, configuring coverage reporting, and investigating flaky tests. MCP-first Playwright automation. This agent writes test code — not production code.

irahardianto/awesome-agv · 53 tokens

implementer

Executes a single plan task using TDD. Writes tests first, then production code, then refactors. Reports status with evidence.

greglas75/zuvo · 30 tokens