AgentDefinition
Definition
The definition of a subagent's identity, instructions, and capabilities — supplied programmatically via the agents param or on the filesystem as .claude/agents/*.md.
Key points
- Programmatic (
agentsparam) required fields:description,prompt. Optional:tools(allowed; omit = inherit all),disallowedTools(accepts MCP patternsmcp__server,mcp__server__*,mcp__*),model(fable/opus/sonnet/haiku/inherit/full ID),skills,memory(user/project/local),mcpServers,initialPrompt,maxTurns,background,effort(low/medium/high/xhigh/max/number),permissionMode. - Python kwarg is
allowed_tools;disallowedTools/mcpServersstay camelCase in Python to match wire format. - Filesystem (
.claude/agents/*.md) required frontmatter:name(lowercase+hyphens; hooks receive it asagent_type),description. Optional addsisolation(worktree= temp git worktree),color,hooks,permissionMode, etc. Heremodeldefaults toinherit. - Three ways to create subagents: (1)
agentsparam; (2).claude/agents/*.md; (3) built-ingeneral-purpose. Programmatic defs take precedence over filesystem defs of the same name. - File precedence (high→low): Managed settings >
--agentsCLI flag >.claude/agents/(project) >~/.claude/agents/(user) > pluginagents/. - Built-in subagents:
Explore(read-only; Write/Edit denied),Plan(read-only, plan mode),general-purpose. - Model resolution:
CLAUDE_CODE_SUBAGENT_MODELenv → per-invocationmodel→ frontmattermodel→ main model. - Tool combos: read-only = Read/Grep/Glob; test = Bash/Read/Grep; code-mod = Read/Edit/Write/Grep/Glob; full = omit
tools.
Why it matters for the exam
- D1 tests that AgentDefinition sets identity/instructions/capabilities, the two definition surfaces, and precedence (programmatic > filesystem; managed > CLI > project > user > plugin).
Common gotchas
- Filesystem
modeldefaults toinherit, but the effective model still follows the resolution chain (env var wins). - Plugin subagents don't support
hooks/mcpServers/permissionMode. - Subagents don't inherit parent conversation history or system prompt — only their own prompt + Agent tool string + project CLAUDE.md.
See also
Sources
Referenced by
Practice questions optional · AI
Generate fresh practice questions about this concept with AI. These are not vault-verified.