Subscribe
AI Coding Tools
3 min read

Claude Code Code Mode Hands the Tool Loop to Generated JavaScript

An experimental opt-in in Claude Code v2.1.323 lets the model write one JavaScript snippet that chains many tool calls, trading turn-by-turn supervision for fewer round trips.

Retro brochure illustration of a robot arm linking code windows with ribbons
Retro brochure illustration of a robot arm linking code windows with ribbons

Anthropic has added an experimental feature called Code Mode to Claude Code. Shipped in version 2.1.323 in mid-November 2026, it changes the agent's execution layer: instead of requesting each Bash, Read or Edit call one at a time and reading every result before deciding the next step, Claude writes a single piece of JavaScript that chains several tool calls in one step, and Claude Code runs it in your session.

How it works

Per the documentation, one generated snippet can run commands in parallel, feed one result into the next call, and return to the model only the output it actually needs to read. Anthropic's example edits a file and reruns tests: the code greps for a symbol, picks the first matching file, applies an edit, runs the test suite, and returns a compact object with the edited filename and test status. In the conversation you still see the underlying tool calls, such as the diff, but not the code itself unless you open the transcript viewer with Ctrl+O.

Per-call review versus one review of the generated code

That structure attacks the token and latency cost of agentic loops. Every intermediate result a model reads is context you pay for, and every step is a round trip. Batching steps into code and filtering locally is the same pattern Anthropic described in its engineering post on code execution with MCP, where one example cut token use from 150,000 to 2,000, and in the API's Programmatic Tool Calling feature, which reported average usage falling from 43,588 to 27,297 tokens on complex research tasks. Claude Code's docs publish no equivalent figure; one independent test reported system-tool context of 11.1k tokens with Code Mode versus 24.6k without, a single third-party measurement.

Cloudflare coined the term Code Mode in September 2025 with an Agents SDK approach that turns MCP schemas into a TypeScript API running in V8 isolates. Anthropic's version applies the idea to Claude Code's own built-in tools, in JavaScript, inside your terminal session.

Switching it on, and controlling it

Code Mode is off by default. You enable it with the environment variable CLAUDE_CODE_EXPERIMENTAL_CODE_MODE=1 in your shell or in the env block of ~/.claude/settings.json, and Claude Code asks for confirmation before the first session. Setting the variable to 0 anywhere disables it, even if it is set to 1 elsewhere. Administrators can block it org-wide through managed settings, but cannot force it on.

Permission machinery still applies inside the generated code. Each tool call passes your deny and ask rules and PreToolUse hooks under the tool's usual name, so a git push embedded in a snippet still evaluates as a Bash-rule case. Review behavior differs by permission mode: in auto mode the model reviews the generated code rather than each individual call, which is the main supervision trade-off the feature asks developers to accept.

Runtime limits are explicit. If Claude waits on the code, it stops after 10 minutes, permission-prompt time included. Background runs can go up to 2 hours while you keep chatting, but only in sessions started in auto or bypassPermissions mode.

What is not supported

The feature is narrow by design. It runs only in an interactive terminal session on the direct Anthropic API. No Agent SDK, no VS Code panel, no desktop app, no headless -p flag, and no Bedrock, Google Cloud, Microsoft Foundry or custom gateways.

The direction of travel is visible. A model that writes its own orchestration code instead of emitting JSON tool calls is a more programmable, more autonomous agent, and the experimental label tells you where Anthropic thinks the rough edges are: error handling, security boundaries and what reviewers see.

Sources

AI Coding ToolsClaudeAnthropic