Code Mode
by Anthropic · Technique · Text & code
Lets a coding agent write JavaScript scripts that call its file, shell and edit functions in loops, so intermediate results stay out of the conversation and fewer tokens are used.
Experimental Claude Code mode that cuts token cost 19-29% on bigger tasks; not faster
Latest · Nov 23Added to Claude Code as an experimental feature: the model writes JavaScript to drive tools instead of separate Bash, Read or Edit calls.
Who says what
Early daysАгенты Романа (Roman's Agents) and George (@bolyki), who ran it on real tasks
Агенты Романа (Roman's Agents)'s runs on open-source tasks used about half the input tokens and cost 71% of normal mode. George's eight Sonnet 5.5 runs got the same results with 20-25% smaller context, and 37% fewer tokens and 19% lower cost on the bigger task, but no speedup and a higher cost on a tiny one.
Daniel Dominguez, reporting on its limits, and Ravi Madabhushi
Dominguez notes it runs only in interactive terminal sessions of the native build, not with -p, the Agent SDK, VS Code or Bedrock, and that auto mode's classifier checks the script without seeing values computed at runtime. Madabhushi argues it leaves MCP authentication, authorization and audit unchanged; only what enters the context window changes.
What would settle it. Anthropic has published no token or latency figures; a test across many task sizes would show where the saving starts.
Evidence
- Nov 23Claude Code gained an experimental Code Mode where the model writes scripts that call toolsReported
Агенты Романа (Roman's Agents)Maker's claimAnthropicvia
InfoQ - Nov 23
- Nov 23
- Nov 23Each call in a script still passes deny/ask rules and PreToolUse hooks, but in auto mode the classifier reviews the script before it runs and cannot see runtime-computed values.ReportedDaniel Dominguezvia
InfoQ - Nov 23Project settings cannot enable Code Mode, so a cloned repository cannot switch it on; administrators can block it via managed settings.ReportedDaniel Dominguezvia
InfoQ
Show all 16
- Nov 23Runs only in interactive terminal sessions of the native build, via a Claude subscription or Console account; not with -p, Agent SDK, VS Code, Desktop, Bedrock, gateways or zero-data-retention orgs.ReportedDaniel Dominguezvia
InfoQ - Nov 23Across eight interactive Sonnet 5.5 runs: same results, context 20-25% smaller; on the bigger task 37% fewer tokens and 19% lower cost versus normal mode. Not faster; costlier on a tiny task.Hands-on testGeorge (@bolyki)via
InfoQ - Nov 23Anthropic has published no token or latency figures for Code Mode.ReportedDaniel Dominguezvia
InfoQ - Nov 23Argued Code Mode doesn't change authentication, authorization or audit layers for MCP; the agent makes the same MCP calls with the same tokens, and only context in the model window changes.Community reportRavi Madabhushivia
InfoQ - Nov 23Unlike Cloudflare's sandboxed Workers or the Claude API's remote container, Claude Code's Code Mode runs the script in the developer's local session against built-in tools and permissions.ReportedDaniel Dominguezvia
InfoQ - Nov 20In the author's own runs on real open-source tasks, Code Mode used about half the input tokens and cost 71% of normal mode (~29% saving); not a universal discount.Hands-on test
Агенты Романа (Roman's Agents) - Nov 20Unlike server-side or MCP-only versions, Anthropic's Code Mode also exposes built-in tools (read, write, edit, Bash) as functions callable from the model's code.Reported
Агенты Романа (Roman's Agents) - Nov 20Its JavaScript REPL keeps variables between calls, so large results can be filtered and sorted in code without entering context; a Poll tool checks long-running background scripts.Reported
Агенты Романа (Roman's Agents) - Nov 20Enabled with CLAUDE_CODE_EXPERIMENTAL_CODE_MODE=1; in the demo it conflicted with a Claude Code hooks-based add-on, and the model then listed only two tools.Hands-on test
Агенты Романа (Roman's Agents) - Nov 20Demo: asked to join Stripe and PostHog data into an HTML report of top-LTV customers, Claude wrote JavaScript with loops and tool calls.Hands-on test
Агенты Романа (Roman's Agents) - Nov 20Three unreleased context-management functions (create, list, release a context) found next to Code Mode in the Claude Code binary, apparently for running sub-agents from the REPL.Reported
Агенты Романа (Roman's Agents)