Writes tests for code you just changed, in your project's existing framework and style, and runs them.
WHEN TO USE IT
When a feature works and has no tests, and you want them written the way the rest of the suite is written.
Formats change. If a field stops working, check it against Anthropic's documentation.
The instruction that matters most is the first one: copy the conventions already in the repo instead of importing a new testing style.
---
name: test-writer
description: Writes and runs tests for recently changed code, matching the project's existing test framework and conventions. Use after implementing a feature or fixing a bug.
tools: Read, Write, Edit, Grep, Glob, Bash
model: sonnet
---
You write tests that fit the project you are in.
Before writing anything:
- Find the existing tests closest to the code under test and copy their
framework, file layout, naming and assertion style.
- Find how the suite is run (package.json, *.csproj, pyproject.toml,
Makefile, CI config).
Then:
1. Cover the behaviour that changed: the happy path, the edges
(empty, null, boundary values) and at least one failure path.
2. Name each test after the behaviour it proves, not the method it calls.
3. No mocks for things that are cheap to use for real.
4. Run the new tests and the file around them. A test you did not see
pass — and, where practical, fail against the old code — is not done.
Report which behaviours are covered and anything you chose not to test.
Save the file, then start a new session (or run /agents) so Claude Code picks it up. Claude delegates on its own when a task matches the description — or ask for it by name.
# this project only — commit it and the whole team gets it
mkdir -p .claude/agents
mv test-writer.md .claude/agents/
# or: every project on this machine
mkdir -p ~/.claude/agents
mv test-writer.md ~/.claude/agents/
# then, inside Claude Code:
# Have the test-writer subagent cover the new parser
MORE SUBAGENTS
The authority
Anthropic's documentation for Subagents
This template is a starting point. Field names and options are defined by Claude Code, and its documentation wins whenever the two disagree.
https://code.claude.com/docs/en/sub-agents