Skip to content
←All articles
AI Tools8 min read

Claude Code Code Mode: Claude writes JavaScript instead of calling tools one by one

Since November 12, 2026 Claude Code has an experimental Code Mode: Claude writes JavaScript that makes several tool calls at once. Setup, limits, permissions.

On November 12, 2026 Anthropic shipped Claude Code v2.1.323 with Code Mode, an experimental mode in which Claude writes a piece of JavaScript that makes several tool calls in one step, instead of asking for one tool at a time and reading each result. It is off by default, works only in the terminal with the Anthropic API, and can be blocked organization-wide.

In sintesi

  • Code Mode landed in Claude Code v2.1.323 (November 12, 2026), is experimental and off by default. Turn it on with CLAUDE_CODE_EXPERIMENTAL_CODE_MODE=1.
  • Claude writes JavaScript that runs commands in parallel, feeds one result into the next call and returns only the part of the output it needs.
  • Every call the code makes still goes through your deny and ask rules and PreToolUse hooks. In auto mode, though, the classifier reviews the code, not each tool call.
  • It does not work with Bedrock, gateways, -p, the Agent SDK, VS Code, Desktop, cloud sessions, or organizations on ZDR or HIPAA. Code stops after 10 minutes, or 2 hours in the background.
  • The idea is not new: Anthropic described it for MCP in November 2025, and Cloudflare ships a @cloudflare/codemode package.

What changes compared with direct tool calls

Without Code Mode, Claude requests a tool call (Bash, Read, Edit), reads the result and decides the next step. With Code Mode it writes a program that makes the calls, and Claude Code runs it in your session. The official Code Mode documentation says a single piece of code can run commands in parallel, use one result in the next call and return just the part of the output Claude needs to read.

The docs' example raises a retry limit: it finds the file, edits it, runs the tests, and the last line hands the path and test output back to Claude.

const files = await $`rg -l "function retryPolicy" src`.text();
const target = files.trim().split("\n")[0];
await edit(target, "maxAttempts: 3", "maxAttempts: 5");
({ edited: target, tests: $`npm test -- retryPolicy`.nothrow() });

In the conversation you see the tool calls (the diff of the edit, for example) and not the code. Press Ctrl+O to read it: each snippet shows up as a collapsed Code row in the transcript viewer.

Why Anthropic got here

The reasoning is about tokens. In the engineering post Code execution with MCP (November 4, 2025) Anthropic names two costs of direct calls: tool definitions take up context, and every intermediate result passes through the model. Its Google Drive to Salesforce example drops from about 150,000 to 2,000 tokens, a 98.7% reduction. That is a vendor figure for a scenario they built, not a measurement of Claude Code's Code Mode, and I have not verified it.

The same post notes that Cloudflare found similar results under the name "Code Mode". The Cloudflare Agents repository includes the @cloudflare/codemode package, described as "LLMs write executable code that calls your tools, instead of one tool call at a time". So Claude Code's Code Mode brings an existing pattern into a widely used coding agent.

How to turn it on and try it

You need Claude Code v2.1.323 or later, a Claude or Console account and the native build. Check with claude --version and update with claude update. Then start the session with the variable:

CLAUDE_CODE_EXPERIMENTAL_CODE_MODE=1 claude

To have it in every session, put it in your user file ~/.claude/settings.json:

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

Claude Code ignores this variable in a project's settings files, so a cloned repository cannot switch it on for you. On first start it asks for confirmation and shows Code Mode (experimental) is on at the top. The docs suggest trying it on a task with many related calls, for example: "Read every Markdown file in this project and list the links that point to local files that don't exist."

To resume a Code Mode session with --continue or --resume, the variable must stay at 1, otherwise Claude Code refuses to resume it.

Requirements and limits

Code Mode has a lot of constraints, and for many companies they are enough to rule it out today. Summary from the documentation:

AreaStatus
ModelsClaude Opus 5.5, Sonnet 5.5, Haiku 5.5, Fable 5.2
ProvidersAnthropic API only: no Bedrock, gateway, Claude Platform on AWS, Google Cloud, Microsoft Foundry
SurfacesInteractive claude in a terminal only: no -p, Agent SDK, VS Code, Desktop, cloud sessions
OrganizationNot available with the HIPAA configuration or zero data retention
TelemetryWon't start with an API key helper, agent teams, OpenTelemetry export or DISABLE_TELEMETRY
DurationCode stops after 10 minutes when Claude waits, up to 2 hours in the background
FeaturesNo Remote Control, Claude in Chrome, computer use; the session can't move to Desktop

The provider point matters if you reach Claude Code through Bedrock or an internal gateway: Code Mode will not start, with the message it only works with the Anthropic API. Teams that run OpenTelemetry for cost monitoring have to choose, because the two don't coexist today.

Permissions and security: what actually changes

Every call the code makes still goes through your deny and ask rules and PreToolUse hooks, so you don't have to rewrite matchers for tools like Bash. The change is in auto mode: the classifier reviews the code before it runs, not each call, and it can't see values computed at run time, such as a path taken from search output. The docs recommend keeping rules or hooks for calls you must control.

To inspect the code, write a PreToolUse hook that matches REPL, the tool that runs Claude's code, and read the JavaScript from tool_input.code. Two warnings from the same page. Bash rules match command text, so a denied command can slip through in a form the rule doesn't recognize, with or without Code Mode: for limits that don't depend on command text you need sandboxing. And if a PreToolUse hook fails or times out, the call is refused even when onFailure is unset. Set "onFailure": "continue" only where you accept the risk.

How to block it organization-wide

An administrator can prevent its use through managed settings. A value of 0 always wins over a 1 set elsewhere:

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

Anyone already in a Code Mode session stays in it until they exit. After a restart they can't resume those sessions while the 0 is in place. Managed settings can't turn it on for users: adoption stays an individual choice.

What to do now

Rayo's view: this is a feature to trial on a specific case, not to switch on for everyone.

  1. Pick a repetitive task with many related calls: an identical edit across dozens of files, or a search that needs filtering before reading.
  2. Run it twice on the same repository, with and without Code Mode, and compare the token consumption and time your account shows. The docs publish no savings figures for Claude Code, so the measurement is yours.
  3. Open the code with Ctrl+O and read it: it is the same review work you would do on a script written by a colleague.
  4. If you use auto mode, add a PreToolUse hook on REPL before rolling it out to the team.
  5. In companies on Bedrock, ZDR or HIPAA, leave the 0 in managed settings and revisit when the feature leaves the experimental stage. The docs warn it may change or be removed in any release.

If your problem is token spend in general, simpler levers exist: see how to cut Claude Code token usage.

Sources

FAQ

How do I enable Code Mode in Claude Code? Update to v2.1.323 or later and start claude with CLAUDE_CODE_EXPERIMENTAL_CODE_MODE=1, or put the variable in the env block of ~/.claude/settings.json. The first time you confirm with "Yes, turn on Code Mode" and Claude Code restarts.

Does Code Mode save tokens? The Claude Code documentation publishes no figures. Anthropic's November 2025 post reports an example from about 150,000 to 2,000 tokens using code execution over MCP, but that is a vendor scenario. For your case, measure it.

Does it work with Bedrock or in -p mode? No. It works only with the Anthropic API and in an interactive claude session in the terminal. Bedrock, gateways, the Agent SDK, VS Code, Desktop and cloud sessions are out.

Is it safe with auto mode? Every call goes through deny and ask rules and PreToolUse hooks. In auto mode, though, the classifier reviews the code and can't see values computed at run time. For critical calls you need rules, hooks and sandboxing.

How do I block it for the whole company? Set CLAUDE_CODE_EXPERIMENTAL_CODE_MODE to 0 in managed settings. The 0 overrides any 1 set elsewhere.

Città di Castello, Umbria, ItalyOpen in Google Maps