The AI Spotlight Follow
Claude Code Has a New Hidden Switch. Others Using the Same Trick Cut Tokens by Up to 99%
AI Coding

Claude Code Has a New Hidden Switch. Others Using the Same Trick Cut Tokens by Up to 99%

Anthropic quietly added an experimental Code Mode to Claude Code. Instead of hauling every tool result through your conversation, Claude writes a little JavaScript and only brings back the answer. Here's what it is, where the big savings numbers come from, how to turn it on, and how to test whether it actually helps your work.

Advertisement

Most people who use Claude Code all day have hit the same wall: the usage meter.

You give the agent a real job, it does a dozen tool calls, each one dumps a pile of text into the conversation, and by mid-afternoon you're rationing prompts.

On November 12, 2026, Anthropic shipped something that goes straight at that problem. It's called Code Mode, it lives inside Claude Code, and it's off by default. You have to know it exists to turn it on.

The idea behind it isn't new. Other companies using the same pattern have reported token savings of 73%, 98.7% and even 99.9% on specific tasks. One early hands-on comparison on everyday business work landed at a more modest but still meaningful 35%.

Advertisement

Those numbers are wildly different. That's the interesting part. Below: what Code Mode actually does, where each of those figures comes from (and why they don't apply to you directly), how to switch it on, and how to run a fair test on your own work before you change anything.

The one-sentence version

Without Code Mode, Claude calls tools one at a time and reads every result. With Code Mode, Claude writes a small JavaScript program that makes the tool calls itself and returns only what matters.

Anthropic's own documentation puts it almost exactly that way. Normally, Claude asks for a tool call such as Bash, Read or Edit, reads the result, then decides the next step. In Code Mode, "Claude writes a piece of JavaScript that makes the tool calls, and Claude Code runs that code in your session."

That sounds like a minor plumbing change. It isn't. It changes what lands in the model's context window, and the context window is what you pay for.

Why normal tool calling burns tokens

Here's a concrete picture.

Say you use an AI meeting notetaker, and your team keeps client notes in a document tool. Both are connected to Claude through connectors (the technical name is MCP, the Model Context Protocol). You ask: "Save today's client call transcript to the client's page."

Under the hood, the classic flow looks like this:

  1. Claude calls the notetaker tool and pulls the whole transcript. Every word lands in your conversation.
  2. Claude then calls the document tool and sends the whole transcript back out. It passes through the conversation a second time.
  3. Claude reads the confirmation and reports back.

The transcript was never something Claude needed to think about. It just needed to move it. But the model had to read it twice anyway, and every one of those words counts against your context window and your usage.

Anthropic described exactly this kind of case in its engineering write-up on code execution with MCP. In its example, a two-hour sales meeting transcript copied from Google Drive into Salesforce could add roughly 50,000 extra tokens each time it flowed through the model.

The waiter analogy

A helpful way to picture it: classic tool calling is a waiter who carries every single ingredient from the kitchen to your table, shows it to you, then goes back for the next one. Flour, eggs, butter, salt. Your table (the context window) slowly fills with stuff you never wanted to look at.

Code Mode is the waiter handing the kitchen a recipe. The cooking happens back there. You only see the finished plate.

Where the idea came from

Claude Code didn't invent this. The name "Code Mode" was coined by Cloudflare in a September 26, 2025 post that pitched it as a better way to use MCP. The basic insight: language models have seen enormous amounts of real code and are very good at writing it, but they've seen relatively few examples of the special tool-calling format. So let them write code against your tools instead.

Cloudflare's own problem shows why this matters at scale.

Cloudflare's 2,500-endpoint problem

Cloudflare wanted AI agents to be able to use its whole platform: DNS, security rules, Workers, storage and more. Its API has over 2,500 endpoints.

If you exposed each one as a separate tool, with its full description, the model would have to read all of them up front. Cloudflare measured that at about 1.17 million tokens, which it noted is more than the entire context window of the most advanced models. Even a stripped-down version with only required parameters came to about 244,000 tokens.

So Cloudflare built an MCP server with just two tools:

  • search() lets the agent write a little JavaScript to search the API specification and find the handful of endpoints it actually needs.
  • execute() lets it write JavaScript that calls those endpoints, chains them together, handles pagination and returns only the result.

The whole tool surface comes to roughly 1,000 tokens, no matter how many endpoints exist. Cloudflare describes that as a 99.9% reduction in input tokens for an API that size. The generated code runs in a locked-down sandbox with no file system and no credentials exposed to the model.

What's different about Claude Code's version

Cloudflare's version, and the earlier write-up from Anthropic, focused on MCP connectors: the external tools you plug in.

Claude Code's Code Mode goes further. It covers Claude Code's own built-in tools too: the ones that read and edit your files, run shell commands and search your project. According to the docs, one piece of code can:

  • run several commands in parallel,
  • feed the result of one call straight into the next,
  • and return only the output Claude needs to read.

Anthropic's documentation gives a tiny example: raise a retry limit in a codebase. The code finds the file with a search, edits one value, runs the relevant tests and hands back a compact summary. Four steps, one round trip.

You still see each tool call in the conversation, such as the diff. You don't see the JavaScript by default; pressing Ctrl+O opens the transcript viewer, where you can expand a collapsed "Code" row.

The numbers, and what each one really measures

This is where most coverage gets sloppy. Here are the main figures floating around, with what each one actually tested.

Who What they tested Reported result
Cloudflare Exposing its entire 2,500+ endpoint API to an agent ~1.17M tokens of tool definitions down to ~1,000 (99.9%)
Anthropic (2025 write-up) Copying a meeting transcript from Google Drive into Salesforce ~150,000 tokens down to ~2,000 (98.7%)
Datadog 25 real observability tasks, 4 models, 3 runs each Input tokens 159k to 43k per task (73%), accuracy 74% to 90%
Browser Use Its rewritten agent that writes code against the browser directly Reported 2.7 to 5.2 times cheaper per task
Early hands-on test Five everyday business jobs, each run with Code Mode on and off, Opus 5.5 on medium effort About 35% fewer tokens overall

The Datadog result is the most interesting

Datadog's test is worth slowing down on, because it measured quality, not just cost.

The company ran 25 observability tasks covering metrics, logs, traces, error tracking and investigations. Each ran three times per model on four different models, comparing its standard toolset with its code-execution toolset. Because the tasks had known right answers, Datadog could score them.

Results, averaged across models:

  • Input tokens per task fell from 159,000 to 43,000.
  • Tool calls fell from 4.1 to 2.5.
  • Correct answers rose from 74% to 90%.

Every model improved. The biggest jump was Claude Sonnet 5, from 67% to 89% correct.

Why would accuracy go up? A plausible explanation (Datadog's own, and widely repeated) is that the model no longer has to hold huge raw responses in its head and do the joining itself. The code does the joining. The model only sees the evidence. Fewer distractions, fewer chances to lose the thread.

Why your number will be smaller

Notice the pattern. The giant percentages come from cases with huge tool catalogs (Cloudflare) or huge payloads passing through (a two-hour transcript). Those are exactly the cases where the old approach is most wasteful.

Day-to-day coding work is different. Many tasks are short. Many results are small. And sometimes Claude genuinely does need to read the output to reason about it. In those cases there's less waste to cut.

That's why a five-task comparison on ordinary business jobs came in around 35%. It's also why Anthropic itself, according to MarkTechPost's review of the docs, publishes no token-saving figure for Claude Code's Code Mode. One independent measurement found the system-tool context dropping from 24.6k tokens to 11.1k with Code Mode on, but that's a single third-party test.

Fair summary: big savings are real in the right workloads. Your savings depend on how much data your tasks shovel around.

Before you try it: the fine print

Code Mode is explicitly experimental. Anthropic's docs say it "may change or be removed in any release." Here's what you need:

  • Version: Claude Code v2.1.323 or later (v2.1.326+ if you use agent teams).
  • Account: a Claude subscription or a Console account. It does not work through gateways, Amazon Bedrock, Google Cloud, Microsoft Foundry and similar routes.
  • Models: Claude Opus 5.5, Sonnet 5.5, Haiku 5.5 or Fable 5.2.
  • Surface: an interactive session in your terminal only. It doesn't work in the Desktop app, the VS Code panel, cloud sessions, -p (headless) mode or the Agent SDK.
  • Build: the native build of Claude Code. On Windows you need Git for Windows.
  • Organization: not available if your org uses the HIPAA configuration or zero data retention.
  • Not compatible with: Remote Control, Claude in Chrome and computer use.

There are also time limits. Code that Claude is actively waiting on stops after 10 minutes, including time spent at permission prompts. Code running in the background can go for up to 2 hours while you keep chatting, but that requires a session started in auto or bypass-permissions mode.

How to turn it on

The switch is an environment variable (shown in full in step 2 below). Call it the Code Mode variable.

  1. Update. Run claude --version. If you're below v2.1.323, run claude update. If you're on the stable channel and it doesn't reach that version yet, wait or switch to the latest channel.
  2. Start a session with the flag. On macOS, Linux or WSL:
CLAUDE_CODE_EXPERIMENTAL_CODE_MODE=1 claude

In Windows PowerShell, set the same variable to "1" with $env: and then run claude. 3. Confirm. The first time, Claude Code asks you to confirm. Choose "Yes, turn on Code Mode." It restarts and shows a line saying Code Mode (experimental) is on. 4. Make it stick (optional). Put the variable in the env block of ~/.claude/settings.json so every new session starts with it.

Two details that trip people up:

  • A value of 0 anywhere wins. If any settings file sets it to 0, Code Mode stays off even if you set 1 elsewhere.
  • Admins can block it org-wide with a 0 in managed settings. They can't force it on.

How to test whether it's worth it for you

Don't switch your whole workflow on faith. Run a small, honest experiment.

1. Pick five real jobs. Not toy prompts. Things you actually do every week: a multi-file refactor, a search-and-summarize across a repo, a data cleanup, pulling something from one connected tool into another.

2. Run each one twice. Once in a normal session, once with Code Mode on. Same model, same effort setting, same starting state. (The 35% comparison used Opus 5.5 on medium effort for both.)

3. Record three things for each run:

  • tokens or usage consumed,
  • whether the result was correct and complete,
  • how long it took, including any permission prompts.

4. Look at the spread, not just the average. You'll probably find a couple of tasks with big savings and a couple with almost none. That tells you which kinds of work to use it for.

5. Decide by workload. Anthropic's docs recommend Code Mode for three kinds of task:

  • a change that repeats across many files,
  • a search whose results need filtering before Claude reads them,
  • several independent commands that can run at the same time.

If your week is full of those, the case is strong. If it's mostly short, conversational edits, the savings may not justify the switch.

The terminal question

There's one more honest consideration. Right now Code Mode only works in the terminal. If you live in the Desktop app or the VS Code panel, ask yourself whether the savings you measured are worth changing how you work. For heavy users hitting limits daily, probably yes. For lighter users, maybe wait until it reaches the other surfaces.

What changes about safety and permissions

Code Mode changes how reviews happen, and that's worth understanding before you hand it a big job.

  • Your deny and ask rules still apply to every tool call inside the code. PreToolUse hooks still fire under the tool's usual name, like Bash.
  • In auto mode, the safety classifier reviews the code as a whole, not each individual call. That's coarser. It can't see values computed at run time, such as a file path that comes out of a search.
  • In other permission modes, the code starts without review and you're prompted per tool call as usual.

For people who write hooks, Anthropic warns that commands can arrive in shapes you didn't expect. A git push might come through as cd 'app' && git push. If you want to inspect the code itself, the docs say to match the REPL tool and read its input.

Practical takeaway: if you run in auto mode, keep your deny rules tight, especially around pushes, deletes and anything touching production.

The bigger trend: the model swallowing the harness

Code Mode is a small feature pointing at a big shift.

For the last few years, AI labs wrapped models in elaborate scaffolding: long system prompts full of corrections, dozens of carefully described tools, rigid step-by-step formats. That "harness" compensated for models that weren't smart enough to figure things out on their own.

As models get stronger, that scaffolding starts to get in the way. Claude Code's creator, Boris Cherny, has said publicly that the team deleted more than 80% of Claude Code's system prompt for the Opus 5 generation, because much of it was correcting behaviors the new model simply got right on its own.

Browser Use went the same direction. In its 1.0 release, the project deleted roughly 80% of its library and let the agent write Python directly against the browser's debugging protocol, reporting higher scores while being cheaper and faster.

Code Mode fits the pattern. Instead of giving the model a huge menu of narrowly described tools and making it step through them one at a time, you give it a couple of powerful primitives and trust it to write the glue.

It's a reasonable bet that if Anthropic sees good results from early adopters, some version of this becomes the default way Claude Code works. That's speculation, but it's the direction every data point above is pointing.

Counterpoints and risks

Code Mode isn't free lunch. A few honest caveats:

  • It's experimental. Behavior can change between releases, and the feature could be removed. Don't build critical automation on it yet.
  • Less visibility by default. You see the tool calls, but not the code unless you open the transcript. If something goes wrong mid-script, debugging takes an extra step.
  • Coarser review in auto mode. A classifier judging a whole script is not the same as approving each step.
  • Narrow availability. Terminal only, Anthropic API or subscription only, no cloud-provider routes. Teams on Bedrock or Google Cloud can't use it.
  • Vendor numbers are vendor numbers. Cloudflare, Anthropic and Datadog all measured their own products. Datadog's methodology is the most transparent, but independent replication across many workloads is still thin.
  • Some tasks need the model to read everything. If the whole point is for Claude to understand a long document, routing it around the context window defeats the purpose.

Practical takeaways

  • If you're hitting usage limits in Claude Code, Code Mode is the most promising free lever available right now.
  • Test before you trust. Five real tasks, run twice, three measurements each.
  • Use it where it shines: repetitive multi-file changes, searches that need filtering, independent commands that can run in parallel, and moving big payloads between connected tools.
  • Keep your deny rules tight if you combine it with auto mode.
  • Watch the changelog. The Claude Code team has been extending support quickly; by November 19, v2.1.329 had added support for running Code Mode alongside agent teams and OpenTelemetry events.

FAQ

Is Code Mode the same thing as Cloudflare's Code Mode? Same core idea, different scope. Cloudflare applies it to MCP servers and runs the code in its own sandboxes. Claude Code's version applies it to Claude Code's built-in tools (files, shell, search) and runs the code in your session.

Will it make Claude smarter? Not directly. But less clutter in the context window can help accuracy. Datadog's tests saw correct answers rise from 74% to 90% with code execution, though that was on its own observability tasks.

Can I use it in the Claude Desktop app or VS Code? Not yet. As of the current docs it only works in an interactive terminal session.

Which models support it? Claude Opus 5.5, Sonnet 5.5, Haiku 5.5 and Fable 5.2.

How do I turn it off? Start a session without the variable, or set the Code Mode variable to 0. A 0 anywhere in your settings overrides a 1.

The bottom line

Code Mode is the kind of change that's easy to miss and hard to ignore once you've measured it. The headline numbers (99.9%, 98.7%) are real, but they come from extreme cases with massive tool catalogs or massive payloads. For ordinary work, think in the range of "noticeably cheaper," not "basically free."

The smart move is boring: update, flip the switch in one terminal, run your five most common jobs twice and look at the numbers. If your work moves a lot of data around, you'll probably keep it on. And either way, you're getting an early look at how AI coding tools are likely to work next: fewer rigid steps, more trust in the model to write its own glue.

Sources

Drop In a Raw, Messy Take and Get Back a Finished Short: The AI Editing Workflow Creators Are Quietly UsingUp next · 11 min readDrop In a Raw, Messy Take and Get Back a Finished Short: The AI Editing Workflow Creators Are Quietly UsingAI can now take a raw talking-head recording full of pauses and retakes and return a captioned, B-rolled, scored short-form video. Here's the full workflow, built from a fresh Claude account: the project, the connectors, the two skills, the real errors you'll hit, and what this means for editors and for everyone's feeds.Keep reading →