SpecMatter field notes

Claude Code / delegated agent field notes

Claude Code Subagents: scope, files, tools, and limits

Short answer: a Claude Code subagent is a named Markdown definition with YAML frontmatter that gives a delegated task its own prompt, tool boundary, model choice, and context. Put project definitions under .claude/agents/ and personal definitions under ~/.claude/agents/. Write a precise description because it is the delegation signal, and restrict tools to what the subagent needs. A valid definition still does not prove that delegation occurred.

Our local test on Claude Code 2.1.283 separated those two claims. A JSON agent definition passed CLI parsing and reached the authentication boundary. The session then returned Not logged in · Please run /login, with zero input tokens, zero output tokens, zero cost, and zero spawned subagents.

A central coding workspace delegates bounded tasks to isolated research, test, and review workspaces and receives reports
Subagents isolate context and tools, then return results to the parent. The illustration shows the intended mechanism, not a claim that our unauthenticated fixture spawned agents.

Local parse/authentication test: Windows 11, Claude Code 2.1.283, 2026-09-27. Delegation remains untested because no Claude subscription or API key was used.

A minimal project subagent

Save a project-specific definition as .claude/agents/evidence-auditor.md. The filename helps humans; the name field is the agent identity.

---
name: evidence-auditor
description: Audits a technical claim against saved local output and reports unsupported claims.
tools: Read, Glob, Grep
model: inherit
---

Read the supplied evidence files. Separate observed output
from documentation and inference. Do not edit files.
FieldWhy it mattersFailure mode
nameStable identity used for invocationDuplicate names in one tree can resolve by filesystem order rather than an intended hierarchy.
descriptionTells Claude when delegation is appropriateA vague description causes missed or inappropriate delegation.
toolsCreates a positive capability boundaryOmitting a boundary can give the delegated task more tools than needed.
modelChooses a model or inherits the parentChanging the model can change cost, speed, and behavior.
Body promptDefines the specialist's job and output disciplineA broad role can duplicate the parent instead of reducing context.

Discovery and precedence are part of the design

SourceScopeDocumented precedence
Managed definitionsOrganizationHighest
--agents JSONCurrent sessionAbove project definitions
.claude/agents/Current projectAbove user definitions
~/.claude/agents/All local projectsAbove plugin definitions
Plugin agents/Where the plugin is enabledLowest of these sources

The official guide says project definitions are discovered while walking from the current directory toward the repository root; when nested project directories define the same name, the closest definition wins. Agent directories are scanned recursively. Keep names unique within one directory tree because duplicate selection there is not a useful precedence mechanism.

The local test: accepted configuration is not delegation

We ran two deliberately different --agents inputs. Passing the Markdown file itself failed immediately because the flag expects JSON or a file containing JSON:

Error: Invalid --agents configuration:
invalid JSON: JSON Parse error: Invalid number
(read from ...\.claude\agents\evidence-auditor.md)

The second fixture used a JSON object with description, prompt, tools, and model. The CLI accepted it, started a print-mode turn, and stopped at authentication:

"result":"Not logged in · Please run /login"
"total_cost_usd":0
"input_tokens":0
"output_tokens":0
"subagent_stats":{"spawned":0,...}

Download the subagent test observations (CSV)

What this means: the JSON shape passed far enough to reach the login check. It does not prove agent selection, tool restriction, context isolation, report quality, foreground execution, or background execution.

What was tested, and what remains untested

ClaimVerdictEvidence
The installed CLI can parse the session agent JSONTestedThe JSON invocation passed configuration parsing and reached authentication.
A Markdown agent file can be passed directly to --agentsRejectedThe CLI returned an invalid JSON error.
The custom subagent was spawnedUntestedThe raw result reported spawned: 0.
The tool boundary prevented writesUntestedNo delegated tool call occurred.
The subagent improved task qualityUntestedNo model response was produced.

Use a subagent when the context boundary is real

FAQ

Do I need Claude Pro or Max to test delegation?

You need an authenticated Claude Code path, which can be a supported Claude subscription or an Anthropic API setup. This test used neither, so delegation was not run.

Does claude plugin validate prove a subagent can run?

No. It can catch some directory or frontmatter problems, but execution still depends on discovery, trust, authentication, model access, and the actual task.

Did this local attempt incur a charge?

No. The result reported total_cost_usd: 0 and zero input and output tokens.

Sources and related field notes

Official documentation checked 2026-09-27. Raw local results are linked above. SpecMatter is not affiliated with Anthropic.