Anthropic has added Code Mode to Claude Code, an experimental feature in which the model writes JavaScript to drive its tools instead of requesting each Bash, Read, or Edit call separately. Code Mode is off by default, requires Claude Code v2.1.323 or later, and is enabled with the CLAUDE_CODE_EXPERIMENTAL_CODE_MODE=1 environment variable. Anthropic warns it may change or be removed in any release.
In a normal session, Claude asks for one tool call, reads the full result, and decides the next step. In Code Mode, one script can run commands in parallel, pass one result into the next call, and return only the output the model needs. The documentation's example finds a file with rg, raises a retry limit, runs the tests, and returns just the path and test output. The conversation still shows each tool call and diff, while the generated code sits in the transcript viewer. Anthropic recommends it for edits repeated across many files, searches that need filtering, and independent commands. Code that Claude waits on stops after ten minutes; sessions started in auto or bypassPermissions mode can push it to the background for up to two hours while the conversation continues.
The permission model is the part architects should read first. Each call inside a script still goes through deny and ask rules and PreToolUse hooks, but in auto mode the classifier reviews the script before it runs, not each call, and cannot see values computed at run time. A git push can now reach a hook as cd 'app' && git push, so hooks must check every part of a command; a hook matching the REPL tool can read the JavaScript from tool_input.code. Project settings cannot enable Code Mode, so a cloned repository cannot switch it on, and administrators can block it through managed settings.
Code Mode runs only in interactive terminal sessions of the native build, on Opus 5.5, Sonnet 5.5, Haiku 5.5, or Fable 5.2, through a Claude subscription or Console account. It does not work with -p, the Agent SDK, the VS Code panel, the Desktop app, Amazon Bedrock, gateways, or zero-data-retention organizations. Agent teams need v2.1.326. Anthropic has published no token or latency figures for it.
George (@bolyki) compared Code Mode with normal mode across eight interactive Sonnet 5.5 runs and posted:
Same results every time. Context 20-25% smaller. On the bigger task: 37% fewer tokens, 19% lower cost. But it is not faster, and on a tiny task it cost more.
Ravi Madabhushi, who builds agent auth infrastructure, pushed back on claims that the feature makes MCP obsolete:
It doesn't materially change anything wrt authentication, authorization and audit policy layers; Your agent still makes those same MCP calls, with the same auth tokens and context and what materially changes is how much context gets into the model window and how much can be discarded.
The idea, and the name, predate Anthropic's release. Cloudflare introduced Code Mode for MCP converting MCP tools into a TypeScript API that models code against inside sandboxed Workers, where bindings keep API keys away from generated code. Anthropic's own post on code execution with MCP described one workflow dropping from 150,000 to 2,000 tokens, and the Claude API offers programmatic tool calling in a remote code execution container. Code Mode instead runs the script in the developer's local session, against Claude Code's built-in tools and permission system.
Code Mode remains opt-in and experimental, and Anthropic collects feedback through /feedback. Setup steps and troubleshooting are in the Claude Code documentation