How to use Claude Code subagents with restricted tools

To restrict a Claude Code subagent, add a tools field to its Markdown file and list only the tools it needs, such as Read, Grep, Glob. The field is an allowlist: a subagent without an entry for a tool doesn’t receive it. Use disallowedTools to remove specific tools from what the subagent would otherwise inherit.
Checked against the Claude Code subagent, permissions and settings documentation as fetched on 2026-11-28. The pages don’t name a CLI version for the tools and disallowedTools fields, so confirm the behavior against your installed release.
What the tools field controls
Subagents inherit the built-in tools and MCP tools that the main conversation has. Two filters then narrow that set. The first removes a short list of tools from every subagent, including AskUserQuestion, EnterPlanMode and Workflow, even when you list them in tools. The second reduces the built-in set for subagents that run in the background, which is the default. Each built-in subagent also inherits the parent conversation’s permission rules, so the tool list narrows what the subagent is given and leaves the rules in place.
Allowlist with tools
Use tools when a subagent should get only a few tools. The docs example allows Read, Grep, Glob and Bash, and the subagent then has no Edit, Write or MCP tools. The same example notes that the subagent can still change files through Bash. The list alone doesn’t make a subagent read-only, so leave Bash out too when it must never write.
Denylist with disallowedTools
Use disallowedTools when a subagent should keep most of the inherited tools. The docs example inherits everything except Write and Edit. When both fields are set, disallowedTools is applied first and tools is resolved against what remains. A specifier such as Bash(git push *) still removes the whole Bash tool rather than just the matching commands.
Where a subagent file lives and which one wins
Claude Code loads subagent files from five locations. When two share a name, the one with the lower priority number is used.
| Location | Scope | Priority |
|---|---|---|
| Managed settings | Organization-wide | 1 (highest) |
--agents CLI flag |
Current session | 2 |
.claude/agents/ |
Current project | 3 |
~/.claude/agents/ |
All your projects | 4 |
Plugin’s agents/ directory |
Where the plugin is enabled | 5 (lowest) |
For project files, Claude Code walks up from the working directory and uses the definition closest to it when nested folders share a name. Managed definitions take precedence over project and user subagents with the same name, so an administrator’s definition wins over a local copy. Plugin subagents ignore the hooks, mcpServers and permissionMode fields for security reasons. If a restriction depends on one of those fields, put the file in .claude/agents/ or ~/.claude/agents/ instead.
Create a subagent with a restricted tool list
The steps below use a project subagent, which you can commit so the whole team gets it. The docs recommend version control for project subagents.
- Create
.claude/agents/at the project root if it doesn’t exist, then save a new file in it, for examplerepo-reader.md. - Set
nameanddescriptionin the frontmatter. The description tells Claude when to delegate. Addtoolsas a comma-separated string or a YAML list. - Write the system prompt in the Markdown body. Subagents receive that prompt and basic environment details, not the Claude Code system prompt.
- Save the file. Claude Code watches
.claude/agents/and~/.claude/agents/, so the next delegation uses the new definition without a restart.
---
name: repo-reader
description: Answers questions about this repository by reading and searching files. Use when no changes are needed.
tools: Read, Grep, Glob
---
You answer questions about this repository. Read and search files only.
Give the file path and line number for every claim.
The name field is the identifier Claude uses, and the filename doesn’t have to match it. Keep names unique within a folder, because two files there with the same name load only one of them.
Restrict MCP tools and subagent spawning
The tools and disallowedTools fields accept a whole MCP server as one entry, and permissions.deny can block named subagents. Use these when a restriction should cover a server or a subagent type rather than a single tool.
Give or withhold a whole MCP server
Entries in tools and disallowedTools can name every tool from one MCP server. mcp__github__* in tools gives the subagent every tool from the github server. mcp__github in disallowedTools removes that server’s tools, and mcp__* withholds every MCP tool. A server name that contains a double underscore needs the full form, such as mcp__reports__v2__*, because a shorter entry matches nothing or matches too much.
---
name: triage-helper
description: Triages issues from the repository without GitHub MCP tools
disallowedTools: mcp__github
---
Block named subagents with permission rules
Add Agent(name) entries to permissions.deny to stop Claude from using a subagent, built-in or custom. The same rule can be passed on the command line with --disallowedTools. Use it for a subagent that should never run in a project, and keep the tools list for limits on what a subagent may use.
{
"permissions": {
"deny": ["Agent(Explore)", "Agent(repo-reader)"]
}
}
The docs also describe an Agent(agent_type) entry in the tools field. It limits which subagent types a main-thread agent started with claude --agent can spawn. The type list is ignored inside a subagent definition, so the restriction only applies at the top level of a session.
Background subagents get a smaller tool set
With nothing configured, a subagent that Claude starts from the main conversation runs in the background. The docs say background subagents run with a smaller built-in tool set than foreground ones. Claude Code removes most other built-in tools from them, whether they’re inherited or named in tools, and it reports nothing unless the list ends up resolving to no tools at all.
The tools that remain for a background subagent include Read, Grep, Glob, Bash, Edit, Write, WebFetch and WebSearch, plus every MCP tool. The docs say not to rely on any other built-in tool in a background subagent. Check each tool your subagent needs against that list before you depend on it. The docs also tie several subagent options to specific Claude Code releases, so confirm the version your team runs.
- List the built-in tools the subagent needs.
- Compare the list with the background set above.
- Run a test task that names the subagent, and confirm the result shows the tools you expect.
- If Claude should wait for the subagent in an interactive session, turn off fork mode, because the docs say it is on by default.
What permissions still apply
Permission rules still govern what a subagent does. The permissionMode field sets a subagent’s mode only when the main session allows it. When the main conversation runs in bypassPermissions, acceptEdits or auto mode, the subagent runs in that mode and Claude Code ignores the field. In plan mode the subagent stays in plan mode. In dontAsk mode, calls that would prompt are denied, while explicitly allowed tools still run.
A Bash rule matches the command text Claude writes. The permissions docs say that such a rule “isn’t a security boundary around the program.” For example, Bash(rm *) stops rm -rf build/ but not /bin/rm -rf build/. The subagent docs add that their output scan “isn’t a substitute for restricting what a subagent can reach.”
Check the restriction before you rely on it
Three checks catch most mistakes. Each one comes from the subagent docs.
- Validate the folder. The docs say to run
claude plugin validateon the directory to find files whose frontmatter doesn’t parse. Note that it doesn’t flag a file that parses but has noname. - Look for misspelled fields. Run
claude --debug, then search~/.claude/debug/<session-id>.txtfordoes not recognize or apply. The log names unrecognized top-level fields, because Claude Code ignores them without an error. - Delegate once and read the result. If the tools list resolves to nothing, the Agent tool returns an error that names the unresolved entries.
claude plugin validate .claude/agents
Where the tool list stops
A tool list narrows what a subagent is given. It doesn’t decide whether a Bash command the subagent runs is safe, and it doesn’t replace session-wide settings. To block specific commands for every session, read how to block destructive commands in Claude Code. To see which settings file wins when the same key appears in more than one place, read Claude Code settings precedence. For limits on which MCP servers a coding agent can reach, read how to restrict which MCP servers Claude Code can use. Revisit the list whenever you add an MCP server, because an entry for a whole server picks up every tool that server exposes. For the wider governance picture, see governance for AI coding agents.
Frequently asked questions
Does the tools field stop a Claude Code subagent from editing files?
It stops the edit tools when you leave them out of the list. The subagent-tools docs give an example with tools set to Read, Grep, Glob and Bash, and note that the subagent then has no Edit, Write or MCP tools. The same docs warn that it can still change files through Bash, so a subagent that must not write needs Bash left out as well.
What happens if every name in a subagent's tools list is misspelled?
The subagent usually fails to launch. The docs say that when no entry in the tools list resolves to a tool, the Agent tool returns an error that names the unresolved entries. Correct each entry to a tool name the docs list, then delegate to the subagent again to confirm it starts.
Which wins when disallowedTools and tools both name a tool?
The tool is removed. The docs say disallowedTools is applied first, and tools is then resolved against what remains, so a tool listed in both is taken out of the subagent. An entry with a specifier, such as Bash(git push *), still removes the whole Bash tool. To block one Bash command and keep Bash, add a Bash deny rule under permissions.deny.
Does a project subagent override a user subagent with the same name?
Yes. When several subagents share a name, Claude Code uses the one from the higher-priority location. Managed settings rank first, then the --agents flag, then .claude/agents/ in the project, then ~/.claude/agents/, then a plugin's agents directory. Keep names unique within one folder, because the /doctor checkup reports files that share a name.