Addy Osmani Explains Claude Code's Experimental Code Mode
Claude Code's experimental Code Mode can use a JavaScript snippet to orchestrate multiple tool calls and pass and filter intermediate results, reducing tool round trips and context usage. The feature requires Claude Code v2.1.323 or later and the CLAUDE_CODE_EXPERIMENTAL_CODE_MODE=1 setting, and currently supports only interactive terminal sessions. Background scripts can run for up to two hours, but this does not automatically provide sandbox isolation for JavaScript or file, web, and MCP calls.
Why read this
SelectedAI score 77
This overview explains how Code Mode works, its activation requirements, and its permission boundaries, helping users determine which coding workflows it is best suited for.
Topics
Body · AI translation
Addy Osmani on Claude Code’s Experimental Code Mode: Orchestrating Tool Calls with JavaScript to Reduce Waiting and Context Usage
Addy Osmani shared details about Claude Code’s experimental Code Mode: Claude can first generate a JavaScript program that calls multiple tools, passes intermediate results, and filters output within a single run, ultimately returning only the necessary information to the model’s context. Users still describe tasks in natural language; the change occurs at the tool-execution layer.
https://code.claude.com/docs/en/code-mode
# Turning Multiple Rounds of Tool Calls into a Single Program
In a conventional workflow, the model performs a search, reads the results, and then decides on the next call. Code Mode allows related steps to be written into the same script: independent operations run in parallel, dependent operations are performed sequentially, and large volumes of search results are filtered before the useful portions are returned.
The official example involves locating a file containing a particular function, changing the number of retries, and then running tests, ultimately returning only the file path and test output. When modifying dozens of files in bulk, it can also reduce repeated calls and the amount of context occupied by intermediate data.
Specific tool operations and modification diffs remain visible in the conversation; pressing Ctrl+O expands the generated JavaScript for inspection.
# Background Tasks Can Run for Up to Two Hours, but Permissions and Sandboxing Must Be Distinguished
In auto or bypassPermissions mode, long-running scripts can be moved to the background and run for up to two hours. Users can continue the conversation in the meantime and view or stop them using /tasks. Foreground scripts that cannot be moved to the background stop after ten minutes.
Tool calls within scripts remain subject to denial and confirmation rules, as well as pre-execution hooks. However, there are two important boundaries: in auto mode, the classifier reviews the entire script rather than reviewing each individual call within it; and sandbox restrictions apply to shell commands invoked by the script, while JavaScript itself and file, web, and MCP calls do not enter the sandbox as a result. Enabling Code Mode does not mean that every operation gains sandbox isolation.
# How Do You Enable It, and What Tasks Is It Suited For?
Officially, Claude Code v2.1.323 or later is required. Set the CLAUDE_CODE_EXPERIMENTAL_CODE_MODE=1 environment variable before starting it. It currently supports only interactive terminal sessions, not the VS Code panel, desktop app, or cloud sessions, and the feature remains subject to change.
Suitable tasks include multi-file inspections, bulk refactoring, parallel searches, and result filtering. The main benefits come from reducing round trips between the model and tools and keeping intermediate results that the model does not need to read inside the script.
AI Trends