Claude Code’s Code Mode: What Changes Between Tool Calls

Claude can run several tool calls in one JavaScript step. See who can enable Code Mode, what reaches the model, and where approvals and redaction apply.

Published

Claude Code’s Code Mode: What Changes Between Tool Calls

Claude Code’s Code Mode is experimental and off by default as of November 2026. Claude writes JavaScript that can make several tool calls in one step and return just the result it needs. If you work across several MCP servers, consider how often Claude needs to think between calls and how often it just needs to carry a value from one call to the next.

How Code Mode changes a search, an edit and a test

Ask Claude to raise a retry limit. In an ordinary session, Claude requests a search, reads the result, chooses a file and requests an edit. It reads the edit result before deciding to run the test. In Anthropic’s Code Mode example, one program searches for the file containing retryPolicy, takes the first matching path, edits the limit in that file and runs the relevant test. The path and test output go back to Claude. The list of search results can stay in a JavaScript variable. Anthropic’s worked example

This can save a round trip to the model wherever a program can already specify the next call. Independent commands can also run in parallel. For context, the benefit comes from what the code leaves out. Consider that first matching path. If several files define retry policies and choosing the right one requires judgment, the useful thing to return is the list of candidates.

Apply the same reasoning to MCP. Suppose you want open issues whose linked changes still need review. If your tools expose those fields, a program could collect the issue references, look up the changes and return the matches. Ask why a particular review stalled, though, and Claude may need the full discussion. Decide what evidence the next decision needs before asking for a shorter result. How MCP connects tools · MCP vs CLI for repository work

Can your session run Code Mode?

Anthropic introduced Code Mode on November 12, 2026, in v2.1.323. Check the whole setup before changing your settings. Release entry · Current requirements

CheckRequirement
VersionClaude Code v2.1.323 or later on either release channel. Older builds start in ordinary mode and may show an account-availability message.
AccountA Claude subscription or Console account with a direct connection. Gateways, Amazon Bedrock, Claude Platform on AWS, Google Cloud’s Agent Platform, Microsoft Foundry and Claude Models on Google Cloud (Anthropic managed) are unsupported.
OrganizationNeither the HIPAA configuration nor zero data retention can be in use.
ModelClaude Opus 5.5, Sonnet 5.5, Haiku 5.5 or Fable 5.2.
SurfaceAn interactive terminal session launched with claude. The VS Code panel, Desktop app and cloud sessions are unsupported.
Agent teamsWith teams enabled, use v2.1.326 or later. Teammates use Code Mode in the default in-process display. Split-pane teammates start in ordinary mode.
InstallationUse the native build. On Windows, install Git for Windows.

An API key helper, OpenTelemetry export or settings that disable feature-flag fetching can also prevent startup. The troubleshooting table below maps those cases to their settings.

Turn it on for a session, then decide whether to keep it

Run the update command below only if your version is too old. If the stable channel hasn’t reached the minimum, wait for it or switch to latest.

Starting a Code Mode session on macOS, Linux or WSL

claude --version

claude update

CLAUDE_CODE_EXPERIMENTAL_CODE_MODE=1 claude

Code Mode (experimental) is on · this session can be resumed only with Code Mode on

On first use, select Yes, turn on Code Mode. In Windows PowerShell, set the variable and launch from the same shell. To keep the setting across launches on any supported platform, add it to your user settings.

Choose Code Mode for the next launch
Windows PowerShell

$env:CLAUDE_CODE_EXPERIMENTAL_CODE_MODE = "1"

claude

$env:CLAUDE_CODE_EXPERIMENTAL_CODE_MODE = "0"

User settings

{ "env": { "CLAUDE_CODE_EXPERIMENTAL_CODE_MODE": "1" } }

claude

{ "env": { "CLAUDE_CODE_EXPERIMENTAL_CODE_MODE": "0" } }

Project settings cannot enable Code Mode. For a first task, try Anthropic’s suggestion to check Markdown files for links to missing local files. The conversation shows the tool calls, including diffs for edits. Press Ctrl+O, expand a Code row to inspect the JavaScript, then press Ctrl+O to return.

To turn it off, remove the variable from your shell and user settings and start a new session, or set its value to 0. A zero in either place wins over a one in the other. To resume a Code Mode session, keep the value at 1 and use claude --continue or claude --resume in the terminal. An ordinary session resumes in ordinary mode even with the variable enabled. Environment variable reference

What gets approved when one program calls several tools?

Imagine a program that finds a path and passes it to an edit. Auto mode’s classifier reads the search and edit instructions before the program starts. The path first becomes known when the search runs. A rule or hook on the edit can check that actual call.

A path can become known after the code reviewWhere Claude Code checks a program, its calls and its output
From proposal to result
Before executionJavaScriptAuto mode reviews the proposed code.
At each tool callActual argumentsDeny and ask rules and PreToolUse hooks apply under the usual tool name.
Before Claude readsReturned outputA PostToolUse hook on REPL can redact the result.

As of Nov 22, 2026 · Source: Anthropic, Run tool calls from code with Code Mode

Every call goes through its usual deny and ask rules and PreToolUse hooks, including calls under an MCP tool’s name. Modes that normally prompt for a call still prompt. Auto and bypassPermissions can let a program finish without interruption, though certain actions always require approval. An ask rule for a specific shell command still prompts when its text matches. Shell hooks should inspect each component of a compound command. For filesystem or network limits that hold regardless of command text, use sandboxing. Permission checks · Claude Code auto mode

Read and approve each piece of JavaScript

Merge this rule into your user settings. A PreToolUse hook matching the same tool, REPL, can inspect the program in tool_input.code.

JSON
{
  "permissions": {
    "ask": ["REPL"]
  }
}

Start a new session. The approval prompt omits the code. Open the transcript with Ctrl+O, expand Code, then return to answer. The main conversation’s transcript does not show a subagent’s code. If the rule prevents a subagent from starting, Anthropic advises removing it.

Approving the program yourself in auto mode takes precedence over a classifier block. Project edits and read-only commands in the approved program can proceed without prompting. At a subsequent tool prompt that isn’t labeled as a subagent prompt, No without a comment, or Esc, stops the program. Completed edits stay in place. No with a comment refuses that call and lets the program continue with other work.

Where the sandbox ends

Configured shell sandbox limits apply to shell commands launched by the program. The JavaScript itself, file tools, web tools and MCP calls run outside that sandbox. For isolation that includes those operations, run Claude Code in a container or virtual machine. Strict sandbox mode keeps shell commands inside the sandbox when the program requests an exception. In auto mode the classifier reviews the requesting program, and the command receives no separate classifier review. Native Windows runs shell commands unsandboxed. Windows users who need the shell sandbox can use WSL2. Sandbox documentation

How long can code run, and how do you stop it?

While code runsWhat you can doTime limit
Claude waitsContinue the conversation after the program finishes. Press Esc while Claude is responding or waiting to stop the code.Ten minutes. From v2.1.328, time at a tool permission prompt in Manual or acceptEdits mode is excluded. Earlier versions counted it.
Code runs in the backgroundKeep talking. Once Claude finishes responding, open /tasks, select the task and press x to stop it.Up to two hours. Start the session in auto or bypassPermissions mode to enable this behavior.

After stopping code, check /tasks for shell commands, subagents or MCP calls it started. They can still be running. Select each one you want to stop and press x.

If a long test holds up the conversation, check how the session started. If you switched away from its starting permission mode, use Shift+Tab to return. If you started in another mode and auto mode is available, exit and run claude --continue --permission-mode auto with Code Mode enabled. If you supplied tool names via --tools, restart in auto mode without that flag. Before v2.1.328, picking a session from the resume list could also cause a wait. Update and resume again, or use --continue on the older build.

Redact the output before Claude reads it

Use a PostToolUse hook matching REPL. It receives tool_response when the program finishes, including background completion and errors. In Anthropic’s example, a program reads a notes file and returns a deploy token. The hook sends back a copy of the response with the sensitive value replaced. Anthropic’s redaction example

  1. Inspect result, stdout, stderr and error. Handle an absent or null result. An error can appear when code fails or stops. Set images or documents to [] if those attachments must be hidden.
  2. Return the copy in hookSpecificOutput.updatedToolOutput with hookEventName set to PostToolUse. Preserve the string types of code, stdout and stderr. Keep error a string or omit it. An invalid shape sends the original output through.
  3. Include the redacted copy even when the hook returns "decision": "block". Catch hook errors and emit a valid copy with placeholders. A crash, timeout or invalid JSON can expose the original output. Also account for refusedCalls, which can show Claude the original input of a refused call.
  4. Check the setup with a file containing a harmless sample value that matches the redaction rule. Ask Claude to read and quote the file, typing its path without @. Look for your replacement text in its reply.

Can you move a Code Mode session or leave it running?

A Code Mode session stays tied to the terminal and requires Code Mode to resume. Remote Control, Claude in Chrome and computer use are unavailable. You cannot move the session to Desktop, convert it to a background session or use /fork to launch a background copy. The background option above applies to a running piece of code inside the session. If you need to pick up the session from your phone, keep using ordinary tool calls. How Remote Control works · How always-on agents resume work

Block Code Mode across an organization

Put this in managed settings to enforce the block. An administrator can disable Code Mode organization-wide. Enabling it requires an individual opt-in. Managed settings

JSON
{
  "env": {
    "CLAUDE_CODE_EXPERIMENTAL_CODE_MODE": "0"
  }
}

An active Code Mode session continues until its user exits or restarts. After that, launches use ordinary mode and existing Code Mode sessions cannot resume while the block is in force.

Troubleshoot by the reason shown at startup

If Claude starts normally but says Code Mode is unavailable, read the reason on the startup line or run /status. After addressing the reason, start a new session. If there is no line at all, check claude --version, confirm the shell or user setting is 1, and look for a conflicting 0 there or in a file supplied with --settings. Startup and runtime troubleshooting

Reason shownWhat to check
Account access or versionUpdate if below v2.1.323. Otherwise check connectivity, restart and try another day if access is still unavailable.
Direct Anthropic API requiredCheck cloud routing, gateway settings and a custom ANTHROPIC_BASE_URL. Use a supported direct connection.
API key helperA direct sign-in or ANTHROPIC_API_KEY is supported. For this setup remove apiKeyHelper, ANTHROPIC_AUTH_TOKEN and any Authorization or X-Api-Key entry in ANTHROPIC_CUSTOM_HEADERS.
Unsupported modelStart with a listed model, for example --model opus. Haiku 5.5 and Fable 5.2 also work despite the message naming Opus and Sonnet.
Background jobStart in the foreground without --remote-control. For a teammate in a split pane, choose in-process display.
Downloaded settings neededCheck settings that disable feature-flag fetching, including DISABLE_TELEMETRY. Code Mode needs those downloads.
OpenTelemetry enabledIf your team can do without export, unset CLAUDE_CODE_ENABLE_TELEMETRY and ENABLE_BETA_TRACING_DETAILED.
Incompatible pluginOpen /plugin and disable the named plugin. For a centrally enabled plugin, ask its administrator.
Incompatible installed modDisable the mod that checks tool calls, or keep ordinary mode if you need that check.
Agent teams conflictUpdate to v2.1.326 or later or, to keep the older version, unset CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS.
Launch tool optionsCheck for --restricted, a --tools list missing REPL, or REPL in --disallowedTools or deny rules. A launch must permit the code runner.
Confirmation could not be savedCheck that your user can write to ~/.claude.json.
Organization settingsAsk the administrator about the managed block.

If the reason names a plugin, identify which parts of your workflow depend on it before deciding which to keep. Claude Superpowers skills and setup

A permission countdown expires

In auto mode, approving code yourself after repeated classifier blocks can trigger prompts for calls in that program and in earlier code still running. With no IDE connected, a countdown may appear. If it expires, Claude Code refuses the call and silently refuses later calls that would have shown a countdown. Send Claude a message to restore the prompts. Before v2.1.327, newer classifier-approved code could also trigger prompts for remaining calls in earlier code. Updating addresses that case.

A hook refuses a call or withholds output

Ask Claude for the error text. The hook did not finish means a timeout or an agent hook that returned no decision. Increase the timeout if the check needs longer, or move an agent check that gives no decision into a command hook. This can also affect later tool calls in the session.

The hook failed points to a launch, exit, HTTP or output error. Repair the hook. This message is uncommon from v2.1.329 onward, though feature-flag fetching stopping mid-session can trigger it. On those builds, failures other than an unfinished hook generally allow a call from code to proceed. For a guarding command or HTTP hook, set "onFailure": "block" to stop calls on timeout or failure. Use "continue" only when proceeding is the intended behavior.

UserPromptSubmit operation blocked by hook indicates an older hook received the program’s output as a prompt. Ask Claude to quote the message if all you see is a reason. Move any output checks to PostToolUse on REPL before updating to v2.1.328 or later. From that version even managed UserPromptSubmit hooks no longer receive code output. On an older build, a prompt hook can let that output through when the input’s source equals poll_event.

Who should switch on Code Mode?

Try it for one terminal session if you regularly filter large MCP responses, apply a known change across files or run independent checks. Choose a task whose desired return value you can name in advance, such as the paths of broken links. Inspect the Code row and ask whether the program returned enough evidence for Claude’s next decision.

Keep the plain tool-call loop when each result changes what you want Claude to investigate, when someone needs to judge each intermediate result, or when your workflow depends on a gateway, remote handoff or an incompatible policy check. Anthropic may change or remove the experiment. Its example gives no measured speedup or token-saving percentage to put into a budget.

Published
Category
Build
Related Articles
Augment Code Review

Augment Code Review

Should your team pay for Augment Code? See how it finds cross-repository dependencies, where its index stops, and how shared usage affects the bill.Nov 21, 2026Build
Vercel Board

Vercel Board

Set up Vercel Board for two agents and a developer. Track a fix through review, choose channel permissions, and sync the thread with Slack or GitHub.Nov 20, 2026Build
Gemini API Tool Retrieval: How an Agent Loads a Schema on Demand

Gemini API Tool Retrieval: How an Agent Loads a Schema on Demand

Follow a refund from schema search to function call, choose server-side or client-side retrieval, and see when deferring Gemini tools costs more.Nov 20, 2026Build
Genie 4 API: How One Live World Session Works, and What It Costs

Genie 4 API: How One Live World Session Works, and What It Costs

Genie 4 opened on the Gemini API on Nov 19, 2026. How one live world session runs, in Google's own code, what a minute costs and where it stops.Nov 19, 2026Build
MAI Code 2 in GitHub Copilot

MAI Code 2 in GitHub Copilot

Choose MAI Code 2 or Flash by the scope of a fix. Check which Copilot plans include each model, where to find the picker and how organization policy works.Nov 19, 2026Build
GitLab Alternatives in 2026: Gitea, GitHub, Forgejo, Bitbucket, Azure DevOps, Codeberg and OneDev

GitLab Alternatives in 2026: Gitea, GitHub, Forgejo, Bitbucket, Azure DevOps, Codeberg and OneDev

Compare seven GitLab alternatives by hosting, CI capacity, registry, security and seat price. See what each importer moves and which pipelines need rewriting.Nov 19, 2026Build
Social Media API in 2026: Zernio, Ayrshare, Phyllo and the Native APIs

Social Media API in 2026: Zernio, Ayrshare, Phyllo and the Native APIs

Compare Zernio, Ayrshare, Phyllo and four native APIs for publishing and creator data. See how customers connect and which features need approval.Nov 18, 2026Build
AGENTS.md vs CLAUDE.md

AGENTS.md vs CLAUDE.md

Which file should your coding agents read? See how Claude Code, Codex, Cursor and Copilot load instructions and how one import keeps team rules in sync.Nov 18, 2026Build
Newsletter

One letter, every Sunday.Working systems, not hot takes.

Weekly. No spam. Unsubscribe anytime.