Claude Code Code Mode: Tool Calls as Scripts
- Source
- code.claude.com
- Author
- ClaudeDevs
- Date

Context
Anthropic has added Code Mode to Claude Code as an experimental, opt-in way for the to use its tools, announcing it as scripts that chain tools together and let Claude keep answering while long commands run. Normally Claude asks for one tool call at a time, such as running a shell command, reading a file or editing one, and reads each result before choosing the next step. In Code Mode, according to the documentation, Claude instead writes a piece of JavaScript that makes the calls, and Claude Code runs it in the session. One program can run commands in parallel, feed one result into the next call, and return only the part of the output Claude needs to read. The documentation's example raises a retry limit by searching for the file, editing it and running its tests in four lines, returning just the file path and test output.
Anthropic suggests it for work made of many related calls: the same change across many files, a search whose results need filtering before Claude reads them, or several independent commands that can run at once. Long jobs can also run in the background for up to two hours while you keep talking to Claude, if the session started in auto or bypass-permissions mode; otherwise Claude waits and the code stops after ten minutes. You still see the individual tool calls, such as each edit's diff, while the code itself is in the transcript viewer.
The main trade-off is in how actions are checked. Each tool call inside the code still passes through your deny and ask rules and your PreToolUse hooks, scripts you set up to approve or block tool calls. But in auto mode, where a classifier decides what may run without asking, that classifier reviews each program before it runs rather than each call, and it cannot see values computed at run time, such as a path taken from search output. Anthropic advises keeping rules or hooks for calls you must control, and warns that a that inspects shell commands should check each part, because a push can arrive as a combined command like cd 'app' && git push.
Code Mode is off by default and may change or be removed. It arrived in Claude Code v2.1.323, is turned on with the CLAUDE_CODE_EXPERIMENTAL_CODE_MODE setting, and works only in an interactive terminal session with a Claude subscription or Console account and recent Claude models. It does not run through Amazon Bedrock, Google Cloud, Microsoft Foundry or other gateways, under HIPAA or zero data retention configurations, in the VS Code panel, the Desktop app, cloud sessions or the Agent SDK, and it disables Remote Control, Claude in Chrome and computer use. A Code Mode session can be resumed only with Code Mode still on, and administrators can block it for a whole organization.
- In Claude Code's experimental Code Mode, Claude writes one JavaScript program that makes its tool calls, so a single piece of code can run commands in parallel, feed one result into the next call, and return only the output Claude needs to read.
- In auto mode the classifier reviews each piece of code before it runs, not each tool call, and cannot see values computed at run time such as a path taken from search output; the docs advise keeping rules or hooks for calls that must be controlled.
- PreToolUse hooks that gate shell commands must check every part of a command: in Code Mode a git push in a folder named app can arrive as cd 'app' && git push. A hook matching the REPL tool can read the generated JavaScript from tool_input.code.
- Code that Claude waits on stops after ten minutes, including time spent at permission prompts. Background code can run up to two hours but needs a session started in auto or bypassPermissions mode.
- Code Mode requires v2.1.323 or later in an interactive terminal session on a Claude subscription or Console account; it does not work through gateways or cloud providers, with HIPAA or zero data retention, or with -p, the Agent SDK, the Desktop app or cloud sessions.
- AI agent — An AI system that doesn't just answer once but works toward a goal in a loop — taking actions, reading the results, and deciding what to do next.
- agent hook — A script the harness runs automatically at a fixed point in an agent's loop — before a tool call, after an edit, on session start.
Checking sign-in…
Loading comments…






