Subagent Tool Permissions and Model Selection in Claude Code
Two frontmatter fields control what a Claude Code subagent can do and what it costs: tools limits its abilities, and model picks the model it runs on. Set tools to the minimum the job needs and model to the cheapest model that does the job well.
This article is part of our Claude Code subagents guide. It builds on how to create a custom subagent and subagent description and system prompt best practices.
The fields at a glance
| Field | Purpose | Values |
|---|---|---|
tools | Allowlist of tools | Comma-separated string or YAML list |
disallowedTools | Denylist, removed from the inherited or specified list | Same format |
model | Model for this subagent | sonnet, opus, haiku, fable, a full model ID, or inherit |
permissionMode | How permission prompts behave | default, acceptEdits, auto, dontAsk, bypassPermissions, plan |
mcpServers | MCP servers scoped to this subagent | Server names or inline definitions |
Field names use camelCase and must match exactly. Claude Code ignores a field it does not recognize and reports no error, so a typo such as disallowedtools does nothing.
Restricting tools
The default: inherit everything
If you omit tools, the subagent inherits the built-in tools and MCP tools available in the main conversation, narrowed by two filters.
The first filter removes a short list from every subagent, even if you list them in tools: Agent, AskUserQuestion, EndConversation, EnterPlanMode, ExitPlanMode, propose_skills, ScheduleWakeup, WaitForMcpServers and Workflow. The docs add that Agent and ExitPlanMode follow conditions that depend on where the subagent runs.
The second filter applies to subagents that run in the background. With nothing configured, subagents started from the main conversation run in the background, except web-fetch. Background subagents keep every MCP tool and these built-ins: Read, Grep, Glob, LSP, Bash, PowerShell, Edit, Write, NotebookEdit, WebFetch, WebSearch, TodoWrite, Skill, ToolSearch and several others. Per the docs, do not rely on other built-in tools in a background subagent. Claude Code removes them without an error unless your tools list resolves to nothing.
Allowlist with tools
List only what the job needs:
---
name: code-reviewer
description: Reviews code for quality and best practices
tools: Read, Glob, Grep
model: sonnet
---
You can also write the list in YAML form:
tools:
- Read
- Grep
- Glob
Denylist with disallowedTools
Use a denylist when you want "everything except". Example: all inherited tools, but no file writes.
---
name: explainer
description: Explains how code works. Use when asked how something is implemented.
disallowedTools: Write, Edit
---
If both fields are present, "disallowedTools is applied first, then tools is resolved against the remaining pool. A tool listed in both is removed."
A disallowedTools entry with a specifier, such as Bash(git push *), still removes the whole tool from the subagent. For command-level control, use a hook instead (see below).
Read-only agents
For agents that only read and report, grant Read, Grep and Glob and leave out Edit, Write and Bash. The built-in Explore and Plan subagents work this way: they use read-only tools, with Write and Edit denied.
If a reviewer needs Bash for git diff, know the limit. The docs' own code reviewer example has tools: Read, Grep, Glob, Bash and notes it can still change files through Bash. When you need finer control than the tools field gives, use a PreToolUse hook. The docs' db-reader example gives the agent Bash and runs a script that blocks SQL write commands by exiting with code 2.
Control which subagents can be spawned
To restrict which subagent types an agent can spawn, use Agent(agent_type) syntax in its tools field:
tools: Agent(worker, researcher), Read, Bash
This is an allowlist: only worker and researcher can be started. Agent without parentheses allows any subagent. By default, a subagent can spawn its own subagents up to three layers below the main conversation. Omit Agent from a subagent's tools, or add it to disallowedTools, to stop it. CLAUDE_CODE_MAX_SUBAGENT_SPAWN_DEPTH changes the depth, and 1 disables nesting.
To block specific subagents for the whole session, use the settings file:
{
"permissions": {
"deny": ["Agent(Explore)", "Agent(my-custom-agent)"]
}
}
Denying the Agent tool itself stops Claude from delegating to any subagent. In version 2.1.63 the Task tool was renamed to Agent, and existing Task(...) references still work as aliases.
MCP tools in subagents
Subagents inherit MCP tools from the main conversation. To change that:
mcp__github__*intoolsgrants one server's tools.disallowedTools: mcp__*removes all MCP tools.mcpServersscopes servers to one subagent. Inline definitions connect when the subagent starts and disconnect when the last agent using them finishes. A string reference shares the parent session's connection.- Inline servers from a project's
.claude/agents/load only after you trust that folder. - Plugin subagents ignore
mcpServers,hooksandpermissionMode.
Choosing a model
"By default, a subagent you define runs on the same model as the conversation that starts it." To choose, set model to one of:
- Alias:
sonnet,opus,haikuorfable - Full model ID: a value the
--modelflag accepts, such asclaude-opus-5-5orclaude-sonnet-5 inherit: the main conversation's model
Resolution order
When more than one source sets a model, Claude Code uses the first in this list:
- The per-invocation
modelparameter that Claude can pass when it starts the subagent. It takes a model alias, not a full model ID orinherit. - The
modelfield in the subagent definition, includinginherit. - The
CLAUDE_CODE_SUBAGENT_MODELenvironment variable. - The main conversation's model, or the spawning subagent's model for a nested subagent.
To force one model on every subagent, set CLAUDE_CODE_SUBAGENT_MODEL together with CLAUDE_CODE_SUBAGENT_MODEL_FORCE=1.
Matching model to task
The docs do not prescribe a model per task, so treat these as practical guidelines to test, not rules:
| Job | Starting point |
|---|---|
| Search, summarize logs, list files | A smaller, faster model such as haiku |
| Review, debugging, data analysis | sonnet (the docs' data-scientist example sets it for more capable analysis) |
| Hard design or reasoning work | opus, or inherit from the main session |
Compare results on a real task before you commit a cheaper model to an agent. A cheaper model that needs two retries can cost more than a stronger one that succeeds once.
Subagents "count toward the same usage limits" as your main conversation, so model choice affects your plan limit as well as speed.
Nested subagents follow their parent
A nested subagent runs on its parent's model by default. If your main session is on Opus and it starts a reviewer on Haiku, then any subagent the reviewer starts also runs on Haiku when it has model: inherit, no model field, or is a built-in Explore, Plan or general-purpose agent. Set model on the nested agent to change this.
Check which model ran
Run /tasks. On Claude Code v2.1.242 or later, the row for a running subagent names its model.
Permission modes
permissionMode in the frontmatter sets how a subagent handles permission prompts. The modes are default, acceptEdits, auto, dontAsk, bypassPermissions and plan. manual is an alias for default.
| Mode | What runs without asking (from the permission modes page) |
|---|---|
default | File reads inside your working directories, and actions that need no approval such as starting a subagent |
acceptEdits | Reads, file edits, and common filesystem commands such as mkdir, touch, mv, cp |
plan | Reads, plus classifier-approved commands when auto mode is available |
auto | Everything, with background safety checks |
dontAsk | Reads and pre-approved tools. Anything that would prompt is denied |
bypassPermissions | Everything |
How a subagent's setting interacts with the main session:
- If you leave it unset, the subagent inherits the main conversation's permission mode.
- If the main conversation uses
bypassPermissions,acceptEditsor auto mode, the subagent runs in that mode and itspermissionModeis ignored. - If the main conversation is in
planmode, the subagent stays in plan mode. - Otherwise, the subagent uses the mode you set.
- In auto mode, a classifier checks subagent work before it starts, while it runs, and after it finishes.
- Background subagents show their permission prompts in your main session, naming the subagent that is asking.
Be careful with bypassPermissions
The docs say to use it only in isolated environments such as containers, VMs or dev containers without internet access. They state that it "offers no protection against prompt injection or unintended actions." Do not set it on a subagent for convenience.
Security view: least privilege
Treat each subagent like a contractor with a key card. Give it the rooms it needs.
- Start from the job, then list the tools it truly needs.
- Prefer an allowlist over a denylist. New tools appear over time, and an allowlist does not grow by accident.
- Keep write tools off agents that only report.
- Add a hook when a tool is needed but some uses are not.
- Avoid
bypassPermissionsoutside isolated environments. - Review
.claude/agents/changes in pull requests, as you would any script.
Worked examples
Reviewer (read-only, inherits the session model):
---
name: code-reviewer
description: Expert code review specialist. Proactively reviews code for quality, security, and maintainability. Use immediately after writing or modifying code.
tools: Read, Grep, Glob, Bash
model: inherit
---
Data analyst (explicit model, narrow tools):
---
name: data-scientist
description: Data analysis expert for SQL queries, BigQuery operations, and data insights. Use proactively for data analysis tasks and queries.
tools: Bash, Read, Write
model: sonnet
---
Debugger (can edit, because fixes need edits):
---
name: debugger
description: Debugging specialist for errors, test failures, and unexpected behavior. Use proactively when encountering any issues.
tools: Read, Edit, Bash, Grep, Glob
---
All three come from the official docs.
See what your agents actually run
After you tighten tools and models, you want evidence that agents behave as designed. Agent Office lists each handoff with its status and token counts across your sessions, which helps you spot an agent that uses far more tokens than its job deserves. It reads local session data only and never message text. See the setup guide to install it. It shows token counts, not prices, and it cannot change an agent's settings.
If a subagent does not run at all, use the troubleshooting checklist.
Sources
Claude and Claude Code are trademarks of Anthropic. Claud Agency is an independent tool by ECOMHUTSY and is not affiliated with Anthropic.
FAQ
How do I restrict the tools a subagent can use?
Add a tools field to the frontmatter as an allowlist, for example tools: Read, Grep, Glob. To block a few tools instead, use disallowedTools. If you set both, disallowedTools is applied first, then tools is resolved against what remains.
What tools does a subagent have if I set none?
It inherits the tools available to subagents, including MCP tools from the main conversation, minus a short list that is removed from every subagent, such as AskUserQuestion, EnterPlanMode and ScheduleWakeup.
Can a subagent use a cheaper model?
Yes. Set model in the frontmatter to haiku, sonnet, opus, fable, a full model ID or inherit. Without it, the subagent runs on the same model as the conversation that starts it.
Which model wins if several settings disagree?
The order is: the per-invocation model parameter Claude passes, then the model field in the subagent file, then the CLAUDE_CODE_SUBAGENT_MODEL environment variable, then the main conversation's model.
What are permission modes and can a subagent have its own?
Modes are default, acceptEdits, auto, dontAsk, bypassPermissions and plan. A subagent can set permissionMode, but if the main conversation uses bypassPermissions, acceptEdits or auto mode, that mode wins and the field is ignored.
Can subagents use MCP tools?
Yes. They inherit MCP tools from the main conversation unless you restrict them. Use mcpServers to scope a server to one subagent, or mcp__<server>__* in tools to allow one server's tools. Plugin subagents ignore mcpServers.
Should a code reviewer be allowed to edit files?
Usually not. Leave out Edit and Write. A reviewer with Bash can still change files through shell commands, so add a prompt rule or a PreToolUse hook if that matters.
Frequently asked questions
How do I restrict the tools a subagent can use?
Add a tools field to the frontmatter as an allowlist, for example tools: Read, Grep, Glob. To block a few tools instead, use disallowedTools. If you set both, disallowedTools is applied first, then tools is resolved against what remains.
What tools does a subagent have if I set none?
It inherits the tools available to subagents, including MCP tools from the main conversation, minus a short list that is removed from every subagent, such as AskUserQuestion, EnterPlanMode and ScheduleWakeup.
Can a subagent use a cheaper model?
Yes. Set model in the frontmatter to haiku, sonnet, opus, fable, a full model ID or inherit. Without it, the subagent runs on the same model as the conversation that starts it.
Which model wins if several settings disagree?
The order is: the per-invocation model parameter Claude passes, then the model field in the subagent file, then the CLAUDE_CODE_SUBAGENT_MODEL environment variable, then the main conversation's model.
What are permission modes and can a subagent have its own?
Modes are default, acceptEdits, auto, dontAsk, bypassPermissions and plan. A subagent can set permissionMode, but if the main conversation uses bypassPermissions, acceptEdits or auto, that mode wins and the field is ignored.
Can subagents use MCP tools?
Yes. They inherit MCP tools from the main conversation unless you restrict them. Use mcpServers to scope a server to one subagent, or mcp__<server>__* in tools to allow one server's tools. Plugin subagents ignore mcpServers.
Should a code reviewer be allowed to edit files?
Usually not. Leave out Edit and Write. Note that a reviewer with Bash can still change files through shell commands, so add a prompt rule or a PreToolUse hook if that matters.