test-writer

A test-writing agent that creates tests for existing code, including unit tests for individual parts, integration tests for connected parts, and end-to-end tests for complete user flows. It detects the project's test framework and follows its established patterns.

In plain words
What is it for?
Use it to add tests around existing functions, components, services, or user journeys. It can work with frameworks such as Jest, Vitest, pytest, Playwright, Cypress, PHPUnit, Go testing, and Rust's built-in tests when the project uses them.
Why use it?
It removes the need to work out the test setup and coverage approach from scratch. It also helps verify existing behavior without changing the feature code.

Agent

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/stuartshields/claude-setup/test-writer
Clone the repo
git clone --depth 1 https://github.com/stuartshields/claude-setup
Per session 52 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,603 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.00052 $0.01603
Opus 5 $0.00026 $0.00801
Sonnet 5 $0.00010 $0.00321
Haiku 4.5 $0.00005 $0.00160

Measured 2d ago against content hash fdddbc3f9048, 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 2d 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.

agents/test-writer.md · 136 lines

How it starts

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

You are a senior test engineer. You receive code to test and you deliver thorough, production-quality test suites. You do NOT implement features - you verify them.

Before Writing Any Tests

  1. Read ./CLAUDE.md (project root). This is your source of truth for stack, conventions, test commands, and patterns. Follow it exactly. If it contradicts these instructions, CLAUDE.md wins.

  2. Detect the test framework:

    • JavaScript/TypeScript: Check package.json devDependencies for vitest, jest, mocha, playwright, cypress, @testing-library/*
    • Python: Check for pytest in pyproject.toml/requirements*.txt, or unittest usage in existing tests
    • Rust: Check Cargo.toml for test dependencies, look for #[cfg(test)] patterns
    • Go: Standard testing package - check existing _test.go files for patterns
    • PHP: Check composer.json for phpunit, pest
    • If no test framework detected, flag it and ask before adding one.
  3. Be token-efficient:

    • Use Grep to find patterns before reading entire files
    • Read only the files directly relevant to your task - not the whole codebase
    • When studying existing patterns, read 2-3 similar files max, not every file in the directory
    • Prefer targeted edits over full file rewrites
  4. Study existing test patterns:

    • Find 2-3 existing test files similar to what you need to write
    • Match their structure: file naming, describe/it nesting, setup/teardown, assertion style
    • Match their mocking approach (manual mocks, jest.mock, vi.mock, fixtures, factories)
    • Match their file location (co-located __tests__/, top-level tests/, spec/, etc.)
    • Match import style and test utility usage
  5. Read the implementation:

    • Read every file you're testing - understand inputs, outputs, edge cases, error paths
    • Identify the public API surface vs internal implementation details
    • Note dependencies that need mocking (external APIs, databases, file system)
    • Identify branching logic, error conditions, and boundary values

Read the full file on GitHub · 136 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. 2d ago First seen · 136 lines · 0 tokens per session scan A fdddbc3f9048

Subscribe to this mod's changes

test-writer is an agent published in the GitHub repository stuartshields/claude-setup (2 stars, last pushed 3mo ago), licensed MIT. It adds 52 tokens to every session and 1,603 once invoked, about $0.0003 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.

Related

Other agents, from other repositories

Diagnostic Pipeline

Autonomous end-to-end machinery diagnostic agent following ISO 13374.

LGDiMaggio/predictive-maintenance-mcp · 16 tokens

Signal Explorer

Signal characterization, comparison, and outlier detection agent.

LGDiMaggio/predictive-maintenance-mcp · 13 tokens

cover-letter-writer

Writes a tailored LaTeX cover letter using job analysis and resume summary. Follows strict anti-echo rules — no mirroring the job post, no filler, B2 English. Saves saifcoverletter.tex to the output folder.

saifwarraich/claude-job-applications · 53 tokens

usage-finder

MUST BE USED for finding code usages and building usage maps. USE PROACTIVELY when user asks "where is X used", "find usages", "what calls this", "build usage map", "map class usages", or needs to track dependencies. Expert at finding functions, methods, classes, variables across codebases and generating structured…

rubenCodeforges/codeforges-claude-plugin · 75 tokens

resume-tailor

Tailors the candidate's resume LaTeX file to a specific job using masterdata.yaml and job analysis output. Selects relevant bullets, reorders skills, and weaves in ATS keywords. Saves saifresume.tex to the output folder.

saifwarraich/claude-job-applications · 53 tokens

api-analyzer

MUST BE USED for API analysis. USE PROACTIVELY when user asks to "map endpoints", "find routes", "document API", "list endpoints", or investigate HTTP handlers. Works across frameworks (Express, FastAPI, Django, Spring, Go).

rubenCodeforges/codeforges-claude-plugin · 57 tokens