Claude Code has an experimental "Code Mode" that batches tool calls into JavaScript
Summary
An experimental Claude Code mode wraps tool and MCP calls in JavaScript so intermediate data bypasses the model's context. Enable it with CLAUDE_CODE_EXPERIMENTAL_CODE_MODE=1; the discussion covers token savings, prior art from Cloudflare and Pi, and safety concerns.
What the comments say
Code Mode wraps two MCP servers in JavaScript so transcripts pass directly between them instead of through context, avoiding token cost, copy-time hallucination and exposing the data to the model; the pattern traces to Cloudflare's Code Mode.
Plain Python scripting never reached harness tools like MCP; this mode does, a pattern popularized by the Pi agent and later adopted by OpenCode.
Agents dump findings into the session where you write, and the more they dump the more expensive the session gets; this mode filters so only important data reaches the session.
Current frontier models already use scratchpads to hold data and write one-off scripts for composite actions, so they may not load everything into context as claimed.
Enable it by starting the CLI with CLAUDE_CODE_EXPERIMENTAL_CODE_MODE=1 claude; it is not visible in the CLI or the VS Code extension settings.
Risk runs both ways: Claude has filled its own context window with logging, and JavaScript as the scripting language is a questionable choice.
Join the discussion
Was this useful to you?
Related
I think we were giving our agent way too many tools to choose from
r/LLMDevs · for-entire-phonly
How Claude Code's Code Mode works
X · Arindam_1729
62 Claude sessions rebuilding my media library in 80 minutes
aaronorelup.com · Aaron Orelup
Half of What AI Delivers Needs Rework: After Logging 204 Dispatches, Managing AI Is Managing a Team
liuqiwei.dev · 刘启威
I Used 664 Million Tokens to Build My Favorite App Yet
alexlieberman.com · Managing Partner of Tenex