Claude Code's Code Mode, Tested: 29% Fewer Tokens, Twice the Time

Code Mode is an experimental Claude Code setting in which Claude writes JavaScript that calls its tools, instead of calling them one at a time. How to turn it on, where it does not start, and the same 138-file link check run twice on Claude Code 2.1.331: same answer, 29% fewer input tokens, 31 seconds against 14.

Anthropic's Claude Code account announced Code Mode on November 17, 2026, as "a new, experimental way for Claude Code to work". The post passed two million views, and every Claude Code release since, from 2.1.323 to 2.1.331, has fixed or extended it. Google already completes "claude code code mode" and "code mode claude code mcp". What nobody shows is what it changes on a real task.

Short answer: Code Mode makes Claude write JavaScript that calls its tools, instead of asking for each tool call one by one. It is off by default, it only runs in an interactive terminal session, and on the task we measured it gave the same answer with 29% fewer input tokens and more than twice the time.

Everything below was checked on November 24, 2026, against Anthropic's Code Mode documentation (code.claude.com), the Claude Code changelog, and Claude Code 2.1.331 installed in a throwaway folder on our machine.

Code Mode in one paragraph

Without Code Mode, Claude asks for one tool call (Bash, Read, Edit, an MCP tool), Claude Code runs it, and Claude reads the full result before choosing the next call. With Code Mode, Claude writes a piece of JavaScript that makes the calls. Claude Code runs it in your session through a tool called REPL. The code can loop over a list of files, feed one result into the next call, run independent commands at the same time, and return only the lines Claude needs. In the conversation you still see the tool calls, an edit's diff for example. The code itself is in the transcript viewer: press Ctrl+O and expand a Code row.

Anthropic's documentation names three kinds of task where it should help: a change that repeats across many files, a search whose results need filtering before Claude reads them, and several independent commands that can run at once.

How to turn it on, and off

  1. Check the version with claude --version. You need 2.1.323 or later (2.1.331 or later through Amazon Bedrock, Google Cloud's Agent Platform or Microsoft Foundry). Run claude update if you are behind.
  2. Start a session with the variable set:
CLAUDE_CODE_EXPERIMENTAL_CODE_MODE=1 claude

On Windows PowerShell: $env:CLAUDE_CODE_EXPERIMENTAL_CODE_MODE = "1", then claude. Windows also needs Git for Windows, because the code's shell commands run in Git Bash. 3. Claude Code shows a screen that explains Code Mode and asks you to choose. "No, start without it" is selected by default: move to "Yes, turn on Code Mode" and press Enter. Claude Code restarts and shows Code Mode (experimental) is on ยท this session can be resumed only with Code Mode on near the top.

To keep it on for every new session, put the variable in your user settings:

{
  "env": {
    "CLAUDE_CODE_EXPERIMENTAL_CODE_MODE": "1"
  }
}

That file is ~/.claude/settings.json. Claude Code ignores this variable in a project's settings, so a repository you clone cannot switch Code Mode on for you. To turn it off, remove the variable or set it to 0: a 0 anywhere wins over a 1 elsewhere, which is also how an organization blocks it in managed settings.

Where it does not start

We hit the first limit before measuring anything. With the variable set, claude -p ran normally and answered with plain Glob and Read calls, no code at all. The documentation is clear about it: Code Mode needs an interactive claude session in a terminal. It does not work in the VS Code panel, the Desktop app or cloud sessions, and it needs the native build of Claude Code (the npm package now installs the same native binary).

The other limits, from the same page:

  • Resuming: a Code Mode session resumes only with Code Mode on. Keep the variable set for claude --continue and claude --resume.
  • Turned off inside it: Remote Control, Claude in Chrome and computer use.
  • Time: code that Claude waits for stops after ten minutes. In auto mode, code can run in the background for up to two hours.
  • Account: a Claude subscription, a Console account or a supported cloud provider, but not through a gateway, and not for organizations on the HIPAA configuration or zero data retention.
  • Models: Claude Opus 5.5, Sonnet 5.5, Haiku 5.5 or Fable 5.2.

One more thing changes with permissions. In auto mode, the safety classifier reads each piece of code once, before it runs, and not each tool call the code then makes. Your deny and ask rules and PreToolUse hooks still apply to each call under the tool's usual name (Bash, Read, an MCP tool), so keep a rule for any command you must control.

We ran the same task twice

The documentation suggests a first task for Code Mode: read every Markdown file in a project and list the links that point to local files that don't exist. We used exactly that prompt, because it is the kind of work Code Mode is meant for, and because the answer can be checked.

The task. A snapshot of Anthropic's public skills repository (commit e4bb5d9), 138 Markdown files, copied twice into fresh git repositories in a throwaway folder. The prompt, identical in both runs: "Read every Markdown file in this project and list the links that point to local files that don't exist. Give the file, the link and why it is broken."

The setup. Claude Code 2.1.331, Sonnet 5.5 at its default effort, an interactive session in a terminal, auto permission mode, no MCP server. Run A with CLAUDE_CODE_EXPERIMENTAL_CODE_MODE=1, run B with 0. Our account had little weekly room left that night, which is why we picked Sonnet 5.5 over Opus 5.5 for both runs. The numbers come from each session's transcript.

Run A: Code Mode onRun B: Code Mode off
Time from prompt to answer31 s14 s
Model requests44
What Claude asked to run4 pieces of JavaScript3 Bash commands
Tool calls actually run193 (138 Read, 55 Bash)3
Input tokens processed112,905159,927
Output tokens1,1921,558
Answerone link, a placeholderthe same link

Most input tokens are cache reads in both runs: 95,983 in run A, 145,204 in run B.

Both answers were right. The only local link that points nowhere is [Title](URL) in skills/academy-guide/SKILL.md, line 82, a placeholder in an example reply. Both runs found it, both said it was not a real broken link, and both skipped links inside code blocks and inline code. Our own quick check with a regular expression had flagged a second one, which turned out to be inside inline code: Claude was right and our regex was not.

What Claude did with Code Mode on. It wrote a loop in JavaScript that listed the files with git ls-files, read each file with file(f).text(), skipped code fences and inline code, and checked every local link with a test -e shell command. Claude Code ran 193 tool calls from that code, and Claude read only the short list the code returned.

What Claude did with Code Mode off. It did not call Read 138 times. It wrote a Python script to a temporary file and ran it with Bash: the same logic, in one process, three Bash calls in total.

Our reading. On this task, Claude without Code Mode already wrote code, just in Python rather than JavaScript. Both runs made four model requests, so Code Mode did not save round trips here. The 29% saving on input tokens comes from a smaller context on each request, most likely because Code Mode now sends shorter tool descriptions, as the changelog of version 2.1.328 says. And Code Mode was slower because the code it wrote waited for each file and each test -e one after the other, when the Python script did it all in one go. This is one task, one model, one night: a data point, not a benchmark.

When Code Mode is worth it

Code Mode earns its place when the many calls are calls a shell script cannot make for Claude:

  • MCP tools: a Bash or Python script cannot call an MCP server's tools, code in Code Mode can, and it can filter their results before Claude reads them;
  • edits across many files, where each edit() keeps Claude Code's diff and permission checks;
  • independent commands that can run at the same time, if the code actually runs them in parallel.

Leave it off when you need Remote Control, Claude in Chrome or computer use, when you script Claude Code with claude -p, and when you would rather not depend on an experiment that "may change or be removed in any release", in Anthropic's words. If you turn it on, read the code once in a while with Ctrl+O: it shows whether Claude wrote a loop that waits on each call, as in our run, or calls that run side by side.

How we look at it from AgentsRoom

We run most of our coding agents in AgentsRoom, several Claude Code sessions side by side, and on a busy week the shared weekly limit runs out before the work does. For us, 29% fewer input tokens matters more than 17 seconds. Two practical notes if you try Code Mode on agents you run in parallel:

  • Compare for yourself. The token counter shows each session's tokens and its cache hit rate, so the same task can be run on two agents, one with Code Mode and one without, and read side by side.
  • Mind resuming. AgentsRoom reopens past Claude Code conversations by their session ID from its History menu. A Code Mode conversation only reopens if the variable is still set, so put it in ~/.claude/settings.json rather than in one shell, or the resume is refused.

Frequently asked questions

What is Code Mode in Claude Code?

Code Mode is an experimental, opt-in way for Claude Code to use its tools. Without it, Claude asks for one tool call at a time (Bash, Read, Edit, an MCP tool) and reads each result before deciding the next step. With it, Claude writes a piece of JavaScript that makes the calls, and Claude Code runs that code in your session. One piece of code can loop over files, chain one result into the next call and return only the part Claude needs to read. It needs Claude Code 2.1.323 or later and is off by default.

How do I turn on Code Mode?

Set the environment variable CLAUDE_CODE_EXPERIMENTAL_CODE_MODE to 1 and start claude, for example CLAUDE_CODE_EXPERIMENTAL_CODE_MODE=1 claude on macOS and Linux. Claude Code asks you to confirm once (Yes, turn on Code Mode), restarts, and shows "Code Mode (experimental) is on" at the top of the session. To keep it on for every session, put the variable in the env block of ~/.claude/settings.json. A project's own settings file cannot turn it on. To turn it off, remove the variable or set it to 0.

Does Code Mode work with claude -p?

No. Anthropic's documentation lists an interactive claude session in a terminal as the only surface, and it does not work in the VS Code panel, the Desktop app or cloud sessions. We checked it on Claude Code 2.1.331: with the variable set, a claude -p run started normally and used plain Glob and Read calls, without any code. Remote Control, Claude in Chrome and computer use are also off in a Code Mode session.

Does Code Mode use fewer tokens?

On our one measured task, yes: the same link check over 138 Markdown files used 112,905 input tokens with Code Mode against 159,927 without, 29% fewer, and 1,192 output tokens against 1,558. Both runs made four model requests, so the saving came from a smaller context on each request, not from fewer round trips. It was also slower: 31 seconds from prompt to answer against 14, because the code read the files one after the other.

Can I resume a Code Mode session without Code Mode?

No. A session started in Code Mode can be resumed only with Code Mode on: keep CLAUDE_CODE_EXPERIMENTAL_CODE_MODE set to 1 when you run claude --continue or claude --resume, or Claude Code refuses to resume it. A session started without Code Mode resumes without it, even with the variable set. After a Code Mode session on a Claude subscription or Console account, you cannot resume it on a cloud provider such as Amazon Bedrock.

When is Code Mode worth turning on?

When a task takes many related tool calls that a shell script cannot make for Claude: edits across many files, MCP tool calls whose results need filtering before Claude reads them, several independent commands that can run at once. On a plain search over files, Claude without Code Mode often writes a shell or Python script by itself, which is what happened in our test. Code Mode is experimental, so keep it for tasks you can check, and leave it off where you need Remote Control or Claude in Chrome.

Download AgentsRoom

Run all your AI agents, on all your projects, from a single window.

Download AgentsRoomFree

Companion app: monitor your agents on the go

Bring your own: Claude, Codex, Antigravity CLI, or other AI provider.

Push bugs and requests straight to your public backlog.

Keep reading