Follow Discord
Sweep 20 Nov 2026 · 19:55Z Build v2.1.330 547 read Stable v2.1.323 Latest v2.1.330 Next v2.1.330 Feeds RSS JSON llms.txt llms-full.txt Unofficial
One change · claude-code

Create custom subagents changedsub-agents

Nearest release: v2.1.330, published 21 hours before upstream edited the page. Shown because the two are within 24 hours of each other. Nothing here says the release caused the edit.

Upstream edited this page at 21 Nov 2026 17:00 UTC, give or take a minute or two: the time comes from Anthropic’s own sitemap rather than from a commit. This site recorded the change at 21 Nov 2026 17:07 UTC.

Upstream edited
Recorded here
Lines+36added
Lines−35removed
From line 26 where the diff opens
First seen 14 Aug 2026 this site's first read of the page
Recorded edits112to this page, all time

The whole hunk

from line 26, old and new numbered
/
lines
from line 26
2626 
2727Claude Code includes built-in subagents that Claude automatically uses when appropriate. Each inherits the parent conversation's permission rules; most run with a restricted tool set.
2828 
29Explore and Plan start without your CLAUDE.md files and the git status snapshot to keep research fast and inexpensive. Other built-in and [custom subagents](#configure-subagents) load both, unless you set [`omitClaudeMd`](#supported-frontmatter-fields) in a custom subagent's definition to start it without the user, project, and local CLAUDE.md files. For the full breakdown of what reaches a subagent, see [what loads at startup](#what-loads-at-startup).
29Explore and Plan start without your CLAUDE.md files and the git status snapshot to keep research fast and inexpensive. For the full breakdown of what reaches a subagent, see [what loads at startup](#what-loads-at-startup).
3030 
3131> [tab] Explore
3232>
from line 66
6666 
6767> [tab] Other
6868>
69> Claude Code includes additional helper agents for specific tasks. These are typically invoked automatically, so you don't need to use them directly.
69> Claude Code includes additional helper agents for specific tasks.
7070>
7171> | Agent | Model | When Claude uses it |
7272> | :- | :- | :- |
from line 73
7373> | claude | None of its own; follows the [model order](#choose-a-model) when Claude spawns it as a subagent | When a task doesn't fit a more specialized agent. A catch-all with every tool [available to subagents](#available-tools). Also the default agent for a dispatched [background session](https://code.claude.com/docs/en/agent-view.md); [which permission mode it starts in](https://code.claude.com/docs/en/agent-view.md#permission-mode-model-and-effort) depends on how the session was started |
7474> | statusline-setup | Sonnet | When you run `/statusline` to configure your status line |
7575> | claude-code-guide | Haiku | When you ask questions about Claude Code features |
76> | web-fetch | Haiku, or the model of the conversation that starts it [when it can't use Haiku](https://code.claude.com/docs/en/tools-reference.md#which-model-the-web-fetch-subagent-runs-on) | When Claude reads a web page in a [session that uses this subagent](https://code.claude.com/docs/en/tools-reference.md#web-fetch-subagent) |
7677 
7778Built-in subagents are registered by default in interactive sessions. To restrict them:
7879 
from line 84
8384 
8485An Agent tool call that omits `subagent_type` fails with [`subagent_type is required`](https://code.claude.com/docs/en/errors#subagent-type-is-required) when the session has no `general-purpose` subagent to fall back on.
8586 
86Beyond these built-in subagents, you can create your own with custom prompts, tool restrictions, permission modes, hooks, and skills. The following sections show how to get started and customize subagents.
87Beyond these built-in subagents, you can create your own with custom prompts, tool restrictions, permission modes, hooks, and skills.
8788 
8889## Quickstart: create your first subagent
8990 
from line 137
136137 
137138You now have a subagent you can use in any project on your machine to analyze codebases and suggest improvements.
138139 
139You can also write subagent files by hand, define them via CLI flags, or distribute them through plugins. The following sections cover all configuration options.
140 
141140> [!NOTE]
142141>
143142> Running `/agents` prints a reminder to ask Claude or edit `.claude/agents/` and `~/.claude/agents/` directly.
from line 144
145144 
146145## Configure subagents
147146 
148A subagent's file location determines who it's available to, and its frontmatter determines what it can do. This section covers where subagent files live and every field they support.
147A subagent's file location determines who it's available to, and its frontmatter determines what it can do.
149148 
150149### Choose the subagent scope
151150 
from line 303
304303| `mcpServers` | No | [MCP servers](https://code.claude.com/docs/en/mcp.md) available to this subagent. Each entry is either a server name referencing an already-configured server (e.g., `"slack"`) or an inline definition with the server name as key and a full [MCP server config](https://code.claude.com/docs/en/mcp.md#installing-mcp-servers) as value. Ignored for [plugin subagents](#choose-the-subagent-scope) |
305304| `hooks` | No | [Lifecycle hooks](#define-hooks-for-subagents) scoped to this subagent. Ignored for [plugin subagents](#choose-the-subagent-scope) |
306305| `memory` | No | [Persistent memory scope](#enable-persistent-memory): `user`, `project`, or `local`. Enables cross-session learning |
307| `background` | No | Set to `true` to keep this subagent in the background even when Claude asks to wait for it. By default, subagents Claude spawns from the main conversation already [start in the background](#run-subagents-in-foreground-or-background) |
306| `background` | No | Set to `true` to keep this subagent in the background even when Claude asks to wait for it. By default, custom subagents Claude spawns from the main conversation already [start in the background](#run-subagents-in-foreground-or-background) |
308307| `omitClaudeMd` | No | Set to `true` to start this subagent without the user, project, and local CLAUDE.md files in its [initial context](#what-loads-at-startup); [managed policy files](https://code.claude.com/docs/en/memory.md#how-claude-md-files-load) still load, except for [managed subagents](#choose-the-subagent-scope). Use it for subagents that take everything they need from the delegation prompt. Ignored when the agent runs as the main session agent via `--agent` or the `agent` setting. Requires Claude Code v2.1.271 or later |
309308| `effort` | No | Effort level when this subagent is active. Overrides the session effort level, but not the [`CLAUDE_CODE_EFFORT_LEVEL`](https://code.claude.com/docs/en/env-vars#variables) environment variable. Options: `low`, `medium`, `high`, `xhigh`, `max`; available levels depend on the model. See [Choose an effort level](#choose-an-effort-level) |
310309| `isolation` | No | Set to `worktree` to run the subagent in a temporary [git worktree](https://code.claude.com/docs/en/worktrees.md), giving it an isolated copy of the repository branched by default from your [default branch](https://code.claude.com/docs/en/worktrees.md#choose-the-base-branch) rather than the parent session's `HEAD`. The worktree is automatically cleaned up if the subagent makes no changes |
from line 406
407406 
408407#### When an allowlist blocks a subagent model
409408 
410If your organization's [`availableModels`](https://code.claude.com/docs/en/model-config#restrict-model-selection) allowlist blocks the model set for a subagent, the subagent runs on the first of these that applies:
409If your organization's [`availableModels`](https://code.claude.com/docs/en/model-config#restrict-model-selection) allowlist blocks the model set for a subagent other than [`web-fetch`](https://code.claude.com/docs/en/tools-reference#which-model-the-web-fetch-subagent-runs-on), the subagent runs on the first of these that applies:
411410 
4124111. For a blocked family alias, the newest permitted version in that family, on [providers that support this substitution](https://code.claude.com/docs/en/model-config.md#restrict-model-selection)
4134122. The model in `CLAUDE_CODE_SUBAGENT_MODEL`, if you set it, under these same rules
from line 464
465464 
466465Teammates in [agent teams](https://code.claude.com/docs/en/agent-teams.md) additionally keep the task tools and cron tools: `TaskCreate`, `TaskGet`, `TaskList`, `TaskUpdate`, `CronCreate`, `CronDelete`, and `CronList`. In a [session without the Task tools](https://code.claude.com/docs/en/tools-reference.md#task-tool-availability), Claude Code doesn't provide the task tools to subagents either, even when the subagent runs a different model. An in-process teammate follows your session the same way. To find out whether a split-pane teammate has the task tools, see [Task tool availability](https://code.claude.com/docs/en/tools-reference.md#task-tool-availability).
467466 
467> [!NOTE]
468>
469> In a session where Claude reads web pages through the built-in [`web-fetch` subagent](https://code.claude.com/docs/en/tools-reference#web-fetch-subagent), the main conversation has no `WebFetch` tool of its own, and neither do [forks](#fork-the-current-conversation) or [teammates](https://code.claude.com/docs/en/agent-teams.md). Other subagents that Claude starts with the Agent tool can still call `WebFetch` themselves.
470 
468471#### Restrict which tools a subagent can use
469472 
470473To restrict tools, use the `tools` field as an allowlist or the `disallowedTools` field as a denylist. If both are set, `disallowedTools` is applied first, then `tools` is resolved against the remaining pool. A tool listed in both is removed.
471474 
472This example uses `tools` to allow only Read, Grep, Glob, and Bash. The subagent can't edit files, write files, or use any MCP tools:
475This example uses `tools` to allow only Read, Grep, Glob, and Bash. The subagent has no Edit, Write, or MCP tools but can still change files through Bash:
473476 
474477```yaml theme={null}
475478---
from line 583
580583 
581584Inline definitions use the same schema as `.mcp.json` server entries, keyed by the server name, and support the `stdio`, `http`, `sse`, and `ws` types.
582585 
583To keep an MCP server out of the main conversation entirely and avoid its tool descriptions consuming context there, define it inline here rather than in `.mcp.json`. The subagent gets the tools; the parent conversation doesn't.
586To keep an MCP server out of the main conversation entirely and avoid its tool descriptions consuming context there, define it inline here rather than in `.mcp.json`.
584587 
585588The MCP restrictions that apply to the main session also cover servers declared in subagent frontmatter:
586589 
from line 614
611614 
612615The main conversation's permission mode decides whether Claude Code uses the value you set:
613616 
614* When the main conversation is in `bypassPermissions`, `acceptEdits`, or [auto mode](https://code.claude.com/docs/en/permission-modes.md#eliminate-prompts-with-auto-mode), the subagent runs in that same mode and Claude Code ignores the `permissionMode` you set. Under auto mode, the classifier evaluates the subagent's tool calls with the main conversation's block and allow rules. When the subagent finishes, the classifier also reviews its work and its final report before the report is delivered, as [How auto mode handles subagents](https://code.claude.com/docs/en/permission-modes.md#eliminate-prompts-with-auto-mode) describes.
617* When the main conversation is in `bypassPermissions`, `acceptEdits`, or [auto mode](https://code.claude.com/docs/en/permission-modes.md#eliminate-prompts-with-auto-mode), your subagent runs in that same mode and Claude Code ignores the `permissionMode` you set.
615618 
619 Under auto mode, the classifier evaluates your subagent's tool calls with the main conversation's block and allow rules. When a subagent that Claude started with the Agent tool finishes, the classifier also reviews its work and its final report before the report is delivered. This review runs for a subagent other than an [agent team](https://code.claude.com/docs/en/agent-teams.md) teammate. See [How auto mode handles subagents](https://code.claude.com/docs/en/permission-modes.md#eliminate-prompts-with-auto-mode).
620 
616621 If a subagent asks for permission while the main conversation is in `bypassPermissions`, check whether its tool call is one of the [actions no mode auto-approves](https://code.claude.com/docs/en/permission-modes.md#actions-no-mode-auto-approves).
617622* When the main conversation is in `plan` mode, the subagent stays in plan mode whichever `permissionMode` you set, unless it runs as an [agent team teammate](#subagent-names) under the [agent teams rules](https://code.claude.com/docs/en/agent-teams.md#have-teammates-plan-before-implementing). If you set `dontAsk`, the subagent also doesn't prompt you: an action that plan mode would ask you to approve is denied instead.
618623* When the main conversation is in `default` or `dontAsk` mode, the subagent runs in the permission mode you set. It keeps the main conversation's permission mode instead in these cases:
from line 696
691696 
692697* `project` is the recommended default scope. It makes subagent knowledge shareable via version control.
693698* Ask the subagent to consult its memory before starting work: "Review this PR, and check your memory for patterns you've seen before."
694* Ask the subagent to update its memory after completing a task: "Now that you're done, save what you learned to your memory." Over time, this builds a knowledge base that makes the subagent more effective.
699* Ask the subagent to update its memory after completing a task: "Now that you're done, save what you learned to your memory."
695700* Include memory instructions directly in the subagent's markdown file so it proactively maintains its own knowledge base:
696701 
697702 ```markdown theme={null}
from line 779
774779Subagents can define [hooks](https://code.claude.com/docs/en/hooks.md) that run during the subagent's lifecycle. There are two ways to configure hooks:
775780 
776781* **In the subagent's frontmatter**: define hooks that run only while that subagent is active
777* **In `settings.json`**: define session-wide hooks that also fire inside subagents. Tool events such as `PreToolUse` and `PostToolUse` fire for the subagent's tool calls the same way they do in the main conversation, and `SubagentStart` and `SubagentStop` fire when a subagent starts or finishes
782* **In `settings.json`**: define session-wide hooks that also fire inside subagents. Tool events such as `PreToolUse` and `PostToolUse` fire for the subagent's tool calls the same way they do in the main conversation
778783 
779Hooks from [settings files, managed policy settings, and plugins](https://code.claude.com/docs/en/hooks.md#hook-locations) all apply inside subagents, so a `PreToolUse` hook in `settings.json` also runs before every tool a subagent uses.
784Hooks on tool events from [settings files, managed policy settings, and plugins](https://code.claude.com/docs/en/hooks.md#hook-locations) all apply inside subagents.
780785 
781786#### Hooks in subagent frontmatter
782787 
783Define hooks directly in the subagent's markdown file. These hooks only run while that specific subagent is active and are cleaned up when it finishes.
788Define hooks directly in the subagent's markdown file.
784789 
785790> [!NOTE]
786791>
from line 823
818823---
819824```
820825 
821When the agent is invoked as a subagent, `Stop` hooks in frontmatter are automatically converted to `SubagentStop` events.
822 
823826#### Project-level hooks for subagent events
824827 
825828Configure hooks in `settings.json` that respond to subagent lifecycle events in the main session.
from line 834
831834 
832835Both events support matchers to target specific agent types by name. The matcher value is the agent's frontmatter `name` for project-level and user-level subagents, or the plugin-scoped identifier such as `my-plugin:db-agent` for [plugin subagents](https://code.claude.com/docs/en/plugins/components.md#agents). A scoped name contains a colon, so it is evaluated as an [unanchored regular expression](https://code.claude.com/docs/en/hooks.md#matcher-patterns); anchor it with `^` and `$`, as in `^my-plugin:db-agent$`, to match only that agent.
833836 
834This example runs a setup script only when the `db-agent` subagent starts, and a cleanup script when any subagent stops:
837This example runs a setup script only when the `db-agent` subagent starts, and a cleanup script when subagents stop:
835838 
836839```json theme={null}
837840{
from line 858
855858}
856859```
857860 
858See [Hooks](https://code.claude.com/docs/en/hooks.md) for the complete hook configuration format.
861See [Hooks](https://code.claude.com/docs/en/hooks.md) for the complete hook configuration format, and [the `web-fetch` subagent](https://code.claude.com/docs/en/tools-reference#web-fetch-subagent) for an exception.
859862 
860863## Work with subagents
861864 
from line 942
939942 
940943#### Which subagents run in the background
941944 
942With nothing configured, a subagent that Claude spawns from your main conversation starts in the background.
945With nothing configured, a subagent other than [`web-fetch`](https://code.claude.com/docs/en/tools-reference#web-fetch-subagent) that Claude spawns from your main conversation starts in the background.
943946 
944947* **`claude -p` and the Agent SDK**: Claude can wait, on its own judgment or when you ask.
945948* **Interactive terminal session, VS Code, and desktop app sessions on your machine**: to let Claude wait for a subagent, [turn off fork mode](#let-claude-wait-for-a-subagent), which is [on by default](#turn-fork-mode-on-or-off).
from line 998
995998 
996999### API errors in subagents
9971000 
998When something [cuts off a subagent's response mid-stream](https://code.claude.com/docs/en/errors.md#the-response-above-may-be-incomplete), and the partial response contains text but no tool calls, Claude Code prompts the subagent to continue rather than ending the run. This happens in interactive sessions too. The run ends on the error only once those continuations are used up.
999 
10001001A subagent whose run ends on an API error, such as a usage limit or a repeated server error, reports that failure back to Claude. What Claude receives depends on where the subagent ran:
10011002 
10021003* **Foreground**: if a rate limit, overload, or server error cuts off a subagent that already produced text output, the Agent tool returns that partial output with a note that the subagent was cut off and didn't finish its task. A subagent that produced nothing, or whose only output was tool calls, fails with [`Agent terminated early due to an API error`](https://code.claude.com/docs/en/errors#agent-terminated-early-due-to-an-api-error), followed by the error detail.
from line 1044
10431044Research the authentication, database, and API modules in parallel using separate subagents
10441045```
10451046 
1046Each subagent explores its area independently, then Claude synthesizes the findings. This works best when the research paths don't depend on each other.
1047Each subagent explores its area independently, then Claude synthesizes the findings.
10471048 
10481049> [!WARNING]
10491050>
from line 1106
11051106 
11061107### Concurrent subagent limit
11071108 
1108Two limits control subagent use, each with its own variable: this one stops Claude from spawning more subagents while too many are running, and the [depth limit](#let-subagents-spawn-their-own-subagents) caps how deeply subagents nest. There's no limit on the total number of subagents Claude can spawn over a session.
1109 
11101109By default, when 20 subagents are running in a session, spawning another with the Agent tool fails with `Concurrent subagent limit reached`, and the error tells Claude not to retry. Spawning succeeds again when the running count drops below the limit. To change the limit, set [`CLAUDE_CODE_MAX_CONCURRENT_SUBAGENTS`](https://code.claude.com/docs/en/env-vars) to any positive whole number. Sessions with [ultracode](https://code.claude.com/docs/en/model-config.md#adjust-effort-level) active are exempt: the limit isn't enforced there. Requires Claude Code v2.1.217 or later.
11111110 
11121111The limit blocks only subagents Claude spawns with the Agent tool, but other runs occupy the same slots:
from line 1115
11161115 
11171116Agents that other features run, such as [workflow](https://code.claude.com/docs/en/workflows.md) agents and [agent team](https://code.claude.com/docs/en/agent-teams.md) teammates, follow their own limits instead.
11181117 
1118There's no limit on the total number of subagents Claude can spawn over a session.
1119 
11191120### Manage subagent context
11201121 
11211122#### What loads at startup
from line 1125
11241125 
11251126A non-fork subagent's initial context contains:
11261127 
1127* **System prompt**: the agent's own prompt plus environment details that Claude Code appends, not the Claude Code system prompt. Custom subagents define theirs in the [markdown body](#write-subagent-files) or `prompt` field. Built-in agents have predefined prompts.
1128* **System prompt**: the agent's own prompt plus environment details that Claude Code appends, not the Claude Code system prompt. Custom subagents define theirs in the [markdown body](#write-subagent-files) or `prompt` field.
11281129* **Task message**: the delegation prompt Claude writes when it hands off the work.
1129* **CLAUDE.md files**: every level of the [CLAUDE.md hierarchy](https://code.claude.com/docs/en/memory.md#how-claude-md-files-load) the main conversation loads, including `~/.claude/CLAUDE.md`, project rules, `CLAUDE.local.md`, managed policy files, and any [`AGENTS.md` files](https://code.claude.com/docs/en/memory#agents-md) loaded as project instructions. The built-in Explore and Plan agents skip this. A subagent whose definition sets [`omitClaudeMd`](#supported-frontmatter-fields) loads only the managed policy files, or none at all when the definition comes from [managed settings](#choose-the-subagent-scope).
1130* **CLAUDE.md files**: every level of the [CLAUDE.md hierarchy](https://code.claude.com/docs/en/memory.md#how-claude-md-files-load) the main conversation loads, including `~/.claude/CLAUDE.md`, project rules, `CLAUDE.local.md`, managed policy files, and any [`AGENTS.md` files](https://code.claude.com/docs/en/memory#agents-md) loaded as project instructions. The built-in Explore, Plan, and [`web-fetch`](https://code.claude.com/docs/en/tools-reference#web-fetch-subagent) agents skip this. A subagent whose definition sets [`omitClaudeMd`](#supported-frontmatter-fields) loads only the managed policy files, or none at all when the definition comes from [managed settings](#choose-the-subagent-scope).
11301131* **Git status**: a snapshot Claude Code reads from your repository when the subagent starts. For a subagent in [its own worktree](https://code.claude.com/docs/en/worktrees.md#isolate-subagents-with-worktrees) of that repository, the snapshot shows the worktree's branch, status, and recent commits. Absent outside a Git repository or whenever the snapshot is turned off; see [`includeGitInstructions`](https://code.claude.com/docs/en/settings-reference#includegitinstructions). Explore and Plan skip it regardless.
11311132* **Preloaded skills**: full content of any skill named in the agent's [`skills` field](#preload-skills-into-subagents). Built-in agents don't preload skills.
11321133* **Sibling roster**: a [system reminder](https://code.claude.com/docs/en/glossary.md#system-reminder) listing `main` and every other named agent in the session, each a valid `to` value for [`SendMessage`](#resume-subagents). The roster appears only when the subagent's tools include `SendMessage` and at least one other agent has a name, whether Claude named it when spawning it or it runs as an [agent team](https://code.claude.com/docs/en/agent-teams.md) teammate. It is a snapshot taken when the subagent starts, so agents named later don't appear.
from line 1136
11351136 
11361137The main conversation still has your full CLAUDE.md when it reads these subagents' results, so most rules don't need to reach the subagent itself. If a rule must, such as "ignore the `vendor/` directory," restate it in the prompt you give Claude when delegating.
11371138 
1138You can't change which subagents receive git status. Only Explore and Plan skip it.
1139You can't change which subagents receive git status.
11391140 
11401141Some main-conversation state never reaches a non-fork subagent:
11411142 
from line 1259
12581259/subtask draft unit tests for the parser changes so far
12591260```
12601261 
1261The fork appears in a panel below your prompt and runs in the background while you keep working. When it finishes, its result arrives as a message in your main conversation. The next section covers the panel controls for watching and steering forks while they run.
1262The fork appears in a panel below your prompt and runs in the background while you keep working. When it finishes, its result arrives as a message in your main conversation.
12621263 
12631264### Observe and steer running forks
12641265 
from line 1303
13021303* **Stop forks only**: add `"Agent(fork)"` to `permissions.deny` in your [settings](#disable-specific-subagents).
13031304* **Turn fork mode off**: set `CLAUDE_CODE_FORK_SUBAGENT` to `0`, following the steps in [Let Claude wait for a subagent](#let-claude-wait-for-a-subagent).
13041305 
1305While fork mode is on, Claude also can't [wait for a subagent](#run-subagents-in-foreground-or-background) in interactive terminal, VS Code, or desktop sessions on your machine. Fork mode is on by default from Claude Code v2.1.302, and in an interactive terminal session from v2.1.232.
1306While fork mode is on, Claude also can't [wait for a subagent](#run-subagents-in-foreground-or-background) other than [`web-fetch`](https://code.claude.com/docs/en/tools-reference#web-fetch-subagent) in interactive terminal, VS Code, or desktop sessions on your machine. Fork mode is on by default from Claude Code v2.1.302, and in an interactive terminal session from v2.1.232.
13061307 
13071308## Example subagents
13081309 
from line 1320
13191320 
13201321### Code reviewer
13211322 
1322A read-only subagent that reviews code without modifying it. This example shows how to design a focused subagent with limited tool access that excludes Edit and Write, and a detailed prompt that specifies exactly what to look for and how to format output.
1323A subagent that reviews code without the Edit and Write tools. It can still change files through Bash.
13231324 
13241325```markdown theme={null}
13251326---
from line 1357
13561357 
13571358### Debugger
13581359 
1359A subagent that can both analyze and fix issues. Unlike the code reviewer, this one includes Edit because fixing bugs requires modifying code. The prompt provides a clear workflow from diagnosis to verification.
1360A subagent that can both analyze and fix issues. Unlike the code reviewer, this one includes Edit because fixing bugs requires modifying code.
13601361 
13611362```markdown theme={null}
13621363---
from line 1394
13931394 
13941395### Data scientist
13951396 
1396A domain-specific subagent for data analysis work. This example shows how to create subagents for specialized workflows outside of typical coding tasks. It explicitly sets `model: sonnet` for more capable analysis.
1397A domain-specific subagent for data analysis work. It explicitly sets `model: sonnet` for more capable analysis.
13971398 
13981399```markdown theme={null}
13991400---
from line 1491
14901491 
14911492On Windows, write the validation script in PowerShell and add `shell: powershell` to the hook entry. See [running hooks in PowerShell](https://code.claude.com/docs/en/hooks.md#windows-powershell-tool).
14921493 
1493The hook receives JSON via stdin with the Bash command in `tool_input.command`. Exit code 2 blocks the operation and feeds the error message back to Claude. See [Hooks](https://code.claude.com/docs/en/hooks.md#exit-code-output) for details on exit codes and [Hook input](https://code.claude.com/docs/en/hooks.md#pretooluse-input) for the complete input schema.
1494See [Hooks](https://code.claude.com/docs/en/hooks.md#exit-code-output) for details on exit codes and [Hook input](https://code.claude.com/docs/en/hooks.md#pretooluse-input) for the complete input schema.
14941495 
14951496The system prompt tells the subagent to refuse write requests, so the hook is a backstop: if the subagent attempts a write anyway, Claude Code blocks the command and the subagent sees the `Blocked: Write operations not allowed. Use SELECT queries only.` message.
14961497 
Feedback