Run tool calls from code with Code Mode changedcode-mode
Nearest release: v2.1.329, published an hour 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 19 Nov 2026 20:02 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 19 Nov 2026 20:07 UTC.
Upstream edited
Recorded here
Lines+47added
Lines−2removed
From line
144
where the diff opens
First seen
13 Nov 2026
this site's first read of the page
Recorded edits8to this page, all time
#### Require approval for a command #### Approve each piece of code first #### Answer a permission prompt while code runs ### Stop code in progress
The whole hunk
from line 144, old and new numbered
/
from line 144
144144
145145### Permission checks
146146
147When Claude runs code, each tool call in it goes through your `deny` and `ask` [permission rules](https://code.claude.com/docs/en/permissions.md) and your [`PreToolUse` hooks](https://code.claude.com/docs/en/hooks#pretooluse) under the tool's usual name, such as `Bash`. Beyond rules and hooks, a classifier reviews the code in auto mode, and you answer prompts in the modes that ask:
147In auto and `bypassPermissions` modes, code can run from start to finish without a permission prompt. Some calls still prompt you, such as the [actions no mode auto-approves](https://code.claude.com/docs/en/permission-modes.md#actions-no-mode-auto-approves).
148148
149Each tool call in the code goes through your `deny` and `ask` [permission rules](https://code.claude.com/docs/en/permissions.md) and [`PreToolUse` hooks](https://code.claude.com/docs/en/hooks#pretooluse) under the tool's usual name, such as `Bash` or an [MCP tool's name](https://code.claude.com/docs/en/permissions.md#mcp). Beyond rules and hooks, a classifier reviews the code in auto mode, and you answer prompts in the modes that ask:
150
149151* **[Auto mode](https://code.claude.com/docs/en/permission-modes.md#eliminate-prompts-with-auto-mode)**: the classifier reviews each piece of code before it runs, not each tool call. It doesn't see values computed at run time, such as a path taken from search output, so keep rules or hooks for calls you must control. You can still be [prompted when new code starts while earlier code runs](#permission-prompt-with-a-countdown)
150* **Other [permission modes](https://code.claude.com/docs/en/permission-modes.md)**: the code starts without a review, and you're prompted for each tool call that would prompt you in that mode
152* **Other [permission modes](https://code.claude.com/docs/en/permission-modes.md)**: you're prompted for each tool call that would prompt you in that mode
151153
152154If you have a `PreToolUse` hook that allows or blocks shell commands, make it check each part of a command, as [Bash rules do](https://code.claude.com/docs/en/permissions.md#compound-commands). In Code Mode, a `git push` in a folder named `app` can reach your hook as `cd 'app' && git push`.
153155
from line 159
157159>
158160> Bash rules match command text, so Claude can run a denied command [in a form the rule doesn't match](https://code.claude.com/docs/en/permissions.md#bash-rule-limits), with or without Code Mode. For limits that don't depend on command text, see [sandboxing](https://code.claude.com/docs/en/sandboxing.md).
159161
162#### Require approval for a command
163
164To see a prompt for a specific command in auto or `bypassPermissions` mode, add an `ask` rule for it. You're prompted for the [forms of the command that the rule matches](https://code.claude.com/docs/en/permissions.md#bash-rule-limits). To be prompted for commands that start with `git push`, save this rule in `~/.claude/settings.json`:
165
166```json theme={null}
167{
168 "permissions": {
169 "ask": ["Bash(git push *)"]
170 }
171}
172```
173
174To test the rule, start a new session in auto mode in a repository with no remote, and ask Claude to run `git push origin main`. You see a prompt for that command.
175
176#### Approve each piece of code first
177
178To read and approve code before it starts, add an `ask` rule for `REPL`, the tool that runs the code. Save this rule in `~/.claude/settings.json`:
179
180```json theme={null}
181{
182 "permissions": {
183 "ask": ["REPL"]
184 }
185}
186```
187
188To test the rule, start a new session and give Claude a task. You see a prompt that doesn't include the code. To read the code before you answer, press `Ctrl+O`, expand the **Code** row, and press `Ctrl+O` again to return. From the main conversation, you don't see a [subagent](https://code.claude.com/docs/en/sub-agents.md)'s code in that view.
189
190If you approve in auto mode, the code starts even when the classifier would have blocked it, and its project edits and read-only commands run without a prompt. If Claude reports that the code can't start a subagent, remove the rule.
191
192#### Answer a permission prompt while code runs
193
194To stop the code at a prompt for one of its tool calls, answer **No** without a comment. These results apply to prompts that aren't labeled as coming from a subagent:
195
196* **No, or `Esc`**: the code stops, and changes from calls that already finished stay in place
197* **No, with a [comment](https://code.claude.com/docs/en/permissions.md#add-a-comment-when-you-answer-a-permission-prompt)**: the call is refused, and the code can continue with its other calls
198
160199### Long-running code
161200
162201While code runs a long build or test, Claude either waits for it or lets it continue in the background:
from line 209
170209* **You started in another mode**: if [auto mode is available](https://code.claude.com/docs/en/permission-modes.md#eliminate-prompts-with-auto-mode) to you, exit, then run `claude --continue --permission-mode auto` with Code Mode on
171210* **You're on a version before v2.1.328 and picked the session from the `claude --resume` list**: exit, [update Claude Code](https://code.claude.com/docs/en/setup.md#update-claude-code), then run the same `claude --resume` command with Code Mode on. To stay on your version, replace `--resume` with `--continue`
172211* **You passed tool names to `--tools`**: start again in auto mode without that flag
212
213### Stop code in progress
214
215To stop code while Claude is responding or waiting for the code, press `Esc`. To stop background code after Claude finishes responding, run [`/tasks`](https://code.claude.com/docs/en/commands) in the session, select the running task, and press `x`.
216
217After you stop the code, check `/tasks` for [subagents](https://code.claude.com/docs/en/sub-agents.md), [shell commands](https://code.claude.com/docs/en/interactive-mode.md#background-bash-commands), and [MCP calls](https://code.claude.com/docs/en/mcp.md#automatic-backgrounding-of-long-tool-calls) that the code started and that are still running. To stop one, select it and press `x`.
173218
174219### Check code output with a hook
175220
No line in this hunk matches that.