Claude Code: restrict Haiku subagents to code exploration only
In Claude Code, Haiku subagents can be forced to read, search, and report on the codebase without making changes, leaving edits to the main agent.
In a Claude Code setup where Sonnet is the main model, Opus acts as an advisor, and Haiku runs subagents, it is recommended to use Haiku subagents exclusively for exploring the codebase.
You can force subagents into a read-only exploration mode while leaving all code changes to the main agent.
To do this, install two hooks:
- Subagents Explore Only — uses
SubagentStartto allow subagents only to read files, perform searches, and report results without modifying files. - Subagent Read Only Guard — uses
PreToolUseto block file writes and forbidden commands. If a subagent tries to change files, the hook blocks the action.
Install them with one command:
npx claude-code-templates --setting hooks/subagents-explore-only --hook security/subagent-read-only-guard
The main agent keeps its normal access rights, while subagents focus solely on exploring the codebase.
Why it matters
AnalysisThis reduces the risk of unintended code changes during automated exploration. It also enforces a clearer separation between research and write operations.
Discuss in community
Share your questions and insights with developers