Claude Code's Code Mode batches tool calls in JavaScript. Here's who should try it, and the permission catch

Claude Code 2.1.323 adds Code Mode, an experimental opt-in where Claude writes JavaScript that makes several tool calls in one step. It only works in an interactive terminal session on Anthropic's own API. If you rely on auto mode, read the permissions section before turning it on.

On this page
  1. How it works
  2. Who can use it
  3. How to turn it on
  4. The permission catch
  5. How it compares
  6. Should you turn it on?
  7. Sources

Anthropic published Claude Code 2.1.323 to npm on November 12, 2026, and two follow-up releases, 2.1.324 and 2.1.325, on November 13. The changelog lists Code Mode first, as “an experimental opt-in in which Claude writes JavaScript to call its tools.” Version 2.1.325 already fixes three Code Mode bugs, including scripts that ignored a worktree entered with EnterWorktree.

The idea isn't new. OpenCode and Docker Agent ship their own versions, compared below. What's different in Claude Code is how much of the existing permission system it keeps, and how many setups it refuses to run in. We haven't run Code Mode ourselves; everything here comes from Anthropic's Code Mode docs and changelog.

How it works

Normally Claude asks for one tool call, such as Read or Bash, reads the result, and then decides on the next call. Each step is a model round trip, and every result lands in the context window whether Claude needs all of it or not.

In Code Mode, Claude writes a short script instead, and Claude Code runs it in your session. The docs give this example for raising a retry limit:

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() });

That one script searches, edits, and runs the tests. The last line decides what Claude reads back: the file path and the test output, without the full search results. Scripts can also run independent commands in parallel.

You still see each tool call in the conversation, such as the edit's diff, but not the script. Press Ctrl+O to open the transcript viewer, where each script appears as a collapsed Code row.

Anthropic suggests it for three kinds of task: a change repeated across many files, a search whose results need filtering before Claude reads them, and several independent commands that can run at once. Anthropic doesn't publish token or latency savings, so we don't have a number to give you.

Who can use it

The requirements list is long, and it rules out several common setups:

RequirementWhat's neededWhat's ruled out
Versionv2.1.323 or later, native buildOlder versions; stable channel until it catches up
AccountClaude subscription or Console accountLLM gateways, Amazon Bedrock, Google Cloud, Microsoft Foundry, API key helpers
OrganizationStandard data handlingHIPAA configuration and zero data retention
ModelOpus 5.5, Sonnet 5.5, Haiku 5.5, or Fable 5.2Older models
SurfaceInteractive claude in a terminalclaude -p, the Agent SDK, the VS Code panel, the Desktop app, cloud sessions
Other settingsFeature-flag fetching onAgent teams, OpenTelemetry export, DISABLE_TELEMETRY

The gateway, ZDR, and -p exclusions are what most teams will hit first. If your company routes Claude Code through Bedrock or an internal proxy, or runs agents in CI with claude -p, Code Mode isn't available to you yet. Remote Control, Claude in Chrome, and computer use also don't work in a Code Mode session.

How to turn it on

Code Mode is off by default. Update with claude update, then start a session with the environment variable set:

# one session
CLAUDE_CODE_EXPERIMENTAL_CODE_MODE=1 claude

# every session: ~/.claude/settings.json
{ "env": { "CLAUDE_CODE_EXPERIMENTAL_CODE_MODE": "1" } }

Claude Code asks you to confirm, restarts, and shows Code Mode (experimental) is on near the top of the session. Claude Code ignores this variable in a project's settings files, so a repository you clone can't switch it on for you. That's a sensible default.

Two things to know before you commit to a session:

  • Resuming is one-way. A Code Mode session can only be resumed in the terminal with Code Mode still on. Turn the variable off and claude --resume refuses it.
  • Long scripts stop at ten minutes when Claude waits on them, counting time you spend at permission prompts. Scripts that run in the background, which needs a session started in auto or bypassPermissions mode, can run for up to two hours.

Admins can block it for everyone by setting CLAUDE_CODE_EXPERIMENTAL_CODE_MODE to "0" in managed settings. They can't force it on.

The permission catch

Every tool call a script makes still goes through your deny and ask rules and your PreToolUse hooks. You don't need new rules for Bash. In the modes that prompt you, you get the same per-call prompts as before.

Auto mode is where it changes. Its classifier now reviews each script before it runs, not each tool call inside it. The docs say plainly that the classifier “doesn't see values computed at run time, such as a path taken from search output.” A script that finds a file with rg and then edits or deletes it gets judged on the code's shape, before anyone knows which file it picked.

Anthropic's own advice is to keep deny rules or hooks for any call you must control. In practice that means:

  • Back auto mode with deny rules for paths that matter, such as .env, .git, and deploy configs. Those still apply to each call.
  • Audit scripts with a hook. A PreToolUse hook that matches REPL, the tool that runs Claude's code, can read the JavaScript from tool_input.code and log or block it.
  • Use the sandbox for hard limits. The docs repeat that Bash rules match command text, so a denied command can run in a form the rule doesn't match, with or without Code Mode.

There's one more auto-mode edge. If Claude starts a new script while an earlier one is still running, the earlier one loses its classifier review. Claude Code then prompts you for its remaining calls with a two-minute countdown, and refuses the call if nobody answers. Unattended sessions will see refusals, not silent approvals.

Hooks need a look too. On calls from a script, a PreToolUse hook that fails or times out refuses the call even when onFailure is unset. A slow hook you never noticed before can start blocking work.

How it compares

Code Mode is now in at least three agents. They differ in what the script can touch:

AgentHow you turn it onWhat scripts can callApprovals
Claude Code 2.1.323+CLAUDE_CODE_EXPERIMENTAL_CODE_MODE=1Claude Code's tools, including a $ shell helper and editPer-call rules and hooks; auto mode reviews the script
OpenCode v2The execute toolBuilt-in and MCP tools through a tools namespace; no direct filesystem, imports, timers, or fetchChecks still apply to nested built-in and MCP tools
Docker Agentcode_mode_tools: true or --code-mode-toolsThe agent's tools, exposed as async functionsOne approval for the whole script; inner calls skip permission checks, including deny patterns

The OpenCode details come from Flavio Copes' write-up of the v2 release, and the Docker details from Docker's docs. Docker's page makes a point worth repeating: for an agent that makes only one or two independent calls per turn, the scripting adds overhead and buys nothing.

The approval column matters most. Docker says approving a script approves “every tool it might invoke internally,” including tools a deny pattern would otherwise block, and tells you to treat that one approval as authorizing everything the toolset can do. Claude Code still applies deny rules and hooks to each call, so it's the stricter of the two. Keep Docker's code_mode_tools off any agent that holds destructive tools.

Should you turn it on?

Try it if you work in the terminal on a subscription or Console account and your tasks are wide: renames across dozens of files, link checks, log triage. Those are the cases where fewer round trips and filtered results should matter most. Anthropic suggests a first prompt that reads every Markdown file and lists links to local files that don't exist, which is a good test because it's easy to check.

Wait if you run unattended auto-mode sessions without deny rules, or if your setup is on the exclusion list. It's also explicitly experimental: Anthropic says it “may change or be removed in any release,” and 2.1.325's fixes show it's still settling. For the rest of this month's Claude Code permission changes, see our 2.1.319 guide.

Sources

Researched and drafted by an AI agent from the linked sources. How posts are made.