New Tool Radar

AI Agents & Automation

How to Limit a Claude Code Subagent to Read-Only Tools

Set a tools allowlist on a Claude Code subagent so it can read, search and report but cannot change any file.

Schematic diagram with three steps: Open the subagent file, Set the tools allowlist, then Test a write attempt.

By default a subagent inherits every tool available in the main conversation. The tools field is an allowlist: list the tools the subagent may use and everything else is blocked. A read-only researcher needs only Read, Grep and Glob.

Before you start

You need a custom subagent file in .claude/agents. Decide the tool list before you edit: for a read-only agent, Read, Grep and Glob are enough, and Write, Edit and Bash stay out.

Add the tools allowlist to the frontmatter

Open the subagent file and add a tools line to the frontmatter, for example tools: Read, Grep, Glob. With no tools field a subagent inherits every tool; with the field set it gets only those. Do not use disallowedTools for this job: it removes tools from the inherited set, but an allowlist is clearer for a read-only agent.

Test by asking for a change the agent must refuse

Ask the subagent to fix a file it found. It should report the problem and stop, because it has no Write or Edit tool. If it edits the file anyway, the tools field is misspelled or in the wrong file.

Worked example: Read-only researcher for a fictional codebase

Maple Shop is a fictional online shop. Its researcher subagent finds where a feature lives. The table shows its tools.

Tool Allowed? Why
Read Yes Reads files to answer
Grep Yes Searches file contents
Glob Yes Finds files by name
Write No A researcher must not change files
Bash No No commands are needed to report

Expected result (UNTESTED): the researcher reports the file locations and refuses to edit, because Write and Edit are not in its tool list. We checked the Claude Code subagents guide, which describes the tools allowlist and the read-only researcher example, but we did not edit a subagent on this machine.

Limits

A tools allowlist is a permission boundary, not a sandbox: it stops the listed tools, but the subagent can still read any file the account can read. For sensitive code, limit what the main agent gives it as well. Check the allowlist after every edit to the file.

Sources

See all