Back to articles

Code Mode Cuts Claude's Token Bill. It Also Blinds the Guardrail

Updated Nov 18, 2026Dishant Sharma6 min read
Code Mode Cuts Claude's Token Bill. It Also Blinds the Guardrail

The top comment on the r/ClaudeCode thread announcing Code Mode has 303 points and says exactly this:

"Claude code has a 'code' mode? Holy shit"

The next one, at 230 points, is "I wonder when they'll add a Claude mode." Someone replied "Claude Code Code Claude Mode." Another asked if it was covered on Bob Loblaw's Law Blog.

That thread hit 500 points and 115 comments in a day. And almost nobody in it was talking about what the feature does.

I read all 112 comments because i wanted to know what the thing was. i came out knowing more about the joke than the feature. So i read the docs, then Flavio Copes' write-up, where he ran it on a real project.

Fair enough, because the name is bad. But underneath it there is a real change to how Claude Code works. And the joke that followed it around, that Anthropic shipped something Pi and OpenCode already had, is also true.

You should care if you run long agent sessions, because the thing being sold here is not intelligence. It is your token bill.

So here is the thing explained properly, and then where it breaks.

What actually changed

Without Code Mode, Claude makes one tool call at a time. It asks to run Bash, waits, reads the result, then decides the next call. Every result goes back through the model.

With Code Mode, Claude writes one JavaScript program that makes the calls. The program runs in your session. Only what the code returns goes back to Claude.

That is the whole idea. Everything else is consequence.

Here is the example from Anthropic's docs. Ask Claude to bump a retry limit and it might write:

const files = await $`rg -l "function retryPolicy" src`.text();
const target = files.trim().split("\n")[0];
await edit(target, "maxAttempts: 3", "maxAttempts: 5");
({ edited: target, tests: $`npm test -- retryPolicy`.nothrow() });
Enter fullscreen mode Exit fullscreen mode

Three tool calls in one step. Find the file, edit it, run the tests.

Turn it on with CLAUDE_CODE_EXPERIMENTAL_CODE_MODE=1 claude. Needs v2.1.323+, the native build, and an interactive terminal.

One annoyance up front. You do not see the code. You see a summary like "Read 8 files, ran 16 shell commands" plus the diffs.

Press Ctrl+O to expand it. So the feature that makes Claude write code hides the code by default.

i get the reasoning, the point is noise. But my first session i could not tell if it was working.

How the tool calls work inside the script

This is the part i had to read twice.

A backtick template runs a shell command. .text() gives you the output as a string. .nothrow() keeps a failing command from throwing, which matters because npm outdated exits 1 when it finds something.

There is file(path).text() to read a file, and edit() to change one. The last expression is what Claude sees.

Not the whole trace. Just that object.

Flavio Copes ran a real test on his Astro project and Claude never saw the 1,394 lines of his README. It saw { files, total, local, missing, localOk }.

A whole file went through a sieve and came out as five keys.

His first run took 15 seconds. Then a second, smaller script, because six "links" pointed at a file called url. Those were the [link](url) example in inline code.

Claude caught its own false positives. It is not just skipping work, it is checking its work in a cheaper loop.

The permission story is where i got uneasy

Every call inside the script still goes through your deny and ask rules and PreToolUse hooks, under its normal name like Bash. That part works.

Auto mode is different, and worth understanding before you trust it.

In auto mode, the classifier reviews each piece of code before it runs, not each tool call.

Read that again. It does not see values computed at run time. If a path comes from a search result, the classifier never saw that path.

So a call you must control needs a rule or a hook. The classifier is not your guardrail anymore.

Second gotcha. A command can reach your hook as cd 'app' && git push instead of a clean git push. If your hook matches command text, check each part.

And one user raised the exact worry i had: "the filter is the whole point until it hides a failed command. i still want the exit code and the last few lines of a red log in the session, because a short summary of that log is how the bug stays."

That is the real risk. The sieve is also a blindfold.

Where the savings actually come from

Anthropic's own MCP research put a number on this. Tool definitions and results through context cost 150,000 tokens. Moving the work into code cut it to 2,000.

That is 98.7%.

One call per turn Code Mode
Round trips one per call one per script
Long output into context filtered in code
Parallelism limited Promise.all()

Flavio's before and after was less dramatic, more convincing. Broken link check: 35 seconds down to 15. Build, typecheck and npm outdated: 17 down to 14.

The interesting one was 100 production builds. Claude wrote a for loop once, ran 101 shell commands in one script, and answered an unrelated question while it ran.

It took 2:23.

That trick only works in auto or bypassPermissions mode. Waiting code stops after ten minutes. Background code gets two hours.

What it is actually good for

Three shapes of task: a change that repeats across many files, a search whose results need filtering, and several independent commands you can fire at once.

And a fourth that matters more than people admit. Agents calling MCP servers.

The old MCP pattern pushes every intermediate result through the model. Anthropic's example: a two hour transcript going from Drive to Salesforce, through context twice, 50,000 tokens each way. Code Mode keeps it in the sandbox and hands the model a status line.

That is the developer case and the agent case in one feature. Less "smarter model," more "model stops reading its own mail."


Naming things in AI is a mess right now, and this is the cleanest example i have got.

There is plan mode. Auto mode. Ultra code mode.

And now Code Mode.

Someone in that thread asked if Code Mode is just ultracode. Another guessed the next one will be called "mode."

The joke that landed hardest:

We've gone from Claude to Clawed to Fisted

Which is a real trajectory, if you think about it. Whoever names the next feature has painted themselves into a corner.

This is a pattern i notice everywhere now. A tool gets a feature, the feature gets a name, the name is a noun that used to be a verb. Then someone writes a config flag for it and we all pretend that was the plan.

i have a folder of bookmarks for features i only learned existed because a Reddit joke told me. Strange way to find out about a product.

Most people do not need this.

If your task is "read this one file and fix the typo," Code Mode adds a layer and buys nothing. The docs say it outright. Use it on many related calls, not on a quick question.

Most of my repos are small, and on those it quietly does nothing. Which is fine, but it is not a demo.

Also, it is experimental. It can change or get removed in any release.

And people who ran it came back unhappy. One wrote it was "much slower and cost more than regular tool calling" across multiple tasks. Another said Claude "killed its context window with logging."

Third: the language is JavaScript. There are a hundred ways to lose an hour to JS semantics, and a benchmarking script is a great place to find all of them.

No Bedrock, Vertex, a gateway, or a custom base URL. No -p, SDK, VS Code panel, or desktop app. HIPAA and zero-retention orgs are out too.

The part i keep thinking about is that the classifier sees the script and not the runtime values.

Not the token savings. Not the 98.7%, which measures something real but is also the number Anthropic chose to publish. The blind spot.

A 98.7% saving is a sales number. A gate that cannot see the value it approves is a production problem.

We keep adding abstraction to make agents cheaper, and every layer is a layer the safety check has to reach through. Here it cannot reach through.

i would still turn it on for a repo-wide audit. But i would write my own hook first.

Recent posts

View all posts