Claude Code’s Code Mode runs tool calls as JavaScript

Claude Code 2.1.323, released on November 12, added an experimental, opt-in Code Mode. In this mode Claude stops requesting Bash, Read or Edit calls one at a time and instead writes JavaScript that makes them, and Claude Code runs that code in your session, Claude’s Code Mode documentation explains. The docs require v2.1.323 or later on either release channel. But on November 15 the stable channel still pointed at 2.1.311, which carries none of the Code Mode strings we searched for, so stable installs get the mode only after switching to latest or once stable catches up.
The latest channel points at 2.1.325, and that build has Code Mode too. To turn it on, set CLAUDE_CODE_EXPERIMENTAL_CODE_MODE to 1 in your shell or in ~/.claude/settings.json and start a new session. A 0 in either place keeps the mode off even when the other place has a 1. Removing the variable, or setting it to 0, turns the mode off from the next session on. When a session starts without the mode, a line near the top reads “Code Mode (experimental) isn’t available” and gives the reason, which /status also shows. If that line never appears, run claude --version and check the variable.
Code Mode needs an interactive claude session in a terminal, the native build, and a Claude subscription or a Console account. It does not run with -p, the Agent SDK, the VS Code panel, the Desktop app or cloud sessions. It is also unavailable through a gateway, Amazon Bedrock, Claude Platform on AWS, Google Cloud’s Agent Platform or Microsoft Foundry, and in organizations that use the HIPAA configuration or zero data retention. The supported models are Opus 5.5, Sonnet 5.5, Haiku 5.5 and Fable 5.2, and on Windows you also need Git for Windows. Some settings stop it from starting: an API key helper, agent teams, OpenTelemetry export and DISABLE_TELEMETRY. A custom ANTHROPIC_BASE_URL or any setting that routes requests through a cloud provider does the same.
What a script changes
One piece of code can run commands in parallel, pass one result into the next call and send back only the part of the output Claude needs to read. In the docs’ example of raising a retry limit, a single script finds the file, edits it, runs the tests and returns the path and the test output. The conversation still shows the individual tool calls, 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.
The docs suggest it for tasks made of many related calls: one change repeated across many files, a search whose results need filtering before Claude reads them, and several independent commands that can run at once.
The docs give no savings figure. The design reasoning appears in the model-facing prompt template that ships in 2.1.323: “each call is a full model round-trip — the whole conversation is re-read before your script runs, and you wait for the reply — while the work inside a script (shell commands, file reads, searches, tool calls) is comparatively free, and runs concurrently when you fan it out with Promise.all.” The same template tells Claude that REPL is its only tool, that variables persist from one call to the next, and that the context has no import, require or process. That template has several branches, and we did not see which one a live session gets.
Permissions, hooks and time limits
Every tool call made from Claude’s code still goes through your deny and ask rules and your PreToolUse hooks, and a rule or matcher for Bash needs no changes. Auto mode works differently. Its classifier reviews each script before it runs, not each tool call, and it does not see values computed at run time, such as a path taken from search output. The docs say to keep rules or hooks for any call you must control. In the other permission modes, scripts start without a review and you get prompted for each call that would normally prompt you. To check the code itself, a PreToolUse hook that matches REPL can read the JavaScript from tool_input.code.
If a PreToolUse hook fails or times out on a call from Claude’s code, the call is refused even when onFailure is unset. A hook counts as failed when it couldn’t start, was killed, exited with 126, 127 or a code above 128, or returned an HTTP error or invalid output. Setting "onFailure": "continue" lets such calls go ahead. A command hook that exits with an ordinary code such as 1 lets the call through unless it sets "onFailure": "block". When scripts can run in the background, UserPromptSubmit hooks also run on code output, so a hook that blocks there should skip inputs whose source is poll_event.
A script Claude waits on stops after ten minutes, and time spent at permission prompts counts toward that limit. Background scripts can run for up to two hours while you keep talking to Claude, but only in sessions started in auto or bypassPermissions mode. In auto mode, if Claude starts a new script while an earlier one is still running, the earlier script loses its classifier review. With no IDE connected, Claude Code then asks about that script’s remaining calls behind a countdown, and an unanswered prompt refuses the call.
Remote Control, Claude in Chrome and computer use are off for the whole session. The session can’t be moved to the Desktop app or turned into a background session, /fork can’t start a background copy, and a Code Mode session can only be resumed in the terminal with the mode on.
Our analysis
What we checked
On November 15 we read the npm and native-installer channel pointers, searched several earlier Claude Code builds for Code Mode marker strings, and compared the start-up check, refusal messages and model prompt in 2.1.323 with the live docs page.
The ten-minute and two-hour limits in the docs match constants in the code, and so does the ANTHROPIC_BASE_URL blocker. Access depends on a server-side flag, though, and the code has more ways to refuse a session than the troubleshooting table lists, so the reason a session shows may not be in the docs.
- “It isn’t open to your account yet” comes from a feature flag,
tengu_rustling_blossom, that is off by default. The binary’s full text adds “or Claude Code couldn’t check whether it is”. - In the linux-x64 builds we searched, the opt-in strings are present in 2.1.318, published November 3, and absent from 2.1.317; that is a check of strings only. The start-up checks in 2.1.322 and 2.1.323 differ only in the model check, compared by function length rather than text, and we infer that November 12 brought the docs, the changelog entry and that check while the feature code was already there.
- The binary has 23 refusal reasons against the table’s 12 rows, and seven have no counterpart on the docs page, among them “must be 1 to turn it on”. The flag-fetch reason also names
DO_NOT_TRACK,CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFICandCLAUDE_CODE_DISABLE_FEATURE_FLAGS, and the background-jobs reason also covers teammates’ panes. - The model check reads as a version floor: 5.2 or later for the
fableandmythosfamilies, 5.5 or later for any other. That is an inference from one function, and the docs never mentionmythos. - A script call that sets no timeout gets 30 seconds, capped at ten minutes. Each part of a script’s output is cut to about 30,000 characters, head and tail kept, under a condition we did not resolve.
- Turning the mode on stores a one-time consent in
~/.claude.jsonunder two keys, one of them for auto mode, and the session then restarts into Code Mode; we found this in the code and did not observe it.
Blocking it for an organization
Setting CLAUDE_CODE_EXPERIMENTAL_CODE_MODE to 0 in managed settings blocks Code Mode for everyone in the organization. Users already in a Code Mode session stay in it until they exit or restart Claude Code, and after that they start without the mode and can’t resume those sessions while the 0 is in place. Managed settings can’t turn the mode on for users.
Up next
Anthropic bought a biotech with one full-time employee
Per Nature, a biotech with one full-time employee and two early-stage antibodies ended up inside Anthropic. Its lab work went to at least five contract research organizations. How many people would you put on a drug program, at minimum?
Related stories
Comments
No comments yet. Be the first.
Join the conversation
Sign in to leave a comment. It appears after moderation.

