Anthropic Ships Code Mode for Claude Code, Letting the AI Batch Its Tool Calls as JavaScript
The experimental v2.1.323 feature shifts auto mode security review from each tool call to the full script

Anthropic has released Code Mode for Claude Code, an experimental feature that lets the model write short JavaScript programs to execute multiple tool calls in a single REPL run instead of issuing them one at a time. The feature shipped in Claude Code v2.1.323 on November 12, 2026, before receiving an official blog announcement on November 17.
The core behavior change is straightforward: rather than calling each tool individually and waiting for a response before issuing the next one, Claude in Code Mode can write a JavaScript program, hand it to a new REPL tool, and collect the results from a corresponding Poll tool once execution completes. That lets a batch of file reads, searches, or similar operations run in parallel, with the intermediate results staying inside the script's execution context rather than passing back through the model after every step.
A New Execution Environment Runs Model-Written JavaScript
When Code Mode is active, Claude gains two new capabilities alongside its existing tools: a REPL tool that accepts a JavaScript program and executes it, and a Poll tool that retrieves the output of scripts running in the background. The model can write programs that call its own tool suite programmatically — file reads, searches, shell commands — and iterate over results using ordinary JavaScript control flow, all inside a single REPL execution.
The runtime is node:vm, running inside Bun, Anthropic's current JavaScript execution environment for Claude Code. Developer Rhys (@RhysSullivan) confirmed the node:vm runtime choice in a public post. Claude Code ships as a Bun executable, so the Code Mode sandbox runs within that same process rather than spinning up an entirely separate environment.
One architectural consequence is that the model's context does not accumulate intermediate tool call results during the program's execution the way it would in normal mode. The REPL boundary contains the intermediate state, and i10x.ai's analysis of Code Mode found this boundary can materially reduce the volume of tokens that flow back through the model — though the effect varies considerably by task structure.
Read more: Claude Code desktop gains nested sessions and parallel agent workflows
Both the REPL and Poll tools are listed alongside other Claude Code tools, so they appear in tool call logs and in the display Claude Code shows during a session. The model decides whether to use Code Mode on any given task; developers cannot directly instruct Claude to write a script rather than issue individual calls, though the feature can be enabled or disabled at the organization level.
Background Tasks and How Auto Mode Interacts With Scripts
Code Mode introduces two timeout tiers depending on how a session is running. Scripts that Claude waits on — where the user is present in the terminal and execution blocks the session — are allowed up to ten minutes. Scripts running as background tasks under auto mode or bypassPermissions mode can run for up to two hours, with a warning notification appearing at the one-minute-fifty-nine-second mark before expiration.
The security model shifts in a consequential way when auto mode is in use. In standard Claude Code operation, auto mode reviews each tool call individually before execution, applying deny rules and PreToolUse hooks to decide whether to block or permit that call. In Code Mode, the auto mode classifier instead reviews the entire JavaScript program once before execution begins.
That design choice means the classifier evaluates the program's static text, not the values it may compute at runtime. If a script builds a file path string dynamically from other variables, or passes a computed value to a tool call inside a loop, the classifier inspects the program as written and cannot see what those values will resolve to during execution. Anthropic's official release notes acknowledge the limitation explicitly: deny rules that depend on inspecting specific argument values may not apply to dynamically constructed calls the same way they would in standard mode.
Read more: Codex hits 20 million users as Claude Code faces growing competition
A Viral Benchmark Number That Belongs to a Different Feature
A 37 percent token reduction figure has been widely shared online as evidence of Code Mode's efficiency. That number does not come from Claude Code or from Code Mode.
It originated in Anthropic's November 2025 engineering post on Programmatic Tool Calling, a separate API-level feature that lets Claude write Python to call tools in a sandboxed environment. The measured result — input tokens falling from an average of 43,588 to 27,297 on complex research tasks — described the API feature's performance on a specific benchmark, not Claude Code's new REPL-based execution. The two features share a conceptual premise — model-authored programs reduce per-step context accumulation — but they use different languages, different runtimes, and operate at different levels of the stack.
Developer tests with the actual Code Mode feature show real but inconsistent results. One developer running Opus 5.5 on a comparable task saw input tokens fall roughly 37 percent, from 150,364 to 94,659 — but the total runtime increased from fifteen seconds to thirty-seven. A second developer running Sonnet 5.5 across eight tasks saw approximately 40 percent fewer input tokens on short work and around 55 percent fewer (486,000 to 218,000) on a thirty-file refactor. The pattern across early tests is that Code Mode can reduce context accumulation on batch-heavy work while sometimes extending wall-clock time, because the model spends additional time writing the script before execution begins.
A Changed Security Model Requires Deliberate Configuration
The shift from per-call to per-program security review changes what organizations relying on deny rules or PreToolUse hooks need to verify before deploying Code Mode. A deny rule written to block specific shell arguments, for example, may pass inspection on a Code Mode script that constructs those arguments dynamically at runtime.
Anthropic recommends deploying OS-level sandboxing — a Docker container with restricted filesystem mounts is the common pattern — for any environment where security requirements cannot depend entirely on command-text rules. Organizations can disable Code Mode across their instances through managed settings.
The feature cannot be enabled through project-level settings files. The environment variable CLAUDE_CODE_EXPERIMENTAL_CODE_MODE=1 must be set at the shell or system level, a design choice that prevents a repository's configuration from silently enabling Code Mode for developers who clone it without awareness of the change.
Availability, Requirements, and Current Constraints
Code Mode requires Claude Code v2.1.323 or later and runs on Opus 5.5, Sonnet 5.5, Haiku 5.5, and Fable 5.2. Anthropic issued a bug-fix release at v2.1.325; multi-agent workflows that use Code Mode require v2.1.326 or higher.
The feature is unavailable in the VS Code extension panel, the Claude Desktop application, cloud-hosted Claude Code sessions, runs using the -p flag, the Claude Agent SDK, deployments on Amazon Bedrock, Google Cloud, or Microsoft Azure AI Foundry, HIPAA-compliant organizations, and environments with zero data retention configured.
On Windows, Git for Windows enables Bash support; without it, Claude Code falls back to PowerShell for shell commands. No additional system dependencies are required for Code Mode itself beyond the runtime Claude Code already uses.
Code Mode is currently limited to native interactive terminal sessions. Anthropic has not announced a timeline for expanding it to the excluded environments.
The approach resembles strategies other AI coding tools have pursued. OpenAI's Codex and the open-source agent OpenCode both allow model-driven orchestration of coding tasks, while Pi, a minimal terminal coding-agent harness by Earendil, uses a QuickJS sandbox to let Claude execute its own scripting layer. Claude Code's implementation is distinct in embedding the execution inside the Bun runtime it already uses, making Code Mode an extension of the existing execution environment rather than a separate subprocess.



