AI
Claude Code's New Experimental Mode Lets AI Write JavaScript to Coordinate Tool Calls
Anthropic's Code Mode lets Claude orchestrate multiple operations in a single script rather than requesting tools one at a time, with trade-offs in efficiency and security considerations.
InfoQ
Anthropic has introduced Code Mode for Claude Code, an experimental capability that shifts how the AI model interacts with its tools. Rather than asking for one operation at a time—each Bash command, file read, or edit request requiring a full review before proceeding—the model now writes JavaScript code that can orchestrate multiple tasks in a single script.
How It Works#
In standard operation, Claude makes a request, reviews the complete result, then determines the next step. Code Mode reverses this workflow: the AI generates a script that can run operations in parallel, chain results together, and filter output before returning only relevant data to the conversation. The documented example runs a file search with rg, adjusts retry limits, executes tests, and surfaces just the file path and test results.
The user-facing experience remains largely transparent—each tool call and code diff still appears in the conversation—while the underlying JavaScript lives in the transcript viewer. Anthropic sees particular value for repeated edits across multiple files, searches requiring filtering, and independent commands that could run simultaneously.
Execution times have limits: scripts stop after 10 minutes in standard operation, but sessions in auto or bypassPermissions mode can push execution to the background for up to two hours while the conversation carries on.
Efficiency Gains (and Trade-Offs)#
Early testing shows mixed results. One user comparing eight runs on Sonnet 5.5 found context windows 20–25% smaller and, on larger tasks, token usage 37% lower with 19% cost savings. However, latency improved on some runs and degraded on others, and smaller tasks actually cost more tokens than the standard approach.
Security Considerations#
The permission model introduces nuance architects should understand closely. Individual tool calls within a script still route through denial rules and PreToolUse hooks, but in auto mode the security classifier evaluates the entire script before execution rather than each call in isolation—and it cannot see values computed at runtime. This means a command like cd 'app' && git push now reaches hooks as a single operation, requiring hooks to inspect every component.
Administrators retain control: Code Mode cannot be enabled through project settings, so cloned repositories cannot activate it unilaterally, and managed settings allow organizational blockage.

