AI News

Claude Code Launches Experimental Code Mode, Enabling Batch Tool Calls via a Single JS Snippet

Shao MengUpdated Nov 15 18:07

English text is being prepared.

AI summary

Claude Code has launched an experimental feature called Code Mode, which is off by default and requires setting CLAUDE_CODE_EXPERIMENTAL_CODE_MODE=1 to enable; once enabled, Claude first writes a piece of JavaScript to call multiple tools at once within the local session, rather than calling Bash, Read, or Edit one by one. The official example changes the retry limit from 3 to 5, allowing an operation that originally took four or five rounds to be completed in one step, and it supports parallel execution of independent commands, passing the result of the previous step directly to the next step, and filtering intermediate output in code before it enters the context. This feature is limited to interactive terminal sessions and does not support -p, the Agent SDK, the VS Code panel, desktop, or cloud sessions, nor can it go through gateways, Bedrock, Google Cloud, or Microsoft Foundry; it only supports Opus 5.5, Sonnet 5.5, Haiku 5.5, and Fable 5.2; in auto mode, the classifier instead reviews the entire code block, and the official recommendation is to use rules or hooks as a fallback for critical calls.

Why read this

SelectedAI score 77

The original article lists in full how to enable Code Mode, the applicable models, and its various limitations, so readers can judge whether their current environment can use it.

Topics

Tags

Body

Claude Code 推出实验功能 Code Mode:从一次调一个工具,到写一段 JS 批量调工具

Code Mode 默认关闭,要自己打开。打开以后,Claude 调工具的方式变了:以前每次只调一个 Bash、Read 或 Edit,看完结果再决定下一步;现在 Claude 先写一段 JavaScript,在里面一次调用多个工具,由 Claude Code 在本地会话里执行。

https://t.co/3U7bRP0jgq

# 具体怎么工作

官方举例是把重试上限从 3 改成 5。Claude 会写一段代码:先用 rg 找到文件,再改参数,接着跑相关测试,最后只把文件路径和测试输出交还给自己看。原本要来回四五轮的操作,现在一步就能做完。

这样做有三个好处。几个独立的命令可以并行跑;上一步的结果可以直接传给下一步,不用经过模型;中间产生的大量输出可以先在代码里筛一遍,只把需要的部分放进上下文。官方推荐的用法也围绕这几点:同一处改动要改很多文件、搜索结果需要先过滤再读、几个独立的命令可以同时跑。

对话界面里看到的仍然是每一次工具调用,比如编辑的 diff。想看背后的代码,按 Ctrl+O 打开记录,展开 Code 行就能看到。

# 门槛和限制

开启方法是设置 CLAUDE_CODE_EXPERIMENTAL_CODE_MODE=1,可以在 shell 里临时设,也可以写进 ~/.claude/settings.json。写在项目的设置文件里不生效,所以克隆下来的仓库没法替你偷偷打开它。第一次开启时,Claude Code 会先请你确认。

限制不少: · 只能在终端的交互式会话里用,不支持 -p、Agent SDK、VS Code 面板、桌面端和云端会话。 · 不能走网关、Bedrock、Google Cloud 或 Microsoft Foundry,也不能用 API key helper。 · 只支持 Opus 5.5、Sonnet 5.5、Haiku 5.5 和 Fable 5.2。 · 开着 agent teams、OpenTelemetry 导出或 DISABLE_TELEMETRY 时无法启动。 · 用 Code Mode 开的会话,恢复时也必须开着 Code Mode。 · 代码在前台跑,最长 10 分钟;放到后台最长 2 小时,但要求会话在 auto 或 bypassPermissions 模式下启动。

# 权限怎么管

代码里的每一次工具调用,仍然要经过你的 deny、ask 规则和 PreToolUse hook。真正变化的是 auto 模式:分类器现在审的是整段代码,不再一次次审单个调用,而且看不到运行时才算出来的值,比如从搜索结果里取出的路径。官方明确建议,必须管住的调用要靠规则或 hook 兜底。想审代码本身,可以写一个匹配 REPL 的 hook,从 tool_input.code 读出 JS。企业可以在托管设置里把这个变量设成 0,全员禁用。

Source

Shao Meng