Tokens to describe Cloudflare’s API
Two tools instead of one per endpoint across 2,500+ endpoints, counted with tiktoken. This is the size of tool definitions, not the cost of a task.
Cloudflare, Feb 2026
MakeBoxEtsy + Claude An experimental Code Mode lets Claude write one short JavaScript program that calls its tools, instead of calling them one at a time and reading every intermediate result. Nothing about the model changed. The loop around it did.
Watch the loop change ↓Write the program. Keep the noise out. Return the answer.
tools the model sees with Code Mode onREPL runs the code · Poll follows background work
// illustrative script shape const files = await glob("src/**/*.ts"); const hits = []; for (const f of files) { const text = await read(f); if (text.includes("oldApi(")) hits.push(f); } // only this reaches the chat: return hits;
Helper names in the snippet are simplified for illustration. Facts: Anthropic’s Code Mode docs.
A coding agent normally works in a strict rhythm. The model asks for one tool—read a file, run a command, query an MCP server. The tool answers. That answer is added to the conversation, the model reads it, decides the next step and asks for the next tool.
For a few steps that is fine. For a task like “check 40 files for a deprecated call” it becomes wasteful: all 40 file bodies land in the context window, even though the model only needs the three file names that match.
Later turns carry that history along, so the same text is processed again and again. Prompt caching makes re-reading cheaper, but it doesn’t make it free.
The idea behind Code Mode is old programming common sense: if the steps can be written as a loop, write the loop. A small program reads and filters the files outside the chat, and the model receives only the three names it needs.
Code Mode arrived as an experimental, off-by-default option in Claude Code v2.1.323, released in mid-November 2026. With it on, Claude stops calling Bash, Read or Edit one by one. It writes JavaScript, and the REPL tool runs that code inside your session. Anthropic docs.
Inside a script, tools keep their usual names—including MCP tools—so one program can combine file work, shell commands and connected services in a single step.
Every tool call inside the code still passes your deny and ask rules and PreToolUse hooks, under the tool’s normal name. In auto mode, the classifier reviews the script before it runs—not each call, and without seeing run-time values. Add "ask": ["REPL"] to approve each script yourself.
Sandbox settings apply to shell commands. The JavaScript itself and its file, web and MCP calls run outside the sandbox—so permission rules, not the sandbox, are what guard them.
The second tool, Poll, follows code that keeps running in the background. Foreground code stops after ten minutes; background code can run for up to two hours. A YouTube walkthrough by Агенты Романа (in Russian), which prompted this article, also says variables survive between REPL calls. Anthropic’s page doesn’t state this either way.
Claude could always write a shell or Python script. The difference is reach: an ordinary script lives in the operating system and can’t call the agent’s own tools or its MCP connections. Code Mode gives the program the agent’s toolbox, with the agent’s permission checks.
Swipe the table to see all columns.
| Approach | Where the code runs | What it can call | What returns to the model |
|---|---|---|---|
| Bash or Python script | Your shell | Programs and files on the machine | Whatever the script prints |
| Claude Code Code Mode | Your Claude Code session (JavaScript) | Claude Code tools by name, including MCP tools, with permission rules per call | What the script returns |
| Server-side Code Mode (e.g. Cloudflare) | The provider’s sandbox | That provider’s API only | What the script returns |
| Gateway (e.g. Executor) | The gateway’s environment | Services connected to the gateway | What the script returns |
Based on Anthropic, Cloudflare and the Executor README (MIT; agents get two tools, skills and execute).
Kenton Varda and Sunil Pai argue that models are better at writing code that calls MCP than at calling MCP directly—they have seen far more code than tool calls. Code runs in V8 isolates with internet access blocked. Post
Alex Zhang and Omar Khattab (MIT CSAIL) put a long prompt into a Python REPL as a variable and let the model peek, grep and call sub-models on parts of it. Post
An API feature where Claude writes orchestration code and only the final output returns to its context. Anthropic reports 37% fewer tokens on complex research tasks. Post
search and execute cover 2,500+ endpoints in about 1,000 tokens of tool definitions. Post
The browser agent library deletes 80% of its code; the agent now writes Python in one persistent REPL directly on the Chrome DevTools Protocol. Release
Code Mode reaches the agent’s built-in tools, not only MCP servers. Docs
You need Claude Code v2.1.323 or later (agent teams need v2.1.326). Check with claude --version. Then start a session with the variable set:
CLAUDE_CODE_EXPERIMENTAL_CODE_MODE=1 claudeOr keep it on for your user account in ~/.claude/settings.json:
{
"env": { "CLAUDE_CODE_EXPERIMENTAL_CODE_MODE": "1" }
}On first use Claude Code asks you to confirm, then shows that Code Mode is on. A project’s settings file can’t switch it on, so a cloned repository can’t enable it for you. Admins can force it off in managed settings by setting the variable to 0. To resume such a session later, keep the variable set when you run claude --continue or --resume.
apiKeyHelper, OpenTelemetry export or DISABLE_TELEMETRY block startup.From the Code Mode documentation, checked November 21, 2026. The feature is experimental and “may change or be removed in any release”.
In the source video the first launch failed because an installed extension relied on Claude Code hooks. Anthropic documents several hook details for Code Mode: a PreToolUse hook that times out refuses the call; Bash hooks must check every part of a compound command; a PostToolUse hook matching REPL can redact output. If startup fails, read the message—it usually names the setting or hook in the way.
Headlines about this trend mix three kinds of numbers: the size of tool descriptions, the tokens a whole task used, and the cost of a run. They aren’t interchangeable. Anthropic’s Code Mode page itself publishes no savings figure.
Two tools instead of one per endpoint across 2,500+ endpoints, counted with tiktoken. This is the size of tool definitions, not the cost of a task.
Cloudflare, Feb 2026Average usage fell from 43,588 to 27,297 tokens with Programmatic Tool Calling in Anthropic’s API. A related API feature, not Claude Code’s Code Mode.
Anthropic, Nov 2025The video’s author ran a series of open-source coding tasks both ways and reports about half the input tokens and a total cost of 71% of normal. No dataset was published; MakeBox did not repeat the test.
Video, 13:25The release claims up to 33 points higher scores and 2–3× faster runs. Its own table notes an OpenAI outage during the run; with provider errors excluded, the score gap against its previous agent wasn’t significant.
browser-use, Nov 2026Savings figures on Anthropic’s own Code Mode page. Any percentage you see for Claude Code comes from someone’s test, not from Anthropic’s documentation.
Retellings sometimes quote larger numbers for browser-use (for example “90% of the code removed”). The release notes say 80%, or 136,866 lines.
ANALYSIS · SCROLL TO EXPLORE · SWIPE ON MOBILE
Conceptual diagram. Stage 03 is our reading of public research, not an announced Anthropic product.
Anthropic’s documentation already mentions agent teams working with Code Mode (from v2.1.326). The video’s author goes further: he reports finding unreleased functions in the Claude Code binary for creating, listing and releasing contexts—likely sub-agents controlled from code. They aren’t documented, and we couldn’t verify them.
The direction matches a research line called Recursive Language Models. There the model doesn’t read a huge input at all. The input sits in a REPL as a variable; the model searches it, splits it and sends parts to sub-models. In the authors’ tests on the OOLONG benchmark at about 132,000 tokens, this setup around the smaller GPT-5-mini beat GPT-5 by more than 34 points. The authors also list the limits: recursive calls block each other, there is no prefix caching, and total cost and runtime have no strong guarantees.
The same idea could apply to a long coding session. Instead of automatic compaction squeezing old history, a model could keep the history as data and choose what to bring back. The catch is caching: Anthropic’s context editing feature warns that clearing old tool results invalidates cached prompt prefixes and causes new cache-write costs. Editing memory freely is not automatically cheaper.
Model releases get the headlines, but this change shows how much depends on the environment around a model. The same Claude can spend far fewer tokens when it is allowed to write the glue code itself. Expect more of the agent’s “plumbing” to move into code the model writes.
If you write code with Claude Code: try Code Mode on a branch, in the terminal, for tasks with many reads, searches or MCP calls. Keep ask rules for risky commands such as git push, consider "ask": ["REPL"] for the first days, and compare your own usage before and after. Don’t rely on the sandbox for the JavaScript part.
If you use Claude with business tools: Code Mode applies to Claude Code in the terminal, not the Claude apps. MCP tools can be called from its scripts under their normal names, so keep confirmation rules on anything that writes, publishes or spends. We have not yet tested MakeBox’s Etsy connector under Code Mode.
MakeBox’s MCP connector gives Claude your listings, keywords and shop data—with confirmation before any change on Etsy.
No. It changes how Claude Code exposes tools to the model. Claude writes JavaScript that calls tools such as Bash, file editing or MCP tools, and Claude Code runs the code in your session.
Use v2.1.323 or later and set CLAUDE_CODE_EXPERIMENTAL_CODE_MODE=1 in your shell or in the env block of ~/.claude/settings.json. Confirm the prompt on first use. Project settings files ignore this variable.
It can, when a task involves many tool calls whose intermediate output doesn’t need to reach the model. Anthropic publishes no savings figure for Code Mode. One YouTube author reported about half the input tokens and 29% lower cost in his own tests; that isn’t an official or independently verified number.
According to Anthropic, each tool call inside the code still goes through deny and ask rules and PreToolUse hooks. In auto mode, the classifier reviews the code before it runs, not each call. Sandbox settings cover shell commands only.
The Desktop app, the VS Code panel, cloud sessions, Remote Control, Claude in Chrome, computer use, gateways and cloud providers such as Bedrock and Foundry, and HIPAA or zero data retention setups.
Cloudflare runs model-written code in its own sandbox against its own API. Claude Code’s version runs in your session and can call any of the agent’s tools, including several MCP servers in one script.
Reviewed November 21, 2026. MakeBox did not run its own Code Mode benchmark; percentages are attributed in the text to the parties that reported them. Diagrams and code snippets are illustrative MakeBox drawings, not screenshots of Claude Code. Published November 21, 2026.