OmniscioSubagent examplesTest runner
A test runner subagent
Anthropic's own example of a good subagent task is "run the test suite and report only the failing tests with their error messages". The value is not cleverness: it is not paying for a thousand lines of green dots on every turn that follows.
The file below does that and one thing more: it makes the agent use your repository's own test command instead of guessing one, which is the mistake that turns a helpful report into a confident fiction.
Checked against Anthropic's Claude Code documentation on November 25, 2026. By the Omniscio team. Updated .
When Claude delegates to it
Delegation is a match between your request, the agent's description and the conversation. The description below names the moment — a change needs its tests run — rather than the role, so it fires when you say "run the tests" or when Claude decides a change needs checking before it reports back.
You can also ask directly, by name: "have the test-runner subagent run the payments tests". The transcript then shows one tool call row for the whole run, with the report as its result.
The case where this pays for itself is the long run: an integration suite that prints for two minutes and ends with one failure. Inline, that output is in your context for the rest of the session. Here, one line comes back.
The file
Save this as .claude/agents/test-runner.md. The body tells the agent to read your task file and run what it finds there, so most repositories need no edit at all; if yours runs tests through a wrapper whose arguments the agent could get wrong, replace the wording of step 2 with the exact command.
---
name: test-runner
description: Runs the test suite and returns only the failing tests with their error messages and the command that reproduces them. Use whenever a change needs its tests run, so the full output stays out of the main conversation.
tools: Read, Grep, Glob, Bash
model: haiku
---
You run tests. You do not fix them.
When you start:
1. Read the repository's task file (package.json, Makefile, pyproject.toml or equivalent) and use the test command it defines. Never invent one.
2. Run the smallest command that covers the change: one file or one pattern before the whole suite.
3. If the suite cannot start at all, such as a missing dependency or a missing service, stop and report that, with the command and the first error line.
For each failing test, report:
- the test's full name and the file it lives in
- the assertion or error message, quoted exactly as printed
- the one command that reproduces that test alone
- whether it also fails without your changes, if you can tell without modifying files
Do not paste passing output, and do not summarise timings unless something timed out.
End with one line: how many passed, how many failed, how many were skipped.The report it returns looks like this, which is the whole point of the exercise: four lines about the one thing that failed, instead of the suite's output.
FAILED tests/test_invoices.py::test_partial_refund - AssertionError: 1250 != 1200
runs: pytest tests/test_invoices.py::test_partial_refund
also fails on the base branch: yes
3 passed, 1 failed, 0 skippedWhat each field does
name
The identifier used when Claude delegates, up to 256 characters and with no colon. The filename does not have to match, but matching them keeps the folder readable.
description
The router. "Runs the test suite" is the what; "use whenever a change needs its tests run" is the when, and the when is what Claude matches. Descriptions load at every session start, so keep this one to two sentences; Anthropic warns at 15,000 tokens across all of them.
tools
Read, Grep and Glob let it find the task file and the test files; Bash runs the command. Leaving Edit and Write out keeps the split clean: this agent reports, and the fixing happens in the conversation that can see the whole change.
All four tools survive the background tool filter. That matters more than it sounds: a subagent Claude starts from your main conversation runs in the background by default, and a background subagent loses most built-in tools it does not need — but not these four.
model
haiku is a deliberate choice for a job that is mostly running a command and quoting its output, and Anthropic lists routing work to a faster, lower-cost model as one of the reasons to use a subagent at all. If its summaries of a failure miss the cause, change this line to sonnet or inherit; the rest of the file does not need to change.
Project file or user file
A test runner is worth committing, in .claude/agents/, because the test command is a property of the repository. A user-level copy in ~/.claude/agents/ is fine for a runner that reads the task file and works out the command itself, which is what the body above does.
- Project definitions outrank user definitions when the names collide, so a project copy wins without you deleting the personal one.
- Both directories are scanned recursively, and the folder does not change the agent's identity.
- Two files in the same directory with the same
namemeans only one loads, and the/doctorsetup checkup reports it.
Confirm Claude picked it up
- No restart needed. Both agent directories are watched; an edit is picked up within seconds. The exceptions are a folder added with
--add-dirand a session started with--disable-slash-commands. - Ask it by name. "Use the test-runner subagent on the auth tests" proves the file loaded in one turn.
/tasksshows the run and the model it is on, which is how you confirm themodelline took effect (v2.1.242 or later).- The transcript shows the delegation as one row, and the report arrives under it.
/agentsprints a reminder to ask Claude to manage subagents, or to edit the folders directly; on v2.1.197 and earlier it opened a wizard.
If the report never arrives, remember the background rule: the result comes back as a completion notification in a later turn. Claude saying "still running" is the design, not a failure.
When it goes wrong
- It invents a test command. The most expensive failure here, because a wrong command can look like a passing suite. The first instruction in the body is the fix: read the task file, use the command it defines.
- It runs everything, every time. Say which file or pattern in the request, or add a rule to the body about running the smallest command that covers the change.
- A typo in
toolsis silent unless it is the only tool left. Claude Code refuses the launch only when every entry fails to resolve; a single misspelt tool beside three valid ones is dropped without an error, and the agent quietly runs without it. Check/tasksafter the first run if you edited that line. - It goes quiet. See above: background results arrive in a later turn.
- It reports a failure it caused. If you give it
Edit, a test can fail because the agent changed something. Leaving the writing tools out avoids that; leavingBashout as well is the only version that cannot touch a file.
And the file-level failure that catches everyone once: the first --- must be the very first line. A blank line or a licence header above it means Claude Code reads the file as documentation and never loads the agent.
Adapting it to your repository
- Add the command that starts a needed service, such as a database container, before the test command. An agent that cannot start the suite should stop and say so, not work around it.
- If your repository has more than one test command, name the one you mean in the request ("use
pytest -x") rather than editing the file. The agent reads the task file first, which is the right default for everything else. - Keep the "do not paste passing output" rule. It is the whole reason the agent exists.
- If your suite is fast, this agent is optional. The value scales with the length of the output, not with the number of tests.
The other four files are on the subagent examples page; the subagents guide covers the context and cost rules behind this one.
Sources
- Anthropic's Create custom subagents, for the file format, the frontmatter fields, the tool filters for background subagents, the delegation and model rules, and the "run the test suite" worked example, read November 25, 2026.
- Anthropic's error reference, for the zero-tools refusal and the description budget, read November 25, 2026.
- Anthropic's commands reference, for
/agentsand/tasks, read November 25, 2026.
The file on this page was written for this site from Anthropic's documented rules. It was not run against a live repository here, and the page makes no claim about how much context it saves in yours.
Common questions
What does a test runner subagent do?
It runs the suite in its own context window and returns the failing tests with their messages, so the passing output never enters your conversation. Anthropic names exactly this case — running the test suite and reporting only the failures — as one of the most effective uses of a subagent.
Should a test runner subagent use a smaller model?
Often, yes. Running a command and quoting its failures is mechanical, and Anthropic lists routing that kind of work to a faster, lower-cost model such as Haiku as a reason to use a subagent. If the summaries miss the cause of a failure, move it to sonnet or inherit.
Why did the test runner say nothing for a while?
Subagents Claude starts from your main conversation run in the background by default, and a background subagent's result arrives as a completion notification in a later turn. Claude reports that it is still running until that notification lands.
Can the test runner fix the failing tests too?
It can if you give it Edit and tell it to. Keeping it read-only is usually the better split: the agent reports and the conversation decides. A runner that edits while it runs also makes it hard to tell a real fix from a changed test.
Long test runs, short reports, one window
Omniscio is a desktop app for running Claude Code and other coding agents side by side, with one list of sessions and one inbox, so an agent only interrupts you when a decision needs you.
The features page lists what is in it today, pricing covers the plans, and you can download it for Windows, macOS or Linux.