Claude Code Code Mode: what it is, how to turn it on, and whether it saves tokens
Code Mode is an experimental Claude Code feature, available since v2.1.323. Normally Claude calls Bash, Read or Edit one at a time and reads each result. In Code Mode it writes a piece of JavaScript that makes several tool calls in one step. It’s off by default: set CLAUDE_CODE_EXPERIMENTAL_CODE_MODE=1 in your shell or in the env block of ~/.claude/settings.json, and use it in an interactive terminal session. Does it save tokens? Anthropic hasn’t published a number. The “37% fewer tokens” you see online comes from a different feature and from one test on one task, where Code Mode also took more than twice as long. Measure it on your own work.
Code Mode is experimental, and the docs say it “may change or be removed in any release.” Everything below is from Anthropic’s docs and changelog as of November 25, 2026, up to v2.1.332.
- What it does
- Turn it on and off
- What it needs
- Permissions and the sandbox
- Does it save tokens?
- Measure it yourself
- When to keep it off
- Questions
What Code Mode does
Without Code Mode, Claude asks for one tool call, reads the result, then decides on the next. With it, “Claude writes a piece of JavaScript that makes the tool calls, and Claude Code runs that code in your session.” The script can loop over files, filter a search before Claude reads it, or run several commands in parallel, and only what the script returns goes back to the model.
The docs point to three kinds of work where this helps:
- the same change across many files;
- a search whose results should be filtered before Claude reads them;
- several independent commands that can run at once.
In the transcript you still see the individual tool calls, not the code. Press Ctrl+O to see the script as a collapsed Code row.
It sounds like Claude now writes its own programs. In a way, yes. But the tools are the same ones you already approve: Bash, Read, Edit, MCP tools. What changes is how many of them run between two looks from the model.
How to turn it on and off
For one session, start Claude Code with the variable set:
CLAUDE_CODE_EXPERIMENTAL_CODE_MODE=1 claude
To keep it on, add it to your user settings:
~/.claude/settings.json
{
"env": {
"CLAUDE_CODE_EXPERIMENTAL_CODE_MODE": "1"
}
}
Claude Code ignores this variable in a project’s settings files, so a repository you clone can’t turn Code Mode on for you. The first time, Claude Code asks you to confirm (“Yes, turn on Code Mode”), restarts, and shows that Code Mode is on.
- Resuming: a Code Mode session resumes only with Code Mode on. Keep the variable set for
claude --continueor--resume. - Turning it off: remove the variable, or set it to
0. A0in either place keeps it off. - For a team: an administrator can keep it off with
0in managed settings, but can’t force it on.
What it needs, and where it doesn’t work
| Requirement | What the docs say |
|---|---|
| Version | Claude Code v2.1.323 or later, native build |
| Account | A Claude subscription, a Console account, or a cloud provider such as Amazon Bedrock, Google Cloud’s Agent Platform or Microsoft Foundry (v2.1.331 or later); not through a gateway, not with Claude for Government, HIPAA or zero data retention configurations |
| Models | Claude Opus 5.5, Sonnet 5.5, Haiku 5.5 or Fable 5.2 |
| Where | An interactive session in a terminal; not the VS Code panel, the desktop app or cloud sessions |
| Not with | Remote Control, Claude in Chrome or computer use |
| Agent teams | v2.1.326 or later; teammates use Code Mode in the default in-process display, not in split panes |
| Script time | Up to ten minutes; a background script up to two hours in auto or bypass-permissions mode |
Cloud providers: Code Mode came to Amazon Bedrock, Google Cloud’s Agent Platform, Microsoft Foundry and Claude Platform on AWS in v2.1.331 (November 23, 2026), so update Claude Code first. Two catches from the docs: a session that ran on a Claude subscription or a Console account can’t be resumed on a cloud provider, and with an Enterprise Admin Console sign-in you need Agent Platform, or Bedrock without the Mantle endpoint.
Permissions and the sandbox
Each tool call inside a script still goes through your deny and ask rules and your PreToolUse hooks, under its usual name (Bash, an MCP tool’s name and so on). Two details matter:
- In auto mode, the classifier reviews each script before it runs, not each tool call, and it doesn’t see values the script computes while it runs. If you want to approve every script yourself, add
"ask": ["REPL"]to the permissions in~/.claude/settings.json.REPLis the tool that runs the code. - The sandbox covers only the shell commands a script runs. In the docs’ words, “the JavaScript itself and its file, web, and MCP tool calls run outside the sandbox.”
If you rely on the sandbox for safety, that second line is the one to remember.
Does Code Mode save tokens?
Anthropic’s Code Mode page gives no number: no percent of tokens, no speed. The only token note is in the changelog for v2.1.328: “Code Mode’s tool descriptions are shorter, reducing token use.”
The 37% that people quote has two sources, and neither is an Anthropic measurement of Code Mode:
- A different feature. On November 24, 2025, Anthropic introduced Programmatic Tool Calling on the Claude Developer Platform, the API version of the same idea. On complex research tasks, average usage dropped from 43,588 to 27,297 tokens, a 37% reduction. That’s the API, not Claude Code.
- One test on one task. A paired run on Claude Code 2.1.323 with Opus 5.5 at medium effort ranked customers across 40 JSON order files. Input tokens, cache included, went from 150,364 without Code Mode to 94,659 with it: 37% fewer. Output was about the same. But the run took 37 seconds instead of 15, and each setting ran once.
Personally, I wouldn’t trust anyone’s number for this, including mine. A loop over 40 files is exactly where a script should win. A task where Claude reads one file and edits it is not. The honest answer is “it depends on the task”, and the only way to know is to measure your own.
How to measure it on your own task
- Pick a real task with many tool calls, such as a rename across 30 files or a search across a large repo.
- Commit your work, so both runs start from the same state.
- Start a fresh session without Code Mode, with the same model and effort you normally use. Give the task.
- When it’s done, note
/context. On a Console account, also note/cost; on a subscription, note/usage. - Reset the files, for example with
git stash -u. Start a fresh session withCLAUDE_CODE_EXPERIMENTAL_CODE_MODE=1, give the same prompt, and note the same numbers. - Compare tokens, time and the result. If the answers differ, the token count doesn’t matter.
On a subscription, /usage shows your share of the 5-hour and weekly limits in percent, so one run may not move it much. Run the pair a few times, or compare /context, which shows how much of the context window each session used.
When to keep it off
- Short, one-step tasks. There’s nothing to batch, and in the one test above Code Mode was slower.
- You work in the desktop app, VS Code or cloud sessions. It doesn’t run there.
- You want to see every command before it runs and use auto mode: either add the
REPLask rule or keep Code Mode off. - You rely on the sandbox for file and network access: the script’s own calls run outside it.
- Your hooks check tool output in
UserPromptSubmit. Since v2.1.328, those hooks don’t receive what a script returns. The docs say to move such checks to aPostToolUsehook that matchesREPL.
Where Meowdoro fits
We built Meowdoro, a focus timer in the MacBook notch that shows which Claude Code and Codex sessions are working, done or waiting for your answer. A ten-minute script is a good moment to stay in your focus block instead of watching the terminal. We haven’t tested Meowdoro with Code Mode yet. If you try it, tell us what you see: meow@meowdoro.com.
Questions
How do I enable Code Mode in Claude Code?
Set CLAUDE_CODE_EXPERIMENTAL_CODE_MODE=1 in your shell or in the env block of ~/.claude/settings.json, start an interactive terminal session on v2.1.323 or later, and confirm when asked. Project settings can’t turn it on.
Does Code Mode work in the Claude desktop app or VS Code?
No. As of v2.1.332, it works only in an interactive terminal session, not in the VS Code panel, the desktop app or cloud sessions.
Is the 37% token saving real?
Not as a general number. Anthropic hasn’t published one for Code Mode. 37% is the result of a different API feature, Programmatic Tool Calling, on research tasks, and of one Claude Code test on one task.
Does Code Mode work with MCP tools?
Yes. A script can call MCP tools, and each call goes through your permission rules and PreToolUse hooks under the tool’s name. Those calls run outside the sandbox.
How do I turn Code Mode off?
Remove the variable from your shell and settings, or set it to 0. Sessions started in Code Mode resume only with it on.
Related guides
Sources: Anthropic’s Code Mode documentation and Claude Code changelog (v2.1.326 to v2.1.332), read on November 25, 2026; Anthropic’s “Introducing advanced tool use on the Claude Developer Platform” (November 24, 2025) for Programmatic Tool Calling; the paired Code Mode test as reported by Wavect (November 16, 2026), from runs by wmedia.es. Code Mode is experimental; check the docs for changes.