Claude Code 2.1.323 shipped Code Mode on November 12. Three days later a post started circulating in Telegram channels: "broken-link search took 2 turns instead of 13", "usage dropped from 150 thousand tokens to 2 thousand". I updated Claude Code and ran the same task six times: three with Claude Code Code Mode and three without it, on one copy of the repository and one model. Code Mode does save tokens, but not where the post says, and not every time.
The short version:
- The starting context in Code Mode is 29% smaller: 44.4K tokens against 62.7K. This held in every run.
- The number of turns barely changed. Without Code Mode, Sonnet 5.5 wrote a script on its own and ran it in a single Bash call.
- In the median run, input is 28% lower. Averaged over three runs there is no difference: one Code Mode run failed on its own script three times and ate the whole saving.
- At API prices the task cost $0.155 on average against $0.182. Accuracy is the same: 22 broken links out of 22 in all six runs.
- The "150 thousand to 2 thousand" figure comes from a different Anthropic article, from 2025. "13 turns against 2" is not in the documentation at all.
What Claude Code Code Mode does#
Normally Claude asks for tools one at a time: read a file, run a command, read the result, decide what to do next. In Code Mode it writes a piece of JavaScript, and Claude Code runs it in your session. The same tools are available inside the code as usual: $ for shell commands, file() for reading, edit() for changes. From the outside the model sees only two tools, REPL and Poll.
Here is what Claude wrote in one of my runs. I shortened the regular expression and the code-block check, the logic is the same:
const files = (await $`git ls-files '*.md'`.text()).trim().split('\n')
const missing = []
for (const f of files) {
const dir = f.includes('/') ? f.slice(0, f.lastIndexOf('/')) : '.'
for (const m of (await file(f).text()).matchAll(/\]\(([^)\s#]+)/g)) {
const link = m[1]
if (/^[a-z]+:/i.test(link)) continue
const path = link.startsWith('/') ? link.slice(1) : `${dir}/${link}`
const r = await $`test -e ${path}`.nothrow()
if (r.exitCode !== 0) missing.push(`${f} -> ${link}`)
}
}
;({ files: files.length, missing })The script returns its last line to the model. It read 58 files and made 46 shell calls, and only the final list reached the model's context. In the interface you see the tool calls themselves, and the code opens in the transcript with Ctrl+O.
The idea is not new. In November 2025 Anthropic described the same technique for MCP servers, and in the API it is called programmatic tool calling. Code Mode brings it to the terminal.
How to enable CLAUDE_CODE_EXPERIMENTAL_CODE_MODE#
You need version 2.1.323 or newer. Check and update:
claude --version
claude updateThen start with the environment variable:
CLAUDE_CODE_EXPERIMENTAL_CODE_MODE=1 claudeTo turn this experimental feature on for every session, put the variable in ~/.claude/settings.json:
{
"env": {
"CLAUDE_CODE_EXPERIMENTAL_CODE_MODE": "1"
}
}Project settings ignore this variable, so a repository you cloned cannot switch Code Mode on for you.
On first launch Claude Code shows a dialog describing the mode, and the cursor sits on "No, start without it". Choose "Yes, turn on Code Mode", and Claude Code restarts. A line appears at the top of the session: Code Mode (experimental) is on · this session can be resumed only with Code Mode on. That is the line visible in the screenshots going around the channels.
Requirements from the documentation that the post leaves out:
- only interactive
claudein a terminal: it does not work with-p, the Agent SDK, the VS Code panel, the Desktop app, or cloud sessions; - Opus 5.5, Sonnet 5.5, Haiku 5.5 or Fable 5.2;
- a Claude subscription or a Console account, no Bedrock, Vertex, Foundry or gateways;
- it will not start with
apiKeyHelper, agent teams, OpenTelemetry export orDISABLE_TELEMETRY.
How I measured it#
The task comes from the Code Mode documentation, verbatim: "Read every Markdown file in this project and list the links that point to local files that don't exist". The test bed is 59 Markdown files from this site's repository, 545 KB of text. I computed the reference answer with a separate script beforehand: 23 broken links, 22 unique.
Conditions were identical for all six runs: Claude Code 2.1.325, Sonnet 5.5, medium effort, auto mode, a fresh copy of the test bed for each run. I started the interactive session through expect, because Code Mode does not work with -p. The numbers come from the session log, the message.usage field.
One quirk of the log. In Code Mode every tool call made from inside the script is written as a separate entry marked isVirtual. Count them as model requests and you get 106 "turns" instead of two. A real model request carries a requestId field.
Results: token savings in numbers#
| Run | Model requests | Starting context | Input per task | Output | ≈ $ at API prices | Found |
|---|---|---|---|---|---|---|
| Code Mode 1 | 2 | 44,371 | 90,549 | 2,178 | 0.10 | 22/22 |
| Code Mode 2 | 2 | 44,368 | 91,732 | 2,353 | 0.16 | 22/22 |
| Code Mode 3 | 7 | 44,368 | 327,604 | 3,617 | 0.21 | 22/22 |
| Without 1 | 2 | 62,665 | 127,175 | 2,242 | 0.17 | 22/22 |
| Without 2 | 4 | 62,662 | 255,190 | 3,022 | 0.20 | 22/22 |
| Without 3 | 2 | 62,662 | 127,336 | 2,488 | 0.18 | 22/22 |
"Input per task" is the sum over all requests: new tokens, cache reads and cache writes. Money is calculated from the Sonnet 5.5 price list as of November 15, 2026: input $2, one-hour cache write $4, cache read $0.10, output $10 per million tokens. On a subscription nothing is charged in dollars, but the same tokens eat into your limits.
The first Code Mode run is cheaper than the others, and not only because of the mode. A failed launch attempt came before it and part of the cache stayed warm: 18K tokens were written to the cache instead of 32 to 35K. Without that luck it would have cost about as much as the second run.
Where the saving comes from, and where it does not#
A smaller fixed part of the context window. This is the main and only stable effect. Without Code Mode the model gets full descriptions of every tool. In Code Mode REPL and Poll stick out, and the rest is described more briefly, as JavaScript functions. The difference is 18K tokens on every request. wmedia.es found the same effect independently on Opus 5.5: 22K tokens on the first request against 36K, 94.7K against 150.4K in total.
There were no fewer turns. The post paints a picture of "13 steps, one file at a time, against 2". In two of my three runs without Code Mode the model wrote a Python script itself and ran it in one Bash call: the same 2 requests. Current models already fold repetitive work into a script when the task allows it. In the wmedia.es test the request count was also equal, 4 and 4.
A bug in the script costs more. The third Code Mode run showed the other side. The first script could not be parsed. The second used require, which does not exist in the sandbox. In the third, zsh swallowed the parentheses in a find command. Every error is an extra request, and every request drags along 44K tokens of context and a growing history. Result: 7 requests and 328K input tokens, worse than any run without Code Mode.
Usage in Claude Code is set by the size of the context that each request carries again. The number of requests only multiplies it. I went through this in detail in the article on Claude Code token usage, where the model's replies came to about 2% of the cost.
Where 150 thousand, 2 thousand and 13 turns came from#
"From 150 thousand to 2 thousand." The figure is from Anthropic's article Code execution with MCP, published November 4, 2025. The example there is different: an agent downloads a meeting transcript from Google Drive and attaches it to a lead in Salesforce. The transcript never passes through the model's context, and the result is "from 150,000 tokens to 2,000 tokens". It has nothing to do with Code Mode in Claude Code, and its documentation has no savings figure at all.
"2 turns instead of 13." I found no source: not in the documentation, not in the changelog, not in Anthropic's article. The documentation has the same broken-links task, but without measurements.
"37%." This number also circulates in retellings. It comes from Anthropic's post Introducing advanced tool use of November 24, 2025, about programmatic tool calling in the API: "from 43,588 to 27,297 tokens, a 37% reduction". Also not Code Mode.
Limitations worth knowing in advance#
- Resuming. A session started in Code Mode can be continued only in a terminal and only with the mode on. Without the variable,
claude --resumewill not open it. - Chrome and computer use disappear. Claude in Chrome, Remote Control and computer use do not work in Code Mode. Claude Code says so at startup: "No Chrome or computer use". If you automate a browser, you will have to turn the mode off.
- Auto mode checks the code, not the calls. The classifier reads the JavaScript once before it runs and does not see values the code computes along the way, such as a path taken from search results.
denyrules andPreToolUsehooks still fire on every call, so keep important prohibitions there. - Ten minutes. Code that is waiting for a result stops after 10 minutes, including the time you spend answering permission dialogs. In the background it lives up to two hours, but only if the session was started in auto or
bypassPermissionsmode. - Hooks. If a
PreToolUsehook crashes or does not answer in time, the call from the code is rejected, even whenonFailureis not set. - No handing off the session. You cannot move it to the Desktop app or turn it into a background session.
A company can ban the mode for all employees with "CLAUDE_CODE_EXPERIMENTAL_CODE_MODE": "0" in managed settings.
Should you turn Code Mode on now#
For tasks with many similar calls it is worth a try: an edit repeated across many files, a search with filtered results, independent commands in parallel. The stable saving is about 18K tokens of starting context on every request, and over a long session it adds up.
Do not turn it on for the sake of a "75 times cheaper" miracle, because there is none. If you work with Claude in Chrome or run Claude Code with -p in scripts, the mode is not for you yet. It also does not replace orchestrating many agents from JavaScript: that is what workflows in Claude Code are for, and Code Mode does not start together with agent teams.
My measurement is small: one task, one model, three runs per mode. Next I will repeat it on a task with edits across many files, where a model without a script really does go through the files one by one.



