Claude Code Adds Experimental Code Mode to Orchestrate Tool Calls with JavaScript
Anthropic's experimental Code Mode lets Claude Code write JavaScript that chains, parallelizes, and filters Bash, Read, and Edit calls, with changes to how auto mode and hooks review those calls. By Daniel Dominguez
Anthropic has introduced an experimental feature called Code Mode to Claude Code. This new capability allows the model to write JavaScript code to manage its tool calls, rather than requesting each tool call separately. Code Mode is currently disabled by default and requires Claude Code version 2.1.323 or later to be enabled, using the CLAUDE_CODE_EXPERIMENTAL_CODE_MODE environment variable.
In a standard conversation with Claude, the model issues a single tool call, evaluates the full result, and then determines the next step. However, with Code Mode, a single script can execute multiple commands concurrently, pass results between calls, and return only the desired output. The documentation provides an example where the model utilizes rg to locate a file, increases a retry limit, runs tests, and returns only the path and test output.
While Code Mode maintains the display of each tool call and diff in the conversation, the generated code resides within the transcript viewer. Anthropic advises this feature for repetitive edits across files, filtering-intensive searches, and independent commands. Scripts will automatically halt after ten minutes of execution. For sessions initiated in auto or bypassPermissions modes, the script will be suspended in the background for up to two hours, allowing the conversation to proceed.
As with all tool calls, the generated code will still be subject to the same deny, ask, and PreToolUse rules. However, in auto mode, the system classifier will review the entire script prior to execution, and cannot access any computed values during runtime.
Notably, Code Mode is not enabled by default and cannot be activated via project settings, even when cloned. Administrators can block access to this feature through managed settings. Additionally, Code Mode is only available within interactive terminal sessions of Claude's native builds, including Opus 5.5, Sonnet 5.5, Haiku 5.5, and Fable 5.2.
Access to Code Mode necessitates a Claude subscription or Console account and is incompatible with the -p flag, the Agent SDK, the VS Code panel, the Desktop app, Amazon Bedrock, gateways, or zero-data-retention organizations. For optimal performance, Agent teams require Claude version 2.1.326.
Despite the promising potential of Code Mode, Anthropic has not released any token or latency figures associated with its implementation. George (@bolyki) conducted a comparison of Code Mode and standard mode across eight Sonnet 5.5 sessions, reporting consistent results and a 20-25% reduction in context size. On larger tasks, Code Mode demonstrated a 37% decrease in token usage and a 19% reduction in cost, while performing slightly slower and costing more on smaller tasks.
Ravi Madabhushi, an engineer specializing in agent authentication infrastructure, raised concerns regarding the impact on authentication, authorization, and audit policies, emphasizing that the core MCP calls and permissions remain unchanged. The feature's origins predate Anthropic's release, having been explored by Cloudflare in the context of MCP and TypeScript APIs.
Anthropic's own documentation outlines how Code Mode can reduce token usage by significant margins, while leveraging Claude Code's built-in tools and permission systems for remote code execution.
Rewritten by urgent.news; may contain errors — check the original.
Source: infoq.com