Hidden Code Mode in Claude Code: Why 35% Token Savings Means a 17% Discount and 6x SlowdownsArticle · digest for November 25
Comparative studio still life with a mechanical token abacus and stopwatch symbolizing hidden Code Mode.
Article4 sections≈ 7 min

Hidden Code Mode in Claude Code: Why 35% Token Savings Means a 17% Discount and 6x Slowdowns

A year ago, Anthropic engineers pulled off a flashy demo: moving a meeting transcript from Google Drive to Salesforce via generated code slashed usage from 150,000 tokens to 2,000. So when an experimental Code Mode quietly appeared in terminal Claude Code on November 12, 2026, it was tempting to flip the switch and forget about rate limits. Real-world tasks tell a calmer story: input tokens drop by about a third, your actual bill after caching shrinks by a sixth, and checking broken links on Windows can drag from 27 seconds to three minutes.

How One Mini-Script Replaces Dozens of Agent Steps

Normally, Claude Code follows the standard agent loop: it makes a tool call for one file, dumps the entire text into chat history, thinks, and asks for the next one. It's like sending an assistant to a filing cabinet for one folder at a time and having them read every page out loud.

Code Mode flips that workflow. The agent writes a short JavaScript script, and Claude Code runs it right inside the session. The script fires off the needed commands (even in parallel), filters out noise locally, and hands back only the final summary. In filing-cabinet terms, you hand over a note saying: "Grab all 40 folders, sum the totals by client, and bring me the top three."

The name is slightly misleading: you don't write or read code yourself, and your prompts stay plain text. Meanwhile, the starting overhead of every message shrinks. Usually, each request drags along system instructions and schemas for every tool (Bash, Read, Edit, MCP servers)—roughly 60,000 tokens in a typical setup before you even ask a question. Code Mode swaps that whole bundle for a single code tool, cutting the header down to around 38,000 tokens. The concept grew out of Anthropic's November 4, 2025 engineering post on code execution with MCP.

Diagram of agent, MCP server, and code execution replacing direct tool calls (Source: Anthropic Engineering)

The official docs show a quick example of what the agent generates under the hood instead of four rounds of back-and-forth:

// Search for files with the target function using ripgrep
const files = await $`rg -l "function retryPolicy" src`.text();
const target = files.trim().split("\n")[0];

// Update the retry limit and run tests directly from the script
await edit(target, "maxAttempts: 3", "maxAttempts: 5");
({
  edited: target,
  tests: $`npm test -- retryPolicy`.nothrow(),
});

The script locates the file, updates the limit, runs the tests, and returns only the filename and test outcome to the model. Intermediate clutter never touches the context window.

How to Turn It On in the Terminal and Peek Under the Hood

The experiment only works in the native terminal version of Claude Code 2.1.323 or higher—it isn't in Desktop, the VS Code extension, or cloud sessions yet. You need a Claude subscription or Anthropic Console with supported models (Opus 5.5, Sonnet 5.5, Haiku 5.5, Fable 5.2). Custom base URL setups, gateways, and the -p flag won't trigger it.

The easiest way to enable it for a single session is via an environment variable:

# Enable Code Mode for the current Claude Code session only
CLAUDE_CODE_EXPERIMENTAL_CODE_MODE=1 claude

That flag lasts until you close the terminal. To keep it on permanently, add an env block to your user config at ~/.claude/settings.json:

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

Project-level configs inside a repo are blocked from enabling Code Mode on purpose, so a cloned repository can't turn it on behind your back; admins can also lock it out via managed settings. On first launch, you'll see a confirmation prompt, followed by a Code Mode is on indicator. You can't toggle the mode off mid-session.

What gets disabled alongside Code Mode

While the mode is active, Claude in Chrome and Computer Use are unavailable. However, deny/ask rules and PreToolUse hooks still inspect every call inside the JS script. In auto mode, the safety classifier checks the entire script before launch (long jobs can run in the background for up to two hours), and for hooks watching commands like git push, be sure to catch chained variants like cd 'app' && git push.

From the outside, the chat looks normal with the code tucked away. To inspect what the agent actually wrote, press Ctrl + O: this opens the full session log, where each script sits in a collapsible Code row alongside the tools it called.

Four Real Tasks: Where the Records Went and Why Windows Slowed Down

In a real sandbox, Code Mode was tested against standard mode on four small-business tasks: finding the top 3 clients across 40 daily order files, catching every broken link across 30 documents, updating a phone number and price on a 25-page site, and answering a quick question about a single file. Model, prompt, and effort stayed identical, and the orders task ran twice—making five paired comparisons.

Accuracy was a tie: all five runs in both modes got the right answer. For the orders, both named Summit Roofing, Harbor Coffee Co., and Northwind Bakery. The Ctrl + O log showed Code Mode splitting the job into three scripts: reading the 40 files, cleaning duplicates and typos, and tallying paid orders.

Savings, however, brought sobering math, with a wide gap between lab benchmarks and the real bill.

Code Mode savings: from lab benchmark to real bill

Input tokens dropped across all five runs mostly because of the slimmer tool header—which is why even the single-file question got cheaper. Yet the API relies on prompt caching: that repeating header already sits in the cheap cache tier. Trimming it cuts your lowest-cost line item, so the real dollar discount is half the token drop. Plus, regular Claude Code can already write small bash scripts in the terminal, narrowing the gap in practice (though on huge folders, raw token savings will matter more).

The real surprise was speed: Code Mode lost in three of the five runs, winning only on the single question and one orders run. The worst slowdown hit the broken-link check across 30 documents—three minutes instead of 27 seconds, over six times slower. Logs showed why: the JS script spawned over a hundred separate shell processes, one per link. On Windows, starting each new shell is expensive, whereas standard mode checked everything in one command. Even standard mode varies wildly, though: the same orders task took 12 seconds on the first try and 36 on the second.

When to Flip the Switch and When to Stick to Standard

Anthropic recommends Code Mode for three scenarios: bulk repetitive edits across dozens of files, searching code or docs while filtering output before it hits context, and running independent commands in parallel. In practice, there's a fourth case—long sessions where you're bumping against subscription limits and saving ~22,000 tokens per message buys you extra runway.

Keeping the flag on full-time is premature. The feature is experimental, and Anthropic warns it may change or disappear in any release. It's also evolving fast: in the eight days after its November 12 launch, it received 61 fixes and updates, so some of the Windows overhead may vanish soon. For short tasks, or whenever you need Claude in Chrome or Computer Use, standard mode is still faster and more predictable.

Want a deep diveVotes help us choose what to break down in detail. This material has 0 votes.
Sources · 3