Claude 一次處理多個步驟時,逐一呼叫工具會花時間,也可能把大量搜尋結果塞進上下文。
- Claude Code 的實驗性功能 Code Mode 會用 JavaScript 編排多個工具操作,例如平行搜尋多個檔案、整理結果,再批次修改。
- 長時間工作也能在背景執行,最長可達兩小時。使用者仍可照常用提示詞和 Claude 互動,也能用
/tasks檢視及管理背景工作,或按 Ctrl+O 檢視 Claude 產生的 JavaScript。每次工具呼叫仍受現有許可權規則和沙箱限制。
AI 伴隨問答
針對這篇報導有疑問?可直接點選快捷問題或向 AI 追問背景脈絡與技術細節:
Code Mode 把多步工具操作交給 JavaScript 一次編排,也能在背景執行長工作,文中並說明如何檢視程式碼與管理背景任務。
Code Mode is an experimental new feature in Claude Code that can improve both speed and context efficiency when Claude needs to orchestrate multiple steps. Try it out and let us know what you think!
It enables Claude to perform multi-step tool calls by writing and running JavaScript. Rather than calling one tool at a time (e.g. Bash, Read, or Edit) and waiting to see the result before deciding what to do next, Code Mode allows Claude to write a simple script to run multiple commands in parallel, passing arguments and filtering outputs for subsequent tool calls to reduce context.
I'm excited about this work because Code Mode enables more efficient and streamlined multi-step coding flows. For example, rather than passing large amounts of raw search data into the context window or having to make a large number of sequential calls to perform the same refactoring across dozens of files, Claude can orchestrate these tasks programmatically in a single pass.
Still, you will be able to interact with Claude as normal through natural prompts. And if you ever need to see the exact JavaScript that Claude generated, you can always use Ctrl+O to expand the collapsed Code rows in the transcript viewer.
One of the most exciting practical improvements from Code Mode is its ability to perform long-running operations, like running test suites or complex builds, as background processes. When Code Mode is running in either auto or bypassPermissions mode, scripts can run in the background for up to two hours. You can continue to interact with Claude and perform other work within the same session. The /tasks command provides complete transparency and control over background scripts.
Each tool call that is generated within a script is still governed by your current deny and ask permission policies, sandbox constraints, and PreToolUse hooks. Hooks can even be defined specifically for the REPL tool to inspect the generated JavaScript before running, or redact sensitive tokens from the output before reading it into the context.
To enable Code Mode, just start your session with CLAUDE_CODE_EXPERIMENTAL_CODE_MODE=1 claude or set the environment variable in your ~/.claude/settings.json file.
Give it a try by running multi-file audits, batch edits, or any type of parallel search-and-filter operation. Code Mode is experimental and the team is actively iterating on it, so please run /feedback in your terminal to let us know what works well and where you hit any edges.
Hope it's helpful!