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.

promising

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

  1. Nov 23
    Claude Code gained an experimental Code Mode where the model writes scripts that call tools
  2. Nov 23
    Off by default; needs Claude Code v2.1.323 or later and CLAUDE_CODE_EXPERIMENTAL_CODE_MODE=1. Anthropic warns it may change or be removed in any release.
    Maker's claimAnthropicviaInfoQ
  3. Nov 23
    One script can run commands in parallel, pass results between calls and return only needed output; recommended for multi-file edits, filtered searches and independent commands.
    Maker's claimAnthropicviaInfoQ
  4. Nov 23
    Each 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.
  5. Nov 23
    Project settings cannot enable Code Mode, so a cloned repository cannot switch it on; administrators can block it via managed settings.
Show all 16
  1. Nov 23
    Runs 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.
  2. Nov 23
    Across 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)viaInfoQ
  3. Nov 23
    Anthropic has published no token or latency figures for Code Mode.
  4. Nov 23
    Argued 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 MadabhushiviaInfoQ
  5. Nov 23
    Unlike 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.
  6. Nov 20
    In 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.
  7. Nov 20
    Unlike 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.
  8. Nov 20
    Its 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.
  9. Nov 20
    Enabled 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.
  10. Nov 20
    Demo: asked to join Stripe and PostHog data into an HTML report of top-LTV customers, Claude wrote JavaScript with loops and tool calls.
  11. Nov 20
    Three 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.

Everything said about Code Mode, on the wire

Cost to run

Alternatives

Works with