SpyBara
Go Premium

Documentation 2026-11-13 23:02 UTC to 2026-11-14 23:57 UTC

79 files changed +1,300 −778. View all changes and history on the product overview
2026
Wed 25 11:59 Tue 24 22:59 Mon 23 23:59 Sun 22 22:59 Sat 21 22:57 Fri 20 23:57 Thu 19 23:00 Wed 18 23:59 Tue 17 23:01 Mon 16 23:59 Sat 14 23:57 Fri 13 23:02 Thu 12 23:02 Wed 11 22:59 Tue 10 21:57 Mon 9 23:02 Sun 8 22:58 Sat 7 23:58 Fri 6 23:01 Thu 5 23:03 Wed 4 23:59 Tue 3 23:58 Mon 2 23:57 Sun 1 23:57

advisor.md +3 −3

Details

8 8 

9> [!NOTE]9> [!NOTE]

10>10>

11> 顧問工具是實驗性功能,需要 Anthropic API 或 [Claude Platform on AWS](https://code.claude.com/docs/zh-TW/claude-platform-on-aws.md)。在 Claude Platform on AWS 上,需要 Claude Code v2.1.300 或更新版本。它在 Amazon Bedrock、Google Cloud 的 Agent Platform 或 Microsoft Foundry 上不可用。行為、定價和可用性可能會變更。11> 顧問工具是實驗性功能,需要 Anthropic API、[Claude Platform on AWS](https://code.claude.com/docs/zh-TW/claude-platform-on-aws.md) 或 [Claude Models on Google Cloud (Anthropic managed)](https://code.claude.com/docs/zh-TW/claude-models-on-google-cloud-anthropic-managed.md)。在 Claude Platform on AWS 或 Claude Models on Google Cloud (Anthropic managed) 上,需要 Claude Code v2.1.300 或更新版本。它在 Amazon Bedrock、Google Cloud 的 Agent Platform 或 Microsoft Foundry 上不可用。行為、定價和可用性可能會變更。

12 12 

13顧問工具讓 Claude 在任務期間的關鍵時刻諮詢第二個通常更強大的模型,例如在提交方案前、遇到重複錯誤時,或在宣佈任務完成前。顧問會收到完整的對話記錄,包括每個工具呼叫和結果,並返回 Claude 在繼續前應用的指導。13顧問工具讓 Claude 在任務期間的關鍵時刻諮詢第二個通常更強大的模型,例如在提交方案前、遇到重複錯誤時,或在宣佈任務完成前。顧問會收到完整的對話記錄,包括每個工具呼叫和結果,並返回 Claude 在繼續前應用的指導。

14 14 


174 174 

175## 需求175## 需求

176 176 

177* **提供者**:Anthropic API 或 [Claude Platform on AWS](https://code.claude.com/docs/zh-TW/claude-platform-on-aws.md),而非 Amazon Bedrock、Google Cloud 的 Agent Platform 或 Microsoft Foundry。在 Claude Platform on AWS 上,顧問需要 Claude Code v2.1.300 或更新版本。177* **提供者**:Anthropic API、[Claude Platform on AWS](https://code.claude.com/docs/zh-TW/claude-platform-on-aws.md) 或 [Claude Models on Google Cloud (Anthropic managed)](https://code.claude.com/docs/zh-TW/claude-models-on-google-cloud-anthropic-managed.md),而非 Amazon Bedrock、Google Cloud 的 Agent Platform 或 Microsoft Foundry。在 Claude Platform on AWS 或 Claude Models on Google Cloud (Anthropic managed) 上,顧問需要 Claude Code v2.1.300 或更新版本。

178* **LLM 閘道**:透過設定有 `ANTHROPIC_BASE_URL` 的 [LLM 閘道](https://code.claude.com/docs/zh-TW/llm-gateway)時,可用性取決於閘道是否將請求完整轉發到 Anthropic API。如果閘道或其上游無法識別顧問工具,請參閱[自動重試和錯誤轉發](https://code.claude.com/docs/zh-TW/llm-gateway-protocol.md#automatic-retry-and-error-forwarding)以了解 Claude Code 如何回應。178* **LLM 閘道**:透過設定有 `ANTHROPIC_BASE_URL` 的 [LLM 閘道](https://code.claude.com/docs/zh-TW/llm-gateway)時,可用性取決於閘道是否將請求完整轉發到 Anthropic API。如果閘道或其上游無法識別顧問工具,請參閱[自動重試和錯誤轉發](https://code.claude.com/docs/zh-TW/llm-gateway-protocol.md#automatic-retry-and-error-forwarding)以了解 Claude Code 如何回應。

179* **支援的主要模型**:Fable、Opus 4.6 或更新版本、Sonnet 4.6 或更新版本、Haiku 4.5,或 Haiku 5.5。請參閱[選擇顧問模型](#choose-an-advisor-model)以了解每個顧問接受的模型。179* **支援的主要模型**:Fable、Opus 4.6 或更新版本、Sonnet 4.6 或更新版本、Haiku 4.5,或 Haiku 5.5。請參閱[選擇顧問模型](#choose-an-advisor-model)以了解每個顧問接受的模型。

180* **功能旗標擷取**:除非您使用的是 Claude Platform on AWS,否則顧問需要從 Anthropic 擷取的功能旗標。設定了關閉擷取之變數(例如 `DISABLE_TELEMETRY`)的工作階段不會有該旗標。若要檢查您的工作階段,請參閱[哪些工作階段會略過擷取或在沒有該旗標的情況下啟動](https://code.claude.com/docs/zh-TW/env-vars.md#features-that-need-feature-flag-fetching)。180* **功能旗標擷取**:除非您使用的是 Claude Platform on AWS 或 Claude Models on Google Cloud (Anthropic managed),否則顧問需要從 Anthropic 擷取的功能旗標。設定了關閉擷取之變數(例如 `DISABLE_TELEMETRY`)的工作階段不會有該旗標。若要檢查您的工作階段,請參閱[哪些工作階段會略過擷取或在沒有該旗標的情況下啟動](https://code.claude.com/docs/zh-TW/env-vars.md#features-that-need-feature-flag-fetching)。

181 181 

182## 關閉顧問182## 關閉顧問

183 183 

Details

392 392 

393### 要求特定工具的核准393### 要求特定工具的核准

394 394 

395將工具的 `permission_policy` 設為 `always_ask`,`allowedTools` 就不再核准該工具的呼叫,因此即使該工具已列出,這些呼叫仍可到達您的 [`canUseTool`](https://code.claude.com/docs/zh-TW/agent-sdk/user-input) 回呼。若改為設定 `always_deny`,[對該工具的呼叫會被拒絕](https://code.claude.com/docs/zh-TW/agent-sdk/permissions.md#how-permissions-are-evaluated),但您載入的外掛中的 [mod](https://code.claude.com/docs/zh-TW/plugins/mods/overview.md) [仍可核准它](https://code.claude.com/docs/zh-TW/permissions.md#precedence-among-rules-hooks-and-mods)。此欄位僅適用於 TypeScript,且需要 Agent SDK v0.3.301 或更新版本。395將工具的 `permission_policy` 設為 `always_ask`,`allowedTools` 就不再核准該工具的呼叫,因此即使該工具已列出,這些呼叫仍可到達您的 [`canUseTool`](https://code.claude.com/docs/zh-TW/agent-sdk/user-input) 回呼。若改為設定 `always_deny`,則會[封鎖該工具](https://code.claude.com/docs/zh-TW/agent-sdk/typescript.md#permission-policy-values)。此欄位僅適用於 TypeScript,且需要 Agent SDK v0.3.301 或更新版本。

396 396 

397請將政策項目放在 `createSdkMcpServer()` 傳回的設定物件上的 `tools` 陣列中,而不是放在您傳入該函式的 `tools` 選項中。此範例展開[天氣工具範例](#weather-tool-example)中的 `weatherServer`,並新增一個 `tools` 陣列,為 `get_temperature` 指定 `always_ask` 政策:397請將政策項目放在 `createSdkMcpServer()` 傳回的設定物件上的 `tools` 陣列中,而不是放在您傳入該函式的 `tools` 選項中。此範例展開[天氣工具範例](#weather-tool-example)中的 `weatherServer`,並新增一個 `tools` 陣列,為 `get_temperature` 指定 `always_ask` 政策:

398 398 

Details

14 14 

15## checkpointing 如何運作15## checkpointing 如何運作

16 16 

17當您啟用檔案 checkpointing 時,SDK 會在透過 Write、Edit 或 NotebookEdit 工具修改檔案之前建立檔案備份。回應串流中的使用者訊息包含一個 checkpoint UUID,您可以將其用作還原點。17當您啟用檔案檢查點功能時,SDK 會在透過 Write、Edit 或 NotebookEdit 工具修改檔案之前建立檔案備份。每個開始一個回合的提示詞都是一個檢查點,而其使用者訊息的 UUID 就是還原點。

18 18 

19> [!NOTE]19> [!NOTE]

20>20>


147 147 

148**2. 捕捉 checkpoint UUID 和工作階段 ID**148**2. 捕捉 checkpoint UUID 和工作階段 ID**

149 149 

150設定 `replay-user-messages` 選項後,回應串流中的每個使用者訊息都有一個 UUID,可作為 checkpoint。150設定 `replay-user-messages` 選項後,每個開始一個回合的提示詞所對應的使用者訊息都有一個 UUID,可作為檢查點。攜帶工具結果的使用者訊息也有 UUID,但該 UUID 並不是檢查點。

151 151 

152對於大多數使用案例,捕捉第一個使用者訊息 UUID(`message.uuid`);回溯到它會將受追蹤的檔案還原到其原始狀態。若要儲存多個 checkpoint 並回溯到中間狀態,請參閱[多個還原點](#multiple-restore-points)。152對於大多數使用案例,捕捉第一個使用者訊息 UUID(`message.uuid`);回溯到它會將受追蹤的檔案還原到其原始狀態。若要儲存多個 checkpoint 並回溯到中間狀態,請參閱[多個還原點](#multiple-restore-points)。

153 153 


171 171 

172### 在危險操作前進行 checkpoint172### 在危險操作前進行 checkpoint

173 173 

174此模式只保留最新的 checkpoint UUID,在每個代理程式轉向前更新它。如果在處理期間出現問題,您可以立即回溯到最後的安全狀態並跳出迴圈。174此模式只保留最新的 checkpoint UUID,並在每個開始新回合的提示詞處更新它。如果在處理期間出現問題,您可以立即回溯到最後的安全狀態並跳出迴圈。

175 175 

176執行此範例前,請將 `your_revert_condition`(Python)或 `yourRevertCondition`(TypeScript)替換為您自己的檢查,例如錯誤偵測或驗證失敗;此範例中未定義預留位置。176執行此範例前,請將 `your_revert_condition`(Python)或 `yourRevertCondition`(TypeScript)替換為您自己的檢查,例如錯誤偵測或驗證失敗;此範例中未定義預留位置。

177 177 


193 await client.query("Refactor the authentication module")193 await client.query("Refactor the authentication module")

194 194 

195 async for message in client.receive_response():195 async for message in client.receive_response():

196 # Update checkpoint before each agent turn starts196 # Update checkpoint at each prompt you send; a tool result isn't one

197 # This overwrites the previous checkpoint. Only keep the latest197 # This overwrites the previous checkpoint. Only keep the latest

198 if isinstance(message, UserMessage) and message.uuid:198 if (

199 isinstance(message, UserMessage)

200 and message.uuid

201 and message.tool_use_result is None

202 and message.parent_tool_use_id is None

203 ):

199 safe_checkpoint = message.uuid204 safe_checkpoint = message.uuid

200 205 

201 # Decide when to revert based on your own logic206 # Decide when to revert based on your own logic


225 let safeCheckpoint: string | undefined;230 let safeCheckpoint: string | undefined;

226 231 

227 for await (const message of response) {232 for await (const message of response) {

228 // Update checkpoint before each agent turn starts233 // Update checkpoint at each prompt you send; a tool result isn't one

229 // This overwrites the previous checkpoint. Only keep the latest234 // This overwrites the previous checkpoint. Only keep the latest

230 if (message.type === "user" && message.uuid) {235 if (message.type === "user" && "isReplay" in message && message.isReplay && message.uuid) {

231 safeCheckpoint = message.uuid;236 safeCheckpoint = message.uuid;

232 }237 }

233 238 


246 251 

247### 多個還原點252### 多個還原點

248 253 

249如果 Claude 在多個轉向中進行變更,您可能想要回溯到特定點而不是一直回到開始。例如,如果 Claude 在第一個轉向中重構檔案,在第二個轉向中新增測試,您可能想要保留重構但撤銷測試。254如果 Claude 在多個提示詞中進行變更,您可能想要回溯到特定點而不是一直回到開始。例如,如果您的第一個提示詞重構了檔案,第二個提示詞新增了測試,請回溯到第二個提示詞的 checkpoint,以保留重構並撤銷測試。

250 255 

251此模式將所有 checkpoint UUID 儲存在具有中繼資料的陣列中。工作階段完成後,您可以回溯到任何先前的 checkpoint:256此模式將每個 checkpoint UUID 連同中繼資料儲存在陣列中。工作階段完成後,您可以回溯到任何先前的 checkpoint:

252 257 

253```python Python theme={null}258```python Python theme={null}

254import asyncio259import asyncio


284 await client.query("Refactor the authentication module")289 await client.query("Refactor the authentication module")

285 290 

286 async for message in client.receive_response():291 async for message in client.receive_response():

287 if isinstance(message, UserMessage) and message.uuid:292 if (

293 isinstance(message, UserMessage)

294 and message.uuid

295 and message.tool_use_result is None

296 and message.parent_tool_use_id is None

297 ):

288 checkpoints.append(298 checkpoints.append(

289 Checkpoint(299 Checkpoint(

290 id=message.uuid,300 id=message.uuid,


338 348 

339 try {349 try {

340 for await (const message of response) {350 for await (const message of response) {

341 if (message.type === "user" && message.uuid) {351 if (message.type === "user" && "isReplay" in message && message.isReplay && message.uuid) {

342 checkpoints.push({352 checkpoints.push({

343 id: message.uuid,353 id: message.uuid,

344 description: `After turn ${checkpoints.length + 1}`,354 description: `After turn ${checkpoints.length + 1}`,


638 648 

639* 檔案 checkpointing 未在原始工作階段上啟用(`enable_file_checkpointing` 或 `enableFileCheckpointing` 未設定為 `true`)649* 檔案 checkpointing 未在原始工作階段上啟用(`enable_file_checkpointing` 或 `enableFileCheckpointing` 未設定為 `true`)

640* 在嘗試恢復和回溯之前,工作階段未正確完成650* 在嘗試恢復和回溯之前,工作階段未正確完成

651* UUID 來自攜帶工具結果的使用者訊息,而該訊息並非檢查點

641 652 

642**解決方案**:確保在原始工作階段上設定了 `enable_file_checkpointing=True`(Python)或 `enableFileCheckpointing: true`(TypeScript),然後使用範例中顯示的模式:捕捉第一個使用者訊息 UUID,完全完成工作階段,然後使用空提示恢復並呼叫 `rewindFiles()` 一次。653**解決方案**:確保在原始工作階段上設定了 `enable_file_checkpointing=True`(Python)或 `enableFileCheckpointing: true`(TypeScript),然後使用範例中顯示的模式:捕捉第一個使用者訊息 UUID,完全完成工作階段,然後使用空提示恢復並呼叫 `rewindFiles()` 一次。

643 654 

Details

496| **持久性** | 每個專案檔案 | 儲存為檔案 | 僅限會話 | 僅限會話 |496| **持久性** | 每個專案檔案 | 儲存為檔案 | 僅限會話 | 僅限會話 |

497| **可重複使用性** | 每個專案 | 跨專案 | 程式碼重複 | 程式碼重複 |497| **可重複使用性** | 每個專案 | 跨專案 | 程式碼重複 | 程式碼重複 |

498| **管理** | 在檔案系統上 | CLI + 檔案 | 在程式碼中 | 在程式碼中 |498| **管理** | 在檔案系統上 | CLI + 檔案 | 在程式碼中 | 在程式碼中 |

499| **預設工具** | 保留 | 保留 | 保留 | 遺失(除非包含) |499| **工具指引** | 保留 | 保留 | 保留 | 遺失(除非包含) |

500| **內建安全** | 維持 | 維持 | 維持 | 必須新增 |500| **內建安全** | 維持 | 維持 | 維持 | 必須新增 |

501| **自訂程度** | 僅新增 | 新增;可省略程式設計指示 | 僅新增 | 完全控制 |501| **自訂程度** | 僅新增 | 新增;可省略程式設計指示 | 僅新增 | 完全控制 |

502| **版本控制** | 與專案一起 | 是 | 與程式碼一起 | 與程式碼一起 |502| **版本控制** | 與專案一起 | 是 | 與程式碼一起 | 與程式碼一起 |

Details

26 26 

27如果來自 `disallowed_tools` 或來自 [SDK 載入的設定檔](#rules-in-settings-files)的拒絕規則匹配,呼叫會被拒絕,且不會呼叫 [`canUseTool`](https://code.claude.com/docs/zh-TW/agent-sdk/user-input)。即使在 [`bypassPermissions`](#bypass-permissions-mode-bypasspermissions) 模式下,以及即使 hook 返回了 `allow`,呼叫也會以這種方式被拒絕。27如果來自 `disallowed_tools` 或來自 [SDK 載入的設定檔](#rules-in-settings-files)的拒絕規則匹配,呼叫會被拒絕,且不會呼叫 [`canUseTool`](https://code.claude.com/docs/zh-TW/agent-sdk/user-input)。即使在 [`bypassPermissions`](#bypass-permissions-mode-bypasspermissions) 模式下,以及即使 hook 返回了 `allow`,呼叫也會以這種方式被拒絕。

28 28 

29在 TypeScript SDK 中,如果您將[自訂工具](https://code.claude.com/docs/zh-TW/agent-sdk/custom-tools.md#require-approval-for-specific-tools)的 `permission_policy` 設定為 [`always_deny`](https://code.claude.com/docs/zh-TW/agent-sdk/typescript#mcpservertoolpolicy),對該工具的呼叫會在此步驟被拒絕。

30 

31**3. 詢問規則**29**3. 詢問規則**

32 30 

33檢查來自 [settings.json](https://code.claude.com/docs/zh-TW/settings-reference.md#permission-settings) 的 `ask` 規則。如果詢問規則匹配,呼叫會傳遞到您的 [`canUseTool` 回呼](https://code.claude.com/docs/zh-TW/agent-sdk/user-input) 以進行確認,即使在 `bypassPermissions` 模式下也是如此。31檢查來自 [settings.json](https://code.claude.com/docs/zh-TW/settings-reference.md#permission-settings) 的 `ask` 規則。如果詢問規則匹配,呼叫會傳遞到您的 [`canUseTool` 回呼](https://code.claude.com/docs/zh-TW/agent-sdk/user-input) 以進行確認,即使在 `bypassPermissions` 模式下也是如此。

Details

875| `allowed_tools` | `list[str]` | `[]` | 無需提示即可自動核准的工具,但從[網路路徑](https://code.claude.com/docs/zh-TW/permissions.md#network-paths)讀取的操作除外。這不會限制 Claude 只使用這些工具。如果您在此處命名其中一個[任務追蹤工具](https://code.claude.com/docs/zh-TW/agent-sdk/todo-tracking.md#model-availability),Claude Code 也會為工作階段選擇加入。其他未列出的工具會進入 `permission_mode` 和 `can_use_tool`。使用 `disallowed_tools` 來封鎖工具。請參閱[權限](https://code.claude.com/docs/zh-TW/agent-sdk/permissions.md#allow-and-deny-rules) |875| `allowed_tools` | `list[str]` | `[]` | 無需提示即可自動核准的工具,但從[網路路徑](https://code.claude.com/docs/zh-TW/permissions.md#network-paths)讀取的操作除外。這不會限制 Claude 只使用這些工具。如果您在此處命名其中一個[任務追蹤工具](https://code.claude.com/docs/zh-TW/agent-sdk/todo-tracking.md#model-availability),Claude Code 也會為工作階段選擇加入。其他未列出的工具會進入 `permission_mode` 和 `can_use_tool`。使用 `disallowed_tools` 來封鎖工具。請參閱[權限](https://code.claude.com/docs/zh-TW/agent-sdk/permissions.md#allow-and-deny-rules) |

876| `system_prompt` | `str \| SystemPromptPreset \| SystemPromptCustom \| SystemPromptFile \| None` | `None` | 系統提示詞設定。傳遞字串以取得自訂提示詞、`{"type": "preset", "preset": "claude_code"}` 以取得 Claude Code 的系統提示詞(含選用的 `"append"`)、`{"type": "custom", "prompt": "..."}` 以取得也可以設定 `"snapshot"` 的自訂提示詞,或 `{"type": "file", "path": "..."}` 以從磁碟載入大型提示詞。請參閱 [`SystemPromptPreset`](#systempromptpreset)、[`SystemPromptCustom`](#systempromptcustom) 和 [`SystemPromptFile`](#systempromptfile) |876| `system_prompt` | `str \| SystemPromptPreset \| SystemPromptCustom \| SystemPromptFile \| None` | `None` | 系統提示詞設定。傳遞字串以取得自訂提示詞、`{"type": "preset", "preset": "claude_code"}` 以取得 Claude Code 的系統提示詞(含選用的 `"append"`)、`{"type": "custom", "prompt": "..."}` 以取得也可以設定 `"snapshot"` 的自訂提示詞,或 `{"type": "file", "path": "..."}` 以從磁碟載入大型提示詞。請參閱 [`SystemPromptPreset`](#systempromptpreset)、[`SystemPromptCustom`](#systempromptcustom) 和 [`SystemPromptFile`](#systempromptfile) |

877| `mcp_servers` | `dict[str, McpServerConfig] \| str \| Path` | `{}` | MCP 伺服器設定或設定檔的路徑 |877| `mcp_servers` | `dict[str, McpServerConfig] \| str \| Path` | `{}` | MCP 伺服器設定或設定檔的路徑 |

878| `strict_mcp_config` | `bool` | `False` | 當為 `True` 時,僅使用在 `mcp_servers` 中傳遞的伺服器,並忽略專案 `.mcp.json`、使用者設定、外掛提供的 MCP 伺服器和 [claude.ai 連接器](https://code.claude.com/docs/zh-TW/mcp.md#use-mcp-servers-from-claude-ai)。對應至 CLI `--strict-mcp-config` 旗標 |878| `strict_mcp_config` | `bool` | `False` | 當為 `True` 時,使用在 `mcp_servers` 中傳遞的伺服器,並忽略專案 `.mcp.json`、使用者設定、外掛提供的 MCP 伺服器和 [claude.ai 連接器](https://code.claude.com/docs/zh-TW/mcp.md#use-mcp-servers-from-claude-ai)。對應至 CLI `--strict-mcp-config` 旗標 |

879| `permission_mode` | `PermissionMode \| None` | `None` | 工具使用的權限模式 |879| `permission_mode` | `PermissionMode \| None` | `None` | 工具使用的權限模式 |

880| `continue_conversation` | `bool` | `False` | 繼續最近的對話 |880| `continue_conversation` | `bool` | `False` | 繼續最近的對話 |

881| `resume` | `str \| None` | `None` | 要繼續的工作階段 ID |881| `resume` | `str \| None` | `None` | 要繼續的工作階段 ID |


895| `add_dirs` | `list[str \| Path]` | `[]` | Claude 可以存取的其他目錄。SDK 將每個項目傳遞給 Claude Code 作為 `--add-dir`,因此使用 `project` 設定來源時,Claude Code 也會[載入目錄的 skill、命令和 subagent](https://code.claude.com/docs/zh-TW/permissions.md#additional-directories-grant-file-access-not-configuration) |895| `add_dirs` | `list[str \| Path]` | `[]` | Claude 可以存取的其他目錄。SDK 將每個項目傳遞給 Claude Code 作為 `--add-dir`,因此使用 `project` 設定來源時,Claude Code 也會[載入目錄的 skill、命令和 subagent](https://code.claude.com/docs/zh-TW/permissions.md#additional-directories-grant-file-access-not-configuration) |

896| `env` | `dict[str, str]` | `{}` | 合併在繼承程序環境之上的環境變數。請參閱[環境變數](https://code.claude.com/docs/zh-TW/env-vars.md)以取得基礎 CLI 讀取的變數,以及[處理緩慢或停滯的 API 回應](#handle-slow-or-stalled-api-responses)以取得逾時相關變數。設定 `CLAUDE_AGENT_SDK_CLIENT_APP` 以在 User-Agent 標頭中識別您的應用程式 |896| `env` | `dict[str, str]` | `{}` | 合併在繼承程序環境之上的環境變數。請參閱[環境變數](https://code.claude.com/docs/zh-TW/env-vars.md)以取得基礎 CLI 讀取的變數,以及[處理緩慢或停滯的 API 回應](#handle-slow-or-stalled-api-responses)以取得逾時相關變數。設定 `CLAUDE_AGENT_SDK_CLIENT_APP` 以在 User-Agent 標頭中識別您的應用程式 |

897| `extra_args` | `dict[str, str \| None]` | `{}` | 要直接傳遞給 CLI 的其他 CLI 引數 |897| `extra_args` | `dict[str, str \| None]` | `{}` | 要直接傳遞給 CLI 的其他 CLI 引數 |

898| `max_buffer_size` | `int \| None` | `None` | 緩衝 CLI stdout 時的最大位元組數 |898| `max_buffer_size` | `int \| None` | `None` | SDK 從 CLI 接受的單一訊息最大長度(以字元為單位)。`None` 使用 1,048,576。更長的訊息會引發 [`CLIJSONDecodeError`](#clijsondecodeerror) |

899| `debug_stderr` | `Any` | `sys.stderr` | *已棄用* - SDK 會忽略此值。使用 `stderr` 回呼以取得 CLI stderr 輸出 |899| `debug_stderr` | `Any` | `sys.stderr` | *已棄用* - SDK 會忽略此值。使用 `stderr` 回呼以取得 CLI stderr 輸出 |

900| `stderr` | `Callable[[str], None] \| None` | `None` | CLI 中 stderr 輸出的回呼函式 |900| `stderr` | `Callable[[str], None] \| None` | `None` | CLI 中 stderr 輸出的回呼函式 |

901| `can_use_tool` | [`CanUseTool`](#canusetool) ` \| None` | `None` | 工具權限回呼,僅在[權限流程](https://code.claude.com/docs/zh-TW/agent-sdk/permissions.md#how-permissions-are-evaluated)進入提示時叫用。不會針對由 `allowed_tools`、允許規則或 `permission_mode` 自動核准的呼叫叫用。允許規則不會預先核准[任何模式都不自動核准的動作](https://code.claude.com/docs/zh-TW/permission-modes.md#actions-no-mode-auto-approves)。請參閱 [`CanUseTool`](#canusetool) 以取得詳細資訊 |901| `can_use_tool` | [`CanUseTool`](#canusetool) ` \| None` | `None` | 工具權限回呼,僅在[權限流程](https://code.claude.com/docs/zh-TW/agent-sdk/permissions.md#how-permissions-are-evaluated)進入提示時叫用。不會針對由 `allowed_tools`、允許規則或 `permission_mode` 自動核准的呼叫叫用。允許規則不會預先核准[任何模式都不自動核准的動作](https://code.claude.com/docs/zh-TW/permission-modes.md#actions-no-mode-auto-approves)。請參閱 [`CanUseTool`](#canusetool) 以取得詳細資訊 |


1244| 欄位 | 類型 | 說明 |1244| 欄位 | 類型 | 說明 |

1245| :- | :- | :- |1245| :- | :- | :- |

1246| `signal` | `Any \| None` | 保留供未來中止信號支援 |1246| `signal` | `Any \| None` | 保留供未來中止信號支援 |

1247| `suggestions` | `list[PermissionUpdate]` | 來自 CLI 的權限更新建議。Bash 提示包含具有 `localSettings` 目的地的建議,因此在 `updated_permissions` 中傳回它會將規則寫入 `.claude/settings.local.json` 並跨工作階段保存。 |1247| `suggestions` | `list[PermissionUpdate]` | 來自 CLI 的權限更新建議。Bash 提示可能包含具有 `localSettings` 目的地的建議,因此在 `updated_permissions` 中傳回它會將規則寫入 `.claude/settings.local.json` 並跨工作階段保存。 |

1248| `tool_use_id` | `str \| None` | 此提示所針對的特定工具呼叫的識別碼。傳遞至 `can_use_tool` 時始終填入 |1248| `tool_use_id` | `str \| None` | 此提示所針對的特定工具呼叫的識別碼。傳遞至 `can_use_tool` 時始終填入 |

1249| `agent_id` | `str \| None` | 呼叫源自 subagent 時的 subagent ID;主 agent 為 `None` |1249| `agent_id` | `str \| None` | 呼叫源自 subagent 時的 subagent ID;主 agent 為 `None` |

1250| `blocked_path` | `str \| None` | 觸發權限請求的檔案路徑(如適用)。例如,當 Bash 命令嘗試存取允許目錄外的路徑時 |1250| `blocked_path` | `str \| None` | 觸發權限請求的檔案路徑(如適用)。例如,當 Bash 命令嘗試存取允許目錄外的路徑時 |


1725* `is_error`:當對話以錯誤狀態結束時為 `True`。在 `error_*` subtypes 上始終為 `True`。在 `subtype="success"` 上,有三種情況會為 `True`。請檢查 `stop_reason` 加以區分:1725* `is_error`:當對話以錯誤狀態結束時為 `True`。在 `error_*` subtypes 上始終為 `True`。在 `subtype="success"` 上,有三種情況會為 `True`。請檢查 `stop_reason` 加以區分:

1726 * `"refusal"`:模型拒絕回應。請在 `result` 中讀取拒絕文字,若 `result` 為空,則在前面的 `AssistantMessage` 中讀取。1726 * `"refusal"`:模型拒絕回應。請在 `result` 中讀取拒絕文字,若 `result` 為空,則在前面的 `AssistantMessage` 中讀取。

1727 * `"tool_deferred_unavailable"`:當您恢復工作階段時,[延遲的工具](https://code.claude.com/docs/zh-TW/hooks.md#defer-a-tool-call-for-later)已不再可用,例如因為其 MCP 伺服器未連線。在以下兩種情況中,恢復後傳送的提示詞與隨恢復一起傳遞的提示詞視為相同:1727 * `"tool_deferred_unavailable"`:當您恢復工作階段時,[延遲的工具](https://code.claude.com/docs/zh-TW/hooks.md#defer-a-tool-call-for-later)已不再可用,例如因為其 MCP 伺服器未連線。在以下兩種情況中,恢復後傳送的提示詞與隨恢復一起傳遞的提示詞視為相同:

1728 * 沒有提示詞:該呼叫仍待處理。讓工具可用後,再次在不附提示詞的情況下恢復,該呼叫會先執行。1728 * 沒有提示詞:預設情況下,該呼叫仍待處理。讓工具可用後,再次在不附提示詞的情況下恢復,該呼叫會先執行。

1729 * 有提示詞:Claude Code 會在沒有工具結果的情況下回答該提示詞,且延遲的呼叫會消失。如果您仍需要呼叫該工具,請傳送新的提示詞。1729 * 有提示詞:預設情況下,該提示詞不會送達 Claude,且該呼叫仍待處理。若要在沒有該工具的情況下繼續,請[捨棄該呼叫](https://code.claude.com/docs/zh-TW/hooks.md#resume-when-a-deferred-tool-is-unavailable)。

1730 * 任何其他值:該回合以 Claude Code 取代模型回應而回報的錯誤結束,例如 API 錯誤。請讀取 `terminal_reason` 以了解原因、讀取 `result` 以取得訊息,並在 API 傳回 HTTP 狀態時讀取 `api_error_status` 以取得該狀態。1730 * 任何其他值:該回合以 Claude Code 取代模型回應而回報的錯誤結束,例如 API 錯誤。請讀取 `terminal_reason` 以了解原因、讀取 `result` 以取得訊息,並在 API 傳回 HTTP 狀態時讀取 `api_error_status` 以取得該狀態。

1731* `api_error_status`:終止 API 錯誤的 HTTP 狀態碼。當轉在沒有錯誤的情況下結束時為 `None`。僅在 `subtype="success"` 上填入。1731* `api_error_status`:終止 API 錯誤的 HTTP 狀態碼。當轉在沒有錯誤的情況下結束時為 `None`。僅在 `subtype="success"` 上填入。

1732* `result`:在 `subtype="success"` 上為最終助手消息的文字,或在 `error_*` subtypes 上為 `None`。當 `subtype="success"` 且 `is_error=True` 時,如果可用,此欄位會保存 API 錯誤字串,但可能為空,因此請檢查 `api_error_status` 和前面的 `AssistantMessage` 內容以獲取詳細資訊。1732* `result`:在 `subtype="success"` 上為最終助手消息的文字,或在 `error_*` subtypes 上為 `None`。當 `subtype="success"` 且 `is_error=True` 時,如果可用,此欄位會保存 API 錯誤字串,但可能為空,因此請檢查 `api_error_status` 和前面的 `AssistantMessage` 內容以獲取詳細資訊。

1733* `errors`:迴圈級別的錯誤字串,例如最大轉數消息。僅在 `error_*` subtypes 上填入。1733* `errors`:迴圈級別的錯誤字串,例如最大轉數消息。僅在 `error_*` subtypes 上填入。

1734* `terminal_reason`:查詢迴圈結束的原因,例如 `"completed"`、`"max_turns"`、`"api_error"`、`"aborted_streaming"` 或 `"aborted_tools"`。`"aborted_streaming"` 或 `"aborted_tools"` 的值表示轉在完成前被中止。常見原因是 [`interrupt()`](#claudesdkclient) 和權限回呼返回 [`PermissionResultDeny`](#permissionresultdeny) 且 `interrupt=True`。在早於該欄位的 CLI 版本上為 `None`,在本地命令(例如 `/voice` 或 `/usage`)的結果上為 `None`,這些命令繞過查詢迴圈,或在 session 致命失敗時發出的合成錯誤結果上為 `None`。鏡像 TypeScript SDK 的 [`SDKResultMessage.terminal_reason`](https://code.claude.com/docs/zh-TW/agent-sdk/typescript#sdkresultmessage),其列出完整的值集。1734* `terminal_reason`:查詢迴圈結束的原因,例如 `"completed"`、`"max_turns"`、`"api_error"`、`"aborted_streaming"` 或 `"aborted_tools"`。`"aborted_streaming"` 或 `"aborted_tools"` 的值表示該回合在完成前被中止。常見原因是 [`interrupt()`](#claudesdkclient),以及權限回呼傳回 [`PermissionResultDeny`](#permissionresultdeny) 且 `interrupt=True`。在早於該欄位的 CLI 版本上、在本機命令(例如 `/voice` 或 `/usage`,這些命令會繞過查詢迴圈)的結果上,或在工作階段發生致命失敗時發出的合成錯誤結果上,此欄位為 `None`。對應 TypeScript SDK 的 [`SDKResultMessage.terminal_reason`](https://code.claude.com/docs/zh-TW/agent-sdk/typescript#sdkresultmessage),其中列出完整的值集。

1735* `origin`:觸發此轉的使用者消息的來源。在[串流輸入模式](https://code.claude.com/docs/zh-TW/agent-sdk/streaming-vs-single-mode.md)中,檢查此項以區分您自己提示的結果(其中 `origin` 為 `None` 或 `{"kind": "human"}`)與注入轉(例如背景任務通知)的結果。需要 Python Agent SDK 0.2.137 或更新版本。1735* `origin`:觸發此轉的使用者消息的來源。在[串流輸入模式](https://code.claude.com/docs/zh-TW/agent-sdk/streaming-vs-single-mode.md)中,檢查此項以區分您自己提示的結果(其中 `origin` 為 `None` 或 `{"kind": "human"}`)與注入轉(例如背景任務通知)的結果。需要 Python Agent SDK 0.2.137 或更新版本。

1736 1736 

1737當數個背景任務在相近的時間內完成時,Claude Code 可以在一個回合中回應它們的通知,而不是每個通知各用一個回合。您仍會依序為每個通知收到一個 `ResultMessage`,每個都帶有 `kind` 為 `"task-notification"` 的 `origin`。除最後一個之外,其餘的 `num_turns` 皆設為 `0` 且 `result` 為空,而最後一個則承載回應所有通知的回合。1737當數個背景任務在相近的時間內完成時,Claude Code 可以在一個回合中回應它們的通知,而不是每個通知各用一個回合。您仍會依序為每個通知收到一個 `ResultMessage`,每個都帶有 `kind` 為 `"task-notification"` 的 `origin`。除最後一個之外,其餘的 `num_turns` 皆設為 `0` 且 `result` 為空,而最後一個則承載回應所有通知的回合。


2083 2083 

2084### `CLIJSONDecodeError`2084### `CLIJSONDecodeError`

2085 2085 

2086當 JSON 解析失敗時引發。2086當 JSON 解析失敗,或來自 CLI 的單一訊息長度超過 `max_buffer_size` 時引發。若要提高此限制並接續已停止的工作,請參閱[大型工具呼叫與結果](https://code.claude.com/docs/zh-TW/agent-sdk/troubleshooting.md#large-tool-calls-and-results)。

2087 2087 

2088```python theme={null}2088```python theme={null}

2089class CLIJSONDecodeError(ClaudeSDKError):2089class CLIJSONDecodeError(ClaudeSDKError):


2429class SyncHookJSONOutput(TypedDict):2429class SyncHookJSONOutput(TypedDict):

2430 # Control fields2430 # Control fields

2431 continue_: NotRequired[bool] # Whether to proceed (default: True)2431 continue_: NotRequired[bool] # Whether to proceed (default: True)

2432 suppressOutput: NotRequired[bool] # Hide stdout from transcript2432 suppressOutput: NotRequired[bool] # Has no effect

2433 stopReason: NotRequired[str] # Message when continue is False2433 stopReason: NotRequired[str] # Message when continue is False

2434 2434 

2435 # Decision fields2435 # Decision fields


2517 2517 

2518### Hook 使用範例2518### Hook 使用範例

2519 2519 

2520此範例註冊兩個 hook:一個阻止危險的 Bash 命令(如 `rm -rf /`),另一個記錄所有工具使用情況以進行稽核。透過其 [`Bash` matcher](https://code.claude.com/docs/zh-TW/agent-sdk/hooks#matchers),安全 hook 會在 Bash 工具呼叫上執行。記錄 hook 沒有 matcher,因此會在每次工具呼叫時執行。2520此範例註冊兩個 hook:一個阻止危險的 Bash 命令(如 `rm -rf /`),另一個記錄所有工具使用情況以進行稽核。透過其 [`Bash` matcher](https://code.claude.com/docs/zh-TW/agent-sdk/hooks#matchers),安全 hook 會在 Bash 工具呼叫上執行。日誌 hook 沒有 matcher,因此會符合每個工具。

2521 2521 

2522```python theme={null}2522```python theme={null}

2523import asyncio2523import asyncio


3583| 屬性 | 類型 | 預設 | 描述 |3583| 屬性 | 類型 | 預設 | 描述 |

3584| :- | :- | :- | :- |3584| :- | :- | :- | :- |

3585| `enabled` | `bool` | `False` | 為命令執行啟用沙箱模式 |3585| `enabled` | `bool` | `False` | 為命令執行啟用沙箱模式 |

3586| `autoAllowBashIfSandboxed` | `bool` | `True` | 啟用沙箱時自動批准 bash 命令 |3586| [`autoAllowBashIfSandboxed`](https://code.claude.com/docs/zh-TW/settings-reference#sandbox-autoallowbashifsandboxed) | `bool` | `False` | 啟用沙箱時自動核准 Bash 命令。`False` 預設值需要 Python SDK v0.2.182 或更新版本 |

3587| `excludedCommands` | `list[str]` | `[]` | 繞過沙箱限制的命令,例如 `["docker *"]`。這些自動執行沙箱外,無需模型參與;[`sandbox.excludedCommands`](https://code.claude.com/docs/zh-TW/settings-reference#sandbox-excludedcommands) 涵蓋何時適用項目 |3587| `excludedCommands` | `list[str]` | `[]` | 繞過沙箱限制的命令,例如 `["docker *"]`。這些自動執行沙箱外,無需模型參與;[`sandbox.excludedCommands`](https://code.claude.com/docs/zh-TW/settings-reference#sandbox-excludedcommands) 涵蓋何時適用項目 |

3588| `allowUnsandboxedCommands` | `bool` | `True` | 允許模型請求在沙箱外執行命令。當為 `True` 時,模型可以在 tool 輸入中設定 `dangerouslyDisableSandbox`,這會回退到[權限系統](#permissions-fallback-for-unsandboxed-commands) |3588| `allowUnsandboxedCommands` | `bool` | `True` | 允許模型請求在沙箱外執行命令。當為 `True` 時,模型可以在 tool 輸入中設定 `dangerouslyDisableSandbox`,這會回退到[權限系統](#permissions-fallback-for-unsandboxed-commands) |

3589| `network` | [`SandboxNetworkConfig`](#sandboxnetworkconfig) | `None` | 網路特定的沙箱配置 |3589| `network` | [`SandboxNetworkConfig`](#sandboxnetworkconfig) | `None` | 網路特定的沙箱配置 |


3594>3594>

3595> 沙箱取決於平台支援,在 Linux 上,需要 `bubblewrap` 和 `socat` 等工具。預設情況下,當 `enabled` 為 `True` 但沙箱無法啟動時,命令會在沙箱外執行,並在 stderr 上顯示警告。此預設與 TypeScript SDK 不同,其中 `failIfUnavailable` 預設為 `true`。3595> 沙箱取決於平台支援,在 Linux 上,需要 `bubblewrap` 和 `socat` 等工具。預設情況下,當 `enabled` 為 `True` 但沙箱無法啟動時,命令會在沙箱外執行,並在 stderr 上顯示警告。此預設與 TypeScript SDK 不同,其中 `failIfUnavailable` 預設為 `true`。

3596>3596>

3597> 在沙箱設定中設定 `"failIfUnavailable": True` 以改為停止。SDK 會將 `failIfUnavailable` 連同已宣告的 `SandboxSettings` 欄位一起轉發給 Claude Code。`query()` 接著會回報 `ResultMessage`,其中 `subtype="error_during_execution"` 且原因在 `errors` 中。因為這是單次 `query()` 呼叫,SDK 會在產生該錯誤結果後引發例外,所以請將迴圈包裝在 try 區塊中以便繼續執行。請參閱[處理結果](https://code.claude.com/docs/zh-TW/agent-sdk/agent-loop.md#handle-the-result)以了解錯誤合約。3597> 在沙箱設定中設定 `"failIfUnavailable": True` 以改為停止。設定 `failIfUnavailable` 後,當沙箱無法啟動時,`query()` 會引發 [`ResultError`](#resulterror),因此請將您的 `async for` 迴圈包裝在 `try` 區塊中。原因位於該例外的 `errors` 清單中。SDK 會將 `failIfUnavailable` 連同已宣告的 `SandboxSettings` 欄位一起轉發給 Claude Code。

3598 3598 

3599若要防止沙箱化命令寫入某個檔案,請在沙箱設定的 [`denyWrite`](https://code.claude.com/docs/zh-TW/settings-reference#sandbox-filesystem-denywrite) 下列出其絕對路徑,例如 `"filesystem": {"denyWrite": ["/home/user/project/.env"]}`。SDK 會將 `filesystem` 連同已宣告的 `SandboxSettings` 欄位一起轉發給 Claude Code。沙箱啟動後,會封鎖對您列出的每個絕對路徑的寫入。3599若要防止沙箱化命令寫入某個檔案,請在沙箱設定的 [`denyWrite`](https://code.claude.com/docs/zh-TW/settings-reference#sandbox-filesystem-denywrite) 下列出其絕對路徑,例如 `"filesystem": {"denyWrite": ["/home/user/project/.env"]}`。SDK 會將 `filesystem` 連同已宣告的 `SandboxSettings` 欄位一起轉發給 Claude Code。沙箱啟動後,會封鎖對您列出的每個絕對路徑的寫入。

3600 3600 


3621 ):3621 ):

3622 print(message)3622 print(message)

3623 except Exception as error:3623 except Exception as error:

3624 # A single-shot query() raises after yielding an error result,3624 # query() raises, for example, when failIfUnavailable is set

3625 # such as when failIfUnavailable is set and the sandbox can't start.3625 # and the sandbox can't start.

3626 print(f"Session ended with an error: {error}")3626 print(f"Session ended with an error: {error}")

3627 3627 

3628 3628 

Details

340| `Read`、`Edit`、`Glob` | 分析和修改代碼 |340| `Read`、`Edit`、`Glob` | 分析和修改代碼 |

341| `Read`、`Edit`、`Bash`、`Glob`、`Grep` | 完全自動化 |341| `Read`、`Edit`、`Bash`、`Glob`、`Grep` | 完全自動化 |

342 342 

343若要將 agent 的內建工具限制為其中一組,請將其作為 `tools` 傳入。如果您改為在 `allowedTools` 中列出一組工具,則是[預先核准這些工具](https://code.claude.com/docs/zh-TW/agent-sdk/custom-tools.md#configure-allowed-tools),agent 仍可呼叫其他工具,但須遵循您的權限模式。

344 

343**權限模式**控制您想要多少人工監督。SDK 會按照固定順序評估活躍模式以及您的允許和拒絕規則,詳見[權限如何被評估](https://code.claude.com/docs/zh-TW/agent-sdk/permissions.md#how-permissions-are-evaluated)。如需完整的模式列表、其行為以及何時使用各個模式,請參閱[代理迴圈如何運作中的權限模式](https://code.claude.com/docs/zh-TW/agent-sdk/agent-loop.md#permission-mode)。345**權限模式**控制您想要多少人工監督。SDK 會按照固定順序評估活躍模式以及您的允許和拒絕規則,詳見[權限如何被評估](https://code.claude.com/docs/zh-TW/agent-sdk/permissions.md#how-permissions-are-evaluated)。如需完整的模式列表、其行為以及何時使用各個模式,請參閱[代理迴圈如何運作中的權限模式](https://code.claude.com/docs/zh-TW/agent-sdk/agent-loop.md#permission-mode)。

344 346 

345## 後續步驟347## 後續步驟

Details

146| `prompt` | `string` | 是 | 代理的系統提示,定義其角色和行為 |146| `prompt` | `string` | 是 | 代理的系統提示,定義其角色和行為 |

147| `tools` | `string[]` | 否 | 允許的工具名稱陣列。如果省略,會繼承[子代理可用的每個工具](https://code.claude.com/docs/zh-TW/sub-agents.md#available-tools) |147| `tools` | `string[]` | 否 | 允許的工具名稱陣列。如果省略,會繼承[子代理可用的每個工具](https://code.claude.com/docs/zh-TW/sub-agents.md#available-tools) |

148| `disallowedTools` | `string[]` | 否 | 要從代理工具集中移除的工具名稱陣列。也接受 MCP 伺服器層級的模式:`mcp__server` 或 `mcp__server__*` 會移除該伺服器的每個工具,而 `mcp__*` 會移除任何伺服器的每個 MCP 工具 |148| `disallowedTools` | `string[]` | 否 | 要從代理工具集中移除的工具名稱陣列。也接受 MCP 伺服器層級的模式:`mcp__server` 或 `mcp__server__*` 會移除該伺服器的每個工具,而 `mcp__*` 會移除任何伺服器的每個 MCP 工具 |

149| `model` | `string` | 否 | 此代理的模型覆寫。接受別名,例如 `'fable'`、`'opus'`、`'sonnet'`、`'haiku'`、`'inherit'`,或完整的模型 ID。`'inherit'` 使用主要模型。當您省略它時,Claude Code 會選擇[子代理模型順序](https://code.claude.com/docs/zh-TW/sub-agents.md#choose-a-model)中的模型 |149| `model` | `string` | 否 | 此 agent 的模型覆寫。接受別名,例如 `'fable'`、`'opus'`、`'sonnet'`、`'haiku'`、`'inherit'`,或完整的模型 ID。`'inherit'` 使用產生此 agent 的那個 agent 的模型。當您省略 `model` 時,Claude Code 會選擇[subagent 模型順序](https://code.claude.com/docs/zh-TW/sub-agents.md#choose-a-model)中的模型 |

150| `skills` | `string[]` | 否 | 在啟動時預先載入 agent 上下文的 skill 名稱清單。清單中最多只會預先載入[前 32 個不重複的名稱](https://code.claude.com/docs/zh-TW/sub-agents.md#preload-skills-into-subagents)。未列出的 skill 仍可透過 Skill 工具叫用 |150| `skills` | `string[]` | 否 | 在啟動時預先載入 agent 上下文的 skill 名稱清單。清單中最多只會預先載入[前 32 個不重複的名稱](https://code.claude.com/docs/zh-TW/sub-agents.md#preload-skills-into-subagents)。未列出的 skill 仍可透過 Skill 工具叫用 |

151| `memory` | `'user' \| 'project' \| 'local'` | 否 | 此代理的記憶來源 |151| `memory` | `'user' \| 'project' \| 'local'` | 否 | 此代理的記憶來源 |

152| `mcpServers` | `(string \| object)[]` | 否 | 此代理可用的 MCP 伺服器,按名稱或內嵌設定 |152| `mcpServers` | `(string \| object)[]` | 否 | 此代理可用的 MCP 伺服器,按名稱或內嵌設定 |

Details

4 4 

5# 排除 Agent SDK 的故障5# 排除 Agent SDK 的故障

6 6 

7> 當 Claude Code CLI 無法啟動、CLI 程序退出或成功結果到達但沒有結構化輸出時,修復 Agent SDK 錯誤。7> 修復 Agent SDK 錯誤:Claude Code CLI 無法啟動或退出、工具訊息過大,或結果到達但沒有結構化輸出。

8 8 

9此頁面涵蓋 CLI 啟動、CLI 程序退出和結構化輸出中的 Agent SDK 錯誤。此頁面上的項目按您看到的錯誤進行分類。每個項目都說明原因和解決方法。9此頁面涵蓋 CLI 啟動、CLI 程序退出、大型工具呼叫與結果,以及結構化輸出中的 Agent SDK 錯誤。此頁面上的項目按您看到的錯誤進行分類。每個項目都說明原因和解決方法。

10 10 

11與功能相關的症狀,例如 hook 未觸發或 skill 未被使用,在該功能的頁面上有故障排除部分。下表列出涵蓋每個症狀的部分或頁面:11與功能相關的症狀,例如 hook 未觸發或 skill 未被使用,在該功能的頁面上有疑難排解部分。下表列出涵蓋每個症狀的部分或頁面:

12 12 

13| 症狀 | 前往 |13| 症狀 | 前往 |

14| :- | :- |14| :- | :- |

15| 找不到 Skills、skill 未被使用、`Invalid skill name` 錯誤 | [Skills 故障排除](https://code.claude.com/docs/zh-TW/agent-sdk/skills.md#troubleshooting) |15| 找不到 Skills、skill 未被使用、`Invalid skill name` 錯誤 | [Skills 疑難排解](https://code.claude.com/docs/zh-TW/agent-sdk/skills.md#troubleshooting) |

16| MCP 伺服器顯示 `failed` 狀態、工具未被呼叫、SDK MCP 伺服器中缺少某個工具、連線逾時、工具輸出超過允許的最大 token 數 | [MCP 疑難排解](https://code.claude.com/docs/zh-TW/agent-sdk/mcp.md#troubleshooting) |16| MCP 伺服器顯示 `failed` 狀態、工具未被呼叫、SDK MCP 伺服器中缺少某個工具、連線逾時、工具輸出超過允許的最大 token 數 | [MCP 疑難排解](https://code.claude.com/docs/zh-TW/agent-sdk/mcp.md#troubleshooting) |

17| Plugin 未載入、plugin skills 未出現 | [Plugins 故障排除](https://code.claude.com/docs/zh-TW/agent-sdk/plugins.md#troubleshooting) |17| 外掛未載入、外掛 skill 未出現 | [外掛疑難排解](https://code.claude.com/docs/zh-TW/agent-sdk/plugins.md#troubleshooting) |

18| Claude 未委派給子代理、基於檔案系統的代理未載入 | [Subagents 故障排除](https://code.claude.com/docs/zh-TW/agent-sdk/subagents.md#troubleshooting) |18| Claude 未委派給 subagent、基於檔案系統的 agent 未載入 | [Subagent 疑難排解](https://code.claude.com/docs/zh-TW/agent-sdk/subagents.md#troubleshooting) |

19| Checkpointing 選項未被識別、使用者訊息沒有 UUID、`No file checkpoint found`、`File rewinding is not enabled`、`ProcessTransport is not ready for writing` | [檔案 checkpointing 故障排除](https://code.claude.com/docs/zh-TW/agent-sdk/file-checkpointing.md#troubleshooting) |19| 檢查點功能選項未被識別、使用者訊息沒有 UUID、`No file checkpoint found`、`File rewinding is not enabled`、`ProcessTransport is not ready for writing` | [檔案檢查點功能疑難排解](https://code.claude.com/docs/zh-TW/agent-sdk/file-checkpointing.md#troubleshooting) |

20| Hook 未觸發、matcher 未如預期篩選、hook 逾時、工具意外被阻止、修改的輸入未被應用、Python 中無法使用工作階段 hooks、子代理權限提示增加、子代理的遞迴 hook 迴圈、`systemMessage` 未出現在輸出中 | [修復常見問題](https://code.claude.com/docs/zh-TW/agent-sdk/hooks.md#fix-common-issues)(在 hooks 頁面上) |20| Hook 未觸發、matcher 未如預期篩選、hook 逾時、工具意外被阻止、修改的輸入未被應用、Python 中無法使用工作階段 hook、subagent 權限提示增加、subagent 的遞迴 hook 迴圈、`systemMessage` 未出現在輸出中 | [修復常見問題](https://code.claude.com/docs/zh-TW/agent-sdk/hooks.md#fix-common-issues)(在 hook 頁面上) |

21| 在您的機器上運作的代理在已部署的服務或容器中失敗 | [故障排除部署失敗](https://code.claude.com/docs/zh-TW/agent-sdk/hosting.md#troubleshoot-deployment-failures) |21| 在您的機器上運作的 agent 在已部署的服務或容器中失敗 | [疑難排解部署失敗](https://code.claude.com/docs/zh-TW/agent-sdk/hosting.md#troubleshoot-deployment-failures) |

22| `Not logged in`、`Invalid API key`、`API Error`、`429`、`There's an issue with the selected model` | [錯誤參考](https://code.claude.com/docs/zh-TW/errors.md#find-your-error) |22| `Not logged in`、`Invalid API key`、`API Error`、`429`、`There's an issue with the selected model` | [錯誤參考](https://code.claude.com/docs/zh-TW/errors.md#find-your-error) |

23| `CLINotFoundError`、`CLIConnectionError`、`ProcessError`、`Claude Code process exited with code N`、`Claude Code returned an error result`、`structured_output` 是 `None` | 此頁面上的 [CLI 啟動](#cli-startup)、[CLI 程序退出](#cli-process-exit) 和 [結構化輸出](#structured-outputs) |23| `CLINotFoundError`、`CLIConnectionError`、`ProcessError`、`Claude Code process exited with code N`、`Claude Code returned an error result`、`CLIJSONDecodeError`、`structured_output` 是 `None` | 此頁面上的 [CLI 啟動](#cli-startup)、[CLI 程序退出](#cli-process-exit)、[大型工具呼叫與結果](#large-tool-calls-and-results) 和 [結構化輸出](#structured-outputs) |

24 24 

25## CLI 啟動25## CLI 啟動

26 26 


136 136 

137冒號後的文字是 CLI 對出錯原因的報告,因此從那裡開始而不是從退出本身開始。Python 將此作為[`ResultError`](https://code.claude.com/docs/zh-TW/agent-sdk/python#resulterror)引發,其 `data` 屬性攜帶完整的錯誤結果。TypeScript 以帶有相同訊息形狀的普通 `Error` 拒絕訊息迴圈。137冒號後的文字是 CLI 對出錯原因的報告,因此從那裡開始而不是從退出本身開始。Python 將此作為[`ResultError`](https://code.claude.com/docs/zh-TW/agent-sdk/python#resulterror)引發,其 `data` 屬性攜帶完整的錯誤結果。TypeScript 以帶有相同訊息形狀的普通 `Error` 拒絕訊息迴圈。

138 138 

139## 大型工具呼叫與結果

140 

141### CLIJSONDecodeError: JSON message exceeded maximum buffer size

142 

143當來自 Claude Code 的單一訊息長度超過 [`max_buffer_size`](https://code.claude.com/docs/zh-TW/agent-sdk/python#claudeagentoptions) 選項時,Python SDK 會引發此錯誤,該選項的預設值為 1,048,576 個字元。錯誤訊息將其稱為位元組:

144 

145```text theme={null}

146Failed to decode JSON: JSON message exceeded maximum buffer size of 1048576 bytes...

147```

148 

149例如,PDF、螢幕截圖和文字檔案都可能產生達到該上限的訊息:

150 

151* **PDF 和螢幕截圖**:當 Claude 使用 Read 工具讀取約 393 KB 或以上的完整 PDF 時,工具結果可能會達到上限,因為其中包含兩份檔案的 base64。含有螢幕截圖的工具結果(無論來自 Read 或 MCP 工具)同樣包含兩份 base64。

152* **文字檔案**:來自 Edit 和 Write 工具的訊息,即使檔案遠小於 1 MB 也可能達到上限,取決於檔案變更的幅度。

153 

154若要避免此錯誤,請在 `ClaudeAgentOptions` 中設定較大的上限:

155 

156```python theme={null}

157options = ClaudeAgentOptions(max_buffer_size=64 * 1024 * 1024)

158```

159 

160此值足以容納一張螢幕截圖,以及對最大至 Read 20 MB 上限之完整 PDF 的 Read。如果錯誤再次出現,例如在對非常大的檔案執行 Edit 時,請設定更高的值。

161 

162工具已做出的任何變更都會保留,而訊息過長的那次工具呼叫也可能已做出變更。若要接續已停止的工作:

163 

1641. 如果您保持 `ClaudeSDKClient` 開啟,請呼叫 `disconnect()`。發生此錯誤後,用戶端將不再接收任何訊息,但 Claude Code 會繼續執行,且仍可能做出變更。

1652. 以較大的上限和 [`continue_conversation=True`](https://code.claude.com/docs/zh-TW/agent-sdk/sessions#continue-resume-and-fork) 啟動新的 `query()` 或 `ClaudeSDKClient`,這會選取工作目錄中最近的工作階段。若要選取特定的工作階段,請將 `resume` 設為 init [`SystemMessage`](https://code.claude.com/docs/zh-TW/agent-sdk/python#systemmessage) 中的 `data["session_id"]`。

166 

139## 結構化輸出167## 結構化輸出

140 168 

141### structured\_output is None but the result says success169### structured\_output is None but the result says success

Details

524console.log(`Set by: ${provenance.cleanupPeriodDays?.source}`);524console.log(`Set by: ${provenance.cleanupPeriodDays?.source}`);

525```525```

526 526 

527### `matchDeniedModels()`

528 

529回報 `models` 中有哪些會被 [`deniedModels`](https://code.claude.com/docs/zh-TW/settings-reference#deniedmodels) 清單封鎖。`denied` 為每個模型各保存一個布林值,當某個項目封鎖該模型時為 `true`。`warnings` 會標示被忽略的輸入,以及封鎖範圍比表面上更多或更少的項目。`false` 並不代表該模型已被允許,因為 Claude Code 也會檢查別名和模型覆寫。此函式目前為 alpha 版,需要 Agent SDK v0.3.323 或更新版本。

530 

531```typescript theme={null}

532function matchDeniedModels(

533 models: readonly string[],

534 deniedModels: readonly string[] | undefined

535): Promise<{ denied: boolean[]; warnings: string[] }>;

536```

537 

527## 型別538## 型別

528 539 

529### `Options`540### `Options`


589| `skills` | `string[] \| 'all'` | `undefined` | 工作階段可用的 skill。傳入 `'all'` 以啟用所有探索到的 skill,或傳入 skill 名稱清單。僅傳入確切名稱。在 Agent SDK v0.3.221 或更新版本中,SDK 會在啟動 Claude Code 程序之前以錯誤拒絕格式錯誤和萬用字元形式的名稱。設定此項時,SDK 會自動將 Skill 工具加入 `allowedTools`。若您同時傳入 `tools`,請在該清單中包含 `'Skill'`。請參閱 [Skills](https://code.claude.com/docs/zh-TW/agent-sdk/skills.md) |600| `skills` | `string[] \| 'all'` | `undefined` | 工作階段可用的 skill。傳入 `'all'` 以啟用所有探索到的 skill,或傳入 skill 名稱清單。僅傳入確切名稱。在 Agent SDK v0.3.221 或更新版本中,SDK 會在啟動 Claude Code 程序之前以錯誤拒絕格式錯誤和萬用字元形式的名稱。設定此項時,SDK 會自動將 Skill 工具加入 `allowedTools`。若您同時傳入 `tools`,請在該清單中包含 `'Skill'`。請參閱 [Skills](https://code.claude.com/docs/zh-TW/agent-sdk/skills.md) |

590| `spawnClaudeCodeProcess` | `(options: SpawnOptions) => SpawnedProcess` | `undefined` | 用於產生 Claude Code 程序的自訂函式。用於在 VM、容器或遠端環境中執行 Claude Code |601| `spawnClaudeCodeProcess` | `(options: SpawnOptions) => SpawnedProcess` | `undefined` | 用於產生 Claude Code 程序的自訂函式。用於在 VM、容器或遠端環境中執行 Claude Code |

591| `stderr` | `(data: string) => void` | `undefined` | stderr 輸出的回呼 |602| `stderr` | `(data: string) => void` | `undefined` | stderr 輸出的回呼 |

592| `strictMcpConfig` | `boolean` | `false` | 僅使用 `mcpServers` 中傳入的伺服器,並忽略專案 `.mcp.json`、使用者設定、外掛提供的 MCP 伺服器以及 [claude.ai 連接器](https://code.claude.com/docs/zh-TW/mcp.md#use-mcp-servers-from-claude-ai) |603| `strictMcpConfig` | `boolean` | `false` | 使用在 `mcpServers` 中傳遞的伺服器,並忽略專案的 `.mcp.json`、使用者設定、外掛提供的 MCP 伺服器,以及 [claude.ai 連接器](https://code.claude.com/docs/zh-TW/mcp.md#use-mcp-servers-from-claude-ai) |

593| `systemPrompt` | `string \| string[] \| { type: 'custom'; prompt: string \| string[]; snapshot?: boolean } \| { type: 'preset'; preset: 'claude_code'; append?: string; excludeDynamicSections?: boolean; snapshot?: boolean }` | `undefined`(最簡提示詞) | 系統提示詞設定。傳入字串以使用自訂提示詞,或傳入 `{ type: 'preset', preset: 'claude_code' }` 以使用 Claude Code 的系統提示詞。傳入字串陣列,並在靜態部分與逐請求部分之間放置匯出的 `SYSTEM_PROMPT_DYNAMIC_BOUNDARY` 常數,即可[快取自訂提示詞的靜態部分](https://code.claude.com/docs/zh-TW/agent-sdk/modifying-system-prompts.md#cache-the-static-part-of-a-custom-prompt)。使用預設物件形式時,加入 `append` 以附加額外指令,並設定 `excludeDynamicSections: true` 將每個工作階段的上下文移至第一則使用者訊息,以[在不同機器間更好地重複使用提示詞快取](https://code.claude.com/docs/zh-TW/agent-sdk/modifying-system-prompts.md#improve-prompt-caching-across-users-and-machines)。設定 `snapshot: false` 可在每次請求時重新建構提示詞,而不是[重複使用工作階段在第一次請求時記錄的提示詞](https://code.claude.com/docs/zh-TW/agent-sdk/modifying-system-prompts.md#change-the-prompt-of-an-existing-session)。若要在自訂提示詞上設定 `snapshot`,請傳入 `{ type: 'custom', prompt }` 形式。`{ type: 'custom' }` 形式和 `snapshot` 欄位需要 TypeScript Agent SDK v0.3.257 或更新版本 |604| `systemPrompt` | `string \| string[] \| { type: 'custom'; prompt: string \| string[]; snapshot?: boolean } \| { type: 'preset'; preset: 'claude_code'; append?: string; excludeDynamicSections?: boolean; snapshot?: boolean }` | `undefined`(最簡提示詞) | 系統提示詞設定。傳入字串以使用自訂提示詞,或傳入 `{ type: 'preset', preset: 'claude_code' }` 以使用 Claude Code 的系統提示詞。傳入字串陣列,並在靜態部分與逐請求部分之間放置匯出的 `SYSTEM_PROMPT_DYNAMIC_BOUNDARY` 常數,即可[快取自訂提示詞的靜態部分](https://code.claude.com/docs/zh-TW/agent-sdk/modifying-system-prompts.md#cache-the-static-part-of-a-custom-prompt)。使用預設物件形式時,加入 `append` 以附加額外指令,並設定 `excludeDynamicSections: true` 將每個工作階段的上下文移至第一則使用者訊息,以[在不同機器間更好地重複使用提示詞快取](https://code.claude.com/docs/zh-TW/agent-sdk/modifying-system-prompts.md#improve-prompt-caching-across-users-and-machines)。設定 `snapshot: false` 可在每次請求時重新建構提示詞,而不是[重複使用工作階段在第一次請求時記錄的提示詞](https://code.claude.com/docs/zh-TW/agent-sdk/modifying-system-prompts.md#change-the-prompt-of-an-existing-session)。若要在自訂提示詞上設定 `snapshot`,請傳入 `{ type: 'custom', prompt }` 形式。`{ type: 'custom' }` 形式和 `snapshot` 欄位需要 TypeScript Agent SDK v0.3.257 或更新版本 |

594| `taskBudget` | `{ total: number }` | `undefined` | *Alpha。* API 端的任務預算(以 token 計)。設定後,模型會被告知其剩餘的 token 預算,以便調整工具使用節奏並在達到上限前收尾 |605| `taskBudget` | `{ total: number }` | `undefined` | *Alpha。* API 端的任務預算(以 token 計)。設定後,模型會被告知其剩餘的 token 預算,以便調整工具使用節奏並在達到上限前收尾 |

595| `thinking` | [`ThinkingConfig`](#thinkingconfig) | 支援的模型為 `{ type: 'adaptive' }` | 控制 Claude 的思考/推理行為。選項請參閱 [`ThinkingConfig`](#thinkingconfig) |606| `thinking` | [`ThinkingConfig`](#thinkingconfig) | 支援的模型為 `{ type: 'adaptive' }` | 控制 Claude 的思考/推理行為。選項請參閱 [`ThinkingConfig`](#thinkingconfig) |


1285| `tools` | 否 | 允許的工具名稱陣列。若省略,則繼承所有[可供 subagent 使用的工具](https://code.claude.com/docs/zh-TW/sub-agents.md#available-tools)。若要將 Skills 預先載入 agent 的上下文,請使用 `skills` 欄位,而不是在此列出 `'Skill'` |1296| `tools` | 否 | 允許的工具名稱陣列。若省略,則繼承所有[可供 subagent 使用的工具](https://code.claude.com/docs/zh-TW/sub-agents.md#available-tools)。若要將 Skills 預先載入 agent 的上下文,請使用 `skills` 欄位,而不是在此列出 `'Skill'` |

1286| `disallowedTools` | 否 | 要為此 agent 明確禁止的工具名稱陣列。也接受 MCP 伺服器層級的模式:`mcp__server` 或 `mcp__server__*` 會移除該伺服器的所有工具,而 `mcp__*` 會移除任何伺服器的所有 MCP 工具 |1297| `disallowedTools` | 否 | 要為此 agent 明確禁止的工具名稱陣列。也接受 MCP 伺服器層級的模式:`mcp__server` 或 `mcp__server__*` 會移除該伺服器的所有工具,而 `mcp__*` 會移除任何伺服器的所有 MCP 工具 |

1287| `prompt` | 是 | agent 的系統提示詞 |1298| `prompt` | 是 | agent 的系統提示詞 |

1288| `model` | 否 | 此 agent 的模型覆寫。接受別名,例如 `'fable'`、`'opus'`、`'sonnet'`、`'haiku'`、`'inherit'`,或完整的模型 ID。`'inherit'` 使用主模型。省略時,Claude Code 會依照 [subagent 模型順序](https://code.claude.com/docs/zh-TW/sub-agents.md#choose-a-model)選擇模型 |1299| `model` | 否 | 此 agent 的模型覆寫。接受別名,例如 `'fable'`、`'opus'`、`'sonnet'`、`'haiku'`、`'inherit'`,或完整的模型 ID。`'inherit'` 會使用產生此 agent 之 agent 的模型。當您省略 `model` 時,Claude Code 會依照 [subagent 模型順序](https://code.claude.com/docs/zh-TW/sub-agents.md#choose-a-model)選擇模型 |

1289| `mcpServers` | 否 | 此 agent 的 MCP 伺服器規格 |1300| `mcpServers` | 否 | 此 agent 的 MCP 伺服器規格 |

1290| `skills` | 否 | 要預先載入 agent 上下文的 skill 名稱陣列 |1301| `skills` | 否 | 要預先載入 agent 上下文的 skill 名稱陣列 |

1291| `initialPrompt` | 否 | 當此 agent 作為主執行緒 agent 執行時,會自動提交為第一個使用者回合 |1302| `initialPrompt` | 否 | 當此 agent 作為主執行緒 agent 執行時,會自動提交為第一個使用者回合 |


1413| 選項 | 型別 | 說明 |1424| 選項 | 型別 | 說明 |

1414| :- | :- | :- |1425| :- | :- | :- |

1415| `signal` | `AbortSignal` | 若操作應中止則會發出訊號 |1426| `signal` | `AbortSignal` | 若操作應中止則會發出訊號 |

1416| `suggestions` | [`PermissionUpdate`](#permissionupdate)`[]` | 建議的權限更新,讓使用者不會再次被詢問此工具。Bash 提示包含一個 `localSettings` [目的地](#permissionupdatedestination)的建議,因此在 `updatedPermissions` 中回傳它會將規則寫入 `.claude/settings.local.json`,並跨工作階段保留。 |1427| `suggestions` | [`PermissionUpdate`](#permissionupdate)`[]` | 建議的權限更新,使使用者不會再次因此工具收到提示。Bash 提示可能包含目的地為 `localSettings` [destination](#permissionupdatedestination) 的建議,因此在 `updatedPermissions` 中回傳它會將規則寫入 `.claude/settings.local.json`,並跨工作階段保留。 |

1417| `blockedPath` | `string` | 觸發權限請求的檔案路徑(如適用) |1428| `blockedPath` | `string` | 觸發權限請求的檔案路徑(如適用) |

1418| `mcpServer` | `{ name: string; source: string }` | 對於 `mcp__*` 工具,提供該工具的 MCP 伺服器及該伺服器定義的來源,欄位與 [`McpServerProvenance`](#mcpserverprovenance) 相同。其他工具則不存在。需要 Agent SDK v0.3.274 或更新版本 |1429| `mcpServer` | `{ name: string; source: string }` | 對於 `mcp__*` 工具,提供該工具的 MCP 伺服器及該伺服器定義的來源,欄位與 [`McpServerProvenance`](#mcpserverprovenance) 相同。其他工具則不存在。需要 Agent SDK v0.3.274 或更新版本 |

1419| `decisionReason` | `string` | 說明為何觸發此權限請求 |1430| `decisionReason` | `string` | 說明為何觸發此權限請求 |


1596選擇 `always_ask` 以自行核准每個呼叫,或選擇 `always_deny` 以直接封鎖該工具:1607選擇 `always_ask` 以自行核准每個呼叫,或選擇 `always_deny` 以直接封鎖該工具:

1597 1608 

1598* **`always_ask`**:對該工具的每個呼叫都[需要核准](https://code.claude.com/docs/zh-TW/agent-sdk/permissions.md#how-permissions-are-evaluated),即使有 `allowedTools` 項目或允許規則涵蓋它。呼叫會送到您的 `canUseTool` 回呼或 [`permissionPromptToolName`](#options) 工具,除非它先被處理。您載入的外掛中的 [mod](https://code.claude.com/docs/zh-TW/plugins/mods/overview.md) [可以先核准它](https://code.claude.com/docs/zh-TW/permissions.md#precedence-among-rules-hooks-and-mods)。否則,在 `dontAsk` 模式下會被拒絕,而在 [`auto`、`plan` 和 `bypassPermissions` 模式](#permission-modes-that-can-approve-an-always_ask-call)下,它可能在到達您的回呼之前就被核准1609* **`always_ask`**:對該工具的每個呼叫都[需要核准](https://code.claude.com/docs/zh-TW/agent-sdk/permissions.md#how-permissions-are-evaluated),即使有 `allowedTools` 項目或允許規則涵蓋它。呼叫會送到您的 `canUseTool` 回呼或 [`permissionPromptToolName`](#options) 工具,除非它先被處理。您載入的外掛中的 [mod](https://code.claude.com/docs/zh-TW/plugins/mods/overview.md) [可以先核准它](https://code.claude.com/docs/zh-TW/permissions.md#precedence-among-rules-hooks-and-mods)。否則,在 `dontAsk` 模式下會被拒絕,而在 [`auto`、`plan` 和 `bypassPermissions` 模式](#permission-modes-that-can-approve-an-always_ask-call)下,它可能在到達您的回呼之前就被核准

1599* **`always_deny`**:對該工具的呼叫在每種權限模式下都[會被拒絕](https://code.claude.com/docs/zh-TW/agent-sdk/permissions.md#how-permissions-are-evaluated),包括 `bypassPermissions`,但您載入的外掛中的 mod [仍然可以核准它](https://code.claude.com/docs/zh-TW/permissions.md#precedence-among-rules-hooks-and-mods)1610* **`always_deny`**:Claude Code 會在每種權限模式中(包括 `bypassPermissions`)將該工具從 Claude 的上下文中移除。移除功能需要 Claude Code v2.1.324 或更新版本

1600 1611 

1601如果您既未傳入 `canUseTool` 也未傳入 `permissionPromptToolName`,或將 [`permissionPrompts`](#options) 設為 `'none'`,則未先被處理的 `always_ask` 呼叫會被拒絕,除非有 [`PermissionRequest` hook](https://code.claude.com/docs/zh-TW/hooks#permissionrequest) 允許它。1612如果您既未傳入 `canUseTool` 也未傳入 `permissionPromptToolName`,或將 [`permissionPrompts`](#options) 設為 `'none'`,則未先被處理的 `always_ask` 呼叫會被拒絕,除非有 [`PermissionRequest` hook](https://code.claude.com/docs/zh-TW/hooks#permissionrequest) 允許它。

1602 1613 


1724 user_message_uuid?: string;1735 user_message_uuid?: string;

1725 user_message_uuids?: string[];1736 user_message_uuids?: string[];

1726 resume_reason?: string;1737 resume_reason?: string;

1738 supersedes?: UUID[];

1727};1739};

1728```1740```

1729 1741 


1738 1750 

1739當中斷或中止在串流完成前截斷助手訊息時,`aborted` 為 `true`:訊息沒有 `stop_reason`,內容可能在詞的中間結束。該欄位在正常完成的訊息上不存在。它需要 Agent SDK v0.3.214 或更新版本。1751當中斷或中止在串流完成前截斷助手訊息時,`aborted` 為 `true`:訊息沒有 `stop_reason`,內容可能在詞的中間結束。該欄位在正常完成的訊息上不存在。它需要 Agent SDK v0.3.214 或更新版本。

1740 1752 

1753`supersedes` 列出此訊息所取代之先前訊息的 UUID。當此訊息到達時,請將那些訊息從您的顯示中移除。

1754 

1741`agent_id` 識別產生該訊息的 subagent,主執行緒訊息不含此欄位。其值等於該 subagent 的 [`task_started`](#sdktaskstartedmessage) 及其他任務事件上的 `task_id`,且在 subagent [恢復](https://code.claude.com/docs/zh-TW/agent-sdk/subagents.md#resume-subagents)時保持不變。在來自[巢狀 subagent](https://code.claude.com/docs/zh-TW/sub-agents.md#let-subagents-spawn-their-own-subagents) 的訊息上,它指的是該巢狀 subagent,而非產生它的 subagent。此欄位需要 Agent SDK v0.3.292 或更新版本。1755`agent_id` 識別產生該訊息的 subagent,主執行緒訊息不含此欄位。其值等於該 subagent 的 [`task_started`](#sdktaskstartedmessage) 及其他任務事件上的 `task_id`,且在 subagent [恢復](https://code.claude.com/docs/zh-TW/agent-sdk/subagents.md#resume-subagents)時保持不變。在來自[巢狀 subagent](https://code.claude.com/docs/zh-TW/sub-agents.md#let-subagents-spawn-their-own-subagents) 的訊息上,它指的是該巢狀 subagent,而非產生它的 subagent。此欄位需要 Agent SDK v0.3.292 或更新版本。

1742 1756 

1743請依 `agent_id` 將 subagent 的訊息與其任務事件配對,而不是將訊息的 `parent_tool_use_id` 與任務事件的 `tool_use_id` 配對。當工具呼叫恢復 subagent 時,任務事件會帶有該呼叫的 `tool_use_id`,而訊息則保留最初啟動該 subagent 之工具呼叫的 `parent_tool_use_id`,因此兩者將不再相符。1757請依 `agent_id` 將 subagent 的訊息與其任務事件配對,而不是將訊息的 `parent_tool_use_id` 與任務事件的 `tool_use_id` 配對。當工具呼叫恢復 subagent 時,任務事件會帶有該呼叫的 `tool_use_id`,而訊息則保留最初啟動該 subagent 之工具呼叫的 `parent_tool_use_id`,因此兩者將不再相符。


5720 5734 

5721當工具呼叫在主對話中執行時,Claude Code 每 30 秒發出一個 `tool_progress` 訊息,帶有 `heartbeat: true`。每個心跳攜帶工具名稱和經過的秒數,因此您可以區分長執行呼叫和停滯工作階段。Claude Code 不為 subagent 內的工具呼叫發出心跳。`heartbeat` 欄位需要 Agent SDK v0.3.214 或更新版本。在 v2.1.257 之前,Claude Code 也不為前景 Agent 工具呼叫發出心跳。5735當工具呼叫在主對話中執行時,Claude Code 每 30 秒發出一個 `tool_progress` 訊息,帶有 `heartbeat: true`。每個心跳攜帶工具名稱和經過的秒數,因此您可以區分長執行呼叫和停滯工作階段。Claude Code 不為 subagent 內的工具呼叫發出心跳。`heartbeat` 欄位需要 Agent SDK v0.3.214 或更新版本。在 v2.1.257 之前,Claude Code 也不為前景 Agent 工具呼叫發出心跳。

5722 5736 

5737在 Agent SDK v0.3.323 或更新版本上,`tool_use_id` 以 `hook-` 開頭的心跳來自長時間執行的 hook,而非工具呼叫。其 `tool_name` 是 hook 事件名稱,例如 `PreToolUse`。

5738 

5723在除心跳外的 Agent 工具的 `tool_progress` 訊息上,`subagent_type` 命名執行中的 subagent 類型,例如 `general-purpose`。`subagent_retry` 在該 subagent 等待 API 錯誤退避(例如速率限制或過載)時存在,每次重試嘗試一個訊息。兩個欄位都需要 Agent SDK v0.3.214 或更新版本。5739在除心跳外的 Agent 工具的 `tool_progress` 訊息上,`subagent_type` 命名執行中的 subagent 類型,例如 `general-purpose`。`subagent_retry` 在該 subagent 等待 API 錯誤退避(例如速率限制或過載)時存在,每次重試嘗試一個訊息。兩個欄位都需要 Agent SDK v0.3.214 或更新版本。

5724 5740 

5725若要從 `subagent_retry` 呈現重試指示器:5741若要從 `subagent_retry` 呈現重試指示器:


6088| :- | :- | :- | :- |6104| :- | :- | :- | :- |

6089| `enabled` | `boolean` | `false` | 為命令執行啟用 sandbox 模式 |6105| `enabled` | `boolean` | `false` | 為命令執行啟用 sandbox 模式 |

6090| `failIfUnavailable` | `boolean` | `true` | 如果 `enabled` 為 `true` 但 sandbox 無法啟動,則在啟動時停止。設定為 `false` 以回退到未 sandboxed 的執行,並在 stderr 上顯示警告 |6106| `failIfUnavailable` | `boolean` | `true` | 如果 `enabled` 為 `true` 但 sandbox 無法啟動,則在啟動時停止。設定為 `false` 以回退到未 sandboxed 的執行,並在 stderr 上顯示警告 |

6091| `autoAllowBashIfSandboxed` | `boolean` | `true` | 當 sandbox 啟用時自動核准 Bash 命令 |6107| [`autoAllowBashIfSandboxed`](https://code.claude.com/docs/zh-TW/settings-reference#sandbox-autoallowbashifsandboxed) | `boolean` | `false` | 當 sandbox 啟用時自動核准 Bash 命令。`false` 預設值需要 Agent SDK v0.3.324 或更新版本 |

6092| `excludedCommands` | `string[]` | `[]` | 繞過 sandbox 限制的命令,例如 `['docker *']`。這些命令會自動以未 sandboxed 的方式執行,無需模型參與;[`sandbox.excludedCommands`](https://code.claude.com/docs/zh-TW/settings-reference#sandbox-excludedcommands) 涵蓋何時適用項目 |6108| `excludedCommands` | `string[]` | `[]` | 繞過 sandbox 限制的命令,例如 `['docker *']`。這些命令會自動以未 sandboxed 的方式執行,無需模型參與;[`sandbox.excludedCommands`](https://code.claude.com/docs/zh-TW/settings-reference#sandbox-excludedcommands) 涵蓋何時適用項目 |

6093| `allowUnsandboxedCommands` | `boolean` | `true` | 允許模型要求在 sandbox 外執行命令。當為 `true` 時,模型可以在工具輸入中設定 `dangerouslyDisableSandbox`,這會回退到[權限系統](#permissions-fallback-for-unsandboxed-commands) |6109| `allowUnsandboxedCommands` | `boolean` | `true` | 允許模型要求在 sandbox 外執行命令。當為 `true` 時,模型可以在工具輸入中設定 `dangerouslyDisableSandbox`,這會回退到[權限系統](#permissions-fallback-for-unsandboxed-commands) |

6094| `network` | [`SandboxNetworkConfig`](#sandboxnetworkconfig) | `undefined` | 網路特定的 sandbox 設定 |6110| `network` | [`SandboxNetworkConfig`](#sandboxnetworkconfig) | `undefined` | 網路特定的 sandbox 設定 |

agent-teams.md +26 −9

Details

102>102>

103> `tmux` 在某些作業系統上有已知限制,傳統上在 macOS 上效果最佳。在 iTerm2 中使用 `tmux -CC` 是進入 `tmux` 的建議入口點。103> `tmux` 在某些作業系統上有已知限制,傳統上在 macOS 上效果最佳。在 iTerm2 中使用 `tmux -CC` 是進入 `tmux` 的建議入口點。

104 104 

105預設值是 `"in-process"`。設定 `"auto"` 以在您已在 tmux 工作階段內運行或您的終端是已安裝 `it2` CLI 的 iTerm2 時啟用分割窗格,否則回退到 in-process。`"tmux"` 設定啟用分割窗格模式,並根據您的終端自動偵測是否使用 tmux 或 iTerm2。105在 agent teams [已啟用](#enable-agent-teams)的情況下,請按照以下步驟為每個隊友提供自己的窗格:

106 106 

107設定 `"iterm2"` 以明確使用 iTerm2 原生分割窗格。此模式需要 [`it2` CLI](https://github.com/mkusaka/it2),如果 `it2` 遺失,會顯示帶有安裝命令的錯誤。當您的終端是 iTerm2 且 tmux 可作為備用方案時,在 `"auto"` 或 `"tmux"` 下會出現提供安裝 `it2` 或切換到 tmux 的設定提示。107**1. 安裝 tmux 或設定 iTerm2**

108 108 

109若要覆蓋預設值,請在 `~/.claude/settings.json` 中設定 [`teammateMode`](https://code.claude.com/docs/zh-TW/settings-reference#teammatemode):109分割窗格模式需要 [tmux](https://github.com/tmux/tmux/wiki) 或 iTerm2 搭配 [`it2` CLI](https://github.com/mkusaka/it2)。請設定您將用來執行 Claude Code 的那一個:

110 

111* **tmux**:透過您系統的套件管理器安裝。請參閱 [tmux wiki](https://github.com/tmux/tmux/wiki/Installing) 以了解平台特定的指示。

112* **iTerm2**:安裝 [`it2` CLI](https://github.com/mkusaka/it2),然後在 **iTerm2 > Settings > General > Magic > Enable Python API** 中啟用 Python API。

113 

114**2. 開啟分割窗格**

115 

116在您變更 [`teammateMode`](https://code.claude.com/docs/zh-TW/settings-reference#teammatemode) 設定之前,隊友會以 in-process 方式運行。

117 

118在 `~/.claude/settings.json` 中將其設定為 `"auto"`:

110 119 

111```json theme={null}120```json theme={null}

112{121{


114}123}

115```124```

116 125 

126使用 `"auto"` 時,當您在 tmux 或 iTerm2 內執行 Claude Code,隊友會在分割窗格中開啟;在其他終端機中則以 in-process 方式運行。

127 

128**3. 啟動 Claude Code 並生成隊友**

129 

130在 tmux 內或 iTerm2 中執行 `claude`,然後要求 Claude 生成隊友。

131 

132如果 iTerm2 中出現 `it2` 的設定提示,請選擇 **Install it2 now**,以在您的 iTerm2 視窗中開啟窗格。

133 

134如果您在 tmux 和 iTerm2 之外執行 Claude Code,或窗格未在您的 iTerm2 視窗中開啟,請再次變更 `teammateMode`:

135 

136* **在 tmux 和 iTerm2 之外**:在已安裝 tmux 的情況下,將 `teammateMode` 設定為 `"tmux"`。窗格會在獨立的 tmux 工作階段中開啟。若要查看它們,請從 Claude Code 提示字元中的 `View teammates` 行複製命令,並在第二個終端機中執行該命令。

137* **窗格未在您的 iTerm2 視窗中開啟**:將 `teammateMode` 設定為 `"iterm2"` 以使用 iTerm2 自身的窗格。如此一來,只有當您在已設定 `it2` 的 iTerm2 中執行 Claude Code 時,隊友才會啟動。

138 

117若要為單個工作階段設定模式,請將其作為旗標傳遞:139若要為單個工作階段設定模式,請將其作為旗標傳遞:

118 140 

119```bash theme={null}141```bash theme={null}


122 144 

123`--teammate-mode` 旗標是實驗性的,不會出現在 `claude --help` 中。145`--teammate-mode` 旗標是實驗性的,不會出現在 `claude --help` 中。

124 146 

125分割窗格模式需要 [tmux](https://github.com/tmux/tmux/wiki) 或 iTerm2 搭配 [`it2` CLI](https://github.com/mkusaka/it2)。若要手動安裝:

126 

127* **tmux**:透過您系統的套件管理器安裝。請參閱 [tmux wiki](https://github.com/tmux/tmux/wiki/Installing) 以了解平台特定的指示。

128* **iTerm2**:安裝 [`it2` CLI](https://github.com/mkusaka/it2),然後在 **iTerm2 → Settings → General → Magic → Enable Python API** 中啟用 Python API。

129 

130### 指定隊友和模型147### 指定隊友和模型

131 148 

132Claude 根據您的任務決定要生成的隊友數量,或者您可以指定您想要的確切內容:149Claude 根據您的任務決定要生成的隊友數量,或者您可以指定您想要的確切內容:


497* **沒有來自 in-process 隊友的背景 subagent**:in-process 隊友自己的 subagent 在前景中執行,因為隊友的背景工作無法超越主管的程序。Claude Code 在隊友生成定義設定 `background: true` 的 subagent 時會傳回錯誤。隊友的 `run_in_background: true` 請求也會失敗,可能傳回錯誤或在前景中無聲執行。從主要對話啟動的 subagent 遵循[背景預設](https://code.claude.com/docs/zh-TW/sub-agents.md#run-subagents-in-foreground-or-background)。514* **沒有來自 in-process 隊友的背景 subagent**:in-process 隊友自己的 subagent 在前景中執行,因為隊友的背景工作無法超越主管的程序。Claude Code 在隊友生成定義設定 `background: true` 的 subagent 時會傳回錯誤。隊友的 `run_in_background: true` 請求也會失敗,可能傳回錯誤或在前景中無聲執行。從主要對話啟動的 subagent 遵循[背景預設](https://code.claude.com/docs/zh-TW/sub-agents.md#run-subagents-in-foreground-or-background)。

498* **主管是固定的**:主要工作階段在其生命週期內是主管。您無法將隊友提升為主管或轉移領導權。515* **主管是固定的**:主要工作階段在其生命週期內是主管。您無法將隊友提升為主管或轉移領導權。

499* **生成時無法為每個隊友設定權限模式**:隊友開始時具有 [權限](#permissions) 下所述的權限模式。516* **生成時無法為每個隊友設定權限模式**:隊友開始時具有 [權限](#permissions) 下所述的權限模式。

500* **分割窗格需要 tmux 或 iTerm2**:預設 in-process 模式在任何終端中工作。VS Code 的整合終端、Windows Terminal 或 Ghostty 不支援分割窗格模式。517* **分割窗格需要 tmux 或 iTerm2**:預設 in-process 模式在任何終端機中都能運作。

501 518 

502## 後續步驟519## 後續步驟

503 520 

agent-view.md +40 −47

Details

144| 形狀 | 意義 |144| 形狀 | 意義 |

145| :- | :- |145| :- | :- |

146| `✻` 或動畫 `✽` | 工作階段程序正在執行,或工作階段需要您的輸入 |146| `✻` 或動畫 `✽` | 工作階段程序正在執行,或工作階段需要您的輸入 |

147| `∙` | 程序已結束。您仍然可以查看該列,當您回覆或附加時,Claude 會從其已儲存的對話重新啟動它 |147| `∙` | 程序已結束。您仍然可以查看該列,當您回覆或按 `Enter` 時,Claude 會從其已儲存的對話重新啟動它 |

148| `✢` | 在迭代之間休眠的 [`/loop`](https://code.claude.com/docs/zh-TW/scheduled-tasks) 工作階段。該列顯示其執行次數和倒數計時 |148| `✢` | 在迭代之間休眠的 [`/loop`](https://code.claude.com/docs/zh-TW/scheduled-tasks) 工作階段。該列顯示其執行次數和倒數計時 |

149 149 

150可能出現在列右邊緣的 `#N` 或 `!N` 標籤是指向工作階段的 [pull request 或 merge request](#pull-request-status) 的連結,不是狀態圖示的一部分。150可能出現在列右邊緣的 `#N` 或 `!N` 標籤是指向工作階段的 [pull request 或 merge request](#pull-request-status) 的連結,不是狀態圖示的一部分。


316* 在群組標題上按 `Enter` 以摺疊群組,但 [篩選](#filter-sessions) 啟用時除外,此時所有群組都會保持展開316* 在群組標題上按 `Enter` 以摺疊群組,但 [篩選](#filter-sessions) 啟用時除外,此時所有群組都會保持展開

317* 按 `Ctrl+X` 停止工作階段,並在兩秒內再次按 `Ctrl+X` 將其從清單中刪除,或按 `Esc` 關閉確認而不刪除。即使停止嘗試失敗(例如因為 [背景服務沒有回應](#agent-view-says-the-background-service-did-not-respond)),第二次按下仍會刪除工作階段。在這種情況下,確認狀態會再維持兩秒,而刪除動作會自行結束工作階段的程序317* 按 `Ctrl+X` 停止工作階段,並在兩秒內再次按 `Ctrl+X` 將其從清單中刪除,或按 `Esc` 關閉確認而不刪除。即使停止嘗試失敗(例如因為 [背景服務沒有回應](#agent-view-says-the-background-service-did-not-respond)),第二次按下仍會刪除工作階段。在這種情況下,確認狀態會再維持兩秒,而刪除動作會自行結束工作階段的程序

318 318 

319在群組標題上按 `Ctrl+X` 會在確認後刪除該群組中的每個工作階段。除了 [刪除工作階段會移除什麼](#what-deleting-a-session-removes) 中說明的保留情況外,刪除會將工作階段從清單中移除。Claude 為其建立的 worktree 會被移除、保留或留在原位,取決於您的刪除方式以及 worktree 中的內容。對話逐字稿保留在您的本機上,可透過 `claude --resume` 取得。319在群組標題上按 `Ctrl+X` 會在確認後刪除該群組中的每個工作階段,但 Claude Code [拒絕刪除](#delete-a-session-after-claude-code-refuses) 的工作階段除外。若要了解每個工作階段的 worktree 會如何處理,請參閱 [刪除工作階段會移除什麼](#what-deleting-a-session-removes)。對話逐字稿保留在您的本機上,可透過 `claude --resume` 取得。

320 320 

321螢幕上放不下的已完成工作階段會摺疊成 `… N more` 列。`Completed` 群組會填滿即時群組之後剩餘的垂直空間。在較矮的終端機上,標題會壓縮成單一摘要行,讓工作中或需要輸入的工作階段保持可見。321螢幕上放不下的已完成工作階段會摺疊成 `… N more` 列。`Completed` 群組會填滿即時群組之後剩餘的垂直空間。在較矮的終端機上,標題會壓縮成單一摘要行,讓工作中或需要輸入的工作階段保持可見。

322 322 


375| `Ctrl+J` | 在分派輸入中插入新行 |375| `Ctrl+J` | 在分派輸入中插入新行 |

376| `Ctrl+X` | 停止工作階段;在兩秒內再次按下以刪除它 |376| `Ctrl+X` | 停止工作階段;在兩秒內再次按下以刪除它 |

377| `Shift+↑` / `Shift+↓` | 重新排序選定的工作階段 |377| `Shift+↑` / `Shift+↓` | 重新排序選定的工作階段 |

378| `Esc` | 關閉查看面板、清除輸入或退出。當您是透過 `←` 將工作階段移至背景而開啟 agent 檢視時,最後一次 `Esc` 會返回該對話而不是退出。啟用 [vim 編輯器模式](https://code.claude.com/docs/zh-TW/interactive-mode.md#vim-editor-mode) 時,在輸入中按 `Esc` 會從 INSERT 切換到 NORMAL 模式並保留您的文字,與主提示詞輸入相同 |378| `Esc` | 關閉查看面板、清除輸入或退出。在 Claude Code v2.1.323 或更新版本中,清除提示詞需要按兩次。當您是透過 `←` 將工作階段移至背景而開啟 agent 檢視時,最後一次 `Esc` 會返回該對話而不是退出。啟用 [vim 編輯器模式](https://code.claude.com/docs/zh-TW/interactive-mode.md#vim-editor-mode) 時,在輸入中按 `Esc` 會從 INSERT 切換到 NORMAL 模式並保留您的文字,與主提示詞輸入相同 |

379| `Ctrl+Y` | 在分派輸入中,還原您上次清除的文字,或以 `Ctrl+K`、`Ctrl+U` 或 `Ctrl+W` 移除的文字。agent 檢視結束時,該文字即會消失 |

379| `Ctrl+C` | 清除輸入;按兩次以退出。當畫面上有選取的文字時,按下會改為清除選取;除非 [選取時已複製](https://code.claude.com/docs/zh-TW/settings-reference.md#copyonselect),否則會先複製該文字 |380| `Ctrl+C` | 清除輸入;按兩次以退出。當畫面上有選取的文字時,按下會改為清除選取;除非 [選取時已複製](https://code.claude.com/docs/zh-TW/settings-reference.md#copyonselect),否則會先複製該文字 |

380| `?` | 顯示快捷鍵 |381| `?` | 顯示快捷鍵 |

381 382 


481 482 

482當您將工作階段移到背景時,每種進行中的背景工作會轉移到背景工作階段、僅在 Claude 於該處重新啟動它時才繼續,或停止:483當您將工作階段移到背景時,每種進行中的背景工作會轉移到背景工作階段、僅在 Claude 於該處重新啟動它時才繼續,或停止:

483 484 

484* **轉移**:執行中的背景 shell 命令、已移到背景的 subagent、您使用 [`/loop`](https://code.claude.com/docs/zh-TW/scheduled-tasks) 建立的排程任務,以及 Claude [對 artifact 留言的自動回覆](https://code.claude.com/docs/zh-TW/artifacts.md#let-claude-reply-to-comments-on-its-own),都會在背景工作階段中繼續執行。subagent 會與它啟動的所有內容一起移動,因此只有當所有這些工作都能移動時,它才會轉移。485* **轉移**:執行中的背景 shell 命令、已移到背景的 subagent,以及您使用 [`/loop`](https://code.claude.com/docs/zh-TW/scheduled-tasks) 建立的排程任務,都會在背景工作階段中繼續執行。subagent 會與它啟動的所有內容一起移動,因此只有當所有這些工作都能移動時,它才會轉移。

485* **僅在 Claude 重新啟動時才繼續**:執行中的[動態工作流程](https://code.claude.com/docs/zh-TW/workflows.md)。如果您查看背景工作階段時工作流程尚未繼續,請[要求 Claude 重新啟動它](#dynamic-workflows-when-you-background)。486* **僅在 Claude 重新啟動時才繼續**:執行中的[動態工作流程](https://code.claude.com/docs/zh-TW/workflows.md)。如果您查看背景工作階段時工作流程尚未繼續,請[要求 Claude 重新啟動它](#dynamic-workflows-when-you-background)。

486* **停止**:無法移到背景工作階段的工作,例如執行中的 [monitor](https://code.claude.com/docs/zh-TW/tools-reference.md#monitor-tool)。當有任何此類工作在執行時,Claude Code 會顯示 `Background this session?` 對話框,讓您在它停止工作前確認。擁有 monitor 的背景 subagent 會與該 monitor 一併停止。487* **停止**:無法移到背景工作階段的工作,例如執行中的 [monitor](https://code.claude.com/docs/zh-TW/tools-reference.md#monitor-tool)。當有任何此類工作在執行時,Claude Code 會顯示 `Background this session?` 對話框,讓您在它停止工作前確認。擁有 monitor 的背景 subagent 會與該 monitor 一併停止。

487 488 


622 623 

623#### 刪除工作階段會移除什麼624#### 刪除工作階段會移除什麼

624 625 

625在 [agent view](#organize-the-list) 中按兩次 `Ctrl+X`,或使用 [`claude rm`](#manage-sessions-from-the-shell) 刪除工作階段。除了下方保留的情況外,工作階段會從清單中移除。其逐字稿會透過 `claude --resume` 保留在您的電腦上,且移除在 supervisor 重新啟動後仍然有效。626在 [agent view](#organize-the-list) 中按兩次 `Ctrl+X`,或使用 [`claude rm`](#manage-sessions-from-the-shell) 刪除工作階段。工作階段會從清單中消失,除非 Claude Code [拒絕刪除它](#delete-a-session-after-claude-code-refuses)。其逐字稿會保留在您的電腦上,可透過 `claude --resume` 存取。

626 627 

627Claude 為工作階段建立的 worktree 會如何處理:628Claude 為工作階段建立的 worktree 會如何處理:

628 629 

629* Agent view 會移除它,包括未提交的變更,因此請先提交您想保留的內容。630* Agent view 會移除它,包括未提交的變更,因此請先提交您想保留的內容。

630* `claude rm` 在它有未提交的變更時會保留它,連同工作階段列一起保留。631* `claude rm` 在它有未提交的變更時會保留它,連同工作階段列一起保留。

631* 當另一個執行中的工作階段正在使用或已鎖定某個 worktree 時,agent view 和 `claude rm` 都不會移除它,再次刪除也不會改變這一點。Claude Code 會保留 worktree 和工作階段,並指出保留的目錄及原因;在 agent view 中,工作階段的列會顯示 `not removed`。請關閉另一個工作階段,然後再次刪除。

632* 當您刪除的工作階段,其 worktree 有 Claude Code 無法確認已保存在其他地方的提交時,Claude Code 會保留 worktree 和工作階段,且訊息會指出 worktree 的分支以及有多少提交尚未推送。訊息也會提供兩種後續做法:推送提交,或再次刪除以捨棄它們。

633 632 

634 遠端上的提交不會阻擋刪除。位於您 `origin` 遠端預設分支之本機副本上的提交也不會,前提是該分支已在您的主簽出中簽出,也就是儲存庫目錄本身,而不是 worktree。633Claude Code 拒絕刪除工作階段的原因之一是[其 worktree 中有未推送的提交](https://code.claude.com/docs/zh-TW/errors.md#worktree-has-commits-that-are-not-pushed-anywhere)。若要保留這些提交,請在刪除工作階段之前推送它們。

635 634 

636 在該拒絕之後,您可以選擇:635無論您使用 agent view 或 `claude rm`,某些 worktree 都會保留在磁碟上:

637 636 

638 * 若要保留提交,請推送它們,或將它們合併到該預設分支,然後再次刪除工作階段。637* 如果您自己建立了 worktree 並從其中啟動工作階段,該 worktree 會保留在磁碟上,由您決定保留或移除。

639 * 若要捨棄它們,請在不推送的情況下再次刪除工作階段:在 agent view 中於其列上按兩次 `Ctrl+X`,或執行拒絕訊息所印出的 `claude rm <id> --discard-unpushed` 命令。這會移除工作階段和 worktree 及其分支,捨棄未推送的提交和任何未提交的變更。638* 如果 Claude 在您的儲存庫內建立的 worktree 目錄已不再有其 `.git` 檔案,該目錄會保留在磁碟上,由您自行移除。worktree 的分支會保留在儲存庫中,因此您會保有該分支上的提交。

640 639 

641 當您再次刪除時,Claude Code 只會捨棄拒絕訊息所顯示的內容:如果 worktree 在此之後新增了提交,Claude Code 會再次保留它並顯示更新後的狀態。640##### 在 Claude Code 拒絕後刪除工作階段

642 641 

643 當另一個已完成工作階段的記錄也指向該 worktree 時,您再次刪除時它仍會保留;請推送提交,然後再次刪除。642當 Claude Code 因工作階段的 worktree 而拒絕刪除它時,請依照其顯示的訊息操作。如果訊息指出有未推送的提交,請參閱 [Worktree has commits that are not pushed anywhere](https://code.claude.com/docs/zh-TW/errors.md#worktree-has-commits-that-are-not-pushed-anywhere)。

644* git 已無法辨識的 worktree(例如在 `git worktree prune` 之後)不會阻擋刪除。Claude Code 會刪除工作階段,並將目錄留在磁碟上。

645* 當 git 或您的 [`WorktreeRemove` hook](https://code.claude.com/docs/zh-TW/hooks#worktreeremove) 無法移除 worktree 時,Claude Code 會保留 worktree 和工作階段,且訊息會指出原因。若是 hook,訊息會說明其結束方式(例如 `exited 1`),並引用其 stderr 的開頭。訊息也會告訴您接下來可以執行以下哪一項:

646 643 

647 * 再次刪除工作階段以強制移除目錄,方法是在 agent view 中於其列上按兩次 `Ctrl+X`,或執行 `claude rm` 拒絕訊息所印出的 `claude rm <id> --force-remove-worktree <worktree-id>` 命令。worktree 的分支會保留在儲存庫中。644##### 解決 `Worktree not removed` 訊息

648 645 

649 只有在 Claude Code 能確認以下所有條件時,才會提供此選項:646`Worktree not removed` 訊息表示 Claude Code 或您的 [`WorktreeRemove` hook](https://code.claude.com/docs/zh-TW/hooks#worktreeremove) 未能完成移除工作階段的 worktree。請推送任何提交並複製出您想保留的任何檔案,然後依照訊息操作。

650 647 

651 * 該目錄是儲存庫在 `.claude/worktrees/` 下的連結 worktree 之一648##### 解決 `files that weren't checked against a repository` 訊息

652 * worktree 及已簽出的 submodule 對追蹤檔案都沒有未提交的變更

653 * 沒有其他工作階段的記錄指向它

654 649 

655 當 Claude Code 無法驗證 submodule 簽出的狀態時(例如已被獨立 git 儲存庫取代的 submodule),也不會提供此選項。650來自 `claude rm` 的此訊息表示,在不屬於任何 git 儲存庫或由 [`WorktreeCreate` hook](https://code.claude.com/docs/zh-TW/hooks#worktreecreate) 管理的 worktree 目錄中仍有檔案。請複製出您想保留的任何檔案,然後依您的情況採取對應步驟:

656 * 修正造成阻礙的問題,例如提交或 stash 未提交的變更、將獨立的 git 儲存庫移出 worktree、關閉正在使用該目錄的任何程式,或修正 hook,然後再次刪除工作階段。

657 * 自行移除目錄,然後再次刪除工作階段。

658 651 

659您自己建立並在其中啟動工作階段的 worktree,無論哪種情況都會保留在原處。652| 您的情況 | 處理方式 |

660 653| :- | :- |

661worktree 目錄不屬於任何 git 儲存庫的工作階段(因為儲存庫已被刪除,或 [`WorktreeCreate` hook](https://code.claude.com/docs/zh-TW/hooks#worktreecreate) 在其他位置建立了該目錄)仍然可以刪除。當目錄中仍有檔案時:654| 沒有 `WorktreeCreate` hook 管理該目錄 | 若要捨棄這些檔案,請在 agent view 中於工作階段的列上按兩次 `Ctrl+X`。或自行移除該目錄,然後再次執行 `claude rm <id>` |

662 655| 有 `WorktreeCreate` hook 管理該目錄,且您有 [`WorktreeRemove` hook](https://code.claude.com/docs/zh-TW/hooks#worktreeremove) | 若要嘗試以您的 hook 移除該目錄,請在 agent view 中於工作階段的列上按兩次 `Ctrl+X`。或自行移除該目錄,然後再次執行 `claude rm <id>` |

663* Agent view 在捨棄它們之前,會要求相同的 `Ctrl+X` 連按兩次。對於 hook 建立的目錄,它會改為執行您的 [`WorktreeRemove` hook](https://code.claude.com/docs/zh-TW/hooks#worktreeremove),若沒有該 hook,則會拒絕刪除並保留工作階段。656| 有 `WorktreeCreate` hook 管理該目錄,且您沒有 `WorktreeRemove` hook | 自行移除該目錄,然後再次執行 `claude rm <id>` |

664* `claude rm` 會保留工作階段和 worktree,並指出原因。

665 

666無論哪種方式,都會保留另一個已完成工作階段的記錄所指向的目錄。

667 657 

668### 設定模型、effort 與快速模式658### 設定模型、effort 與快速模式

669 659 


774| [`--add-dir <path>`](https://code.claude.com/docs/zh-TW/permissions#additional-directories-grant-file-access-not-configuration) | 授予對額外目錄的檔案存取權限 |764| [`--add-dir <path>`](https://code.claude.com/docs/zh-TW/permissions#additional-directories-grant-file-access-not-configuration) | 授予對額外目錄的檔案存取權限 |

775| [`--plugin-dir <path>`](https://code.claude.com/docs/zh-TW/plugins/create#load-a-directory-or-archive-for-one-session) | 從本機目錄載入外掛 |765| [`--plugin-dir <path>`](https://code.claude.com/docs/zh-TW/plugins/create#load-a-directory-or-archive-for-one-session) | 從本機目錄載入外掛 |

776| [`--mcp-config <file-or-json>`](https://code.claude.com/docs/zh-TW/mcp) | 從設定檔或 JSON 字串載入 MCP 伺服器 |766| [`--mcp-config <file-or-json>`](https://code.claude.com/docs/zh-TW/mcp) | 從設定檔或 JSON 字串載入 MCP 伺服器 |

777| `--strict-mcp-config` | 僅使用來自 `--mcp-config` 的 MCP 伺服器,忽略其他 MCP 設定。關於此旗標在受管 MCP 檔案下的行為,請參閱[使用 managed-mcp.json 進行獨佔控制](https://code.claude.com/docs/zh-TW/managed-mcp.md#exclusive-control-with-managed-mcp-json) |767| `--strict-mcp-config` | 略過在 `.mcp.json` 等位置設定的 MCP 伺服器,並載入您以 `--mcp-config` 傳遞的 MCP 伺服器。關於此旗標在受管 MCP 檔案下的行為,請參閱[使用 managed-mcp.json 進行獨佔控制](https://code.claude.com/docs/zh-TW/managed-mcp.md#exclusive-control-with-managed-mcp-json) |

778 768 

779每個值各重複一次 `--add-dir`、`--plugin-dir` 或 `--mcp-config`。`claude agents` 不支援以空格分隔的形式,例如 `--add-dir a b c`。769每個值各重複一次 `--add-dir`、`--plugin-dir` 或 `--mcp-config`。`claude agents` 不支援以空格分隔的形式,例如 `--add-dir a b c`。

780 770 


802| `claude stop <id>` | 停止工作階段。也接受 `claude kill` |792| `claude stop <id>` | 停止工作階段。也接受 `claude kill` |

803| `claude respawn <id>` | 重新啟動工作階段(執行中或已停止),例如用於採用更新的 Claude Code 二進位檔案。具有已儲存對話的工作階段會繼續該對話 |793| `claude respawn <id>` | 重新啟動工作階段(執行中或已停止),例如用於採用更新的 Claude Code 二進位檔案。具有已儲存對話的工作階段會繼續該對話 |

804| `claude respawn --all` | 重新啟動每個執行中的工作階段,例如一次將所有工作階段移至更新的 Claude Code 二進位檔案 |794| `claude respawn --all` | 重新啟動每個執行中的工作階段,例如一次將所有工作階段移至更新的 Claude Code 二進位檔案 |

805| `claude rm <id>` | 從清單中移除工作階段,以及 Claude 為其建立的 worktree(當安全刪除時);請參閱 [刪除工作階段會移除什麼](#what-deleting-a-session-removes)。對話逐字稿會保留在您的本機上,並可透過 `claude --resume` 繼續使用 |795| `claude rm <id>` | 從清單中移除工作階段,以及 Claude 為其建立的 worktree(當可安全刪除時)。如果 Claude Code 因其 worktree 而拒絕刪除工作階段,請參閱 [在 Claude Code 拒絕後刪除工作階段](#delete-a-session-after-claude-code-refuses)。對話逐字稿會保留在您的本機上,並可透過 `claude --resume` 繼續使用 |

806| `claude rm <id> --discard-unpushed <commit>@<worktree-id>` | 刪除因未推送提交而拒絕刪除的工作階段,捨棄 worktree 及其分支和提交。傳遞拒絕列印的確切值;請參閱 [刪除工作階段會移除什麼](#what-deleting-a-session-removes)。需要 v2.1.260 或更新版本 |796| `claude rm <id> --discard-unpushed <commit>@<worktree-id>` | 在 Claude Code 因未推送的提交而拒絕後,再次嘗試刪除工作階段並捨棄其 worktree。請從提供此命令的 `claude rm` 訊息中複製該命令;請參閱 [Worktree has commits that are not pushed anywhere](https://code.claude.com/docs/zh-TW/errors.md#worktree-has-commits-that-are-not-pushed-anywhere)。需要 v2.1.260 或更新版本 |

807| `claude rm <id> --force-remove-worktree <worktree-id>` | 刪除因 git 或 `WorktreeRemove` hook 無法移除其 worktree 而拒絕刪除的工作階段,無論如何刪除 worktree 目錄並在儲存庫中保留其分支。傳遞拒絕列印的確切值;請參閱 [刪除工作階段會移除什麼](#what-deleting-a-session-removes)。需要 v2.1.268 或更新版本 |797| `claude rm <id> --force-remove-worktree <worktree-id>` | 在 Claude Code 因無法移除 worktree 而拒絕後,再次嘗試刪除工作階段,並無論如何移除其 worktree 目錄。請從提供此命令的 `claude rm` 訊息中複製該命令;請參閱 [解決 `Worktree not removed` 訊息](#resolve-a-worktree-not-removed-message)。需要 v2.1.268 或更新版本 |

808| `claude daemon status` | 列印 [supervisor](#the-supervisor-process) 的狀態、版本、socket 目錄和 worker 計數 |798| `claude daemon status` | 列印 [supervisor](#the-supervisor-process) 的狀態、版本、socket 目錄和 worker 計數 |

809| `claude daemon logs` | 追蹤 supervisor 的日誌檔案 [`~/.claude/daemon.log`](#where-state-is-stored),在新行出現時列印出來,直到您按下 `Ctrl+C` |799| `claude daemon logs` | 追蹤 supervisor 的日誌檔案 [`~/.claude/daemon.log`](#where-state-is-stored),在新行出現時列印出來,直到您按下 `Ctrl+C` |

810| `claude daemon stop --any` | 停止 supervisor 程序及其託管的背景工作階段。傳遞 `--keep-workers` 以保持背景工作階段執行中,以便[下一個 supervisor](#the-supervisor-process) 可以重新連接到它們。下一個 `claude agents` 或 `claude --bg` 會啟動全新的 supervisor |800| `claude daemon stop --any` | 停止 supervisor 程序及其託管的背景工作階段。傳遞 `--keep-workers` 以保持背景工作階段執行中,以便[下一個 supervisor](#the-supervisor-process) 可以重新連接到它們。下一個 `claude agents` 或 `claude --bg` 會啟動全新的 supervisor |


912 902 

913### 背景化顯示 `Background this session?` 對話框903### 背景化顯示 `Background this session?` 對話框

914 904 

915當您按 `←` 將工作階段放到背景時,若出現 `Background this session?` 對話框,表示該工作階段有進行中的背景工作,背景化會使其停止、中斷,或在無人看管的情況下繼續執行:905當您按 `←` 將工作階段放到背景時,若出現 `Background this session?` 對話框,表示該工作階段有進行中的背景工作,背景化會使其停止或中斷:

916 906 

917* **無法移動的工作**:工作階段有無法移動到背景工作階段的工作,例如執行中的 [monitor](https://code.claude.com/docs/zh-TW/tools-reference.md#monitor-tool)。對話框會列出 Claude Code 將停止的背景工作,並另外計算會轉移的任務數量。907* **無法移動的工作**:工作階段有無法移動到背景工作階段的工作,例如執行中的 [monitor](https://code.claude.com/docs/zh-TW/tools-reference.md#monitor-tool)。對話框會列出 Claude Code 將停止的背景工作,並另外計算會轉移的任務數量。

918* **具有執行中 subagent 的工作流程**:[動態工作流程](https://code.claude.com/docs/zh-TW/workflows.md)仍有 subagent 在執行。如果您仍要背景化,這些 subagent 會停止,對話框會說明有多少個。當 Claude [在背景工作階段中重新啟動該工作流程](#dynamic-workflows-when-you-background)時,它們會從頭開始。908* **具有執行中 subagent 的工作流程**:[動態工作流程](https://code.claude.com/docs/zh-TW/workflows.md)仍有 subagent 在執行。如果您仍要背景化,這些 subagent 會停止,對話框會說明有多少個。當 Claude [在背景工作階段中重新啟動該工作流程](#dynamic-workflows-when-you-background)時,它們會從頭開始。

919* **自動 artifact 回覆**:Claude 正在[自行回覆 artifact 上的評論](https://code.claude.com/docs/zh-TW/artifacts.md#let-claude-reply-to-comments-on-its-own)。這些回覆會在背景工作階段中繼續,對話框也會說明這一點。909* **自動 artifact 回覆**:Claude 正在[自行回覆 artifact 上的評論](https://code.claude.com/docs/zh-TW/artifacts.md#let-claude-reply-to-comments-on-its-own)。如果您仍要背景化,這些回覆會停止。

920 910 

921執行 `/tasks` 以查看正在執行的所有內容,然後確認仍要背景化,或選擇 `Stay` 讓工作先完成。請參閱[背景化時轉移的內容](#what-carries-over-when-you-background)以了解哪些類型的工作會轉移,哪些會被 Claude Code 停止。911執行 `/tasks` 以查看正在執行的所有內容,然後確認仍要背景化,或選擇 `Stay` 讓工作先完成。請參閱[背景化時轉移的內容](#what-carries-over-when-you-background)以了解哪些類型的工作會轉移,哪些會被 Claude Code 停止。

922 912 


939 929 

940 在該列上按 `Enter`,頁尾會顯示 `Press enter again to resume this session (it ended while the background service was off), or ctrl+x to remove it.` 在同一列上再次按 `Enter` 以恢復其已儲存的對話。回覆或 `claude attach <id>` 會在沒有該頁尾提示的情況下恢復它。930 在該列上按 `Enter`,頁尾會顯示 `Press enter again to resume this session (it ended while the background service was off), or ctrl+x to remove it.` 在同一列上再次按 `Enter` 以恢復其已儲存的對話。回覆或 `claude attach <id>` 會在沒有該頁尾提示的情況下恢復它。

941 931 

942當[逐字稿清理](https://code.claude.com/docs/zh-TW/settings-reference.md#cleanupperioddays)已移除停止工作階段的已儲存對話時,Claude Code 會拒絕開啟該列:訊息會說明沒有可恢復的內容。`claude rm <id>` 會刪除該列(上述[保留的情況](#what-deleting-a-session-removes)除外),而 `claude respawn <id>` 會再次執行其原始提示詞。請參閱[此工作階段的已儲存對話已不在磁碟上](https://code.claude.com/docs/zh-TW/errors.md#this-sessions-saved-conversation-is-no-longer-on-disk)。932當[逐字稿清理](https://code.claude.com/docs/zh-TW/settings-reference.md#cleanupperioddays)已移除停止工作階段的已儲存對話時,Claude Code 會拒絕開啟該列:訊息會說明沒有可恢復的內容。`claude rm <id>` 會刪除該列,除非 [Claude Code 拒絕刪除](#what-deleting-a-session-removes),而 `claude respawn <id>` 會再次執行其原始提示詞。請參閱[此工作階段的已儲存對話已不在磁碟上](https://code.claude.com/docs/zh-TW/errors.md#this-sessions-saved-conversation-is-no-longer-on-disk)。

943 933 

944單純的睡眠不會停止工作階段。工作階段在睡眠期間會被保留,監督程序在喚醒時會重新連接到它們。934單純的睡眠不會停止工作階段。工作階段在睡眠期間會被保留,監督程序在喚醒時會重新連接到它們。

945 935 

946### 開啟工作階段時顯示對話已開啟936### 開啟工作階段時顯示對話已開啟

947 937 

948兩個程序無法寫入同一個逐字稿。當停止工作階段的已儲存對話已在另一個執行中的 Claude Code 程序中開啟時,Claude Code 會拒絕啟動該工作階段自己的程序。您看到的內容取決於持有該對話的是什麼:938這些訊息表示此機器上的另一個 Claude Code 程序已開啟該停止工作階段的已儲存對話,因此 agent view 和 `claude attach` 不會開啟該工作階段:

949 939 

950* 您恢復對話的終端機,例如使用 `claude --resume` 或 `/resume`:該列顯示 `Open in a terminal`,並提示在那裡繼續,開啟該列會顯示 `Can't open — this session is running in another terminal`。在該終端機中繼續,或退出它並再次開啟該列。940* `Can't open — this session is running in another terminal`:另一個程序已開啟該對話,例如 `claude -p` 的執行,或您在其中恢復該對話的終端機。請在該終端機中繼續,或退出該程序或等待其完成,然後再次開啟該工作階段。

951* 另一個非互動式 Claude Code 程序,例如同一對話的背景工作階段程序尚未退出:開啟該列會顯示 `This conversation is already open in another running Claude session`。使用該程序,或等待它退出後再次開啟該列。941* `This conversation is already open in another running Claude session`:另一個背景工作階段已開啟該對話。請使用該工作階段,或停止它後再次開啟此工作階段。

952 942 

953Claude Code 會儲存您在被拒絕的嘗試中輸入的回覆(以 `!` 或 `/` 開頭的回覆除外),並在工作階段下次啟動時傳送它。943Claude Code 會儲存您在被拒絕的嘗試中輸入的回覆(以 `!` 或 `/` 開頭的回覆除外),並在工作階段下次啟動時傳送它。

954 944 


973 963 

974當背景工作階段的程序在完成啟動前退出,且主機記憶體不足時,該列的狀態會說明退出情況並附加 `possibly low memory — free some up and retry`。964當背景工作階段的程序在完成啟動前退出,且主機記憶體不足時,該列的狀態會說明退出情況並附加 `possibly low memory — free some up and retry`。

975 965 

976該註記是一個假設,而不是已確認的原因。Claude Code 只在程序無聲退出(未寫入錯誤,也未被信號停止)且主機在該時刻回報記憶體不足時才會附加它。當程序在退出前確實寫入了錯誤時,該列會改為顯示該錯誤。966> [!NOTE]

967>

968> 該註記是一個假設,而不是已確認的原因。Claude Code 只在程序無聲退出(未寫入錯誤,也未被信號停止)且主機在該時刻回報記憶體不足時才會附加它。當程序在退出前確實寫入了錯誤時,該列會改為顯示該錯誤。

977 969 

978釋放機器上的記憶體,然後附加或回覆該列,監督程序會為工作階段啟動新的程序。當記憶體持續不足時,監督程序也會自行[停止閒置工作階段](#the-supervisor-process)以釋放資源,如果停止其他工作階段沒有釋放任何資源,也會停止閒置的釘選工作階段。970釋放主機上的記憶體,然後在該列上按 `Enter`,如果[頁尾要求](#opening-a-session-says-it-has-no-saved-transcript),請再按一次。[監督程序](#the-supervisor-process)會為工作階段啟動新的程序。當記憶體持續不足時,監督程序也會自行[停止閒置工作階段](#the-supervisor-process)以釋放資源,如果停止其他工作階段沒有釋放任何資源,也會停止閒置的釘選工作階段。

979 971 

980### Agent view 表示背景服務未回應972### Agent view 表示背景服務未回應

981 973 


1036 1028 

1037### `.claude/worktrees/` 正在填滿1029### `.claude/worktrees/` 正在填滿

1038 1030 

1039在 agent view 中刪除工作階段會移除 Claude 為其建立的 worktree,但[某些刪除會保留 worktree 或在磁碟上留下其目錄](#what-deleting-a-session-removes),因此剩餘目錄可能會累積。Git 不再識別的目錄不會出現在 `git worktree list` 中,因此請手動移除這些目錄。1031在 agent view 中刪除工作階段會移除 Claude 為其建立的 worktree,但[某些 worktree 目錄會保留在磁碟上](#what-deleting-a-session-removes)。Git 不再識別的目錄不會出現在 `git worktree list` 中,因此請手動移除這些目錄。

1040 1032 

1041在專案目錄中使用 `git worktree list` 列出剩餘項目,並使用 `git worktree remove <path>` 逐一移除。請參閱[清理 worktree](https://code.claude.com/docs/zh-TW/worktrees.md#clean-up-worktrees)。1033在專案目錄中使用 `git worktree list` 列出剩餘項目,並使用 `git worktree remove <path>` 逐一移除。如果 Git 拒絕,請參閱[清理 subagent 和背景工作階段的 worktree](https://code.claude.com/docs/zh-TW/worktrees.md#clean-up-subagent-and-background-session-worktrees)。

1042 1034 

1043## 限制1035## 限制

1044 1036 


1046 1038 

1047* **速率限制適用**:背景工作階段與互動工作階段一樣消耗您的訂閱使用量,因此並行執行十個代理的使用配額速度快十倍。1039* **速率限制適用**:背景工作階段與互動工作階段一樣消耗您的訂閱使用量,因此並行執行十個代理的使用配額速度快十倍。

1048* **工作階段是本地的**:背景工作階段在您的機器上執行。它們在睡眠時保留,但如果機器關閉則停止。1040* **工作階段是本地的**:背景工作階段在您的機器上執行。它們在睡眠時保留,但如果機器關閉則停止。

1049* **Claude 建立的 worktrees 在 agent view 中隨工作階段刪除**:在刪除在其自己的 worktree 中編輯檔案的工作階段之前,提交變更。[某些刪除會改為保留 worktree](#what-deleting-a-session-removes)。1041* **Claude 建立的 worktrees 在 agent view 中隨工作階段刪除**:在刪除在其自己的 worktree 中編輯檔案的工作階段之前,提交變更。[某些 worktree 會保留在磁碟上](#what-deleting-a-session-removes)。

1050 1042 

1051## 相關資源1043## 相關資源

1052 1044 


1064 1056 

1065| 版本 | 變更 |1057| 版本 | 變更 |

1066| - | - |1058| - | - |

1059| v2.1.323 | 在 agent view 的輸入中,[`Ctrl+Y`](#keyboard-shortcuts) 會還原已清除的文字。 |

1067| v2.1.299 | [分派輸入中的 `/effort` 和 `/fast`](#set-the-model-effort-and-fast-mode) 會為您接下來分派的工作階段設定 effort 等級和快速模式。不帶值輸入 `/model`、`/effort` 或 `/fast` 會開啟選擇器。 |1060| v2.1.299 | [分派輸入中的 `/effort` 和 `/fast`](#set-the-model-effort-and-fast-mode) 會為您接下來分派的工作階段設定 effort 等級和快速模式。不帶值輸入 `/model`、`/effort` 或 `/fast` 會開啟選擇器。 |

1068| v2.1.299 | Claude Code 僅在任何單獨的 `--` 分隔符之前、且不在另一個旗標的值中時,才[將 `--bg` 和 `--background` 讀取為旗標](#from-your-shell),並在位置不明確時拒絕執行,而不是猜測。在此版本之前,內容為 `--bg` 或 `--background` 的提示詞或傳給背景工作階段的回覆可能會被當成旗標。這可能會反覆啟動新的背景工作階段,而不是傳遞該文字。 |1061| v2.1.299 | Claude Code 僅在任何單獨的 `--` 分隔符之前、且不在另一個旗標的值中時,才[將 `--bg` 和 `--background` 讀取為旗標](#from-your-shell),並在位置不明確時拒絕執行,而不是猜測。在此版本之前,內容為 `--bg` 或 `--background` 的提示詞或傳給背景工作階段的回覆可能會被當成旗標。這可能會反覆啟動新的背景工作階段,而不是傳遞該文字。 |

1069| v2.1.296 | 您在[工作階段移到背景時](#switch-sessions-without-leaving-the-terminal)輸入的提示詞或 `!` shell 命令會被停止或保持未傳送,其文字會保留在提示詞歷史中。在此版本之前,回應或命令會在您再也看不到的地方持續執行,而在 `←` 之後立即傳送的提示詞可能會在看不見的情況下再執行一次。在 `SessionStart` hook 仍在執行時輸入的提示詞會遺失:既未傳送,也不在提示詞歷史中。 |1062| v2.1.296 | 您在[工作階段移到背景時](#switch-sessions-without-leaving-the-terminal)輸入的提示詞或 `!` shell 命令會被停止或保持未傳送,其文字會保留在提示詞歷史中。在此版本之前,回應或命令會在您再也看不到的地方持續執行,而在 `←` 之後立即傳送的提示詞可能會在看不見的情況下再執行一次。在 `SessionStart` hook 仍在執行時輸入的提示詞會遺失:既未傳送,也不在提示詞歷史中。 |


1111| v2.1.246 | `/fork` 會從本身作為副本啟動、且之後尚未記錄新提示詞的工作階段[複製完整對話](#copy-the-session-with-%2Ffork):您附加的 `/fork` 副本、在 `←` 或 `/background` 將其移到背景後重新附加的工作階段,或使用 `claude --resume <id> --fork-session` 啟動的工作階段。在此版本之前,如果您在傳送新提示詞前就在這樣的工作階段中執行 `/fork`,Claude Code 會列印正常的確認訊息,但以空對話啟動副本。使用 `←` 或 `/background` 將這樣的工作階段移到背景也會以相同方式遺失對話。 |1104| v2.1.246 | `/fork` 會從本身作為副本啟動、且之後尚未記錄新提示詞的工作階段[複製完整對話](#copy-the-session-with-%2Ffork):您附加的 `/fork` 副本、在 `←` 或 `/background` 將其移到背景後重新附加的工作階段,或使用 `claude --resume <id> --fork-session` 啟動的工作階段。在此版本之前,如果您在傳送新提示詞前就在這樣的工作階段中執行 `/fork`,Claude Code 會列印正常的確認訊息,但以空對話啟動副本。使用 `←` 或 `/background` 將這樣的工作階段移到背景也會以相同方式遺失對話。 |

1112| v2.1.246 | 當您在剛分派的工作階段的工作程序仍在啟動時開啟它,例如在其列上按 `Enter`,Claude Code 會等待程序然後附加。在此版本之前,如果您在程序仍在啟動時按 `Enter`,Claude Code 可能會停止工作階段,出現 [`Session <id> was stopped while the respawn was in flight`](https://code.claude.com/docs/zh-TW/errors#session-was-stopped-while-the-respawn-was-in-flight)。 |1105| v2.1.246 | 當您在剛分派的工作階段的工作程序仍在啟動時開啟它,例如在其列上按 `Enter`,Claude Code 會等待程序然後附加。在此版本之前,如果您在程序仍在啟動時按 `Enter`,Claude Code 可能會停止工作階段,出現 [`Session <id> was stopped while the respawn was in flight`](https://code.claude.com/docs/zh-TW/errors#session-was-stopped-while-the-respawn-was-in-flight)。 |

1113| v2.1.246 | 當您[背景化](#from-inside-a-session)已命名的工作階段時,Claude Code 只會列出它一次,而當您再次背景化相同的對話時,它會為新列的名稱編號,例如 `my-session (2)`,現有列則保留其名稱。在此版本之前,您按下 `←` 的終端機可能會在 `claude agents --json` 中以相同名稱作為第二個工作階段出現,如果您再次背景化相同的對話,Claude Code 會以完全相同的名稱新增另一列。 |1106| v2.1.246 | 當您[背景化](#from-inside-a-session)已命名的工作階段時,Claude Code 只會列出它一次,而當您再次背景化相同的對話時,它會為新列的名稱編號,例如 `my-session (2)`,現有列則保留其名稱。在此版本之前,您按下 `←` 的終端機可能會在 `claude agents --json` 中以相同名稱作為第二個工作階段出現,如果您再次背景化相同的對話,Claude Code 會以完全相同的名稱新增另一列。 |

1114| v2.1.239 | 開啟 [vim 編輯器模式](https://code.claude.com/docs/zh-TW/interactive-mode.md#vim-editor-mode)時,在 agent view 的輸入中按 `Esc` 會從 INSERT 切換到 NORMAL 模式並保留您的文字,與主要提示詞輸入一致;在 NORMAL 模式下輸入中仍有文字時,按 `Esc` 會清除它,在空輸入上按 `Esc` 則會退出,如 [`Esc` 快捷鍵](#keyboard-shortcuts)所述。在此版本之前,`Esc` 會清除輸入。 |1107| v2.1.239 | 開啟 [vim 編輯器模式](https://code.claude.com/docs/zh-TW/interactive-mode.md#vim-editor-mode)時,在 agent view 的輸入中按 `Esc` 會從 INSERT 切換到 NORMAL 模式並保留您的文字,與主要提示詞輸入一致。在此版本之前,`Esc` 會清除輸入。 |

1115| v2.1.233 | 對於連結到 GitLab merge request 的工作階段,Claude Code 會以 GitLab 的 `!1234` 參考語法寫入該列的標籤。您也可以將 merge request 的 URL 貼到[分派輸入](#filter-sessions)中以選取該工作階段。在此版本之前,標籤呈現為 `#1234`,而貼上的 merge request URL 只有在工作階段的第一個提示詞包含該 URL 時才會符合。 |1108| v2.1.233 | 對於連結到 GitLab merge request 的工作階段,Claude Code 會以 GitLab 的 `!1234` 參考語法寫入該列的標籤。您也可以將 merge request 的 URL 貼到[分派輸入](#filter-sessions)中以選取該工作階段。在此版本之前,標籤呈現為 `#1234`,而貼上的 merge request URL 只有在工作階段的第一個提示詞包含該 URL 時才會符合。 |

1116| v2.1.227 | 當另一個執行中的 Claude Code 工作階段正在該 worktree 目錄內執行時,[刪除工作階段](#what-deleting-a-session-removes)會保留工作階段及其 worktree。Agent view 會在列上顯示 `not deleted` 並在頁尾顯示原因,`claude rm` 會列印 `kept <id>` 及原因,其中會指出另一個工作階段的程序 ID。在此版本之前,刪除工作階段會在另一個工作階段仍在其中工作時移除 worktree。 |1109| v2.1.227 | 當另一個執行中的 Claude Code 工作階段正在該 worktree 目錄內執行時,[刪除工作階段](#what-deleting-a-session-removes)會保留工作階段及其 worktree。Agent view 會在列上顯示 `not deleted` 並在頁尾顯示原因,`claude rm` 會列印 `kept <id>` 及原因,其中會指出另一個工作階段的程序 ID。在此版本之前,刪除工作階段會在另一個工作階段仍在其中工作時移除 worktree。 |

1117| v2.1.225 | 在您尚未信任的目錄中執行 `claude agents`,會在 agent view 開啟前顯示與 `claude` 啟動時相同的[工作區信任對話框](https://code.claude.com/docs/zh-TW/permissions.md#project-allow-rules-and-workspace-trust)。接受會儲存該工作區的信任;拒絕則會在不開啟 agent view 的情況下退出。在此版本之前,`claude agents` 會在不詢問的情況下開啟,所以您從它分派的工作階段會在您從未被要求信任的目錄中執行。 當清單依目錄分組時,將滑鼠懸停在列上會醒目提示它,但不會改變[分派目標](#dispatch-to-a-specific-directory);使用方向鍵或點擊選取列仍會改變目標。在此版本之前,將滑鼠移到另一個專案中的工作階段上,會在無提示的情況下改變下一個分派工作階段的啟動目錄。 |1110| v2.1.225 | 在您尚未信任的目錄中執行 `claude agents`,會在 agent view 開啟前顯示與 `claude` 啟動時相同的[工作區信任對話框](https://code.claude.com/docs/zh-TW/permissions.md#project-allow-rules-and-workspace-trust)。接受會儲存該工作區的信任;拒絕則會在不開啟 agent view 的情況下退出。在此版本之前,`claude agents` 會在不詢問的情況下開啟,所以您從它分派的工作階段會在您從未被要求信任的目錄中執行。 當清單依目錄分組時,將滑鼠懸停在列上會醒目提示它,但不會改變[分派目標](#dispatch-to-a-specific-directory);使用方向鍵或點擊選取列仍會改變目標。在此版本之前,將滑鼠移到另一個專案中的工作階段上,會在無提示的情況下改變下一個分派工作階段的啟動目錄。 |

artifacts.md +2 −3

Details

368| 外部請求 | 頁面可以從 Google Fonts 載入字型,以及從[五個公開 CDN 主機](#allowlist-the-viewer-domain)載入指令碼:cdnjs、unpkg、Tailwind 和 jQuery CDN,以及 jsDelivr 上的選定路徑,例如 `/npm/`。CSP 會阻止所有外部影像和所有其他外部指令碼、樣式表和字型,並讓 `fetch`、XHR 和 WebSocket 呼叫只能到達頁面自身的來源和 Google Fonts 主機。因此,Claude 會從這些 CDN 之一載入頁面需要的任何程式庫,內嵌所有其他 CSS 和 JavaScript,並將影像嵌入為資料 URI。[Connector 呼叫](#pull-live-data-with-mcp-connectors)會通過 claude.ai 進行,它會自行進行網路呼叫。 |368| 外部請求 | 頁面可以從 Google Fonts 載入字型,以及從[五個公開 CDN 主機](#allowlist-the-viewer-domain)載入指令碼:cdnjs、unpkg、Tailwind 和 jQuery CDN,以及 jsDelivr 上的選定路徑,例如 `/npm/`。CSP 會阻止所有外部影像和所有其他外部指令碼、樣式表和字型,並讓 `fetch`、XHR 和 WebSocket 呼叫只能到達頁面自身的來源和 Google Fonts 主機。因此,Claude 會從這些 CDN 之一載入頁面需要的任何程式庫,內嵌所有其他 CSS 和 JavaScript,並將影像嵌入為資料 URI。[Connector 呼叫](#pull-live-data-with-mcp-connectors)會通過 claude.ai 進行,它會自行進行網路呼叫。 |

369| 無後端 | 成品是靜態頁面。它無法自行驗證檢視者。 |369| 無後端 | 成品是靜態頁面。它無法自行驗證檢視者。 |

370| 下載 | 頁面無法自行啟動下載。為了讓檢視者儲存頁面產生的檔案,Claude 會宣告下載功能。請參閱[提供檔案下載](#offer-a-file-download)。 |370| 下載 | 頁面無法自行啟動下載。為了讓檢視者儲存頁面產生的檔案,Claude 會宣告下載功能。請參閱[提供檔案下載](#offer-a-file-download)。 |

371| 單一頁面 | 相對連結無法解析,因為頁面旁邊沒有部署任何內容。對於多區段內容,Claude 使用頁面內錨點而不是個別檔案。 |

372| 來源檔案類型 | 發佈的檔案必須是 `.html`、`.htm` 或 `.md`,且必須解碼為 UTF-8,或根據其位元組順序標記解碼為小端 UTF-16。Markdown 檔案會呈現為樣式化的文件頁面,並具有語法醒目提示的程式碼。無法解碼或包含替換字元 `U+FFFD` 的檔案會[被拒絕並顯示要修正的行和列](https://code.claude.com/docs/zh-TW/errors.md#the-source-file-is-not-valid-utf-8-text)。 |371| 來源檔案類型 | 發佈的檔案必須是 `.html`、`.htm` 或 `.md`,且必須解碼為 UTF-8,或根據其位元組順序標記解碼為小端 UTF-16。Markdown 檔案會呈現為樣式化的文件頁面,並具有語法醒目提示的程式碼。無法解碼或包含替換字元 `U+FFFD` 的檔案會[被拒絕並顯示要修正的行和列](https://code.claude.com/docs/zh-TW/errors.md#the-source-file-is-not-valid-utf-8-text)。 |

373| 來源位置 | 路徑指向網路主機的檔案會在未被讀取的情況下遭到拒絕。請參閱[未發佈:該檔案位於網路共用上](https://code.claude.com/docs/zh-TW/errors.md#not-published-that-file-is-on-a-network-share),了解哪些路徑會遭到拒絕,以及 Windows 上對應磁碟機的例外情況。 |372| 來源位置 | 路徑指向網路主機的檔案會在未被讀取的情況下遭到拒絕。請參閱[未發佈:該檔案位於網路共用上](https://code.claude.com/docs/zh-TW/errors.md#not-published-that-file-is-on-a-network-share),了解哪些路徑會遭到拒絕,以及 Windows 上對應磁碟機的例外情況。 |

374| 呈現大小 | 呈現的頁面必須為 16 MiB 或更小。大型嵌入影像通常是發佈因大小而失敗的原因。 |373| 呈現大小 | 呈現的頁面必須為 16 MiB 或更小。大型嵌入影像通常是發佈因大小而失敗的原因。 |


432 431 

433要設定在自動刪除之前保留成品的時間,請前往 [**組織設定 > 資料和隱私**](https://claude.ai/admin-settings/data-privacy-controls)。您可以為仍然是其作者私人的成品和已共享的成品設定單獨的保留期。432要設定在自動刪除之前保留成品的時間,請前往 [**組織設定 > 資料和隱私**](https://claude.ai/admin-settings/data-privacy-controls)。您可以為仍然是其作者私人的成品和已共享的成品設定單獨的保留期。

434 433 

435### 檢查稽核日誌434### 使用 Compliance API 稽核 artifact 活動

436 435 

437發佈、分享和刪除成品各自出現在您組織的稽核日誌中,位於 `claude_artifact_*` 事件類型下,與在 claude.ai 對話中建立的成品使用的相同系列。436在 Enterprise 方案上,查詢 Compliance API 的 [Activity Feed](https://platform.claude.com/docs/en/manage-claude/compliance-activity-feed),即可查看誰發佈、分享或刪除了 artifact。要找出可用於篩選的活動類型,請在 [Activity Feed 參考](https://platform.claude.com/docs/en/api/compliance/activities/list)中展開 `activity_types`,並尋找名稱包含 `artifact` 的項目。

438 437 

439### 允許列表檢視器網域438### 允許列表檢視器網域

440 439 

Details

28 28 

29## 常見的邊界29## 常見的邊界

30 30 

31自動模式允許推送到您正在使用的儲存庫的任何分支(包括預設分支),並預設建立拉取請求。名稱標記為部署或發佈目標的非預設分支(例如 `production`、`release` 或 `gh-pages`)不受該預設涵蓋:分類器會根據其自身條件判斷推送到該分支,包括作為生產部署。推送的內容仍然會被檢查,因此強制推送、秘密進入提交,或在 CI 或部署管道執行時會將秘密發送到儲存庫外的變更仍然會被阻止。31在自動模式下,Claude 預設可以推送到您正在使用的儲存庫(包括其預設分支),而不會顯示提示。當您的任務要求時,它也可以在該儲存庫中開啟 pull request。部分推送和 pull request [會被阻止](https://code.claude.com/docs/zh-TW/permission-modes.md#what-the-classifier-blocks-by-default),例如包含秘密的推送,或向另一個儲存庫開啟的 pull request。

32 32 

33如果您想在 Claude 的推送和拉取請求命令之前進行人工檢查點,請新增權限規則:下面的[配方](#add-a-human-checkpoint)會保持自動模式對所有其他操作開啟。33如果您想在 Claude 的推送和拉取請求命令之前進行人工檢查點,請新增權限規則:下面的[配方](#add-a-human-checkpoint)會保持自動模式對所有其他操作開啟。

34 34 

35### 新增人工檢查點35### 新增人工檢查點

36 36 

37最直接的機制是 [`permissions.ask`](https://code.claude.com/docs/zh-TW/permissions#permission-rule-syntax)。內容範圍的 ask 規則(如下面的規則)在分類器之前進行評估,並且始終強制權限提示,即使在自動模式下也是如此,因為明確的 ask 規則是您要求提示該操作的明確意圖。在您的[設定](https://code.claude.com/docs/zh-TW/settings.md#where-settings-live)中新增規則:37最直接的機制是 [`permissions.ask`](https://code.claude.com/docs/zh-TW/permissions#permission-rule-syntax)。下面的 ask 規則會在分類器之前進行評估,因此預設情況下您會看到提示。在您的[設定](https://code.claude.com/docs/zh-TW/settings.md#where-settings-live)中新增規則:

38 38 

39```json theme={null}39```json theme={null}

40{40{


53 53 

54| 邊界 | 機制 | 自動模式中的行為 |54| 邊界 | 機制 | 自動模式中的行為 |

55| :- | :- | :- |55| :- | :- | :- |

56| 在操作前提示 | `permissions.ask` | 始終為符合內容範圍規則(如上面的配方)的命令提示。分類器無法自動批准符合的操作。 |56| 在操作前提示 | `permissions.ask` | 預設情況下,會為符合內容範圍規則(如上面的配方)的命令提示。分類器無法自動批准符合的操作。 |

57| 永不執行操作 | `permissions.deny` | 在諮詢分類器之前阻止。分類器和使用者意圖都無法覆蓋它。 |57| 永不執行操作 | `permissions.deny` | 在諮詢分類器之前阻止。分類器和使用者意圖都無法覆蓋它。 |

58| 此工作階段的一次性邊界 | 在對話中陳述,例如「在我審查之前不要推送」 | 分類器會阻止符合的操作,但如果[內容壓縮](https://code.claude.com/docs/zh-TW/costs.md#reduce-token-usage)移除了陳述該邊界的訊息,邊界可能會遺失。使用 ask 或 deny 規則以獲得持久保證。 |58| 此工作階段的一次性邊界 | 在對話中陳述,例如「在我審查之前不要推送」 | 分類器會阻止符合的操作,但如果[內容壓縮](https://code.claude.com/docs/zh-TW/costs.md#reduce-token-usage)移除了陳述該邊界的訊息,邊界可能會遺失。使用 ask 或 deny 規則以獲得持久保證。 |

59 59 


95 * **祕密管理**95 * **祕密管理**

96 * **CI/CD 部署目標**96 * **CI/CD 部署目標**

97 * **網路態勢**97 * **網路態勢**

98 * **Host containment**:預設為具有開放網際網路的普通開發人員機器或 CI 執行器。如果 Claude Code 在具有出口允許清單或不得接觸的鄰近項目的容器、VM 或 pod 中執行,請命名允許的主機、雲端中繼資料端點是否應可到達,以及任務使用的雲端專案、叢集或登錄以及使用的身分。在此項目命名該身分之前,分類器[阻止](https://code.claude.com/docs/zh-TW/permission-modes.md#what-the-classifier-blocks-by-default)主機自身認證的請求。需要 Claude Code v2.1.257 或更新版本98 * **Host containment**:預設為具有開放網際網路的普通開發人員機器或 CI 執行器。如果 Claude Code 在具有出口允許清單或不得接觸的鄰近項目的容器、VM 或 pod 中執行,請命名允許的主機、雲端中繼資料端點是否應可到達,以及任務使用的雲端專案、叢集或登錄以及使用的身分。在此項目命名該身分之前,分類器會[阻止](https://code.claude.com/docs/zh-TW/permission-modes.md#what-the-classifier-blocks-by-default)取得主機自身憑證的請求。需要 Claude Code v2.1.257 或更新版本

99 * **受保護的部署命名空間 / 環境**:在您命名它們之前,回退到「敏感遠端目標」啟發式99 * **受保護的部署命名空間 / 環境**:在您命名它們之前,回退到「敏感遠端目標」的預設值

100 * **資料保留 / 解密**100 * **資料保留 / 解密**

101* **Trust slots**:命名分類器視為在您邊界內的內容。槽位為「受信任的儲存庫」、「原始碼控制」、「受信任的內部網域」、「受信任的雲端儲存桶」、「關鍵內部服務」和「內部套件登錄」。儲存庫和原始碼控制項目預設為工作儲存庫及其配置的遠端。其他所有信任槽位預設為 `None configured`,因此在您新增之前,沒有其他內容是受信任的。儲存庫的可見性僅限於機密資料:私有儲存庫是機密資料的可接受目的地,但將儲存庫設為私有永遠不會清除祕密或個人或受信任的資料進入其中,分類器將從工作儲存庫外部移植、重新指向或首次讀取的內容視為不是該儲存庫自己的工作。101* **Trust slots**:命名分類器視為在您邊界內的內容。槽位為「受信任的儲存庫」、「原始碼控制」、「受信任的內部網域」、「受信任的雲端儲存桶」、「關鍵內部服務」和「內部套件登錄」。儲存庫和原始碼控制項目預設為工作儲存庫及其配置的遠端。其他所有信任槽位預設為 `None configured`,因此在您新增之前,沒有其他內容是受信任的。儲存庫的可見性僅限於機密資料:私有儲存庫是機密資料的可接受目的地,但將儲存庫設為私有永遠不會清除祕密或個人或受信任的資料進入其中,分類器將從工作儲存庫外部移植、重新指向或首次讀取的內容視為不是該儲存庫自己的工作。

102* **Sensitivity slots**:命名保護規則視為高風險的內容。槽位為「敏感資料位置和受眾」、「敏感遠端目標」和「受保護的 IaC 範圍」。每個預設為廣泛的啟發式,例如將任何名稱包含 `prod` 或 `production` 的主機或命名空間視為敏感遠端目標,因此保護規則在您配置任何內容之前就處於活動狀態。在敏感槽位中命名具體目標會使這些規則應用於命名的目標,而不是啟發式。102* **Sensitivity slots**:命名保護規則視為高風險的內容。槽位為「敏感資料位置和受眾」、「敏感遠端目標」和「受保護的 IaC 範圍」。預設情況下,當 `prod` 或 `production` 在主機或命名空間的名稱中是一個完整的單字時,該主機或命名空間會被視為敏感遠端目標。例如,`prod-db` 符合,而 `webprod01` 不符合。

103 103 

104若要在預設值旁邊新增您自己的項目,請在陣列中包含字面字串 `"$defaults"`。預設項目會在該位置拼接,因此您的自訂項目可以在它們之前或之後。104若要在預設值旁邊新增您自己的項目,請在陣列中包含字面字串 `"$defaults"`。預設項目會在該位置拼接,因此您的自訂項目可以在它們之前或之後。

105 105 


130* **Key internal services**:CI、構件登錄、內部套件索引、事件工具130* **Key internal services**:CI、構件登錄、內部套件索引、事件工具

131* **Internal package registry**:私有 npm、PyPI 或其他登錄,安裝應該透過它進行,因此繞過它安裝公開登錄的安裝會被阻止131* **Internal package registry**:私有 npm、PyPI 或其他登錄,安裝應該透過它進行,因此繞過它安裝公開登錄的安裝會被阻止

132* **Sensitive data locations & audiences**:保存個人資料、機密業務資料、認證、受管制資料或類似敏感資料的儲存桶、資料庫或路徑,以及每個位置中的資料可能與之共享的受眾,以便分類器保護這些位置而不是從內容猜測。132* **Sensitive data locations & audiences**:保存個人資料、機密業務資料、認證、受管制資料或類似敏感資料的儲存桶、資料庫或路徑,以及每個位置中的資料可能與之共享的受眾,以便分類器保護這些位置而不是從內容猜測。

133* **Sensitive remote targets**:計為生產環境的命名空間、主機或容器,因此遠端 shell 和埠轉發進入它們需要您的明確批准133* **Sensitive remote targets**:計為生產環境的命名空間、主機或容器

134* **Protected IaC scopes**:應用或銷毀應始終需要您命名變更的基礎設施資源134* **Protected IaC scopes**:應用或銷毀應始終需要您命名變更的基礎設施資源

135* **Additional context**:受管制行業限制、多租戶基礎設施或影響分類器應視為風險的合規要求135* **Additional context**:受管制行業限制、多租戶基礎設施或影響分類器應視為風險的合規要求

136 136 


279 279 

280## 從 `/permissions` 編輯規則280## 從 `/permissions` 編輯規則

281 281 

282若要檢視和編輯分類器規則和 `environment` 項目而不開啟設定檔,請執行 [`/permissions`](https://code.claude.com/docs/zh-TW/permissions#manage-permissions) 並選取 **Auto mode** 索引標籤。該索引標籤需要 Claude Code v2.1.246 或更新版本,且僅在 [auto mode 可供您的工作階段使用](https://code.claude.com/docs/zh-TW/permission-modes.md#eliminate-prompts-with-auto-mode) 時才會出現。282若要檢視和編輯分類器規則和 `environment` 項目而不開啟設定檔,請在 CLI 中執行 [`/permissions`](https://code.claude.com/docs/zh-TW/permissions#manage-permissions) 並選取 **Auto mode** 索引標籤。該索引標籤需要 Claude Code v2.1.246 或更新版本,且僅在 [自動模式可供您的工作階段使用](https://code.claude.com/docs/zh-TW/permission-modes.md#eliminate-prompts-with-auto-mode) 時才會出現。

283 283 

284Claude Code 會將來自 [managed settings](https://code.claude.com/docs/zh-TW/server-managed-settings.md) 或 `--settings` 旗標的項目顯示為唯讀,並將您在該索引標籤上所做的每項變更儲存到 `~/.claude/settings.json`。284Claude Code 會將來自 [managed settings](https://code.claude.com/docs/zh-TW/server-managed-settings.md) 或 `--settings` 旗標的項目顯示為唯讀,並將您在該索引標籤上所做的每項變更儲存到 `~/.claude/settings.json`。

285 285 

286## 透過分類器路由所有 shell 命令286> [!NOTE]

287>

288> 在桌面應用程式中,`/permissions` 沒有 **Auto mode** 索引標籤。在本機、WSL 或 SSH 工作階段中,請在執行該工作階段的機器或 WSL 發行版上,編輯 `~/.claude/settings.json` 中的 [`autoMode` 區塊](#where-the-classifier-reads-configuration)。

289 

290## 暫停 shell 允許規則

287 291 

288根據預設,narrow Bash 和 PowerShell 允許規則(例如 `Bash(npm test)`)在自動模式中保持有效。Claude Code 會在分類器執行前解析它們,除非命令帶有[每個命令允許的網域](https://code.claude.com/docs/zh-TW/sandboxing.md#per-command-allowed-domains-in-auto-mode)。Claude Code 只會暫停授予任意程式碼執行權限的廣泛規則,例如 `Bash(*)` 或萬用字元解釋器,以及每個命名 [`Monitor`](https://code.claude.com/docs/zh-TW/tools-reference#monitor-tool) 的規則,因為 Monitor 命令會透過 shell 執行。這表示 narrow 規則仍然可能讓破壞性引數通過而不被分類器看到,例如規則前綴未預期的指令碼路徑或旗標。292根據預設,narrow Bash 和 PowerShell 允許規則(例如 `Bash(npm test)`)在自動模式中保持有效。Claude Code 會在分類器執行前解析它們,除非命令帶有[每個命令允許的網域](https://code.claude.com/docs/zh-TW/sandboxing.md#per-command-allowed-domains-in-auto-mode)。Claude Code 只會暫停授予任意程式碼執行權限的廣泛規則,例如 `Bash(*)` 或萬用字元解釋器,以及每個命名 [`Monitor`](https://code.claude.com/docs/zh-TW/tools-reference#monitor-tool) 的規則,因為 Monitor 命令會透過 shell 執行。這表示 narrow 規則仍然可能讓破壞性引數通過而不被分類器看到,例如規則前綴未預期的指令碼路徑或旗標。

289 293 

290將 `autoMode.classifyAllShell` 設定為 `true`,以在自動模式啟用時暫停每個 Bash 和 PowerShell 允許規則,讓分類器評估每個 shell 命令,無論您的允許清單為何,除了[關鍵路徑移除](https://code.claude.com/docs/zh-TW/permission-modes.md#critical-paths)。在 [Code Mode](https://code.claude.com/docs/zh-TW/code-mode.md#permission-checks) 工作階段中,即使啟用此設定,分類器仍會審查執行這些命令的程式碼。294將 `autoMode.classifyAllShell` 設定為 `true`,以在自動模式啟用時,以及在[分類器審查命令時的 plan mode](https://code.claude.com/docs/zh-TW/permission-modes.md#analyze-before-you-edit-with-plan-mode) 中,暫停您的 Bash 和 PowerShell 允許規則。在 [Code Mode](https://code.claude.com/docs/zh-TW/code-mode.md#permission-checks) 工作階段中,即使啟用此設定,分類器仍會審查執行這些命令的程式碼。

291 295 

292```json theme={null}296```json theme={null}

293{297{


297}301}

298```302```

299 303 

300這會用延遲換取涵蓋範圍:允許規則會立即核准的命令現在會等待分類器決定,每個 shell 命令都計為一次分類器呼叫。304在自動模式和 plan mode 中,原本只靠允許規則就會核准的命令會花費較長時間,因為每個命令都會等待分類器決定。

301 

302此設定僅在自動模式啟用時適用,您的允許規則在其他權限模式中的行為正常。

303 305 

304## 檢查預設值和您的有效設定306## 檢查預設值和您的有效設定

305 307 


359 361 

360## 檢視拒絕362## 檢視拒絕

361 363 

364> [!NOTE]

365>

366> 在桌面應用程式中,`/permissions` 沒有 **Recently blocked** 標籤。若要讓 Claude 重試您確實打算執行的動作,請在您的下一則訊息中[指明該動作及其具體細節](https://code.claude.com/docs/zh-TW/permission-modes.md#approvals-you-state-in-conversation)。

367 

362若要讓 Claude 重試被封鎖的動作,請使用 `/permissions` 中的 **Recently blocked** 標籤:368若要讓 Claude 重試被封鎖的動作,請使用 `/permissions` 中的 **Recently blocked** 標籤:

363 369 

364**1. 開啟標籤**370**1. 開啟標籤**

Details

10 10 

11例如:11例如:

12 12 

13* 為了讓命令能安全執行而不需要您逐一核准,新的終端機和 VS Code 工作階段會以[自動模式](https://code.claude.com/docs/zh-TW/permission-modes.md#eliminate-prompts-with-auto-mode)啟動,由分類器在任何有風險的操作執行前先進行審查。13* 為了讓命令能執行而不需要您逐一核准,新的終端機和 VS Code 工作階段會以[自動模式](https://code.claude.com/docs/zh-TW/permission-modes.md#eliminate-prompts-with-auto-mode)啟動。

14* 為了讓您的主要對話保持專注,同時讓獨立的工作平行進行,Claude 會將工作委派給 subagent,並且只在必要時才回報。14* 為了讓您的主要對話保持專注,同時讓獨立的工作平行進行,Claude 會將工作委派給 subagent,並且只在必要時才回報。

15* 為了讓長時間的工作階段能持續進行而不需要您管理,對話會在上下文視窗填滿之前自動壓縮。15* 為了讓長時間的工作階段能持續進行而不需要您管理,對話會在上下文視窗填滿之前自動壓縮。

16 16 


595 595 

596您很少需要自己清理這些:596您很少需要自己清理這些:

597 597 

598* 當您結束一個未命名的 worktree 工作階段時,如果其中沒有任何內容,Claude Code 會[移除該 worktree](https://code.claude.com/docs/zh-TW/worktrees.md#clean-up-worktrees)。對於已命名的工作階段或有變更的工作階段,它會詢問要怎麼做。598* 當您結束一個未命名的 worktree 工作階段時,如果其中沒有任何內容,Claude Code 會[移除它以 git 建立的 worktree](https://code.claude.com/docs/zh-TW/worktrees.md#clean-up-worktrees)。對於已命名的工作階段或有變更的工作階段,它會詢問要怎麼做。

599* Subagent 的 worktree 會在 subagent 完成且沒有變更時消失。599* Subagent 的 worktree 會在 subagent 完成且沒有變更時消失。

600* 確實被遺留下來的 subagent 和背景工作階段 worktree,會在存在時間超過 `cleanupPeriodDays` 且不含任何工作時被清除。600* 確實被遺留下來的 subagent 和背景工作階段 worktree,會在存在時間超過 `cleanupPeriodDays` 且不含任何工作時被清除。

601 601 

Details

6 6 

7> 追蹤、回溯和總結 Claude 的編輯和對話以管理會話狀態。7> 追蹤、回溯和總結 Claude 的編輯和對話以管理會話狀態。

8 8 

9Claude Code 會自動追蹤 Claude 在您工作時所做的檔案編輯,讓您可以快速撤銷變更並回溯到先前的狀態,以防任何事情出現偏差。9Claude Code 會自動追蹤 Claude 在您工作時所做的檔案編輯。若要撤銷編輯,請在工作階段中執行 `/rewind` 或其別名 `/undo`,以開啟[回溯選單](#rewind-and-summarize)。

10 10 

11## 檢查點的運作方式11## 檢查點的運作方式

12 12 

chrome.md +6 −2

Details

41* [Claude Code](https://code.claude.com/docs/zh-TW/quickstart.md#step-1-install-claude-code)41* [Claude Code](https://code.claude.com/docs/zh-TW/quickstart.md#step-1-install-claude-code)

42* 直接 Anthropic 計畫(Pro、Max、Ultra、Team 或 Enterprise)42* 直接 Anthropic 計畫(Pro、Max、Ultra、Team 或 Enterprise)

43 43 

44在已啟用 HIPAA 的 Enterprise 組織中,Claude in Chrome 預設為關閉,[Owner](https://code.claude.com/docs/zh-TW/server-managed-settings.md#access-control) 可以在 [**Organization settings > Claude in Chrome**](https://claude.ai/admin-settings/browser-extension) 中將其開啟。您與 Anthropic 簽訂的商業夥伴協議(BAA)不涵蓋透過 Claude in Chrome 傳送至第三方網站的資料。如需 Eligible Services 清單,請參閱 [Implementation Guide](https://trust.anthropic.com/resources?s=l1wrssd9hsbi4gak0tp5a6\&name=%5Banthropic%5D-hipaa-ready-offering-implementation-guide)。

45 

46Chrome 整合還需要使用 `/login` 登入。如果您使用 API 金鑰或來自 [`claude setup-token`](https://code.claude.com/docs/zh-TW/authentication#generate-a-long-lived-token) 的長期 token 進行身分驗證,即使您傳入 `--chrome`,Claude Code 也會保持 Chrome 整合關閉。瀏覽器擴充功能無法使用這些憑證進行身分驗證。44Chrome 整合還需要使用 `/login` 登入。如果您使用 API 金鑰或來自 [`claude setup-token`](https://code.claude.com/docs/zh-TW/authentication#generate-a-long-lived-token) 的長期 token 進行身分驗證,即使您傳入 `--chrome`,Claude Code 也會保持 Chrome 整合關閉。瀏覽器擴充功能無法使用這些憑證進行身分驗證。

47 45 

48> [!NOTE]46> [!NOTE]

49>47>

50> Chrome 整合不適用於 Amazon Bedrock、Google Cloud 的 Agent Platform 或 Microsoft Foundry 等第三方提供商。如果您只透過第三方提供商存取 Claude,則需要單獨的 claude.ai 帳戶才能使用此功能。48> Chrome 整合不適用於 Amazon Bedrock、Google Cloud 的 Agent Platform 或 Microsoft Foundry 等第三方提供商。如果您只透過第三方提供商存取 Claude,則需要單獨的 claude.ai 帳戶才能使用此功能。

51 49 

50### 啟用 HIPAA 或零資料保留時的 Chrome 可用性

51 

52在已啟用 HIPAA 的 Enterprise 組織中,Claude in Chrome 預設為關閉,[Owner](https://code.claude.com/docs/zh-TW/server-managed-settings.md#access-control) 可以在 [**Organization settings > Claude in Chrome**](https://claude.ai/admin-settings/browser-extension) 中將其開啟。您與 Anthropic 簽訂的商業夥伴協議(BAA)不涵蓋透過 Claude in Chrome 傳送至第三方網站的資料。如需 Eligible Services 清單,請參閱 [Implementation Guide](https://trust.anthropic.com/resources?s=l1wrssd9hsbi4gak0tp5a6\&name=%5Banthropic%5D-hipaa-ready-offering-implementation-guide)。

53 

54如果您的組織已為 Claude Code 啟用[零資料保留(ZDR)](https://code.claude.com/docs/zh-TW/zero-data-retention.md),則 Claude in Chrome 無法在 Claude Code 中使用。即使 Owner 已在 **Organization settings > Claude in Chrome** 中將其開啟,或您傳入 `--chrome`,它仍會保持關閉。`/chrome` 會回報 `Claude in Chrome is disabled by your organization's policy`。在組織允許的情況下,您仍可在 Claude Code 之外使用此擴充功能。

55 

52## 在 CLI 中開始使用56## 在 CLI 中開始使用

53 57 

54**1. 使用 Chrome 啟動 Claude Code**58**1. 使用 Chrome 啟動 Claude Code**

Details

1347 1347 

1348##### 在 Code 分頁中套用 `code` 設定1348##### 在 Code 分頁中套用 `code` 設定

1349 1349 

1350當下列條件全部成立時,原則在其 [`code`](#choose-cli-or-code) 鍵下保存的 Claude Code 設定會在 Claude Desktop 的 Code 分頁中套用:1350除了[某些供應商與模型變數](https://code.claude.com/docs/zh-TW/desktop.md#managed-settings)之外,當下列所有條件都成立時,原則在其 [`code`](#choose-cli-or-code) 鍵下所保存的 Claude Code 設定會在 Claude Desktop 的 Code 分頁中套用:

1351 1351 

1352* 原則也具有 `desktop` 鍵,空的 `desktop: {}` 也算1352* 原則也具有 `desktop` 鍵,空的 `desktop: {}` 也算

1353* Claude Desktop 為 2.9939.2 或更新版本1353* Claude Desktop 為 2.9939.2 或更新版本

Details

137| `usage-data/` | 由 [`/insights`](https://code.claude.com/docs/zh-TW/costs#analyze-your-usage-patterns) 寫入的 `report.html` 和時間戳記報告副本,加上用於建立它們的快取每個工作階段分析資料 |137| `usage-data/` | 由 [`/insights`](https://code.claude.com/docs/zh-TW/costs#analyze-your-usage-patterns) 寫入的 `report.html` 和時間戳記報告副本,加上用於建立它們的快取每個工作階段分析資料 |

138| `skills/.trash/`、`plugins/.trash/` | claude.ai 同步移除的 [技能](https://code.claude.com/docs/zh-TW/skills.md#how-synced-skills-behave) 和 [外掛程式](https://code.claude.com/docs/zh-TW/plugins/loading.md#synced-plugins),例如在你在 claude.ai 上關閉一個或停止同步後。檔案保留在此處,以便你可以恢復它們,直到掃描刪除它們 |138| `skills/.trash/`、`plugins/.trash/` | claude.ai 同步移除的 [技能](https://code.claude.com/docs/zh-TW/skills.md#how-synced-skills-behave) 和 [外掛程式](https://code.claude.com/docs/zh-TW/plugins/loading.md#synced-plugins),例如在你在 claude.ai 上關閉一個或停止同步後。檔案保留在此處,以便你可以恢復它們,直到掃描刪除它們 |

139| `plugins/installed_plugins.set-aside.<date>.<hash>.json`、`plugins/installed_plugins.unreadable.<date>.<hash>.kept` | Claude Code 在重寫 [`installed_plugins.json`](https://code.claude.com/docs/zh-TW/plugins/loading#find-plugins-on-disk) 之前製作的日期副本:安裝記錄它刪除,以及它無法讀取的檔案的內容。 |139| `plugins/installed_plugins.set-aside.<date>.<hash>.json`、`plugins/installed_plugins.unreadable.<date>.<hash>.kept` | Claude Code 在重寫 [`installed_plugins.json`](https://code.claude.com/docs/zh-TW/plugins/loading#find-plugins-on-disk) 之前製作的日期副本:安裝記錄它刪除,以及它無法讀取的檔案的內容。 |

140| `plugins/mcpb/` | Claude Code 從外掛宣告的 [MCP bundle](https://code.claude.com/docs/zh-TW/plugins/components.md#include-a-packaged-mcpb-server) 中解壓縮出的檔案。bundle 的年齡從最後一次使用它的工作階段起算。 |

140| `todos/`、`statsig/`、`logs/` | 來自舊版本的舊版目錄。不再寫入。掃描會移除其內容,然後移除空目錄。 |141| `todos/`、`statsig/`、`logs/` | 來自舊版本的舊版目錄。不再寫入。掃描會移除其內容,然後移除空目錄。 |

141 142 

142`sessions/` 中的工作階段檔案、自動記憶和 Claude Desktop 及 Cowork 文字記錄各自遵循自己的保留規則:143`sessions/` 中的工作階段檔案、自動記憶和 Claude Desktop 及 Cowork 文字記錄各自遵循自己的保留規則:

Details

1> ## Documentation Index

2> Fetch the complete documentation index at: https://code.claude.com/docs/llms.txt

3> Use this file to discover all available pages before exploring further.

4 

5# 搭配 Google Cloud 上的 Claude 模型(由 Anthropic 管理)使用 Claude Code

6 

7> 設定 Claude Code 以使用 Anthropic 透過您的 Google Cloud 專案執行的 Claude API,並搭配 Google Cloud 憑證、IAM 與 Marketplace 計費。

8 

9Google Cloud 上的 Claude 模型(由 Anthropic 管理)是由 Anthropic 執行、透過您的 Google Cloud 專案存取的 Claude API。若要從 Claude Code 使用它,請登入 Google Cloud 並設定三個環境變數。

10 

11> [!NOTE]

12>

13> Google Cloud 也透過 Google Cloud 的 Agent Platform(前身為 Vertex AI)提供 Claude,該服務由 Google 管理。如果您使用 Agent Platform,請改為依照 [Google Cloud 的 Agent Platform 上的 Claude Code](https://code.claude.com/docs/zh-TW/google-vertex-ai.md) 進行。若要確認您使用的是哪一種,請參閱[您使用的是哪一種服務?](https://platform.claude.com/docs/en/build-with-claude/claude-models-on-google-cloud/overview#which-offering-are-you-using)

14 

15開始之前,請[安裝 Claude Code](https://code.claude.com/docs/zh-TW/setup.md#install-claude-code) v2.1.307 或更新版本。若要檢查版本,請在 shell 中執行 `claude --version`。若要更新,請執行 `claude update`。

16 

17## 先決條件

18 

19* 一個已完成[帳戶設定](https://platform.claude.com/docs/en/build-with-claude/claude-models-on-google-cloud/anthropic-managed#set-up-your-account)的 Google Cloud 專案

20* 每個執行 Claude Code 的 Google 帳戶或服務帳戶,都需在該專案上具備 `roles/claude.user` [IAM 角色](https://platform.claude.com/docs/en/build-with-claude/claude-models-on-google-cloud/anthropic-managed#iam-roles)

21* 您的專案 ID 以及以 `wrkspc_` 開頭的[工作區 ID](https://platform.claude.com/docs/en/build-with-claude/claude-models-on-google-cloud/anthropic-managed#find-your-workspace-id)

22* [gcloud CLI](https://cloud.google.com/sdk/docs/install),如果您是以 Google 帳戶登入,而非使用服務帳戶金鑰檔案

23 

24## 設定 Claude Code

25 

26**1. 建立應用程式預設憑證**

27 

28> [tab] Google 帳戶

29>

30> 在 shell 中執行此命令,並以具備 `roles/claude.user` 角色的 Google 帳戶登入:

31>

32> ```bash theme={null}

33> gcloud auth application-default login

34> ```

35>

36> 即使您已經執行過 `gcloud auth login`,仍請執行此命令。

37>

38> 如果已設定 `GOOGLE_APPLICATION_CREDENTIALS`,請取消設定。只要設定了該變數,Claude Code 就會使用其指定的檔案,並忽略此命令儲存的憑證。

39 

40> [tab] 服務帳戶金鑰檔案

41>

42> 在執行 Claude Code 的 shell 或 CI 工作中,將 `GOOGLE_APPLICATION_CREDENTIALS` 設定為[服務帳戶金鑰檔案](https://docs.cloud.google.com/iam/docs/keys-create-delete)的路徑。如需其他憑證來源,請參閱[如何進行身分驗證](https://platform.claude.com/docs/en/build-with-claude/claude-models-on-google-cloud/anthropic-managed#authentication)。

43 

44**2. 將變數加入您的設定**

45 

46將三個變數加入您的[使用者設定檔](https://code.claude.com/docs/zh-TW/settings.md) `~/.claude/settings.json` 的 `env` 區塊。如果該檔案不存在,請以下列內容建立:

47 

48```json theme={null}

49{

50 "env": {

51 "CLAUDE_CODE_USE_ANTHROPIC_GOOGLE_CLOUD": "1",

52 "ANTHROPIC_GOOGLE_CLOUD_PROJECT": "my-project-id",

53 "ANTHROPIC_GOOGLE_CLOUD_WORKSPACE_ID": "wrkspc_01ABCDEFGHIJKLMN"

54 }

55}

56```

57 

58請以您自己的專案 ID 與[工作區 ID](https://platform.claude.com/docs/en/build-with-claude/claude-models-on-google-cloud/anthropic-managed#find-your-workspace-id) 取代 `my-project-id` 與 `wrkspc_` 值。若要改為設定單一 shell 或 CI 工作,請在該環境中設定相同的三個變數。

59 

60您不需要登入 Anthropic 帳戶,也不需要從中登出。

61 

62**3. 啟動 Claude Code 並檢查供應商**

63 

64在 shell 中執行 `claude`,然後在 Claude Code 提示字元執行 `/status`。`API provider` 行會包含 `on Google Cloud`,其後的各行會顯示您的 `Workspace ID`、`GCP project` 與 `GCP location`。若要從 shell 或 CI 工作輸出相同的內容,請執行 [`claude auth status --text`](https://code.claude.com/docs/zh-TW/cli-reference)。

65 

66如果您看到 `on Google Cloud`,請傳送一個提示詞,或在 CI 工作中執行 `claude -p "hello"`。收到回覆即表示您的憑證與 IAM 角色運作正常。如果您沒有看到它,或 Claude Code 顯示錯誤,請[對供應商設定進行疑難排解](#troubleshooting)。

67 

68### 為團隊設定 Claude Code

69 

70將[設定 Claude Code](#set-up-claude-code) 步驟 2 中的 `env` 區塊放入每位開發人員電腦上的[受管設定](https://code.claude.com/docs/zh-TW/managed-settings.md)檔案中。在專案上授予每位開發人員 `roles/claude.user` 角色,並請每位開發人員在自己的電腦上執行 `gcloud auth application-default login`。

71 

72## 固定模型版本

73 

74如果您部署給團隊使用,請[固定模型 ID](https://code.claude.com/docs/zh-TW/model-config.md#pin-models-for-third-party-deployments),以免 Claude Code 更新時讓所有人同時改用較新的模型。請將這些變數加入包含[設定 Claude Code](#set-up-claude-code) 中三個變數的 `env` 區塊:

75 

76```json theme={null}

77{

78 "env": {

79 "ANTHROPIC_DEFAULT_OPUS_MODEL": "claude-opus-5-5",

80 "ANTHROPIC_DEFAULT_SONNET_MODEL": "claude-sonnet-5-5",

81 "ANTHROPIC_DEFAULT_FABLE_MODEL": "claude-fable-5-1",

82 "ANTHROPIC_DEFAULT_HAIKU_MODEL": "claude-haiku-4-5-20251001"

83 }

84}

85```

86 

87請以您想從[模型概覽](https://platform.claude.com/docs/en/about-claude/models/overview)中使用的 Claude API 模型 ID 取代範例值。

88 

89## 環境變數

90 

91| 變數 | 必要 | 說明 |

92| - | - | - |

93| `CLAUDE_CODE_USE_ANTHROPIC_GOOGLE_CLOUD` | 是 | 設為 `1` 以將模型請求傳送至 Google Cloud 上的 Claude 模型(由 Anthropic 管理) |

94| `ANTHROPIC_GOOGLE_CLOUD_WORKSPACE_ID` | 是,除非您設定了 `ANTHROPIC_GOOGLE_CLOUD_BASE_URL` | 您的工作區 ID |

95| `ANTHROPIC_GOOGLE_CLOUD_PROJECT` | 建議 | 您的 Google Cloud 專案 ID。若未設定,Claude Code 會使用 `GOOGLE_CLOUD_PROJECT` |

96| `ANTHROPIC_GOOGLE_CLOUD_LOCATION` | 否 | 請求 URL 中的[位置](https://platform.claude.com/docs/en/build-with-claude/claude-models-on-google-cloud/anthropic-managed#project-location-and-workspace-resolution)。預設為 `global` |

97| `ANTHROPIC_GOOGLE_CLOUD_BASE_URL` | 否 | 取代 Claude Code 根據專案、位置與工作區 ID 建立的基礎 URL,例如改為 [LLM 閘道](https://code.claude.com/docs/zh-TW/llm-gateway)的位址。Claude Code 會附加 API 路徑,例如 `/v1/messages` |

98| `CLAUDE_CODE_SKIP_ANTHROPIC_GOOGLE_CLOUD_AUTH` | 否 | 當閘道自行附加 Google 憑證時設為 `1`,讓 Claude Code 不傳送 Google 存取 token |

99 

100## 無法使用的 Claude Code 功能

101 

102使用 Claude Models on Google Cloud (Anthropic managed) 時,無法使用的功能包括:

103 

104* [快速模式](https://code.claude.com/docs/zh-TW/fast-mode.md):您無法透過 `/fast` 或 `fastMode` 設定將其開啟

105* [Remote Control](https://code.claude.com/docs/zh-TW/remote-control.md) 與[雲端工作階段](https://code.claude.com/docs/zh-TW/claude-code-on-the-web.md)

106* [來自 claude.ai 的 MCP 連接器](https://code.claude.com/docs/zh-TW/mcp.md#use-mcp-servers-from-claude-ai)

107* [頻道](https://code.claude.com/docs/zh-TW/channels.md)

108* [`/design-sync` 與 `/import` 命令](https://code.claude.com/docs/zh-TW/commands#all-commands)

109* [伺服器管理設定](https://code.claude.com/docs/zh-TW/server-managed-settings.md)。若要為您的團隊強制套用設定,請改為在每台電腦上使用[受管設定](https://code.claude.com/docs/zh-TW/managed-settings.md)

110 

111若要查看其他無法使用或僅部分支援的功能,請在[功能可用性摘要](https://code.claude.com/docs/zh-TW/feature-availability.md#summary-by-provider)中選取 **Google Cloud (Anthropic managed)** 分頁。

112 

113## 疑難排解

114 

115如果 Claude Code 要求您登入,或 `/status` 中的 `API provider` 行不包含 `on Google Cloud`:

116 

117* 確認 `CLAUDE_CODE_USE_ANTHROPIC_GOOGLE_CLOUD` 為 `1`

118* 確認 `claude --version` 輸出 2.1.307 或更新版本

119* 從您的 shell 與[設定檔](https://code.claude.com/docs/zh-TW/settings.md#find-or-create-your-settings-files)中移除 `CLAUDE_CODE_USE_BEDROCK`、`CLAUDE_CODE_USE_FOUNDRY` 與 `CLAUDE_CODE_USE_ANTHROPIC_AWS`

120 

121`CLAUDE_CODE_USE_VERTEX` 可以保持設定。變更變數後,請重新啟動 Claude Code。如果 `/status` 未顯示變更,請參閱[您設定的值被忽略](https://code.claude.com/docs/zh-TW/settings.md#a-value-you-set-is-ignored)。

122 

123### `No workspace ID found`

124 

125將 `ANTHROPIC_GOOGLE_CLOUD_WORKSPACE_ID` 設定為您的[工作區 ID](https://platform.claude.com/docs/en/build-with-claude/claude-models-on-google-cloud/anthropic-managed#find-your-workspace-id),然後重新啟動 Claude Code。請忽略訊息中提到的 `workspaceId` 建構函式選項:該選項適用於從自己的程式碼呼叫 Anthropic SDK 的人。

126 

127### `No project was given`

128 

129將 `ANTHROPIC_GOOGLE_CLOUD_PROJECT` 設定為您的 Google Cloud 專案 ID,然後重新啟動 Claude Code。

130 

131### `Could not load Google Cloud credentials`

132 

133重複[設定 Claude Code](#set-up-claude-code) 的步驟 1;如果您使用服務帳戶金鑰檔案,請使用新的金鑰。

134 

135### `Google Cloud credentials expired or invalid`

136 

137如果訊息要求您重新整理 Google Cloud 憑證,請重複[設定 Claude Code](#set-up-claude-code) 的步驟 1。若使用服務帳戶金鑰檔案,請使用新的金鑰。

138 

139### `Google Cloud authentication failed`

140 

141請依照 [`Google Cloud credentials expired or invalid`](#google-cloud-credentials-expired-or-invalid) 的步驟操作。如果這樣仍無法排除錯誤:

142 

143* **專案**:在 `/status` 中,確認 `GCP project` 行顯示的是您的專案。如果顯示的是其他專案,或沒有這一行,請依照 [`No project was given`](#no-project-was-given) 操作

144* **工作區**:在 `/status` 中,確認 `Workspace ID` 行顯示的是您的工作區 ID。如果顯示的是其他 ID,請依照 [`No workspace ID found`](#no-workspace-id-found) 操作

145* **IAM 角色**:確認執行 Claude Code 的 Google 帳戶或服務帳戶,在 `GCP project` 行所示的專案上具備 `roles/claude.user` 或 `roles/claude.admin`。若要授予該角色,請使用[該服務的授予命令](https://platform.claude.com/docs/en/build-with-claude/claude-models-on-google-cloud/anthropic-managed#before-making-api-calls),或請專案管理員授予

146* **服務**:確認 `GCP project` 行所示的專案已啟用 `claude.googleapis.com` 服務。若要啟用,請依照[該服務的帳戶設定步驟](https://platform.claude.com/docs/en/build-with-claude/claude-models-on-google-cloud/anthropic-managed#set-up-your-account)操作,或請專案管理員啟用

147 

148## 相關資源

149 

150* [Google Cloud 上的 Claude 模型(由 Anthropic 管理)](https://platform.claude.com/docs/en/build-with-claude/claude-models-on-google-cloud/anthropic-managed):帳戶設定、IAM 角色、計費、資料保留與功能支援

151* [企業部署概覽](https://code.claude.com/docs/zh-TW/third-party-integrations.md):部署 Claude Code 的其他方式,以及代理伺服器與閘道設定

152* [模型設定](https://code.claude.com/docs/zh-TW/model-config.md):模型別名、固定模型版本,以及限制使用者可選擇的模型

Details

163Claude 決定您在對話中發送的每條訊息去向:163Claude 決定您在對話中發送的每條訊息去向:

164 164 

165* 快速問題通常在對話中得到回答。165* 快速問題通常在對話中得到回答。

166* 新工作進入新執行緒或已在該區域工作的執行緒,Claude 告訴您哪個。每個新執行緒在您的訊息下顯示為卡片:一個帶有執行緒標題和狀態的框,您點擊打開執行緒。166* 新工作進入新執行緒或已在該區域工作的執行緒,Claude 告訴您哪個。每個新執行緒都會出現在對話中,點擊它即可開啟該執行緒。

167* 一條訊息中的多個不相關任務成為單獨的執行緒。167* 一條訊息中的多個不相關任務成為單獨的執行緒。

168 168 

169如果 Claude 路由的內容與您想要的不同,請說出來。[調整 Claude 執行 project 的方式](#tune-how-claude-runs-a-project) 列出了您可以告訴它的內容,例如為後續工作重用現有執行緒或就地回答而不是啟動執行緒。169如果 Claude 路由的內容與您想要的不同,請說出來。[調整 Claude 執行 project 的方式](#tune-how-claude-runs-a-project) 列出了您可以告訴它的內容,例如為後續工作重用現有執行緒或就地回答而不是啟動執行緒。

170 170 

171執行緒的完整結果保留在執行緒中,您可以開啟對話中的卡片來讀取。執行緒產生的檔案也會出現在 project 的 [**Library**](#see-what-needs-you-in-overview) 中。171執行緒的完整結果保留在執行緒中,因此請開啟該執行緒來讀取。執行緒產生的檔案也會出現在 project 的 [**Library**](#see-what-needs-you-in-overview) 中。

172 172 

173有時 Claude 在 **Suggested threads** 清單中提議執行緒而不是啟動它們。點擊建議上的箭頭啟動該執行緒。當列出多個時,清單下的按鈕啟動所有這些。173有時 Claude 在 **Suggested threads** 清單中提議執行緒而不是啟動它們。點擊建議上的箭頭啟動該執行緒。當列出多個時,清單下的按鈕啟動所有這些。

174 174 


180* **Pull request**:當您要求時打開一個,並可以為錯誤修復或另一個具體變更自己打開一個。180* **Pull request**:當您要求時打開一個,並可以為錯誤修復或另一個具體變更自己打開一個。

181* **打開後**:使用 [auto-fix](https://code.claude.com/docs/zh-TW/claude-code-on-the-web.md#auto-fix-pull-requests) 打開監視提取請求,無論 auto-fix 是否對您的其他雲端工作階段打開。它在 CI 失敗時推送修復,解決審查評論,並在檢查通過且提取請求準備好供您審查時在執行緒中回覆。181* **打開後**:使用 [auto-fix](https://code.claude.com/docs/zh-TW/claude-code-on-the-web.md#auto-fix-pull-requests) 打開監視提取請求,無論 auto-fix 是否對您的其他雲端工作階段打開。它在 CI 失敗時推送修復,解決審查評論,並在檢查通過且提取請求準備好供您審查時在執行緒中回覆。

182 182 

183當執行緒推送了分支或打開了提取請求時,其在對話中的卡片可以顯示下一步的按鈕:

184 

185* **Resolve conflicts**、**Fix CI**、**Address comments** 和 **Merge it** 將該指示作為來自您的訊息發送到執行緒,因此您可以自己提示執行緒而不是等待它對提取請求做出反應。

186* **Review PR** 在 GitHub 上打開提取請求。

187* **Create PR** 出現在閒置執行緒已推送分支但尚未打開提取請求時。點擊它會直接從該分支建立提取請求,而不是向執行緒發送打開提取請求的指示。

188 

189要更改執行緒何時打開提取請求,例如僅在您要求時,或它們從哪個分支開始,請在任務或 [project 指示](#write-project-instructions) 中說出來。183要更改執行緒何時打開提取請求,例如僅在您要求時,或它們從哪個分支開始,請在任務或 [project 指示](#write-project-instructions) 中說出來。

190 184 

191### 在 Overview 中查看需要您的內容185### 在 Overview 中查看需要您的內容


212 206 

213### 當您需要控制時打開執行緒207### 當您需要控制時打開執行緒

214 208 

215點擊對話中執行緒的卡片或 Overview 中該執行緒的列,即可在 Overview 窗格中開啟其逐字稿。您可以在那裡:209點擊對話中的執行緒或 Overview 中該執行緒的列,即可在 Overview 窗格中開啟該執行緒。您可以在那裡:

216 210 

217* 逐步讀取 Claude 所做的內容。211* 逐步讀取 Claude 所做的內容。

218* 通過在執行緒自己的訊息框中寫入來引導任務。那裡的訊息直接進入該執行緒,而 project 對話中的後續工作只有在 Claude 將後續工作與該執行緒匹配時才會到達它。212* 通過在執行緒自己的訊息框中寫入來引導任務。那裡的訊息直接進入該執行緒,而 project 對話中的後續工作只有在 Claude 將後續工作與該執行緒匹配時才會到達它。

Details

43| `claude purge [path]` | 刪除專案的所有本機 Claude Code 狀態:逐字稿、工作清單、偵錯日誌、檔案編輯歷史記錄、提示詞歷史記錄行和專案在 `~/.claude.json` 中的項目。省略 `[path]` 以從互動式清單中選擇。旗標:`--dry-run` 以預覽,`-y`/`--yes` 以跳過確認,`-i`/`--interactive` 以確認每個項目,`--all` 用於每個專案。請參閱 [清除本機資料](https://code.claude.com/docs/zh-TW/claude-directory.md#clear-local-data) | `claude purge ~/work/repo --dry-run` |43| `claude purge [path]` | 刪除專案的所有本機 Claude Code 狀態:逐字稿、工作清單、偵錯日誌、檔案編輯歷史記錄、提示詞歷史記錄行和專案在 `~/.claude.json` 中的項目。省略 `[path]` 以從互動式清單中選擇。旗標:`--dry-run` 以預覽,`-y`/`--yes` 以跳過確認,`-i`/`--interactive` 以確認每個項目,`--all` 用於每個專案。請參閱 [清除本機資料](https://code.claude.com/docs/zh-TW/claude-directory.md#clear-local-data) | `claude purge ~/work/repo --dry-run` |

44| `claude remote-control` | 啟動 [Remote Control](https://code.claude.com/docs/zh-TW/remote-control.md) 伺服器以從 Claude.ai 或 Claude 應用程式控制 Claude Code。別名:`claude rc`。以伺服器模式執行(無本機互動式工作階段)。請參閱 [伺服器模式旗標](https://code.claude.com/docs/zh-TW/remote-control.md#start-a-remote-control-session)。停止伺服器後,您可以恢復它正在服務的工作階段。請參閱 [停止伺服器後繼續工作階段](https://code.claude.com/docs/zh-TW/remote-control.md#resume-sessions-after-stopping-the-server) | `claude remote-control --name "My Project"` |44| `claude remote-control` | 啟動 [Remote Control](https://code.claude.com/docs/zh-TW/remote-control.md) 伺服器以從 Claude.ai 或 Claude 應用程式控制 Claude Code。別名:`claude rc`。以伺服器模式執行(無本機互動式工作階段)。請參閱 [伺服器模式旗標](https://code.claude.com/docs/zh-TW/remote-control.md#start-a-remote-control-session)。停止伺服器後,您可以恢復它正在服務的工作階段。請參閱 [停止伺服器後繼續工作階段](https://code.claude.com/docs/zh-TW/remote-control.md#resume-sessions-after-stopping-the-server) | `claude remote-control --name "My Project"` |

45| `claude respawn <id>` | 重新啟動 [背景工作階段](https://code.claude.com/docs/zh-TW/agent-view.md#manage-sessions-from-the-shell)(執行中或已停止),保持其對話完整。使用 `--all` 重新啟動每個執行中的工作階段,例如以取得更新的 Claude Code 二進位檔 | `claude respawn 7c5dcf5d` |45| `claude respawn <id>` | 重新啟動 [背景工作階段](https://code.claude.com/docs/zh-TW/agent-view.md#manage-sessions-from-the-shell)(執行中或已停止),保持其對話完整。使用 `--all` 重新啟動每個執行中的工作階段,例如以取得更新的 Claude Code 二進位檔 | `claude respawn 7c5dcf5d` |

46| `claude rm <id>` | 從清單中移除 [背景工作階段](https://code.claude.com/docs/zh-TW/agent-view.md#manage-sessions-from-the-shell)。當移除因工作階段的 worktree [而被拒絕](https://code.claude.com/docs/zh-TW/agent-view.md#what-deleting-a-session-removes) 且第二個 `claude rm` 可以解決時,拒絕會列印要傳遞的確切旗標和值:`--discard-unpushed <commit>@<worktree-id>` 會捨棄具有未推送提交的 worktree 以及這些提交,`--force-remove-worktree <worktree-id>` 刪除 git 或 `WorktreeRemove` hook 無法移除的 worktree 目錄。`--discard-unpushed` 需要 Claude Code v2.1.260 或更新版本,而 `--force-remove-worktree` 需要 v2.1.268 或更新版本。對話逐字稿保留在您的本機機器上,可透過 `claude --resume` 取得 | `claude rm 7c5dcf5d` |46| `claude rm <id>` | 從清單中移除 [背景工作階段](https://code.claude.com/docs/zh-TW/agent-view.md#manage-sessions-from-the-shell)。如果 Claude Code 因工作階段的 worktree 而拒絕刪除該工作階段,請參閱 [在 Claude Code 拒絕後刪除工作階段](https://code.claude.com/docs/zh-TW/agent-view.md#delete-a-session-after-claude-code-refuses)。對話逐字稿保留在您的本機機器上,可透過 `claude --resume` 取得 | `claude rm 7c5dcf5d` |

47| `claude self-hosted-runner` | 啟動執行程序,將此機器或容器註冊到 [自託管環境](https://code.claude.com/docs/zh-TW/self-hosted-environments) 並在您的基礎結構上託管 Claude Code 雲端工作階段。執行 `claude self-hosted-runner setup` 以進行引導式操作員逐步解說,`claude self-hosted-runner doctor` 以 [診斷已部署的執行程序](https://code.claude.com/docs/zh-TW/self-hosted-environments-deploy.md#troubleshooting),以及 `claude self-hosted-runner orchestrator` 以生成 [隨需執行程序](https://code.claude.com/docs/zh-TW/self-hosted-environments-configuration.md#on-demand-runners)。需要 Claude Code v2.1.224 或更新版本 | `claude self-hosted-runner setup` |47| `claude self-hosted-runner` | 啟動執行程序,將此機器或容器註冊到 [自託管環境](https://code.claude.com/docs/zh-TW/self-hosted-environments) 並在您的基礎結構上託管 Claude Code 雲端工作階段。執行 `claude self-hosted-runner setup` 以進行引導式操作員逐步解說,`claude self-hosted-runner doctor` 以 [診斷已部署的執行程序](https://code.claude.com/docs/zh-TW/self-hosted-environments-deploy.md#troubleshooting),以及 `claude self-hosted-runner orchestrator` 以生成 [隨需執行程序](https://code.claude.com/docs/zh-TW/self-hosted-environments-configuration.md#on-demand-runners)。需要 Claude Code v2.1.224 或更新版本 | `claude self-hosted-runner setup` |

48| `claude setup-token` | 為 CI 和指令碼產生長期 OAuth token。將 token 列印到終端機而不儲存它。需要 Claude 訂閱。請參閱 [產生長期 token](https://code.claude.com/docs/zh-TW/authentication.md#generate-a-long-lived-token) | `claude setup-token` |48| `claude setup-token` | 為 CI 和指令碼產生長期 OAuth token。將 token 列印到終端機而不儲存它。需要 Claude 訂閱。請參閱 [產生長期 token](https://code.claude.com/docs/zh-TW/authentication.md#generate-a-long-lived-token) | `claude setup-token` |

49| `claude stop <id>` | 停止 [背景工作階段](https://code.claude.com/docs/zh-TW/agent-view.md#manage-sessions-from-the-shell)。也接受 `claude kill` | `claude stop 7c5dcf5d` |49| `claude stop <id>` | 停止 [背景工作階段](https://code.claude.com/docs/zh-TW/agent-view.md#manage-sessions-from-the-shell)。也接受 `claude kill` | `claude stop 7c5dcf5d` |


128| `--session-id` | 為對話使用特定工作階段 ID(必須是有效的 UUID) | `claude --session-id "550e8400-e29b-41d4-a716-446655440000"` |128| `--session-id` | 為對話使用特定工作階段 ID(必須是有效的 UUID) | `claude --session-id "550e8400-e29b-41d4-a716-446655440000"` |

129| `--setting-sources` | 要載入的設定來源的逗號分隔清單(`user`、`project`、`local`)。請參閱[代理程式檢視](https://code.claude.com/docs/zh-TW/agent-view.md#what-carries-over-when-you-background)和[代理程式團隊](https://code.claude.com/docs/zh-TW/agent-teams.md#context-and-communication)以了解您從此工作階段啟動的工作階段繼承清單 | `claude --setting-sources user,project` |129| `--setting-sources` | 要載入的設定來源的逗號分隔清單(`user`、`project`、`local`)。請參閱[代理程式檢視](https://code.claude.com/docs/zh-TW/agent-view.md#what-carries-over-when-you-background)和[代理程式團隊](https://code.claude.com/docs/zh-TW/agent-teams.md#context-and-communication)以了解您從此工作階段啟動的工作階段繼承清單 | `claude --setting-sources user,project` |

130| `--settings` | 設定 JSON 檔案或內嵌 JSON 字串的路徑。您在此設定的值會覆蓋此工作階段的 `settings.json` 檔案中的相同金鑰。您省略的金鑰會保留其檔案型值。檔案必須是不超過 2 MiB 的一般檔案。請參閱[設定優先順序](https://code.claude.com/docs/zh-TW/settings.md#settings-precedence) | `claude --settings ./settings.json` |130| `--settings` | 設定 JSON 檔案或內嵌 JSON 字串的路徑。您在此設定的值會覆蓋此工作階段的 `settings.json` 檔案中的相同金鑰。您省略的金鑰會保留其檔案型值。檔案必須是不超過 2 MiB 的一般檔案。請參閱[設定優先順序](https://code.claude.com/docs/zh-TW/settings.md#settings-precedence) | `claude --settings ./settings.json` |

131| `--strict-mcp-config` | 僅使用 `--mcp-config` 中的 MCP 伺服器,忽略所有其他 MCP 設定。請參閱[使用 managed-mcp.json 進行獨佔控制](https://code.claude.com/docs/zh-TW/managed-mcp.md#exclusive-control-with-managed-mcp-json)以了解旗標在受管 MCP 檔案下執行的操作 | `claude --strict-mcp-config --mcp-config ./mcp.json` |131| `--strict-mcp-config` | 跳過在 `.mcp.json`、`~/.claude.json` 或外掛等位置設定的 MCP 伺服器,並載入您透過 `--mcp-config` 傳遞的伺服器。請參閱[使用 managed-mcp.json 進行獨佔控制](https://code.claude.com/docs/zh-TW/managed-mcp.md#exclusive-control-with-managed-mcp-json)以了解此旗標在受管 MCP 檔案下的作用 | `claude --strict-mcp-config --mcp-config ./mcp.json` |

132| `--system-prompt` | 使用自訂文字取代整個系統提示 | `claude --system-prompt "You are a Python expert"` |132| `--system-prompt` | 使用自訂文字取代整個系統提示 | `claude --system-prompt "You are a Python expert"` |

133| `--system-prompt-file` | 從檔案載入系統提示,取代預設提示 | `claude --system-prompt-file ./custom-prompt.txt` |133| `--system-prompt-file` | 從檔案載入系統提示,取代預設提示 | `claude --system-prompt-file ./custom-prompt.txt` |

134| `--system-prompt-snapshot` | 傳遞 `off` 以在每個要求上重建系統提示,而不是重複使用[在對話的第一個要求上記錄](#system-prompt-flags-in-resumed-conversations)的提示,例如在您跨 `--continue` 執行反覆運算 `--append-system-prompt` 文字時。需要 Claude Code v2.1.257 或更新版本 | `claude --system-prompt-snapshot off` |134| `--system-prompt-snapshot` | 傳遞 `off` 以在每個要求上重建系統提示,而不是重複使用[在對話的第一個要求上記錄](#system-prompt-flags-in-resumed-conversations)的提示,例如在您跨 `--continue` 執行反覆運算 `--append-system-prompt` 文字時。需要 Claude Code v2.1.257 或更新版本 | `claude --system-prompt-snapshot off` |

commands.md +3 −3

Details

47 47 

48| 命令 | 用途 |48| 命令 | 用途 |

49| :- | :- |49| :- | :- |

50| `/add-dir <path>` | 添加工作目錄以在目前工作階段期間進行檔案存取。輸入部分路徑以查看匹配的目錄建議;按 `Tab` 接受一個。大多數 `.claude/` 設定[不會從添加的目錄中發現](https://code.claude.com/docs/zh-TW/permissions.md#additional-directories-grant-file-access-not-configuration)。您無法添加大多數[網路路徑](https://code.claude.com/docs/zh-TW/errors.md#working-directory-is-a-network-path),例如 `\\server\share`。成功添加後,您的 [`DirectoryAdded` hook](https://code.claude.com/docs/zh-TW/hooks#directoryadded) 會運行。當您在 Claude 回應時運行它時,Claude Code 會要求您立即確認目錄,一旦您確認,Claude 在同一回合中的下一個工具呼叫就可以存取它。在 v2.1.234 之前,Claude Code 會將命令排隊直到該回合完成 |50| `/add-dir <path>` | 添加工作目錄以進行檔案存取。輸入部分路徑以查看匹配的目錄建議;按 `Tab` 接受一個。大多數 `.claude/` 設定[不會從添加的目錄中發現](https://code.claude.com/docs/zh-TW/permissions.md#additional-directories-grant-file-access-not-configuration)。您無法添加大多數[網路路徑](https://code.claude.com/docs/zh-TW/errors.md#working-directory-is-a-network-path),例如 `\\server\share`。成功添加後,您的 [`DirectoryAdded` hook](https://code.claude.com/docs/zh-TW/hooks#directoryadded) 會運行。如果您在 Claude 回應時運行 `/add-dir`,一旦您確認添加,Claude 的下一個工具呼叫就可以存取該目錄 |

51| `/advisor [model\|off]` | 啟用或停用[顧問工具](https://code.claude.com/docs/zh-TW/advisor.md),它在任務期間的關鍵時刻諮詢第二個模型以獲得指導。接受 `fable`、`opus`、`sonnet` 或完整的模型 ID。`fable` 需要 [Fable 存取](https://code.claude.com/docs/zh-TW/advisor.md#choose-an-advisor-model)。沒有引數時,打開選擇器。在沒有互動式終端機的工作階段中,或通過 [Remote Control](https://code.claude.com/docs/zh-TW/remote-control.md#limitations),將模型或 `off` 作為引數傳遞;在那裡沒有引數時,命令會將目前顧問列印為文字。這些形式需要 Claude Code v2.1.260 或更新版本 |51| `/advisor [model\|off]` | 啟用或停用[顧問工具](https://code.claude.com/docs/zh-TW/advisor.md),它在任務期間的關鍵時刻諮詢第二個模型以獲得指導。接受 `fable`、`opus`、`sonnet` 或完整的模型 ID。`fable` 需要 [Fable 存取](https://code.claude.com/docs/zh-TW/advisor.md#choose-an-advisor-model)。沒有引數時,打開選擇器。在沒有互動式終端機的工作階段中,或通過 [Remote Control](https://code.claude.com/docs/zh-TW/remote-control.md#limitations),將模型或 `off` 作為引數傳遞;在那裡沒有引數時,命令會將目前顧問列印為文字。這些形式需要 Claude Code v2.1.260 或更新版本 |

52| `/agents` | 列印提醒以要求 Claude 建立或管理 [subagent](https://code.claude.com/docs/zh-TW/sub-agents.md),或直接編輯 `.claude/agents/` 或 `~/.claude/agents/`。在 v2.1.197 及更早版本上,打開用於建立和管理 subagent 設定的互動式介面 |52| `/agents` | 列印提醒以要求 Claude 建立或管理 [subagent](https://code.claude.com/docs/zh-TW/sub-agents.md),或直接編輯 `.claude/agents/` 或 `~/.claude/agents/`。在 v2.1.197 及更早版本上,打開用於建立和管理 subagent 設定的互動式介面 |

53| `/artifact-capabilities` | **[Skill](https://code.claude.com/docs/zh-TW/skills.md#bundled-skills)。** 載入已發佈 [artifact](https://code.claude.com/docs/zh-TW/artifacts.md) 可以使用的執行時功能的參考,例如[呼叫您的連接器](https://code.claude.com/docs/zh-TW/artifacts.md#pull-live-data-with-mcp-connectors)或[提供檔案下載](https://code.claude.com/docs/zh-TW/artifacts.md#offer-a-file-download),包括您的帳戶擁有的功能。Claude 通常在建立使用其中一個的頁面前自行載入它。在 [artifact](https://code.claude.com/docs/zh-TW/artifacts.md#availability) 可用的地方可用 |53| `/artifact-capabilities` | **[Skill](https://code.claude.com/docs/zh-TW/skills.md#bundled-skills)。** 載入已發佈 [artifact](https://code.claude.com/docs/zh-TW/artifacts.md) 可以使用的執行時功能的參考,例如[呼叫您的連接器](https://code.claude.com/docs/zh-TW/artifacts.md#pull-live-data-with-mcp-connectors)或[提供檔案下載](https://code.claude.com/docs/zh-TW/artifacts.md#offer-a-file-download),包括您的帳戶擁有的功能。Claude 通常在建立使用其中一個的頁面前自行載入它。在 [artifact](https://code.claude.com/docs/zh-TW/artifacts.md#availability) 可用的地方可用 |


69| `/code-review [low\|medium\|high\|xhigh\|max\|ultra] [--fix] [--comment] [--max-findings n\|all\|default] [pr#\|branch\|path]` | **[Skill](https://code.claude.com/docs/zh-TW/skills.md#bundled-skills)。** 檢查目前差異或您傳遞的 PR 編號、分支或路徑,以查找正確性錯誤。根據您的模型和 effort 等級,檢查也涵蓋清理機會。傳遞 `--fix` 以應用發現,`--comment` 以在 GitHub PR 或 GitLab merge request 上發佈它們,或 `ultra` 以運行深度[雲端審查](https://code.claude.com/docs/zh-TW/ultrareview.md)。發佈到 GitLab merge request 需要 Claude Code v2.1.257 或更新版本。在 `github.com` PR 目標上使用 `ultra` 時,傳遞 `--post` 以在啟動對話框中預先選擇[將完成的發現發佈到 PR](https://code.claude.com/docs/zh-TW/ultrareview.md#post-findings-to-the-pull-request);`--post` 需要 Claude Code v2.1.227 或更新版本。有關 effort 等級、目標設定以及它與 `/simplify` 的關係,請參閱[使用 `/code-review` 在本地檢查](https://code.claude.com/docs/zh-TW/code-review-local)。別名:`/review` |69| `/code-review [low\|medium\|high\|xhigh\|max\|ultra] [--fix] [--comment] [--max-findings n\|all\|default] [pr#\|branch\|path]` | **[Skill](https://code.claude.com/docs/zh-TW/skills.md#bundled-skills)。** 檢查目前差異或您傳遞的 PR 編號、分支或路徑,以查找正確性錯誤。根據您的模型和 effort 等級,檢查也涵蓋清理機會。傳遞 `--fix` 以應用發現,`--comment` 以在 GitHub PR 或 GitLab merge request 上發佈它們,或 `ultra` 以運行深度[雲端審查](https://code.claude.com/docs/zh-TW/ultrareview.md)。發佈到 GitLab merge request 需要 Claude Code v2.1.257 或更新版本。在 `github.com` PR 目標上使用 `ultra` 時,傳遞 `--post` 以在啟動對話框中預先選擇[將完成的發現發佈到 PR](https://code.claude.com/docs/zh-TW/ultrareview.md#post-findings-to-the-pull-request);`--post` 需要 Claude Code v2.1.227 或更新版本。有關 effort 等級、目標設定以及它與 `/simplify` 的關係,請參閱[使用 `/code-review` 在本地檢查](https://code.claude.com/docs/zh-TW/code-review-local)。別名:`/review` |

70| `/color [color\|default]` | 設定目前工作階段的提示詞欄顏色。可用顏色:`red`、`blue`、`green`、`yellow`、`purple`、`orange`、`pink`、`cyan`。使用 `default` 重置,或運行時不帶引數以選擇隨機顏色。當 [Remote Control](https://code.claude.com/docs/zh-TW/remote-control.md) 連接時,顏色會同步到 claude.ai/code。也可在非互動模式 (`-p`) 中使用 |70| `/color [color\|default]` | 設定目前工作階段的提示詞欄顏色。可用顏色:`red`、`blue`、`green`、`yellow`、`purple`、`orange`、`pink`、`cyan`。使用 `default` 重置,或運行時不帶引數以選擇隨機顏色。當 [Remote Control](https://code.claude.com/docs/zh-TW/remote-control.md) 連接時,顏色會同步到 claude.ai/code。也可在非互動模式 (`-p`) 中使用 |

71| `/compact [instructions]` | 通過總結到目前為止的對話來釋放上下文。可選地傳遞焦點指示以進行摘要。請參閱[壓縮如何處理規則、skill 和記憶檔案](https://code.claude.com/docs/zh-TW/context-window.md#what-survives-compaction) |71| `/compact [instructions]` | 通過總結到目前為止的對話來釋放上下文。可選地傳遞焦點指示以進行摘要。請參閱[壓縮如何處理規則、skill 和記憶檔案](https://code.claude.com/docs/zh-TW/context-window.md#what-survives-compaction) |

72| `/config [key=value ...]` | 打開[設定](https://code.claude.com/docs/zh-TW/settings.md)介面以調整主題、模型、[輸出風格](https://code.claude.com/docs/zh-TW/output-styles.md)和其他偏好設定。傳遞一個或多個 `key=value` 對以直接設定設定而不打開介面,例如 `/config thinking=false`、`/config theme=dark` 或 `/config model=sonnet`。`key=value` 形式也適用於非互動模式 (`-p`) 和來自 Claude 行動應用程式通過 [Remote Control](https://code.claude.com/docs/zh-TW/remote-control.md)。`key=value` 形式無法打開需要您在面板中確認的設定,例如 [`autoContinueAtUsageLimit`](https://code.claude.com/docs/zh-TW/interactive-mode#turn-automatic-continue-off),儘管它可以關閉一個。運行 `/config --help` 以列出它接受的鍵。別名:`/settings` |72| `/config [key=value ...]` | 打開[設定](https://code.claude.com/docs/zh-TW/settings.md)介面以調整偏好設定。傳遞 `key=value` 對以直接設定某項設定,例如 `/config verbose=true`、`/config theme=dark` 或 `/config model=sonnet`。該形式也適用於非互動模式 (`-p`) 和來自 Claude 行動應用程式通過 [Remote Control](https://code.claude.com/docs/zh-TW/remote-control.md)。它無法開啟需要您在面板中確認的設定,例如 [`autoContinueAtUsageLimit`](https://code.claude.com/docs/zh-TW/interactive-mode#turn-automatic-continue-off)。運行 `/config --help` 以列出它接受的鍵。別名:`/settings` |

73| `/context [all]` | 將目前上下文使用情況視覺化為彩色網格。顯示上下文繁重工具、記憶膨脹和容量警告的最佳化建議。當對話超過上下文視窗時,輸出包括[警告](https://code.claude.com/docs/zh-TW/errors.md#context-exceeds-the-token-limit),顯示您超過限制的距離以及哪個命令釋放空間。在[全螢幕模式](https://code.claude.com/docs/zh-TW/fullscreen.md)中,`/context` 會摺疊每項細目以保持網格可見。傳遞 `all` 以展開它 |73| `/context [all]` | 將目前上下文使用情況視覺化為彩色網格。顯示上下文繁重工具、記憶膨脹和容量警告的最佳化建議。當對話超過上下文視窗時,輸出包括[警告](https://code.claude.com/docs/zh-TW/errors.md#context-exceeds-the-token-limit),顯示您超過限制的距離以及哪個命令釋放空間。在[全螢幕模式](https://code.claude.com/docs/zh-TW/fullscreen.md)中,`/context` 會摺疊每項細目以保持網格可見。傳遞 `all` 以展開它 |

74| `/copy [N]` | 將最後的助手回應複製到剪貼簿。傳遞數字 `N` 以複製第 N 個最新回應:`/copy 2` 複製倒數第二個。當存在程式碼區塊或引用區塊時,顯示互動式選擇器以選擇個別區塊或完整回應。在選擇器中按 `w` 以將選擇寫入檔案而不是剪貼簿,這在 SSH 上很有用 |74| `/copy [N]` | 將最後的助手回應複製到剪貼簿。傳遞數字 `N` 以複製第 N 個最新回應:`/copy 2` 複製倒數第二個。當存在程式碼區塊或引用區塊時,顯示互動式選擇器以選擇個別區塊或完整回應。在選擇器中按 `w` 以將選擇寫入檔案而不是剪貼簿,這在 SSH 上很有用 |

75| `/cost` | `/usage` 的別名 |75| `/cost` | `/usage` 的別名 |


112| `/model [model]` | 切換 AI 模型並將其保存為新工作階段的預設值。對於支援它的模型,使用左/右箭頭以[調整 effort 等級](https://code.claude.com/docs/zh-TW/model-config.md#adjust-effort-level)。沒有引數時,打開選擇器;在行上按 `s` 以僅為目前工作階段切換。請參閱[新模型何時開始生效](https://code.claude.com/docs/zh-TW/interactive-mode.md#when-claude-code-sends-what-you-queued)。在 v2.1.242 之前,它可能會等待。使用 `-p` 時,傳遞模型引數,該引數不會保存為您的預設值;需要 v2.1.205 或更新版本 |112| `/model [model]` | 切換 AI 模型並將其保存為新工作階段的預設值。對於支援它的模型,使用左/右箭頭以[調整 effort 等級](https://code.claude.com/docs/zh-TW/model-config.md#adjust-effort-level)。沒有引數時,打開選擇器;在行上按 `s` 以僅為目前工作階段切換。請參閱[新模型何時開始生效](https://code.claude.com/docs/zh-TW/interactive-mode.md#when-claude-code-sends-what-you-queued)。在 v2.1.242 之前,它可能會等待。使用 `-p` 時,傳遞模型引數,該引數不會保存為您的預設值;需要 v2.1.205 或更新版本 |

113| `/output-style [style]` | 列出[輸出風格](https://code.claude.com/docs/zh-TW/output-styles.md)或切換到一個,例如 `/output-style concise`。請參閱[變更您的輸出風格](https://code.claude.com/docs/zh-TW/output-styles.md#change-your-output-style)。需要 Claude Code v2.1.269 或更新版本 |113| `/output-style [style]` | 列出[輸出風格](https://code.claude.com/docs/zh-TW/output-styles.md)或切換到一個,例如 `/output-style concise`。請參閱[變更您的輸出風格](https://code.claude.com/docs/zh-TW/output-styles.md#change-your-output-style)。需要 Claude Code v2.1.269 或更新版本 |

114| `/passes` | 與朋友分享免費一週的 Claude Code。僅在您的帳戶符合條件時可見 |114| `/passes` | 與朋友分享免費一週的 Claude Code。僅在您的帳戶符合條件時可見 |

115| `/permissions` | 管理工具權限的允許、詢問和拒絕規則。打開互動式對話框,您可以按範圍檢視規則、添加或移除規則、管理工作目錄以及檢查[最近的自動模式拒絕](https://code.claude.com/docs/zh-TW/auto-mode-config.md#review-denials)。您也可以從對話框的 **Auto mode** 標籤檢視和編輯[自動模式分類器規則](https://code.claude.com/docs/zh-TW/auto-mode-config.md#edit-rules-from-permissions)。別名:`/allowed-tools` |115| `/permissions` | 管理工具權限的允許、詢問和拒絕規則。打開互動式對話框,您可以按範圍檢視規則、添加或移除規則、管理工作目錄以及檢查[最近的自動模式拒絕](https://code.claude.com/docs/zh-TW/auto-mode-config.md#review-denials)。您也可以從對話框的 **Auto mode** 標籤檢視和編輯[自動模式分類器規則](https://code.claude.com/docs/zh-TW/auto-mode-config.md#edit-rules-from-permissions)。在桌面應用程式中,請改為編輯您的[設定檔](https://code.claude.com/docs/zh-TW/auto-mode-config.md#where-the-classifier-reads-configuration)。別名:`/allowed-tools` |

116| `/plan [description]` | 直接從提示詞進入 plan mode。傳遞可選描述以進入 plan mode 並立即開始該任務,例如 `/plan fix the auth bug` |116| `/plan [description]` | 直接從提示詞進入 plan mode。傳遞可選描述以進入 plan mode 並立即開始該任務,例如 `/plan fix the auth bug` |

117| `/plugin [subcommand]` | 管理 Claude Code [外掛](https://code.claude.com/docs/zh-TW/plugins/overview.md)。運行時不帶引數以打開外掛選單,或傳遞子命令(例如 `list`、`install`、`enable` 或 `disable`)以直接執行。Claude Code 可以在安裝期間啟動外掛;[安裝摘要](https://code.claude.com/docs/zh-TW/plugins/install.md#install-a-plugin)會告訴您它是否已啟動,或是否需要運行 `/reload-plugins` |117| `/plugin [subcommand]` | 管理 Claude Code [外掛](https://code.claude.com/docs/zh-TW/plugins/overview.md)。運行時不帶引數以打開外掛選單,或傳遞子命令(例如 `list`、`install`、`enable` 或 `disable`)以直接執行。Claude Code 可以在安裝期間啟動外掛;[安裝摘要](https://code.claude.com/docs/zh-TW/plugins/install.md#install-a-plugin)會告訴您它是否已啟動,或是否需要運行 `/reload-plugins` |

118| `/plugin-authoring` | 載入 Claude 用來[編寫 mod](https://code.claude.com/docs/zh-TW/plugins/mods/create.md#ask-claude-for-a-mod) 的參考資料。當您要求 mod 時,Claude 可以自行載入它。這是來自[內建外掛](https://code.claude.com/docs/zh-TW/plugins/mods/overview.md#mods-built-into-claude-code)的 skill,您可以在 `/plugin` 中關閉它。需要 Claude Code v2.1.287 或更新版本 |118| `/plugin-authoring` | 載入 Claude 用來[編寫 mod](https://code.claude.com/docs/zh-TW/plugins/mods/create.md#ask-claude-for-a-mod) 的參考資料。當您要求 mod 時,Claude 可以自行載入它。這是來自[內建外掛](https://code.claude.com/docs/zh-TW/plugins/mods/overview.md#mods-built-into-claude-code)的 skill,您可以在 `/plugin` 中關閉它。需要 Claude Code v2.1.287 或更新版本 |

Details

49 49 

50## 檢查 MCP servers50## 檢查 MCP servers

51 51 

52執行 `/mcp` 以查看每個已設定的 server、其連線狀態,以及您是否已為目前專案核准它。server 可以定義正確但仍然不提供 tools,原因有幾個常見的:52執行 `/mcp` 以查看您的伺服器及其連線狀態。伺服器可以定義正確但仍然不提供工具,原因有幾個常見的:

53 53 

54* `.mcp.json` 中的專案範圍 servers 需要一次性核准。如果提示被關閉,server 將保持停用狀態,直到您從 `/mcp` 核准它。54* `.mcp.json` 中的專案範圍伺服器需要一次性核准。如果您關閉了該提示,伺服器將保持停用狀態。若要再次看到該提示,請執行 `claude mcp reset-project-choices` 並重新啟動 Claude Code。它會針對每個專案伺服器再次詢問。

55* 啟動失敗的 server 在 `/mcp` 中顯示為失敗。`command` 或 `args` 中的相對檔案路徑是常見原因,因為它們相對於您啟動 Claude Code 的目錄而不是 `.mcp.json` 的位置進行解析。55* 啟動失敗的 server 在 `/mcp` 中顯示為失敗。`command` 或 `args` 中的相對檔案路徑是常見原因,因為它們相對於您啟動 Claude Code 的目錄而不是 `.mcp.json` 的位置進行解析。

56* 顯示為已連線但列出零個 tools 的 server 已成功啟動但未返回 tool 清單。從 `/mcp` 選擇 **Reconnect**。如果計數保持為零,執行 `claude --debug=mcp` 並在 `~/.claude/debug/<session-id>.txt` 的偵錯日誌中讀取 server 的 stderr。56* 顯示為已連線但列出零個 tools 的 server 已成功啟動但未返回 tool 清單。從 `/mcp` 選擇 **Reconnect**。如果計數保持為零,執行 `claude --debug=mcp` 並在 `~/.claude/debug/<session-id>.txt` 的偵錯日誌中讀取 server 的 stderr。

57 57 


72 72 

73對 `settings.json` 的編輯在短暫的檔案穩定延遲後在執行中的工作階段中生效,即使您在工作階段開始後才建立檔案或專案的 `.claude/` 資料夾。您不需要重新啟動。在 v2.1.257 之前,Claude Code 沒有偵測到在工作階段開始後建立的 `.claude/` 資料夾中的編輯。73對 `settings.json` 的編輯在短暫的檔案穩定延遲後在執行中的工作階段中生效,即使您在工作階段開始後才建立檔案或專案的 `.claude/` 資料夾。您不需要重新啟動。在 v2.1.257 之前,Claude Code 沒有偵測到在工作階段開始後建立的 `.claude/` 資料夾中的編輯。

74 74 

75如果在保存後幾秒鐘 `/hooks` 仍顯示舊定義,請再次執行 `/hooks` 以重新整理檢視。75如果在儲存後幾秒鐘 `/hooks` 仍顯示舊定義,請再次執行 `/hooks` 以重新整理檢視。如果 `/hooks` 顯示 hook 但它仍然不觸發,下一步是即時監視 hook 評估。使用 `claude --debug` 啟動工作階段並觸發工具呼叫。如需日誌格式,請參閱 [Debug hooks](https://code.claude.com/docs/zh-TW/hooks.md#debug-hooks),如需常見失敗模式,請參閱 [hooks 疑難排解](https://code.claude.com/docs/zh-TW/hooks-guide.md#limitations-and-troubleshooting)。

76 

77如果 `/hooks` 顯示 hook 但它仍然不觸發,下一步是即時監視 hook 評估。使用 `claude --debug` 啟動工作階段並觸發 tool 呼叫。偵錯日誌記錄每個事件、檢查了哪些 matchers 以及 hook 的結束代碼和輸出。如需日誌格式,請參閱 [Debug hooks](https://code.claude.com/docs/zh-TW/hooks.md#debug-hooks),如需常見失敗模式,請參閱 [hooks 疑難排解](https://code.claude.com/docs/zh-TW/hooks-guide.md#limitations-and-troubleshooting)。

78 76 

79## 針對乾淨的設定進行測試77## 針對乾淨的設定進行測試

80 78 


159| 清理邏輯在工作階段結束時永遠不會執行 | 未設定 `SessionEnd` hook | 在 `settings.json` 中新增 `SessionEnd` hook。請參閱 [hook 事件列表](https://code.claude.com/docs/zh-TW/hooks.md#hook-events)。 |157| 清理邏輯在工作階段結束時永遠不會執行 | 未設定 `SessionEnd` hook | 在 `settings.json` 中新增 `SessionEnd` hook。請參閱 [hook 事件列表](https://code.claude.com/docs/zh-TW/hooks.md#hook-events)。 |

160| `.mcp.json` 中的 MCP 伺服器永遠不會載入 | 檔案位於 `.claude/` 下,或其伺服器位於頂層 `servers` 鍵下(如 VS Code 的 `mcp.json`),而不是 `mcpServers` | 專案 MCP 設定位於存放庫根目錄的 `.mcp.json`,而不是在 `.claude/` 內,伺服器位於 `mcpServers` 鍵下。請參閱 [MCP 設定](https://code.claude.com/docs/zh-TW/mcp.md)。 |158| `.mcp.json` 中的 MCP 伺服器永遠不會載入 | 檔案位於 `.claude/` 下,或其伺服器位於頂層 `servers` 鍵下(如 VS Code 的 `mcp.json`),而不是 `mcpServers` | 專案 MCP 設定位於存放庫根目錄的 `.mcp.json`,而不是在 `.claude/` 內,伺服器位於 `mcpServers` 鍵下。請參閱 [MCP 設定](https://code.claude.com/docs/zh-TW/mcp.md)。 |

161| 在 `settings.json` 中的 `mcpServers` 下新增的 MCP 伺服器永遠不會出現 | `settings.json` 不讀取 `mcpServers` 鍵 | 在存放庫根目錄的 `.mcp.json` 中定義專案伺服器,或執行 `claude mcp add --scope user` 以取得使用者範圍的伺服器。請參閱 [MCP 設定](https://code.claude.com/docs/zh-TW/mcp.md)。 |159| 在 `settings.json` 中的 `mcpServers` 下新增的 MCP 伺服器永遠不會出現 | `settings.json` 不讀取 `mcpServers` 鍵 | 在存放庫根目錄的 `.mcp.json` 中定義專案伺服器,或執行 `claude mcp add --scope user` 以取得使用者範圍的伺服器。請參閱 [MCP 設定](https://code.claude.com/docs/zh-TW/mcp.md)。 |

162| 新增的專案 MCP 伺服器但未出現 | 一次性核准提示被關閉 | 專案範圍的伺服器需要核准。執行 `/mcp` 以查看狀態並核准。 |160| 新增的專案 MCP 伺服器但未出現 | 一次性核准提示被關閉 | 專案範圍的伺服器需要核准。執行 `claude mcp reset-project-choices`,重新啟動 Claude Code,然後核准該伺服器。 |

163| MCP 伺服器從某些目錄啟動失敗 | `command` 或 `args` 使用相對檔案路徑 | 對本機指令碼使用絕對路徑。您 `PATH` 上的可執行檔(如 `npx` 或 `uvx`)可以按原樣使用。 |161| MCP 伺服器從某些目錄啟動失敗 | `command` 或 `args` 使用相對檔案路徑 | 對本機指令碼使用絕對路徑。您 `PATH` 上的可執行檔(如 `npx` 或 `uvx`)可以按原樣使用。 |

164| MCP 伺服器啟動時沒有預期的環境變數 | 伺服器的設定項目未設定它們,且它們不在 Claude Code 傳遞給 stdio 伺服器的環境中:其自身環境,減去 [它從子程序中移除的變數](https://code.claude.com/docs/zh-TW/monitoring-usage.md#administrator-configuration) | 在伺服器的 `.mcp.json` 項目內設定每個伺服器的 `env`,這不取決於啟動環境或工作區信任。 |162| MCP 伺服器啟動時沒有預期的環境變數 | 伺服器的設定項目未設定它們,且它們不在 Claude Code 傳遞給 stdio 伺服器的環境中:其自身環境,減去 [它從子程序中移除的變數](https://code.claude.com/docs/zh-TW/monitoring-usage.md#administrator-configuration) | 在伺服器的 `.mcp.json` 項目內設定每個伺服器的 `env`,這不取決於啟動環境或工作區信任。 |

165| `Bash(rm *)` 拒絕規則不會阻止 `/bin/rm` 或 `find -delete` | Bash 規則比對字面命令字串,而不是基礎可執行檔;請參閱 [Bash 規則不比對的內容](https://code.claude.com/docs/zh-TW/permissions.md#bash-rule-limits) | 使用 [PreToolUse hook](https://code.claude.com/docs/zh-TW/hooks-guide.md) 或 [sandbox](https://code.claude.com/docs/zh-TW/sandboxing.md) 以獲得硬性保證。 |163| `Bash(rm *)` 拒絕規則不會阻止 `/bin/rm` 或 `find -delete` | Bash 規則比對字面命令字串,而不是基礎可執行檔;請參閱 [Bash 規則不比對的內容](https://code.claude.com/docs/zh-TW/permissions.md#bash-rule-limits) | 使用 [PreToolUse hook](https://code.claude.com/docs/zh-TW/hooks-guide.md) 或 [sandbox](https://code.claude.com/docs/zh-TW/sandboxing.md) 以獲得硬性保證。 |

desktop.md +3 −2

Details

264 264 

265### 最小化窗格265### 最小化窗格

266 266 

267若要以小尺寸持續顯示 Terminal、Browser、[iOS Simulator](https://code.claude.com/docs/zh-TW/desktop-ios-simulator.md) 或[側邊聊天](#ask-a-side-question-without-derailing-the-session),請點擊窗格標題中的 **Minimize**。此按鈕需要 Claude Desktop v4.0.0 或更新版本,以及 Claude 帳戶而非[第三方供應商](https://code.claude.com/docs/zh-TW/third-party-integrations.md)。Browser 窗格僅在本機工作階段中提供此按鈕。267若要以小尺寸持續顯示 Terminal、Browser、[iOS Simulator](https://code.claude.com/docs/zh-TW/desktop-ios-simulator.md) 或[側邊聊天](#ask-a-side-question-without-derailing-the-session),請點擊窗格標題中的 **Minimize**。此按鈕需要 Claude Desktop v4.0.0 或更新版本。若使用[第三方供應商](https://code.claude.com/docs/zh-TW/third-party-integrations.md),則需要 v5.11492.0 或更新版本,因此請[檢查您的版本](#check-your-version)。Browser 窗格僅在本機工作階段中提供此按鈕。

268 268 

269當[工作階段詳細資訊面板](#see-session-details)顯示在畫面上時,最小化的窗格會位於該面板中,否則會浮動在聊天的某個角落:269當[工作階段詳細資訊面板](#see-session-details)顯示在畫面上時,最小化的窗格會位於該面板中,否則會浮動在聊天的某個角落:

270 270 


2127 2127 

2128若要防止這種情況,請同時在 Claude Desktop 原則中(Windows 上位於 `HKLM`)部署 `forceLoginOrgUUID`,並設為您的 claude.ai 組織 ID。除非原則本身[選擇了 Claude API](https://claude.com/docs/third-party/claude-desktop/claude-api#choose-an-authentication-approach),否則 Claude Desktop 會在應用程式下次啟動時停止使用個人自己的 API 金鑰或 Console 帳戶。2128若要防止這種情況,請同時在 Claude Desktop 原則中(Windows 上位於 `HKLM`)部署 `forceLoginOrgUUID`,並設為您的 claude.ai 組織 ID。除非原則本身[選擇了 Claude API](https://claude.com/docs/third-party/claude-desktop/claude-api#choose-an-authentication-approach),否則 Claude Desktop 會在應用程式下次啟動時停止使用個人自己的 API 金鑰或 Console 帳戶。

2129 2129 

2130部署之前,請先檢查兩種情況:2130部署之前,請先檢查三種情況:

2131 2131 

2132* **Claude Console 組織**:請勿單獨以 Claude Console 組織的 ID 部署 `forceLoginOrgUUID`,否則您組織的成員將無法使用 Claude Desktop。請改為參閱[哪些裝置提供 Claude API 帳戶登入](https://claude.com/docs/third-party/claude-desktop/claude-api#which-devices-offer-the-claude-api-account-sign-in)。2132* **Claude Console 組織**:請勿單獨以 Claude Console 組織的 ID 部署 `forceLoginOrgUUID`,否則您組織的成員將無法使用 Claude Desktop。請改為參閱[哪些裝置提供 Claude API 帳戶登入](https://claude.com/docs/third-party/claude-desktop/claude-api#which-devices-offer-the-claude-api-account-sign-in)。

2133* **Enterprise Admin Console**:如果它負責傳遞您電腦的 Claude Desktop 設定,請先將這些電腦更新至 Claude Desktop v2.37337.0 或更新版本,因為一旦設定此鍵,較早的版本就會忽略它。請參閱[讓裝置保持使用其受管設定檔](https://claude.com/docs/third-party/claude-desktop/admin-console#keep-a-device-on-its-managed-profile)。2133* **Enterprise Admin Console**:如果它負責傳遞您電腦的 Claude Desktop 設定,請先將這些電腦更新至 Claude Desktop v2.37337.0 或更新版本,因為一旦設定此鍵,較早的版本就會忽略它。請參閱[讓裝置保持使用其受管設定檔](https://claude.com/docs/third-party/claude-desktop/admin-console#keep-a-device-on-its-managed-profile)。

2134* **第三方提供者**:如果使用者在應用程式中自行設定了[第三方推論設定](https://claude.com/docs/third-party/claude-desktop/in-app-configuration),從您部署此鍵後的下一次啟動起,Claude Desktop 就會忽略該設定。若要讓使用者繼續使用 Amazon Bedrock、Google Cloud 的 Agent Platform、Microsoft Foundry 或 LLM 閘道,請在同一個 Claude Desktop 原則中將[設定部署](https://claude.com/docs/third-party/claude-desktop/configuration)到他們的電腦。

2134 2135 

2135### 網路存取需求2136### 網路存取需求

2136 2137 

Details

182* **Review allowed permissions**:從 **Always allowed** 面板查看和撤銷此任務的已儲存工具批准182* **Review allowed permissions**:從 **Always allowed** 面板查看和撤銷此任務的已儲存工具批准

183* **Delete**:移除任務。任務建立的工作階段會被[封存](https://code.claude.com/docs/zh-TW/desktop.md#organize-and-find-sessions),而非刪除。存放任務 `SKILL.md` 檔案的資料夾會保留在磁碟上的 `~/.claude/scheduled-tasks/<task-name>/`,或者如果您設定了 [`CLAUDE_CONFIG_DIR`](https://code.claude.com/docs/zh-TW/env-vars) 變數,則位於其下的 `scheduled-tasks/<task-name>/`。若要移除該資料夾,請自行刪除。183* **Delete**:移除任務。任務建立的工作階段會被[封存](https://code.claude.com/docs/zh-TW/desktop.md#organize-and-find-sessions),而非刪除。存放任務 `SKILL.md` 檔案的資料夾會保留在磁碟上的 `~/.claude/scheduled-tasks/<task-name>/`,或者如果您設定了 [`CLAUDE_CONFIG_DIR`](https://code.claude.com/docs/zh-TW/env-vars) 變數,則位於其下的 `scheduled-tasks/<task-name>/`。若要移除該資料夾,請自行刪除。

184 184 

185您也可以透過在任何 Desktop 工作階段中詢問 Claude 來列出、建立、編輯和暫停任務。例如,「暫停我的 dependency-audit 任務」或「顯示我的排程任務」。若要刪除任務,請使用其詳細資料頁面上的 **Delete** 按鈕。185您也可以透過詢問 Claude、讓任務自行更新,或在磁碟上編輯任務的提示詞來管理任務:

186 186 

187若要讓任務使用 `update_scheduled_task` MCP 工具變更其自己的排程或提示詞,請按一下 **Run now** 並每次核准該呼叫。187* **詢問 Claude**:在任何 Desktop 工作階段中詢問 Claude 來列出、建立、編輯和暫停任務。例如,「暫停我的 dependency-audit 任務」或「顯示我的排程任務」。若要刪除任務,請使用其詳細資料頁面上的 **Delete** 按鈕。

188 188* **讓任務自行更新**:若要讓任務使用 `update_scheduled_task` MCP 工具變更其自己的排程或提示詞,請按一下 **Run now** 並每次核准該呼叫

189若要在磁碟上編輯任務的提示詞,請開啟 `~/.claude/scheduled-tasks/<task-name>/SKILL.md`(如果設定了 [`CLAUDE_CONFIG_DIR`](https://code.claude.com/docs/zh-TW/env-vars),則在其下)。該檔案使用 YAML frontmatter 作為 `name` 和 `description`,提示詞作為主體。變更在下一次執行時生效。排程、資料夾和啟用狀態不在此檔案中:透過 Edit 表單變更它們或詢問 Claude。189* **在磁碟上編輯提示詞**:開啟 `~/.claude/scheduled-tasks/<task-name>/SKILL.md`,或者如果您設定了 [`CLAUDE_CONFIG_DIR`](https://code.claude.com/docs/zh-TW/env-vars) 變數,則開啟其下的 `scheduled-tasks/<task-name>/SKILL.md`。該檔案使用 YAML frontmatter 作為 `name` 和 `description`,提示詞作為主體。變更在下一次執行時生效。排程、資料夾和啟用狀態不在此檔案中:透過 Edit 表單變更它們或詢問 Claude。

190 190 

191## 相關資源191## 相關資源

192 192 

env-vars.md +11 −4

Details

168| `ANTHROPIC_FOUNDRY_AUTH_TOKEN` | 用於 Microsoft Foundry 身分驗證的 Bearer token,例如 Microsoft Entra 存取 token。Claude Code 會將其作為 `Authorization: Bearer` 標頭傳送。優先於 `ANTHROPIC_FOUNDRY_API_KEY` 與 Azure 預設憑證鏈。請參閱 [Microsoft Foundry](https://code.claude.com/docs/zh-TW/microsoft-foundry.md)。需要 Claude Code v2.1.203 或更新版本 |168| `ANTHROPIC_FOUNDRY_AUTH_TOKEN` | 用於 Microsoft Foundry 身分驗證的 Bearer token,例如 Microsoft Entra 存取 token。Claude Code 會將其作為 `Authorization: Bearer` 標頭傳送。優先於 `ANTHROPIC_FOUNDRY_API_KEY` 與 Azure 預設憑證鏈。請參閱 [Microsoft Foundry](https://code.claude.com/docs/zh-TW/microsoft-foundry.md)。需要 Claude Code v2.1.203 或更新版本 |

169| `ANTHROPIC_FOUNDRY_BASE_URL` | Microsoft Foundry 資源的完整基礎 URL(例如 `https://my-resource.services.ai.azure.com/anthropic`)。可替代 `ANTHROPIC_FOUNDRY_RESOURCE`(請參閱 [Microsoft Foundry](https://code.claude.com/docs/zh-TW/microsoft-foundry.md)) |169| `ANTHROPIC_FOUNDRY_BASE_URL` | Microsoft Foundry 資源的完整基礎 URL(例如 `https://my-resource.services.ai.azure.com/anthropic`)。可替代 `ANTHROPIC_FOUNDRY_RESOURCE`(請參閱 [Microsoft Foundry](https://code.claude.com/docs/zh-TW/microsoft-foundry.md)) |

170| `ANTHROPIC_FOUNDRY_RESOURCE` | Microsoft Foundry 資源名稱(例如 `my-resource`)。Claude Code [會拒絕 URL 或主機名稱](https://code.claude.com/docs/zh-TW/errors.md#anthropic-foundry-resource-must-be-a-foundry-resource-name)。若未設定 `ANTHROPIC_FOUNDRY_BASE_URL` 則為必要(請參閱 [Microsoft Foundry](https://code.claude.com/docs/zh-TW/microsoft-foundry.md)) |170| `ANTHROPIC_FOUNDRY_RESOURCE` | Microsoft Foundry 資源名稱(例如 `my-resource`)。Claude Code [會拒絕 URL 或主機名稱](https://code.claude.com/docs/zh-TW/errors.md#anthropic-foundry-resource-must-be-a-foundry-resource-name)。若未設定 `ANTHROPIC_FOUNDRY_BASE_URL` 則為必要(請參閱 [Microsoft Foundry](https://code.claude.com/docs/zh-TW/microsoft-foundry.md)) |

171| `ANTHROPIC_GOOGLE_CLOUD_BASE_URL` | 覆寫 [Claude Models on Google Cloud (Anthropic managed)](https://code.claude.com/docs/zh-TW/claude-models-on-google-cloud-anthropic-managed.md) 端點 URL,例如透過 [LLM 閘道](https://code.claude.com/docs/zh-TW/llm-gateway) 路由時 |

172| `ANTHROPIC_GOOGLE_CLOUD_LOCATION` | Claude Code 放入 [Claude Models on Google Cloud (Anthropic managed)](https://code.claude.com/docs/zh-TW/claude-models-on-google-cloud-anthropic-managed.md) 請求 URL 中的 Google Cloud 位置。預設為 `global` |

173| `ANTHROPIC_GOOGLE_CLOUD_PROJECT` | [Claude Models on Google Cloud (Anthropic managed)](https://code.claude.com/docs/zh-TW/claude-models-on-google-cloud-anthropic-managed.md) 的 Google Cloud 專案 ID |

174| `ANTHROPIC_GOOGLE_CLOUD_WORKSPACE_ID` | [Claude Models on Google Cloud (Anthropic managed)](https://code.claude.com/docs/zh-TW/claude-models-on-google-cloud-anthropic-managed.md) 的工作區 ID。為必要設定,除非您使用 v2.1.307 或更新版本且已設定 `ANTHROPIC_GOOGLE_CLOUD_BASE_URL` |

171| `ANTHROPIC_MODEL` | 要使用的模型設定名稱(請參閱[模型設定](https://code.claude.com/docs/zh-TW/model-config.md#environment-variables)) |175| `ANTHROPIC_MODEL` | 要使用的模型設定名稱(請參閱[模型設定](https://code.claude.com/docs/zh-TW/model-config.md#environment-variables)) |

172| `ANTHROPIC_ORGANIZATION_ID` | [Workload Identity Federation](https://platform.claude.com/docs/en/manage-claude/workload-identity-federation) 的組織 ID。請與 `ANTHROPIC_FEDERATION_RULE_ID` 一起設定。請參閱[身分驗證優先順序](https://code.claude.com/docs/zh-TW/authentication.md#authentication-precedence) |176| `ANTHROPIC_ORGANIZATION_ID` | [Workload Identity Federation](https://platform.claude.com/docs/en/manage-claude/workload-identity-federation) 的組織 ID。請與 `ANTHROPIC_FEDERATION_RULE_ID` 一起設定。請參閱[身分驗證優先順序](https://code.claude.com/docs/zh-TW/authentication.md#authentication-precedence) |

173| `ANTHROPIC_PROFILE` | 用於身分驗證的 Anthropic 設定檔名稱,例如由 [`ant auth login`](https://platform.claude.com/docs/en/cli-sdks-libraries/cli/authentication) 建立,或由[在沒有 API 金鑰的情況下登入 Console 帳戶](https://code.claude.com/docs/zh-TW/authentication.md#sign-in-without-an-api-key)所建立的設定檔。請參閱[身分驗證優先順序](https://code.claude.com/docs/zh-TW/authentication.md#authentication-precedence) |177| `ANTHROPIC_PROFILE` | 用於身分驗證的 Anthropic 設定檔名稱,例如由 [`ant auth login`](https://platform.claude.com/docs/en/cli-sdks-libraries/cli/authentication) 建立,或由[在沒有 API 金鑰的情況下登入 Console 帳戶](https://code.claude.com/docs/zh-TW/authentication.md#sign-in-without-an-api-key)所建立的設定檔。請參閱[身分驗證優先順序](https://code.claude.com/docs/zh-TW/authentication.md#authentication-precedence) |


255| `CLAUDE_CODE_DISABLE_FILE_MENTIONS` | 設為 `1` 可阻止 Claude Code 展開檔案和目錄的 [`@` 提及](https://code.claude.com/docs/zh-TW/common-workflows#reference-files-and-directories)。Claude 會改為取得所提及的路徑,並附上請它使用檔案工具讀取這些路徑的說明。在[專案和本機設定](https://code.claude.com/docs/zh-TW/settings-reference.md#variables-claude-code-ignores-in-env)中會被忽略。需要 Claude Code v2.1.299 或更新版本 |259| `CLAUDE_CODE_DISABLE_FILE_MENTIONS` | 設為 `1` 可阻止 Claude Code 展開檔案和目錄的 [`@` 提及](https://code.claude.com/docs/zh-TW/common-workflows#reference-files-and-directories)。Claude 會改為取得所提及的路徑,並附上請它使用檔案工具讀取這些路徑的說明。在[專案和本機設定](https://code.claude.com/docs/zh-TW/settings-reference.md#variables-claude-code-ignores-in-env)中會被忽略。需要 Claude Code v2.1.299 或更新版本 |

256| `CLAUDE_CODE_DISABLE_GIT_INSTRUCTIONS` | 設定為 `1` 可從 Claude 的上下文中移除內建的提交與 PR 工作流程指令以及 git 狀態快照。在使用您自己的 git 工作流程 skill 時很有用。設定時優先於 [`includeGitInstructions`](https://code.claude.com/docs/zh-TW/settings-reference#includegitinstructions) 設定 |260| `CLAUDE_CODE_DISABLE_GIT_INSTRUCTIONS` | 設定為 `1` 可從 Claude 的上下文中移除內建的提交與 PR 工作流程指令以及 git 狀態快照。在使用您自己的 git 工作流程 skill 時很有用。設定時優先於 [`includeGitInstructions`](https://code.claude.com/docs/zh-TW/settings-reference#includegitinstructions) 設定 |

257| `CLAUDE_CODE_DISABLE_INLINE_SHELL_RM_PROMPT` | 設定為 `1` 可阻止 Claude Code 讀取以 `-c` 傳遞給 shell 的腳本(例如 `bash -c 'rm -rf ~'`)來檢查[關鍵路徑](https://code.claude.com/docs/zh-TW/permission-modes.md#removals-inside-nested-commands-and-inline-scripts)移除。Claude Code 仍會檢查這些腳本中的 shell 變數與位置參數目標,其他關鍵路徑檢查也會持續執行。請在啟動 Claude Code 的環境中設定,因為 Claude Code 會忽略透過設定 `env` 區塊傳遞的副本。需要 Claude Code v2.1.288 或更新版本 |261| `CLAUDE_CODE_DISABLE_INLINE_SHELL_RM_PROMPT` | 設定為 `1` 可阻止 Claude Code 讀取以 `-c` 傳遞給 shell 的腳本(例如 `bash -c 'rm -rf ~'`)來檢查[關鍵路徑](https://code.claude.com/docs/zh-TW/permission-modes.md#removals-inside-nested-commands-and-inline-scripts)移除。Claude Code 仍會檢查這些腳本中的 shell 變數與位置參數目標,其他關鍵路徑檢查也會持續執行。請在啟動 Claude Code 的環境中設定,因為 Claude Code 會忽略透過設定 `env` 區塊傳遞的副本。需要 Claude Code v2.1.288 或更新版本 |

258| `CLAUDE_CODE_DISABLE_LEGACY_MODEL_REMAP` | 設為 `1` 可防止在 Anthropic API 上將 Opus 4 和 Opus 4.1 自動重新對應至目前的 Opus 版本。當您刻意想要固定使用較舊的模型時使用。重新對應不會在 Amazon Bedrock、Google Cloud's Agent Platform 或 Microsoft Foundry 上執行 |262| `CLAUDE_CODE_DISABLE_LEGACY_MODEL_REMAP` | 設為 `1` 可防止在 Anthropic API 上將 Opus 4 和 Opus 4.1 自動重新對應到目前的 Opus 版本。此重新對應不會在 Amazon Bedrock、Google Cloud's Agent Platform 或 Microsoft Foundry 上執行 |

259| `CLAUDE_CODE_DISABLE_MCP_TASK_BACKGROUND` | 設為 `1` 可讓 Claude 在互動工作階段中等待 [MCP 任務](https://code.claude.com/docs/zh-TW/mcp.md#make-claude-wait-for-the-result-of-an-mcp-task)的結果。當[自動背景化](https://code.claude.com/docs/zh-TW/mcp.md#automatic-backgrounding-of-long-tool-calls)開啟時,預設仍會在兩分鐘後將呼叫移至背景。需要 Claude Code v2.1.304 或更新版本 |263| `CLAUDE_CODE_DISABLE_MCP_TASK_BACKGROUND` | 設為 `1` 可讓 Claude 在互動工作階段中等待 [MCP 任務](https://code.claude.com/docs/zh-TW/mcp.md#make-claude-wait-for-the-result-of-an-mcp-task)的結果。當[自動背景化](https://code.claude.com/docs/zh-TW/mcp.md#automatic-backgrounding-of-long-tool-calls)開啟時,預設仍會在兩分鐘後將呼叫移至背景。需要 Claude Code v2.1.304 或更新版本 |

260| `CLAUDE_CODE_DISABLE_MODEL_ACCESS_FALLBACK` | 設定為 `1` 可阻止 [Amazon Bedrock](https://code.claude.com/docs/zh-TW/amazon-bedrock.md#when-a-model-is-disabled-mid-session) 與 [Google Cloud's Agent Platform](https://code.claude.com/docs/zh-TW/google-vertex-ai.md#when-a-model-is-disabled-mid-session) 上的 Claude Code 在您的帳戶於工作階段中途失去對該工作階段模型的存取權時改用較舊的模型;被拒絕的請求會立即失敗。您設定的[備援模型鏈](https://code.claude.com/docs/zh-TW/model-config.md#fallback-model-chains)仍會在該拒絕發生時切換,而[啟動模型檢查](https://code.claude.com/docs/zh-TW/amazon-bedrock.md#startup-model-checks)仍會在啟動時改用備援。需要 Claude Code v2.1.285 或更新版本 |264| `CLAUDE_CODE_DISABLE_MODEL_ACCESS_FALLBACK` | 設定為 `1` 可阻止 [Amazon Bedrock](https://code.claude.com/docs/zh-TW/amazon-bedrock.md#when-a-model-is-disabled-mid-session) 與 [Google Cloud's Agent Platform](https://code.claude.com/docs/zh-TW/google-vertex-ai.md#when-a-model-is-disabled-mid-session) 上的 Claude Code 在您的帳戶於工作階段中途失去對該工作階段模型的存取權時改用較舊的模型;被拒絕的請求會立即失敗。您設定的[備援模型鏈](https://code.claude.com/docs/zh-TW/model-config.md#fallback-model-chains)仍會在該拒絕發生時切換,而[啟動模型檢查](https://code.claude.com/docs/zh-TW/amazon-bedrock.md#startup-model-checks)仍會在啟動時改用備援。需要 Claude Code v2.1.285 或更新版本 |

261| `CLAUDE_CODE_DISABLE_MOUNTED_DRIVE_RM_PROMPT` | 設定為 `1` 可針對 `/Volumes/USB` 等路徑關閉[掛載磁碟機提示](https://code.claude.com/docs/zh-TW/permission-modes.md#the-mounted-drive-prompt)。[請在啟動 Claude Code 的環境中設定此變數](#set-variables-in-your-shell),因為 Claude Code [會在設定 `env` 區塊中忽略它](https://code.claude.com/docs/zh-TW/settings-reference#variables-claude-code-ignores-in-env)。需要 Claude Code v2.1.304 或更新版本 |265| `CLAUDE_CODE_DISABLE_MOUNTED_DRIVE_RM_PROMPT` | 設定為 `1` 可針對 `/Volumes/USB` 等路徑關閉[掛載磁碟機提示](https://code.claude.com/docs/zh-TW/permission-modes.md#the-mounted-drive-prompt)。[請在啟動 Claude Code 的環境中設定此變數](#set-variables-in-your-shell),因為 Claude Code [會在設定 `env` 區塊中忽略它](https://code.claude.com/docs/zh-TW/settings-reference#variables-claude-code-ignores-in-env)。需要 Claude Code v2.1.304 或更新版本 |


263| `CLAUDE_CODE_DISABLE_MOUSE_CLICKS` | 設定為 `1` 可在[全螢幕呈現](https://code.claude.com/docs/zh-TW/fullscreen.md)中停用點擊、拖曳與懸停處理,同時保留滑鼠滾輪捲動。當您希望滾輪捲動在 Claude Code 中運作,但不希望點擊會定位游標、展開工具輸出或開啟連結時使用。同時設定兩者時,`CLAUDE_CODE_DISABLE_MOUSE` 優先。需要 Claude Code v2.1.195 或更新版本 |267| `CLAUDE_CODE_DISABLE_MOUSE_CLICKS` | 設定為 `1` 可在[全螢幕呈現](https://code.claude.com/docs/zh-TW/fullscreen.md)中停用點擊、拖曳與懸停處理,同時保留滑鼠滾輪捲動。當您希望滾輪捲動在 Claude Code 中運作,但不希望點擊會定位游標、展開工具輸出或開啟連結時使用。同時設定兩者時,`CLAUDE_CODE_DISABLE_MOUSE` 優先。需要 Claude Code v2.1.195 或更新版本 |

264| `CLAUDE_CODE_DISABLE_MTLS_RELOAD_ON_STALE_CONNECTION` | 設定為 `1` 可阻止 Claude Code 在 API 請求因連線層級錯誤(例如連線重設或 TLS 交握錯誤)而失敗時重新讀取 [mTLS 用戶端憑證與金鑰](https://code.claude.com/docs/zh-TW/network-config.md#mtls-authentication)。停用重新載入後,Claude Code 只會在下次套用設定時或下次啟動時載入已輪替的檔案。需要 Claude Code v2.1.232 或更新版本 |268| `CLAUDE_CODE_DISABLE_MTLS_RELOAD_ON_STALE_CONNECTION` | 設定為 `1` 可阻止 Claude Code 在 API 請求因連線層級錯誤(例如連線重設或 TLS 交握錯誤)而失敗時重新讀取 [mTLS 用戶端憑證與金鑰](https://code.claude.com/docs/zh-TW/network-config.md#mtls-authentication)。停用重新載入後,Claude Code 只會在下次套用設定時或下次啟動時載入已輪替的檔案。需要 Claude Code v2.1.232 或更新版本 |

265| `CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC` | 設定為任何非空值(例如 `1`)可停用非必要的網路流量:自動更新、遙測、錯誤回報、`/feedback` 命令、[Claude 草擬的意見回饋](https://code.claude.com/docs/zh-TW/tools-reference.md#sendfeedback-tool-behavior)、版本資訊、[PR 與 MR 狀態徽章](https://code.claude.com/docs/zh-TW/interactive-mode.md#pr-review-status)檢查,以及[快速模式](https://code.claude.com/docs/zh-TW/fast-mode.md#use-fast-mode-behind-proxies-and-llm-gateways)檢查等可用性檢查。它也會停止[外掛 `command` 來源的背景執行](https://code.claude.com/docs/zh-TW/plugins/loading#when-a-command-source-re-runs);這些是本機命令而非網路流量,但因為它們可能觸發相依套件安裝,所以也會停止。**設定為 `0` 或 `false` 仍會停用這些流量**,這與大多數開關型變數不同;請取消設定此變數以重新允許。也會停用功能旗標擷取,使 [Remote Control](https://code.claude.com/docs/zh-TW/remote-control.md#requirements) 以及其他[需要功能旗標擷取的功能](#features-that-need-feature-flag-fetching)無法使用。官方外掛市集自動安裝不在涵蓋範圍內;請使用 `CLAUDE_CODE_DISABLE_OFFICIAL_MARKETPLACE_AUTOINSTALL` 停用。不會影響[閘道模型探索](https://code.claude.com/docs/zh-TW/llm-gateway-connect.md#add-gateway-models-to-the-model-picker),該功能有其自己的選擇加入機制 |269| `CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC` | 設定為任何非空值(例如 `1`)可停用非必要的網路流量:自動更新、遙測、錯誤回報、`/feedback` 命令、[Claude 草擬的意見回饋](https://code.claude.com/docs/zh-TW/tools-reference.md#sendfeedback-tool-behavior)、版本資訊、[PR 與 MR 狀態徽章](https://code.claude.com/docs/zh-TW/interactive-mode.md#pr-review-status)檢查,以及[快速模式](https://code.claude.com/docs/zh-TW/fast-mode.md#use-fast-mode-behind-proxies-and-llm-gateways)檢查等可用性檢查。它也會停止[外掛 `command` 來源的背景執行](https://code.claude.com/docs/zh-TW/plugins/loading#when-a-command-source-re-runs);這些是本機命令而非網路流量,但因為它們可能觸發相依套件安裝,所以也會停止。**設定為 `0` 或 `false` 仍會停用這些流量**,這與大多數開關型變數不同;請取消設定此變數以重新允許。也會停用功能旗標擷取,使 [Remote Control](https://code.claude.com/docs/zh-TW/remote-control.md#requirements) 以及其他[需要功能旗標擷取的功能](#features-that-need-feature-flag-fetching)無法使用。官方外掛市集自動安裝不在涵蓋範圍內;請使用 `CLAUDE_CODE_DISABLE_OFFICIAL_MARKETPLACE_AUTOINSTALL` 停用。不會影響[閘道模型探索](https://code.claude.com/docs/zh-TW/llm-gateway-connect.md#add-gateway-models-to-the-model-picker),該功能有其自己的選擇加入機制 |

266| `CLAUDE_CODE_DISABLE_NONSTREAMING_FALLBACK` | 設定為 `1` 可在串流請求於中途失敗時停用非串流備援。串流錯誤會改為傳遞至重試層。當代理伺服器或閘道導致備援產生重複的工具執行時很有用 |270| `CLAUDE_CODE_DISABLE_NONSTREAMING_FALLBACK` | 設為 `1` 以在串流請求於串流中途失敗時停用非串流備援。當代理伺服器或閘道導致備援產生重複的工具執行時很有用 |

267| `CLAUDE_CODE_DISABLE_NOTIFICATION_PRESENCE_CHECK` | 設定為 `1` 可讓 `PushNotification` 工具即使在您正在終端機中輸入或終端機處於焦點時,也傳送桌面通知。預設情況下,當工具偵測到最近的鍵盤活動或終端機焦點時,會同時略過桌面通知與[行動推播](https://code.claude.com/docs/zh-TW/remote-control.md#mobile-push-notifications)。此變數僅停用該本機檢查,因此當伺服器偵測到您處於活動狀態時,仍可抑制行動推播。需要 Claude Code v2.1.193 或更新版本 |271| `CLAUDE_CODE_DISABLE_NOTIFICATION_PRESENCE_CHECK` | 設定為 `1` 可讓 `PushNotification` 工具即使在您正在終端機中輸入或終端機處於焦點時,也傳送桌面通知。預設情況下,當工具偵測到最近的鍵盤活動或終端機焦點時,會同時略過桌面通知與[行動推播](https://code.claude.com/docs/zh-TW/remote-control.md#mobile-push-notifications)。此變數僅停用該本機檢查,因此當伺服器偵測到您處於活動狀態時,仍可抑制行動推播。需要 Claude Code v2.1.193 或更新版本 |

268| `CLAUDE_CODE_DISABLE_OFFICIAL_MARKETPLACE_AUTOINSTALL` | 設定為 `1` 可停用官方外掛市集的自動註冊。Claude Code 會在即將註冊市集時讀取此變數,通常是在電腦首次互動式啟動期間。若當時已設定此變數,Claude Code 會永久略過註冊。之後取消設定此變數並不會撤銷此略過。隨時執行 `claude plugin marketplace add anthropics/claude-plugins-official` 即可註冊市集 |272| `CLAUDE_CODE_DISABLE_OFFICIAL_MARKETPLACE_AUTOINSTALL` | 設定為 `1` 可停用官方外掛市集的自動註冊。Claude Code 會在即將註冊市集時讀取此變數,通常是在電腦首次互動式啟動期間。若當時已設定此變數,Claude Code 會永久略過註冊。之後取消設定此變數並不會撤銷此略過。隨時執行 `claude plugin marketplace add anthropics/claude-plugins-official` 即可註冊市集 |

269| `CLAUDE_CODE_DISABLE_PERMISSION_PROMPT_NOTIFY_HOOKS` | 在 Claude Code 將權限請求傳送至 Agent SDK 的 `canUseTool` 回呼的工作階段中(Claude Desktop 與 VS Code 擴充功能即是以此方式託管 Claude Code),設定為 `1` 可阻止 Claude Code 執行您的[針對未回答權限請求的 `Notification` hook](https://code.claude.com/docs/zh-TW/hooks#notification)。在終端機工作階段中沒有作用。需要 Claude Code v2.1.233 或更新版本 |273| `CLAUDE_CODE_DISABLE_PERMISSION_PROMPT_NOTIFY_HOOKS` | 在 Claude Code 將權限請求傳送至 Agent SDK 的 `canUseTool` 回呼的工作階段中(Claude Desktop 與 VS Code 擴充功能即是以此方式託管 Claude Code),設定為 `1` 可阻止 Claude Code 執行您的[針對未回答權限請求的 `Notification` hook](https://code.claude.com/docs/zh-TW/hooks#notification)。在終端機工作階段中沒有作用。需要 Claude Code v2.1.233 或更新版本 |


275| `CLAUDE_CODE_DISABLE_TERMINAL_TITLE` | 設為 `1` 可停用根據對話上下文自動更新終端機標題。這也會略過[產生工作階段標題](https://code.claude.com/docs/zh-TW/sessions.md#name-your-sessions)的背景小型/快速模型請求,並關閉[向終端機回報狀態](https://code.claude.com/docs/zh-TW/terminal-config.md#see-session-status-in-your-terminal) |279| `CLAUDE_CODE_DISABLE_TERMINAL_TITLE` | 設為 `1` 可停用根據對話上下文自動更新終端機標題。這也會略過[產生工作階段標題](https://code.claude.com/docs/zh-TW/sessions.md#name-your-sessions)的背景小型/快速模型請求,並關閉[向終端機回報狀態](https://code.claude.com/docs/zh-TW/terminal-config.md#see-session-status-in-your-terminal) |

276| `CLAUDE_CODE_DISABLE_THINKING` | 設定為 `1` 可從 API 請求中完全省略 `thinking` 參數。這是針對拒絕此參數的代理伺服器與閘道的相容性選項。在預設會思考的模型上,省略此參數代表模型仍可能思考。若要在 Anthropic API 上明確停用[延伸思考](https://platform.claude.com/docs/en/build-with-claude/extended-thinking),請改用 `MAX_THINKING_TOKENS=0`。兩個變數都無法在 Opus 5.5、Sonnet 5.5、Haiku 5.5 或 Fable 模型上關閉思考,這些模型無法關閉思考。在[第三方提供者](https://code.claude.com/docs/zh-TW/third-party-integrations.md)上,`MAX_THINKING_TOKENS=0` 同樣會省略此參數,因此兩個變數在那裡的行為相同 |280| `CLAUDE_CODE_DISABLE_THINKING` | 設定為 `1` 可從 API 請求中完全省略 `thinking` 參數。這是針對拒絕此參數的代理伺服器與閘道的相容性選項。在預設會思考的模型上,省略此參數代表模型仍可能思考。若要在 Anthropic API 上明確停用[延伸思考](https://platform.claude.com/docs/en/build-with-claude/extended-thinking),請改用 `MAX_THINKING_TOKENS=0`。兩個變數都無法在 Opus 5.5、Sonnet 5.5、Haiku 5.5 或 Fable 模型上關閉思考,這些模型無法關閉思考。在[第三方提供者](https://code.claude.com/docs/zh-TW/third-party-integrations.md)上,`MAX_THINKING_TOKENS=0` 同樣會省略此參數,因此兩個變數在那裡的行為相同 |

277| `CLAUDE_CODE_DISABLE_ULTRAREVIEW_TRUST_CHECK` | 設定為 `1` 可讓 [`claude ultrareview`](https://code.claude.com/docs/zh-TW/ultrareview#trust-the-folder-before-the-review-runs) 在您尚未信任的資料夾中、且無法詢問您是否信任時(例如在 CI 中),不以 `Error: Workspace not trusted` 結束。請在啟動 Claude Code 的環境中設定此變數,而非設定 `env` 區塊,且只在每次此類執行都從您信任的資料夾開始時才設定。能夠詢問的執行仍會詢問。需要 Claude Code v2.1.309 或更新版本 |281| `CLAUDE_CODE_DISABLE_ULTRAREVIEW_TRUST_CHECK` | 設定為 `1` 可讓 [`claude ultrareview`](https://code.claude.com/docs/zh-TW/ultrareview#trust-the-folder-before-the-review-runs) 在您尚未信任的資料夾中、且無法詢問您是否信任時(例如在 CI 中),不以 `Error: Workspace not trusted` 結束。請在啟動 Claude Code 的環境中設定此變數,而非設定 `env` 區塊,且只在每次此類執行都從您信任的資料夾開始時才設定。能夠詢問的執行仍會詢問。需要 Claude Code v2.1.309 或更新版本 |

282| `CLAUDE_CODE_DISABLE_ULTRATHINK` | 設為 `1` 可關閉 [`ultrathink`](https://code.claude.com/docs/zh-TW/model-config#use-ultrathink-for-one-off-deep-reasoning) 關鍵字。需要 Claude Code v2.1.316 或更新版本 |

278| `CLAUDE_CODE_DISABLE_UNKNOWN_MODEL_WINDOW_ENFORCEMENT` | 設定為 `1` 可在 Claude Code 無法辨識模型 ID(例如 [LLM 閘道](https://code.claude.com/docs/zh-TW/llm-gateway)別名)時略過主動[自動壓縮](https://code.claude.com/docs/zh-TW/costs.md#reduce-token-usage)。若未設定此變數,Claude Code 會在其為該 ID 假設的上下文視窗處進行壓縮。`CLAUDE_CODE_MAX_CONTEXT_TOKENS` 可改為修正假設的視窗;關於各變數的適用時機,請參閱[修正閘道或自訂模型 ID 的視窗](https://code.claude.com/docs/zh-TW/model-config.md#correct-the-window-for-a-gateway-or-custom-model-id)。需要 Claude Code v2.1.223 或更新版本 |283| `CLAUDE_CODE_DISABLE_UNKNOWN_MODEL_WINDOW_ENFORCEMENT` | 設定為 `1` 可在 Claude Code 無法辨識模型 ID(例如 [LLM 閘道](https://code.claude.com/docs/zh-TW/llm-gateway)別名)時略過主動[自動壓縮](https://code.claude.com/docs/zh-TW/costs.md#reduce-token-usage)。若未設定此變數,Claude Code 會在其為該 ID 假設的上下文視窗處進行壓縮。`CLAUDE_CODE_MAX_CONTEXT_TOKENS` 可改為修正假設的視窗;關於各變數的適用時機,請參閱[修正閘道或自訂模型 ID 的視窗](https://code.claude.com/docs/zh-TW/model-config.md#correct-the-window-for-a-gateway-or-custom-model-id)。需要 Claude Code v2.1.223 或更新版本 |

279| `CLAUDE_CODE_DISABLE_VIRTUAL_SCROLL` | 設定為 `1` 可在[全螢幕呈現](https://code.claude.com/docs/zh-TW/fullscreen.md)中停用虛擬捲動,並呈現逐字稿中的每則訊息。若在全螢幕模式中捲動時,應顯示訊息的地方出現空白區域,請使用此設定 |284| `CLAUDE_CODE_DISABLE_VIRTUAL_SCROLL` | 設定為 `1` 可在[全螢幕呈現](https://code.claude.com/docs/zh-TW/fullscreen.md)中停用虛擬捲動,並呈現逐字稿中的每則訊息。若在全螢幕模式中捲動時,應顯示訊息的地方出現空白區域,請使用此設定 |

280| `CLAUDE_CODE_DISABLE_WEB_FETCH` | 設定為 `1` 可關閉 [WebFetch](https://code.claude.com/docs/zh-TW/tools-reference.md#webfetch-tool-behavior) 工具。[WebSearch](https://code.claude.com/docs/zh-TW/tools-reference.md#websearch-tool-behavior) 工具仍可使用。需要 Claude Code v2.1.285 或更新版本 |285| `CLAUDE_CODE_DISABLE_WEB_FETCH` | 設定為 `1` 可關閉 [WebFetch](https://code.claude.com/docs/zh-TW/tools-reference.md#webfetch-tool-behavior) 工具。[WebSearch](https://code.claude.com/docs/zh-TW/tools-reference.md#websearch-tool-behavior) 工具仍可使用。需要 Claude Code v2.1.285 或更新版本 |


356| `CLAUDE_CODE_PERFORCE_MODE` | 設為 `1` 以啟用可感知 Perforce 的寫入保護。設定後,若目標檔案缺少擁有者寫入位元,Edit、Write 與 NotebookEdit 會失敗並提示 `p4 edit <file>`;Perforce 會清除已同步檔案的此位元,直到 `p4 edit` 開啟它們為止。這可防止 Claude Code 繞過 Perforce 變更追蹤 |361| `CLAUDE_CODE_PERFORCE_MODE` | 設為 `1` 以啟用可感知 Perforce 的寫入保護。設定後,若目標檔案缺少擁有者寫入位元,Edit、Write 與 NotebookEdit 會失敗並提示 `p4 edit <file>`;Perforce 會清除已同步檔案的此位元,直到 `p4 edit` 開啟它們為止。這可防止 Claude Code 繞過 Perforce 變更追蹤 |

357| `CLAUDE_CODE_PLUGIN_CACHE_DIR` | 覆寫外掛根目錄。儘管名稱如此,此變數設定的是上層目錄,而非快取本身:市集與外掛快取位於此路徑下的子目錄中。預設為 `~/.claude/plugins` |362| `CLAUDE_CODE_PLUGIN_CACHE_DIR` | 覆寫外掛根目錄。儘管名稱如此,此變數設定的是上層目錄,而非快取本身:市集與外掛快取位於此路徑下的子目錄中。預設為 `~/.claude/plugins` |

358| `CLAUDE_CODE_PLUGIN_DIRS` | 要為工作階段載入的外掛目錄,每個目錄的載入方式與 [`--plugin-dir`](https://code.claude.com/docs/zh-TW/plugins/cli-reference#flags-that-load-a-plugin-for-one-session) 旗標相同。在 Unix 上以 `:` 分隔多個路徑,在 Windows 上以 `;` 分隔。請以絕對路徑提供每個路徑,或以 `~` 開頭,因為 Claude Code 會略過相對路徑。需要 Claude Code v2.1.280 或更新版本。請參閱[為單一工作階段載入外掛](https://code.claude.com/docs/zh-TW/plugins/create.md#load-a-directory-or-archive-for-one-session) |363| `CLAUDE_CODE_PLUGIN_DIRS` | 要為工作階段載入的外掛目錄,每個目錄的載入方式與 [`--plugin-dir`](https://code.claude.com/docs/zh-TW/plugins/cli-reference#flags-that-load-a-plugin-for-one-session) 旗標相同。在 Unix 上以 `:` 分隔多個路徑,在 Windows 上以 `;` 分隔。請以絕對路徑提供每個路徑,或以 `~` 開頭,因為 Claude Code 會略過相對路徑。需要 Claude Code v2.1.280 或更新版本。請參閱[為單一工作階段載入外掛](https://code.claude.com/docs/zh-TW/plugins/create.md#load-a-directory-or-archive-for-one-session) |

359| `CLAUDE_CODE_PLUGIN_DIR_WATCH` | 控制 Claude Code 是否在 [mod](https://code.claude.com/docs/zh-TW/plugins/mods/overview.md) 的檔案變更時重新載入該 mod。重新載入適用於您使用 `--plugin-dir` 從目錄載入的 mod,且在互動式工作階段中預設為開啟。設為 `1` 可在非互動式工作階段中也開啟,或設為 `0` 在所有工作階段中關閉。需要 Claude Code v2.1.287 或更新版本。請參閱 [mod 設定與環境變數](https://code.claude.com/docs/zh-TW/plugins/mods/reference.md#settings-and-environment-variables) |364| `CLAUDE_CODE_PLUGIN_DIR_WATCH` | 控制 [mod](https://code.claude.com/docs/zh-TW/plugins/mods/overview.md) 在其檔案變更時是否重新載入。預設情況下,[skills 目錄](https://code.claude.com/docs/zh-TW/plugins/org.md#keep-skills-directory-plugins-loading)中的 mod 會在任何超過一個提示詞的工作階段中重新載入,包括[非互動](https://code.claude.com/docs/zh-TW/headless.md)工作階段。`--plugin-dir` 目錄中的 mod 僅在互動式終端機工作階段中重新載入。設為 `1` 可讓它們像 skills 目錄中的 mod 一樣重新載入,設為 `0` 則在所有地方關閉重新載入。需要 Claude Code v2.1.287 或更新版本 |

360| `CLAUDE_CODE_PLUGIN_GIT_TIMEOUT_MS` | 複製或重新整理外掛市集的逾時時間(毫秒)(預設:120000)。對於大型儲存庫或緩慢的網路連線,請調高此值。請參閱 [Git clone timed out](https://code.claude.com/docs/zh-TW/plugins/troubleshooting.md#git-clone-timed-out-after-120s) |365| `CLAUDE_CODE_PLUGIN_GIT_TIMEOUT_MS` | 複製或重新整理外掛市集的逾時時間(毫秒)(預設:120000)。對於大型儲存庫或緩慢的網路連線,請調高此值。請參閱 [Git clone timed out](https://code.claude.com/docs/zh-TW/plugins/troubleshooting.md#git-clone-timed-out-after-120s) |

361| `CLAUDE_CODE_PLUGIN_KEEP_MARKETPLACE_ON_FAILURE` | 設為 `1` 可在市集重新整理無法連線至遠端或無法通過遠端身分驗證時,略過重新複製的嘗試並繼續使用現有的市集 checkout。適用於離線或氣隙隔離環境,在這類環境中重新複製也會以相同方式失敗。請參閱[市集更新在離線環境中失敗](https://code.claude.com/docs/zh-TW/plugins/troubleshooting.md#marketplace-updates-keep-failing-offline) |366| `CLAUDE_CODE_PLUGIN_KEEP_MARKETPLACE_ON_FAILURE` | 設為 `1` 可在市集重新整理無法連線至遠端或無法通過遠端身分驗證時,略過重新複製的嘗試並繼續使用現有的市集 checkout。適用於離線或氣隙隔離環境,在這類環境中重新複製也會以相同方式失敗。請參閱[市集更新在離線環境中失敗](https://code.claude.com/docs/zh-TW/plugins/troubleshooting.md#marketplace-updates-keep-failing-offline) |

362| `CLAUDE_CODE_PLUGIN_PREFER_HTTPS` | 設為 `1` 可透過 HTTPS 而非 SSH 複製 GitHub `owner/repo` 簡寫來源。適用於外掛安裝與更新,以及 `/plugin marketplace add` 與 `update`。適用於 CI 執行器、容器,或任何未為 `github.com` 設定 SSH 金鑰的環境 |367| `CLAUDE_CODE_PLUGIN_PREFER_HTTPS` | 設為 `1` 可透過 HTTPS 而非 SSH 複製 GitHub `owner/repo` 簡寫來源。適用於外掛安裝與更新,以及 `/plugin marketplace add` 與 `update`。適用於 CI 執行器、容器,或任何未為 `github.com` 設定 SSH 金鑰的環境 |


391| `CLAUDE_CODE_SIMPLE` | 設為 `1` 以最精簡的系統提示詞執行,且僅提供 Bash、檔案讀取與檔案編輯工具。來自 `--mcp-config` 的 MCP 工具仍可使用。停用 hook、skill、自訂命令、subagent、已安裝外掛、MCP 伺服器、自動記憶與 CLAUDE.md 的自動探索。您以 `--add-dir` 傳遞的目錄中的 skill 仍會載入。不會讀取 OAuth token 與鑰匙圈憑證,因此 Anthropic 身分驗證必須來自 `ANTHROPIC_API_KEY` 或 `--settings` 中的 `apiKeyHelper`。等同於傳遞 [`--bare`](https://code.claude.com/docs/zh-TW/headless#start-faster-with-bare-mode) |396| `CLAUDE_CODE_SIMPLE` | 設為 `1` 以最精簡的系統提示詞執行,且僅提供 Bash、檔案讀取與檔案編輯工具。來自 `--mcp-config` 的 MCP 工具仍可使用。停用 hook、skill、自訂命令、subagent、已安裝外掛、MCP 伺服器、自動記憶與 CLAUDE.md 的自動探索。您以 `--add-dir` 傳遞的目錄中的 skill 仍會載入。不會讀取 OAuth token 與鑰匙圈憑證,因此 Anthropic 身分驗證必須來自 `ANTHROPIC_API_KEY` 或 `--settings` 中的 `apiKeyHelper`。等同於傳遞 [`--bare`](https://code.claude.com/docs/zh-TW/headless#start-faster-with-bare-mode) |

392| `CLAUDE_CODE_SIMPLE_SYSTEM_PROMPT` | 在 Claude Code 的完整系統提示詞與工具描述經過縮減的較短提示詞之間選擇。未設定時,Haiku 4.5、Sonnet 5、Opus 4.7 以及這些系列中的較早模型預設使用完整提示詞,較新的模型則使用較短的提示詞。設為 `1` 可在任何模型上使用較短的提示詞。設為 `0`、`false`、`no` 或 `off` 可在任何模型上使用完整提示詞,即使實驗或伺服器設定原本會選擇較短的提示詞也是如此。兩種提示詞都保留完整的工具集、hook、MCP 伺服器與 CLAUDE.md 探索 |397| `CLAUDE_CODE_SIMPLE_SYSTEM_PROMPT` | 在 Claude Code 的完整系統提示詞與工具描述經過縮減的較短提示詞之間選擇。未設定時,Haiku 4.5、Sonnet 5、Opus 4.7 以及這些系列中的較早模型預設使用完整提示詞,較新的模型則使用較短的提示詞。設為 `1` 可在任何模型上使用較短的提示詞。設為 `0`、`false`、`no` 或 `off` 可在任何模型上使用完整提示詞,即使實驗或伺服器設定原本會選擇較短的提示詞也是如此。兩種提示詞都保留完整的工具集、hook、MCP 伺服器與 CLAUDE.md 探索 |

393| `CLAUDE_CODE_SKIP_ANTHROPIC_AWS_AUTH` | 略過 [Claude Platform on AWS](https://code.claude.com/docs/zh-TW/claude-platform-on-aws.md) 的用戶端身分驗證,適用於自行簽署請求的閘道 |398| `CLAUDE_CODE_SKIP_ANTHROPIC_AWS_AUTH` | 略過 [Claude Platform on AWS](https://code.claude.com/docs/zh-TW/claude-platform-on-aws.md) 的用戶端身分驗證,適用於自行簽署請求的閘道 |

399| `CLAUDE_CODE_SKIP_ANTHROPIC_GOOGLE_CLOUD_AUTH` | 針對會自行附加憑證的閘道,略過 [Claude Models on Google Cloud (Anthropic managed)](https://code.claude.com/docs/zh-TW/claude-models-on-google-cloud-anthropic-managed.md) 的 Google Cloud 身分驗證 |

394| `CLAUDE_CODE_SKIP_AWS_CRED_CACHE` | 設為 `1` 可關閉從 AWS 預設憑證提供者鏈解析之憑證的程序內快取,讓 Claude Code 在每個 API 請求時都解析該鏈。關閉快取時,以 SSO 為基礎的設定檔會在每個請求時向 IAM Identity Center 請求憑證。請參閱[憑證快取與解析逾時](https://code.claude.com/docs/zh-TW/amazon-bedrock.md#credential-caching-and-resolution-timeout)。需要 Claude Code v2.1.207 或更新版本 |400| `CLAUDE_CODE_SKIP_AWS_CRED_CACHE` | 設為 `1` 可關閉從 AWS 預設憑證提供者鏈解析之憑證的程序內快取,讓 Claude Code 在每個 API 請求時都解析該鏈。關閉快取時,以 SSO 為基礎的設定檔會在每個請求時向 IAM Identity Center 請求憑證。請參閱[憑證快取與解析逾時](https://code.claude.com/docs/zh-TW/amazon-bedrock.md#credential-caching-and-resolution-timeout)。需要 Claude Code v2.1.207 或更新版本 |

395| `CLAUDE_CODE_SKIP_BEDROCK_AUTH` | 略過 Amazon Bedrock 的 AWS 身分驗證(例如使用 LLM 閘道時) |401| `CLAUDE_CODE_SKIP_BEDROCK_AUTH` | 略過 Amazon Bedrock 的 AWS 身分驗證(例如使用 LLM 閘道時) |

396| `CLAUDE_CODE_SKIP_FAST_MODE_NETWORK_ERRORS` | 設為 `1` 可將失敗的[快速模式](https://code.claude.com/docs/zh-TW/fast-mode.md#use-fast-mode-behind-proxies-and-llm-gateways)可用性檢查視為可用,適用於封鎖該檢查對 `api.anthropic.com` 之直接請求的網路。Claude Code 仍會遵循「disabled by your organization」回應 |402| `CLAUDE_CODE_SKIP_FAST_MODE_NETWORK_ERRORS` | 設為 `1` 可將失敗的[快速模式](https://code.claude.com/docs/zh-TW/fast-mode.md#use-fast-mode-behind-proxies-and-llm-gateways)可用性檢查視為可用,適用於封鎖該檢查對 `api.anthropic.com` 之直接請求的網路。Claude Code 仍會遵循「disabled by your organization」回應 |


420| `CLAUDE_CODE_TRANSCRIPT_LOCAL_GC` | 設定為 `1` 以限制長時間 `-p` 或 Agent SDK 工作階段的[逐字稿檔案](https://code.claude.com/docs/zh-TW/sessions.md#where-transcripts-are-stored)成長的大小。每次上下文壓縮後,一旦檔案大於 5 MB,Claude Code 就會移除該次上下文壓縮之前的歷史記錄。在 v2.1.296 或更新版本中,若移除該歷史記錄只能使檔案縮小不到 10%,檔案會保持原樣。無論檔案是否經過修剪,繼續工作階段都會還原相同的對話。請在您啟動 Claude Code 的環境中設定此變數,因為設定中的 `env` 區塊無法開啟它。需要 Claude Code v2.1.287 或更新版本 |426| `CLAUDE_CODE_TRANSCRIPT_LOCAL_GC` | 設定為 `1` 以限制長時間 `-p` 或 Agent SDK 工作階段的[逐字稿檔案](https://code.claude.com/docs/zh-TW/sessions.md#where-transcripts-are-stored)成長的大小。每次上下文壓縮後,一旦檔案大於 5 MB,Claude Code 就會移除該次上下文壓縮之前的歷史記錄。在 v2.1.296 或更新版本中,若移除該歷史記錄只能使檔案縮小不到 10%,檔案會保持原樣。無論檔案是否經過修剪,繼續工作階段都會還原相同的對話。請在您啟動 Claude Code 的環境中設定此變數,因為設定中的 `env` 區塊無法開啟它。需要 Claude Code v2.1.287 或更新版本 |

421| `CLAUDE_CODE_USER_DIALOG_TIMEOUT_MS` | Claude Code 取消轉送至遠端用戶端(例如 [Remote Control](https://code.claude.com/docs/zh-TW/remote-control.md) 或 SDK 主機)的對話框,或[被暫留的跨工作階段訊息](https://code.claude.com/docs/zh-TW/cross-session-messaging.md#control-inbound-messages)之核准對話框前的期限(毫秒);權限提示與 `AskUserQuestion` 問題使用各自的流程,不受此變數控制。在 Claude Code v2.1.236 或更新版本中,它也會限制可能在無人看管狀態下執行的工作階段中,於工作階段中途出現的 [Fable 用量點數同意提示](https://code.claude.com/docs/zh-TW/model-config.md#fable-and-usage-credits)。[控制傳入訊息](https://code.claude.com/docs/zh-TW/cross-session-messaging.md#control-inbound-messages)與[非互動工作階段](https://code.claude.com/docs/zh-TW/cross-session-messaging.md#non-interactive-sessions)涵蓋完整的暫留訊息到期規則,包括期限不適用的情況。覆寫 [`dialogExpiry`](https://code.claude.com/docs/zh-TW/settings-reference#dialogexpiry) 設定。`0` 或負值會停用期限。在[專案與本機設定](https://code.claude.com/docs/zh-TW/settings-reference.md#variables-claude-code-ignores-in-env)中會被忽略 |427| `CLAUDE_CODE_USER_DIALOG_TIMEOUT_MS` | Claude Code 取消轉送至遠端用戶端(例如 [Remote Control](https://code.claude.com/docs/zh-TW/remote-control.md) 或 SDK 主機)的對話框,或[被暫留的跨工作階段訊息](https://code.claude.com/docs/zh-TW/cross-session-messaging.md#control-inbound-messages)之核准對話框前的期限(毫秒);權限提示與 `AskUserQuestion` 問題使用各自的流程,不受此變數控制。在 Claude Code v2.1.236 或更新版本中,它也會限制可能在無人看管狀態下執行的工作階段中,於工作階段中途出現的 [Fable 用量點數同意提示](https://code.claude.com/docs/zh-TW/model-config.md#fable-and-usage-credits)。[控制傳入訊息](https://code.claude.com/docs/zh-TW/cross-session-messaging.md#control-inbound-messages)與[非互動工作階段](https://code.claude.com/docs/zh-TW/cross-session-messaging.md#non-interactive-sessions)涵蓋完整的暫留訊息到期規則,包括期限不適用的情況。覆寫 [`dialogExpiry`](https://code.claude.com/docs/zh-TW/settings-reference#dialogexpiry) 設定。`0` 或負值會停用期限。在[專案與本機設定](https://code.claude.com/docs/zh-TW/settings-reference.md#variables-claude-code-ignores-in-env)中會被忽略 |

422| `CLAUDE_CODE_USE_ANTHROPIC_AWS` | 使用 [Claude Platform on AWS](https://code.claude.com/docs/zh-TW/claude-platform-on-aws.md) |428| `CLAUDE_CODE_USE_ANTHROPIC_AWS` | 使用 [Claude Platform on AWS](https://code.claude.com/docs/zh-TW/claude-platform-on-aws.md) |

429| `CLAUDE_CODE_USE_ANTHROPIC_GOOGLE_CLOUD` | 使用 [Claude Models on Google Cloud (Anthropic managed)](https://code.claude.com/docs/zh-TW/claude-models-on-google-cloud-anthropic-managed.md) |

423| `CLAUDE_CODE_USE_BEDROCK` | 使用 [Amazon Bedrock](https://code.claude.com/docs/zh-TW/amazon-bedrock.md) |430| `CLAUDE_CODE_USE_BEDROCK` | 使用 [Amazon Bedrock](https://code.claude.com/docs/zh-TW/amazon-bedrock.md) |

424| `CLAUDE_CODE_USE_FOUNDRY` | 使用 [Microsoft Foundry](https://code.claude.com/docs/zh-TW/microsoft-foundry.md) |431| `CLAUDE_CODE_USE_FOUNDRY` | 使用 [Microsoft Foundry](https://code.claude.com/docs/zh-TW/microsoft-foundry.md) |

425| `CLAUDE_CODE_USE_MANTLE` | 使用 Amazon Bedrock [Mantle 端點](https://code.claude.com/docs/zh-TW/amazon-bedrock.md#use-the-mantle-endpoint) |432| `CLAUDE_CODE_USE_MANTLE` | 使用 Amazon Bedrock [Mantle 端點](https://code.claude.com/docs/zh-TW/amazon-bedrock.md#use-the-mantle-endpoint) |


586* 在 Pro、Max 和 Ultra 方案上執行 [`/restart`](https://code.claude.com/docs/zh-TW/commands)593* 在 Pro、Max 和 Ultra 方案上執行 [`/restart`](https://code.claude.com/docs/zh-TW/commands)

587* 將您的 claude.ai 帳戶所啟用的 [skills](https://code.claude.com/docs/zh-TW/skills.md#where-synced-skills-load) 和[外掛](https://code.claude.com/docs/zh-TW/plugins/loading.md#synced-plugins)同步到您的終端機工作階段594* 將您的 claude.ai 帳戶所啟用的 [skills](https://code.claude.com/docs/zh-TW/skills.md#where-synced-skills-load) 和[外掛](https://code.claude.com/docs/zh-TW/plugins/loading.md#synced-plugins)同步到您的終端機工作階段

588* 啟用 [You should know mod](https://code.claude.com/docs/zh-TW/interactive-mode.md#you-should-know-suggestions)595* 啟用 [You should know mod](https://code.claude.com/docs/zh-TW/interactive-mode.md#you-should-know-suggestions)

589* 使用 [advisor 工具](https://code.claude.com/docs/zh-TW/advisor.md#requirements),但在 Claude Platform on AWS 上使用 Claude Code v2.1.300 或更新版本時除外596* 使用 [advisor 工具](https://code.claude.com/docs/zh-TW/advisor.md#requirements),但在 Claude Platform on AWS 或 [Claude Models on Google Cloud (Anthropic managed)](https://code.claude.com/docs/zh-TW/feature-availability.md#availability-by-model-provider) 上使用 Claude Code v2.1.300 或更新版本時除外

590* 使用 [MCP tasks](https://code.claude.com/docs/zh-TW/mcp.md#mcp-tasks-that-run-on-the-server)597* 使用 [MCP tasks](https://code.claude.com/docs/zh-TW/mcp.md#mcp-tasks-that-run-on-the-server)

591* 啟用 [Code Mode](https://code.claude.com/docs/zh-TW/code-mode.md#requirements)598* 啟用 [Code Mode](https://code.claude.com/docs/zh-TW/code-mode.md#requirements)

592* 閱讀或回覆 [artifact 上的留言](https://code.claude.com/docs/zh-TW/artifacts.md#collect-comments-on-an-artifact)599* 閱讀或回覆 [artifact 上的留言](https://code.claude.com/docs/zh-TW/artifacts.md#collect-comments-on-an-artifact)

errors.md +374 −362

Details

46| `Agent terminated early due to an API error` | [伺服器錯誤](#agent-terminated-early-due-to-an-api-error) |46| `Agent terminated early due to an API error` | [伺服器錯誤](#agent-terminated-early-due-to-an-api-error) |

47| `You've hit your session limit` / `You've hit your weekly limit` / `You've hit your Opus limit` / `You've hit your Sonnet limit` | [用量上限](#youve-hit-your-session-limit) |47| `You've hit your session limit` / `You've hit your weekly limit` / `You've hit your Opus limit` / `You've hit your Sonnet limit` | [用量上限](#youve-hit-your-session-limit) |

48| `Usage credits required for 1M context` | [用量上限](#usage-credits-required-for-1m-context) |48| `Usage credits required for 1M context` | [用量上限](#usage-credits-required-for-1m-context) |

49| `the prompt to confirm went unanswered — nothing was sent` | [用量上限](#the-prompt-to-confirm-went-unanswered) |49| `the prompt to confirm went unanswered · nothing was sent`,自 v2.1.324 起 | [用量上限](#the-prompt-to-confirm-went-unanswered) |

50| `Claude stopped here · send a message to be asked again` | [用量上限](#the-prompt-to-confirm-went-unanswered) |

50| `Server is temporarily limiting requests` | [用量上限](#server-is-temporarily-limiting-requests) |51| `Server is temporarily limiting requests` | [用量上限](#server-is-temporarily-limiting-requests) |

51| `Request rejected (429)` | [用量上限](#request-rejected-429) |52| `Request rejected (429)` | [用量上限](#request-rejected-429) |

52| `Credit balance is too low` | [用量上限](#credit-balance-is-too-low) |53| `Credit balance is too low` | [用量上限](#credit-balance-is-too-low) |


84| `Remote Control stopped — the app running this session is now signed in to a different Claude account` | [身分驗證](#remote-control-stopped-because-the-app-running-the-session-signed-out-or-switched-accounts) |85| `Remote Control stopped — the app running this session is now signed in to a different Claude account` | [身分驗證](#remote-control-stopped-because-the-app-running-the-session-signed-out-or-switched-accounts) |

85| `Remote Control stopped — the app running this session is signed out of Claude` | [身分驗證](#remote-control-stopped-because-the-app-running-the-session-signed-out-or-switched-accounts) |86| `Remote Control stopped — the app running this session is signed out of Claude` | [身分驗證](#remote-control-stopped-because-the-app-running-the-session-signed-out-or-switched-accounts) |

86| `Couldn't verify your organization's policy for remote control` | [疑難排解 Remote Control](https://code.claude.com/docs/zh-TW/remote-control.md#couldnt-verify-your-organizations-policy-for-remote-control) |87| `Couldn't verify your organization's policy for remote control` | [疑難排解 Remote Control](https://code.claude.com/docs/zh-TW/remote-control.md#couldnt-verify-your-organizations-policy-for-remote-control) |

88| `Remote Control didn't finish connecting` | [啟動 Remote Control 工作階段](https://code.claude.com/docs/zh-TW/remote-control.md#start-a-remote-control-session) |

87| `Remote Control is disabled by your organization's policy` | [疑難排解 Remote Control](https://code.claude.com/docs/zh-TW/remote-control.md#remote-control-is-disabled-by-your-organizations-policy) |89| `Remote Control is disabled by your organization's policy` | [疑難排解 Remote Control](https://code.claude.com/docs/zh-TW/remote-control.md#remote-control-is-disabled-by-your-organizations-policy) |

88| `Remote Control was turned off by your organization's policy` | [疑難排解 Remote Control](https://code.claude.com/docs/zh-TW/remote-control.md#remote-control-was-turned-off-by-your-organizations-policy) |90| `Remote Control was turned off by your organization's policy` | [疑難排解 Remote Control](https://code.claude.com/docs/zh-TW/remote-control.md#remote-control-was-turned-off-by-your-organizations-policy) |

89| `Session failed: working folder not found:` | [Remote Control 疑難排解](https://code.claude.com/docs/zh-TW/remote-control.md#working-folder-not-found) |91| `Session failed: working folder not found:` | [Remote Control 疑難排解](https://code.claude.com/docs/zh-TW/remote-control.md#working-folder-not-found) |

90| `The program file this Remote Control started from is gone` | [Remote Control 疑難排解](https://code.claude.com/docs/zh-TW/remote-control.md#program-file-is-gone) |92| `The program file this Remote Control started from is gone` | [Remote Control 疑難排解](https://code.claude.com/docs/zh-TW/remote-control.md#program-file-is-gone) |

91| `Session failed: spawn error:`,後接 `ENOENT` 訊息 | [Remote Control 疑難排解](https://code.claude.com/docs/zh-TW/remote-control.md#program-file-is-gone) |93| `Session failed: spawn error:`,後接 `ENOENT` 訊息 | [Remote Control 疑難排解](https://code.claude.com/docs/zh-TW/remote-control.md#program-file-is-gone) |

94| `Remote Control disconnected:` 後接提及 `share link` 的原因 | [Remote Control](https://code.claude.com/docs/zh-TW/remote-control.md#what-connected-devices-see) |

92| `OAuth token revoked` / `OAuth token has expired` | [身分驗證](#oauth-token-revoked-or-expired) |95| `OAuth token revoked` / `OAuth token has expired` | [身分驗證](#oauth-token-revoked-or-expired) |

93| `Failed to authenticate: OAuth token revoked` | [身分驗證](#oauth-token-revoked-or-expired) |96| `Failed to authenticate: OAuth token revoked` | [身分驗證](#oauth-token-revoked-or-expired) |

94| `Your account does not have access to Claude. Please login again or contact your administrator.` | [身分驗證](#oauth-token-revoked-or-expired) |97| `Your account does not have access to Claude. Please login again or contact your administrator.` | [身分驗證](#oauth-token-revoked-or-expired) |


141| `Unable to connect to API` | [網路](#unable-to-connect-to-api) |144| `Unable to connect to API` | [網路](#unable-to-connect-to-api) |

142| `Connection refused —` / `Can't reach the API server —` / `No internet route —` / `Couldn't connect through your proxy` / `Connection dropped`,各以括號中的錯誤代碼結尾 | [網路](#unable-to-connect-to-api) |145| `Connection refused —` / `Can't reach the API server —` / `No internet route —` / `Couldn't connect through your proxy` / `Connection dropped`,各以括號中的錯誤代碼結尾 | [網路](#unable-to-connect-to-api) |

143| 設定期間出現的 `Unable to connect to Anthropic services` | [網路](#unable-to-connect-to-anthropic-services) |146| 設定期間出現的 `Unable to connect to Anthropic services` | [網路](#unable-to-connect-to-anthropic-services) |

147| `Unable to fetch your privacy settings at this time` | [claude.ai 上的隱私設定](https://claude.ai/settings/data-privacy-controls) |

144| `Socket is closed` | [網路](#socket-is-closed) |148| `Socket is closed` | [網路](#socket-is-closed) |

145| `Waiting for API response · will retry in` | [自動重試](#automatic-retries),或如果持續發生,則為[網路](#unable-to-connect-to-api) |149| `Waiting for API response · will retry in` | [自動重試](#automatic-retries),或如果持續發生,則為[網路](#unable-to-connect-to-api) |

146| `API returned an empty or malformed response` | [網路](#api-returned-an-empty-or-malformed-response) |150| `API returned an empty or malformed response` | [網路](#api-returned-an-empty-or-malformed-response) |

147| `Streaming response ended before any complete data was received` | [網路](#streaming-response-ended-before-any-complete-data-was-received) |151| `Streaming response ended before any complete data was received` | [網路](#streaming-response-ended-before-any-complete-data-was-received) |

148| `Bedrock streaming response has content-type "..."; expected "application/vnd.amazon.eventstream"` | [網路](#bedrock-streaming-response-has-an-unexpected-content-type) |152| `Bedrock streaming response has content-type "..."; expected "application/vnd.amazon.eventstream"` | [網路](#bedrock-streaming-response-has-an-unexpected-content-type) |

153| `Claude Code used only the certificates that it could read in full from the NODE_EXTRA_CA_CERTS file` / `Claude Code ignored all of the NODE_EXTRA_CA_CERTS file: it holds no certificate that Claude Code can read` | [自訂 CA 憑證](https://code.claude.com/docs/zh-TW/network-config.md#custom-ca-certificates) |

149| `SSL certificate verification failed` | [網路](#ssl-certificate-errors) |154| `SSL certificate verification failed` | [網路](#ssl-certificate-errors) |

150| 登入或啟動期間出現的 `SSL certificate error (...)` | [網路](#ssl-certificate-errors) |155| 登入或啟動期間出現的 `SSL certificate error (...)` | [網路](#ssl-certificate-errors) |

151| `unable to get local issuer certificate` | [網路](#ssl-certificate-errors) |156| `unable to get local issuer certificate` | [網路](#ssl-certificate-errors) |


276| ``Couldn't run `<command>` for <name>. A file named HEAD or .git in this folder or one above it may not be yours``,來自注入動態上下文的 skill | [注入命令的權限檢查](https://code.claude.com/docs/zh-TW/skills.md#permission-checks-on-injected-commands) |281| ``Couldn't run `<command>` for <name>. A file named HEAD or .git in this folder or one above it may not be yours``,來自注入動態上下文的 skill | [注入命令的權限檢查](https://code.claude.com/docs/zh-TW/skills.md#permission-checks-on-injected-commands) |

277| ``Skill <name> requires bash (`shell: bash` in frontmatter) but Git Bash was not found`` | [命令列錯誤](#security-review-fails-without-origin-head) |282| ``Skill <name> requires bash (`shell: bash` in frontmatter) but Git Bash was not found`` | [命令列錯誤](#security-review-fails-without-origin-head) |

278| `No shell command in <name> was run, because the <tool> tool does not accept one of them` | [命令列錯誤](#no-shell-command-was-run) |283| `No shell command in <name> was run, because the <tool> tool does not accept one of them` | [命令列錯誤](#no-shell-command-was-run) |

284| `This skill, command or hook and the arguments filled into it add up to more than 4,000,000 characters` | [命令列錯誤](#skill-command-or-hook-over-the-4000000-character-limit) |

279| `Input must be provided either through stdin or as a prompt argument when using --print` | [命令列錯誤](#input-must-be-provided-when-using-print) |285| `Input must be provided either through stdin or as a prompt argument when using --print` | [命令列錯誤](#input-must-be-provided-when-using-print) |

280| `Claude Code can't read the keyboard here: stdin is not a terminal` | [命令列錯誤](#claude-code-cant-read-the-keyboard-here) |286| `Claude Code can't read the keyboard here: stdin is not a terminal` | [命令列錯誤](#claude-code-cant-read-the-keyboard-here) |

281| `Error: Input contained only whitespace` | [命令列錯誤](#input-contained-only-whitespace) |287| `Error: Input contained only whitespace` | [命令列錯誤](#input-contained-only-whitespace) |


289| `Your connected GitHub account can't see <owner>/<repo>` | [命令列錯誤](#your-connected-github-account-cant-see-the-repository) |295| `Your connected GitHub account can't see <owner>/<repo>` | [命令列錯誤](#your-connected-github-account-cant-see-the-repository) |

290| `The GitHub App preflight failed transiently (network or service hiccup) — retry in a moment to start from GitHub instead` | [命令列錯誤](#the-github-app-preflight-failed-transiently) |296| `The GitHub App preflight failed transiently (network or service hiccup) — retry in a moment to start from GitHub instead` | [命令列錯誤](#the-github-app-preflight-failed-transiently) |

291| 帶有 `the upload cannot follow that setting` 的 `Not uploading this working tree` | [命令列錯誤](#the-repository-upload-cant-follow-a-git-setting) |297| 帶有 `the upload cannot follow that setting` 的 `Not uploading this working tree` | [命令列錯誤](#the-repository-upload-cant-follow-a-git-setting) |

298| `Not uploading this working tree` 並附有其他原因 / `Git will not work in this checkout because its folder, or the .git in it, belongs to another user` | [不透過 GitHub 傳送本機儲存庫](https://code.claude.com/docs/zh-TW/claude-code-on-the-web.md#send-local-repositories-without-github) |

292| `GitHub isn't connected to your Claude account, so this repository can't be cloned in the cloud` | [命令列錯誤](#github-isnt-connected-to-your-claude-account) |299| `GitHub isn't connected to your Claude account, so this repository can't be cloned in the cloud` | [命令列錯誤](#github-isnt-connected-to-your-claude-account) |

293| `Your GitHub organization has an IP allowlist that is blocking Claude` | [命令列錯誤](#a-github-organization-policy-is-blocking-claude) |300| `Your GitHub organization has an IP allowlist that is blocking Claude` | [命令列錯誤](#a-github-organization-policy-is-blocking-claude) |

294| `Your GitHub organization requires single sign-on` | [命令列錯誤](#a-github-organization-policy-is-blocking-claude) |301| `Your GitHub organization requires single sign-on` | [命令列錯誤](#a-github-organization-policy-is-blocking-claude) |


312| `/recap only runs when you ask for it yourself in this session` | [命令列錯誤](#recap-only-runs-when-you-ask-for-it-yourself) |319| `/recap only runs when you ask for it yourself in this session` | [命令列錯誤](#recap-only-runs-when-you-ask-for-it-yourself) |

313| `/feedback is disabled by your organization's policy`,或 `/bug` 或 `/share` 的相同訊息 | [命令列錯誤](#feedback-is-disabled-by-your-organizations-policy) |320| `/feedback is disabled by your organization's policy`,或 `/bug` 或 `/share` 的相同訊息 | [命令列錯誤](#feedback-is-disabled-by-your-organizations-policy) |

314| `` `plugin eval` is currently in early access `` / `` `plugin eval` is currently unavailable `` | [外掛錯誤](#plugin-eval-is-currently-in-early-access) |321| `` `plugin eval` is currently in early access `` / `` `plugin eval` is currently unavailable `` | [外掛錯誤](#plugin-eval-is-currently-in-early-access) |

322| `credential store on this machine holds a symbolic link inside it` | [授予工具](https://code.claude.com/docs/zh-TW/plugin-evals.md#grant-tools) |

315| `cannot be evaluated where sessions load it` | [使用 evals 測試外掛](https://code.claude.com/docs/zh-TW/plugin-evals.md#cannot-be-evaluated-where-sessions-load-it) |323| `cannot be evaluated where sessions load it` | [使用 evals 測試外掛](https://code.claude.com/docs/zh-TW/plugin-evals.md#cannot-be-evaluated-where-sessions-load-it) |

316| `Marketplace "<name>" is registered from an untrusted source` | [外掛錯誤](#marketplace-is-registered-from-an-untrusted-source) |324| `Marketplace "<name>" is registered from an untrusted source` | [外掛錯誤](#marketplace-is-registered-from-an-untrusted-source) |

317| `Claude Code refuses the marketplace name "<name>"` | [外掛錯誤](#claude-code-refuses-the-marketplace-name) |325| `Claude Code refuses the marketplace name "<name>"` | [外掛錯誤](#claude-code-refuses-the-marketplace-name) |


343| `Plugin "<plugin>" was not uninstalled: installed_plugins.json` | [外掛疑難排解](https://code.claude.com/docs/zh-TW/plugins/troubleshooting.md#installed-plugins-json-holds-a-record-this-version-cannot-read) |351| `Plugin "<plugin>" was not uninstalled: installed_plugins.json` | [外掛疑難排解](https://code.claude.com/docs/zh-TW/plugins/troubleshooting.md#installed-plugins-json-holds-a-record-this-version-cannot-read) |

344| `Plugin directory does not exist: <path>` | [外掛疑難排解](https://code.claude.com/docs/zh-TW/plugins/troubleshooting.md#plugin-directory-does-not-exist) |352| `Plugin directory does not exist: <path>` | [外掛疑難排解](https://code.claude.com/docs/zh-TW/plugins/troubleshooting.md#plugin-directory-does-not-exist) |

345| `Skipping connection (recent failure cached; retries automatically in 15 min, or edit the plugin config to retry now)` | [外掛錯誤](#skipping-connection-recent-failure-cached) |353| `Skipping connection (recent failure cached; retries automatically in 15 min, or edit the plugin config to retry now)` | [外掛錯誤](#skipping-connection-recent-failure-cached) |

354| `is not added on this machine, so your organization's marketplace policy keeps its plugins off` | [新增市集](https://code.claude.com/docs/zh-TW/plugins/install.md#add-a-marketplace) |

355| `A mod's http.fetch hook stopped this request` | [開啟或關閉 mod](https://code.claude.com/docs/zh-TW/plugins/mods/overview.md#turn-mods-on-or-off) |

346| `Error: No such tool available: <tool name>` | [工具錯誤](#no-such-tool-available) |356| `Error: No such tool available: <tool name>` | [工具錯誤](#no-such-tool-available) |

347| `MCP server "<name>" connection closed before the tool call was answered` | [工具錯誤](#connection-closed-before-the-tool-call-was-answered) |357| `MCP server "<name>" connection closed before the tool call was answered` | [工具錯誤](#connection-closed-before-the-tool-call-was-answered) |

348| `MCP server "<name>" is disabled — re-enable it via /mcp to use its tools` | [工具錯誤](#mcp-server-is-disabled) |358| `MCP server "<name>" is disabled — re-enable it via /mcp to use its tools` | [工具錯誤](#mcp-server-is-disabled) |


356| `cannot contain null bytes (\0)` | [工具錯誤](#path-cannot-contain-null-bytes) |366| `cannot contain null bytes (\0)` | [工具錯誤](#path-cannot-contain-null-bytes) |

357| `Path contains null bytes` | [工具錯誤](#path-cannot-contain-null-bytes) |367| `Path contains null bytes` | [工具錯誤](#path-cannot-contain-null-bytes) |

358| `command contains the invisible character U+FEFF (byte order mark) or U+180E (Mongolian vowel separator), and was not run` | [工具錯誤](#command-contains-an-invisible-character) |368| `command contains the invisible character U+FEFF (byte order mark) or U+180E (Mongolian vowel separator), and was not run` | [工具錯誤](#command-contains-an-invisible-character) |

359| `This call was not run. The command was approved before Claude Code restarted` | [工具錯誤](#command-approved-before-a-restart-was-not-run) |369| `This call was not run. Claude Code could not confirm that the shell is back in the directory`,自 v2.1.323 起 | [工具錯誤](#command-approved-before-a-restart-was-not-run) |

360| `File is too large to read as an image (the limit is 128MB)` | [工具錯誤](#file-is-too-large-to-read-as-an-image) |370| `File is too large to read as an image (the limit is 128MB)` | [工具錯誤](#file-is-too-large-to-read-as-an-image) |

361| `Cannot read this as an image: <path> is a pipe or a device` | [工具錯誤](#file-is-too-large-to-read-as-an-image) |371| `Cannot read this as an image: <path> is a pipe or a device` | [工具錯誤](#file-is-too-large-to-read-as-an-image) |

362| `subagent_type is required: the general-purpose agent is not available in this session` | [工具錯誤](#subagent-type-is-required) |372| `subagent_type is required: the general-purpose agent is not available in this session` | [工具錯誤](#subagent-type-is-required) |


445| `Claude Code's fullscreen renderer didn't finish starting last time on this machine` / `Claude Code's fullscreen renderer has repeatedly failed to start on this machine` | [全螢幕轉譯](https://code.claude.com/docs/zh-TW/fullscreen.md#fullscreen-renderer-didnt-finish-starting) |455| `Claude Code's fullscreen renderer didn't finish starting last time on this machine` / `Claude Code's fullscreen renderer has repeatedly failed to start on this machine` | [全螢幕轉譯](https://code.claude.com/docs/zh-TW/fullscreen.md#fullscreen-renderer-didnt-finish-starting) |

446| `Claude Code exited after an unrecoverable interface error (...)` | [設定警告](#exited-after-an-unrecoverable-interface-error) |456| `Claude Code exited after an unrecoverable interface error (...)` | [設定警告](#exited-after-an-unrecoverable-interface-error) |

447| `Agent descriptions are over the 15.0k-token limit` | [設定警告](#agent-descriptions-are-over-the-15000-token-limit) |457| `Agent descriptions are over the 15.0k-token limit` | [設定警告](#agent-descriptions-are-over-the-15000-token-limit) |

458| `declares type "claudeai-proxy", which only claude.ai connectors use` | 從您的 MCP 設定中移除該項目。請參閱[使用來自 claude.ai 的 MCP 伺服器](https://code.claude.com/docs/zh-TW/mcp.md#use-mcp-servers-from-claude-ai)。 |

448| `hook needs quotes around a path with a space` | [設定警告](#hook-needs-quotes-around-a-path-with-a-space) |459| `hook needs quotes around a path with a space` | [設定警告](#hook-needs-quotes-around-a-path-with-a-space) |

449| `Instruction file not loaded` | [設定警告](#instruction-file-not-loaded) |460| `Instruction file not loaded` | [設定警告](#instruction-file-not-loaded) |

450| `Not loaded: rename <path>, then restart — its name uses "<name>", a name reserved for the skills synced from your claude.ai account` | [設定警告](#a-skill-command-or-workflow-wasnt-loaded-because-its-name-is-reserved) |461| `Not loaded: rename <path>, then restart — its name uses "<name>", a name reserved for the skills synced from your claude.ai account` | [設定警告](#a-skill-command-or-workflow-wasnt-loaded-because-its-name-is-reserved) |


486| `CLAUDE_CODE_AUTO_COMPACT_WINDOW="<value>" reads as <N> tokens, so Claude Code treats it as the 100k minimum` | [`CLAUDE_CODE_AUTO_COMPACT_WINDOW` 的值與警告](https://code.claude.com/docs/zh-TW/model-config#claude_code_auto_compact_window-values) |497| `CLAUDE_CODE_AUTO_COMPACT_WINDOW="<value>" reads as <N> tokens, so Claude Code treats it as the 100k minimum` | [`CLAUDE_CODE_AUTO_COMPACT_WINDOW` 的值與警告](https://code.claude.com/docs/zh-TW/model-config#claude_code_auto_compact_window-values) |

487| `CLAUDE_CODE_AUTO_COMPACT_WINDOW="<value>" is too large, so Claude Code treats it as the 1M maximum` | [`CLAUDE_CODE_AUTO_COMPACT_WINDOW` 的值與警告](https://code.claude.com/docs/zh-TW/model-config#claude_code_auto_compact_window-values) |498| `CLAUDE_CODE_AUTO_COMPACT_WINDOW="<value>" is too large, so Claude Code treats it as the 1M maximum` | [`CLAUDE_CODE_AUTO_COMPACT_WINDOW` 的值與警告](https://code.claude.com/docs/zh-TW/model-config#claude_code_auto_compact_window-values) |

488| `CLAUDE_CODE_AUTO_COMPACT_WINDOW="<value>" isn't a usable size, so Claude Code ignores it` | [`CLAUDE_CODE_AUTO_COMPACT_WINDOW` 的值與警告](https://code.claude.com/docs/zh-TW/model-config#claude_code_auto_compact_window-values) |499| `CLAUDE_CODE_AUTO_COMPACT_WINDOW="<value>" isn't a usable size, so Claude Code ignores it` | [`CLAUDE_CODE_AUTO_COMPACT_WINDOW` 的值與警告](https://code.claude.com/docs/zh-TW/model-config#claude_code_auto_compact_window-values) |

489| `Model "<model>" isn't recognized · context assumed to be 200k tokens` | [修正閘道或自訂模型 ID 的上下文視窗](https://code.claude.com/docs/zh-TW/model-config.md#correct-the-window-for-a-gateway-or-custom-model-id) |500| `Model "<model>" isn't recognized · context assumed to be <N> tokens` / `Claude Code doesn't recognize the model "<model>", so it assumes a context window of <N> tokens` | [修正閘道或自訂模型 ID 的視窗](https://code.claude.com/docs/zh-TW/model-config.md#correct-the-window-for-a-gateway-or-custom-model-id) |

490| `Claude Code doesn't recognize the model "<model>", so it assumes a context window of 200k tokens` | [修正閘道或自訂模型 ID 的上下文視窗](https://code.claude.com/docs/zh-TW/model-config.md#correct-the-window-for-a-gateway-or-custom-model-id) |

491| `Model "<model>" isn't recognized · did you mean "<suggestion>"?` / `Claude Code doesn't recognize the model "<model>". Did you mean "<suggestion>"?` | [修正拼錯的模型名稱](https://code.claude.com/docs/zh-TW/model-config.md#fix-a-mistyped-model-name) |501| `Model "<model>" isn't recognized · did you mean "<suggestion>"?` / `Claude Code doesn't recognize the model "<model>". Did you mean "<suggestion>"?` | [修正拼錯的模型名稱](https://code.claude.com/docs/zh-TW/model-config.md#fix-a-mistyped-model-name) |

492| `[claude-code:unrecognized_model]` | [設定警告](#unrecognized-model-id-on-a-request) |502| `[claude-code:unrecognized_model]` | [設定警告](#unrecognized-model-id-on-a-request) |

493| `is ignored — managed settings set allowManagedReadPathsOnly` / `is ignored — managed settings set allowManagedDomainsOnly` | [設定警告](#sandbox-allow-entries-are-ignored-under-a-managed-lock) |503| `is ignored — managed settings set allowManagedReadPathsOnly` / `is ignored — managed settings set allowManagedDomainsOnly` | [設定警告](#sandbox-allow-entries-are-ignored-under-a-managed-lock) |


934當 [Fable 用量點數同意提示](https://code.claude.com/docs/zh-TW/model-config.md#fable-and-usage-credits)在無人回應的情況下關閉時,Claude Code 會以以下其中一條訊息結束回合:944當 [Fable 用量點數同意提示](https://code.claude.com/docs/zh-TW/model-config.md#fable-and-usage-credits)在無人回應的情況下關閉時,Claude Code 會以以下其中一條訊息結束回合:

935 945 

936```text theme={null}946```text theme={null}

937Fable limit reached · continuing on Fable 5.1 uses usage credits, and the prompt to confirm went unanswered — nothing was sent · answer it where this session is running, or /model to change947Fable limit reached · continuing on Fable 5.1 uses usage credits, and the prompt to confirm went unanswered · nothing was sent · answer it where this session is running, or /model to change

938Fable 5.1 now uses usage credits · the prompt to confirm went unanswered — nothing was sent · answer it where this session is running, or /model to change948Fable 5.1 now uses usage credits · the prompt to confirm went unanswered · nothing was sent · answer it where this session is running, or /model to change

939```949```

940 950 

941訊息會命名工作階段的 Fable 模型,因此在 Fable 5.2 上它們會讀作 `continuing on Fable 5.2` 和 `Fable 5.2 now uses usage credits`。在 v2.1.257 之前,第一條訊息以 `Fable 5 limit reached` 開頭。951訊息會命名工作階段的 Fable 模型,因此在 Fable 5.2 上它們會讀作 `continuing on Fable 5.2` 和 `Fable 5.2 now uses usage credits`。連接 [Remote Control](https://code.claude.com/docs/zh-TW/remote-control.md) 時,每條訊息可能改以 `Claude stopped here · send a message to be asked again, or switch models` 結尾。在 v2.1.257 之前,第一條訊息以 `Fable 5 limit reached` 開頭。

942 952 

943這發生在 [Remote Control](https://code.claude.com/docs/zh-TW/remote-control.md) 工作階段、[背景工作階段](https://code.claude.com/docs/zh-TW/agent-view.md)、[agent team](https://code.claude.com/docs/zh-TW/agent-teams.md) 隊友工作階段,以及另一個應用程式透過 Agent SDK 託管的工作階段中。如需 Claude Code 何時關閉提示,請參閱 [Fable 和用量點數](https://code.claude.com/docs/zh-TW/model-config.md#fable-and-usage-credits)。953這發生在 [Remote Control](https://code.claude.com/docs/zh-TW/remote-control.md) 工作階段、[背景工作階段](https://code.claude.com/docs/zh-TW/agent-view.md)、[agent team](https://code.claude.com/docs/zh-TW/agent-teams.md) 隊友工作階段,以及另一個應用程式透過 Agent SDK 託管的工作階段中。如需 Claude Code 何時關閉提示,請參閱 [Fable 和用量點數](https://code.claude.com/docs/zh-TW/model-config.md#fable-and-usage-credits)。

944 954 

945**該怎麼做:**955**該怎麼做:**

946 956 

947* 在工作階段執行所在的終端機或託管它的應用程式中,發送另一個提示詞,當同意提示重新出現時回答它。對於背景工作階段,請先從 [agents 檢視](https://code.claude.com/docs/zh-TW/agent-view.md)附加到它。從 Remote Control 用戶端重新發送會再次顯示此訊息,因為用戶端無法顯示提示。957* 在工作階段執行所在的終端機或託管它的應用程式中,發送另一個提示詞,當同意提示重新出現時回答它。對於背景工作階段,請先從 [agents 檢視](https://code.claude.com/docs/zh-TW/agent-view.md)附加到它。如果訊息顯示 `Claude stopped here`,您也可以從已連接的裝置回覆,並在那裡回答同意提示。

948* 執行 `/model` 以切換到不計費用量點數的模型958* 執行 `/model` 以切換到不計費用量點數的模型

949* 若要給自己更多時間,請將 [`dialogExpiry`](https://code.claude.com/docs/zh-TW/settings-reference#dialogexpiry) 設定為更長的值或 `"never"`959* 若要給自己更多時間,請將 [`dialogExpiry`](https://code.claude.com/docs/zh-TW/settings-reference#dialogexpiry) 設定為更長的值或 `"never"`

950 960 


1921**處理方式:**1931**處理方式:**

1922 1932 

1923* 如果提示表示憑證由此環境管理,則啟動 Claude Code 的應用程式擁有該憑證,此處的其他步驟並不適用:請重試,或聯絡您的管理員1933* 如果提示表示憑證由此環境管理,則啟動 Claude Code 的應用程式擁有該憑證,此處的其他步驟並不適用:請重試,或聯絡您的管理員

1934* 若您設定了 `CLAUDE_CODE_USE_ANTHROPIC_GOOGLE_CLOUD`,請改為依照 [Claude Models on Google Cloud (Anthropic managed)](https://code.claude.com/docs/zh-TW/claude-models-on-google-cloud-anthropic-managed.md#google-cloud-credentials-expired-or-invalid) 的步驟進行

1924* 如果您以應用程式預設憑證進行身分驗證,請執行訊息所指的 [`gcpAuthRefresh`](https://code.claude.com/docs/zh-TW/google-vertex-ai#advanced-credential-configuration) 命令,或 `gcloud auth application-default login`,完成登入後重試1935* 如果您以應用程式預設憑證進行身分驗證,請執行訊息所指的 [`gcpAuthRefresh`](https://code.claude.com/docs/zh-TW/google-vertex-ai#advanced-credential-configuration) 命令,或 `gcloud auth application-default login`,完成登入後重試

1925* 如果您在設定了 `CLAUDE_CODE_SKIP_VERTEX_AUTH` 的情況下透過 [LLM 閘道](https://code.claude.com/docs/zh-TW/llm-gateway)進行路由,請重新整理 `ANTHROPIC_AUTH_TOKEN` 或 `ANTHROPIC_CUSTOM_HEADERS` 中的閘道 token,然後重試1936* 如果您在設定了 `CLAUDE_CODE_SKIP_VERTEX_AUTH` 的情況下透過 [LLM 閘道](https://code.claude.com/docs/zh-TW/llm-gateway)進行路由,請重新整理 `ANTHROPIC_AUTH_TOKEN` 或 `ANTHROPIC_CUSTOM_HEADERS` 中的閘道 token,然後重試

1926* 如果您以服務帳戶金鑰檔案進行身分驗證,請確認 `GOOGLE_APPLICATION_CREDENTIALS` 指向有效的金鑰。請參閱[設定 GCP 憑證](https://code.claude.com/docs/zh-TW/google-vertex-ai.md#3-configure-gcp-credentials)1937* 如果您以服務帳戶金鑰檔案進行身分驗證,請確認 `GOOGLE_APPLICATION_CREDENTIALS` 指向有效的金鑰。請參閱[設定 GCP 憑證](https://code.claude.com/docs/zh-TW/google-vertex-ai.md#3-configure-gcp-credentials)


1941**處理方式:**1952**處理方式:**

1942 1953 

1943* 如果提示指出憑證由此環境管理,表示啟動 Claude Code 的應用程式擁有該憑證,此處的其他步驟不適用:請重試,或聯絡您的管理員1954* 如果提示指出憑證由此環境管理,表示啟動 Claude Code 的應用程式擁有該憑證,此處的其他步驟不適用:請重試,或聯絡您的管理員

1955* 若您設定了 `CLAUDE_CODE_USE_ANTHROPIC_GOOGLE_CLOUD`,請改為依照 [Claude Models on Google Cloud (Anthropic managed)](https://code.claude.com/docs/zh-TW/claude-models-on-google-cloud-anthropic-managed.md#google-cloud-authentication-failed) 的步驟進行

1944* 確認 [IAM 設定](https://code.claude.com/docs/zh-TW/google-vertex-ai.md#iam-configuration)中的角色已授予您用來進行身分驗證的身分1956* 確認 [IAM 設定](https://code.claude.com/docs/zh-TW/google-vertex-ai.md#iam-configuration)中的角色已授予您用來進行身分驗證的身分

1945* 確認模型已在您的專案中啟用。請參閱[請求模型存取權](https://code.claude.com/docs/zh-TW/google-vertex-ai.md#2-request-model-access)1957* 確認模型已在您的專案中啟用。請參閱[請求模型存取權](https://code.claude.com/docs/zh-TW/google-vertex-ai.md#2-request-model-access)

1946 1958 


2500* 使用 `/mcp disable <name>` 禁用您未使用的 MCP 伺服器,以從上下文中移除其工具定義2512* 使用 `/mcp disable <name>` 禁用您未使用的 MCP 伺服器,以從上下文中移除其工具定義

2501* 修剪大型 `CLAUDE.md` 記憶檔案,或將指示移至[路徑範圍規則](https://code.claude.com/docs/zh-TW/memory.md#path-specific-rules),這些規則僅在相關時載入2513* 修剪大型 `CLAUDE.md` 記憶檔案,或將指示移至[路徑範圍規則](https://code.claude.com/docs/zh-TW/memory.md#path-specific-rules),這些規則僅在相關時載入

2502* 自動壓縮預設為開啟,通常可防止此錯誤。如果您在 `/config` 中或使用 [`DISABLE_AUTO_COMPACT`](https://code.claude.com/docs/zh-TW/env-vars) 關閉了它,請將其重新開啟。如果您保持關閉,請在視窗填滿之前自己執行 `/compact`。2514* 自動壓縮預設為開啟,通常可防止此錯誤。如果您在 `/config` 中或使用 [`DISABLE_AUTO_COMPACT`](https://code.claude.com/docs/zh-TW/env-vars) 關閉了它,請將其重新開啟。如果您保持關閉,請在視窗填滿之前自己執行 `/compact`。

2503* 如果在可接受更多 token 的模型上,錯誤出現在接近 200K token 時,原因之一是 Claude Code 無法辨識該模型 ID。Claude Code 會為這類 ID 假設 200K 的視窗,因此若要在超過該點後繼續工作,請[提供模型實際的上下文視窗](https://code.claude.com/docs/zh-TW/model-config.md#correct-the-window-for-a-gateway-or-custom-model-id)。2515* 如果 Claude Code 警告無法辨識您的模型 ID,該警告可能會指出它所假設的視窗大小。當模型的實際視窗不同時,請[提供 Claude Code 實際的視窗大小](https://code.claude.com/docs/zh-TW/model-config.md#correct-the-window-for-a-gateway-or-custom-model-id)。

2504 * 如果您使用自訂的 [`ANTHROPIC_BASE_URL`](https://code.claude.com/docs/zh-TW/env-vars),且錯誤以 `Prompt is too long · automatic compaction failed` 開頭,請[設定模型的上下文視窗](https://code.claude.com/docs/zh-TW/model-config.md#correct-the-window-for-a-gateway-or-custom-model-id)或[更新](https://code.claude.com/docs/zh-TW/setup.md#update-claude-code)至 v2.1.299 或更新版本。在 v2.1.299 之前,Claude Code 會在接近假設的 200K 視窗時以該訊息結束回合,而不是傳送請求。2516 * 如果您使用自訂的 [`ANTHROPIC_BASE_URL`](https://code.claude.com/docs/zh-TW/env-vars),且錯誤以 `Prompt is too long · automatic compaction failed` 開頭,請[設定模型的上下文視窗](https://code.claude.com/docs/zh-TW/model-config.md#correct-the-window-for-a-gateway-or-custom-model-id),或[更新](https://code.claude.com/docs/zh-TW/setup.md#update-claude-code)至 v2.1.299 或更新版本。在 v2.1.299 之前,Claude Code 會在接近所假設的 200K 視窗時以該訊息結束回合,而不送出請求。

2505* 如果錯誤是在您於 Claude 壓縮對話期間停止它之後立即出現,您的對話並未變更,且仍大到需要壓縮。請執行 `/compact` 並再次送出您的訊息。若要避免此錯誤再次發生,請將 Claude Code [更新](https://code.claude.com/docs/zh-TW/setup.md#update-claude-code)至 v2.1.304 或更新版本。在 v2.1.304 之前,在那個時間點停止可能會使該回合以此錯誤結束。2517* 如果錯誤是在您於 Claude 壓縮對話期間停止它之後立即出現,您的對話並未變更,且仍大到需要壓縮。請執行 `/compact` 並再次送出您的訊息。若要避免此錯誤再次發生,請將 Claude Code [更新](https://code.claude.com/docs/zh-TW/setup.md#update-claude-code)至 v2.1.304 或更新版本。在 v2.1.304 之前,在那個時間點停止可能會使該回合以此錯誤結束。

2506* 在 v2.1.305 上,若有許多 MCP 工具且直接連線至 Anthropic API,此錯誤可能會掩蓋來自 API 的無關 400 或 422 錯誤。請將 [Claude Code 更新](https://code.claude.com/docs/zh-TW/setup.md#update-claude-code)至 v2.1.306 或更新版本,以查看原始錯誤。2518* 在 v2.1.305 上,若有許多 MCP 工具且直接連線至 Anthropic API,此錯誤可能會掩蓋來自 API 的無關 400 或 422 錯誤。請將 [Claude Code 更新](https://code.claude.com/docs/zh-TW/setup.md#update-claude-code)至 v2.1.306 或更新版本,以查看原始錯誤。

2507 2519 


3192 3204 

3193## 命令列錯誤3205## 命令列錯誤

3194 3206 

3195這些錯誤來自 `claude` 命令列及其子命令、您在輸入提示處提交的命令名稱,以及像 `/security-review` 這類會在其提示詞執行前先執行 shell 命令以收集脈絡的命令。它們也可能來自會重新啟動 CLI 的 `/tui`。3207這些錯誤來自 `claude` 命令列及其子命令、您在提示詞輸入處送出的命令名稱,以及像 `/security-review` 這類在其提示詞執行前先執行 shell 命令來收集脈絡的命令。它們也來自會重新啟動 CLI 的 `/tui`。

3196 3208 

3197### `--bg` 與 `--print` 衝突3209### `--bg` 與 `--print` 之間的衝突

3198 3210 

3199此訊息需要 Claude Code v2.1.198 或更新版本。您在同一次 `claude` 呼叫中將 `--bg` 與 `-p` 或 `--print` 合併使用。`--bg` 會啟動一個[背景工作階段](https://code.claude.com/docs/zh-TW/agent-view.md#from-your-shell),您之後可以使用 `claude agents` 附加到該工作階段;而 `--print` 則以[非互動方式](https://code.claude.com/docs/zh-TW/headless.md)執行,永遠不會啟動 `claude agents` 所附加的互動式工作階段。在 v2.1.198 之前,此組合會默默建立一個永遠無法附加的背景工作。3211此訊息需要 Claude Code v2.1.198 或更新版本。您在同一次 `claude` 呼叫中將 `--bg` 與 `-p` 或 `--print` 併用。`--bg` 會啟動一個[背景工作階段](https://code.claude.com/docs/zh-TW/agent-view.md#from-your-shell),您稍後可用 `claude agents` 附加到該工作階段;而 `--print` 以[非互動方式](https://code.claude.com/docs/zh-TW/headless.md)執行,永遠不會啟動 `claude agents` 所附加的互動式工作階段。在 v2.1.198 之前,這種組合會默默建立一個永遠無法附加的背景工作。

3200 3212 

3201```text theme={null}3213```text theme={null}

3202--bg and --print conflict: --print never starts the interactive session that `claude agents` attaches to, so the job would be unattachable. The prompt is the positional — drop --print: `claude --bg '<task>'`.3214--bg and --print conflict: --print never starts the interactive session that `claude agents` attaches to, so the job would be unattachable. The prompt is the positional — drop --print: `claude --bg '<task>'`.


3204 3216 

3205**處理方式:**3217**處理方式:**

3206 3218 

3207* 移除 `-p` 或 `--print`。`--bg` 會將提示詞作為其位置引數,因此 `claude --bg "<task>"` 就是完整的命令。請參閱[從 shell 分派新的 agent](https://code.claude.com/docs/zh-TW/agent-view.md#from-your-shell)。3219* 移除 `-p` 或 `--print`。`--bg` 會將提示詞當作其位置引數,因此 `claude --bg "<task>"` 就是完整的命令。請參閱[從 shell 派發新的 agent](https://code.claude.com/docs/zh-TW/agent-view.md#from-your-shell)。

3208* 若要以非互動方式執行提示詞並列印結果,而不是建立背景工作階段,請移除 `--bg` 並執行 `claude -p "<task>"`3220* 若要以非互動方式執行提示詞並印出結果,而不是建立背景工作階段,請移除 `--bg` 並執行 `claude -p "<task>"`

3209 3221 

3210### Couldn't tell whether `--bg` is a flag or text3222### Couldn't tell whether `--bg` is a flag or text

3211 3223 

3212您執行 `claude` 時,將 `--bg` 或 `--background` 放在 Claude Code 無法判斷您是要將其作為背景旗標還是文字的位置。該命令沒有啟動任何東西,僅列印這一行,並以退出碼 1 結束:3224您執行 `claude` 時,`--bg` 或 `--background` 所在的位置讓 Claude Code 無法判斷您是想將其作為背景旗標還是文字。該命令沒有啟動任何東西,印出下列這行後以退出碼 1 結束:

3213 3225 

3214```text theme={null}3226```text theme={null}

3215Couldn't tell whether --bg is a flag or text here, so nothing was started. To start a background session put it first: claude --bg <prompt>3227Couldn't tell whether --bg is a flag or text here, so nothing was started. To start a background session put it first: claude --bg <prompt>


3221 3233 

3222* 若要啟動[背景工作階段](https://code.claude.com/docs/zh-TW/agent-view.md#from-your-shell),請在 shell 中將旗標放在最前面再次執行命令:`claude --bg --name nightly-audit "<task>"`3234* 若要啟動[背景工作階段](https://code.claude.com/docs/zh-TW/agent-view.md#from-your-shell),請在 shell 中將旗標放在最前面再次執行命令:`claude --bg --name nightly-audit "<task>"`

3223 3235 

3224### 系統提示詞旗標與其檔案形式衝突3236### 系統提示詞旗標與其檔案形式之間的衝突

3225 3237 

3226您在同一次 `claude` 呼叫中同時傳入了 [`--append-subagent-system-prompt`](https://code.claude.com/docs/zh-TW/cli-reference#cli-flags) 與 `--append-subagent-system-prompt-file`,因此 `claude` 會以退出碼 1 結束,而不會啟動工作階段:3238您在同一次 `claude` 呼叫中同時傳入了 [`--append-subagent-system-prompt`](https://code.claude.com/docs/zh-TW/cli-reference#cli-flags) 與 `--append-subagent-system-prompt-file`,因此 `claude` 會以退出碼 1 結束,而不會啟動工作階段:

3227 3239 


3229Error: Cannot use both --append-subagent-system-prompt and --append-subagent-system-prompt-file. Please use only one.3241Error: Cannot use both --append-subagent-system-prompt and --append-subagent-system-prompt-file. Please use only one.

3230```3242```

3231 3243 

3232在 v2.1.283 之前,當您將 `--system-prompt` 與 `--system-prompt-file` 一起傳入,或將 `--append-system-prompt` 與 `--append-system-prompt-file` 一起傳入時,`claude` 也會以相同方式結束,因為這些成對的旗標會相互衝突,而不是[合併使用](https://code.claude.com/docs/zh-TW/cli-reference.md#system-prompt-flags)。在這些版本中,訊息會指出您合併使用的那一對旗標。3244在 v2.1.283 之前,當您將 `--system-prompt` 與 `--system-prompt-file` 併用,或將 `--append-system-prompt` 與 `--append-system-prompt-file` 併用時,`claude` 也會以同樣方式結束,因為這些組合會相互衝突,而不是[合併使用](https://code.claude.com/docs/zh-TW/cli-reference.md#system-prompt-flags)。在這些版本中,訊息會列出您併用的那一組旗標。

3233 3245 

3234**處理方式:**3246**處理方式:**

3235 3247 

3236* 保留旗標的其中一種形式,並移除另一種。若要將固定的提示詞檔案與每次執行的文字結合,請在啟動前將文字合併到檔案中,而不是同時傳入兩個旗標3248* 保留旗標的其中一種形式並移除另一種。若要將固定的提示詞檔案與每次執行的文字結合,請在啟動前將文字合併到檔案中,而不要同時傳入兩個旗標

3237 3249 

3238### 無效的 `--agents` 設定3250### 無效的 `--agents` 設定

3239 3251 

3240您傳給 `--agents` 的值無效,因此 `claude` 會以退出碼 1 結束,而不會啟動工作階段。當您傳入 `--safe-mode` 或設定 [`CLAUDE_CODE_SAFE_MODE`](https://code.claude.com/docs/zh-TW/env-vars#variables) 時,Claude Code 會完全忽略 `--agents`。搭配 `--resume` 或 `--continue` 時,內嵌的 JSON 值不會被檢查,工作階段會照常啟動;從檔案讀取的值則會在每次啟動時檢查。在 v2.1.242 之前,Claude Code 仍會照樣啟動工作階段。3252您傳給 `--agents` 的值無效,因此 `claude` 會以退出碼 1 結束,而不會啟動工作階段。當您傳入 `--safe-mode` 或設定 [`CLAUDE_CODE_SAFE_MODE`](https://code.claude.com/docs/zh-TW/env-vars#variables) 時,Claude Code 會完全忽略 `--agents`。搭配 `--resume` 或 `--continue` 時,行內 JSON 值不會被檢查,工作階段會照常啟動;從檔案讀取的值則在每次啟動時都會被檢查。在 v2.1.242 之前,Claude Code 仍會照常啟動工作階段。

3241 3253 

3242```text theme={null}3254```text theme={null}

3243Error: Invalid --agents configuration:3255Error: Invalid --agents configuration:

3244<what failed>3256<what failed>

3245```3257```

3246 3258 

3247第一行之後的內容取決於該值失敗的方式。Claude Code 會依序執行以下檢查,並在第一個失敗的檢查處停止。如果您的值有兩類問題,您要在修正第一類之後才會看到第二類:3259第一行之後的內容取決於該值失敗的方式。Claude Code 會依序執行下列檢查,並在第一個失敗的檢查處停止。如果您的值有兩種問題,您必須先修正第一個,才會看到第二個:

3248 3260 

32491. 當值以 `{` 開頭但無法解析為 JSON,或 `--agents` 檔案的內容無法解析時,Claude Code 會列印一行 `invalid JSON:`,其中包含 JSON 剖析器本身的訊息32611. 當值以 `{` 開頭但無法解析為 JSON,或 `--agents` 檔案的內容無法解析時,Claude Code 會印出一行 `invalid JSON:`,內含 JSON 剖析器本身的訊息

32502. 當值可以解析,但某個 agent 定義不符合 [CLI 定義的 subagent](https://code.claude.com/docs/zh-TW/sub-agents.md#choose-the-subagent-scope) 的 schema 時,Claude Code 會針對每個問題列印一行32622. 當值可以解析,但某個 agent 定義不符合 [CLI 定義之 subagent](https://code.claude.com/docs/zh-TW/sub-agents.md#choose-the-subagent-scope) 的 schema 時,Claude Code 會針對每個問題印出一行

32513. 當 agent 名稱以 `-` 開頭時,Claude Code 會列印 `<name>: agent names must not start with '-'`32633. 當 agent 名稱以 `-` 開頭時,Claude Code 會印出 `<name>: agent names must not start with '-'`

3252 3264 

3253當問題行超過 20 行時,Claude Code 會列印前 20 行,並將其餘部分替換為 `…and N more`。3265當問題行超過 20 行時,Claude Code 會印出前 20 行,並將其餘部分替換為 `…and N more`。

3254 3266 

3255搭配 `--print` 時,`--agents` 也接受以[JSON 檔案的路徑](https://code.claude.com/docs/zh-TW/sub-agents.md#choose-the-subagent-scope)取代內嵌物件。在 v2.1.281 之前,`--agents` 只接受內嵌 JSON,並將檔案路徑視為無效的 JSON。檔案形式有其自己的拒絕訊息,會取代此訊息列印出來,包括以下幾種:3267搭配 `--print` 時,`--agents` 也接受以 [JSON 檔案的路徑](https://code.claude.com/docs/zh-TW/sub-agents.md#choose-the-subagent-scope)取代行內物件。在 v2.1.281 之前,`--agents` 只接受行內 JSON,並將檔案路徑視為無效的 JSON。檔案形式有其自己的拒絕訊息,會取代此訊息印出,包括下列這些:

3256 3268 

3257* **`Error: --agents takes a JSON object, or a file path only with --print (-p)`**:Claude Code 在互動式工作階段中將該值讀取為檔案路徑。請以內嵌 JSON 傳入定義,或加上 `-p` 以從檔案讀取。3269* **`Error: --agents takes a JSON object, or a file path only with --print (-p)`**:Claude Code 在互動式工作階段中將該值讀取為檔案路徑。請以行內 JSON 傳入定義,或加上 `-p` 以從檔案讀取。

3258* **`Error: --agents file not found: <path>`**:該路徑上沒有檔案。不以 `{` 開頭且不是有效 JSON 的值會被讀取為路徑,因此被 shell 弄亂的內嵌 JSON 也可能以此方式失敗。請檢查路徑或引號,然後再次執行命令。3270* **`Error: --agents file not found: <path>`**:該路徑不存在任何檔案。不以 `{` 開頭且不是有效 JSON 的值會被當作路徑讀取,因此被您的 shell 弄亂的行內 JSON 也可能以這種方式失敗。請檢查路徑或引號後再次執行命令。

3259 3271 

3260**處理方式:**3272**處理方式:**

3261 3273 

3262* 修正訊息列出的每個問題,然後再次執行命令。請參閱 [CLI 定義的 subagent 所接受的欄位](https://code.claude.com/docs/zh-TW/sub-agents.md#choose-the-subagent-scope)。3274* 修正訊息中列出的每個問題,然後再次執行命令。請參閱 [CLI 定義之 subagent 可使用的欄位](https://code.claude.com/docs/zh-TW/sub-agents.md#choose-the-subagent-scope)。

3263 3275 

3264### 無法從 `--restricted` 工作階段建立雲端工作階段3276### Cloud sessions cannot be created from a `--restricted` session

3265 3277 

3266當您以 [`--restricted`](https://code.claude.com/docs/zh-TW/cli-reference#cli-flags) 啟動工作階段時,Claude Code 會拒絕從中建立[雲端工作階段](https://code.claude.com/docs/zh-TW/claude-code-on-the-web.md#from-terminal-to-cloud),因為新的工作階段會在受限程序之外執行,而且不會強制執行受限模式。Claude Code 會在用戶端、聯絡伺服器之前就拒絕,因此不會建立任何雲端工作階段:3278當您以 [`--restricted`](https://code.claude.com/docs/zh-TW/cli-reference#cli-flags) 啟動工作階段時,Claude Code 會拒絕從中建立[雲端工作階段](https://code.claude.com/docs/zh-TW/claude-code-on-the-web.md#from-terminal-to-cloud),因為新的工作階段會在受限程序之外執行,且不會強制執行受限模式。Claude Code 會在用戶端、聯繫伺服器之前就拒絕,因此不會建立任何雲端工作階段:

3267 3279 

3268```text theme={null}3280```text theme={null}

3269Cloud sessions cannot be created from a --restricted session: they would not enforce it.3281Cloud sessions cannot be created from a --restricted session: they would not enforce it.


3271 3283 

3272**處理方式:**3284**處理方式:**

3273 3285 

3274* 在受限工作階段中於本機執行該任務3286* 在受限工作階段中於本機執行該工作

3275* 如果您能控制工作階段的啟動方式,請啟動一個不帶 `--restricted` 的新 `claude` 工作階段,並從那裡建立雲端工作階段3287* 如果您能控制工作階段的啟動方式,請在不使用 `--restricted` 的情況下啟動新的 `claude` 工作階段,並從那裡建立雲端工作階段

3276 3288 

3277在 v2.1.248 之前,Claude Code 沒有 `--restricted` 旗標;較早的版本會以未知選項錯誤拒絕該旗標本身。3289在 v2.1.248 之前,Claude Code 沒有 `--restricted` 旗標;較早的版本會以未知選項錯誤拒絕該旗標本身。

3278 3290 

3279### 雲端工作階段已被您組織的政策停用3291### Cloud sessions are disabled by your organization's policy

3280 3292 

3281您組織的 `allow_remote_sessions` 政策已關閉,因此無法使用[雲端工作階段](https://code.claude.com/docs/zh-TW/claude-code-on-the-web.md)以及使用它們的命令:3293您組織的 `allow_remote_sessions` 政策已關閉,因此無法使用[雲端工作階段](https://code.claude.com/docs/zh-TW/claude-code-on-the-web.md)以及使用它們的命令:

3282 3294 


3284Cloud sessions are disabled by your organization's policy. Contact your organization admin to enable them.3296Cloud sessions are disabled by your organization's policy. Contact your organization admin to enable them.

3285```3297```

3286 3298 

3287此訊息會在您[從終端機建立雲端工作階段](https://code.claude.com/docs/zh-TW/claude-code-on-the-web.md#from-terminal-to-cloud)時出現,也會在您提交需要雲端工作階段的命令(例如 `/teleport`、`/remote-env` 或 `/web-setup`)時出現。在 v2.1.268 之前,提交這些命令之一會改為傳回 [`Unknown command`](#unknown-command)。3299當您[從終端機建立雲端工作階段](https://code.claude.com/docs/zh-TW/claude-code-on-the-web.md#from-terminal-to-cloud)時,以及當您送出需要雲端工作階段的命令(例如 `/teleport`、`/remote-env` 或 `/web-setup`)時,會出現此訊息。在 v2.1.268 之前,送出這些命令之一會改為傳回 [`Unknown command`](#unknown-command)。

3288 3300 

3289如果訊息改為指出此工作階段正在使用的某個憑證,並以 `Cloud sessions use your claude.ai login.` 結尾,請參閱 [Cloud sessions use your claude.ai login](#cloud-sessions-use-your-claude-ai-login)。如果 Claude Code 完全無法載入您組織的政策,您會看到[另一則訊息](#couldnt-verify-your-organizations-policy-for-cloud-sessions)。3301如果訊息改為列出此工作階段正在使用的憑證,並以 `Cloud sessions use your claude.ai login.` 結尾,請參閱 [Cloud sessions use your claude.ai login](#cloud-sessions-use-your-claude-ai-login)。如果 Claude Code 完全無法載入您組織的政策,您會看到[另一則訊息](#couldnt-verify-your-organizations-policy-for-cloud-sessions)。

3290 3302 

3291**處理方式:**3303**處理方式:**

3292 3304 


3294 3306 

3295### Cloud sessions use your claude.ai login3307### Cloud sessions use your claude.ai login

3296 3308 

3297當[政策拒絕訊息](#cloud-sessions-are-disabled-by-your-organizations-policy)指出此工作階段正在使用的某個憑證並以這句話結尾時,表示 Claude Code 檢查的是核發該憑證之組織的雲端工作階段政策。該組織可能與您的 claude.ai 登入所屬的組織不同:3309當[政策拒絕訊息](#cloud-sessions-are-disabled-by-your-organizations-policy)列出此工作階段正在使用的憑證並以這句話結尾時,表示 Claude Code 檢查的是核發該憑證之組織的雲端工作階段政策。該組織可能與您的 claude.ai 登入所屬的組織不同:

3298 3310 

3299```text theme={null}3311```text theme={null}

3300Cloud sessions are disabled by your organization's policy. This session is using ANTHROPIC_API_KEY, so Claude Code checked the policy for the organization that key belongs to. Cloud sessions use your claude.ai login.3312Cloud sessions are disabled by your organization's policy. This session is using ANTHROPIC_API_KEY, so Claude Code checked the policy for the organization that key belongs to. Cloud sessions use your claude.ai login.

3301```3313```

3302 3314 

3303最後一句話表示雲端工作階段是在您的 claude.ai 登入上執行,而不是在該憑證上執行。當您從 shell 啟動、恢復雲端工作階段或傳送訊息給雲端工作階段時(例如使用 `--cloud` 或 `--teleport`),就會出現此形式。在 v2.1.296 之前,Claude Code 在這種情況下也會輸出要求您聯絡組織管理員的形式。3315最後一句話的意思是,雲端工作階段是以您的 claude.ai 登入執行,而不是以該憑證執行。當您從 shell 啟動、恢復雲端工作階段或向其傳送訊息(例如使用 `--cloud` 或 `--teleport`)時,會出現這種形式。在 v2.1.296 之前,Claude Code 在這種情況下也會印出要您聯絡組織管理員的形式。

3304 3316 

3305### Couldn't verify your organization's policy for cloud sessions3317### Couldn't verify your organization's policy for cloud sessions

3306 3318 

3307這些訊息表示 Claude Code 無法載入您組織的政策,而它會在建立、恢復[雲端工作階段](https://code.claude.com/docs/zh-TW/claude-code-on-the-web.md)或傳送訊息給雲端工作階段之前檢查該政策。當政策請求尚未完成時,訊息為:3319這些訊息表示 Claude Code 無法載入您組織的政策;在建立、恢復[雲端工作階段](https://code.claude.com/docs/zh-TW/claude-code-on-the-web.md)或向其傳送訊息之前,Claude Code 會先檢查此政策。當政策請求尚未完成時,訊息為:

3308 3320 

3309```text theme={null}3321```text theme={null}

3310Couldn't verify your organization's policy for cloud sessions. Check your network connection and try again.3322Couldn't verify your organization's policy for cloud sessions. Check your network connection and try again.

3311```3323```

3312 3324 

3313在工作階段中,需要雲端工作階段的命令(例如 `/teleport` 或 `/web-setup`)也會顯示此訊息。即使在您的 shell 會輸出 `Cloud sessions aren't available:` 形式的情況下也是如此,且其第二句為 `Check your network connection, then restart Claude Code and try again.`3325在工作階段內,需要雲端工作階段的命令(例如 `/teleport` 或 `/web-setup`)也會顯示此訊息。即使在您的 shell 會印出 `Cloud sessions aren't available:` 形式的情況下也是如此,且其第二句為 `Check your network connection, then restart Claude Code and try again.`

3314 3326 

3315一旦政策請求失敗,訊息就會說明失敗的原因。這適用於您使用 `--cloud` 或 `--teleport` 等旗標從 shell 啟動、恢復雲端工作階段或傳送訊息給雲端工作階段的情況。在無法連到 API 時,訊息為:3327一旦政策請求失敗,訊息會說明失敗的原因。這適用於您使用 `--cloud` 或 `--teleport` 等旗標從 shell 啟動、恢復雲端工作階段或向其傳送訊息的情況。沒有通往 API 的路徑時,訊息如下:

3316 3328 

3317```text theme={null}3329```text theme={null}

3318Cloud sessions aren't available: couldn't reach api.anthropic.com to load your organization's policy. Check your network or proxy.3330Cloud sessions aren't available: couldn't reach api.anthropic.com to load your organization's policy. Check your network or proxy.

3319```3331```

3320 3332 

3321其他失敗會使用相同的開頭並附上各自的原因,例如代理伺服器以 HTTP 403 拒絕請求、伺服器錯誤,或 API 不接受的憑證。當 API 不接受此工作階段用來取代您 claude.ai 登入的憑證(例如 `ANTHROPIC_API_KEY` 環境變數)時,訊息也可能指出該憑證並要求您取消設定它:3333其他失敗情況使用相同的開頭,並附上各自的原因,例如代理伺服器以 HTTP 403 拒絕請求、伺服器錯誤,或 API 不接受的憑證。當 API 不接受此工作階段用來取代您 claude.ai 登入的憑證(例如 `ANTHROPIC_API_KEY` 環境變數)時,訊息也可能列出該憑證並要您取消設定它:

3322 3334 

3323```text theme={null}3335```text theme={null}

3324Cloud sessions aren't available: api.anthropic.com didn't accept this session's credentials when Claude Code asked for your organization's policy. Cloud sessions use your claude.ai login. ANTHROPIC_API_KEY is set, so this session is using API-key auth — unset it (or run in a shell without it) to use cloud sessions.3336Cloud sessions aren't available: api.anthropic.com didn't accept this session's credentials when Claude Code asked for your organization's policy. Cloud sessions use your claude.ai login. ANTHROPIC_API_KEY is set, so this session is using API-key auth — unset it (or run in a shell without it) to use cloud sessions.

3325```3337```

3326 3338 

3327在 v2.1.296 之前,這些失敗也會輸出 `Couldn't verify` 訊息。3339在 v2.1.296 之前,這些失敗也會印出 `Couldn't verify` 訊息。

3328 3340 

3329**處理方式:**3341**處理方式:**

3330 3342 

3331* 對於 `Couldn't verify` 訊息,請檢查網路連線後再試一次。若在工作階段中,請先重新啟動 Claude Code3343* 對於 `Couldn't verify` 訊息,請檢查您的網路連線後再試一次。若在工作階段內,請先重新啟動 Claude Code

3332* 對於 `Cloud sessions aren't available:` 訊息,請依其原因採取對應措施,例如檢查代理伺服器或取消設定訊息指出的憑證,然後再次執行命令3344* 對於 `Cloud sessions aren't available:` 訊息,請依其原因採取對應動作,例如檢查代理伺服器或取消設定其列出的憑證,然後再次執行命令

3333 3345 

3334### 由於資料夾取代了受追蹤的檔案,未暫存任何內容3346### 因資料夾取代了受追蹤的檔案而未儲藏任何內容

3335 3347 

3336此訊息表示您的檢出目錄中,現在有一個資料夾位於原本由 git 追蹤的檔案或連結所在的位置。當您將[雲端工作階段](https://code.claude.com/docs/zh-TW/claude-code-on-the-web.md#from-cloud-to-terminal)拉取到終端機(例如使用 `claude --teleport` 或 `/teleport`)並選擇暫存(stash)選項之後,就會出現此訊息。暫存這種狀態可能會刪除資料夾內的檔案,因此 Claude Code 會拒絕暫存,並讓您的檢出目錄與索引保持不變:3348此訊息表示您的 checkout 中有一個資料夾現在位於原本是受 git 追蹤之檔案或連結的位置。當您將[雲端工作階段](https://code.claude.com/docs/zh-TW/claude-code-on-the-web.md#from-cloud-to-terminal)拉到終端機(例如使用 `claude --teleport` 或 `/teleport`)時選擇了 stash 選項後,就會出現此訊息。對這種狀態執行 stash 可能會刪除資料夾內的檔案,因此 Claude Code 拒絕執行 stash,並保持您的 checkout 與索引不變:

3337 3349 

3338```text wrap theme={null}3350```text wrap theme={null}

3339Error: Nothing was stashed: "f" is now a folder in place of a tracked file or link, and stashing could delete what's in it for good. Commit the change or move the folder somewhere else, then try again.3351Error: Nothing was stashed: "f" is now a folder in place of a tracked file or link, and stashing could delete what's in it for good. Commit the change or move the folder somewhere else, then try again.


3341 3353 

3342**處理方式:**3354**處理方式:**

3343 3355 

3344* 依照訊息所述,提交變更或將資料夾移到其他位置,然後再次執行 teleport3356* 依訊息所述,提交該變更或將資料夾移到其他地方,然後再次執行 teleport

3345 3357 

3346### `--json-schema` 的值不是有效的 JSON Schema3358### `--json-schema` 的值不是有效的 JSON Schema

3347 3359 

3348您在[非互動模式](https://code.claude.com/docs/zh-TW/headless.md#get-structured-output)中傳給 [`--json-schema`](https://code.claude.com/docs/zh-TW/cli-reference#cli-flags) 的 schema 未能通過 JSON Schema 編譯,因此 `claude` 會以退出碼 1 結束,而不會執行提示詞。在 v2.1.205 之前,無效的 schema 會產生非結構化輸出且不報錯,而且任何使用 `format` 關鍵字的 schema 都會被視為無效。3360您在[非互動模式](https://code.claude.com/docs/zh-TW/headless.md#get-structured-output)中傳給 [`--json-schema`](https://code.claude.com/docs/zh-TW/cli-reference#cli-flags) 的 schema 未能通過 JSON Schema 編譯,因此 `claude` 會以退出碼 1 結束,而不會執行提示詞。在 v2.1.205 之前,無效的 schema 會產生非結構化輸出且不會出現錯誤,而任何使用 `format` 關鍵字的 schema 都會被視為無效。

3349 3361 

3350```text theme={null}3362```text theme={null}

3351Error: --json-schema is not a valid JSON Schema: data/type must be equal to one of the allowed values3363Error: --json-schema is not a valid JSON Schema: data/type must be equal to one of the allowed values

3352```3364```

3353 3365 

3354第二個冒號之後的文字是驗證器的診斷訊息,會指出失敗的關鍵字或位置。使用 `format` 關鍵字的 schema(例如 `"format": "email"`)是有效的:Claude Code 將 `format` 視為註解接受,而不會強制執行它。3366第二個冒號之後的文字是驗證器的診斷訊息,會列出失敗的關鍵字或位置。使用 `format` 關鍵字的 schema(例如 `"format": "email"`)是有效的:Claude Code 將 `format` 視為註記接受,但不會強制執行。

3355 3367 

3356Claude Code 在 schema 編譯之前會執行兩項檢查:對於無法解析的 JSON 值,會以 `Error: --json-schema is not valid JSON` 拒絕;對於有效但不是物件的 JSON,會以 `Error: --json-schema must be a JSON object` 拒絕。3368Claude Code 會在 schema 編譯之前執行兩項檢查:對於無法解析為 JSON 的值,會以 `Error: --json-schema is not valid JSON` 拒絕;對於不是物件的有效 JSON,會以 `Error: --json-schema must be a JSON object` 拒絕。

3357 3369 

3358**處理方式:**3370**處理方式:**

3359 3371 

3360* 修正診斷訊息指出的 schema 部分,然後重新執行命令3372* 修正診斷訊息所指出的 schema 部分,然後重新執行命令

3361* 請參閱[取得結構化輸出](https://code.claude.com/docs/zh-TW/headless.md#get-structured-output),了解可運作的 schema 與命令3373* 請參閱[取得結構化輸出](https://code.claude.com/docs/zh-TW/headless.md#get-structured-output)以取得可運作的 schema 與命令

3362 3374 

3363### 設定檔超過 2MiB 上限3375### Settings file exceeds the 2MiB limit

3364 3376 

3365您傳給 [`--settings`](https://code.claude.com/docs/zh-TW/cli-reference#cli-flags) 的檔案大於 2 MiB,因此 `claude` 會在啟動時以退出碼 1 結束,而不會載入它。在 v2.1.214 之前,Claude Code 讀取該檔案時不做大小檢查,數 GB 的檔案或像 `/dev/zero` 這樣的裝置檔案會使記憶體無限制地增長。3377您傳給 [`--settings`](https://code.claude.com/docs/zh-TW/cli-reference#cli-flags) 的檔案大於 2 MiB,因此 `claude` 會在啟動時以退出碼 1 結束,而不會載入它。在 v2.1.214 之前,Claude Code 讀取該檔案時不會檢查大小,多達數 GB 的檔案或 `/dev/zero` 之類的裝置檔案會使記憶體用量無限制地增長。

3366 3378 

3367```text theme={null}3379```text theme={null}

3368Error: Settings file exceeds the 2MiB limit: /path/to/settings.json3380Error: Settings file exceeds the 2MiB limit: /path/to/settings.json

3369```3381```

3370 3382 

3371Claude Code 也會以相同方式拒絕不是一般檔案的 `--settings` 路徑:裝置、FIFO 或 socket 會回報 `Error: Cannot use settings file (Not a regular file (device, FIFO, or socket))`,後面接著路徑;而目錄則會回報 `EISDIR` 原因。3383對於不是一般檔案的 `--settings` 路徑,Claude Code 也會以同樣方式拒絕:裝置、FIFO 或 socket 會回報 `Error: Cannot use settings file (Not a regular file (device, FIFO, or socket))` 並接著列出路徑,而目錄則會回報 `EISDIR` 原因。

3372 3384 

3373**處理方式:**3385**處理方式:**

3374 3386 


3376 3388 

3377### Configuration error in \~/.claude.json3389### Configuration error in \~/.claude.json

3378 3390 

3379Claude Code 無法解析 `~/.claude.json`,也就是保存您的帳戶資訊、MCP 伺服器與各專案狀態的檔案。[非互動式](https://code.claude.com/docs/zh-TW/headless.md)啟動(例如 `claude -p`)會以退出碼 1 結束。3391Claude Code 無法解析 `~/.claude.json`,這個檔案存放您的帳戶詳細資料、MCP 伺服器以及各專案的狀態。像 `claude -p` 這類[非互動](https://code.claude.com/docs/zh-TW/headless.md)啟動會以退出碼 1 結束。

3380 3392 

3381當 Claude Code 找到[備份](https://code.claude.com/docs/zh-TW/claude-directory.md#cleaned-up-automatically)時,輸出會指名該備份,並輸出一行將其複製回來的 `cp` 命令:3393當 Claude Code 找到[備份](https://code.claude.com/docs/zh-TW/claude-directory.md#cleaned-up-automatically)時,輸出會列出該備份,並印出一行將其複製回去的 `cp` 命令:

3382 3394 

3383```text wrap theme={null}3395```text wrap theme={null}

3384Claude configuration file at /home/user/.claude.json is corrupted: <JSON parser's message>3396Claude configuration file at /home/user/.claude.json is corrupted: <JSON parser's message>


3391 3403 

3392**處理方式:**3404**處理方式:**

3393 3405 

3394* **輸出中有 `cp` 行**:在終端機中執行該行。在 Windows 上,請在 PowerShell 中執行。3406* **輸出中有 `cp` 這一行**:在終端機中執行該行。在 Windows 上,請在 PowerShell 中執行。

3395* **輸出中沒有 `cp` 行,或執行後錯誤再次出現**:若 `~/.claude.json` 仍保有您的設定,請修正其 JSON。若無法修正,若 [`~/.claude/backups/`](https://code.claude.com/docs/zh-TW/claude-directory#cleaned-up-automatically) 中有其他 `.claude.json.backup.<timestamp>` 檔案,請將其複製過去覆寫該檔案,或將該檔案重新命名。若 `~/.claude.json` 不存在,Claude Code 會以預設設定啟動,且不會保有該檔案原本的任何內容。3407* **輸出中沒有 `cp` 這一行,或執行後錯誤再次出現**:如果 `~/.claude.json` 仍保有您的設定,請修正其 JSON。如果無法修正,若 [`~/.claude/backups/`](https://code.claude.com/docs/zh-TW/claude-directory#cleaned-up-automatically) 中有其他 `.claude.json.backup.<timestamp>` 檔案,請將其複製覆蓋過去,否則請將其重新命名。當 `~/.claude.json` 不存在時,Claude Code 會以預設設定啟動,且不包含該檔案原本存放的任何內容。

3396* **`~/.claude.json` 已不再保有您的設定**:在 [`~/.claude/backups/`](https://code.claude.com/docs/zh-TW/claude-directory#cleaned-up-automatically) 或您的家目錄中找出仍保有設定的 `.claude.json.corrupted.<timestamp>` 檔案。修正其 JSON,然後將其複製過去覆寫 `~/.claude.json`。若找不到或無法修正,請以保有您設定的 `.claude.json.backup.<timestamp>` 檔案嘗試相同步驟。若都沒有,請將 `~/.claude.json` 重新命名,並以 [`claude mcp add`](https://code.claude.com/docs/zh-TW/mcp#installing-mcp-servers) 重新加入您的 MCP 伺服器。3408* **`~/.claude.json` 已不再保有您的設定**:在 [`~/.claude/backups/`](https://code.claude.com/docs/zh-TW/claude-directory#cleaned-up-automatically) 或您的家目錄中,找出仍保有設定的 `.claude.json.corrupted.<timestamp>` 檔案。修正其 JSON,然後將其複製覆蓋 `~/.claude.json`。如果找不到或無法修正,請以保有您設定的 `.claude.json.backup.<timestamp>` 檔案嘗試相同步驟。如果沒有任何檔案保有您的設定,請將 `~/.claude.json` 重新命名,並使用 [`claude mcp add`](https://code.claude.com/docs/zh-TW/mcp#installing-mcp-servers) 重新新增您的 MCP 伺服器。

3397 3409 

3398### Claude configuration file was empty and no backup holds anything3410### Claude configuration file was empty and no backup holds anything

3399 3411 

3400啟動時出現此訊息,表示其所指名的檔案是空白的,且該檔案的所有 [`.backup` 副本](https://code.claude.com/docs/zh-TW/claude-directory#cleaned-up-automatically)都沒有任何內容。Claude Code 已針對該檔案保存的內容使用預設值啟動。您的 `settings.json` 檔案與 `.mcp.json` 是獨立的檔案。3412啟動時出現此訊息,表示它所列出的檔案是空白的,且該檔案的 [`.backup` 副本](https://code.claude.com/docs/zh-TW/claude-directory#cleaned-up-automatically)中沒有任何內容。Claude Code 對該檔案存放的內容以預設值啟動。您的 `settings.json` 檔案與 `.mcp.json` 是獨立的檔案。

3401 3413 

3402```text wrap theme={null}3414```text wrap theme={null}

3403Claude configuration file at /home/user/.claude.json was empty and no backup holds anything: starting with defaults.3415Claude configuration file at /home/user/.claude.json was empty and no backup holds anything: starting with defaults.


3405 3417 

3406**處理方式:**3418**處理方式:**

3407 3419 

3408* 重新設定您原本在該檔案中設定的內容。例如,從終端機使用 `claude mcp add` 新增您 `user` 與 `local` 範圍的 [MCP 伺服器](https://code.claude.com/docs/zh-TW/mcp.md#mcp-installation-scopes)。3420* 重新設定您原本在該檔案中設定的內容。例如,在終端機中使用 `claude mcp add` 新增您 `user` 與 `local` 範圍的 [MCP 伺服器](https://code.claude.com/docs/zh-TW/mcp.md#mcp-installation-scopes)。

3409* 如果 Claude Code 要求您重新登入,請重新登入3421* 如果 Claude Code 要求,請重新登入

3410 3422 

3411在 v2.1.318 之前,Claude Code 會將沒有備份的空白檔案回報為[已損壞](#configuration-error-in-claude-json)。3423在 v2.1.318 之前,Claude Code 會將沒有備份的空白檔案回報為[已損毀](#configuration-error-in-claude-json)。

3412 3424 

3413### 目前的目錄已不存在3425### The current directory no longer exists

3414 3426 

3415您從一個在 shell 進入後被刪除或移動的目錄啟動了 `claude`,例如被另一個 shell 移除的 worktree 或暫存目錄。Claude Code 無法讀取其工作目錄,因此在啟動工作階段之前就會以退出碼 1 結束,互動模式與[非互動](https://code.claude.com/docs/zh-TW/headless.md)模式皆然。在 v2.1.239 之前,Claude Code 會當機,並在 stderr 上輸出壓縮過的 bundle 原始碼與原始的 `ENOENT ... uv_cwd` 堆疊,而不是此訊息。3427您從一個在 shell 進入後已被刪除或移動的目錄啟動 `claude`,例如被另一個 shell 移除的 worktree 或暫存目錄。Claude Code 無法讀取其工作目錄,因此無論是互動模式或[非互動](https://code.claude.com/docs/zh-TW/headless.md)模式,都會在啟動工作階段前以退出碼 1 結束。在 v2.1.239 之前,Claude Code 會當機,並在 stderr 上印出經過壓縮的 bundle 原始碼與原始的 `ENOENT ... uv_cwd` 堆疊,而不是此訊息。

3416 3428 

3417```text theme={null}3429```text theme={null}

3418The current directory no longer exists (it was deleted or moved). Start Claude Code from an existing directory.3430The current directory no longer exists (it was deleted or moved). Start Claude Code from an existing directory.


3421 3433 

3422兩種形式的原因與修正方式相同。3434兩種形式的原因與修正方式相同。

3423 3435 

3424當 Claude Code 因其他原因(例如權限變更)無法讀取工作目錄時,訊息會改為指出錯誤代碼:`Can't read the current directory (EACCES). Start Claude Code from a different directory.`3436當 Claude Code 因其他原因(例如權限變更)無法讀取工作目錄時,訊息會改為列出錯誤代碼:`Can't read the current directory (EACCES). Start Claude Code from a different directory.`

3425 3437 

3426在 macOS 上,若 `~/Desktop`、`~/Documents`、`~/Downloads` 或 iCloud Drive 中的目錄出現 `EPERM`,通常表示 macOS 正在阻擋您的終端機應用程式存取該資料夾。讀取該資料夾的其他命令也會以相同方式失敗:在那裡執行 `ls` 會回報 `Operation not permitted`,即使使用 `sudo` 也一樣。3438在 macOS 上,對於位於 `~/Desktop`、`~/Documents`、`~/Downloads` 或 iCloud Drive 中的目錄出現 `EPERM`,通常表示 macOS 正在封鎖您的終端機應用程式存取該資料夾。讀取該資料夾的其他命令也會以同樣方式失敗:在該處執行 `ls` 會回報 `Operation not permitted`,即使使用 `sudo` 也一樣。

3427 3439 

3428**處理方式:**3440**處理方式:**

3429 3441 

3430* 切換到存在的目錄,例如您的家目錄或專案目錄,然後再次執行 `claude`3442* 切換到存在的目錄,例如您的家目錄或專案目錄,然後再次執行 `claude`

3431* 如果該目錄已在相同路徑重新建立,您的 shell 仍持有已刪除的那一個。請執行 `cd "$PWD"`,或離開後重新進入該目錄,然後再次執行 `claude`3443* 如果該目錄已在相同路徑重新建立,您的 shell 仍持有已刪除的那個目錄。請執行 `cd "$PWD"` 或離開後重新進入該目錄,然後再次執行 `claude`

3432* 對於 macOS 上的 `EPERM`,請以 Cmd+Q 結束您的終端機應用程式,再次開啟它,回到該資料夾,然後執行 `claude`。如果在該資料夾中執行 `ls` 仍然失敗,請開啟 **系統設定 > 隱私權與安全性 > 檔案與檔案夾**,為您的終端機應用程式開啟該資料夾,然後重新開啟終端機3444* 對於 macOS 上的 `EPERM`,請以 Cmd+Q 結束您的終端機應用程式,再重新開啟,回到該資料夾並執行 `claude`。如果在該資料夾中 `ls` 仍然失敗,請開啟 **System Settings > Privacy & Security > Files and Folders**,為您的終端機應用程式開啟該資料夾的存取權,然後重新開啟終端機

3433 3445 

3434### 暫存目錄被拒絕使用或無法建立3446### 暫存目錄遭拒絕或無法建立

3435 3447 

3436在 macOS 與 Linux 上,Claude Code 會在啟動時建立一個私人暫存目錄 `claude-<uid>`,位於系統暫存目錄或 [`CLAUDE_CODE_TMPDIR`](https://code.claude.com/docs/zh-TW/env-vars) 覆寫值之下。當該目錄無法建立,或該路徑上已存在的項目未通過安全檢查時,Claude Code 會將失敗原因列印到 stderr,並以退出碼 1 結束,而不會啟動工作階段:3448在 macOS 與 Linux 上,Claude Code 會在啟動時建立一個私人暫存目錄 `claude-<uid>`,位於系統暫存目錄或 [`CLAUDE_CODE_TMPDIR`](https://code.claude.com/docs/zh-TW/env-vars) 覆寫所指定的位置下。當該目錄無法建立,或該路徑上既有的項目未通過安全檢查時,Claude Code 會將失敗原因印到 stderr,並以退出碼 1 結束,而不會啟動工作階段:

3437 3449 

3438```text wrap theme={null}3450```text wrap theme={null}

3439Claude Code's temporary directory /tmp/claude-501 could not be created: the volume holding /tmp is full (ENOSPC). Free space on that volume, or set CLAUDE_CODE_TMPDIR to a directory on another one, then try again.3451Claude Code's temporary directory /tmp/claude-501 could not be created: the volume holding /tmp is full (ENOSPC). Free space on that volume, or set CLAUDE_CODE_TMPDIR to a directory on another one, then try again.


3447 3459 

3448**處理方式:**3460**處理方式:**

3449 3461 

3450* 對於 `could not be created` 後接 `is full (ENOSPC)` 的情況,請釋放訊息所指出磁碟區上的磁碟空間。當訊息改為 `your disk quota on the volume holding /tmp is used up (EDQUOT)` 時,請刪除您在該磁碟區上不再需要的自有檔案3462* 對於 `could not be created` 後接 `is full (ENOSPC)` 的情況,請釋放訊息所列磁碟區上的磁碟空間。如果訊息改為 `your disk quota on the volume holding /tmp is used up (EDQUOT)`,請刪除您在該磁碟區上不再需要的檔案

3451* 對於 `Refusing to use it` 形式,請移除所指名的項目本身(而不是連結所指向的目標),然後再次啟動 Claude Code;對於 `owned by uid` 形式,只有管理員或該使用者能夠移除它3463* 對於 `Refusing to use it` 的各種形式,請移除所列出的項目本身,而不是連結所指向的目標,然後再次啟動 Claude Code;對於 `owned by uid` 形式,只有管理員或該使用者可以移除它

3452* 對於 `is not readable`,請對所指名的目錄執行 `chmod 0700`,或移除它後再次啟動3464* 對於 `is not readable`,請對所列出的目錄執行 `chmod 0700`,或將其移除後重新啟動

3453* 在上述任何情況下,您都可以將 [`CLAUDE_CODE_TMPDIR`](https://code.claude.com/docs/zh-TW/env-vars) 設為您能控制的目錄,然後再次啟動 Claude Code,而不去動被拒絕的路徑3465* 在上述任何情況下,您都可以將 [`CLAUDE_CODE_TMPDIR`](https://code.claude.com/docs/zh-TW/env-vars) 設定為您能控制的目錄,然後再次啟動 Claude Code,不去動被拒絕的路徑

3454 3466 

3455在 v2.1.309 之前,當磁碟區已滿或您的配額已用完時,Claude Code 只會印出作業系統的錯誤文字。例如 `ENOSPC: no space left on device, mkdir '/tmp/claude-501'`,處理步驟相同。3467在 v2.1.309 之前,當磁碟區已滿或您的配額已用完時,Claude Code 只會印出作業系統的錯誤文字。例如 `ENOSPC: no space left on device, mkdir '/tmp/claude-501'`,適用相同的處理步驟。

3456 3468 

3457### Claude Code 因磁碟已滿而無法儲存3469### Claude Code 因磁碟已滿而無法儲存

3458 3470 

3459在 [`claude -p`](https://code.claude.com/docs/zh-TW/headless) 執行後,stderr 上出現這一行表示磁碟已滿或您的磁碟配額已用盡,因此 Claude Code 無法儲存該次執行的所有內容:3471在 [`claude -p`](https://code.claude.com/docs/zh-TW/headless) 執行後於 stderr 出現這一行,表示磁碟已滿或您的磁碟配額已用完,因此 Claude Code 無法儲存該次執行的所有內容:

3460 3472 

3461```text wrap theme={null}3473```text wrap theme={null}

3462Error: Claude Code could not save all of this session's transcript under /Users/you/.claude because the disk is full (ENOSPC). If you resume this session, part of the conversation may be missing. Free up space on that disk before the next run.3474Error: Claude Code could not save all of this session's transcript under /Users/you/.claude because the disk is full (ENOSPC). If you resume this session, part of the conversation may be missing. Free up space on that disk before the next run.

3463```3475```

3464 3476 

3465使用文字或 `json` 輸出時,該次執行會以退出碼 1 結束,而答案已經印出。使用 `stream-json` 輸出時,該次執行會維持其一般的退出碼,答案仍會送達。3477使用文字或 `json` 輸出時,該次執行會以退出碼 1 結束,且答案已經印出。使用 `stream-json` 輸出時,該次執行會保持其一般的退出碼,答案仍會送達。

3466 3478 

3467**處理方式:**3479**處理方式:**

3468 3480 

3469* **`the disk is full (ENOSPC)`**:在下次執行前,釋放包含訊息中路徑之磁碟上的空間3481* **`the disk is full (ENOSPC)`**:在下次執行之前,釋放存放訊息中路徑之磁碟上的空間

3470* **`your disk quota is used up (EDQUOT)`**:在下次執行前,釋放空間或要求更大的配額3482* **`your disk quota is used up (EDQUOT)`**:在下次執行之前,釋放空間或申請更大的配額

3471 3483 

3472### 目錄無法解析為實際位置3484### Directory couldn't be resolved to a real location

3473 3485 

3474您對工作目錄的子目錄執行了 `/add-dir`,而 Claude Code 無法將該目錄解析為其實際位置。3486您對工作目錄的某個子目錄執行了 `/add-dir`,而 Claude Code 無法將該目錄解析為其實際位置。

3475 3487 

3476您本來就擁有工作目錄之子目錄的檔案存取權,因此 `/add-dir` 只會載入其 skill、命令與 agent。在載入之前,Claude Code 會檢查該目錄的實際位置(解析所有符號連結後)是否位於工作目錄內。當 Claude Code 無法解析該位置時,它不會載入任何內容,並顯示此訊息:3488您對工作目錄的子目錄本來就有檔案存取權,因此 `/add-dir` 只會載入其 skill、命令與 agent。在載入之前,Claude Code 會檢查該目錄的實際位置(已解析所有符號連結)是否位於工作目錄內。當 Claude Code 無法解析該位置時,它不會載入任何內容,並顯示此訊息:

3477 3489 

3478```text theme={null}3490```text theme={null}

3479packages/app couldn't be resolved to a real location, so its skills, commands, and agents weren't loaded. Check that it is a directory inside the working directory and try again.3491packages/app couldn't be resolved to a real location, so its skills, commands, and agents weren't loaded. Check that it is a directory inside the working directory and try again.


3481 3493 

3482**處理方式:**3494**處理方式:**

3483 3495 

3484* 確認該路徑指向工作目錄內的一個實際目錄,然後再次執行 `/add-dir`3496* 確認該路徑指向工作目錄內的實際目錄,然後再次執行 `/add-dir`

3485* 此訊息不會變更您的檔案存取權;它只是回報該目錄的 `.claude/` 內容未被載入3497* 此訊息不會改變您的檔案存取權;它只是回報該目錄的 `.claude/` 內容未被載入

3486 3498 

3487在 v2.1.261 之前,當工作目錄位於 `/net/<host>` 自動掛載點時,每次執行 `/add-dir <subdirectory>` 也都會出現此訊息,因為 Claude Code 在設計上不會解析該處的路徑;該目錄本身沒有問題,重試也無濟於事。3499在 v2.1.261 之前,當工作目錄位於 `/net/<host>` 自動掛載點上時(Claude Code 依設計不會解析這類路徑),每次執行 `/add-dir <subdirectory>` 都會出現此訊息;該目錄本身沒有問題,重試也無濟於事。

3488 3500 

3489### 啟動 Remote Control 時工作區未受信任3501### 啟動 Remote Control 時出現 Workspace not trusted

3490 3502 

3491> [!NOTE]3503> [!NOTE]

3492>3504>

3493> 如果 `claude ultrareview` 印出了 `Error: Workspace not trusted`,請改為參閱[執行 claude ultrareview 時出現 Workspace not trusted](#workspace-not-trusted-when-running-claude-ultrareview)。3505> 如果 `claude ultrareview` 印出了 `Error: Workspace not trusted`,請改為參閱[執行 claude ultrareview 時出現 Workspace not trusted](#workspace-not-trusted-when-running-claude-ultrareview)。

3494 3506 

3495您在尚未信任的目錄中,以 `claude remote-control` 或其別名 `claude rc` 啟動了 [Remote Control](https://code.claude.com/docs/zh-TW/remote-control.md) 伺服器模式,而該命令無法詢問您是否信任該目錄。例如,該命令的標準輸入或標準輸出不是終端機,因為其中之一被重新導向或透過管線傳送。該命令會以退出碼 1 結束:3507您在尚未信任的目錄中,以 `claude remote-control` 或其別名 `claude rc` 啟動 [Remote Control](https://code.claude.com/docs/zh-TW/remote-control.md) 伺服器模式,而該命令無法詢問您是否信任該目錄。例如,該命令的標準輸入或標準輸出不是終端機,因為其中之一被重新導向或透過管線傳送。該命令會以退出碼 1 結束:

3496 3508 

3497```text theme={null}3509```text theme={null}

3498Error: Workspace not trusted. Please run `claude` in /Users/you/project first to review and accept the workspace trust dialog.3510Error: Workspace not trusted. Please run `claude` in /Users/you/project first to review and accept the workspace trust dialog.

3499```3511```

3500 3512 

3501另有兩種同樣以 `Error: Workspace not trusted.` 開頭的變體,會出現在太小而無法顯示信任該目錄會啟用哪些功能的終端機中,或未回報其大小的終端機中。請放大視窗或切換到一般終端機視窗,然後再次執行 `claude rc`。3513在太小而無法顯示信任該目錄會啟用哪些功能的終端機中,或在未回報其大小的終端機中,會出現另外兩種同樣以 `Error: Workspace not trusted.` 開頭的變體。請放大視窗或切換到一般的終端機視窗,然後再次執行 `claude rc`。

3502 3514 

3503在您的家目錄中,訊息會有所不同,因為工作區信任對話框永遠不會儲存對家目錄的信任,所以在那裡接受信任無法滿足此檢查。在 v2.1.214 之前,家目錄會顯示上述訊息,但其建議在那裡無法奏效。3515在您的家目錄中,訊息會有所不同,因為工作區信任對話框永遠不會儲存家目錄的信任設定,因此在那裡接受信任無法滿足此項檢查。在 v2.1.214 之前,家目錄會顯示上述訊息,而其建議在那裡無法成功。

3504 3516 

3505```text theme={null}3517```text theme={null}

3506Error: Workspace not trusted. /Users/you is your home directory, and for security home-directory trust is never saved, so running `claude` here first won't help. Run `claude rc` from a project directory instead (run `claude` there once to accept the trust dialog).3518Error: Workspace not trusted. /Users/you is your home directory, and for security home-directory trust is never saved, so running `claude` here first won't help. Run `claude rc` from a project directory instead (run `claude` there once to accept the trust dialog).

3507```3519```

3508 3520 

3509如果您在 [`Trust <directory>?` 問題](https://code.claude.com/docs/zh-TW/remote-control#requirements)回答 `n` 或按下 Enter,該命令會列印一則指出該目錄的 `Remote Control did not start` 訊息,並以退出碼 1 結束。請再次執行 `claude rc` 並回答 `y`。3521如果您在 [`Trust <directory>?` 問題](https://code.claude.com/docs/zh-TW/remote-control#requirements)中回答 `n` 或按下 Enter,該命令會印出一則列出該目錄的 `Remote Control did not start` 訊息,並以退出碼 1 結束。請再次執行 `claude rc` 並回答 `y`。

3510 3522 

3511**處理方式:**3523**處理方式:**

3512 3524 

3513* 先從終端機信任該目錄:在該處執行 `claude rc` 並回答 `y`,或在該處執行 `claude` 並接受[工作區信任對話框](https://code.claude.com/docs/zh-TW/permissions.md#project-allow-rules-and-workspace-trust),然後再次執行您原本的命令3525* 先從終端機信任該目錄:在該處執行 `claude rc` 並回答 `y`,或在該處執行 `claude` 並接受[工作區信任對話框](https://code.claude.com/docs/zh-TW/permissions.md#project-allow-rules-and-workspace-trust),然後再次執行您原本的命令

3514* 在您的家目錄中,請切換到專案目錄,並在那裡啟動 Remote Control3526* 在您的家目錄中,請切換到專案目錄並在那裡啟動 Remote Control

3515 3527 

3516在 v2.1.284 之前,即使在終端機中,該命令也從不詢問。3528在 v2.1.284 之前,即使在終端機中,該命令也從不詢問。

3517 3529 


3527 3539 

3528**處理方式:**3540**處理方式:**

3529 3541 

3530* 在指令碼或 CI 工作中,附加 `--trust-workspace` 以僅在該次執行中信任該資料夾:`claude ultrareview --trust-workspace`。請僅對您信任的程式碼附加此旗標,因為 git 與 Claude Code 之後可能會執行該資料夾的 git 設定與專案設定中所指定的程式。對於您不信任其程式碼的 pull request,請[從您信任的分支執行審查](https://code.claude.com/docs/zh-TW/ultrareview.md#trust-the-folder-before-the-review-runs)。3542* 在指令碼或 CI 工作中,附加 `--trust-workspace` 以在該次執行中信任該資料夾:`claude ultrareview --trust-workspace`。請只對您信任的程式碼附加此旗標,因為 git 與 Claude Code 之後可能會執行該資料夾的 git 設定與專案設定中指定的程式。對於您不信任其程式碼的 pull request,請[從您信任的分支執行審查](https://code.claude.com/docs/zh-TW/ultrareview.md#trust-the-folder-before-the-review-runs)。

3531* 在您自己的電腦上,於該資料夾中執行 `claude` 並接受[工作區信任對話框](https://code.claude.com/docs/zh-TW/permissions.md#project-allow-rules-and-workspace-trust),然後再次執行原本的命令3543* 在您自己的電腦上,於該資料夾中執行 `claude` 並接受[工作區信任對話框](https://code.claude.com/docs/zh-TW/permissions.md#project-allow-rules-and-workspace-trust),然後再次執行您原本的命令

3532 3544 

3533`claude ultrareview` 的下列每則訊息都表示沒有啟動任何審查,且退出碼為 1:3545`claude ultrareview` 的下列每則訊息都表示沒有啟動任何審查,且退出碼為 1:

3534 3546 

3535* **`Error: Workspace not trusted. This terminal ...`**:終端機未回報列數與欄數,或無法容納信任問題及其警告。請放大終端機或使用會回報其大小的終端機,然後再次執行 `claude ultrareview`。在家目錄以外,您也可以在該資料夾中執行一次 `claude` 並接受信任對話框,之後在那裡的執行就不會再詢問。3547* **`Error: Workspace not trusted. This terminal ...`**:終端機未回報其列數與欄數,或無法容納信任問題及其警告。請放大終端機或使用會回報其大小的終端機,然後再次執行 `claude ultrareview`。在家目錄以外的位置,您也可以在該資料夾中執行一次 `claude` 並接受信任對話框,之後在那裡執行就不會再詢問。

3536* **`Error: Workspace not trusted. <folder> is your home directory`**:由於對家目錄的信任永遠不會被儲存,先在那裡執行 `claude` 並沒有幫助。請改從專案目錄執行 `claude ultrareview`(事先在那裡執行一次 `claude` 以接受信任對話框),或附加 `--trust-workspace`。3548* **`Error: Workspace not trusted. <folder> is your home directory`**:由於家目錄的信任設定永遠不會被儲存,先在該處執行 `claude` 無濟於事。請改從專案目錄執行 `claude ultrareview`(先在那裡執行一次 `claude` 以接受信任對話框),或附加 `--trust-workspace`。

3537* **`No answer in time.` 後接 `Error: Workspace not trusted`**:`Trust <folder>? [y/N]` 問題在 5 分鐘內未獲回答。請再次執行 `claude ultrareview` 並回答它。3549* **`No answer in time.` 後接 `Error: Workspace not trusted`**:`Trust <folder>? [y/N]` 問題在 5 分鐘內未獲回答。請再次執行 `claude ultrareview` 並回答問題。

3538* **`Ultrareview did not start: <folder> is not trusted`**:您在 `Trust <folder>? [y/N]` 問題中拒絕了,例如回答 `n` 或按下 Enter。若要啟動審查,請再次執行 `claude ultrareview` 並回答 `y`。3550* **`Ultrareview did not start: <folder> is not trusted`**:您在 `Trust <folder>? [y/N]` 問題中拒絕了,例如回答 `n` 或按下 Enter。若要開始審查,請再次執行 `claude ultrareview` 並回答 `y`。

3539* **``Ultrareview did not start: `--trust-workspace` takes no value``**:`--trust-workspace` 後面接了旗標以外的內容,例如 PR 編號或 `false`。如果您不信任該資料夾,請省略此旗標。若要在此次執行中信任它,請將 PR 編號或基礎分支放在旗標之前:`claude ultrareview 1234 --trust-workspace`。3551* **``Ultrareview did not start: `--trust-workspace` takes no value``**:`--trust-workspace` 後面接著旗標以外的內容,例如 PR 編號或 `false`。如果您不信任該資料夾,請省略此旗標。若要在此次執行中信任它,請將 PR 編號或基底分支放在旗標之前:`claude ultrareview 1234 --trust-workspace`。

3540 3552 

3541在 v2.1.309 之前,`claude ultrareview` 不接受 `--trust-workspace`。3553在 v2.1.309 之前,`claude ultrareview` 不接受 `--trust-workspace`。

3542 3554 

3543### Remote Control 因問題未獲回答而未啟動3555### Remote Control 因問題未獲回答而未啟動

3544 3556 

3545此訊息表示 [`claude remote-control`](https://code.claude.com/docs/zh-TW/remote-control) 詢問了訊息中引述的首次執行問題,但沒有得到回答:3557此訊息表示 [`claude remote-control`](https://code.claude.com/docs/zh-TW/remote-control) 提出了訊息中所引用的首次執行問題,但沒有得到回答:

3546 3558 

3547```text theme={null}3559```text theme={null}

3548Remote Control did not start: "Enable Remote Control?" got no answer. Run `claude remote-control` at a terminal and answer y once; it won't ask again.3560Remote Control did not start: "Enable Remote Control?" got no answer. Run `claude remote-control` at a terminal and answer y once; it won't ask again.


3551 3563 

3552**處理方式:**3564**處理方式:**

3553 3565 

3554* **`Enable Remote Control?`**:在腳本或服務中,標準輸入會在任何人能回答之前結束。請以您的腳本或服務執行時所用的使用者身分,在終端機中執行一次 `claude remote-control` 並回答 `y`。3566* **`Enable Remote Control?`**:在指令碼或服務中,標準輸入會在任何人能回答之前就結束。請以您的指令碼或服務執行時所用的使用者身分,在終端機中執行一次 `claude remote-control` 並回答 `y`。

3555* **`Choose [1/2] (default: 1):`**:再次執行 `claude remote-control` 並[選擇產生模式](https://code.claude.com/docs/zh-TW/remote-control.md#set-the-default-spawn-mode-for-a-project),或傳入 [`--spawn=same-dir` 或 `--spawn=worktree`](https://code.claude.com/docs/zh-TW/remote-control#start-a-remote-control-session) 以跳過此問題3567* **`Choose [1/2] (default: 1):`**:再次執行 `claude remote-control` 並[選擇產生模式](https://code.claude.com/docs/zh-TW/remote-control.md#set-the-default-spawn-mode-for-a-project),或傳入 [`--spawn=same-dir` 或 `--spawn=worktree`](https://code.claude.com/docs/zh-TW/remote-control#start-a-remote-control-session) 以略過此問題

3556 3568 

3557### 不會傳遞到 Remote Control 所啟動的工作階段3569### Not carried over to the sessions Remote Control starts

3558 3570 

3559您在 `remote-control` 動詞之前加上了全域 `claude` 旗標來啟動 [Remote Control](https://code.claude.com/docs/zh-TW/remote-control.md),而該旗標會限制或設定 Remote Control 所啟動的工作階段,例如 `--settings`、`--setting-sources`、`--permission-mode`、`--disallowed-tools` 或 `--mcp-config`。放在動詞之前的旗標永遠不會傳到這些工作階段。Claude Code 會改為拒絕啟動,並指出該旗標:3571您在 `remote-control` 動詞之前加上了某個全域 `claude` 旗標來啟動 [Remote Control](https://code.claude.com/docs/zh-TW/remote-control.md),而該旗標會限制或設定 Remote Control 所啟動的工作階段,例如 `--settings`、`--setting-sources`、`--permission-mode`、`--disallowed-tools` 或 `--mcp-config`。放在動詞之前的旗標永遠不會傳遞到這些工作階段。Claude Code 會改為拒絕啟動,並列出該旗標:

3560 3572 

3561```text theme={null}3573```text theme={null}

3562Error: `--settings` before `remote-control` is not carried over to the sessions Remote Control starts, so Remote Control refuses to start rather than drop it — remove it, and give Remote Control's own options after the verb (see `claude remote-control --help`). Pass settings with `claude remote-control --settings <file>`.3574Error: `--settings` before `remote-control` is not carried over to the sessions Remote Control starts, so Remote Control refuses to start rather than drop it — remove it, and give Remote Control's own options after the verb (see `claude remote-control --help`). Pass settings with `claude remote-control --settings <file>`.

3563```3575```

3564 3576 

3565對於捨棄後無害的全域旗標,例如 `--verbose`、`--model`,或由包裝程式注入的 `--session-id` 或 `--plugin-dir`,Claude Code 不會拒絕:它會忽略這些旗標,Remote Control 會照常啟動。3577對於可以無害地捨棄的全域旗標,例如 `--verbose`、`--model`,或由包裝程式注入的 `--session-id` 或 `--plugin-dir`,Claude Code 不會拒絕:它會忽略這些旗標,Remote Control 會照常啟動。

3566 3578 

3567對於尚未被認定為無害的全域旗標,Claude Code 也會拒絕啟動,因此在較新版本中新增的旗標可能會出現在此訊息中,直到之後的版本將其標記為無害為止。3579對於 Claude Code 尚未認定為無害的全域旗標,它也會拒絕啟動,因此在較新版本中新增的旗標可能會出現在此訊息中,直到後續版本將其標記為無害為止。

3568 3580 

3569**處理方式:**3581**處理方式:**

3570 3582 

3571* 將該旗標從動詞之前移除,並在動詞之後傳入 [Remote Control 自身的選項](https://code.claude.com/docs/zh-TW/remote-control.md#start-a-remote-control-session);`claude remote-control --help` 會列出這些選項3583* 將該旗標從動詞之前移除,並在動詞之後傳入 [Remote Control 本身的選項](https://code.claude.com/docs/zh-TW/remote-control.md#start-a-remote-control-session);`claude remote-control --help` 會列出這些選項

3572* 當被拒絕的旗標是 `--permission-mode` 時,請執行 `claude remote-control --permission-mode <mode>`,為 Remote Control 所啟動的工作階段設定權限模式3584* 當被拒絕的旗標是 `--permission-mode` 時,請執行 `claude remote-control --permission-mode <mode>`,為 Remote Control 所啟動的工作階段設定權限模式

3573 3585 

3574在 v2.1.248 之前,當全域旗標在前時,`claude remote-control` 不接受其自身的旗標,該命令會以 `unknown option` 錯誤失敗。3586在 v2.1.248 之前,當全域旗標在前時,`claude remote-control` 不接受其本身的旗標,且該命令會以 `unknown option` 錯誤失敗。

3575 3587 

3576### Remote Control 因 `--settings` 檔案而未啟動3588### Remote Control 因 `--settings` 檔案而未啟動

3577 3589 


3583 3595 

3584**處理方式:**3596**處理方式:**

3585 3597 

3586* 修正訊息所指出的問題,然後重新執行您的 `claude remote-control` 命令3598* 修正訊息所指出的問題,然後再次執行您的 `claude remote-control` 命令

3587 3599 

3588### The settings file has changed since Remote Control started3600### The settings file has changed since Remote Control started

3589 3601 


3595 3607 

3596**處理方式:**3608**處理方式:**

3597 3609 

3598* 若要使用該檔案的目前內容,請停止 `claude remote-control` 並重新執行相同的命令。若要找回它原本服務的工作階段,請參閱[停止伺服器後繼續工作階段](https://code.claude.com/docs/zh-TW/remote-control.md#resume-sessions-after-stopping-the-server)。3610* 若要使用該檔案的目前內容,請停止 `claude remote-control` 並再次執行相同的命令。若要找回它原本服務的工作階段,請參閱[停止伺服器後恢復工作階段](https://code.claude.com/docs/zh-TW/remote-control.md#resume-sessions-after-stopping-the-server)。

3599* 若要保留 Remote Control 啟動時所使用的設定,請將檔案內容還原為原本的樣子,若 `claude remote-control` 已結束,再重新執行命令3611* 若要保留 Remote Control 啟動時所用的設定,請將檔案內容還原為原本的樣子;如果 `claude remote-control` 已經結束,請再次執行該命令

3600 3612 

3601### `--sandbox` or `--no-sandbox` is not supported by claude remote-control3613### `--sandbox` or `--no-sandbox` is not supported by claude remote-control

3602 3614 

3603此錯誤表示啟動您 [Remote Control](https://code.claude.com/docs/zh-TW/remote-control.md) 伺服器的命令在 `remote-control` 之後傳入了 `--sandbox` 或 `--no-sandbox`,而 `claude remote-control` 兩者皆不接受。伺服器會以退出碼 1 結束,而不會啟動:3615此錯誤表示啟動您 [Remote Control](https://code.claude.com/docs/zh-TW/remote-control.md) 伺服器的命令在 `remote-control` 之後傳入了 `--sandbox` 或 `--no-sandbox`,而 `claude remote-control` 兩個旗標都不接受。伺服器會以退出碼 1 結束,而不會啟動:

3604 3616 

3605```text theme={null}3617```text theme={null}

3606Error: --sandbox is not supported by claude remote-control. The flag had no effect and was removed. To sandbox sessions, set sandbox.enabled to true in settings.3618Error: --sandbox is not supported by claude remote-control. The flag had no effect and was removed. To sandbox sessions, set sandbox.enabled to true in settings.


3609 3621 

3610**處理方式:**3622**處理方式:**

3611 3623 

3612* 從命令中移除該旗標(包括在替您啟動伺服器的指令碼或服務定義中),然後再次執行3624* 從命令中移除該旗標,包括在為您啟動伺服器的指令碼或服務定義中,然後再次執行

3613* 若要對伺服器所啟動的工作階段使用沙箱,請在[設定檔](https://code.claude.com/docs/zh-TW/settings.md#where-settings-live)中將 [`sandbox.enabled`](https://code.claude.com/docs/zh-TW/settings-reference#sandbox-enabled) 設為 `true`,以開啟[沙箱機制](https://code.claude.com/docs/zh-TW/sandboxing.md)3625* 若要將伺服器所啟動的工作階段放入沙箱,請在[設定檔](https://code.claude.com/docs/zh-TW/settings.md#where-settings-live)中將 [`sandbox.enabled`](https://code.claude.com/docs/zh-TW/settings-reference#sandbox-enabled) 設為 `true` 以開啟[沙箱機制](https://code.claude.com/docs/zh-TW/sandboxing.md)

3614 3626 

3615這兩個旗標已在 v2.1.300 中從 `claude remote-control` 移除,因此為較早版本撰寫的命令可能仍帶有其中之一。3627這兩個旗標已在 v2.1.300 中從 `claude remote-control` 移除,因此為較早版本撰寫的命令可能仍帶有其中之一。

3616 3628 

3617### 此建置中尚無法使用 claude import3629### claude import is not yet available in this build

3618 3630 

3619您執行了 [`claude import`](https://code.claude.com/docs/zh-TW/cli-reference#cli-commands),而 Claude Code 發現匯入流程已關閉,因此該命令會以退出碼 1 結束,而不會開始匯入。在 v2.1.222 之前,匯入流程關閉的建置會將 `import` 視為提示詞,並啟動互動式工作階段,而不是列印此訊息。3631您執行了 [`claude import`](https://code.claude.com/docs/zh-TW/cli-reference#cli-commands),而 Claude Code 發現匯入流程已關閉,因此該命令會以退出碼 1 結束,而不會開始匯入。在 v2.1.222 之前,匯入流程關閉的建置會將 `import` 當作提示詞,並啟動互動式工作階段,而不是印出此訊息。

3620 3632 

3621```text theme={null}3633```text theme={null}

3622`claude import` is not yet available in this build. Run `claude` and use /mcp or edit ~/.claude/settings.json directly.3634`claude import` is not yet available in this build. Run `claude` and use /mcp or edit ~/.claude/settings.json directly.

3623```3635```

3624 3636 

3625Claude Code 透過從 Anthropic 擷取並快取在磁碟上的功能旗標來開啟 `claude import`。此訊息表示快取的值為關閉。原因通常是以下其中之一:3637Claude Code 透過一個從 Anthropic 擷取並快取在磁碟上的功能旗標來開啟 `claude import`。此訊息表示快取的值為關閉。原因通常是下列其中之一:

3626 3638 

3627* 您在安裝後尚未啟動過工作階段,因此 Claude Code 尚未擷取該旗標。即使您可以使用此功能,第一次執行 `claude import` 時也可能列印此訊息。3639* 您在安裝後尚未啟動過工作階段,因此 Claude Code 尚未擷取該旗標。即使該功能對您可用,第一次執行 `claude import` 也可能印出此訊息。

3628* 您透過 Amazon Bedrock、Google Cloud 的 Agent Platform、Microsoft Foundry 或 Claude Platform on AWS 使用 Claude Code,或透過 [Claude apps 閘道](https://code.claude.com/docs/zh-TW/claude-apps-gateway#availability-and-limitations)使用。Claude Code 在這些工作階段中不會擷取功能旗標,因此 `claude import` 會一直無法使用。3640* 您透過 Amazon Bedrock、Google Cloud 的 Agent Platform、Microsoft Foundry 或 Claude Platform on AWS,或透過 [Claude apps 閘道](https://code.claude.com/docs/zh-TW/claude-apps-gateway#availability-and-limitations)使用 Claude Code。Claude Code 在這些工作階段中不會擷取功能旗標,因此 `claude import` 會保持無法使用。

3629* 您設定了 `DISABLE_TELEMETRY`、`DO_NOT_TRACK`、[`CLAUDE_CODE_DISABLE_FEATURE_FLAGS`](https://code.claude.com/docs/zh-TW/env-vars#variables)、`DISABLE_GROWTHBOOK` 或 [`CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC`](https://code.claude.com/docs/zh-TW/env-vars),這些會關閉功能旗標擷取,因此 `claude import` 會維持無法使用。3641* 您設定了 `DISABLE_TELEMETRY`、`DO_NOT_TRACK`、[`CLAUDE_CODE_DISABLE_FEATURE_FLAGS`](https://code.claude.com/docs/zh-TW/env-vars#variables)、`DISABLE_GROWTHBOOK` 或 [`CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC`](https://code.claude.com/docs/zh-TW/env-vars),這些會關閉功能旗標擷取,因此 `claude import` 會保持無法使用。

3630 3642 

3631**處理方式:**3643**處理方式:**

3632 3644 

3633* 在全新安裝中,啟動 `claude`,等待工作階段載入後結束,然後再次執行 `claude import`3645* 在全新安裝上,啟動 `claude`,等待工作階段載入後結束,再次執行 `claude import`

3634* 在功能旗標擷取持續關閉的環境中,請自行完成設定:使用 [`claude mcp add`](https://code.claude.com/docs/zh-TW/mcp#installing-mcp-servers) 新增 MCP 伺服器,並建立您想沿用的 [`CLAUDE.md` 檔案](https://code.claude.com/docs/zh-TW/memory#how-claude-md-files-load)、[skill 與命令](https://code.claude.com/docs/zh-TW/skills.md#where-skills-live),以及 [subagent](https://code.claude.com/docs/zh-TW/sub-agents.md#choose-the-subagent-scope)。訊息中也提到了 `~/.claude/settings.json`。在 `claude import` 所沿用的設定中,該檔案只保存[權限模式](https://code.claude.com/docs/zh-TW/settings-reference.md#permission-settings);Claude Code 不會從中讀取 MCP 伺服器。3646* 在功能旗標擷取保持關閉的情況下,請自行完成設定:使用 [`claude mcp add`](https://code.claude.com/docs/zh-TW/mcp#installing-mcp-servers) 新增 MCP 伺服器,並建立您想轉移的 [`CLAUDE.md` 檔案](https://code.claude.com/docs/zh-TW/memory#how-claude-md-files-load)、[skill 與命令](https://code.claude.com/docs/zh-TW/skills.md#where-skills-live)以及 [subagent](https://code.claude.com/docs/zh-TW/sub-agents.md#choose-the-subagent-scope)。訊息中也提到了 `~/.claude/settings.json`。在 `claude import` 會轉移的設定中,該檔案只存放[權限模式](https://code.claude.com/docs/zh-TW/settings-reference.md#permission-settings);Claude Code 不會從中讀取 MCP 伺服器。

3635 3647 

3636### 無法讀取 Claude Code 設定3648### Could not read Claude Code config

3637 3649 

3638您在 Claude Code 無法剖析 `~/.claude.json`(它儲存您帳戶詳細資料與各專案狀態的檔案)時執行了 [`claude import`](https://code.claude.com/docs/zh-TW/cli-reference#cli-commands)。該子命令會讀取此檔案以檢查可用性,但不會顯示互動式工作階段所顯示的復原對話框,因此會以退出碼 1 結束。在 v2.1.222 之前,設定檔無法讀取時執行 `claude import` 會啟動互動式工作階段,並由其復原對話框處理該檔案。3650您在 Claude Code 無法解析 `~/.claude.json`(存放您帳戶詳細資料與各專案狀態的檔案)時執行了 [`claude import`](https://code.claude.com/docs/zh-TW/cli-reference#cli-commands)。該子命令會讀取此檔案以檢查可用性,但不會顯示互動式工作階段所顯示的復原對話框,因此會以退出碼 1 結束。在 v2.1.222 之前,在設定檔無法讀取時執行 `claude import` 會啟動互動式工作階段,並由其復原對話框處理該檔案。

3639 3651 

3640```text theme={null}3652```text theme={null}

3641Could not read Claude Code config — run `claude` with no arguments to recover it.3653Could not read Claude Code config — run `claude` with no arguments to recover it.


3643 3655 

3644**處理方式:**3656**處理方式:**

3645 3657 

3646* 不帶引數執行 `claude`。Claude Code 會偵測到無效的檔案並提供重設選項。然後再次執行 `claude import`。3658* 不帶任何引數執行 `claude`。Claude Code 會偵測到無效的檔案並提議將其重設。然後再次執行 `claude import`。

3647* 若要保留您手動做過的編輯,請改為在編輯器中修正 `~/.claude.json` 的 JSON 語法,然後重新執行 `claude import`3659* 若要保留您手動進行的編輯,請改在編輯器中修正 `~/.claude.json` 的 JSON 語法,然後重新執行 `claude import`

3648 3660 

3649### 無法從 Claude Desktop 匯入伺服器3661### 無法從 Claude Desktop 匯入伺服器

3650 3662 

3651Claude Code 無法新增您在 `claude mcp add-from-claude-desktop` 中選取的其中一個伺服器。該命令仍會匯入其他選取的伺服器,並針對每個無法新增的伺服器列印一行。在 v2.1.205 之前,第一個失敗的伺服器會中止匯入。3663Claude Code 無法新增您在 `claude mcp add-from-claude-desktop` 中選取的其中一個伺服器。該命令仍會匯入其他選取的伺服器,並針對每個無法新增的伺服器印出一行。在 v2.1.205 之前,第一個失敗的伺服器會中止匯入。

3652 3664 

3653```text theme={null}3665```text theme={null}

3654Could not import my server: Invalid name my server. Names can only contain letters, numbers, hyphens, and underscores.3666Could not import my server: Invalid name my server. Names can only contain letters, numbers, hyphens, and underscores.

3655```3667```

3656 3668 

3657伺服器名稱之後的文字是原因。最常見的是名稱檢查:Claude Desktop 允許伺服器名稱中包含空格與句點等字元,而 `claude mcp` 將其限制為字母、數字、連字號與底線。其他原因包括伺服器設定未通過驗證,以及伺服器被您組織的 [MCP 政策](https://code.claude.com/docs/zh-TW/managed-mcp.md)封鎖。3669伺服器名稱之後的文字是原因。最常見的是名稱檢查:Claude Desktop 允許伺服器名稱中包含空格與句點等字元,而 `claude mcp` 則限制只能使用字母、數字、連字號與底線。其他原因包括伺服器設定未通過驗證,以及伺服器被您組織的 [MCP 政策](https://code.claude.com/docs/zh-TW/managed-mcp.md)封鎖。

3658 3670 

3659**處理方式:**3671**處理方式:**

3660 3672 

3661* 在 `claude_desktop_config.json` 中將該伺服器重新命名為只使用字母、數字、連字號與底線,然後再次執行 `claude mcp add-from-claude-desktop`3673* 在 `claude_desktop_config.json` 中將伺服器重新命名為只使用字母、數字、連字號與底線,然後再次執行 `claude mcp add-from-claude-desktop`

3662* 使用 `claude mcp add` 或 `claude mcp add-json` 以有效的名稱直接新增該伺服器。請參閱[從 Claude Desktop 匯入 MCP 伺服器](https://code.claude.com/docs/zh-TW/mcp.md#import-mcp-servers-from-claude-desktop)。3674* 使用 `claude mcp add` 或 `claude mcp add-json` 以有效名稱直接新增該伺服器。請參閱[從 Claude Desktop 匯入 MCP 伺服器](https://code.claude.com/docs/zh-TW/mcp.md#import-mcp-servers-from-claude-desktop)。

3663 3675 

3664### 無法將 MCP 伺服器新增到受管範圍3676### 無法將 MCP 伺服器新增至 managed 範圍

3665 3677 

3666您以 `--scope managed` 執行了 `claude mcp add` 或 `claude mcp add-json`。該範圍保存的是您的組織透過 [`managedMcpServers`](https://code.claude.com/docs/zh-TW/settings-reference#managedmcpservers) 受管設定提供的伺服器。Claude Code 只從受管設定讀取它們,因此該命令無法將伺服器寫入該範圍。3678您以 `--scope managed` 執行了 `claude mcp add` 或 `claude mcp add-json`。該範圍存放您組織透過 [`managedMcpServers`](https://code.claude.com/docs/zh-TW/settings-reference#managedmcpservers) 受管設定提供的伺服器。Claude Code 只會從受管設定讀取這些伺服器,因此該命令無法將伺服器寫入該範圍。

3667 3679 

3668```text theme={null}3680```text theme={null}

3669Cannot add MCP server to scope: managed3681Cannot add MCP server to scope: managed


3671 3683 

3672**處理方式:**3684**處理方式:**

3673 3685 

3674* 將伺服器新增到您可寫入的範圍:`local`、`user` 或 `project`。若不指定 `--scope`,該命令會使用 `local`。請參閱 [MCP 安裝範圍](https://code.claude.com/docs/zh-TW/mcp.md#mcp-installation-scopes)3686* 將伺服器新增至您可以寫入的範圍:`local`、`user` 或 `project`。未指定 `--scope` 時,命令會使用 `local`。請參閱 [MCP 安裝範圍](https://code.claude.com/docs/zh-TW/mcp.md#mcp-installation-scopes)

3675* 若要將伺服器提供給組織中的每位使用者,請將其新增到您部署的受管設定中的 [`managedMcpServers`](https://code.claude.com/docs/zh-TW/settings-reference#managedmcpservers)3687* 若要將伺服器提供給組織中的每位使用者,請將其新增至您所部署之受管設定中的 [`managedMcpServers`](https://code.claude.com/docs/zh-TW/settings-reference#managedmcpservers)

3676 3688 

3677### 受管設定只允許外掛伺服器時無法新增 MCP 伺服器3689### 受管設定只允許外掛伺服器時無法新增 MCP 伺服器

3678 3690 

3679您在組織的受管設定將 [`strictPluginOnlyCustomization`](https://code.claude.com/docs/zh-TW/settings-reference#strictpluginonlycustomization) 設為 `true` 或設為包含 `mcp` 的清單時,執行了 `claude mcp add` 或 `claude mcp add-json`。在該設定下,Claude Code 不會從 `~/.claude.json` 或 `.mcp.json` 載入 MCP 伺服器,因此該命令會以退出碼 1 結束,而不是儲存一個永遠不會載入的伺服器:3691您在組織的受管設定將 [`strictPluginOnlyCustomization`](https://code.claude.com/docs/zh-TW/settings-reference#strictpluginonlycustomization) 設為 `true` 或設為包含 `mcp` 的清單時,執行了 `claude mcp add` 或 `claude mcp add-json`。在此設定下,Claude Code 不會從 `~/.claude.json` 或 `.mcp.json` 載入 MCP 伺服器,因此該命令會以退出碼 1 結束,而不會儲存一個永遠不會載入的伺服器:

3680 3692 

3681```text theme={null}3693```text theme={null}

3682Cannot add MCP server: your organization's managed settings allow only MCP servers that plugins provide. Install a plugin that provides this server, or ask your administrator to make it available.3694Cannot add MCP server: your organization's managed settings allow only MCP servers that plugins provide. Install a plugin that provides this server, or ask your administrator to make it available.

3683```3695```

3684 3696 

3685`claude mcp add-from-claude-desktop` 會將您選取的每個伺服器回報為未匯入,並以此訊息作為原因。[`/import`](https://code.claude.com/docs/zh-TW/commands#all-commands) 會針對它嘗試新增的每個 MCP 伺服器回報此訊息,但仍會匯入它找到的其他項目。3697`claude mcp add-from-claude-desktop` 會將您選取的每個伺服器回報為未匯入,並以此訊息作為原因。[`/import`](https://code.claude.com/docs/zh-TW/commands#all-commands) 會針對其嘗試新增的每個 MCP 伺服器回報此訊息,並仍會匯入它找到的其他項目。

3686 3698 

3687在 v2.1.284 之前,這些命令會儲存伺服器並回報成功,但該伺服器永遠不會載入。3699在 v2.1.284 之前,這些命令會儲存該伺服器並回報成功,但該伺服器從未載入。

3688 3700 

3689**處理方式:**3701**處理方式:**

3690 3702 

3691* 安裝提供該伺服器的[外掛](https://code.claude.com/docs/zh-TW/plugins/install.md)3703* 安裝提供該伺服器的[外掛](https://code.claude.com/docs/zh-TW/plugins/install.md)

3692* 請您的管理員在[外掛](https://code.claude.com/docs/zh-TW/plugins/org.md)中發布該伺服器,或者若它是遠端 HTTP 或 SSE 伺服器,則透過 [`managedMcpServers`](https://code.claude.com/docs/zh-TW/settings-reference#managedmcpservers) 提供3704* 請您的管理員以[外掛](https://code.claude.com/docs/zh-TW/plugins/org.md)發佈該伺服器,或者如果它是遠端 HTTP 或 SSE 伺服器,則透過 [`managedMcpServers`](https://code.claude.com/docs/zh-TW/settings-reference#managedmcpservers) 提供

3693 3705 

3694### 無法讀取 .mcp.json3706### Can't read .mcp.json

3695 3707 

3696讀取專案 [`.mcp.json`](https://code.claude.com/docs/zh-TW/mcp#project-scope) 的命令(例如搭配 `--scope project` 的 `claude mcp add` 或 `claude mcp add-json`,或 `claude mcp remove`)發現目前目錄中的該檔案不是一般檔案,或大於 2 MiB,因此會以此錯誤結束,而不會讀取該檔案。3708讀取專案 [`.mcp.json`](https://code.claude.com/docs/zh-TW/mcp#project-scope) 的命令(例如搭配 `--scope project` 的 `claude mcp add` 或 `claude mcp add-json`,或是 `claude mcp remove`)發現您目前目錄中的該檔案不是一般檔案或大於 2 MiB,因此會以此錯誤結束,而不會讀取該檔案。

3697 3709 

3698```text theme={null}3710```text theme={null}

3699Can't read .mcp.json: it isn't a regular file or is larger than 2097152 bytes. Fix or remove it, then run the command again.3711Can't read .mcp.json: it isn't a regular file or is larger than 2097152 bytes. Fix or remove it, then run the command again.

3700```3712```

3701 3713 

3702在 v2.1.257 之前,位於 `.mcp.json` 的 FIFO 會讓命令無限期等待且沒有任何輸出,而指向 `/dev/zero` 等裝置檔案的符號連結則會讓記憶體持續增長,直到程序被終止。3714在 v2.1.257 之前,位於 `.mcp.json` 的 FIFO 會讓命令無止盡地等待且沒有任何輸出,而指向 `/dev/zero` 之類裝置檔案的符號連結會使記憶體用量持續增長,直到程序被終止為止。

3703 3715 

3704**處理方式:**3716**處理方式:**

3705 3717 

3706* 檢查目前目錄中 `.mcp.json` 是什麼。將其替換為[專案範圍格式](https://code.claude.com/docs/zh-TW/mcp.md#project-scope)的一般 JSON 檔案,或將其刪除,然後再次執行命令。3718* 檢查您目前目錄中 `.mcp.json` 位置上的內容。將其替換為符合[專案範圍格式](https://code.claude.com/docs/zh-TW/mcp.md#project-scope)的一般 JSON 檔案,或將其刪除,然後再次執行命令。

3707 3719 

3708### MCP 伺服器未被儲存或移除3720### MCP 伺服器未被儲存或移除

3709 3721 

3710此錯誤表示 `claude mcp add` 或 `claude mcp remove` 等命令未能將您的變更寫入 `~/.claude.json`。可能是其他 Claude Code 程序一直鎖定著該檔案,或者該檔案是唯讀的或受到沙箱保護。3722此錯誤表示 `claude mcp add` 或 `claude mcp remove` 之類的命令未能將您的變更寫入 `~/.claude.json`。可能是其他 Claude Code 程序持續鎖定該檔案,或該檔案為唯讀或受到沙箱保護。

3711 3723 

3712```text theme={null}3724```text theme={null}

3713MCP server "example" was not saved to /home/user/.claude.json. If other Claude Code processes use that file, they may have kept it locked: add the server again, with CLAUDE_CODE_CONFIG_LOCK_WAIT_MS=60000 set to wait up to a minute. If that file is read-only or protected by a sandbox, make it writable or run the command outside the sandbox first.3725MCP server "example" was not saved to /home/user/.claude.json. If other Claude Code processes use that file, they may have kept it locked: add the server again, with CLAUDE_CODE_CONFIG_LOCK_WAIT_MS=60000 set to wait up to a minute. If that file is read-only or protected by a sandbox, make it writable or run the command outside the sandbox first.

3714```3726```

3715 3727 

3716在移除之後,訊息會以 `was not removed from` 取代 `was not saved to`,並以 `remove the server again` 取代 `add the server again`。對於 `local` 範圍的伺服器,路徑之後會接著該項目所屬的專案目錄,形式為 `(local scope for /path/to/project)`。3728移除之後,訊息會以 `was not removed from` 取代 `was not saved to`,並以 `remove the server again` 取代 `add the server again`。對於 `local` 範圍的伺服器,路徑之後會接著該項目所屬的專案目錄,形式為 `(local scope for /path/to/project)`。

3717 3729 

3718**處理方式:**3730**處理方式:**

3719 3731 

3720* **有其他 Claude Code 程序正在執行**:命令會等待檔案鎖定約 10 到 20 秒,然後在未寫入的情況下放棄。請將 [`CLAUDE_CODE_CONFIG_LOCK_WAIT_MS`](https://code.claude.com/docs/zh-TW/env-vars#variables) 設定為較長的等待時間(以毫秒為單位,例如 `60000`),然後重新執行相同的命令。3732* **有其他 Claude Code 程序正在執行**:命令會等待約 10 到 20 秒以取得檔案的鎖定,然後放棄而不寫入。請將 [`CLAUDE_CODE_CONFIG_LOCK_WAIT_MS`](https://code.claude.com/docs/zh-TW/env-vars#variables) 設為較長的等待時間(以毫秒為單位,例如 `60000`),再次執行相同的命令。

3721* **檔案是唯讀的或受沙箱保護**:讓訊息所指出的檔案可寫入,然後重新執行相同的新增或移除命令,或在沙箱之外執行該命令。3733* **檔案為唯讀或受沙箱保護**:讓訊息所列的檔案變為可寫入,然後再次執行相同的新增或移除命令,或在沙箱之外執行該命令。

3722 3734 

3723在 v2.1.283 之前,即使變更未寫入檔案,`claude mcp add`、`claude mcp add-json` 與 `claude mcp remove` 也會回報成功。在 v2.1.318 之前,訊息未提及鎖定,且 Claude Code 不會讀取 [`CLAUDE_CODE_CONFIG_LOCK_WAIT_MS`](https://code.claude.com/docs/zh-TW/env-vars#variables)。3735在 v2.1.283 之前,即使變更未寫入檔案,`claude mcp add`、`claude mcp add-json` 與 `claude mcp remove` 仍會回報成功。在 v2.1.318 之前,訊息不會提及鎖定,且 Claude Code 不會讀取 [`CLAUDE_CODE_CONFIG_LOCK_WAIT_MS`](https://code.claude.com/docs/zh-TW/env-vars#variables)。

3724 3736 

3725### MCP 伺服器可能未被儲存或移除3737### MCP 伺服器可能未被儲存或移除

3726 3738 

3727您針對 `user` 或 `local` [範圍](https://code.claude.com/docs/zh-TW/mcp.md#mcp-installation-scopes)中的伺服器執行了 `claude mcp add`、`claude mcp add-json` 或 `claude mcp remove`,而 Claude Code 無法讀回 `~/.claude.json` 來確認變更。變更可能已寫入磁碟,也可能沒有。`to confirm the change` 之後的括號內容會說明原因。3739您對 `user` 或 `local` [範圍](https://code.claude.com/docs/zh-TW/mcp.md#mcp-installation-scopes)中的伺服器執行了 `claude mcp add`、`claude mcp add-json` 或 `claude mcp remove`,而 Claude Code 無法讀回 `~/.claude.json` 以確認變更。變更可能已寫入磁碟,也可能沒有。`to confirm the change` 之後的括號內會說明原因。

3728 3740 

3729```text theme={null}3741```text theme={null}

3730MCP server "example" may not have been saved: /home/user/.claude.json could not be read to confirm the change (EACCES: permission denied, open '/home/user/.claude.json'). Run `claude mcp get example` to check, then add the server again if it is missing.3742MCP server "example" may not have been saved: /home/user/.claude.json could not be read to confirm the change (EACCES: permission denied, open '/home/user/.claude.json'). Run `claude mcp get example` to check, then add the server again if it is missing.

3731```3743```

3732 3744 

3733在移除之後,訊息會是 `may not have been removed`,並以 `then remove the server again if it is still listed` 結尾。如果原因是 `the file was not found`,該伺服器可能仍處於已設定狀態。3745移除之後,訊息會顯示 `may not have been removed`,並以 `then remove the server again if it is still listed` 結尾。如果原因是 `the file was not found`,該伺服器可能仍在設定中。

3734 3746 

3735在 v2.1.283 之前,即使無法確認變更,這些命令也會回報成功。3747在 v2.1.283 之前,即使變更無法確認,這些命令仍會回報成功。

3736 3748 

3737**處理方式:**3749**處理方式:**

3738 3750 

3739* 執行 `claude mcp get <name>` 以檢查變更是否已寫入磁碟。對於 `local` 範圍的伺服器,請從該伺服器所屬的專案目錄執行,因為 local 範圍是以專案為單位。3751* 執行 `claude mcp get <name>` 以檢查變更是否已寫入磁碟。對於 `local` 範圍的伺服器,由於 local 範圍是依專案區分的,請從該伺服器所屬的專案目錄執行。

3740* 如果在新增後伺服器不存在,或在移除後仍被列出,請再次執行相同的新增或移除命令。3752* 如果新增後伺服器不存在,或移除後仍被列出,請再次執行相同的新增或移除命令。

3741 3753 

3742### 伺服器由 Anthropic 託管,不支援本機 OAuth3754### Server is Anthropic-hosted and doesn't support local OAuth

3743 3755 

3744您為某個 MCP 伺服器啟動了登入,而其 URL 指向透過第三方身分識別提供者進行身分驗證、由 Anthropic 託管的連接器主機。這些主機包括 `microsoft365.mcp.claude.com`、`gmail.mcp.claude.com` 與 `gcal.mcp.claude.com`。Claude Code 會拒絕從 `/mcp` 面板與 `claude mcp login` 為這些主機啟動本機 OAuth 流程,因為[它們的登入只能透過 claude.ai 進行](https://code.claude.com/docs/zh-TW/mcp.md#use-mcp-servers-from-claude-ai)。3756您為某個 MCP 伺服器開始登入,而其 URL 指向透過第三方身分提供者進行身分驗證的 Anthropic 託管連接器主機。這些主機包括 `microsoft365.mcp.claude.com`、`gmail.mcp.claude.com` 與 `gcal.mcp.claude.com`。無論是從 `/mcp` 面板或 `claude mcp login`,Claude Code 都會拒絕為這些主機啟動其本機 OAuth 流程,因為[它們的登入只能透過 claude.ai 進行](https://code.claude.com/docs/zh-TW/mcp.md#use-mcp-servers-from-claude-ai)。

3745 3757 

3746```text theme={null}3758```text theme={null}

3747"gmail" is Anthropic-hosted and doesn't support local OAuth. Connect it via Settings → Connectors on claude.ai (requires `claude login`), then it'll be available here automatically.3759"gmail" is Anthropic-hosted and doesn't support local OAuth. Connect it via Settings → Connectors on claude.ai (requires `claude login`), then it'll be available here automatically.


3749 3761 

3750**處理方式:**3762**處理方式:**

3751 3763 

3752* 使用 `claude mcp remove <name>` 移除您的項目,以免它遮蔽相同 URL 的 claude.ai 連接器3764* 使用 `claude mcp remove <name>` 移除您的項目,使其不會遮蔽相同 URL 的 claude.ai 連接器

3753* 移除後,在登入您於 Claude Code 中使用的帳戶的情況下,於 [claude.ai/customize/connectors](https://claude.ai/customize/connectors) 連接該服務。連接後,如果您目前使用的身分驗證方式是 claude.ai 訂閱登入,[該連接器會自動出現在 Claude Code 中](https://code.claude.com/docs/zh-TW/mcp.md#use-mcp-servers-from-claude-ai)3765* 移除後,在登入您於 Claude Code 中使用之帳戶的情況下,於 [claude.ai/customize/connectors](https://claude.ai/customize/connectors) 連接該服務。連接完成後,如果您目前的身分驗證方式是 claude.ai 訂閱登入,[該連接器會自動出現在 Claude Code 中](https://code.claude.com/docs/zh-TW/mcp.md#use-mcp-servers-from-claude-ai)

3754 3766 

3755### 伺服器拒絕了設定的 headersHelper 所產生的 Authorization 標頭3767### Server rejected the Authorization header minted by the configured headersHelper

3756 3768 

3757某個由 [`headersHelper`](https://code.claude.com/docs/zh-TW/mcp#use-dynamic-headers-for-custom-authentication) 提供 `Authorization` 標頭的 MCP 伺服器以 HTTP 401 或 403 回應連線,因此 Claude Code 將該連線回報為失敗。由於 helper 提供了 `Authorization` 標頭,Claude Code [不會改用 OAuth](https://code.claude.com/docs/zh-TW/mcp.md#authenticate-with-remote-mcp-servers) 連線該伺服器:3769某個 MCP 伺服器的 [`headersHelper`](https://code.claude.com/docs/zh-TW/mcp#use-dynamic-headers-for-custom-authentication) 提供 `Authorization` 標頭,而該伺服器以 HTTP 401 或 403 回應連線,因此 Claude Code 將連線回報為失敗。由於 helper 提供了 `Authorization` 標頭,Claude Code 對該伺服器[不會改用 OAuth](https://code.claude.com/docs/zh-TW/mcp.md#authenticate-with-remote-mcp-servers):

3758 3770 

3759```text theme={null}3771```text theme={null}

3760Server rejected the Authorization header minted by the configured headersHelper (HTTP 401). Check that the helper command returns a valid credential for this MCP endpoint — OAuth fallback is disabled when the helper supplies Authorization.3772Server rejected the Authorization header minted by the configured headersHelper (HTTP 401). Check that the helper command returns a valid credential for this MCP endpoint — OAuth fallback is disabled when the helper supplies Authorization.

3761```3773```

3762 3774 

3763Claude Code 在每次嘗試連線時都會重新執行 helper,因此在暫時性拒絕(例如權杖輪替競爭)之後重試,可能會以新的憑證成功。3775Claude Code 會在每次連線嘗試時重新執行 helper,因此在暫時性拒絕(例如權杖輪替的競態條件)之後重試,可能會以新的憑證成功。

3764 3776 

3765**處理方式:**3777**處理方式:**

3766 3778 

3767* 以 Claude Code 執行它的方式自行執行 `headersHelper` 命令:從 [Claude Code 執行它的目錄](https://code.claude.com/docs/zh-TW/mcp.md#where-the-helper-runs)執行,帶上 [Claude Code 為它設定的環境變數](https://code.claude.com/docs/zh-TW/mcp.md#use-dynamic-headers-for-custom-authentication),並且對於來自專案 `.mcp.json`、外掛或專案 agent 檔案的伺服器,不帶 [Claude Code 移除的憑證變數](https://code.claude.com/docs/zh-TW/mcp.md#which-variables-a-helper-can-read)。確認它輸出的 `Authorization` 值能被該伺服器的端點接受3779* 以 Claude Code 執行 `headersHelper` 命令的方式自行執行它:從 [Claude Code 執行它的目錄](https://code.claude.com/docs/zh-TW/mcp.md#where-the-helper-runs)執行,帶上 [Claude Code 為其設定的環境變數](https://code.claude.com/docs/zh-TW/mcp.md#use-dynamic-headers-for-custom-authentication),並且對於來自專案 `.mcp.json`、外掛或專案 agent 檔案的伺服器,不帶 [Claude Code 會移除的憑證變數](https://code.claude.com/docs/zh-TW/mcp.md#which-variables-a-helper-can-read)。確認它印出的 `Authorization` 值能被伺服器的端點接受

3768* 修正 helper 或其憑證來源後,在 `/mcp` 中選取該伺服器並選擇 **Reconnect**3780* 修正 helper 或其憑證來源之後,在 `/mcp` 中選取該伺服器並選擇 **Reconnect**

3769 3781 

3770在 v2.1.248 之前,對於 helper 提供 `Authorization` 標頭的伺服器,Claude Code 仍會執行 OAuth 探索。該探索可能會以 `Incompatible auth server: does not support dynamic client registration` 失敗,而不是回報被拒絕的憑證。3782在 v2.1.248 之前,對於 helper 提供 `Authorization` 標頭的伺服器,Claude Code 仍會執行 OAuth 探索。該探索可能會以 `Incompatible auth server: does not support dynamic client registration` 失敗,而不是回報被拒絕的憑證。

3771 3783 

3772### MCP 伺服器拒絕了 elicitation 功能3784### MCP 伺服器拒絕了 elicitation 能力

3773 3785 

3774以 Java MCP SDK 0.11.0 至 0.17.0 建置的 MCP 伺服器拒絕了連線。這些 SDK 版本無法剖析 Claude Code 在交握中宣告的 `form` 與 `url` [elicitation 模式](https://code.claude.com/docs/zh-TW/mcp.md#elicitation-modes-claude-code-declares)。訊息如下:3786一個以 Java MCP SDK 0.11.0 至 0.17.0 建置的 MCP 伺服器拒絕了連線。這些 SDK 版本無法解析 Claude Code 在其交握中宣告的 `form` 與 `url` [elicitation 模式](https://code.claude.com/docs/zh-TW/mcp.md#elicitation-modes-claude-code-declares)。訊息如下:

3775 3787 

3776```text theme={null}3788```text theme={null}

3777This server (Java MCP SDK 0.17.0 or older) rejected Claude Code's elicitation capability. Set "bareElicitationCapability": true for it, or upgrade to Java MCP SDK 0.17.1+ (Spring AI 1.0.7+ or 1.1.6+).3789This server (Java MCP SDK 0.17.0 or older) rejected Claude Code's elicitation capability. Set "bareElicitationCapability": true for it, or upgrade to Java MCP SDK 0.17.1+ (Spring AI 1.0.7+ or 1.1.6+).


3779 3791 

3780**處理方式:**3792**處理方式:**

3781 3793 

3782* 將伺服器升級至 Java MCP SDK 0.17.1 或更新版本,或升級至訊息所指名的其中一個 Spring AI 版本3794* 將伺服器升級至 Java MCP SDK 0.17.1 或更新版本,或升級至訊息所列的其中一個 Spring AI 版本

3783* 或者,在您的 MCP 設定中將 `"bareElicitationCapability": true` 新增到該伺服器的項目,然後重新啟動 Claude Code。此欄位適用於 stdio、`sse`、`http` 和 `ws` 項目,且需要 Claude Code v2.1.281 或更新版本3795* 或在您 MCP 設定中該伺服器的項目加上 `"bareElicitationCapability": true`,然後重新啟動 Claude Code。此欄位可用於 stdio、`sse`、`http` 與 `ws` 項目,且需要 Claude Code v2.1.281 或更新版本

3784 3796 

3785以下 `.mcp.json` 項目為一個 HTTP 伺服器設定此欄位:3797下列 `.mcp.json` 項目為一個 HTTP 伺服器設定此欄位:

3786 3798 

3787```json theme={null}3799```json theme={null}

3788{3800{


3796}3808}

3797```3809```

3798 3810 

3799重新啟動後,`/mcp` 會將該伺服器顯示為已連線。Claude Code 只會對該伺服器宣告 form 模式,因此在升級伺服器後請移除此欄位。3811重新啟動後,`/mcp` 會顯示該伺服器已連線。Claude Code 只對該伺服器宣告 form 模式,因此在您升級該伺服器後,請移除此欄位。

3800 3812 

3801伺服器也可能以其本身的錯誤文字失敗,例如包含 `Unrecognized field "form"` 的錯誤。適用相同的修正方式。3813伺服器也可能以其自身的錯誤文字失敗,例如包含 `Unrecognized field "form"` 的訊息。相同的修正方式同樣適用。

3802 3814 

3803### 找不到 MCP 權限提示工具3815### 找不到 MCP 權限提示工具

3804 3816 

3805您傳給 [`--permission-prompt-tool`](https://code.claude.com/docs/zh-TW/cli-reference#cli-flags) 的工具在執行首次需要權限決定時,不在已連線的 MCP 工具之中,原因可能是其伺服器從未連線,或沒有任何已連線的伺服器提供該名稱的工具。Claude Code 仍會傳送您的提示詞:[非互動](https://code.claude.com/docs/zh-TW/headless.md)執行會在第一次工具呼叫時以此錯誤與退出碼 1 結束,因此即使已發出請求,也不會產生任何回答。在第一次提示之前,Claude Code 會等待該伺服器連線,最長等待由 [`MCP_TIMEOUT`](https://code.claude.com/docs/zh-TW/env-vars) 設定的每個伺服器 30 秒連線逾時。在 v2.1.206 之前,啟動時不會等待伺服器完成連線,因此啟動緩慢但正常的伺服器也會產生此錯誤。3817您傳給 [`--permission-prompt-tool`](https://code.claude.com/docs/zh-TW/cli-reference#cli-flags) 的工具在該次執行首次需要權限決定時,並不在已連線的 MCP 工具之中,原因可能是其伺服器從未連線,或沒有任何已連線的伺服器提供該名稱的工具。Claude Code 仍會送出您的提示詞:[非互動](https://code.claude.com/docs/zh-TW/headless.md)執行會在第一次工具呼叫時以此錯誤及退出碼 1 結束,因此即使已送出請求,也不會產生任何答案。在第一個提示詞之前,Claude Code 會等待該伺服器連線,最長等待時間為由 [`MCP_TIMEOUT`](https://code.claude.com/docs/zh-TW/env-vars) 設定的每個伺服器連線逾時 30 秒。在 v2.1.206 之前,啟動時不會等待伺服器完成連線,因此啟動較慢但運作正常的伺服器也會產生此錯誤。

3806 3818 

3807```text theme={null}3819```text theme={null}

3808Error: MCP tool mcp__permissions__approve (passed via --permission-prompt-tool) not found. Available MCP tools: none3820Error: MCP tool mcp__permissions__approve (passed via --permission-prompt-tool) not found. Available MCP tools: none

3809```3821```

3810 3822 

3811`Available MCP tools:` 之後的清單列出已連線的 MCP 工具。3823`Available MCP tools:` 之後的清單列出了已連線的 MCP 工具。

3812 3824 

3813**處理方式:**3825**處理方式:**

3814 3826 

3815* 確認伺服器能啟動並保持連線:在相同目錄中執行 `claude mcp list`,並確認該伺服器被列為已連線3827* 確認伺服器能啟動並保持連線:在相同目錄中執行 `claude mcp list`,確認該伺服器列為已連線

3816* 確認工具名稱與伺服器所提供的 `mcp__<server>__<tool>` 名稱相符3828* 確認工具名稱與伺服器所提供的 `mcp__<server>__<tool>` 名稱相符

3817* 如果伺服器需要超過 30 秒才能啟動,請調高 [`MCP_TIMEOUT`](https://code.claude.com/docs/zh-TW/env-vars)3829* 如果伺服器需要超過 30 秒才能啟動,請提高 [`MCP_TIMEOUT`](https://code.claude.com/docs/zh-TW/env-vars)

3818 3830 

3819### OAuth 回呼連接埠已被使用3831### OAuth callback port is already in use

3820 3832 

3821當您以 OAuth 登入遠端 MCP 伺服器時,Claude Code 會啟動本機監聽器來接收登入回呼。如果該監聽器所需的連接埠被其他程序佔用,登入就會以此訊息失敗。這大多發生在透過 [`MCP_OAUTH_CALLBACK_PORT`](https://code.claude.com/docs/zh-TW/env-vars) 變數或 `--callback-port` 設定了[固定回呼連接埠](https://code.claude.com/docs/zh-TW/mcp.md#use-a-fixed-oauth-callback-port)時,因為若未設定,Claude Code 會挑選一個可用的連接埠。3833當您以 OAuth 登入遠端 MCP 伺服器時,Claude Code 會啟動一個本機監聽器來接收登入回呼。如果該監聽器所需的連接埠被其他程序佔用,登入會以此訊息失敗。這種情況大多發生在透過 [`MCP_OAUTH_CALLBACK_PORT`](https://code.claude.com/docs/zh-TW/env-vars) 變數或 `--callback-port` 設定了[固定回呼連接埠](https://code.claude.com/docs/zh-TW/mcp.md#use-a-fixed-oauth-callback-port)時,因為若未設定,Claude Code 會挑選可用的連接埠。

3822 3834 

3823```text theme={null}3835```text theme={null}

3824OAuth callback port <port> is already in use — another process may be holding it. Run `lsof -ti:<port> -sTCP:LISTEN` to find it.3836OAuth callback port <port> is already in use — another process may be holding it. Run `lsof -ti:<port> -sTCP:LISTEN` to find it.

3825```3837```

3826 3838 

3827在 Windows 上,建議的命令改為 `netstat -ano | findstr :<port>`。3839在 Windows 上,建議的命令則是 `netstat -ano | findstr :<port>`。

3828 3840 

3829**處理方式:**3841**處理方式:**

3830 3842 

3831* 執行訊息中的命令以找出佔用該連接埠的程序,然後停止它或等待它結束3843* 執行訊息中的命令以找出佔用該連接埠的程序,並停止它或等待其結束

3832* 如果另一個程式需要永久使用該連接埠,請向伺服器註冊不同的重新導向 URI,並以 `MCP_OAUTH_CALLBACK_PORT` 或 `--callback-port`(視您使用哪一個而定)設定其連接埠3844* 如果另一個程式需要永久使用該連接埠,請向伺服器註冊不同的重新導向 URI,並使用 `MCP_OAUTH_CALLBACK_PORT` 或 `--callback-port`(以您使用的為準)設定其連接埠

3833* 然後再次開始登入,例如在 `/mcp` 中選取該伺服器3845* 然後重新開始登入,例如在 `/mcp` 中選取該伺服器

3834 3846 

3835### 沒有可用於 OAuth 重新導向的連接埠3847### No available ports for OAuth redirect

3836 3848 

3837當您以 [OAuth](https://code.claude.com/docs/zh-TW/mcp.md#authenticate-with-remote-mcp-servers) 登入遠端 MCP 伺服器時,Claude Code 會啟動本機監聽器來接收登入回呼。當 Claude Code 無法為其繫結本機連接埠時,登入就會以此訊息失敗。機器上有某些東西阻止它在 `127.0.0.1` 上監聽,例如安全性軟體或拒絕本機監聽器的沙箱政策。3849當您以 [OAuth](https://code.claude.com/docs/zh-TW/mcp.md#authenticate-with-remote-mcp-servers) 登入遠端 MCP 伺服器時,Claude Code 會啟動一個本機監聽器來接收登入回呼。當 Claude Code 無法為其繫結本機連接埠時,登入會以此訊息失敗。電腦上有某些東西阻止它在 `127.0.0.1` 上監聽,例如安全性軟體或拒絕本機監聽器的沙箱政策。

3838 3850 

3839```text theme={null}3851```text theme={null}

3840No available ports for OAuth redirect3852No available ports for OAuth redirect

3841```3853```

3842 3854 

3843在 v2.1.268 之前,Claude Code 不會改用作業系統指派的連接埠,因此當只有它自行挑選的連接埠無法繫結時,也會出現此訊息。這可能發生在 Hyper-V 保留的連接埠範圍涵蓋 Claude Code 挑選範圍的 Windows 主機上。3855在 v2.1.268 之前,Claude Code 不會改用作業系統指派的連接埠,因此當只是它自行挑選的連接埠無法繫結時,也會出現此訊息。這可能發生在 Hyper-V 保留了涵蓋 Claude Code 挑選範圍之連接埠區段的 Windows 主機上。

3844 3856 

3845**處理方式:**3857**處理方式:**

3846 3858 

3847* 檢查是否有安全性軟體或沙箱政策阻止程序在 `127.0.0.1` 上監聽,並允許 Claude Code 繫結本機連接埠3859* 檢查是否有安全性軟體或沙箱政策阻止程序在 `127.0.0.1` 上監聽,並允許 Claude Code 繫結本機連接埠

3848* 然後再次開始登入,例如在 `/mcp` 中選取該伺服器3860* 然後重新開始登入,例如在 `/mcp` 中選取該伺服器

3849 3861 

3850### 沒有 origin/HEAD 時 /security-review 失敗3862### 缺少 origin/HEAD 時 /security-review 失敗

3851 3863 

3852[`/security-review`](https://code.claude.com/docs/zh-TW/commands#all-commands) 會將您的分支與 `origin/HEAD`(記錄您 `origin` 遠端上哪個分支為預設分支的本機 ref)進行差異比對,以建立其審查上下文。當該 ref 不存在時,收集差異的 git 命令會失敗,審查會在開始前就停止。3864[`/security-review`](https://code.claude.com/docs/zh-TW/commands#all-commands) 會將您的分支與 `origin/HEAD` 進行差異比對來建立其審查脈絡;`origin/HEAD` 是記錄您 `origin` 遠端上哪個分支為預設分支的本機 ref。當該 ref 不存在時,收集差異的 git 命令會失敗,審查會在開始前就停止。

3853 3865 

3854```text theme={null}3866```text theme={null}

3855Error: Shell command failed for pattern "!`git diff --name-only origin/HEAD...`": [stderr]3867Error: Shell command failed for pattern "!`git diff --name-only origin/HEAD...`": [stderr]


3858'git <command> [<revision>...] -- [<file>...]'3870'git <command> [<revision>...] -- [<file>...]'

3859```3871```

3860 3872 

3861訊息可能會改為引用 `git log` 或其他 `git diff`。只有當遠端公告了預設分支,且您的 fetch refspec 涵蓋它時,Git 才會建立 `origin/HEAD`;對含有提交的遠端執行完整的 `git clone` 就會如此。在以下設定中,該參照會不存在:3873訊息引用的也可能是 `git log` 或其他 `git diff` 命令。只有當遠端公告了預設分支且您的 fetch refspec 涵蓋該分支時,Git 才會建立 `origin/HEAD`;對含有提交的遠端執行完整的 `git clone` 就會如此。在下列設定中,該 ref 會不存在:

3862 3874 

3863* 單一分支或 CI 的 checkout,其擷取的 refspec 範圍過窄3875* 單一分支或 CI 的 checkout,其擷取的 refspec 範圍太窄

3864* 伺服器端 HEAD 指向無人推送過之分支的遠端3876* 伺服器端 HEAD 指向一個從未有人推送之分支的遠端

3865* 沒有 `origin` 遠端的儲存庫,或您從未擷取過的遠端3877* 沒有 `origin` 遠端的儲存庫,或您從未擷取過的遠端

3866 3878 

3867對於任何[注入動態上下文](https://code.claude.com/docs/zh-TW/skills.md#when-an-injected-command-fails)的 skill,Claude Code 都會顯示相同的錯誤,而注入的命令失敗會中止該 skill 的呼叫。3879對於任何[注入動態脈絡](https://code.claude.com/docs/zh-TW/skills.md#when-an-injected-command-fails)的 skill,Claude Code 都會顯示相同的錯誤,而失敗的注入命令會中止該 skill 的呼叫。

3868 3880 

3869以下同類字串會在命令執行之前就觸發:3881相關的訊息會在命令執行之前就出現:

3870 3882 

3871* `Shell command permission check failed for pattern "..."`:命令的權限檢查未允許它。請參閱[注入命令的權限檢查](https://code.claude.com/docs/zh-TW/skills.md#permission-checks-on-injected-commands),了解在各權限模式下哪些結果會中止,以及 `allowed-tools` 何時會預先核准命令3883* `Shell command permission check failed for pattern "..."`:命令的權限檢查不允許執行它。請參閱[注入命令的權限檢查](https://code.claude.com/docs/zh-TW/skills.md#permission-checks-on-injected-commands),了解在各權限模式下哪些結果會中止,以及 `allowed-tools` 何時會預先核准命令

3872* ``Skill <name> requires bash (`shell: bash` in frontmatter) but Git Bash was not found``:該 skill 的 frontmatter 要求 bash,但電腦上沒有 bash。請安裝 Git for Windows,或將 frontmatter 改為 `shell: powershell`。請參閱[注入命令的執行方式](https://code.claude.com/docs/zh-TW/skills.md#how-injected-commands-run)3884* ``Skill <name> requires bash (`shell: bash` in frontmatter) but Git Bash was not found``:skill 的 frontmatter 要求在沒有 bash 的電腦上使用 bash。請安裝 Git for Windows,或將 frontmatter 改為 `shell: powershell`。請參閱[注入命令的執行方式](https://code.claude.com/docs/zh-TW/skills.md#how-injected-commands-run)

3873 3885 

3874**處理方式:**3886**處理方式:**

3875 3887 

3876* 指定遠端的預設分支來建立該參照:`git remote set-head origin <default-branch>`。只要本機追蹤參照 `origin/<default-branch>` 存在,這就能運作。如果它不存在(例如在單一分支複製中),請先擷取該分支:執行 `git remote set-branches --add origin <branch>`,接著執行 `git fetch origin`,然後重新執行 set-head 命令。再重新執行 `/security-review`。3888* 指定遠端的預設分支以建立該 ref:`git remote set-head origin <default-branch>`。只要本機追蹤 ref `origin/<default-branch>` 存在,這就能運作。如果它不存在(例如在單一分支的 clone 中),請先擷取該分支:執行 `git remote set-branches --add origin <branch>`,然後執行 `git fetch origin`,再重新執行 set-head 命令。接著重新執行 `/security-review`。

3877* 如果您不想指定分支名稱,請執行 `git fetch origin`,然後執行 `git remote set-head origin --auto`,它會詢問遠端哪個分支是預設分支。當遠端沒有公告預設分支(因為它是空的,或其 HEAD 指向無人推送的分支)時,它會以 `error: Cannot determine remote HEAD` 失敗;此時請明確指定分支。當您的複製不擷取該分支時,它會以 `error: Not a valid ref` 失敗;請先如上所述擴大 refspec。3889* 如果您不想指定分支,請執行 `git fetch origin`,然後執行 `git remote set-head origin --auto`,它會詢問遠端哪個分支是其預設分支。當遠端未公告預設分支(因為它是空的,或其 HEAD 指向一個從未有人推送的分支)時,它會以 `error: Cannot determine remote HEAD` 失敗;此時請改為明確指定分支。當您的 clone 不會擷取該分支時,它會以 `error: Not a valid ref` 失敗;請先依上述方式擴大 refspec。

3878* 如果儲存庫沒有遠端,請使用 `git remote add origin <url>` 新增一個,並在建立參照前先擷取。如果遠端是空的,請先使用 `git push -u origin HEAD` 推送您的分支,並在 set-head 命令中指定該分支;之後 `origin/HEAD` 會指向您剛推送的分支,因此在您的分支與其分歧之前,`/security-review` 看到的差異都會是空的。3890* 如果儲存庫沒有遠端,請使用 `git remote add origin <url>` 新增一個,並在建立 ref 之前先擷取。如果遠端是空的,請先使用 `git push -u origin HEAD` 推送您的分支,並在 set-head 命令中指定該分支;`origin/HEAD` 之後會指向您剛推送的分支,因此在您的分支與其分歧之前,`/security-review` 會看到空的差異。

3879 3891 

3880### No shell command in a skill or command was run3892### skill 或命令中的 shell 命令未被執行

3881 3893 

3882`No shell command in <name> was run` 表示該 skill 或命令檔案中的某個 `` !`<command>` `` [動態上下文命令](https://code.claude.com/docs/zh-TW/skills.md#inject-dynamic-context)包含 Bash 或 PowerShell 工具會拒絕的字元:3894`No shell command in <name> was run` 表示該 skill 或命令檔案中的某個 `` !`<command>` `` [動態脈絡命令](https://code.claude.com/docs/zh-TW/skills.md#inject-dynamic-context)包含 Bash 或 PowerShell 工具會拒絕的字元:

3883 3895 

3884* **任一工具**:除 tab 或換行以外的原始控制字元3896* **兩種工具皆然**:除了 tab 或換行以外的原始控制字元

3885* **PowerShell 工具**:另外還有 U+FEFF 或 U+180E3897* **PowerShell 工具**:另外還有 U+FEFF 或 U+180E

3886 3898 

3887訊息會以被拒絕的命令結尾,並將每個被拒絕的字元顯示為 `�`,如以下 Bash 工具的範例:3899訊息會以被拒絕的命令結尾,並將每個被拒絕的字元顯示為 `�`,如下列 Bash 工具的範例:

3888 3900 

3889```text theme={null}3901```text theme={null}

3890No shell command in /my-skill was run, because the Bash tool does not accept one of them: command contains control characters that would be hidden in the approval dialog. Unprintable characters are shown as � below: remove them from the skill or command file, or from the arguments or options substituted into it.3902No shell command in /my-skill was run, because the Bash tool does not accept one of them: command contains control characters that would be hidden in the approval dialog. Unprintable characters are shown as � below: remove them from the skill or command file, or from the arguments or options substituted into it.


3895 3907 

3896* 在訊息結尾引用的命令中找出每個 `�`。從 [skill 或命令檔案](https://code.claude.com/docs/zh-TW/skills.md#where-skills-live)中,或從代入該檔案的引數或[選項](https://code.claude.com/docs/zh-TW/plugins/manifest-reference.md#user-configuration)中,移除它所代表的字元。3908* 在訊息結尾引用的命令中找出每個 `�`。從 [skill 或命令檔案](https://code.claude.com/docs/zh-TW/skills.md#where-skills-live)中,或從代入該檔案的引數或[選項](https://code.claude.com/docs/zh-TW/plugins/manifest-reference.md#user-configuration)中,移除它所代表的字元。

3897 3909 

3898### 使用 `--print` 時必須提供輸入3910### skill、命令或 hook 超過 4,000,000 字元的限制

3899 3911 

3900單獨執行 `claude` 需要 stdout 是終端機,才能啟動互動式 UI。當 stdout 被重新導向,或主控台不是真正的終端機(例如 PowerShell ISE 與某些 IDE 輸出窗格)時,`claude` 會改以[非互動方式](https://code.claude.com/docs/zh-TW/headless.md)執行。這與 `claude -p` 是相同的模式,而該模式需要提示詞,因此即使您沒有傳入該旗標,訊息也會提到 `--print`。在任何地方傳入 `-p`/`--print` 卻沒有提示詞、stdin 也沒有透過管線傳入任何內容,都會產生相同的錯誤。3912包含 `more than 4,000,000 characters` 的訊息表示某個 skill、命令或 [prompt 或 agent hook](https://code.claude.com/docs/zh-TW/hooks.md#prompt-and-agent-hook-fields) 未執行。如果您將長文字貼上作為引數,請將其存成檔案,並執行 `/clear`(因為該文字會留在對話中),然後傳入其路徑。在 [Code Mode](https://code.claude.com/docs/zh-TW/code-mode.md#tool-call-refused-by-a-hook) 之外,超過限制的 `PreToolUse` prompt 或 agent hook 不會阻擋該呼叫。請改用沒有此限制的 [command hook](https://code.claude.com/docs/zh-TW/hooks.md#command-hook-fields)。

3913 

3914### Input must be provided when using `--print`

3915 

3916單純的 `claude` 需要 stdout 是終端機才能啟動互動式 UI。當 stdout 被重新導向,或主控台不是真正的終端機(例如 PowerShell ISE 與部分 IDE 輸出窗格)時,`claude` 會改為以[非互動方式](https://code.claude.com/docs/zh-TW/headless.md)執行。這與 `claude -p` 是相同的模式,而該模式需要提示詞,因此即使您沒有傳入該旗標,訊息仍會提到 `--print`。在任何地方傳入 `-p`/`--print` 卻沒有提示詞,且 stdin 也沒有透過管線傳入任何內容,都會產生相同的錯誤。

3901 3917 

3902```text theme={null}3918```text theme={null}

3903Error: Input must be provided either through stdin or as a prompt argument when using --print3919Error: Input must be provided either through stdin or as a prompt argument when using --print


3905 3921 

3906**處理方式:**3922**處理方式:**

3907 3923 

3908* 若要互動使用,請在真正的終端機中執行 `claude`:使用 Windows Terminal 或 PowerShell 主控台而非 ISE,並使用 IDE 的整合式終端機而非輸出窗格3924* 若要互動式使用,請在真正的終端機中執行 `claude`:使用 Windows Terminal 或 PowerShell 主控台而非 ISE,並使用 IDE 的整合式終端機而非輸出窗格

3909* 若要單次使用,請傳入提示詞:`claude -p "your question"`,或以 `echo "your question" | claude -p` 透過管線傳入3925* 若要單次使用,請傳入提示詞:`claude -p "your question"`,或以 `echo "your question" | claude -p` 透過管線傳入

3910 3926 

3911### Claude Code 無法在此讀取鍵盤3927### Claude Code can't read the keyboard here

3912 3928 

3913您在不帶 [`-p`](https://code.claude.com/docs/zh-TW/headless) 的情況下執行了 `claude`,這會啟動[互動式工作階段](https://code.claude.com/docs/zh-TW/interactive-mode.md),但其標準輸入不是終端機。有東西透過管線傳送或重新導向了它,或是啟動 `claude` 的程式提供了它自己的輸入串流。3929您在未加上 [`-p`](https://code.claude.com/docs/zh-TW/headless) 的情況下執行了 `claude`,這會啟動[互動式工作階段](https://code.claude.com/docs/zh-TW/interactive-mode.md),但其標準輸入不是終端機。可能是某些內容透過管線傳入或重新導向了標準輸入,或是啟動 `claude` 的程式提供了自己的輸入串流。

3914 3930 

3915互動式工作階段需要從終端機讀取您的按鍵,而沒有終端機時 Claude Code 的行為取決於您的平台:3931互動式工作階段需要終端機來讀取您的按鍵輸入,而 Claude Code 在沒有終端機時的行為取決於您的平台:

3916 3932 

3917* **Windows**:Claude Code 會將訊息列印到 stderr 並以退出碼 1 結束,而不會啟動介面3933* **Windows**:Claude Code 會將訊息輸出到 stderr 並以代碼 1 結束,而不會啟動介面

3918* **macOS 與 Linux**:Claude Code 會從 `/dev/tty` 讀取您的按鍵並啟動工作階段,並以任何透過管線傳入的文字作為您的第一個提示詞。當 `/dev/tty` 無法開啟時,您會看到此訊息,其第一行會以 `/dev/tty` 取代 Windows 的措辭。3934* **macOS 與 Linux**:Claude Code 會從 `/dev/tty` 讀取您的按鍵輸入並啟動工作階段,並將任何透過管線傳入的文字作為您的第一個提示詞。只有在無法開啟 `/dev/tty` 時才會看到此訊息,且其第一行會以 `/dev/tty` 取代 Windows 版的措辭。

3919 3935 

3920在 Windows 上,訊息內容如下:3936在 Windows 上,訊息內容如下:

3921 3937 


3927 3943 

3928**處理方式:**3944**處理方式:**

3929 3945 

3930* 若要互動工作,請直接在終端機中執行 `claude`,不要透過管線傳送或重新導向其輸入3946* 若要以互動方式工作,請直接在終端機中執行 `claude`,不要透過管線傳入或重新導向其輸入

3931* 若要在沒有互動式介面的情況下取得回覆(例如從指令碼),請加上 `-p`,並以引數或透過 stdin 提供提示詞,例如 `claude -p "your question"` 或 `echo "your question" | claude -p`。這也適用於 `--continue` 與 `--resume <session-id>`。3947* 若要在不使用互動式介面的情況下取得回覆(例如從指令碼中),請加上 `-p`,並以引數或透過 stdin 提供提示詞,例如 `claude -p "your question"` 或 `echo "your question" | claude -p`。這同樣適用於 `--continue` 與 `--resume <session-id>`。

3932 3948 

3933在 v2.1.287 之前,Claude Code 會啟動介面而不是列印此訊息,然後要嘛畫面上什麼都不顯示,要嘛以包含 `Raw mode is not supported` 的錯誤失敗。3949在 v2.1.287 之前,Claude Code 會啟動介面而不是輸出此訊息,接著要麼畫面上什麼都不顯示,要麼以包含 `Raw mode is not supported` 的錯誤失敗。

3934 3950 

3935如果您是在執行 `claude install` 時看到 `Raw mode is not supported`,請參閱[安裝期間出現 `Raw mode is not supported`](https://code.claude.com/docs/zh-TW/troubleshoot-install#raw-mode-is-not-supported-during-install)。3951如果您是在 `claude install` 期間看到 `Raw mode is not supported`,請參閱[安裝期間出現 `Raw mode is not supported`](https://code.claude.com/docs/zh-TW/troubleshoot-install#raw-mode-is-not-supported-during-install)。

3936 3952 

3937### 輸入只包含空白字元3953### Input contained only whitespace

3938 3954 

3939在[非互動模式](https://code.claude.com/docs/zh-TW/headless.md)中,Claude Code 會拒絕完全由空格、定位字元或換行組成的提示詞,而不會傳送它,因為 API 會拒絕沒有可見文字的訊息。您看到哪則訊息取決於空白提示詞的來源:3955在[非互動模式](https://code.claude.com/docs/zh-TW/headless.md)中,Claude Code 會拒絕完全由空格、定位字元或換行組成的提示詞,而不會將其送出,因為 API 會拒絕沒有可見文字的訊息。您看到的訊息取決於空白提示詞的來源:

3940 3956 

3941* **`claude -p` 的提示詞引數或透過管線傳入的 stdin**:`claude` 會以 `Error: Input contained only whitespace. Provide a prompt with text through stdin or as a prompt argument when using --print` 結束3957* **`claude -p` 的提示詞引數或透過管線傳入的 stdin**:`claude` 會以 `Error: Input contained only whitespace. Provide a prompt with text through stdin or as a prompt argument when using --print` 結束

3942* **提交到執行中的 `--input-format stream-json` 或 [Agent SDK](https://code.claude.com/docs/zh-TW/agent-sdk/overview.md) 工作階段的訊息**:Claude Code 會在不呼叫模型的情況下結束該回合,工作階段仍可繼續使用。拒絕會以資訊訊息以及該回合的結果文字送達:`Blank prompt — the message was only whitespace, so nothing was sent to the model.`3958* **提交到執行中的 `--input-format stream-json` 或 [Agent SDK](https://code.claude.com/docs/zh-TW/agent-sdk/overview.md) 工作階段的訊息**:Claude Code 會在不呼叫模型的情況下結束該回合,且工作階段仍可繼續使用。拒絕會以資訊訊息以及該回合的結果文字形式傳回:`Blank prompt — the message was only whitespace, so nothing was sent to the model.`

3943 3959 

3944在 v2.1.229 之前,Claude Code 會將只含空白的訊息傳送給 API,而 API 會以 400 錯誤拒絕該請求。3960在 v2.1.229 之前,Claude Code 會將僅含空白的訊息傳送給 API,而 API 會以 400 錯誤拒絕該請求。

3945 3961 

3946**處理方式:**3962**處理方式:**

3947 3963 

3948* 在提示詞中加入可見的文字。如果指令碼是從變數或檔案建立提示詞,請在呼叫 Claude Code 之前確認來源不是空的。3964* 在提示詞中包含可見文字。如果指令碼是從變數或檔案建構提示詞,請在呼叫 Claude Code 之前確認來源不是空的。

3949 3965 

3950### stream-json 輸入超過 256M 個字元且沒有換行3966### stream-json input carried over 256M characters with no newline

3951 3967 

3952您的程式在 stdin 上向 `claude -p --input-format stream-json` 執行傳送了超過 268,435,456 個字元且沒有換行,因此 Claude Code 會將此錯誤列印到 stderr 並以退出碼 1 結束,而不會繼續緩衝更多輸入。訊息中將此上限表示為 `256M`。在 v2.1.257 之前,Claude Code 會無限制地緩衝此類輸入,使記憶體持續增長,直到程序當機或被終止。3968您的程式在沒有換行的情況下,透過 stdin 向 `claude -p --input-format stream-json` 執行傳送了超過 268,435,456 個字元,因此 Claude Code 會將此錯誤輸出到 stderr 並以代碼 1 結束,而不會繼續緩衝更多輸入。訊息中以 `256M` 表示此上限。在 v2.1.257 之前,Claude Code 會無限制地緩衝此類輸入,使記憶體持續增長,直到程序當機或被終止。

3953 3969 

3954```text theme={null}3970```text theme={null}

3955Error: stream-json input carried over 256M characters with no newline. Each stream-json message must be a single newline-terminated JSON line: either the producer is not newline-terminating its messages, or one message exceeded this budget.3971Error: stream-json input carried over 256M characters with no newline. Each stream-json message must be a single newline-terminated JSON line: either the producer is not newline-terminating its messages, or one message exceeded this budget.

3956```3972```

3957 3973 

3958這麼長卻沒有換行的輸入,通常表示產生者根本不是 stream-json 產生者,例如意外透過管線傳入的二進位檔案或純文字日誌輸出。單一訊息超過此上限也會未通過相同的檢查。3974如此長且沒有換行的輸入,通常表示產生者根本不是 stream-json 產生者,例如不小心透過管線傳入的二進位檔案或純文字日誌輸出。單一訊息超過上限也會在同一項檢查中失敗。

3959 3975 

3960**處理方式:**3976**處理方式:**

3961 3977 

3962* 檢查透過管線傳入 stdin 的內容。使用 [`--input-format stream-json`](https://code.claude.com/docs/zh-TW/cli-reference#cli-flags) 時,每則訊息都必須是以換行結尾的一行 JSON3978* 檢查透過管線傳入 stdin 的內容。使用 [`--input-format stream-json`](https://code.claude.com/docs/zh-TW/cli-reference#cli-flags) 時,每則訊息都必須是一行以換行結尾的 JSON

3963* 若要改為傳送純文字,請移除 `--input-format stream-json`;`claude -p` 預設會從 stdin 讀取純文字提示詞3979* 若要改為傳送純文字,請移除 `--input-format stream-json`;`claude -p` 預設會從 stdin 讀取純文字提示詞

3964 3980 

3965### 未知的命令3981### Unknown command

3966 3982 

3967在互動式終端機工作階段中,您提交了一個與此工作階段中任何命令都不相符的 `/` 名稱,因此 Claude Code 會回報該名稱,而不會執行任何動作:3983在互動式終端機工作階段中,您提交了一個與此工作階段中任何命令都不相符的 `/` 名稱,因此 Claude Code 會回報該名稱,而不會執行任何動作:

3968 3984 


3970Unknown command: /hepl. Did you mean /help?3986Unknown command: /hepl. Did you mean /help?

3971```3987```

3972 3988 

3973Claude Code 會建議選單在此工作階段中列出的最接近的命令名稱或別名。當沒有相近的名稱時,訊息會在名稱之後結束。原因通常是以下其中之一:3989Claude Code 會建議此工作階段中選單所列出、最接近的命令名稱或別名。若沒有相近的名稱,訊息會在名稱之後結束。原因通常是下列其中之一:

3974 3990 

3975* 打字錯誤,例如將 `/help` 打成 `/hepl`。[命令選單如何比對您輸入的內容](https://code.claude.com/docs/zh-TW/commands.md#how-the-command-menu-matches-what-you-type)說明了如何在提交前挑選相近的符合項目3991* 打字錯誤,例如將 `/help` 打成 `/hepl`。[命令選單如何比對您輸入的內容](https://code.claude.com/docs/zh-TW/commands.md#how-the-command-menu-matches-what-you-type)說明了如何在提交前選擇相近的符合項目

3976* 命令存在,但由於未滿足某項要求(例如您的平台、方案或身分驗證方式),在此工作階段中無法使用。請參閱 [`/web-setup`](https://code.claude.com/docs/zh-TW/web-quickstart#web-setup-shows-no-commands-match-or-unknown-command)、[`/schedule`](https://code.claude.com/docs/zh-TW/routines#schedule-returns-unknown-command) 或 [`/auto-mode-setup`](https://code.claude.com/docs/zh-TW/auto-mode-config#auto-mode-setup-returns-unknown-command) 的相關項目。某些命令在您組織的政策停用它們時,會以自己的訊息回應,例如 [`Cloud sessions are disabled by your organization's policy`](#cloud-sessions-are-disabled-by-your-organizations-policy)3992* 命令存在,但因為未符合某項需求(例如您的平台、方案或身分驗證方式)而無法在此工作階段中使用。請參閱 [`/web-setup`](https://code.claude.com/docs/zh-TW/web-quickstart#web-setup-shows-no-commands-match-or-unknown-command)、[`/schedule`](https://code.claude.com/docs/zh-TW/routines#schedule-returns-unknown-command) 或 [`/auto-mode-setup`](https://code.claude.com/docs/zh-TW/auto-mode-config#auto-mode-setup-returns-unknown-command) 的對應項目。某些命令在您組織的政策停用它們時,會以自己的訊息回應,例如 [`Cloud sessions are disabled by your organization's policy`](#cloud-sessions-are-disabled-by-your-organizations-policy)

3977* 來自[外掛](https://code.claude.com/docs/zh-TW/plugins/overview.md)或 [MCP 伺服器](https://code.claude.com/docs/zh-TW/mcp.md#use-mcp-prompts-as-commands)的命令,但該外掛或伺服器在此工作階段中未安裝或未連線3993* 來自[外掛](https://code.claude.com/docs/zh-TW/plugins/overview.md)或 [MCP 伺服器](https://code.claude.com/docs/zh-TW/mcp.md#use-mcp-prompts-as-commands)的命令,但該外掛或伺服器未在此工作階段中安裝或連線

3978 3994 

3979只有在互動式終端機工作階段中,Claude Code 才會以這種方式回應不相符的 `/` 名稱。在其他所有工作階段中,它會改將提示詞作為一般訊息傳送給 Claude,並附上一則說明該命令未執行的備註,以及 Claude 在該工作階段中可執行的命令清單。這些工作階段包括:3995Claude Code 只會在互動式終端機工作階段中以這種方式回應不相符的 `/` 名稱。在所有其他工作階段中,它會改為將提示詞作為一般訊息傳送給 Claude,並附上說明命令未執行的註記,以及 Claude 可在該工作階段中執行的命令清單。這些工作階段包括:

3980 3996 

3981* `-p` 執行3997* `-p` 執行

3982* [Agent SDK](https://code.claude.com/docs/zh-TW/agent-sdk/overview.md) 應用程式3998* [Agent SDK](https://code.claude.com/docs/zh-TW/agent-sdk/overview.md) 應用程式


3984* [VS Code 擴充功能](https://code.claude.com/docs/zh-TW/vs-code.md)的聊天面板4000* [VS Code 擴充功能](https://code.claude.com/docs/zh-TW/vs-code.md)的聊天面板

3985* [雲端工作階段](https://code.claude.com/docs/zh-TW/claude-code-on-the-web.md)與[雲端排程任務](https://code.claude.com/docs/zh-TW/routines.md)4001* [雲端工作階段](https://code.claude.com/docs/zh-TW/claude-code-on-the-web.md)與[雲端排程任務](https://code.claude.com/docs/zh-TW/routines.md)

3986 4002 

3987對於無法在這些工作階段之一中執行的內建命令,Claude Code 仍會回應該命令無法使用,而不是將其傳送給 Claude。在 v2.1.274 之前,只有雲端工作階段與雲端排程任務會將不相符的名稱傳送給 Claude。在 v2.1.273 之前,它們也會回應 `Unknown command`。4003對於無法在上述工作階段中執行的內建命令,Claude Code 仍會回應該命令無法使用,而不會將其傳送給 Claude。在 v2.1.274 之前,只有雲端工作階段與雲端排程任務會將不相符的名稱傳送給 Claude。在 v2.1.273 之前,它們同樣會回應 `Unknown command`。

3988 4004 

3989Claude Code 不會將每個以 `/` 開頭的提示詞都視為命令。當 `/` 之後的第一個字以標點符號開頭(例如開啟 Lean 文件註解的 `/--`),或是像 `/var/log/syslog` 這樣的路徑時,它會將提示詞作為一般訊息傳送給 Claude。4005Claude Code 不會將每個以 `/` 開頭的提示詞都視為命令。當 `/` 之後的第一個字以標點符號開頭(例如開啟 Lean 文件註解的 `/--`),或是一個路徑(例如 `/var/log/syslog`)時,它會將提示詞作為一般訊息傳送給 Claude。

3990 4006 

3991在 v2.1.236 之前,如果您在命令選單列出與您輸入的名稱相近的符合項目時按下 `Enter`,Claude Code 會執行該符合項目,因此像 `/hepl` 這樣的打字錯誤會執行 `/help`,而不是產生此訊息。4007在 v2.1.236 之前,如果您在命令選單列出與您輸入名稱相近的符合項目時按下 `Enter`,Claude Code 會執行該符合項目,因此像 `/hepl` 這樣的打字錯誤會執行 `/help`,而不會產生此訊息。

3992 4008 

3993**處理方式:**4009**處理方式:**

3994 4010 

3995* 執行建議的名稱,或輸入 `/` 加上名稱的一部分,以查看此工作階段中可用的命令4011* 執行建議的名稱,或輸入 `/` 再加上名稱的一部分,以查看此工作階段中可用的命令

3996* 如果 Claude Code 將文件中記載的命令回報為未知,請查看[命令參考](https://code.claude.com/docs/zh-TW/commands.md)中該命令的列,了解它所指出的需求4012* 如果 Claude Code 將文件中記載的命令回報為未知,請在[命令參考](https://code.claude.com/docs/zh-TW/commands.md)中查看該命令所在列所列出的需求

3997 4013 

3998### 差異對 ultrareview 而言過大4014### Diff is too large for ultrareview

3999 4015 

4000您的分支與基底分支之間的差異(包括未提交與已暫存的變更)超過了 [ultrareview](https://code.claude.com/docs/zh-TW/ultrareview.md) 的大小上限,因此 `/code-review ultra` 與 `claude ultrareview` 子命令會在雲端工作階段啟動前拒絕該審查。被拒絕的審查不會使用免費執行次數,也不會收取用量點數。訊息會指出生效的上限、您的差異大小,以及貢獻最多變更行數的檔案。在 v2.1.216 之前,訊息只顯示原始的差異統計資料。4016您的分支與基礎分支之間的差異(包含未提交與已暫存的變更)超過了 [ultrareview](https://code.claude.com/docs/zh-TW/ultrareview.md) 的大小限制,因此 `/code-review ultra` 與 `claude ultrareview` 子命令會在雲端工作階段啟動之前拒絕審查。被拒絕的審查不會用掉免費次數,也不會計費用量點數。訊息會列出目前生效的限制、您的差異大小,以及貢獻最多變更行數的檔案。在 v2.1.216 之前,訊息只會顯示原始的差異統計資料。

4001 4017 

4002```text theme={null}4018```text theme={null}

4003Diff is too large for ultrareview: 812 files, 96,410 lines changed (limits: 500 files, 8,000 lines). Largest files: package-lock.json (41,904 lines), dist/bundle.js (18,210 lines), src/generated/api.ts (9,876 lines). Pass a closer base branch (`/code-review ultra <branch>`) to narrow the scope, or split the change.4019Diff is too large for ultrareview: 812 files, 96,410 lines changed (limits: 500 files, 8,000 lines). Largest files: package-lock.json (41,904 lines), dist/bundle.js (18,210 lines), src/generated/api.ts (9,876 lines). Pass a closer base branch (`/code-review ultra <branch>`) to narrow the scope, or split the change.

4004```4020```

4005 4021 

4006審查 pull request 時也適用相同的上限;該形式的訊息以 `PR #<N> is too large for ultrareview` 開頭,並指出該 PR 的檔案數與行數。4022審查 pull request 時適用相同的限制;該形式的訊息以 `PR #<N> is too large for ultrareview` 開頭,並列出該 PR 的檔案數與行數。

4007 4023 

4008**處理方式:**4024**處理方式:**

4009 4025 

4010* 傳入更接近您工作的基底分支,例如 `/code-review ultra develop`,讓審查只涵蓋與該分支之間的差異4026* 傳入更接近您工作內容的基礎分支,例如 `/code-review ultra develop`,讓審查只涵蓋與該分支之間的差異

4011* 將變更拆分為較小的分支並逐一審查。訊息所指名的檔案貢獻了最多的變更行數,因此請先將它們移到各自的分支。4027* 將變更拆分成較小的分支並分別審查。訊息所列出的檔案貢獻了最多的變更行數,因此請先將這些檔案移到各自的分支。

4012 4028 

4013### 找不到與基底分支的 merge-base4029### Could not find merge-base with the base branch

4014 4030 

4015`/code-review ultra` 與 `claude ultrareview` 子命令會審查您的分支與基底分支之間的差異,這需要兩者共同擁有的提交。當 `git merge-base` 找不到任何共同提交時,Claude Code 會在雲端工作階段啟動前拒絕該審查。在 Claude Code 能驗證為完整、且至少有一個分支的複製上,它會改為[審查每個被追蹤的檔案](https://code.claude.com/docs/zh-TW/ultrareview.md#diff-limits-and-fallbacks),而不是拒絕。當完全找不到基底分支、Claude Code 無法驗證您的複製是否完整,或在無法進行整棵樹差異比對的少數儲存庫中(例如 SHA-256 物件格式),您會看到此拒絕訊息。4031`/code-review ultra` 與 `claude ultrareview` 子命令會審查您的分支與基礎分支之間的差異,這需要兩者共有的一個提交。當 `git merge-base` 找不到共有提交時,Claude Code 會在雲端工作階段啟動之前拒絕審查。在 Claude Code 能確認為完整、且至少有一個分支的 clone 上,它會改為[審查每個受追蹤的檔案](https://code.claude.com/docs/zh-TW/ultrareview.md#diff-limits-and-fallbacks),而不是拒絕。您會在以下情況看到此拒絕:完全找不到基礎分支、Claude Code 無法確認您的 clone 是否完整,或是在極少數無法進行整個樹狀結構差異比對的儲存庫中,例如使用 SHA-256 物件格式的儲存庫。

4016 4032 

4017```text theme={null}4033```text theme={null}

4018Could not find merge-base with main. Pass the base branch explicitly (e.g. `/code-review ultra develop`) or make sure you're in a git repo with a main branch.4034Could not find merge-base with main. Pass the base branch explicitly (e.g. `/code-review ultra develop`) or make sure you're in a git repo with a main branch.


4020 4036 

4021第一句之後的提示取決於 Claude Code 觀察到的情況:4037第一句之後的提示取決於 Claude Code 觀察到的情況:

4022 4038 

4023* **您沒有傳入基底分支**:Claude Code 與儲存庫的預設分支進行比較,並建議您明確傳入基底分支,如上例所示4039* **您未傳入基礎分支**:Claude Code 會與儲存庫的預設分支比較,並建議您明確傳入基礎分支,如上方範例所示

4024* **您傳入的基底分支已存在於您的複製中**:提示內容為 ``Make sure <branch> exists locally or on origin (try `git fetch origin <branch>`)``4040* **您傳入的基礎分支原本就在您的 clone 中**:提示內容為 ``Make sure <branch> exists locally or on origin (try `git fetch origin <branch>`)``

4025* **您傳入的基礎分支不在您的 clone 中**:Claude Code 在比較之前會先從 origin 擷取它。提示內容為 ``<branch> was fetched from origin but shares no history with HEAD. If another branch is your real base, pass it explicitly (`/code-review ultra <branch>`)``;當 Claude Code 無法判斷您的 clone 是否為淺層 clone 時,則會改為建議 `git fetch --unshallow origin`。在 v2.1.221 之前,提示會對每個擷取的基礎分支都建議 `git fetch --unshallow origin`,而在完整的 clone 上,該命令會以 `fatal: --unshallow on a complete repository does not make sense` 失敗。4041* **您傳入的基礎分支不在您的 clone 中**:Claude Code 在比較前已從 origin 擷取該分支。提示內容為 ``<branch> was fetched from origin but shares no history with HEAD. If another branch is your real base, pass it explicitly (`/code-review ultra <branch>`)``;當 Claude Code 無法判斷您的 clone 是否為淺層 clone 時,則會改為建議 `git fetch --unshallow origin`。在 v2.1.221 之前,對於每個擷取的基礎分支,提示都會建議 `git fetch --unshallow origin`,而在完整的 clone 上,該命令會以 `fatal: --unshallow on a complete repository does not make sense` 失敗。

4026 4042 

4027**處理方式:**4043**處理方式:**

4028 4044 

4029* 如果另一個分支才是您真正的基底,請明確傳入它:`/code-review ultra <branch>`4045* 如果另一個分支才是您真正的基礎分支,請明確傳入:`/code-review ultra <branch>`

4030* 如果您的複製可能沒有完整歷史,請執行 `git fetch --unshallow origin` 並重新執行審查4046* 如果您的 clone 可能沒有完整的歷史記錄,請執行 `git fetch --unshallow origin` 並重新執行審查

4031 4047 

4032### 您的 checkout 沒有任何分支4048### Your checkout has no branches

4033 4049 

4034checkout 可能有提交卻沒有分支:如果您執行 `git init`,接著執行 `git fetch <url>` 與 `git checkout FETCH_HEAD`,就會得到一個沒有任何參照的分離 HEAD。Claude Code 會將您的儲存庫打包為 git bundle 以上傳進行 [ultrareview](https://code.claude.com/docs/zh-TW/ultrareview.md),而它無法打包沒有分支或其他參照的儲存庫,因此 `/code-review ultra` 與 `claude ultrareview` 子命令會在雲端工作階段啟動前拒絕該審查。4050checkout 可能有提交卻沒有分支:如果您執行 `git init`,接著執行 `git fetch <url>` 與 `git checkout FETCH_HEAD`,就會得到一個沒有任何 ref 的 detached HEAD。Claude Code 會將您的儲存庫打包成 git bundle 以上傳進行 [ultrareview](https://code.claude.com/docs/zh-TW/ultrareview.md),而它無法打包沒有分支或其他 ref 的儲存庫,因此 `/code-review ultra` 與 `claude ultrareview` 子命令會在雲端工作階段啟動之前拒絕審查。

4035 4051 

4036```text theme={null}4052```text theme={null}

4037Your checkout has no branches (detached HEAD only), which cloud review can't bundle. Create one first — `git checkout -b <name>` — then rerun /code-review ultra.4053Your checkout has no branches (detached HEAD only), which cloud review can't bundle. Create one first — `git checkout -b <name>` — then rerun /code-review ultra.

4038```4054```

4039 4055 

4040在 v2.1.221 之前,Claude Code 會嘗試審查此 checkout 中每個被追蹤的檔案,而上傳會失敗。4056在 v2.1.221 之前,Claude Code 會嘗試審查此 checkout 中每個受追蹤的檔案,而上傳會失敗。

4041 4057 

4042**處理方式:**4058**處理方式:**

4043 4059 

4044* 使用 `git checkout -b <name>` 在目前的提交上建立分支,然後重新執行審查4060* 使用 `git checkout -b <name>` 在目前的提交上建立分支,然後重新執行審查

4045 4061 

4046### 沒有 GitHub 帳戶連結到您的 Claude 帳戶4062### No GitHub account is connected to your Claude account

4047 4063 

4048您執行了 `/code-review ultra <PR#>` 或 `claude ultrareview <PR#>`,而在建立雲端工作階段之前,Claude Code 會詢問伺服器[連結到您 Claude 帳戶的 GitHub 帳戶](https://code.claude.com/docs/zh-TW/ultrareview.md#review-a-pull-request)是否能存取該 PR 的儲存庫。由於沒有連結任何帳戶,或連結已過期,雲端複製將會失敗,因此 Claude Code 會拒絕啟動。對於被拒絕的啟動,Claude Code 不會耗用免費執行次數,也不會收取用量點數。4064您執行了 `/code-review ultra <PR#>` 或 `claude ultrareview <PR#>`,而在建立雲端工作階段之前,Claude Code 會詢問伺服器[連結到您 Claude 帳戶的 GitHub 帳戶](https://code.claude.com/docs/zh-TW/ultrareview.md#review-a-pull-request)是否能存取該 PR 的儲存庫。由於沒有連結任何帳戶,或連結已過期,雲端 clone 將會失敗,因此 Claude Code 拒絕啟動。被拒絕的啟動不會用掉免費次數,也不會計費用量點數。

4049 4065 

4050```text theme={null}4066```text theme={null}

4051Ultrareview clones <owner>/<repo> in the cloud with the GitHub account connected to your Claude account, and none is connected (or the connection expired). To fix: run /web-setup to reuse your GitHub CLI login, or connect an account at https://claude.ai/connect-github — then re-run /code-review ultra 1234 (allow a minute after connecting).4067Ultrareview clones <owner>/<repo> in the cloud with the GitHub account connected to your Claude account, and none is connected (or the connection expired). To fix: run /web-setup to reuse your GitHub CLI login, or connect an account at https://claude.ai/connect-github — then re-run /code-review ultra 1234 (allow a minute after connecting).

4052```4068```

4053 4069 

4054當 [`/web-setup`](https://code.claude.com/docs/zh-TW/web-quickstart#connect-from-your-terminal) 在您的工作階段中無法使用時,訊息只會提到 claude.ai 連結。4070當 [`/web-setup`](https://code.claude.com/docs/zh-TW/web-quickstart#connect-from-your-terminal) 在您的工作階段中無法使用時,訊息只會列出 claude.ai 連結。

4055 4071 

4056**處理方式:**4072**處理方式:**

4057 4073 

4058* 執行 `/web-setup` 將您的 GitHub CLI 登入連結到您的 Claude 帳戶,或在 [claude.ai/connect-github](https://claude.ai/connect-github) 連結帳戶4074* 執行 `/web-setup` 將您的 GitHub CLI 登入連結到您的 Claude 帳戶,或在 [claude.ai/connect-github](https://claude.ai/connect-github) 連結帳戶

4059* 連結後約一分鐘再重新執行審查4075* 連結後等待一分鐘再重新執行審查

4060 4076 

4061在 v2.1.248 之前,Claude Code 不會在啟動前檢查此項目。4077在 v2.1.248 之前,Claude Code 不會在啟動前進行此檢查。

4062 4078 

4063### 您連結的 GitHub 帳戶無法看到該儲存庫4079### Your connected GitHub account can't see the repository

4064 4080 

4065您執行了 `/code-review ultra <PR#>` 或 `claude ultrareview <PR#>`,而[連結到您 Claude 帳戶的 GitHub 帳戶](https://code.claude.com/docs/zh-TW/ultrareview.md#review-a-pull-request)無法讀取該 PR 的儲存庫,因此雲端複製將會失敗,Claude Code 會拒絕啟動。對於被拒絕的啟動,Claude Code 不會耗用免費執行次數,也不會收取用量點數。4081您執行了 `/code-review ultra <PR#>` 或 `claude ultrareview <PR#>`,而[連結到您 Claude 帳戶的 GitHub 帳戶](https://code.claude.com/docs/zh-TW/ultrareview.md#review-a-pull-request)無法讀取該 PR 的儲存庫,因此雲端 clone 將會失敗,Claude Code 拒絕啟動。被拒絕的啟動不會用掉免費次數,也不會計費用量點數。

4066 4082 

4067```text theme={null}4083```text theme={null}

4068Your connected GitHub account can't see <owner>/<repo> — usually the Claude GitHub app isn't installed on <owner> or wasn't granted this repo (web-connected accounts need it for private repos), or a different GitHub account is connected. To fix: run /web-setup to reuse your GitHub CLI login, or install the app at https://github.com/apps/claude/installations/new — then re-run /code-review ultra 1234.4084Your connected GitHub account can't see <owner>/<repo> — usually the Claude GitHub app isn't installed on <owner> or wasn't granted this repo (web-connected accounts need it for private repos), or a different GitHub account is connected. To fix: run /web-setup to reuse your GitHub CLI login, or install the app at https://github.com/apps/claude/installations/new — then re-run /code-review ultra 1234.

4069```4085```

4070 4086 

4071當 [`/web-setup`](https://code.claude.com/docs/zh-TW/web-quickstart#connect-from-your-terminal) 在您的工作階段中無法使用時,訊息只會提到安裝應用程式。4087當 [`/web-setup`](https://code.claude.com/docs/zh-TW/web-quickstart#connect-from-your-terminal) 在您的工作階段中無法使用時,訊息只會列出應用程式安裝方式。

4072 4088 

4073**處理方式:**4089**處理方式:**

4074 4090 

4075* 如果您本機的 `gh` CLI 能夠讀取該儲存庫,請執行 `/web-setup` 將該登入連結到您的 Claude 帳戶4091* 如果您本機的 `gh` CLI 可以讀取該儲存庫,請執行 `/web-setup` 將該登入連結到您的 Claude 帳戶

4076* 完成變更後重新執行審查4092* 完成變更後重新執行審查

4077 4093 

4078在 v2.1.248 之前,Claude Code 不會在啟動前檢查此項目。4094在 v2.1.248 之前,Claude Code 不會在啟動前進行此檢查。

4079 4095 

4080### GitHub App 預檢暫時性失敗4096### The GitHub App preflight failed transiently

4081 4097 

4082您從本機儲存庫啟動了[雲端工作階段](https://code.claude.com/docs/zh-TW/claude-code-on-the-web.md),而有兩個步驟同時失敗。Claude Code 無法建置或上傳您儲存庫的 bundle。在上傳之前,它檢查了雲端服務是否能從 GitHub 複製該儲存庫,而該檢查並未得到明確的答案,而是以重試可能排除的錯誤結束,例如網路錯誤、逾時或暫時性的伺服器錯誤。完整訊息會以阻止 bundle 的原因開頭,例如 `Could not upload repo bundle (<error>)`,並以預檢的句子結尾:4098您從本機儲存庫啟動了[雲端工作階段](https://code.claude.com/docs/zh-TW/claude-code-on-the-web.md),而有兩個步驟同時失敗。Claude Code 無法建置或上傳您儲存庫的 bundle。在上傳之前,它會檢查雲端服務是否能從 GitHub clone 該儲存庫,而該檢查沒有得到明確的答案,而是以重試可能解決的錯誤結束,例如網路錯誤、逾時或暫時性的伺服器錯誤。完整訊息以造成 bundle 失敗的原因開頭,例如 `Could not upload repo bundle (<error>)`,並以預檢句子結尾:

4083 4099 

4084```text theme={null}4100```text theme={null}

4085Could not upload repo bundle (<error>). The GitHub App preflight failed transiently (network or service hiccup) — retry in a moment to start from GitHub instead4101Could not upload repo bundle (<error>). The GitHub App preflight failed transiently (network or service hiccup) — retry in a moment to start from GitHub instead


4087 4103 

4088**處理方式:**4104**處理方式:**

4089 4105 

4090* 稍後重新執行命令。當 GitHub 檢查通過時,Claude Code 可以從 GitHub 複製啟動工作階段,因此失敗的上傳不再阻擋啟動4106* 稍候片刻後重新執行命令。當 GitHub 檢查通過時,Claude Code 可以從 GitHub clone 啟動工作階段,因此失敗的上傳就不再阻擋啟動

4091* 如果重試持續失敗,訊息開頭會指出阻止上傳的原因。當該原因是您可以修正的問題時,請加以修正,讓工作階段能改從您的本機儲存庫啟動4107* 如果重試持續失敗,訊息開頭會列出造成上傳失敗的原因。若該原因是您可以修正的,請加以修正,讓工作階段可以改從您的本機儲存庫啟動

4092 4108 

4093在 v2.1.251 之前,即使 GitHub 檢查只是暫時性失敗,Claude Code 也會以 `Please set up GitHub on https://claude.ai/code` 結束訊息,而設定建議無法排除暫時性失敗。4109在 v2.1.251 之前,即使 GitHub 檢查只是暫時性失敗,Claude Code 也會以 `Please set up GitHub on https://claude.ai/code` 作為訊息結尾,而設定建議無法解決暫時性失敗。

4094 4110 

4095### 儲存庫上傳無法遵循某項 git 設定4111### The repository upload can't follow a git setting

4096 4112 

4097您啟動了[上傳本機儲存庫的雲端工作階段](https://code.claude.com/docs/zh-TW/claude-code-on-the-web.md#send-local-repositories-without-github),或對某個分支進行 [ultrareview](https://code.claude.com/docs/zh-TW/ultrareview.md),而上傳無法遵循決定哪些屬性規則適用於您檔案的某項 git 設定。如果上傳照常進行並漏掉某條規則,那麼 git 在儲存前會轉換的檔案(例如由 clean 過濾器加密的檔案)可能會以磁碟上的原樣傳到雲端。Claude Code 會改為拒絕上傳,不會上傳任何內容:4113您啟動了[會上傳本機儲存庫的雲端工作階段](https://code.claude.com/docs/zh-TW/claude-code-on-the-web.md#send-local-repositories-without-github),或是對某個分支進行 [ultrareview](https://code.claude.com/docs/zh-TW/ultrareview.md),而上傳無法遵循用於決定哪些屬性規則套用到您檔案的某個 git 設定。如果上傳繼續進行而遺漏了某條規則,則 git 在儲存前會轉換的檔案(例如由 clean 篩選器加密的檔案)可能會以磁碟上的原樣傳到雲端。因此 Claude Code 會拒絕上傳,且不會上傳任何內容:

4098 4114 

4099```text theme={null}4115```text theme={null}

4100Not uploading this working tree: core.ignoreCase (which decides whether .gitattributes patterns match file names regardless of letter case) is set in <file>, and the upload cannot follow that setting, so a file git would change before storing it (to encrypt it, for example) could be uploaded as it is on disk. Move the core.ignoreCase line into this repository’s .git/config or directly into your ~/.gitconfig, then retry.4116Not uploading this working tree: core.ignoreCase (which decides whether .gitattributes patterns match file names regardless of letter case) is set in <file>, and the upload cannot follow that setting, so a file git would change before storing it (to encrypt it, for example) could be uploaded as it is on disk. Move the core.ignoreCase line into this repository’s .git/config or directly into your ~/.gitconfig, then retry.

4101```4117```

4102 4118 

4103訊息會指出該設定及其設定位置,並以針對您所遇情況的修正方式結尾。`core.attributesFile` 與 `attr.tree` 也會出現相同的拒絕訊息,各自附有其修正方式。4119訊息會列出該設定及其設定位置,並以針對您遇到情況的修正方式作為結尾。`core.attributesFile` 與 `attr.tree` 也會出現相同的拒絕,各自附有其修正方式。

4104 4120 

4105訊息可能會指出您的 git 設定透過 `include` 或 `includeIf` 指示引入的設定檔,即使該指示的條件並不適用於此儲存庫。4121訊息可能會列出您的 git 設定透過 `include` 或 `includeIf` 指示詞引入的設定檔,即使該指示詞的條件並不適用於此儲存庫。

4106 4122 

4107**處理方式:**4123**處理方式:**

4108 4124 

4109* 套用訊息最後一句中的修正方式4125* 套用訊息最後一句中的修正方式

4110 4126 

4111### GitHub 未連結到您的 Claude 帳戶4127### GitHub isn't connected to your Claude account

4112 4128 

4113您從本機儲存庫啟動了[雲端工作階段](https://code.claude.com/docs/zh-TW/claude-code-on-the-web.md),例如使用 `/autofix-pr`。沒有 GitHub 帳戶連結到您的 Claude 帳戶,或連結已過期,因此 Claude Code 會拒絕啟動:4129您從本機儲存庫啟動了[雲端工作階段](https://code.claude.com/docs/zh-TW/claude-code-on-the-web.md),例如使用 `/autofix-pr`。由於沒有 GitHub 帳戶連結到您的 Claude 帳戶,或連結已過期,因此 Claude Code 拒絕啟動:

4114 4130 

4115```text theme={null}4131```text theme={null}

4116GitHub isn't connected to your Claude account, so this repository can't be cloned in the cloud. Run /web-setup to connect with your GitHub CLI login, or connect on the web at https://claude.ai/connect-github4132GitHub isn't connected to your Claude account, so this repository can't be cloned in the cloud. Run /web-setup to connect with your GitHub CLI login, or connect on the web at https://claude.ai/connect-github

4117```4133```

4118 4134 

4119當您使用 [`/schedule`](https://code.claude.com/docs/zh-TW/routines) 建立雲端排程任務時,相同的訊息會以列出儲存庫的設定提示形式出現;該提示不會阻擋任務的建立。4135當您使用 [`/schedule`](https://code.claude.com/docs/zh-TW/routines) 建立雲端排程任務時,相同的訊息會以列出該儲存庫的設定註記形式出現;該註記不會阻擋任務的建立。

4120 4136 

4121**處理方式:**4137**處理方式:**

4122 4138 

4123* 執行 `/web-setup` 將您的 GitHub CLI 登入連結到您的 Claude 帳戶,或在 [claude.ai/connect-github](https://claude.ai/connect-github) 連結帳戶。關於兩者的差異,請參閱 [GitHub 身分驗證選項](https://code.claude.com/docs/zh-TW/claude-code-on-the-web.md#github-authentication-options)。4139* 執行 `/web-setup` 將您的 GitHub CLI 登入連結到您的 Claude 帳戶,或在 [claude.ai/connect-github](https://claude.ai/connect-github) 連結帳戶。關於兩者的差異,請參閱 [GitHub 身分驗證選項](https://code.claude.com/docs/zh-TW/claude-code-on-the-web.md#github-authentication-options)。

4124* 連結後約一分鐘再重新執行命令4140* 連結後等待一分鐘再重新執行命令

4125 4141 

4126在 v2.1.268 之前,Claude Code 會將此情況回報為 Claude GitHub App 檢查的暫時性失敗,並建議重試或安裝該應用程式;但這兩者都無法連結 GitHub 帳戶。4142在 v2.1.268 之前,Claude Code 會將此情況回報為 Claude GitHub App 檢查的暫時性失敗,並建議重試或安裝該應用程式;但這兩者都不會連結 GitHub 帳戶。

4127 4143 

4128### GitHub 組織政策正在封鎖 Claude4144### A GitHub organization policy is blocking Claude

4129 4145 

4130您在 Claude Code 提示字元執行了會啟動雲端工作階段的命令,例如 [`/autofix-pr`](https://code.claude.com/docs/zh-TW/claude-code-on-the-web#auto-fix-pull-requests)。在建立工作階段之前,Claude Code 會在 GitHub 上檢查 Claude 對儲存庫的存取權,而 GitHub 拒絕了,因為您的 GitHub 組織有一項封鎖 Claude 的政策。Claude Code 會在此停止,並顯示一則指出該政策的訊息。4146您在 Claude Code 提示字元執行了會啟動雲端工作階段的命令,例如 [`/autofix-pr`](https://code.claude.com/docs/zh-TW/claude-code-on-the-web#auto-fix-pull-requests)。在建立工作階段之前,Claude Code 會檢查 Claude 在 GitHub 上對該儲存庫的存取權,而 GitHub 因為您的 GitHub 組織有封鎖 Claude 的政策而拒絕。Claude Code 會在此停止,並顯示列出該政策的訊息。

4131 4147 

4132當封鎖存取的是 IP 允許清單時,訊息內容為:4148當封鎖存取的是 IP 允許清單時,訊息內容如下:

4133 4149 

4134```text theme={null}4150```text theme={null}

4135Your GitHub organization has an IP allowlist that is blocking Claude. Add Claude's IP ranges to your GitHub allowlist.4151Your GitHub organization has an IP allowlist that is blocking Claude. Add Claude's IP ranges to your GitHub allowlist.

4136```4152```

4137 4153 

4138當封鎖存取的是單一登入時,訊息內容為:4154當封鎖的是單一登入時,訊息內容如下:

4139 4155 

4140```text theme={null}4156```text theme={null}

4141Your GitHub organization requires single sign-on. Disconnect and reconnect GitHub on the Connectors page in Claude on the web, click Authorize next to your organization when GitHub asks, then try again.4157Your GitHub organization requires single sign-on. Disconnect and reconnect GitHub on the Connectors page in Claude on the web, click Authorize next to your organization when GitHub asks, then try again.

4142```4158```

4143 4159 

4144當封鎖存取的是 Microsoft Entra ID 條件式存取政策時,訊息內容為:4160當封鎖的是 Microsoft Entra ID 條件式存取政策時,訊息內容如下:

4145 4161 

4146```text theme={null}4162```text theme={null}

4147Your GitHub organization's identity provider (Microsoft Entra ID) has a Conditional Access policy that is blocking Claude. Ask your GitHub Enterprise or Entra ID admin to allow Claude in that policy.4163Your GitHub organization's identity provider (Microsoft Entra ID) has a Conditional Access policy that is blocking Claude. Ask your GitHub Enterprise or Entra ID admin to allow Claude in that policy.


4149 4165 

4150**處理方式:**4166**處理方式:**

4151 4167 

4152* **IP 允許清單**:請 GitHub 組織或企業的擁有者允許 Anthropic 的對外 IP 位址。請參閱 [GitHub 允許清單與防火牆](https://code.claude.com/docs/zh-TW/network-config.md#github-allow-lists-and-firewalls),了解相關位址以及需要變更的 GitHub 設定。4168* **IP 允許清單**:請您的 GitHub 組織或企業的擁有者允許 Anthropic 的對外 IP 位址。關於這些位址以及需要變更的 GitHub 設定,請參閱 [GitHub 允許清單與防火牆](https://code.claude.com/docs/zh-TW/network-config.md#github-allow-lists-and-firewalls)。

4153* **單一登入**:在 [claude.ai/customize/connectors](https://claude.ai/customize/connectors) 中中斷 GitHub 的連接,然後再次連接。當 GitHub 詢問時,按一下組織旁的 **Authorize**,讓新連線獲得該組織單一登入的授權。4169* **單一登入**:在 [claude.ai/customize/connectors](https://claude.ai/customize/connectors) 中斷 GitHub 連結,然後重新連結。當 GitHub 詢問時,請點選您組織旁的 **Authorize**,讓新的連結獲得其單一登入的授權。

4154* **條件式存取政策**:請您的 GitHub Enterprise 或 Microsoft Entra ID 管理員在該政策中允許 Claude4170* **條件式存取政策**:請您的 GitHub Enterprise 或 Microsoft Entra ID 管理員在該政策中允許 Claude

4155* 完成變更後,再次執行該命令4171* 完成變更後,再次執行命令

4156 4172 

4157### 需要單一登入授權4173### Single sign-on authorization needed

4158 4174 

4159您執行了 [`/install-github-app`](https://code.claude.com/docs/zh-TW/github-actions#quick-setup),並選擇了一個其組織強制使用 SAML 單一登入的儲存庫。在設定之前,Claude Code 會使用 GitHub CLI 檢查您對該儲存庫的存取權,而 GitHub 拒絕了該檢查,因為您的 `gh` token 尚未獲得該組織的授權。精靈會顯示警告以及授權步驟:4175您執行了 [`/install-github-app`](https://code.claude.com/docs/zh-TW/github-actions#quick-setup),並選擇了一個其組織強制執行 SAML 單一登入的儲存庫。在設定之前,Claude Code 會使用 GitHub CLI 檢查您對該儲存庫的存取權,而 GitHub 拒絕了該檢查,因為您的 `gh` token 尚未獲得該組織的授權。精靈會顯示警告以及授權步驟:

4160 4176 

4161```text theme={null}4177```text theme={null}

4162Single sign-on authorization needed4178Single sign-on authorization needed


4165 4181 

4166**處理方式:**4182**處理方式:**

4167 4183 

4168* 執行 `gh auth refresh -h github.com -s repo,workflow`,以 `repo` 和 `workflow` 範圍重新授權您的 GitHub CLI 登入,並在 GitHub 提示單一登入時授權該組織4184* 執行 `gh auth refresh -h github.com -s repo,workflow`,以 `repo` 與 `workflow` 範圍重新授權您的 GitHub CLI 登入,並在 GitHub 提示單一登入時授權該組織

4169* 如果您使用 `GH_TOKEN` 中的個人存取 token 進行驗證,請開啟 [github.com/settings/tokens](https://github.com/settings/tokens),在該 token 上選擇 **Configure SSO**,並授權該組織4185* 如果您使用 `GH_TOKEN` 中的個人存取 token 進行身分驗證,請開啟 [github.com/settings/tokens](https://github.com/settings/tokens),在該 token 上選擇 **Configure SSO**,並授權該組織

4170* 再次執行 `/install-github-app`4186* 再次執行 `/install-github-app`

4171 4187 

4172在 v2.1.273 之前,Claude Code 在此情況下會改為顯示 `Admin permissions required` 警告。4188在 v2.1.273 之前,Claude Code 會針對此情況顯示 `Admin permissions required` 警告。

4173 4189 

4174### 無法繼續對話4190### Failed to resume the conversation

4175 4191 

4176Claude Code 無法讀取或處理您從 [`claude --resume` 選擇器](https://code.claude.com/docs/zh-TW/sessions#use-the-session-picker)中選取之工作階段的已儲存逐字稿,因此它會結束程序,而不是在部分載入的狀態下繼續。訊息中包含重試用的命令:4192Claude Code 無法讀取或處理您從 [`claude --resume` 選擇器](https://code.claude.com/docs/zh-TW/sessions#use-the-session-picker)中選取之工作階段的已儲存逐字稿,因此它會結束程序,而不會在部分載入的狀態下繼續。訊息中包含重試的命令:

4177 4193 

4178```text theme={null}4194```text theme={null}

4179Failed to resume the conversation.4195Failed to resume the conversation.

4180Run claude --resume <session-id> to retry, or claude to start a new session.4196Run claude --resume <session-id> to retry, or claude to start a new session.

4181```4197```

4182 4198 

4183Claude Code 在顯示訊息後會以代碼 1 結束。在執行中的工作階段內使用 `/resume` 選擇器時,則會在對話中回報 `Failed to resume conversation`,而您目前的工作階段會繼續執行。在 v2.1.216 之前,從 `claude --resume` 選擇器繼續失敗時,會無限期停留在 `Resuming conversation…` 載入動畫上,而不會顯示此訊息。4199Claude Code 在顯示訊息後會以代碼 1 結束。執行中工作階段內的 `/resume` 選擇器則會在對話中回報 `Failed to resume conversation`,且您目前的工作階段會繼續執行。在 v2.1.216 之前,從 `claude --resume` 選擇器恢復失敗時,會無限期停留在 `Resuming conversation…` 載入動畫,而不會顯示此訊息。

4184 4200 

4185**處理方式:**4201**處理方式:**

4186 4202 

4187* 使用訊息中的工作階段 ID 執行 `claude --resume <session-id>` 以重試4203* 使用訊息中的工作階段 ID 執行 `claude --resume <session-id>` 以重試

4188* 在 v2.1.285 之前的版本上,如果重試以相同方式失敗,請執行 `claude update` 後再次繼續。當已儲存的逐字稿包含這些版本無法讀取的項目時,這些版本會讓繼續操作失敗。4204* 在 v2.1.285 之前的版本上,如果重試以相同方式失敗,請執行 `claude update` 後再次恢復。當已儲存的逐字稿包含這些版本無法讀取的項目時,這些版本會讓恢復失敗。

4189* 如果重試再次失敗,請執行 `claude` 以開始新的工作階段4205* 如果重試再次失敗,請執行 `claude` 以啟動新的工作階段

4190 4206 

4191### 找不到具有該工作階段 ID 的對話4207### No conversation found with the session ID

4192 4208 

4193您將工作階段 ID 傳給 `claude --resume <session-id>`,但沒有任何已儲存的逐字稿與之相符:4209您將工作階段 ID 傳給了 `claude --resume <session-id>`,但沒有任何已儲存的逐字稿與之相符:

4194 4210 

4195```text theme={null}4211```text theme={null}

4196No conversation found with session ID: <session-id>4212No conversation found with session ID: <session-id>

4197```4213```

4198 4214 

4199Claude Code 顯示訊息後會以代碼 1 結束。Claude Code 會[先搜尋目前的專案,再搜尋這台機器上的所有其他專案](https://code.claude.com/docs/zh-TW/sessions.md#where-the-session-picker-looks)來尋找該 ID。在 v2.1.223 之前,查找只會涵蓋目前的專案目錄及其 git worktree,因此請從該工作階段最後工作的目錄進行恢復。4215Claude Code 在顯示訊息後會以代碼 1 結束。Claude Code 會[先搜尋目前的專案,再搜尋此電腦上的所有其他專案](https://code.claude.com/docs/zh-TW/sessions.md#where-the-session-picker-looks)來尋找該 ID。在 v2.1.223 之前,查詢只會涵蓋目前的專案目錄及其 git worktree,因此請從該工作階段最後工作的目錄恢復。

4200 4216 

4201常見原因:4217常見原因:

4202 4218 

4203* **ID 輸入錯誤**:對於非互動式執行,ID 是 [`--output-format json` 輸出](https://code.claude.com/docs/zh-TW/headless#get-structured-output)中的 `session_id` 欄位4219* **ID 輸入錯誤**:對於非互動式執行,ID 是 [`--output-format json` 輸出](https://code.claude.com/docs/zh-TW/headless#get-structured-output)中的 `session_id` 欄位

4204* **逐字稿已刪除**:Claude Code 會依照[保留清理規則](https://code.claude.com/docs/zh-TW/claude-directory.md#cleaned-up-automatically),在[保留期限](https://code.claude.com/docs/zh-TW/sessions.md#where-transcripts-are-stored)(預設為 30 天)後移除逐字稿4220* **逐字稿已刪除**:Claude Code 會依照[保留清理規則](https://code.claude.com/docs/zh-TW/claude-directory.md#cleaned-up-automatically),在[保留期間](https://code.claude.com/docs/zh-TW/sessions.md#where-transcripts-are-stored)(預設為 30 天)過後移除逐字稿

4205* **不同的機器**:Claude Code 將逐字稿儲存在本機,因此請在執行該工作階段的機器上繼續4221* **不同的電腦**:Claude Code 將逐字稿儲存在本機,因此請在執行該工作階段的電腦上恢復它

4206* **重複的副本**:如果您複製了 `~/.claude/projects` 下的專案目錄,導致兩份逐字稿帶有相同的 ID,Claude Code 會回報此訊息,而不會任意繼續其中一份副本4222* **重複的副本**:如果您複製了 `~/.claude/projects` 下的專案目錄,使兩份逐字稿帶有相同的 ID,Claude Code 會回報此訊息,而不會任意恢復其中一份

4207 4223 

4208**處理方式:**4224**處理方式:**

4209 4225 

4210* 對於互動式工作階段,請使用 `claude --resume` 開啟[工作階段選擇器](https://code.claude.com/docs/zh-TW/sessions.md#use-the-session-picker),並按 `Ctrl+A` 將範圍擴大到這台機器上的所有專案,然後選取該工作階段4226* 對於互動式工作階段,請使用 `claude --resume` 開啟[工作階段選擇器](https://code.claude.com/docs/zh-TW/sessions.md#use-the-session-picker),並按下 `Ctrl+A` 將範圍擴大到此電腦上的所有專案,然後選取該工作階段

4211* 使用 `claude -p` 或 [Agent SDK](https://code.claude.com/docs/zh-TW/agent-sdk/overview.md) 建立的工作階段不會出現在選擇器中,因此請對照原始執行所輸出的 `session_id` 再次檢查 ID4227* 使用 `claude -p` 或 [Agent SDK](https://code.claude.com/docs/zh-TW/agent-sdk/overview.md) 建立的工作階段不會出現在選擇器中,因此請將 ID 與您原始執行所輸出的 `session_id` 重新比對

4212 4228 

4213### Claude Code 讀取此工作階段的逐字稿檔案時,Windows 回報錯誤(EBADF)4229### Windows reported an error (EBADF) when Claude Code read this session's transcript file

4214 4230 

4215您在 Windows 上繼續一個工作階段,其已儲存的[逐字稿檔案](https://code.claude.com/docs/zh-TW/sessions.md#where-transcripts-are-stored)正常開啟,但接著讀取時發生系統錯誤 EBADF。此系統錯誤並未說明讀取失敗的原因,因此訊息會提出可能的原因以及可以嘗試的做法:4231您在 Windows 上恢復了一個工作階段,其已儲存的[逐字稿檔案](https://code.claude.com/docs/zh-TW/sessions.md#where-transcripts-are-stored)正常開啟,但接著讀取時以系統錯誤 EBADF 失敗。系統錯誤並未說明讀取失敗的原因,因此訊息會建議可能的原因以及可嘗試的做法:

4216 4232 

4217```text theme={null}4233```text theme={null}

4218Windows reported an error (EBADF) when Claude Code read this session's transcript file, although the file had opened normally. This can happen when other software intercepts file reads — security, encryption or endpoint-management tools, for example. If it keeps happening for this conversation, try excluding the folder that holds Claude Code's session transcripts from such software (the .claude folder in your user profile, unless the app or CLAUDE_CONFIG_DIR points Claude Code elsewhere), or adding Claude Code to its allowed applications, then resume again.4234Windows reported an error (EBADF) when Claude Code read this session's transcript file, although the file had opened normally. This can happen when other software intercepts file reads — security, encryption or endpoint-management tools, for example. If it keeps happening for this conversation, try excluding the folder that holds Claude Code's session transcripts from such software (the .claude folder in your user profile, unless the app or CLAUDE_CONFIG_DIR points Claude Code elsewhere), or adding Claude Code to its allowed applications, then resume again.

4219```4235```

4220 4236 

4221此訊息會接在命令本身的失敗行之後,例如 `Failed to resume session <session-id>`。`claude --resume` 或 [`claude -p`](https://code.claude.com/docs/zh-TW/headless) 命令在顯示此訊息後會以代碼 1 結束。在工作階段內使用 `/resume` 後,您目前的工作階段會繼續執行。4237此訊息會接在命令本身的失敗行之後,例如 `Failed to resume session <session-id>`。`claude --resume` 或 [`claude -p`](https://code.claude.com/docs/zh-TW/headless) 命令在顯示訊息後會以代碼 1 結束。在工作階段內使用 `/resume` 後,您目前的工作階段會繼續執行。

4222 4238 

4223**處理方式:**4239**處理方式:**

4224 4240 

4225* 將存放工作階段逐字稿的資料夾從會掃描或攔截檔案讀取的軟體(例如安全性、加密或端點管理工具)中排除。逐字稿預設位於 `%USERPROFILE%\.claude\projects` 下,或位於 [`CLAUDE_CONFIG_DIR`](https://code.claude.com/docs/zh-TW/env-vars) 所指定的目錄下4241* 將存放您工作階段逐字稿的資料夾排除在會掃描或攔截檔案讀取的軟體之外,例如安全性、加密或端點管理工具。逐字稿預設位於 `%USERPROFILE%\.claude\projects` 下,或位於 [`CLAUDE_CONFIG_DIR`](https://code.claude.com/docs/zh-TW/env-vars) 所指定的目錄下

4226* 如果無法新增排除項目,請改為將 Claude Code 加入該軟體的允許應用程式4242* 如果無法新增排除項目,請改為將 Claude Code 加入該軟體的允許應用程式

4227* 再次繼續該工作階段4243* 再次恢復工作階段

4228 4244 

4229在 v2.1.282 之前,此失敗不附帶任何說明:`claude --resume <session-id>` 會停在 `Failed to resume session <session-id>`,而 `-p` 執行只會輸出系統錯誤文字,例如 `Failed to resume session: EBADF: bad file descriptor, read`。4245在 v2.1.282 之前,此失敗不會附帶任何說明:`claude --resume <session-id>` 會在 `Failed to resume session <session-id>` 結束,而 `-p` 執行只會輸出系統錯誤文字,例如 `Failed to resume session: EBADF: bad file descriptor, read`。

4230 4246 

4231### 無法在此工作階段中切換渲染器4247### Cannot switch renderers in this session

4232 4248 

4233切換渲染器時,Claude Code 會重新啟動其程序。您在一個 Claude Code 拒絕重新啟動的工作階段中執行了 [`/tui`](https://code.claude.com/docs/zh-TW/fullscreen#enable-fullscreen-rendering),因此它不會切換,也不會儲存任何內容。您看到的訊息會指出原因:4249切換轉譯器時,Claude Code 會重新啟動其程序。您在 Claude Code 拒絕重新啟動的工作階段中執行了 [`/tui`](https://code.claude.com/docs/zh-TW/fullscreen#enable-fullscreen-rendering),因此它不會切換,也不會儲存任何內容。您看到的訊息會告訴您原因:

4234 4250 

4235* `Cannot switch renderers while work is running in the background`:您有正在背景執行、重新啟動會將其捨棄的工作,例如背景 shell 或 subagent。請等待工作完成,或使用 [`/tasks`](https://code.claude.com/docs/zh-TW/commands) 將其停止,然後再次執行 `/tui fullscreen` 或 `/tui default`4251* `Cannot switch renderers while work is running in the background`:您有正在背景執行、重新啟動會將其中斷的工作,例如背景 shell 或 subagent。請等待工作完成,或使用 [`/tasks`](https://code.claude.com/docs/zh-TW/commands) 停止它,然後再次執行 `/tui fullscreen` 或 `/tui default`

4236* `Cannot switch renderers in this session`:該工作階段有 Claude Code 無法傳遞給重新啟動後程序的限制。在 v2.1.234 之前,Claude Code 仍會重新啟動,而重新啟動後的工作階段會在沒有這些限制的情況下執行4252* `Cannot switch renderers in this session`:工作階段具有 Claude Code 無法傳遞給重新啟動後程序的限制。在 v2.1.234 之前,Claude Code 仍會重新啟動,而重新啟動後的工作階段會在沒有這些限制的情況下執行

4237 4253 

4238在限制訊息中,括號內的部分會指出 Claude Code 找到的限制:4254在限制訊息中,括號內的部分會列出 Claude Code 找到的限制:

4239 4255 

4240```text theme={null}4256```text theme={null}

4241Cannot switch renderers in this session — it has restrictions a restart can't carry over (permission rules set for this session only). Nothing was changed. Running /tui fullscreen in a session started without them switches every later session too.4257Cannot switch renderers in this session — it has restrictions a restart can't carry over (permission rules set for this session only). Nothing was changed. Running /tui fullscreen in a session started without them switches every later session too.

4242```4258```

4243 4259 

4244訊息括號內可能顯示的各項原因:4260訊息括號內可能顯示的各個原因:

4245 4261 

4246* `launch flags: a custom system prompt, a tool allowlist, or restricted settings`:您使用了 Claude Code 不會傳回給重新啟動後程序的旗標來啟動工作階段。這些旗標包括 [`--system-prompt`](https://code.claude.com/docs/zh-TW/cli-reference#cli-flags)、`--system-prompt-file`、`--append-system-prompt-file`、[`--tools`](https://code.claude.com/docs/zh-TW/cli-reference#cli-flags) 允許清單、[`--setting-sources`](https://code.claude.com/docs/zh-TW/cli-reference#cli-flags) 以及 [`--permission-prompt-tool`](https://code.claude.com/docs/zh-TW/cli-reference#cli-flags)4262* `launch flags: a custom system prompt, a tool allowlist, or restricted settings`:您使用了 Claude Code 不會傳回給重新啟動後程序的旗標啟動工作階段。這些旗標包括 [`--system-prompt`](https://code.claude.com/docs/zh-TW/cli-reference#cli-flags)、`--system-prompt-file`、`--append-system-prompt-file`、[`--tools`](https://code.claude.com/docs/zh-TW/cli-reference#cli-flags) 允許清單、[`--setting-sources`](https://code.claude.com/docs/zh-TW/cli-reference#cli-flags),以及 [`--permission-prompt-tool`](https://code.claude.com/docs/zh-TW/cli-reference#cli-flags)

4247* `permission rules set for this session only`:來自 hook 或 SDK 呼叫端的[權限更新](https://code.claude.com/docs/zh-TW/hooks.md#permission-update-entries)以 `session` 目的地新增了拒絕或詢問規則。限於工作階段範圍的允許規則不會觸發拒絕。重新啟動會捨棄這些規則,而 Claude Code 會改為再次提示4263* `permission rules set for this session only`:來自 hook 或 SDK 呼叫端的[權限更新](https://code.claude.com/docs/zh-TW/hooks.md#permission-update-entries)新增了目的地為 `session` 的 deny 或 ask 規則。工作階段範圍的 allow 規則不會觸發拒絕。重新啟動會捨棄這些規則,而 Claude Code 會改為再次提示

4248* `ask-before-running rules with no command-line form`:來自 hook 或 SDK 呼叫端的權限更新,在 Claude Code 以 `--allowed-tools` 和 `--disallowed-tools` 傳回的規則之外新增了詢問規則。詢問規則沒有對應的旗標4264* `ask-before-running rules with no command-line form`:來自 hook 或 SDK 呼叫端的權限更新,在 Claude Code 以 `--allowed-tools` 與 `--disallowed-tools` 傳回的規則之外新增了 ask 規則。ask 規則沒有對應的旗標

4249* `permission rules a command line cannot carry intact` 和 `added directories a command line cannot carry intact`:權限更新在工作階段中途新增了規則或目錄路徑。重新啟動後程序的命令列無法以相同的值攜帶其文字4265* `permission rules a command line cannot carry intact` 與 `added directories a command line cannot carry intact`:權限更新在工作階段中途新增了規則或目錄路徑。重新啟動後程序的命令列無法將其文字以相同的值傳遞

4250 4266 

4251**處理方式:**4267**處理方式:**

4252 4268 

4253* 在未帶有這些限制而啟動的工作階段中,執行 `/tui fullscreen`,或執行 `/tui default` 切換回來。Claude Code 會在該處儲存 [`tui` 設定](https://code.claude.com/docs/zh-TW/settings-reference#tui)4269* 在未套用這些限制而啟動的工作階段中,執行 `/tui fullscreen`,或執行 `/tui default` 以切換回來。Claude Code 會在該處儲存 [`tui` 設定](https://code.claude.com/docs/zh-TW/settings-reference#tui)

4254 4270 

4255### Can't restart while work is running or Remote Control is connected4271### Can't restart while work is running or Remote Control is connected

4256 4272 


4258 4274 

4259### Claude Code couldn't restart4275### Claude Code couldn't restart

4260 4276 

4261當此訊息表示您的對話已儲存時,代表對話已寫入磁碟,您可以從中斷處繼續。Claude Code 當時正在自行重新啟動,例如在您執行 [`/tui`](https://code.claude.com/docs/zh-TW/fullscreen#enable-fullscreen-rendering) 後切換至或切換出全螢幕渲染,但無法啟動新程序,因此以狀態 1 結束:4277當此訊息表示您的對話已儲存時,該對話位於磁碟上,您可以從中斷處繼續。Claude Code 原本正在重新啟動自身,例如在您執行 [`/tui`](https://code.claude.com/docs/zh-TW/fullscreen#enable-fullscreen-rendering) 後切換至或切換出全螢幕轉譯,但無法啟動新的程序,因此以狀態 1 結束:

4262 4278 

4263```text theme={null}4279```text theme={null}

4264Claude Code couldn't restart. Your conversation is saved. Start Claude Code again and run /resume to pick it up.4280Claude Code couldn't restart. Your conversation is saved. Start Claude Code again and run /resume to pick it up.

4265```4281```

4266 4282 

4267當重新啟動時沒有可重新開啟的對話,例如因為 `/tui` 是您在新工作階段中的第一個輸入,訊息內容為 `Claude Code couldn't restart. Start Claude Code again.`4283當重新啟動沒有可重新開啟的對話時,例如因為 `/tui` 是您在新工作階段中的第一個輸入,訊息內容為 `Claude Code couldn't restart. Start Claude Code again.`

4268 4284 

4269**處理方式:**4285**處理方式:**

4270 4286 

4271* 在您的 shell 中再次執行 `claude`。如果訊息表示您的對話已儲存,請在新工作階段中執行 [`/resume`](https://code.claude.com/docs/zh-TW/sessions#resume-a-session) 並選取該對話。如果對話不在清單中,請[擴大工作階段選擇器的範圍](https://code.claude.com/docs/zh-TW/sessions.md#where-the-session-picker-looks)4287* 在您的 shell 中再次執行 `claude`。如果訊息表示您的對話已儲存,請在新的工作階段中執行 [`/resume`](https://code.claude.com/docs/zh-TW/sessions#resume-a-session) 並選取該對話。如果它不在清單中,請[擴大工作階段選擇器的範圍](https://code.claude.com/docs/zh-TW/sessions.md#where-the-session-picker-looks)

4272* 若重新啟動持續失敗,請在 shell 中使用 [`claude --debug-file claude-debug.log`](https://code.claude.com/docs/zh-TW/cli-reference#cli-flags) 啟動 Claude Code。若從該工作階段重新啟動失敗,您啟動所在目錄中的 `claude-debug.log` 會記錄一行包含作業系統錯誤的 `Failed to relaunch:`。在您[回報問題](#report-an-error)時請附上該行4288* 如果重新啟動持續失敗,請從您的 shell 以 [`claude --debug-file claude-debug.log`](https://code.claude.com/docs/zh-TW/cli-reference#cli-flags) 啟動 Claude Code。如果從該工作階段重新啟動失敗,您啟動時所在目錄中的 `claude-debug.log` 會記錄一行 `Failed to relaunch:`,其中包含作業系統的錯誤。在您[回報問題](#report-an-error)時請附上該行

4273 4289 

4274### 無法開啟 Claude Desktop4290### Couldn't open Claude Desktop

4275 4291 

4276您在工作階段中執行了 [`/desktop`](https://code.claude.com/docs/zh-TW/desktop#coming-from-the-cli) 或其別名 `/app`,或在 shell 中執行了 [`claude --desktop`](https://code.claude.com/docs/zh-TW/cli-reference#cli-flags),而 Claude Code 用來開啟 Claude Desktop 的系統命令失敗了。執行 `/desktop` 後,工作階段會留在終端機中;`claude --desktop` 會輸出不含 `Error:` 前綴的訊息,並以狀態 1 結束。4292您在工作階段中執行了 [`/desktop`](https://code.claude.com/docs/zh-TW/desktop#coming-from-the-cli) 或其別名 `/app`,或在您的 shell 中執行了 [`claude --desktop`](https://code.claude.com/docs/zh-TW/cli-reference#cli-flags),而 Claude Code 用來開啟 Claude Desktop 的系統命令失敗了。執行 `/desktop` 後,工作階段會留在終端機中;`claude --desktop` 則會輸出不含 `Error:` 前綴的訊息,並以狀態 1 結束。

4277 4293 

4278括號內的文字會指出失敗的命令,以及其結束狀態和錯誤輸出的第一行(若有產生)。在 macOS 上該命令為 `open`,如此範例所示;在 Windows 上則為 `rundll32`:4294括號內的文字會列出失敗的命令,以及其產生的結束狀態與錯誤輸出的第一行(若有)。在 macOS 上,該命令為 `open`,如本範例所示;在 Windows 上則為 `rundll32`:

4279 4295 

4280```text theme={null}4296```text theme={null}

4281Error: Couldn't open Claude Desktop (`open` exited 1: LSOpenURLsWithRole() failed for the URL claude://resume?session=<session-id> with error -10814). Open Claude Desktop and try again.4297Error: Couldn't open Claude Desktop (`open` exited 1: LSOpenURLsWithRole() failed for the URL claude://resume?session=<session-id> with error -10814). Open Claude Desktop and try again.


4284**處理方式:**4300**處理方式:**

4285 4301 

4286* 自行開啟 Claude Desktop,然後再次執行 `/desktop` 或 `claude --desktop`4302* 自行開啟 Claude Desktop,然後再次執行 `/desktop` 或 `claude --desktop`

4287* 若要閱讀失敗命令的完整錯誤輸出,請使用 `/debug` 開啟偵錯日誌並再次執行 `/desktop`,或執行 `claude --desktop --debug-file <path>`,然後查看偵錯日誌4303* 若要閱讀失敗命令的完整錯誤輸出,請使用 `/debug` 開啟除錯日誌並再次執行 `/desktop`,或執行 `claude --desktop --debug-file <path>`,然後查看除錯日誌

4288 4304 

4289在 v2.1.285 之前,訊息的結尾為 `Open Claude Desktop and run /desktop again.`。在 v2.1.275 之前,訊息為 `Failed to open Claude Desktop. Please try opening it manually.`,且未說明失敗的內容。4305在 v2.1.285 之前,訊息以 `Open Claude Desktop and run /desktop again.` 結尾。在 v2.1.275 之前,訊息為 `Failed to open Claude Desktop. Please try opening it manually.`,且未說明失敗的內容。

4290 4306 

4291### /terminal-setup 未變更您的 Zed 按鍵對應4307### /terminal-setup left your Zed keymap unchanged

4292 4308 

4293您在 Zed 中執行了 [`/terminal-setup`](https://code.claude.com/docs/zh-TW/terminal-config#enter-multiline-prompts),而 Claude Code 無法完成對您 Zed `keymap.json` 的更新,因此維持該檔案原狀。4309您在 Zed 中執行了 [`/terminal-setup`](https://code.claude.com/docs/zh-TW/terminal-config#enter-multiline-prompts),而 Claude Code 無法完成對您 Zed `keymap.json` 的更新,因此保留了該檔案原狀。

4294 4310 

4295每則訊息都會指出您按鍵對應檔的路徑,並在結尾附上供您自行新增的快捷鍵區塊:4311每則訊息都會列出您 keymap 的路徑,並以您需自行新增的快捷鍵區塊作為結尾:

4296 4312 

4297```text theme={null}4313```text theme={null}

4298Couldn't update your Zed keymap, so it was left unchanged.4314Couldn't update your Zed keymap, so it was left unchanged.


4300{ "context": "Terminal", "bindings": { "shift-enter": ["terminal::SendText", "\u001b\r"] } }4316{ "context": "Terminal", "bindings": { "shift-enter": ["terminal::SendText", "\u001b\r"] } }

4301```4317```

4302 4318 

4303訊息的第一行會指出原因:4319訊息的第一行會列出原因:

4304 4320 

4305* `Couldn't read your Zed keymap, so it was left unchanged.`:Claude Code 無法讀取該檔案,例如因為檔案權限4321* `Couldn't read your Zed keymap, so it was left unchanged.`:Claude Code 無法讀取該檔案,例如因為檔案權限

4306* `Your Zed keymap isn't a readable list of keybindings, so it was left unchanged.`:檔案可以正常讀取,但即使允許 `//` 註解和結尾逗號,仍無法解析為快捷鍵區塊的陣列4322* `Your Zed keymap isn't a readable list of keybindings, so it was left unchanged.`:檔案可以正常讀取,但即使允許 `//` 註解與結尾逗號,仍無法剖析為快捷鍵區塊的陣列

4307* `Couldn't back up your Zed keymap; not modifying it.`:Claude Code 無法將檔案複製為其旁邊的 `.bak` 備份,因此未做任何變更4323* `Couldn't back up your Zed keymap; not modifying it.`:Claude Code 無法將檔案複製為其旁邊的 `.bak` 備份,因此沒有做任何變更

4308* `Couldn't update your Zed keymap, so it was left unchanged.`:合併後的結果無法驗證為帶有該快捷鍵的有效按鍵對應,因此 Claude Code 將其捨棄而未寫入。帶有重複鍵的快捷鍵區塊可能導致此情況4324* `Couldn't update your Zed keymap, so it was left unchanged.`:合併後的結果未能驗證為帶有該快捷鍵的有效 keymap,因此 Claude Code 將其捨棄而不寫入。含有重複鍵的快捷鍵區塊可能會造成此情況

4309 4325 

4310**處理方式:**4326**處理方式:**

4311 4327 

4312* 將訊息中的區塊複製到訊息所指路徑上 `keymap.json` 的頂層陣列中4328* 將訊息中的區塊複製到訊息所列路徑之 `keymap.json` 中的最上層陣列

4313* 對於 `isn't a readable list of keybindings`,請修正語法錯誤,或讓檔案的頂層值成為陣列,然後再次執行 `/terminal-setup`4329* 對於 `isn't a readable list of keybindings`,請修正語法錯誤,或將檔案的最上層值改為陣列,然後再次執行 `/terminal-setup`

4314 4330 

4315在 v2.1.247 之前,`/terminal-setup` 無法解析使用 `//` 註解或結尾逗號的 Zed 按鍵對應,並會以僅包含其自身快捷鍵的內容取代整個檔案,同時回報快捷鍵已安裝。若要還原被較早版本取代的按鍵對應,請使用[輸入多行提示詞](https://code.claude.com/docs/zh-TW/terminal-config.md#enter-multiline-prompts)中所述的 `.bak` 備份檔案。4331在 v2.1.247 之前,`/terminal-setup` 無法剖析使用 `//` 註解或結尾逗號的 Zed keymap,並會以僅包含其自身快捷鍵的內容取代整個檔案,同時回報快捷鍵已安裝。若要還原先前版本所取代的 keymap,請使用 [Enter multiline prompts](https://code.claude.com/docs/zh-TW/terminal-config.md#enter-multiline-prompts) 中所述的 `.bak` 備份檔案。

4316 4332 

4317### 此連線無法使用 skill 使用情況報告4333### Skill usage reports are not available on this connection

4318 4334 

4319您透過 [Remote Control](https://code.claude.com/docs/zh-TW/remote-control.md),從手機或瀏覽器執行了 [`/skill-doctor`](https://code.claude.com/docs/zh-TW/skills#find-unused-skills)。Claude Code 不會透過 Remote Control 傳送 skill 使用情況報告,而是改為回覆此訊息:4335您透過 [Remote Control](https://code.claude.com/docs/zh-TW/remote-control.md) 從手機或瀏覽器執行了 [`/skill-doctor`](https://code.claude.com/docs/zh-TW/skills#find-unused-skills)。Claude Code 不會透過 Remote Control 傳送 skill 使用報告,而會以此訊息回覆:

4320 4336 

4321```text theme={null}4337```text theme={null}

4322Skill usage reports are not available on this connection.4338Skill usage reports are not available on this connection.


4324 4340 

4325**處理方式:**4341**處理方式:**

4326 4342 

4327* 在執行該工作階段之機器的終端機中執行 `/skill-doctor`,或在該處執行 `claude -p "/skill-doctor"`4343* 在執行工作階段之電腦的終端機中執行 `/skill-doctor`,或在該處執行 `claude -p "/skill-doctor"`

4328 4344 

4329### 無法透過 Remote Control 選擇自訂輸出風格4345### Custom output styles can't be selected over Remote Control

4330 4346 

4331您透過 [Remote Control](https://code.claude.com/docs/zh-TW/remote-control.md) 從行動應用程式或網頁執行了 [`/output-style`](https://code.claude.com/docs/zh-TW/output-styles#change-your-output-style),或者該命令是在轉送至工作階段的訊息中送達。由於這樣的回合可能並非來自帳戶擁有者,Claude Code 在其中只會列出並選擇[內建風格](https://code.claude.com/docs/zh-TW/output-styles.md#built-in-output-styles),並在命令列出風格或無法辨識您提供的名稱時加上此通知。[自訂風格](https://code.claude.com/docs/zh-TW/output-styles.md#create-a-custom-output-style)名稱會得到與不存在之名稱相同的回覆:4347您透過 [Remote Control](https://code.claude.com/docs/zh-TW/remote-control.md) 從行動應用程式或網頁執行了 [`/output-style`](https://code.claude.com/docs/zh-TW/output-styles#change-your-output-style),或該命令是在轉送到工作階段的訊息中送達的。由於這樣的回合可能並非來自帳戶擁有者,Claude Code 在其中只會列出與選取[內建風格](https://code.claude.com/docs/zh-TW/output-styles.md#built-in-output-styles),並在命令列出風格或無法辨識您提供的名稱時加上此通知。[自訂風格](https://code.claude.com/docs/zh-TW/output-styles.md#create-a-custom-output-style)名稱會得到與不存在之名稱相同的回覆:

4332 4348 

4333```text theme={null}4349```text theme={null}

4334Custom output styles can't be selected over Remote Control or from a relayed message. Select one in the session itself, or pick a built-in style here.4350Custom output styles can't be selected over Remote Control or from a relayed message. Select one in the session itself, or pick a built-in style here.


4337**處理方式:**4353**處理方式:**

4338 4354 

4339* 選擇內建風格,例如 `/output-style concise`4355* 選擇內建風格,例如 `/output-style concise`

4340* 若要使用自訂風格,請在專案的 `.claude/settings.local.json` 中設定 [`outputStyle`](https://code.claude.com/docs/zh-TW/settings-reference#outputstyle),或在工作階段本身的終端機(若有)執行 `/output-style <style>`4356* 若要使用自訂風格,請在專案的 `.claude/settings.local.json` 中設定 [`outputStyle`](https://code.claude.com/docs/zh-TW/settings-reference#outputstyle),或在工作階段本身的終端機(若有)中執行 `/output-style <style>`

4341 4357 

4342### 輸出風格會儲存到此工作階段不會載入的本機設定4358### Output styles are saved to local settings which this session doesn't load

4343 4359 

4344您在設定來源排除 `local` 的工作階段中,嘗試以 `/output-style <style>` 或 `/config outputStyle=<style>` 切換[輸出風格](https://code.claude.com/docs/zh-TW/output-styles.md)。例如 [`settingSources`](https://code.claude.com/docs/zh-TW/agent-sdk/typescript#options) 未包含 `"local"` 的 [Agent SDK](https://code.claude.com/docs/zh-TW/agent-sdk/typescript.md) 工作階段,以及以未包含 `local` 的 [`--setting-sources`](https://code.claude.com/docs/zh-TW/cli-reference#cli-flags) 值啟動的 CLI 工作階段。這兩個命令都會將風格儲存到 `.claude/settings.local.json`,而這類工作階段永遠不會讀回該檔案,因此 Claude Code 會拒絕,而不是寫入一個不會生效的設定:4360您在設定來源排除 `local` 的工作階段中,嘗試以 `/output-style <style>` 或 `/config outputStyle=<style>` 切換[輸出風格](https://code.claude.com/docs/zh-TW/output-styles.md)。例如 [`settingSources`](https://code.claude.com/docs/zh-TW/agent-sdk/typescript#options) 省略了 `"local"` 的 [Agent SDK](https://code.claude.com/docs/zh-TW/agent-sdk/typescript.md) 工作階段,以及使用省略了 `local` 的 [`--setting-sources`](https://code.claude.com/docs/zh-TW/cli-reference#cli-flags) 值啟動的 CLI 工作階段。這兩個命令都會將風格儲存到 `.claude/settings.local.json`,而這類工作階段永遠不會讀回該檔案,因此 Claude Code 會拒絕,而不會寫入不會產生效果的設定:

4345 4361 

4346```text theme={null}4362```text theme={null}

4347Output styles are saved to local settings (.claude/settings.local.json), which this session doesn't load, so the style can't be changed here.4363Output styles are saved to local settings (.claude/settings.local.json), which this session doesn't load, so the style can't be changed here.


4352* 將 `local` 加入工作階段的設定來源,然後再次切換4368* 將 `local` 加入工作階段的設定來源,然後再次切換

4353* 在工作階段會載入的設定檔中設定 [`outputStyle`](https://code.claude.com/docs/zh-TW/settings-reference#outputstyle) 鍵,例如專案中的 `.claude/settings.json` 或 `~/.claude/settings.json`。在 TypeScript SDK 中,請改為在內嵌的 `settings` 物件中設定 `outputStyle`;請參閱[啟用輸出風格](https://code.claude.com/docs/zh-TW/agent-sdk/modifying-system-prompts.md#activate-an-output-style)4369* 在工作階段會載入的設定檔中設定 [`outputStyle`](https://code.claude.com/docs/zh-TW/settings-reference#outputstyle) 鍵,例如專案中的 `.claude/settings.json` 或 `~/.claude/settings.json`。在 TypeScript SDK 中,請改為在內嵌的 `settings` 物件中設定 `outputStyle`;請參閱[啟用輸出風格](https://code.claude.com/docs/zh-TW/agent-sdk/modifying-system-prompts.md#activate-an-output-style)

4354 4370 

4355### /recap 只在您親自要求時執行4371### /recap only runs when you ask for it yourself

4356 4372 

4357[`/recap`](https://code.claude.com/docs/zh-TW/interactive-mode#session-recap) 請求並非來自您自己的輸入。它出現在從 Slack、Teams 或[專案](https://code.claude.com/docs/zh-TW/claude-projects.md)討論串轉傳至工作階段的訊息中,或出現在[雲端排程任務](https://code.claude.com/docs/zh-TW/routines.md)或其他程式傳送的提示詞中。4373[`/recap`](https://code.claude.com/docs/zh-TW/interactive-mode#session-recap) 請求並非來自您自己的輸入。它是在從 Slack、Teams 或[專案](https://code.claude.com/docs/zh-TW/claude-projects.md)討論串轉送到工作階段的訊息中送達的,或是在[雲端排程任務](https://code.claude.com/docs/zh-TW/routines.md)或其他程式所傳送的提示詞中送達的。

4358 4374 

4359即使轉送的訊息是您自己撰寫的,也會收到此通知。Claude Code 無法判斷轉送或自動化的訊息是否來自執行該工作階段之帳戶的本人,因此會以此通知回覆,而不是提供摘要:4375即使轉送的訊息是您自己撰寫的,也會收到此通知。Claude Code 無法判斷轉送或自動化的訊息是否來自執行該工作階段之帳戶的本人,因此會以此通知回應,而不是提供摘要:

4360 4376 

4361```text theme={null}4377```text theme={null}

4362/recap only runs when you ask for it yourself in this session: from the terminal, the Claude app or claude.ai/code, or over Remote Control. A message relayed from Slack, Teams or a project thread, or sent by a routine or another program, can't request it.4378/recap only runs when you ask for it yourself in this session: from the terminal, the Claude app or claude.ai/code, or over Remote Control. A message relayed from Slack, Teams or a project thread, or sent by a routine or another program, can't request it.

4363```4379```

4364 4380 

4365您傳給 `claude -p` 的 `/recap`,或您自己的 [Agent SDK](https://code.claude.com/docs/zh-TW/agent-sdk/overview.md) 應用程式傳送給其所啟動之工作階段的 `/recap`,都算是您自己的輸入。4381您傳給 `claude -p` 的 `/recap`,或您自己的 [Agent SDK](https://code.claude.com/docs/zh-TW/agent-sdk/overview.md) 應用程式傳送給其所啟動之工作階段的 `/recap`,都視為您自己的輸入。

4366 4382 

4367**處理方式:**4383**處理方式:**

4368 4384 

4369* 親自開啟該工作階段並在其中執行 `/recap`:在其終端機中、在 [Desktop 應用程式](https://code.claude.com/docs/zh-TW/desktop.md)或[行動應用程式](https://code.claude.com/docs/zh-TW/mobile.md)中、在 [claude.ai/code](https://claude.ai/code),或透過 [Remote Control](https://code.claude.com/docs/zh-TW/remote-control.md)4385* 自行開啟工作階段並在其中執行 `/recap`:在其終端機中、在 [Desktop 應用程式](https://code.claude.com/docs/zh-TW/desktop.md)或[行動應用程式](https://code.claude.com/docs/zh-TW/mobile.md)中、在 [claude.ai/code](https://claude.ai/code),或透過 [Remote Control](https://code.claude.com/docs/zh-TW/remote-control.md)

4370* 如果是雲端排程任務或其他程式傳送的,請從該提示詞中移除 `/recap`4386* 如果是雲端排程任務或其他程式傳送的,請從該提示詞中移除 `/recap`

4371 4387 

4372### /feedback is disabled by your organization's policy4388### /feedback is disabled by your organization's policy

4373 4389 

4374此訊息表示產品意見回饋已關閉,因此您輸入的命令不會開啟意見回饋對話框。組織的政策與先前的拒絕都會產生此訊息:4390此訊息表示產品意見回饋已關閉,因此您輸入的命令不會開啟意見回饋對話框。組織的政策與先前的拒絕都會產生此訊息:

4375 4391 

4376* **組織政策**:您組織的政策不允許從 Claude Code 提交產品意見回饋。`/feedback`、`/bug` 與 `/share` 都會以此訊息回應。4392* **組織政策**:您組織的政策不允許從 Claude Code 提供產品意見回饋。`/feedback`、`/bug` 與 `/share` 都會以此訊息回應。

4377* **先前的拒絕**:意見回饋服務拒絕了您傳送的報告,例如顯示 [`Couldn't send feedback: Feedback has not been enabled for your organization.`](#couldnt-send-feedback)。之後 `/feedback` 與 `/bug` 可能會以此訊息回應。此狀態在這台機器上會從該次拒絕起持續七天。這適用於所有方案,包括 Pro 與 Max。4393* **先前的拒絕**:意見回饋服務拒絕了您傳送的報告,例如以 [`Couldn't send feedback: Feedback has not been enabled for your organization.`](#couldnt-send-feedback) 拒絕。此後 `/feedback` 與 `/bug` 可能會以此訊息回應。在此電腦上,該狀態會從該次拒絕起持續七天。這適用於所有方案,包括 Pro 與 Max。

4378 4394 

4379訊息會列出您在 Claude Code 提示字元輸入的命令:4395訊息會列出您在 Claude Code 提示字元輸入的命令:

4380 4396 


4386 4402 

4387**處理方式:**4403**處理方式:**

4388 4404 

4389* 若要回報錯誤,請在 [github.com/anthropics/claude-code/issues](https://github.com/anthropics/claude-code/issues) 建立 issue。任何人都可以閱讀該處的 issue,因此請勿包含程式碼、逐字稿及任何其他機密內容。4405* 若要回報錯誤,請在 [github.com/anthropics/claude-code/issues](https://github.com/anthropics/claude-code/issues) 開啟 issue。任何人都可以閱讀該處的 issue,因此請勿包含程式碼、逐字稿以及任何其他機密內容。

4390* 在先前遭到拒絕後,請等待七天過去,然後再次傳送報告,以確認服務是否仍會拒絕4406* 在先前的拒絕之後,請等待七天過去,然後再次傳送報告,以確認服務是否仍會拒絕

4391 4407 

4392在 v2.1.319 之前,先前的拒絕不會產生此訊息。4408在 v2.1.319 之前,先前的拒絕不會產生此訊息。

4393 4409 

4394在 v2.1.302 之前,完整訊息為 `/feedback is disabled by your organization's policy. Contact your organization admin to enable it.`4410在 v2.1.302 之前,完整訊息內容為 `/feedback is disabled by your organization's policy. Contact your organization admin to enable it.`

4395 4411 

4396## Plugin 錯誤4412## Plugin 錯誤

4397 4413 


4948* **對於 Claude 撰寫的命令**:您無需修正任何內容。訊息會告知 Claude 如何改寫該命令。4964* **對於 Claude 撰寫的命令**:您無需修正任何內容。訊息會告知 Claude 如何改寫該命令。

4949* **對於 skill 或命令檔案**:訊息會接在 `No shell command in <name> was run` 之後。請參閱 [在何處找到該字元並將其移除](#no-shell-command-was-run)。4965* **對於 skill 或命令檔案**:訊息會接在 `No shell command in <name> was run` 之後。請參閱 [在何處找到該字元並將其移除](#no-shell-command-was-run)。

4950 4966 

4951### Command approved before Claude Code restarted was not run4967### Approved command was not run after Claude Code restarted

4952 4968 

4953您核准的 shell 命令未執行,Claude 會收到此訊息作為該命令的結果:4969您核准的 shell 命令未執行,Claude 會收到此訊息作為該命令的結果:

4954 4970 

4955```text wrap theme={null}4971```text wrap theme={null}

4956This call was not run. The command was approved before Claude Code restarted, and Claude Code could not confirm that the shell is back in the directory where it was approved. That directory may be gone or replaced, lie outside the directory where the session started, or be one that Claude Code needs approval to enter or is not allowed to examine. The shell's directory is <directory>. If the command still makes sense, cd to the directory it was meant for and make the call again; it may need approval again.4972This call was not run. Claude Code could not confirm that the shell is back in the directory where it was approved. That directory may be gone or replaced, lie outside the directory where the session started, or be one that Claude Code needs approval to enter or is not allowed to examine. The shell's directory is <directory>. If the command still makes sense, cd to the directory it was meant for and make the call again; it may need approval again.

4957```4973```

4958 4974 

4959訊息的第三句也可能改為 `It does not keep track of that directory across a restart in a session that has been in a worktree.`4975訊息的第三句也可能改為 `It does not keep track of that directory across a restart in a session that has been in a worktree.`


5556 5572 

5557### Worktree 有未推送到任何地方的提交5573### Worktree 有未推送到任何地方的提交

5558 5574 

5559您嘗試刪除[背景工作階段](https://code.claude.com/docs/zh-TW/agent-view.md#what-deleting-a-session-removes),其 worktree 包含 Claude Code 無法確認已在其他地方儲存的提交。Claude Code 保留 worktree 和工作階段列,而不是在您未察覺的情況下銷毀提交。`claude rm` 命名分支和未推送的提交,並說明如何進行:5575您嘗試刪除[背景工作階段](https://code.claude.com/docs/zh-TW/agent-view.md#what-deleting-a-session-removes),其 worktree 包含 Claude Code 無法確認已在其他地方儲存的提交。`claude rm` 會說明如何進行:

5560 5576 

5561```text theme={null}5577```text theme={null}

5562kept 7c5dcf5d — its worktree is still at “/home/you/project/.claude/worktrees/fix-login”5578kept 7c5dcf5d — its worktree is still at “/home/you/project/.claude/worktrees/fix-login”


5566 5582 

5567當 Claude Code 無法總結提交時,詳細行改為顯示 `The worktree has unpushed commits`。在 [agent 檢視](https://code.claude.com/docs/zh-TW/agent-view.md)中,工作階段的列顯示 `not removed`,原因相同。5583當 Claude Code 無法總結提交時,詳細行改為顯示 `The worktree has unpushed commits`。在 [agent 檢視](https://code.claude.com/docs/zh-TW/agent-view.md)中,工作階段的列顯示 `not removed`,原因相同。

5568 5584 

5569遠端上的提交不會阻止刪除。您的 `origin` 遠端預設分支的本機副本上的提交也不會,只要該分支在您的主簽出(即儲存庫目錄本身而不是 worktree)中簽出。

5570 

5571**該怎麼做:**5585**該怎麼做:**

5572 5586 

5573* 要保留提交,推送 worktree 的分支,或將其合併到在主簽出中簽出的預設分支,然後再次刪除工作階段5587* 要保留提交,請推送它們。一旦推送將它們放到遠端追蹤分支(例如 `origin/claude/fix-login`)上,請再次嘗試刪除工作階段。

5574* 要捨棄提交,執行訊息列印的 `claude rm <id> --discard-unpushed` 命令,或在 agent 檢視中的工作階段列上再次按 `Ctrl+X` 兩次。這會移除工作階段和 worktree 以及其分支、未推送的提交和任何未提交的變更。如果刪除再次被拒絕,請依照新的訊息操作。5588* 如果訊息提供捨棄提交的選項,請先確認您不需要該 worktree、這些提交或任何未提交的變更。然後執行訊息提供的步驟:在 agent 檢視中的工作階段列上按 `Ctrl+X` 兩次,或執行 `claude rm` 列印的 `claude rm <id> --discard-unpushed <commit>@<worktree-id>` 命令。如果 Claude Code 再次拒絕,請依照新的訊息操作。

5575* 當訊息說 worktree 也由另一個已完成的工作階段記錄時,再次刪除不會捨棄它:推送提交,然後再次刪除工作階段5589* 當訊息說 worktree 也由另一個已完成的工作階段記錄時,再次刪除不會捨棄它:推送提交,然後再次嘗試刪除工作階段

5576 5590 

5577在 v2.1.268 之前,`claude rm` 將提交摘要放在 `kept` 行本身上。當 `claude rm` 無法總結提交時,`kept` 行會以 `worktree has commits that are not pushed anywhere` 代替摘要。5591在 v2.1.268 之前,`claude rm` 將提交摘要放在 `kept` 行本身上。當 `claude rm` 無法總結提交時,`kept` 行會以 `worktree has commits that are not pushed anywhere` 代替摘要。

5578 5592 

5579在 v2.1.260 之前,訊息未命名分支或提交,也沒有捨棄的途徑。您仍然可以刪除工作階段,這會遺失未提交的變更,但會保留分支和提交。使用拒絕訊息列印的路徑執行 `git worktree remove --force --force <path>`,然後執行 `claude rm <id>`。對於已鎖定的 worktree,Git 需要兩次 `--force`。5593在 v2.1.260 之前,訊息未命名分支或提交,也沒有捨棄的途徑。您仍然可以刪除工作階段,這會遺失未提交的變更,但會保留分支和提交。使用拒絕訊息列印的路徑執行 `git worktree remove --force --force <path>`,然後執行 `claude rm <id>`。對於已鎖定的 worktree,Git 需要兩次 `--force`。

5580 5594 

5581在 v2.1.248 之前,在主簽出中簽出的預設分支不計算在內:您已經合併到那裡的分支仍然會觸發此拒絕,直到其提交到達遠端。

5582 

5583### Terminal host process died5595### Terminal host process died

5584 5596 

5585每個[背景工作階段的](https://code.claude.com/docs/zh-TW/agent-view.md)終端機在背景服務下的主機程序中執行,該程序在服務仍保持其連線時死亡,因此無法連線到工作階段。5597每個[背景工作階段的](https://code.claude.com/docs/zh-TW/agent-view.md)終端機在背景服務下的主機程序中執行,該程序在服務仍保持其連線時死亡,因此無法連線到工作階段。


6194該行其餘部分會說明工作階段所依循的政策:6206該行其餘部分會說明工作階段所依循的政策:

6195 6207 

6196* **有先前成功擷取時快取的設定**:Claude Code 會以該快取政策執行工作階段([保留的環境變數](https://code.claude.com/docs/zh-TW/server-managed-settings.md#fetch-and-caching-behavior)除外),該行顯示 `using cached policy`。6208* **有先前成功擷取時快取的設定**:Claude Code 會以該快取政策執行工作階段([保留的環境變數](https://code.claude.com/docs/zh-TW/server-managed-settings.md#fetch-and-caching-behavior)除外),該行顯示 `using cached policy`。

6197* **沒有快取**:Claude Code 會在沒有伺服器管理設定的情況下執行工作階段,該行顯示 `no remote policy applied`。6209* **沒有可套用的快取設定**:Claude Code 會在沒有伺服器管理設定的情況下執行工作階段,該行顯示 `no remote policy applied`。例如,此機器尚未擷取過設定,或上次擷取已超過 [24 小時](https://code.claude.com/docs/zh-TW/server-managed-settings.md#fetch-and-caching-behavior)。

6198 6210 

6199在 Code 分頁中,當您傳送訊息時,警告會以對話中的一行出現,而當擷取的狀態改變時,會出現新的一行。三則相關訊息也會以相同方式出現:6211在 Code 分頁中,當您傳送訊息時,警告會以對話中的一行出現,而當擷取的狀態改變時,會出現新的一行。三則相關訊息也會以相同方式出現:

6200 6212 

fast-mode.md +1 −1

Details

183如果 Agent Platform 拒絕快速模式,Claude Code 會回退到標準速度。互動式工作階段接著會顯示下列其中一則終端機訊息:183如果 Agent Platform 拒絕快速模式,Claude Code 會回退到標準速度。互動式工作階段接著會顯示下列其中一則終端機訊息:

184 184 

185* `Using standard speed on Fable 5.2 · fast mode wasn't available`:執行 `/fast on` 以再次嘗試快速模式185* `Using standard speed on Fable 5.2 · fast mode wasn't available`:執行 `/fast on` 以再次嘗試快速模式

186* `Fast mode was refused for this project · trying again in 30m`:Agent Platform 以 403 或 404 錯誤回應了快速模式請求。若要更早嘗試,請執行 `/fast on`。186* `Fast mode paused: your cloud provider refused a fast request · trying again in 30m`:Agent Platform 以 403 或 404 錯誤回應了快速模式請求。若要更早嘗試,請執行 `/fast on`。需要 Claude Code v2.1.323 或更新版本。

187 187 

188### 在代理和 LLM 閘道後面使用快速模式188### 在代理和 LLM 閘道後面使用快速模式

189 189 

Details

4 4 

5# 功能可用性5# 功能可用性

6 6 

7> 比較 Claude Code 功能在 Anthropic 訂閱計畫、Anthropic Console、Amazon Bedrock、AWS 上的 Claude Platform、Google Cloud 的 Agent Platform 和 Microsoft Foundry 中的可用性。7> 比較哪些 Claude Code 功能可在各 Anthropic 訂閱計畫、Anthropic Console,以及 Amazon Bedrock 和 Google Cloud 等雲端提供者上使用。

8 8 

9Claude Code CLI 和所有在本地執行的功能在每個提供者上的運作方式完全相同。如需每個提供者的設定說明,請參閱[企業部署概述](https://code.claude.com/docs/zh-TW/third-party-integrations.md)。若要直接跳到您的提供者上缺少的功能,請參閱[按提供者摘要](#summary-by-provider)標籤。9Claude Code CLI 和所有在本地執行的功能在每個提供者上的運作方式完全相同。如需每個提供者的設定說明,請參閱[企業部署概述](https://code.claude.com/docs/zh-TW/third-party-integrations.md)。若要直接跳到您的提供者上缺少的功能,請參閱[按提供者摘要](#summary-by-provider)標籤。

10 10 


18* **Anthropic Console**:您使用 Anthropic API 金鑰進行身分驗證,或[在沒有 API 金鑰的情況下登入 Console 帳戶](https://code.claude.com/docs/zh-TW/authentication.md#sign-in-without-an-api-key)18* **Anthropic Console**:您使用 Anthropic API 金鑰進行身分驗證,或[在沒有 API 金鑰的情況下登入 Console 帳戶](https://code.claude.com/docs/zh-TW/authentication.md#sign-in-without-an-api-key)

19* **Amazon Bedrock**:您使用 Amazon Bedrock 模型目錄中的 Claude 模型,並設定 `CLAUDE_CODE_USE_BEDROCK`。[Mantle 端點](https://code.claude.com/docs/zh-TW/amazon-bedrock.md#use-the-mantle-endpoint)(`CLAUDE_CODE_USE_MANTLE`)也包含在此欄位中19* **Amazon Bedrock**:您使用 Amazon Bedrock 模型目錄中的 Claude 模型,並設定 `CLAUDE_CODE_USE_BEDROCK`。[Mantle 端點](https://code.claude.com/docs/zh-TW/amazon-bedrock.md#use-the-mantle-endpoint)(`CLAUDE_CODE_USE_MANTLE`)也包含在此欄位中

20* **Claude Platform on AWS**:您透過 AWS Marketplace 購買 Claude,但呼叫 Anthropic API,並設定 `CLAUDE_CODE_USE_ANTHROPIC_AWS`20* **Claude Platform on AWS**:您透過 AWS Marketplace 購買 Claude,但呼叫 Anthropic API,並設定 `CLAUDE_CODE_USE_ANTHROPIC_AWS`

21* **Google Cloud's Agent Platform**:由 Google 營運;您設定 `CLAUDE_CODE_USE_VERTEX`21* **Google Cloud (Anthropic managed)**:您使用 [Claude Models on Google Cloud (Anthropic managed)](https://code.claude.com/docs/zh-TW/claude-models-on-google-cloud-anthropic-managed.md),並設定 `CLAUDE_CODE_USE_ANTHROPIC_GOOGLE_CLOUD`。您透過自己的 Google Cloud 專案存取由 Anthropic 營運的 Claude API。若要區分這兩種 Google Cloud 方案,請參閱[您使用的是哪一種方案?](https://platform.claude.com/docs/en/build-with-claude/claude-models-on-google-cloud/overview#which-offering-are-you-using)

22* **Google Cloud (Google managed)**:由 Google 營運,屬於 Google Cloud's Agent Platform(前身為 Vertex AI)的一部分;您設定 `CLAUDE_CODE_USE_VERTEX` 並使用 Claude Models on Google Cloud (Google managed)

22* **Microsoft Foundry**:由 Anthropic 營運;您設定 `CLAUDE_CODE_USE_FOUNDRY`23* **Microsoft Foundry**:由 Anthropic 營運;您設定 `CLAUDE_CODE_USE_FOUNDRY`

23 24 

24### 所有供應商皆可使用的功能25### 所有供應商皆可使用的功能


34 35 

35以下功能在不同供應商之間有所差異:36以下功能在不同供應商之間有所差異:

36 37 

37* **MCP 伺服器**:只有當您的 claude.ai 訂閱是目前使用中的身分驗證方式時,才會載入[來自 claude.ai 的連接器](https://code.claude.com/docs/zh-TW/mcp.md#use-mcp-servers-from-claude-ai)。Microsoft Foundry [託管於 Azure 的部署](https://platform.claude.com/docs/en/build-with-claude/claude-in-microsoft-foundry#hosting-options)不支援[工具搜尋](https://code.claude.com/docs/zh-TW/mcp.md#configure-tool-search)。在 Google Cloud's Agent Platform 上,早於 Claude Opus 4.5、Claude Sonnet 4.5 與 Claude Haiku 4.5 的模型不支援工具搜尋38* **MCP 伺服器**:只有當您的 claude.ai 訂閱是目前使用中的身分驗證方式時,才會載入[來自 claude.ai 的連接器](https://code.claude.com/docs/zh-TW/mcp.md#use-mcp-servers-from-claude-ai)。Microsoft Foundry [託管於 Azure 的部署](https://platform.claude.com/docs/en/build-with-claude/claude-in-microsoft-foundry#hosting-options)不支援[工具搜尋](https://code.claude.com/docs/zh-TW/mcp.md#configure-tool-search)。在 Google Cloud (Google managed) 上,早於 Claude Opus 4.5、Claude Sonnet 4.5 與 Claude Haiku 4.5 的模型不支援工具搜尋

38* **Subagent**:當主要對話執行 Fable 時,若使用 Claude 訂閱、Anthropic Console 帳戶,或透過 `ANTHROPIC_BASE_URL` 連線的 [LLM 閘道](https://code.claude.com/docs/zh-TW/llm-gateway),內建的 [Explore subagent](https://code.claude.com/docs/zh-TW/sub-agents.md#built-in-subagents) 會在 Opus 上執行。在其他供應商上(包括 Claude Platform on AWS),它會在 Fable 上執行39* **Subagents**:當父對話執行 Fable 時,若使用 Claude 訂閱、Anthropic Console 帳戶,或透過 `ANTHROPIC_BASE_URL` 連線的 [LLM 閘道](https://code.claude.com/docs/zh-TW/llm-gateway),內建的 [Explore subagent](https://code.claude.com/docs/zh-TW/sub-agents.md#built-in-subagents) 會在 Opus 上執行。在其他供應商(包括 Claude Platform on AWS)上,它會在 Fable 上執行

39* **[命令](https://code.claude.com/docs/zh-TW/commands.md#all-commands)**:40* **[命令](https://code.claude.com/docs/zh-TW/commands.md#all-commands)**:

40 * `/design-sync` 與 `/import`(及其 `claude import` 子命令形式)在 Amazon Bedrock、Google Cloud's Agent Platform、Microsoft Foundry 與 Claude Platform on AWS 上無法使用,透過 [Claude apps 閘道](https://code.claude.com/docs/zh-TW/claude-apps-gateway#availability-and-limitations)也無法使用41 * `/design-sync` 與 `/import`(及其 `claude import` 子命令形式)在雲端供應商上無法使用,透過 [Claude apps 閘道](https://code.claude.com/docs/zh-TW/claude-apps-gateway#availability-and-limitations)也無法使用

41 * `/voice` 需要 claude.ai 帳戶42 * `/voice` 需要 claude.ai 帳戶

42 * `/list-agents` 及其別名 `/peers` 僅在[已啟用跨工作階段訊息傳遞](https://code.claude.com/docs/zh-TW/cross-session-messaging.md#availability)的工作階段中可用43 * `/list-agents` 及其別名 `/peers` 僅在[已啟用跨工作階段訊息傳遞](https://code.claude.com/docs/zh-TW/cross-session-messaging.md#availability)的工作階段中可用

43 44 


71 <th>Anthropic Console</th>72 <th>Anthropic Console</th>

72 <th>Amazon Bedrock</th>73 <th>Amazon Bedrock</th>

73 <th>Claude Platform on AWS</th>74 <th>Claude Platform on AWS</th>

74 <th>Google Cloud's Agent Platform</th>75 <th>Google Cloud (Anthropic managed)</th>

76 <th>Google Cloud (Google managed)</th>

75 <th>Microsoft Foundry</th>77 <th>Microsoft Foundry</th>

76 </tr>78 </tr>

77 </thead>79 </thead>


83 <td>✓</td>85 <td>✓</td>

84 <td>✗</td>86 <td>✗</td>

85 <td>✓</td>87 <td>✓</td>

88 <td>✓</td>

86 <td>請參閱附註 <sup>[1](#fn1)</sup></td>89 <td>請參閱附註 <sup>[1](#fn1)</sup></td>

87 <td>✓</td>90 <td>✓</td>

88 </tr>91 </tr>


93 <td>✓(Opus 5 與 4.8 需要佈建)</td>96 <td>✓(Opus 5 與 4.8 需要佈建)</td>

94 <td>✗</td>97 <td>✗</td>

95 <td>✗</td>98 <td>✗</td>

99 <td>✗</td>

96 <td>✓([Fable 5.2,有條件限制](https://code.claude.com/docs/zh-TW/fast-mode.md#use-fast-mode-on-agent-platform))</td>100 <td>✓([Fable 5.2,有條件限制](https://code.claude.com/docs/zh-TW/fast-mode.md#use-fast-mode-on-agent-platform))</td>

97 <td>✗</td>101 <td>✗</td>

98 </tr>102 </tr>


103 <td>✓</td>107 <td>✓</td>

104 <td>請參閱附註 <sup>[2](#fn2)</sup></td>108 <td>請參閱附註 <sup>[2](#fn2)</sup></td>

105 <td>✓</td>109 <td>✓</td>

110 <td>✓</td>

106 <td>請參閱附註 <sup>[2](#fn2)</sup></td>111 <td>請參閱附註 <sup>[2](#fn2)</sup></td>

107 <td>請參閱附註 <sup>[2](#fn2)</sup></td>112 <td>請參閱附註 <sup>[2](#fn2)</sup></td>

108 </tr>113 </tr>


113 <td>✓</td>118 <td>✓</td>

114 <td>✗</td>119 <td>✗</td>

115 <td>✓(Claude Code v2.1.300 或更新版本)</td>120 <td>✓(Claude Code v2.1.300 或更新版本)</td>

121 <td>✓(Claude Code v2.1.300 或更新版本)</td>

116 <td>✗</td>122 <td>✗</td>

117 <td>✗</td>123 <td>✗</td>

118 </tr>124 </tr>


125 <td>✗</td>131 <td>✗</td>

126 <td>✗</td>132 <td>✗</td>

127 <td>✗</td>133 <td>✗</td>

134 <td>✗</td>

128 </tr>135 </tr>

129 136 

130 <tr>137 <tr>


135 <td>✓(同一台機器)<sup>[5](#fn5)</sup></td>142 <td>✓(同一台機器)<sup>[5](#fn5)</sup></td>

136 <td>✓(同一台機器)<sup>[5](#fn5)</sup></td>143 <td>✓(同一台機器)<sup>[5](#fn5)</sup></td>

137 <td>✓(同一台機器)<sup>[5](#fn5)</sup></td>144 <td>✓(同一台機器)<sup>[5](#fn5)</sup></td>

145 <td>✓(同一台機器)<sup>[5](#fn5)</sup></td>

138 </tr>146 </tr>

139 147 

140 <tr>148 <tr>


145 <td>✗</td>153 <td>✗</td>

146 <td>✗</td>154 <td>✗</td>

147 <td>✗</td>155 <td>✗</td>

156 <td>✗</td>

148 </tr>157 </tr>

149 158 

150 <tr>159 <tr>


153 <td>✓</td>162 <td>✓</td>

154 <td>✓</td>163 <td>✓</td>

155 <td>✗</td>164 <td>✗</td>

165 <td>✗</td>

156 <td>✓</td>166 <td>✓</td>

157 <td>✓</td>167 <td>✓</td>

158 </tr>168 </tr>


164 <td>✓</td>174 <td>✓</td>

165 <td>✓</td>175 <td>✓</td>

166 <td>✓</td>176 <td>✓</td>

177 <td>✓</td>

167 <td>✗</td>178 <td>✗</td>

168 </tr>179 </tr>

169 </tbody>180 </tbody>


181 <th>Anthropic Console</th>192 <th>Anthropic Console</th>

182 <th>Amazon Bedrock</th>193 <th>Amazon Bedrock</th>

183 <th>Claude Platform on AWS</th>194 <th>Claude Platform on AWS</th>

184 <th>Google Cloud's Agent Platform</th>195 <th>Google Cloud (Anthropic managed)</th>

196 <th>Google Cloud (Google managed)</th>

185 <th>Microsoft Foundry</th>197 <th>Microsoft Foundry</th>

186 </tr>198 </tr>

187 </thead>199 </thead>


195 <td>✗</td>207 <td>✗</td>

196 <td>✗</td>208 <td>✗</td>

197 <td>✗</td>209 <td>✗</td>

210 <td>✗</td>

198 </tr>211 </tr>

199 212 

200 <tr>213 <tr>


205 <td>✗</td>218 <td>✗</td>

206 <td>✗</td>219 <td>✗</td>

207 <td>✗</td>220 <td>✗</td>

221 <td>✗</td>

208 </tr>222 </tr>

209 223 

210 <tr>224 <tr>


213 <td>✓(符合資格的帳戶)</td>227 <td>✓(符合資格的帳戶)</td>

214 <td>請參閱附註 <sup>[3](#fn3)</sup></td>228 <td>請參閱附註 <sup>[3](#fn3)</sup></td>

215 <td>✓(符合資格的帳戶)</td>229 <td>✓(符合資格的帳戶)</td>

230 <td>✓(需申請)</td>

216 <td>請參閱附註 <sup>[3](#fn3)</sup></td>231 <td>請參閱附註 <sup>[3](#fn3)</sup></td>

217 <td>請參閱附註 <sup>[3](#fn3)</sup></td>232 <td>請參閱附註 <sup>[3](#fn3)</sup></td>

218 </tr>233 </tr>

219 </tbody>234 </tbody>

220</table>235</table>

221 236 

222<sup>1</sup> 在 Google Cloud's Agent Platform 上,網頁搜尋適用於 Opus 4、Sonnet 4、Haiku 4.5 及更新的模型。\237<sup>1</sup> 在 Google Cloud (Google managed) 上,網頁搜尋適用於 Opus 4、Sonnet 4、Haiku 4.5 及更新的模型。\

223 238 

224<sup>2</sup> 在這些供應商上,自動模式僅支援 Claude Sonnet 5 或更新版本、Opus 4.7 或更新版本、Haiku 5.5 以及 Fable 模型。請參閱[自動模式設定](https://code.claude.com/docs/zh-TW/auto-mode-config.md)。如需這些供應商上的工作階段以哪種權限模式啟動,請參閱[工作階段以哪種模式啟動](https://code.claude.com/docs/zh-TW/permission-modes.md#which-mode-a-session-starts-in)。\239<sup>2</sup> 在這些供應商上,自動模式僅支援 Claude Sonnet 5 或更新版本、Opus 4.7 或更新版本、Haiku 5.5 以及 Fable 模型。請參閱[自動模式設定](https://code.claude.com/docs/zh-TW/auto-mode-config.md)。如需這些供應商上的工作階段以哪種權限模式啟動,請參閱[工作階段以哪種模式啟動](https://code.claude.com/docs/zh-TW/permission-modes.md#which-mode-a-session-starts-in)。\

225 240 


227 242 

228<sup>4</sup> 僅限儀表板與 API。[貢獻指標](https://code.claude.com/docs/zh-TW/analytics.md#enable-contribution-metrics)需要 claude.ai Team 或 Enterprise 組織。\243<sup>4</sup> 僅限儀表板與 API。[貢獻指標](https://code.claude.com/docs/zh-TW/analytics.md#enable-contribution-metrics)需要 claude.ai Team 或 Enterprise 組織。\

229 244 

230<sup>5</sup> 在 macOS 與 Linux(包括 WSL 2 中的 Linux)上需要 Claude Code v2.1.224 或更新版本。在原生 Windows 上,需要 Claude Code v2.1.234 或更新版本。使用 API 金鑰身分驗證時,訊息傳遞僅限同一台機器。在 Amazon Bedrock、Claude Platform on AWS、Google Cloud's Agent Platform 與 Microsoft Foundry 上,訊息傳遞僅限同一台機器,且需要 Claude Code v2.1.248 或更新版本。Claude 只能從已連線至 [Remote Control](https://code.claude.com/docs/zh-TW/remote-control.md) 的工作階段中找到您的[雲端工作階段](https://code.claude.com/docs/zh-TW/claude-code-on-the-web.md)以及您在其他機器上的工作階段。若要連線,您需要 claude.ai 登入,並符合其他 [Remote Control 需求](https://code.claude.com/docs/zh-TW/remote-control.md#requirements)。請參閱[傳送訊息至其他機器上的工作階段](https://code.claude.com/docs/zh-TW/cross-session-messaging.md#message-sessions-on-other-machines)。245<sup>5</sup> 在 macOS 與 Linux(包括 WSL 2 中的 Linux)上需要 Claude Code v2.1.224 或更新版本。在原生 Windows 上,需要 Claude Code v2.1.234 或更新版本。使用 API 金鑰身分驗證時,訊息傳遞僅限同一台機器。在 Amazon Bedrock、Claude Platform on AWS、Google Cloud (Anthropic managed)、Google Cloud (Google managed) 與 Microsoft Foundry 上,訊息傳遞僅限同一台機器,且需要 Claude Code v2.1.248 或更新版本。Claude 只能從已連線至 [Remote Control](https://code.claude.com/docs/zh-TW/remote-control.md) 的工作階段中找到您的[雲端工作階段](https://code.claude.com/docs/zh-TW/claude-code-on-the-web.md)以及您在其他機器上的工作階段。若要連線,您需要 claude.ai 登入,並符合其他 [Remote Control 需求](https://code.claude.com/docs/zh-TW/remote-control.md#requirements)。請參閱[傳送訊息至其他機器上的工作階段](https://code.claude.com/docs/zh-TW/cross-session-messaging.md#message-sessions-on-other-machines)。

231 246 

232> [!NOTE]247> [!NOTE]

233>248>


237 252 

238### 依供應商摘要253### 依供應商摘要

239 254 

240每個分頁列出該供應商上無法使用或僅部分支援的功能,並在有替代方案時一併列出。除了上述的[供應商特定差異](#features-available-on-every-provider)之外,未列出的功能皆與 Claude 訂閱上的運作方式相同。在 Amazon Bedrock、Google Cloud's Agent Platform、Microsoft Foundry 與 Claude Platform on AWS 上,傳送至 Anthropic 的錯誤回報與遙測預設為關閉。請參閱[依 API 供應商區分的預設行為](https://code.claude.com/docs/zh-TW/data-usage.md#default-behaviors-by-api-provider),了解哪些流量仍會傳送至 Anthropic 以及如何選擇退出。255每個分頁列出該供應商上無法使用或僅部分支援的功能,並在有替代方案時一併列出。另請參閱[供應商特定差異](#features-available-on-every-provider)。在 Amazon Bedrock、Google Cloud (Google managed)、Microsoft Foundry 與 Claude Platform on AWS 上,傳送至 Anthropic 的錯誤回報與遙測預設為關閉。請參閱[依 API 供應商區分的預設行為](https://code.claude.com/docs/zh-TW/data-usage.md#default-behaviors-by-api-provider),了解哪些流量仍會傳送至 Anthropic 以及如何選擇退出。

241 256 

242> [tab] Amazon Bedrock257> [tab] Amazon Bedrock

243>258>


264>279>

265> \*\*替代方案:\*\*排程方面,請使用 [`/loop`](https://code.claude.com/docs/zh-TW/scheduled-tasks) 取代 `/schedule`。雲端工作階段方面,請使用 [GitLab CI/CD](https://code.claude.com/docs/zh-TW/gitlab-ci-cd.md)。280> \*\*替代方案:\*\*排程方面,請使用 [`/loop`](https://code.claude.com/docs/zh-TW/scheduled-tasks) 取代 `/schedule`。雲端工作階段方面,請使用 [GitLab CI/CD](https://code.claude.com/docs/zh-TW/gitlab-ci-cd.md)。

266 281 

267> [tab] Google Cloud's Agent Platform282> [tab] Google Cloud (Anthropic managed)

283>

284> \*\*無法使用:\*\*所有[需要 Claude 訂閱的功能](#features-that-require-a-claude-subscription),以及[快速模式](https://code.claude.com/docs/zh-TW/fast-mode.md)、[頻道](https://code.claude.com/docs/zh-TW/channels.md)、[GitHub Actions](https://code.claude.com/docs/zh-TW/github-actions.md)、[Code Mode](https://code.claude.com/docs/zh-TW/code-mode.md)、[分析儀表板](https://code.claude.com/docs/zh-TW/analytics.md)、[伺服器受管設定](https://code.claude.com/docs/zh-TW/server-managed-settings.md),以及 [`/design-sync` 與 `/import` 命令](https://code.claude.com/docs/zh-TW/commands#all-commands)。

285>

286> \*\*Google Cloud (Google managed) 不支援但此處可用:\*\*Claude Code v2.1.300 或更新版本中的 [Advisor](https://code.claude.com/docs/zh-TW/advisor.md)。

287>

288> **部分支援:**

289>

290> * [跨工作階段訊息傳遞](https://code.claude.com/docs/zh-TW/cross-session-messaging.md):僅限此機器上您的工作階段之間 <sup>[5](#fn5)</sup>

291> * [零資料保留](https://platform.claude.com/docs/en/build-with-claude/claude-models-on-google-cloud/anthropic-managed#data-retention):可依申請提供。請聯絡您的 Anthropic 客戶代表

292>

293> \*\*替代方案:\*\*排程方面,請使用 [`/loop`](https://code.claude.com/docs/zh-TW/scheduled-tasks) 取代 `/schedule`。

294 

295> [tab] Google Cloud (Google managed)

296>

297> 若您設定 `CLAUDE_CODE_USE_VERTEX` 以搭配 Google Cloud's Agent Platform 使用 Claude Code,您使用的就是此供應商。

268>298>

269> \*\*無法使用:\*\*所有[需要 Claude 訂閱的功能](#features-that-require-a-claude-subscription),以及 [Advisor](https://code.claude.com/docs/zh-TW/advisor.md)、[頻道](https://code.claude.com/docs/zh-TW/channels.md)、[Code Mode](https://code.claude.com/docs/zh-TW/code-mode.md)、[分析儀表板](https://code.claude.com/docs/zh-TW/analytics.md)、[伺服器受管設定](https://code.claude.com/docs/zh-TW/server-managed-settings.md),以及 [`/design-sync` 與 `/import` 命令](https://code.claude.com/docs/zh-TW/commands#all-commands)。299> \*\*無法使用:\*\*所有[需要 Claude 訂閱的功能](#features-that-require-a-claude-subscription),以及 [Advisor](https://code.claude.com/docs/zh-TW/advisor.md)、[頻道](https://code.claude.com/docs/zh-TW/channels.md)、[Code Mode](https://code.claude.com/docs/zh-TW/code-mode.md)、[分析儀表板](https://code.claude.com/docs/zh-TW/analytics.md)、[伺服器受管設定](https://code.claude.com/docs/zh-TW/server-managed-settings.md),以及 [`/design-sync` 與 `/import` 命令](https://code.claude.com/docs/zh-TW/commands#all-commands)。

270>300>


304 334 

305## 按訂閱計畫的可用性335## 按訂閱計畫的可用性

306 336 

307如果您透過 Amazon Bedrock、Google Cloud 的 Agent Platform、Microsoft Foundry 或 Anthropic Console API 金鑰進行驗證,本節不適用於您。當您使用 claude.ai 帳戶登入時,您的計畫決定了下列功能中哪些可用。337如果您透過雲端供應商或 Anthropic Console API 金鑰進行驗證,本節不適用於您。當您使用 claude.ai 帳戶登入時,您的計畫決定了下列功能中哪些可用。

308 338 

309在已套用 [HIPAA 設定](https://code.claude.com/docs/zh-TW/hipaa-setup.md)的 Enterprise 組織中,此表格中的部分功能會被關閉。339在已套用 [HIPAA 設定](https://code.claude.com/docs/zh-TW/hipaa-setup.md)的 Enterprise 組織中,此表格中的部分功能會被關閉。

310 340 


345## 相關資源375## 相關資源

346 376 

347* [企業部署概述](https://code.claude.com/docs/zh-TW/third-party-integrations.md):比較提供者之間的驗證、計費和地區377* [企業部署概述](https://code.claude.com/docs/zh-TW/third-party-integrations.md):比較提供者之間的驗證、計費和地區

348* 提供者設定指南:[Amazon Bedrock](https://code.claude.com/docs/zh-TW/amazon-bedrock.md)、[AWS 上的 Claude Platform](https://code.claude.com/docs/zh-TW/claude-platform-on-aws.md)、[Google Cloud 的 Agent Platform](https://code.claude.com/docs/zh-TW/google-vertex-ai.md)、[Microsoft Foundry](https://code.claude.com/docs/zh-TW/microsoft-foundry.md)378* 提供者設定指南:[Amazon Bedrock](https://code.claude.com/docs/zh-TW/amazon-bedrock.md)、[AWS 上的 Claude Platform](https://code.claude.com/docs/zh-TW/claude-platform-on-aws.md)、[Google Cloud 上的 Claude 模型(由 Anthropic 管理)](https://code.claude.com/docs/zh-TW/claude-models-on-google-cloud-anthropic-managed.md)、[Google Cloud 的 Agent Platform](https://code.claude.com/docs/zh-TW/google-vertex-ai.md)、[Microsoft Foundry](https://code.claude.com/docs/zh-TW/microsoft-foundry.md)

349* [平台和整合](https://code.claude.com/docs/zh-TW/platforms.md):Claude Code 執行的位置,包括 CLI、Desktop、IDE 擴充功能、網頁、行動和 CI/CD379* [平台和整合](https://code.claude.com/docs/zh-TW/platforms.md):Claude Code 執行的位置,包括 CLI、Desktop、IDE 擴充功能、網頁、行動和 CI/CD

Details

188>188>

189> **將防護措施放在 hook 中。** 在 CLAUDE.md 或 skill 中寫下「絕不編輯 `.env`」這類指令只是請求,而非保證。封鎖該編輯的 `PreToolUse` hook 才是強制執行。如果某條規則每次都必須成立,請將其設為 hook,而不是提示詞指令。189> **將防護措施放在 hook 中。** 在 CLAUDE.md 或 skill 中寫下「絕不編輯 `.env`」這類指令只是請求,而非保證。封鎖該編輯的 `PreToolUse` hook 才是強制執行。如果某條規則每次都必須成立,請將其設為 hook,而不是提示詞指令。

190>190>

191> **Hook 輸出會進入上下文。** 執行 linter 的 `PostToolUse` hook 會將結果以文字形式回饋給 Claude 閱讀;`/fix-lint` skill 則告訴 Claude 如何解決這些問題。191> **將 hook 與 skill 搭配使用。** 使用 `PostToolUse` hook 執行您的 linter,並[將錯誤傳送給 Claude](https://code.claude.com/docs/zh-TW/hooks.md#exit-code-2-behavior-per-event)。若要提供 Claude 您自己的錯誤修正規則,請撰寫 `/fix-lint` 之類的 skill。

192 192 

193### 了解功能如何分層193### 了解功能如何分層

194 194 

glossary.md +1 −1

Details

283 283 

284### 沙箱機制284### 沙箱機制

285 285 

286Bash 工具的 OS 層級檔案系統和網路隔離。命令在您預先定義的邊界內執行,因此 Claude 可以在其中自由工作,無需針對每個命令顯示核准提示。沙箱機制是與[權限規則](#permission-rule)分開的一層。286Bash 工具的 OS 層級檔案系統和網路隔離。命令在您預先定義的邊界內執行。沙箱機制是與[權限規則](#permission-rule)分開的一層。

287 287 

288了解更多:[沙箱機制](https://code.claude.com/docs/zh-TW/sandboxing.md)288了解更多:[沙箱機制](https://code.claude.com/docs/zh-TW/sandboxing.md)

289 289 

Details

11View plans11View plans

12Contact sales12Contact sales

13 13 

14> [!NOTE]

15>

16> 本頁說明透過您的 Google Cloud 專案使用 Claude 的兩種方式之一:Google Cloud 的 Agent Platform(前身為 Vertex AI),由 Google 管理。如果您使用的是 Claude Models on Google Cloud(由 Anthropic 管理),請改為依照[其 Claude Code 設定頁面](https://code.claude.com/docs/zh-TW/claude-models-on-google-cloud-anthropic-managed.md)進行。若要確認您使用的是哪一種,請參閱[您使用的是哪一種方案?](https://platform.claude.com/docs/en/build-with-claude/claude-models-on-google-cloud/overview#which-offering-are-you-using)

17 

14## 先決條件18## 先決條件

15 19 

16在使用 Google Cloud 的 Agent Platform(前身為 Vertex AI)設定 Claude Code 之前,請確保您具有:20在使用 Google Cloud 的 Agent Platform(前身為 Vertex AI)設定 Claude Code 之前,請確保您具有:

headless.md +13 −3

Details

81執行會等待背景工作,例如背景命令、subagent 和工作流程、Monitor 監視,以及待處理的 `/loop` 喚醒:81執行會等待背景工作,例如背景命令、subagent 和工作流程、Monitor 監視,以及待處理的 `/loop` 喚醒:

82 82 

83* **[背景命令](https://code.claude.com/docs/zh-TW/tools-reference.md#background-commands)**:對於主對話啟動的命令,例如開發伺服器或監視建置,執行會等待直到該命令退出或達到其 [時間限制](https://code.claude.com/docs/zh-TW/tools-reference.md#time-limit-for-background-commands)。接著 Claude 會依據結果再進行一個回合。在命令執行期間,10 分鐘上限不會結束等待。83* **[背景命令](https://code.claude.com/docs/zh-TW/tools-reference.md#background-commands)**:對於主對話啟動的命令,例如開發伺服器或監視建置,執行會等待直到該命令退出或達到其 [時間限制](https://code.claude.com/docs/zh-TW/tools-reference.md#time-limit-for-background-commands)。接著 Claude 會依據結果再進行一個回合。在命令執行期間,10 分鐘上限不會結束等待。

84* **背景 [subagent](https://code.claude.com/docs/zh-TW/sub-agents.md) 和工作流程**:執行會保持開啟,直到該工作完成,因為其結果是最終輸出的一部分。84* **背景 [subagent](https://code.claude.com/docs/zh-TW/sub-agents.md) 和工作流程**:執行會保持開啟,直到每一項都完成,或 10 分鐘上限結束等待為止。

85* **[Monitor](https://code.claude.com/docs/zh-TW/tools-reference.md#monitor-tool) 監視**:執行會等待直到監視逾時或 10 分鐘上限結束等待,以先發生者為準。在等待期間,Claude 會持續回應監視報告的內容。預設情況下,監視在 Claude 啟動後五分鐘逾時。85* **[Monitor](https://code.claude.com/docs/zh-TW/tools-reference.md#monitor-tool) 監視**:執行會等待直到監視逾時或 10 分鐘上限結束等待,以先發生者為準。在等待期間,Claude 會持續回應監視報告的內容。預設情況下,監視在 Claude 啟動後五分鐘逾時。

86* **待處理的喚醒**:在以文字傳遞提示詞(而非使用 `--input-format stream-json`)的執行中,當 Claude 已排定 [自訂節奏的 `/loop` 喚醒](https://code.claude.com/docs/zh-TW/scheduled-tasks#let-claude-choose-the-interval) 時,執行會等待每次喚醒觸發並執行其迭代,直到 [迴圈結束](https://code.claude.com/docs/zh-TW/scheduled-tasks.md#stop-a-loop),即使超過 10 分鐘上限也是如此。86* **待處理的喚醒**:在以文字傳遞提示詞(而非使用 `--input-format stream-json`)的執行中,當 Claude 已排定 [自訂節奏的 `/loop` 喚醒](https://code.claude.com/docs/zh-TW/scheduled-tasks#let-claude-choose-the-interval) 時,執行會等待每次喚醒觸發並執行其迭代,直到 [迴圈結束](https://code.claude.com/docs/zh-TW/scheduled-tasks.md#stop-a-loop),即使超過 10 分鐘上限也是如此。

87 87 


91 91 

92當背景工作啟動另一個回合時,使用預設的 `text` 輸出時,執行會列印每個回合的結果;使用 `json` 輸出時,則列印最後一個回合的結果。在 v2.1.295 之前,使用 `text` 輸出時,執行也只會列印最後一個回合的結果。92當背景工作啟動另一個回合時,使用預設的 `text` 輸出時,執行會列印每個回合的結果;使用 `json` 輸出時,則列印最後一個回合的結果。在 v2.1.295 之前,使用 `text` 輸出時,執行也只會列印最後一個回合的結果。

93 93 

94#### 給予長時間執行的 subagent 命令更多時間

95 

96當 subagent 的長時間命令在逾時時 [移至背景](https://code.claude.com/docs/zh-TW/tools-reference.md#foreground-commands-that-move-to-the-background),`claude -p` 執行可能會在該命令完成之前就以代碼 0 退出。

97 

98若要將預設逾時提高到超過該命令的執行時間,請設定 [`BASH_DEFAULT_TIMEOUT_MS`](https://code.claude.com/docs/zh-TW/env-vars),例如使用 `BASH_DEFAULT_TIMEOUT_MS=300000 claude -p "<prompt>"` 設為五分鐘。對於執行超過 10 分鐘的背景 subagent 命令,也請提高 [10 分鐘上限](#background-tasks-at-exit)。

99 

94#### 非互動式執行結束時的 MCP 工作100#### 非互動式執行結束時的 MCP 工作

95 101 

96`claude -p` 執行不會等待在背景中進行的 MCP 工作:102`claude -p` 執行不會等待在背景中進行的 MCP 工作:


333 339 

334### 在無人值守的執行中關閉權限提示340### 在無人值守的執行中關閉權限提示

335 341 

336當沒有人能回應權限提示時,例如在排程工作中,請傳入 `--permission-prompts none`。當您的執行具有權限主機時,此旗標最為重要:具有 [`canUseTool` 回呼](https://code.claude.com/docs/zh-TW/agent-sdk/user-input)的 Agent SDK 應用程式,或您透過 [`--permission-prompt-tool`](https://code.claude.com/docs/zh-TW/cli-reference#cli-flags) 傳入的 MCP 工具。若未使用此旗標,您的執行會等待該主機回應每個權限請求。342當沒有人能回應權限提示時,例如在排程工作中,請傳入 `--permission-prompts none`。當您的執行具有權限主機時,此旗標最為重要:具有 [`canUseTool` 回呼](https://code.claude.com/docs/zh-TW/agent-sdk/user-input)的 Agent SDK 應用程式,或您透過 [`--permission-prompt-tool`](https://code.claude.com/docs/zh-TW/cli-reference#cli-flags) 傳入的 MCP 工具。若未使用此旗標或 [`permissions.denyInsteadOfPrompting`](https://code.claude.com/docs/zh-TW/settings-reference#permissions-denyinsteadofprompting) 設定,您的執行會等待該主機回應每個權限請求。

337 343 

338使用此旗標時,您的執行不會諮詢主機,也不會等待它。任何會觸發提示的動作都會被拒絕,除非有 `PermissionRequest` hook 允許;Claude 會被告知沒有人能核准該請求且不應重試,而執行會繼續進行。在沒有主機的 `-p` 執行中,這些請求無論如何都會被拒絕,而此旗標還會告知 Claude 不要重試。權限規則、[`PermissionRequest` hook](https://code.claude.com/docs/zh-TW/hooks#permissionrequest) 以及您設定的權限模式仍會優先決定每個呼叫;Claude Code 只會拒絕其他機制都無法處理的請求。344使用此旗標時,您的執行不會諮詢主機,也不會等待它。任何會觸發提示的動作都會被拒絕,除非有 `PermissionRequest` hook 允許;Claude 會被告知沒有人能核准該請求且不應重試,而執行會繼續進行。在沒有主機的 `-p` 執行中,這些請求無論如何都會被拒絕,而此旗標還會告知 Claude 不要重試。權限規則、[`PermissionRequest` hook](https://code.claude.com/docs/zh-TW/hooks#permissionrequest) 以及您設定的權限模式仍會優先決定每個呼叫;Claude Code 只會拒絕其他機制都無法處理的請求。

339 345 

346> [!NOTE]

347>

348> `--permission-prompts none` 旗標僅在單次執行中有效。若要在之後的執行中也拒絕會等待權限提示的呼叫,請在您的使用者設定或受管設定中將 [`permissions.denyInsteadOfPrompting`](https://code.claude.com/docs/zh-TW/settings-reference#permissions-denyinsteadofprompting) 設為 `true`。

349 

340此範例以[自動模式](https://code.claude.com/docs/zh-TW/permission-modes.md#eliminate-prompts-with-auto-mode)執行無人值守的任務。分類器會照常審查每個動作,而 Claude Code 會拒絕任何原本會退回提示的動作:350此範例以[自動模式](https://code.claude.com/docs/zh-TW/permission-modes.md#eliminate-prompts-with-auto-mode)執行無人值守的任務。分類器會照常審查每個動作,而 Claude Code 會拒絕任何原本會退回提示的動作:

341 351 

342```bash theme={null}352```bash theme={null}


369> * 使用者呼叫的 [skill](https://code.claude.com/docs/zh-TW/skills.md) 及自訂命令可以運作。在提示詞字串中加入 `/skill-name`,Claude Code 會在執行前將其展開。379> * 使用者呼叫的 [skill](https://code.claude.com/docs/zh-TW/skills.md) 及自訂命令可以運作。在提示詞字串中加入 `/skill-name`,Claude Code 會在執行前將其展開。

370> * 僅在終端機介面中執行的內建命令(例如 `/login`)無法使用。380> * 僅在終端機介面中執行的內建命令(例如 `/login`)無法使用。

371> * `/model`、`/effort`、`/fast`、`/color` 及 `/rename` 接受以引數形式傳入值,例如 `/model sonnet`;不帶引數的 `/mcp` 會輸出伺服器狀態的文字摘要。這些形式遵循各命令的[可用性說明](https://code.claude.com/docs/zh-TW/commands.md#all-commands)。381> * `/model`、`/effort`、`/fast`、`/color` 及 `/rename` 接受以引數形式傳入值,例如 `/model sonnet`;不帶引數的 `/mcp` 會輸出伺服器狀態的文字摘要。這些形式遵循各命令的[可用性說明](https://code.claude.com/docs/zh-TW/commands.md#all-commands)。

372> * 若要變更設定,請將 `key=value` 傳給 `/config`,例如 `/config thinking=false`。382> * 若要變更設定,請將 `key=value` 傳給 `/config`,例如 `/config verbose=true`。

373> * `/output-style <style>` 會切換[輸出風格](https://code.claude.com/docs/zh-TW/output-styles.md),單獨使用 `/output-style` 則會列出所有風格。需要 Claude Code v2.1.269 或更新版本。383> * `/output-style <style>` 會切換[輸出風格](https://code.claude.com/docs/zh-TW/output-styles.md),單獨使用 `/output-style` 則會列出所有風格。需要 Claude Code v2.1.269 或更新版本。

374 384 

375### 自訂系統提示詞385### 自訂系統提示詞

hooks.md +10 −13

Details

66 66 

67### Hook 如何解析67### Hook 如何解析

68 68 

69為了了解事件、匹配器和處理程式如何組合在一起,請考慮此 `PreToolUse` hook,它會阻止破壞性 shell 命令。69為了了解事件、matcher 和處理程式如何組合在一起,請考慮此 `PreToolUse` hook,它會阻止 `rm -rf` 命令。

70 70 

71> [tab] macOS/Linux71> [tab] macOS/Linux

72>72>


440| `Bash(rm *)` | `echo $(date)` | 否 | 沒有子命令符合 `rm *` |440| `Bash(rm *)` | `echo $(date)` | 否 | 沒有子命令符合 `rm *` |

441| `Bash(git push *)` | `echo $(date)` | 是 | 指定超過命令名稱的模式,在遇到 `$()`、反引號或 `$VAR` 時仍會執行 hook |441| `Bash(git push *)` | `echo $(date)` | 是 | 指定超過命令名稱的模式,在遇到 `$()`、反引號或 `$VAR` 時仍會執行 hook |

442 442 

443當 Claude Code 無法判斷 Bash 輸入會執行哪些命令時,無論模式為何都會執行您的 hook。由於 `if` 篩選僅為盡力而為,若要強制實施嚴格的允許或拒絕,請使用[權限系統](https://code.claude.com/docs/zh-TW/permissions.md)而非 hook。443當 Claude Code 無法將 Bash 輸入拆分為子命令時,無論模式為何都會執行您的 hook。由於 `if` 篩選僅為盡力而為,若要強制實施嚴格的允許或拒絕,請使用[權限系統](https://code.claude.com/docs/zh-TW/permissions.md)而非 hook。

444 444 

445#### 命令 hook 欄位445#### 命令 hook 欄位

446 446 


691 - matcher: "Bash"691 - matcher: "Bash"

692 hooks:692 hooks:

693 - type: command693 - type: command

694 command: "./scripts/security-check.sh"694 command: '"${CLAUDE_PROJECT_DIR}"/scripts/security-check.sh'

695---695---

696```696```

697 697 


825 825 

826退出 0 表示成功,是當您列印 JSON 進行結構化控制時的預期退出碼。當您的 hook 以 0 退出,但列印了無法解析或未通過 [schema 驗證](#json-output) 的 JSON 時,操作會繼續進行,除非該 hook 是 [失敗時會阻止操作的 hook](#block-the-action-when-a-hook-fails)。該次執行不會是套用您欄位的成功,而是 [非阻止性錯誤](#exit-code-output)。826退出 0 表示成功,是當您列印 JSON 進行結構化控制時的預期退出碼。當您的 hook 以 0 退出,但列印了無法解析或未通過 [schema 驗證](#json-output) 的 JSON 時,操作會繼續進行,除非該 hook 是 [失敗時會阻止操作的 hook](#block-the-action-when-a-hook-fails)。該次執行不會是套用您欄位的成功,而是 [非阻止性錯誤](#exit-code-output)。

827 827 

828要修正您的輸出,請使用 `<hook name> hook error` 通知所帶有的解析或驗證訊息。對於非 [async](#how-async-hooks-execute) 的 hook,只有當您列印單一 JSON 物件(位於一行或多行),且周圍只有空白時,您的 stdout 才會被視為 [JSON 輸出](#json-output)。Claude Code 會將其他任何 stdout 讀取為純文字或解析失敗:828如果 `<hook name> hook error` 通知帶有剖析或驗證訊息,請據此修正您的輸出。對於非 [async](#how-async-hooks-execute) 的 hook,只有當您輸出單一 JSON 物件(可為單行或多行),且其周圍除空白字元外沒有任何其他內容時,stdout 才會被視為 [JSON 輸出](#json-output)。Claude Code 會將其他任何 stdout 視為純文字或剖析失敗:

829 829 

830* **不以 `{` 開頭的輸出,或以 `{` 開頭但不以 `}` 結尾的輸出**:純文字。依此規則,JSON 陣列和帶引號的 JSON 字串都是純文字。830* **不以 `{` 開頭的輸出,或以 `{` 開頭但不以 `}` 結尾的輸出**:純文字。依此規則,JSON 陣列和帶引號的 JSON 字串都是純文字。

831* **兩行或更多行,每行本身都可解析為 JSON,且第一行以 `{` 開頭、最後一行以 `}` 結尾**:若沒有任何一行是設定欄位的 JSON 輸出物件,則為純文字。若有一行是,則輸出為解析失敗,因此請列印該物件,且 stdout 上不要有其他任何內容。831* **兩行或更多行,每行本身都可解析為 JSON,且第一行以 `{` 開頭、最後一行以 `}` 結尾**:若沒有任何一行是設定欄位的 JSON 輸出物件,則為純文字。若有一行是,則輸出為解析失敗,因此請列印該物件,且 stdout 上不要有其他任何內容。

832* **其他任何以 `{` 開頭並以 `}` 結尾但不是有效 JSON 的內容**:解析失敗。832* **其他任何以 `{` 開頭並以 `}` 結尾但不是有效 JSON 的內容**:解析失敗。

833 833 

834對於大多數事件,Claude Code 將 stdout 寫入偵錯日誌,不在逐字稿中顯示。在以下事件上,您的 stdout 會傳達給 Claude 或壓縮摘要:834在以下事件上,您的純文字 stdout 會傳達給 Claude 或壓縮摘要:

835 835 

836* **`UserPromptSubmit`、`UserPromptExpansion`、`SessionStart` 和 `PostModelSwitch`**:Claude Code 將純文字 stdout 新增為 Claude 可以看到並據以行動的上下文。它不會新增其無法解析的 stdout。836* **`UserPromptSubmit`、`UserPromptExpansion`、`SessionStart` 和 `PostModelSwitch`**:Claude Code 將純文字 stdout 新增為 Claude 可以看到並據以行動的上下文。它不會新增其無法解析的 stdout。

837* **`PreCompact`**:您的 stdout 會成為 [壓縮摘要的指示](#precompact-output)837* **`PreCompact`**:您的 stdout 會成為 [壓縮摘要的指示](#precompact-output)


873 873 

874#### 其他退出碼874#### 其他退出碼

875 875 

876帶有 `Failed with non-blocking status code:` 的 `<hook name> hook error` 通知表示您的 hook 的退出碼不是 0 或 2,且其 stdout 為純文字或空白。除非該 hook 是 [失敗時會阻止操作的 hook](#block-the-action-when-a-hook-fails),否則這是 [非阻止性錯誤](#exit-code-output),因此您的 hook 並未停止該操作。要擷取您的 hook 的完整 stderr,而不僅是通知顯示的第一行,請啟用 [偵錯日誌](#debug-hooks)。876帶有 `Failed with non-blocking status code:` 的 `<hook name> hook error` 通知表示您的 hook 的退出碼不是 0 或 2,且其 stdout 為純文字或空白。該次執行是 [非阻止性錯誤](#exit-code-output),因此您的 hook 並未停止該操作。如果通知截斷了您的 stderr,請依照 [偵錯 hook](#debug-hooks) 的說明啟用偵錯日誌,然後重新執行該 hook。

877 877 

878例如,當 `Bash` 上的 `PreToolUse` hook 將 `something broke` 列印到 stderr 並以 1 退出時,`PreToolUse:Bash hook error` 通知帶有這一行:878例如,當 `Bash` 上的 `PreToolUse` hook 將 `something broke` 列印到 stderr 並以 1 退出時,`PreToolUse:Bash hook error` 通知帶有這一行:

879 879 


1097 1097 

1098| 欄位 | 預設 | 描述 |1098| 欄位 | 預設 | 描述 |

1099| :- | :- | :- |1099| :- | :- | :- |

1100| `continue` | `true` | 如果為 `false`,Claude 在 hook 執行後完全停止處理。優先於任何事件特定的決定欄位 |1100| `continue` | `true` | 如果為 `false`,Claude 在 hook 執行後完全停止處理。它不會阻止 `PreToolUse` 工具呼叫,因此若要阻止,請同時返回 `permissionDecision: "deny"` |

1101| `stopReason` | 無 | 當 `continue` 為 `false` 時向使用者顯示的訊息。它停留在對話中,因此如果對話繼續,Claude 會看到它 |1101| `stopReason` | 無 | 當 `continue` 為 `false` 時向使用者顯示的訊息。它停留在對話中,因此如果對話繼續,Claude 會看到它 |

1102| `suppressOutput` | `false` | 無效果:Claude Code 接受該欄位但不據以行動。成功的 hook 的 stdout 永遠不在逐字稿中顯示,並記錄在偵錯日誌中 |1102| `suppressOutput` | `false` | 無效果 |

1103| `systemMessage` | 無 | 向使用者顯示的警告訊息。在 [Agent SDK](https://code.claude.com/docs/zh-TW/agent-sdk/overview.md) 和 [`--output-format stream-json`](https://code.claude.com/docs/zh-TW/headless) 輸出中,它可以作為 [`SDKInformationalMessage`](https://code.claude.com/docs/zh-TW/agent-sdk/typescript#sdkinformationalmessage) 到達 |1103| `systemMessage` | 無 | 向使用者顯示的警告訊息。在 [Agent SDK](https://code.claude.com/docs/zh-TW/agent-sdk/overview.md) 和 [`--output-format stream-json`](https://code.claude.com/docs/zh-TW/headless) 輸出中,它可以作為 [`SDKInformationalMessage`](https://code.claude.com/docs/zh-TW/agent-sdk/typescript#sdkinformationalmessage) 到達 |

1104| `terminalSequence` | 無 | Claude Code 代表您發出的終端機逃逸序列,例如桌面通知、視窗標題或響鈴。限制為 OSC `0`/`1`/`2`/`9`/`99`/`777` 和 BEL。如果值包含允許清單外的任何內容,該欄位將被忽略。使用此項而不是寫入 `/dev/tty`,後者對 hook 不可用 |1104| `terminalSequence` | 無 | Claude Code 代表您發出的終端機逃逸序列,例如桌面通知、視窗標題或響鈴。限制為 OSC `0`/`1`/`2`/`9`/`99`/`777` 和 BEL。如果值包含允許清單外的任何內容,該欄位將被忽略。使用此項而不是寫入 `/dev/tty`,後者對 hook 不可用 |

1105 1105 


1109{ "continue": false, "stopReason": "Build failed, fix errors before continuing" }1109{ "continue": false, "stopReason": "Build failed, fix errors before continuing" }

1110```1110```

1111 1111 

1112對於 `PreToolUse` 和 `PostToolUse` hook,即使工具呼叫在 Claude 仍在串流回應時失敗或完成,停止仍然適用。1112對於 `PreToolUse` 和 `PostToolUse` hook,即使工具呼叫在 Claude 仍在串流回應時失敗或完成,停止仍然適用。當權限檢查拒絕 `PreToolUse` 呼叫時,停止不適用。

1113 1113 

1114#### 發出終端機通知1114#### 發出終端機通知

1115 1115 


1220* `PostToolUse`:`updatedToolOutput` 替換工具的結果。在 [Cowork](https://claude.com/docs/cowork/overview) 雲端工作階段中,當工具為 `AskUserQuestion` 或 `ExitPlanMode` 時,Claude Code 會忽略 `updatedToolOutput`,Claude 會讀取原始的回答或計畫。請參閱 [PostToolUse 決定控制](#posttooluse-decision-control)1220* `PostToolUse`:`updatedToolOutput` 替換工具的結果。在 [Cowork](https://claude.com/docs/cowork/overview) 雲端工作階段中,當工具為 `AskUserQuestion` 或 `ExitPlanMode` 時,Claude Code 會忽略 `updatedToolOutput`,Claude 會讀取原始的回答或計畫。請參閱 [PostToolUse 決定控制](#posttooluse-decision-control)

1221* `UserPromptSubmit`:無法替換提示詞;僅在其旁邊注入 `additionalContext`1221* `UserPromptSubmit`:無法替換提示詞;僅在其旁邊注入 `additionalContext`

1222 1222 

1223對於遮蔽或轉換使用案例,在 `PreToolUse` 攔截外送的工具輸入,在 `PostToolUse` 攔截傳入的工具結果。1223對於遮蔽或轉換使用案例,在 `PreToolUse` 攔截外送的工具輸入,在 `PostToolUse` 攔截成功呼叫的結果。`PostToolUseFailure` 無法重寫結果,因此失敗命令的輸出會原封不動地傳達給 Claude。

1224 1224 

1225以下是每種模式的實際範例:1225以下是每種模式的實際範例:

1226 1226 


3374 3374 

3375WorktreeRemove hook 的退出碼決定結果。當 hook 以非零值結束,且 `worktree_path` 處的目錄之後仍然存在時,移除即告失敗:3375WorktreeRemove hook 的退出碼決定結果。當 hook 以非零值結束,且 `worktree_path` 處的目錄之後仍然存在時,移除即告失敗:

3376 3376 

3377* worktree 會保留在磁碟上,hook 的命令與 stderr 會寫入[偵錯日誌](#debug-hooks)。

3378* 如果您當時正在刪除背景工作階段,該工作階段也會保留。[agent view](https://code.claude.com/docs/zh-TW/agent-view.md#what-deleting-a-session-removes) 中的拒絕訊息會回報 hook 的結束方式(例如 `exited 1`)、引用其 stderr 的開頭,並說明再次刪除工作階段是否仍會移除該目錄。3377* 如果您當時正在刪除背景工作階段,該工作階段也會保留。[agent view](https://code.claude.com/docs/zh-TW/agent-view.md#what-deleting-a-session-removes) 中的拒絕訊息會回報 hook 的結束方式(例如 `exited 1`)、引用其 stderr 的開頭,並說明再次刪除工作階段是否仍會移除該目錄。

3379* 如果 `claude remote-control` 當時正在清理工作階段的 worktree,執行它的終端機會顯示 `worktree removal failed, kept: <path>`。3378* 如果 `claude remote-control` 當時正在清理工作階段的 worktree,執行它的終端機會顯示 `worktree removal failed, kept: <path>`。

3380 3379 


3778}3777}

3779```3778```

3780 3779 

3781在對話方塊中,選取 **Decline** 會傳送 `decline`,按下 `Esc` 則會傳送 `cancel`,因此請傳回您希望伺服器看到的那一個。

3782 

3783對於 URL 模式的請求,傳回 `accept` 的 hook 會略過對話方塊,因此 URL 永遠不會開啟。3780對於 URL 模式的請求,傳回 `accept` 的 hook 會略過對話方塊,因此 URL 永遠不會開啟。

3784 3781 

3785無論您傳回哪個 `action`,Claude Code 都會捨棄 Elicitation hook JSON 輸出中的 `reason`、`systemMessage` 與 `continue`。3782無論您傳回哪個 `action`,Claude Code 都會捨棄 Elicitation hook JSON 輸出中的 `reason`、`systemMessage` 與 `continue`。

hooks-guide.md +14 −14

Details

242 242 

243### 封鎖對受保護檔案的編輯243### 封鎖對受保護檔案的編輯

244 244 

245防止 Claude 修改敏感檔案,例如 `.env`、`package-lock.json` 或 `.git/` 中的任何內容。Claude 會收到說明編輯遭封鎖原因的回饋,以便調整其做法。245防止 Claude 的 `Edit` 和 `Write` 工具修改敏感檔案,例如 `.env`、`package-lock.json` 或 `.git/` 中的任何內容。Claude 會收到說明編輯遭封鎖原因的回饋,以便調整其做法。

246 246 

247此範例使用由 hook 呼叫的獨立指令碼檔案。該指令碼會將目標檔案路徑與受保護模式清單進行比對,並以退出碼 2 結束來封鎖編輯。247此範例使用由 hook 呼叫的獨立指令碼檔案。該指令碼會將目標檔案路徑與受保護模式清單進行比對,並以退出碼 2 結束來封鎖編輯。

248 248 


306 306 

307要求 Claude 在您的 `.env` 檔案中新增註解。Claude Code 會在編輯執行前將其封鎖,並將指令碼的 `Blocked:` 訊息作為回饋傳遞給 Claude。307要求 Claude 在您的 `.env` 檔案中新增註解。Claude Code 會在編輯執行前將其封鎖,並將指令碼的 `Blocked:` 訊息作為回饋傳遞給 Claude。

308 308 

309Claude 仍可透過 shell 命令變更受保護的檔案。若要封鎖其中部分命令,請在 `.claude/settings.json` 的 `permissions.deny` 下,為每個路徑新增一條 [`Edit` 拒絕規則](https://code.claude.com/docs/zh-TW/permissions#what-read-and-edit-rules-cover),例如針對專案根目錄 `.env` 的 `Edit(/.env)`。

310 

311即使有這些規則,Claude 仍可透過其他方式變更 `.env`。若要限制命令可以寫入哪些檔案,請參閱[設定沙箱機制](https://code.claude.com/docs/zh-TW/sandboxing.md#configure-sandboxing)。

312 

309### 在壓縮後重新注入上下文313### 在壓縮後重新注入上下文

310 314 

311當 Claude 的上下文視窗填滿時,壓縮會摘要對話以釋放空間。這可能會遺失重要細節。使用帶有 `compact` matcher 的 `SessionStart` hook,在每次壓縮後重新注入關鍵上下文。315當 Claude 的上下文視窗填滿時,壓縮會摘要對話以釋放空間。這可能會遺失重要細節。使用帶有 `compact` matcher 的 `SessionStart` hook,在每次壓縮後重新注入關鍵上下文。


589 593 

590* **結束代碼 0**:如果您從 `PreToolUse` hook 以結束代碼 0 結束,工具呼叫仍會經過正常的 [權限流程](https://code.claude.com/docs/zh-TW/permissions.md),因為結束代碼 0 並不會核准它。對於 `UserPromptSubmit`、`UserPromptExpansion`、`SessionStart` 和 `PostModelSwitch` hooks,Claude Code 會將其 [視為純文字](https://code.claude.com/docs/zh-TW/hooks.md#exit-code-0) 的 stdout 新增到 Claude 的上下文。594* **結束代碼 0**:如果您從 `PreToolUse` hook 以結束代碼 0 結束,工具呼叫仍會經過正常的 [權限流程](https://code.claude.com/docs/zh-TW/permissions.md),因為結束代碼 0 並不會核准它。對於 `UserPromptSubmit`、`UserPromptExpansion`、`SessionStart` 和 `PostModelSwitch` hooks,Claude Code 會將其 [視為純文字](https://code.claude.com/docs/zh-TW/hooks.md#exit-code-0) 的 stdout 新增到 Claude 的上下文。

591* **結束代碼 2**:將原因寫入 stderr。視事件而定,Claude 會將其作為回饋接收以便調整、使用者會看到它,或者不顯示任何訊息(如 `ConfigChange` 和 `Elicitation`)。某些事件無法被阻止:對於 `SessionStart` 和其他事件,結束代碼 2 向使用者顯示 stderr 並繼續執行。請參閱 [每個事件的結束代碼 2 行為](https://code.claude.com/docs/zh-TW/hooks.md#exit-code-2-behavior-per-event) 以取得完整清單。595* **結束代碼 2**:將原因寫入 stderr。視事件而定,Claude 會將其作為回饋接收以便調整、使用者會看到它,或者不顯示任何訊息(如 `ConfigChange` 和 `Elicitation`)。某些事件無法被阻止:對於 `SessionStart` 和其他事件,結束代碼 2 向使用者顯示 stderr 並繼續執行。請參閱 [每個事件的結束代碼 2 行為](https://code.claude.com/docs/zh-TW/hooks.md#exit-code-2-behavior-per-event) 以取得完整清單。

592* **任何其他結束代碼**:關於每個事件的例外情況(例如 `WorktreeCreate` 在任何非零結束代碼上失敗),請參閱 [結束代碼輸出](https://code.claude.com/docs/zh-TW/hooks.md#exit-code-output)。在其他事件上,除非該 hook 屬於其失敗會阻止動作的類型,請依據您的 hook 印出到 stdout 的內容找出您的情況:596 

593 * 通過 schema 驗證的已解析物件:Claude Code 忽略結束代碼,JSON 單獨決定結果,hook 不會報告為錯誤。597若要查詢 `PreToolUse` 等事件上結束代碼與 stdout 組合的結果,請參閱 [結束代碼輸出](https://code.claude.com/docs/zh-TW/hooks.md#exit-code-output)。對於具有自身結束代碼規則的事件(例如 `WorktreeCreate`),也請查看同一節。

594 * 未通過 schema 驗證的已解析物件,或 Claude Code [嘗試解析為 JSON](https://code.claude.com/docs/zh-TW/hooks.md#exit-code-0) 但不是有效 JSON 的 stdout:動作以非阻止性錯誤繼續進行。請查看 `<hook name> hook error` 通知中的驗證或解析訊息。

595 * Claude Code [視為純文字](https://code.claude.com/docs/zh-TW/hooks.md#exit-code-0) 的 stdout,或空 stdout:動作以非阻止性錯誤繼續進行。逐字稿顯示 `<hook name> hook error` 通知,然後是 stderr 的第一行,前綴為 `Failed with non-blocking status code:`。要擷取完整的 stderr,請使用 `claude --debug` 或在工作階段中執行 `/debug` 來啟用 [偵錯日誌](https://code.claude.com/docs/zh-TW/hooks.md#debug-hooks)。

596 598 

597#### 結構化 JSON 輸出599#### 結構化 JSON 輸出

598 600 


696 698 

697下面的標籤顯示不同事件類型上的一些其他匹配器。699下面的標籤顯示不同事件類型上的一些其他匹配器。

698 700 

699> [tab] 記錄每個 Bash 命令701> [tab] 記錄成功的 Bash 命令

700>702>

701> 僅匹配 `Bash` 工具呼叫並將每個命令記錄到檔案。`PostToolUse` 事件在命令完成後觸發,所以 `tool_input.command` 包含執行的內容。hook 在 stdin 上接收事件資料作為 JSON,`jq -r '.tool_input.command'` 僅提取命令字串,`>>` 將其附加到日誌檔案:703> 僅匹配 `Bash` 工具呼叫並將每個成功的命令記錄到檔案。`PostToolUse` 事件在命令成功後觸發,所以 `tool_input.command` 包含執行的內容。hook 在 stdin 上接收事件資料作為 JSON,`jq -r '.tool_input.command'` 僅提取命令字串,`>>` 將其附加到日誌檔案:

702>704>

703> ```json theme={null}705> ```json theme={null}

704> {706> {


799| `Bash(git *)` | `echo $(date)` | 否 | 沒有子命令相符 `git *` |801| `Bash(git *)` | `echo $(date)` | 否 | 沒有子命令相符 `git *` |

800| `Bash(git push *)` | `echo $(date)` | 是 | 指定超過命令名稱的模式在 `$()`、反引號或 `$VAR` 上執行 hook |802| `Bash(git push *)` | `echo $(date)` | 是 | 指定超過命令名稱的模式在 `$()`、反引號或 `$VAR` 上執行 hook |

801 803 

802當 Claude Code 無法確定 Bash 輸入執行哪些命令時,無論模式如何,它都會執行您的 hook。[Bash 匹配表](https://code.claude.com/docs/zh-TW/hooks.md#bash-if-matching) 涵蓋 Claude Code 可以和不能按子命令縮小的命令形狀。因為篩選是盡力而為,請使用 [權限系統](https://code.claude.com/docs/zh-TW/permissions.md) 而不是 hook 來強制執行硬允許或拒絕。804當 Claude Code 無法將 Bash 輸入拆分為子命令時,無論模式如何,它都會執行您的 hook。[Bash 匹配表](https://code.claude.com/docs/zh-TW/hooks.md#bash-if-matching) 涵蓋 Claude Code 可以和不能按子命令縮小的命令形狀。因為篩選是盡力而為,請使用 [權限系統](https://code.claude.com/docs/zh-TW/permissions.md) 而不是 hook 來強制執行硬允許或拒絕。

803 805 

804`if` 欄位接受與權限規則相同的模式:`"Bash(git *)"`、`"Edit(*.ts)"` 等。要匹配多個工具名稱,請使用各自具有自己 `if` 值的單獨處理程式,或在支援管道替代的 `matcher` 級別進行匹配。806`if` 欄位接受與權限規則相同的模式:`"Bash(git *)"`、`"Edit(*.ts)"` 等。要匹配多個工具名稱,請使用各自具有自己 `if` 值的單獨處理程式,或在支援管道替代的 `matcher` 級別進行匹配。

805 807 


897 899 

898使用 `type: "http"` hooks 將事件資料 POST 到 HTTP 端點,而不是執行 shell 命令。端點接收命令 hook 在 stdin 上接收的相同 JSON,並使用相同的 JSON 格式透過 HTTP 回應主體傳回結果。900使用 `type: "http"` hooks 將事件資料 POST 到 HTTP 端點,而不是執行 shell 命令。端點接收命令 hook 在 stdin 上接收的相同 JSON,並使用相同的 JSON 格式透過 HTTP 回應主體傳回結果。

899 901 

900HTTP hooks 在您希望 Web 伺服器、雲端函數或外部服務處理 hook 邏輯時很有用:例如,一個共享的審計服務,在整個團隊中記錄工具使用事件。902HTTP hooks 在您希望 Web 伺服器、雲端函數或外部服務處理 hook 邏輯時很有用,例如團隊共享的審計服務。以下設定會將每個成功的工具呼叫 POST 到本機記錄服務:

901 

902此範例將每個工具使用 POST 到本機記錄服務:

903 903 

904```json theme={null}904```json theme={null}

905{905{


1058* **成功**:您看不到任何內容,除非 hook 的 JSON 顯示某些內容,例如 `systemMessage` 或 Stop hook 回饋。1058* **成功**:您看不到任何內容,除非 hook 的 JSON 顯示某些內容,例如 `systemMessage` 或 Stop hook 回饋。

1059 * 要確認 hook 已執行,請檢查其效果,例如重新格式化的檔案1059 * 要確認 hook 已執行,請檢查其效果,例如重新格式化的檔案

1060* **阻止錯誤**:在大多數事件上,您會看到隨阻止一起傳回的訊息,例如 `Blocked: rm commands are not allowed`。在少數事件上,例如 `ConfigChange` 和 `Elicitation`,您不會看到任何訊息。[退出碼 2](https://code.claude.com/docs/zh-TW/hooks.md#exit-code-2) 說明訊息的來源。1060* **阻止錯誤**:在大多數事件上,您會看到隨阻止一起傳回的訊息,例如 `Blocked: rm commands are not allowed`。在少數事件上,例如 `ConfigChange` 和 `Elicitation`,您不會看到任何訊息。[退出碼 2](https://code.claude.com/docs/zh-TW/hooks.md#exit-code-2) 說明訊息的來源。

1061* **非阻止錯誤**:您會看到 `<hook name> hook error` 通知,其中包含簡短說明,例如 `Failed with non-blocking status code:` 之後的 stderr 第一行,或 JSON 驗證或解析訊息。操作仍會繼續進行。1061* **非阻止錯誤**:帶有 `Failed with non-blocking status code:` 的 `<hook name> hook error` 通知表示您的 hook 並未停止該操作。當 `Notification` 等事件上的命令 hook 失敗時,您不會看到此通知。

1062 1062 

1063若要查詢特定退出碼和 stdout 所對應的結果,包括每個事件的例外,請參閱參考文件中的[退出碼輸出](https://code.claude.com/docs/zh-TW/hooks.md#exit-code-output)。1063若要查詢 `PreToolUse` 等事件上特定退出碼和 stdout 組合所對應的結果,請參閱參考文件中的[退出碼輸出](https://code.claude.com/docs/zh-TW/hooks.md#exit-code-output)。對於具有自身退出碼規則的事件(例如 `WorktreeCreate`),也請查看同一節。

1064 1064 

1065如需完整的執行詳細資訊,包括 hook 退出碼、stdout 和 stderr,請閱讀[除錯日誌](https://code.claude.com/docs/zh-TW/hooks.md#debug-hooks)。使用 `claude --debug-file /tmp/claude.log` 啟動 Claude Code 以寫入已知路徑,然後在另一個終端機中執行 `tail -f /tmp/claude.log`。如果您啟動時沒有該旗標,請在工作階段中執行 `/debug` 以啟用日誌並找到日誌路徑。1065如需執行詳細資訊,請閱讀[除錯日誌](https://code.claude.com/docs/zh-TW/hooks.md#debug-hooks)。使用 `claude --debug-file /tmp/claude.log` 啟動 Claude Code 以寫入已知路徑,然後在另一個終端機中執行 `tail -f /tmp/claude.log`。如果您啟動時沒有該旗標,請在工作階段中執行 `/debug` 以啟用日誌並找到日誌路徑。

1066 1066 

1067## 深入瞭解1067## 深入瞭解

1068 1068 

Details

619 619 

620貼上的文字可能包含 Unicode 字元,終端機不會顯示這些字元,例如標籤字元、雙向控制字元和零寬度空格,因此提示詞可能包含您看不到的文字。為了防止複製的文字攜帶終端機不會顯示的指令,Claude Code 會在您按下 Enter 時移除這些字元,然後再傳送任何內容。它會清理提示詞和提示詞所包含的任何摺疊 [貼上文字參考](https://code.claude.com/docs/zh-TW/terminal-config.md#paste-large-content) 的內容。Claude Code 會保留波斯語和印度系文字所使用的連接符,以及表情符號序列內的選擇器。620貼上的文字可能包含 Unicode 字元,終端機不會顯示這些字元,例如標籤字元、雙向控制字元和零寬度空格,因此提示詞可能包含您看不到的文字。為了防止複製的文字攜帶終端機不會顯示的指令,Claude Code 會在您按下 Enter 時移除這些字元,然後再傳送任何內容。它會清理提示詞和提示詞所包含的任何摺疊 [貼上文字參考](https://code.claude.com/docs/zh-TW/terminal-config.md#paste-large-content) 的內容。Claude Code 會保留波斯語和印度系文字所使用的連接符,以及表情符號序列內的選擇器。

621 621 

622如果 Claude Code 移除了任何內容,該 Enter 不會傳送任何內容。清理後的提示詞會回到輸入框中,並顯示通知,例如 `Removed 3 invisible characters · review and press Enter to send`,再次按下 Enter 會傳送顯示的文字。622如果 Claude Code 移除了任何內容,它會傳送清理後的提示詞,或將其放回輸入框供您檢閱。若要判斷是哪一種情況,請查看通知:

623 623 

624當您在命令列上傳遞提示詞時,例如 `claude "fix the login bug"`,Claude Code 不會等待第二次 Enter。它會移除字元、顯示通知並傳送清理後的提示詞。如果清理後的提示詞會以 `/` 開頭,Claude Code 會改為將其放在輸入框中供您檢閱並傳送。624* **`Removed 3 invisible characters from your prompt`**:如果輸入框是空的,表示您的提示詞已在不含這些字元的情況下傳送。如果提示詞仍在輸入框中,表示尚未傳送,請再次按下 Enter。

625* **`Removed 3 invisible characters · review and press Enter to send`**:未傳送任何內容。請閱讀輸入框中清理後的提示詞,然後按下 Enter 以傳送顯示的內容。

626 

627當您在命令列上傳遞提示詞時,例如 `claude "fix the login bug"`,Claude Code 會移除字元、顯示通知並傳送清理後的提示詞。如果清理後的提示詞會以 `/` 開頭,Claude Code 會改為將其放在輸入框中供您檢閱並傳送。

625 628 

626## 使用 /diff 檢視變更629## 使用 /diff 檢視變更

627 630 

Details

110 110 

111兩個用戶端設定會改變 Claude Code 對無法識別的模型 ID 的假設,無論開發人員使用哪種連線方法:111兩個用戶端設定會改變 Claude Code 對無法識別的模型 ID 的假設,無論開發人員使用哪種連線方法:

112 112 

113* **內容視窗**:Claude Code 假設 200K,或當 ID 帶有 `[1m]` 時為 1M。若要宣告實際視窗,請參閱 [更正閘道或自訂模型 ID 的視窗](https://code.claude.com/docs/zh-TW/model-config.md#correct-the-window-for-a-gateway-or-custom-model-id)113* **上下文視窗**:Claude Code 預設假設 1M token 的上下文視窗。若要宣告實際視窗,請參閱 [更正閘道或自訂模型 ID 的視窗](https://code.claude.com/docs/zh-TW/model-config.md#correct-the-window-for-a-gateway-or-custom-model-id)

114* **功能**:若要給閘道別名提供其背後模型的功能,請在您分發的設定中使用 [`modelOverrides`](https://code.claude.com/docs/zh-TW/errors#unrecognized-model-id-on-a-request) 項目將該模型的 Anthropic ID 對應到您的別名。如需 `ANTHROPIC_DEFAULT_*_MODEL_SUPPORTED_CAPABILITIES` 變數適用的位置,請參閱 [功能傳遞](#feature-pass-through)114* **功能**:若要給閘道別名提供其背後模型的功能,請在您分發的設定中使用 [`modelOverrides`](https://code.claude.com/docs/zh-TW/errors#unrecognized-model-id-on-a-request) 項目將該模型的 Anthropic ID 對應到您的別名。如需 `ANTHROPIC_DEFAULT_*_MODEL_SUPPORTED_CAPABILITIES` 變數適用的位置,請參閱 [功能傳遞](#feature-pass-through)

115 115 

116## 請求標頭116## 請求標頭


296* 頂層的 `output_config.effort` 欄位。[自動重試和錯誤轉發](#automatic-retry-and-error-forwarding)涵蓋拒絕它的上游296* 頂層的 `output_config.effort` 欄位。[自動重試和錯誤轉發](#automatic-retry-and-error-forwarding)涵蓋拒絕它的上游

297* 自適應推理的 `thinking` 欄位,它沒有測試版標頭297* 自適應推理的 `thinking` 欄位,它沒有測試版標頭

298* 承載[對話中途系統訊息](#feature-pass-through)的 `role: "system"` 項目298* 承載[對話中途系統訊息](#feature-pass-through)的 `role: "system"` 項目

299* 自動模式[伺服器端分類器審查](https://code.claude.com/docs/zh-TW/permission-modes.md#server-side-classifier-review)的 `anthropic-beta` 值和 `safeguards` 欄位,適用於該審查保持開啟的工作階段,例如 `/status` 將 **Auto mode server** 顯示為 `Enabled` 時。若要關閉審查,請在啟動工作階段之前設定 `CLAUDE_CODE_AUTO_MODE_SERVER=0`。在終端機中,`/status` 隨後會將 **Auto mode server** 顯示為 `Disabled`。

299* 訂閱身分驗證所需的 OAuth `anthropic-beta` 值300* 訂閱身分驗證所需的 OAuth `anthropic-beta` 值

300* 開發人員透過 [`ANTHROPIC_BETAS`](https://code.claude.com/docs/zh-TW/env-vars) 或 [`CLAUDE_CODE_EXTRA_BODY`](https://code.claude.com/docs/zh-TW/env-vars) 自行添加的標頭值和請求體欄位301* 開發人員透過 [`ANTHROPIC_BETAS`](https://code.claude.com/docs/zh-TW/env-vars) 或 [`CLAUDE_CODE_EXTRA_BODY`](https://code.claude.com/docs/zh-TW/env-vars) 自行添加的標頭值和請求體欄位

301 302 

managed-mcp.md +3 −2

Details

30| 模式 | 功能 | 設定 |30| 模式 | 功能 | 設定 |

31| :- | :- | :- |31| :- | :- | :- |

32| **停用 MCP** | 沒有伺服器載入,除了 [在獨佔控制下載入的少數伺服器](#exclusive-control-with-managed-mcp-json) | `managed-mcp.json` 搭配空白伺服器對應 |32| **停用 MCP** | 沒有伺服器載入,除了 [在獨佔控制下載入的少數伺服器](#exclusive-control-with-managed-mcp-json) | `managed-mcp.json` 搭配空白伺服器對應 |

33| **固定部署** | 每個使用者都取得相同的伺服器,無法新增其他伺服器 | `managed-mcp.json` 搭配您想要的伺服器 |33| **固定部署** | 每個使用者都取得您列出的伺服器,而他們自己設定的伺服器不會載入 | `managed-mcp.json` 搭配您想要的伺服器 |

34| **提供的伺服器** | 每個使用者都取得您列出的遠端伺服器,並保留他們自己的伺服器 | 受管設定中的 `managedMcpServers` |34| **提供的伺服器** | 每個使用者都取得您列出的遠端伺服器,並保留他們自己的伺服器 | 受管設定中的 `managedMcpServers` |

35| **已核准的目錄** | 發佈已核准伺服器的清單;使用者新增他們想要的伺服器,其他任何伺服器都會被封鎖 | `allowedMcpServers` + `allowManagedMcpServersOnly: true` |35| **已核准的目錄** | 發佈已核准伺服器的清單;使用者新增他們想要的伺服器,其他任何伺服器都會被封鎖 | `allowedMcpServers` + `allowManagedMcpServersOnly: true` |

36| **僅限外掛程式伺服器** | 使用者無法透過 `~/.claude.json` 或 `.mcp.json` 新增伺服器;[skills 目錄外掛](https://code.claude.com/docs/zh-TW/plugins/loading.md#skills-directory-plugins-blocked-by-managed-settings) 不再以外掛形式載入,而來自其他外掛的伺服器仍會載入 | [`strictPluginOnlyCustomization`](https://code.claude.com/docs/zh-TW/settings-reference#strictpluginonlycustomization) 搭配清單中的 `mcp` |36| **僅限外掛程式伺服器** | 使用者無法透過 `~/.claude.json` 或 `.mcp.json` 新增伺服器;[skills 目錄外掛](https://code.claude.com/docs/zh-TW/plugins/loading.md#skills-directory-plugins-blocked-by-managed-settings) 不再以外掛形式載入,而來自其他外掛的伺服器仍會載入 | [`strictPluginOnlyCustomization`](https://code.claude.com/docs/zh-TW/settings-reference#strictpluginonlycustomization) 搭配清單中的 `mcp` |


49* 該檔案定義的伺服器49* 該檔案定義的伺服器

50* 您[透過 `managedMcpServers` 提供的伺服器](#provide-servers-through-managed-settings)50* 您[透過 `managedMcpServers` 提供的伺服器](#provide-servers-through-managed-settings)

51* 啟動工作階段的應用程式註冊的同處理程序伺服器,例如 VS Code 擴充功能自己的伺服器或[桌面應用程式提供的連接器](https://code.claude.com/docs/zh-TW/mcp.md#how-connectors-reach-claude-code)51* 啟動工作階段的應用程式註冊的同處理程序伺服器,例如 VS Code 擴充功能自己的伺服器或[桌面應用程式提供的連接器](https://code.claude.com/docs/zh-TW/mcp.md#how-connectors-reach-claude-code)

52* Claude Code 在 [mod](https://code.claude.com/docs/zh-TW/plugins/mods/overview.md) [新增工具](https://code.claude.com/docs/zh-TW/plugins/mods/api.md#add-a-tool)時建立的伺服器。若要封鎖使用者的 mod 所新增的工具,請[阻止使用者安裝的 mod 載入](https://code.claude.com/docs/zh-TW/plugins/mods/admin.md#stop-user-installed-mods-from-loading)。

52* 內建的[Chrome 中的 Claude](https://code.claude.com/docs/zh-TW/chrome.md) 伺服器,如果您[允許它與受管集合並存](#allow-claude-in-chrome-alongside-the-managed-set)53* 內建的[Chrome 中的 Claude](https://code.claude.com/docs/zh-TW/chrome.md) 伺服器,如果您[允許它與受管集合並存](#allow-claude-in-chrome-alongside-the-managed-set)

53 54 

54使用者無法新增、修改或使用任何其他 MCP 伺服器,包括外掛程式提供的伺服器和透過 [`--mcp-config` CLI 旗標](https://code.claude.com/docs/zh-TW/cli-reference#cli-flags)傳遞的伺服器。該檔案也會抑制 Claude Code 自行擷取的 claude.ai 連接器,除非您[允許它們與受管集合並存](#allow-claude-ai-connectors-alongside-the-managed-set)。55使用者無法新增、修改或使用任何其他 MCP 伺服器,包括外掛程式提供的伺服器和透過 [`--mcp-config` CLI 旗標](https://code.claude.com/docs/zh-TW/cli-reference#cli-flags)傳遞的伺服器。該檔案也會抑制 Claude Code 自行擷取的 claude.ai 連接器,除非您[允許它們與受管集合並存](#allow-claude-ai-connectors-alongside-the-managed-set)。


137}138}

138```139```

139 140 

140`claude mcp add` 失敗,並顯示上述企業原則錯誤。使用者之前設定的伺服器在下次啟動工作階段時停止載入,沒有警告說明原則是原因。您透過 `managedMcpServers` 提供的伺服器和您允許與受管集合並存的任何其他內容仍在空對應下載入,因此請保持那些金鑰未設定以完全停用 MCP。141`claude mcp add` 失敗,並顯示上述企業原則錯誤。使用者之前設定的伺服器在下次啟動工作階段時停止載入,沒有警告說明原則是原因。您透過 `managedMcpServers` 提供的伺服器,以及您允許與受管集合並存的任何其他內容,在空對應下[仍會載入](#exclusive-control-with-managed-mcp-json),因此請勿設定那些鍵。

141 142 

142### 允許 claude.ai 連接器與受管集合並存143### 允許 claude.ai 連接器與受管集合並存

143 144 

Details

97 97 

98各處的鍵都相同,但每種機制會以不同的位置和形式儲存它們:98各處的鍵都相同,但每種機制會以不同的位置和形式儲存它們:

99 99 

100* **伺服器受管**:由 Anthropic 的伺服器或您的閘道保存政策。Claude Code 會保留一份本機快取,在啟動時套用,並[在每次成功擷取時取代](https://code.claude.com/docs/zh-TW/server-managed-settings.md#security-considerations)。100* **伺服器受管**:由 Anthropic 的伺服器或您的閘道保存政策。Claude Code 會保留一份本機快取,該快取[可在啟動時套用](https://code.claude.com/docs/zh-TW/server-managed-settings.md#fetch-and-caching-behavior),並[在每次成功擷取時取代](https://code.claude.com/docs/zh-TW/server-managed-settings.md#security-considerations)。

101* **macOS 設定描述檔**:`com.anthropic.claudecode` 受管偏好設定網域。使用與 `managed-settings.json` 相同的頂層鍵,巢狀設定使用字典,清單則使用 plist 陣列。101* **macOS 設定描述檔**:`com.anthropic.claudecode` 受管偏好設定網域。使用與 `managed-settings.json` 相同的頂層鍵,巢狀設定使用字典,清單則使用 plist 陣列。

102* **Windows HKLM 登錄**:JSON 以名為 `Settings` 的 `REG_SZ` 或 `REG_EXPAND_SZ` 值存放於 `HKLM\SOFTWARE\Policies\ClaudeCode` 下。102* **Windows HKLM 登錄**:JSON 以名為 `Settings` 的 `REG_SZ` 或 `REG_EXPAND_SZ` 值存放於 `HKLM\SOFTWARE\Policies\ClaudeCode` 下。

103* **檔案型**:系統目錄中的 `managed-settings.json`、選用的 `managed-settings.d/` 目錄和 `managed-mcp.json`:macOS 上為 `/Library/Application Support/ClaudeCode/`,Linux 和 WSL 上為 `/etc/claude-code/`,Windows 上為 `C:\Program Files\ClaudeCode\`。Claude Code 不會讀取舊版 Windows 路徑 `C:\ProgramData\ClaudeCode\managed-settings.json`。103* **檔案型**:系統目錄中的 `managed-settings.json`、選用的 `managed-settings.d/` 目錄和 `managed-mcp.json`:macOS 上為 `/Library/Application Support/ClaudeCode/`,Linux 和 WSL 上為 `/etc/claude-code/`,Windows 上為 `C:\Program Files\ClaudeCode\`。Claude Code 不會讀取舊版 Windows 路徑 `C:\ProgramData\ClaudeCode\managed-settings.json`。

mcp.md +6 −4

Details

252 252 

253以下清單中的狀態回報的是設定上的決定,而非連線嘗試,因此 Claude Code 會在不連線到伺服器的情況下印出它們:253以下清單中的狀態回報的是設定上的決定,而非連線嘗試,因此 Claude Code 會在不連線到伺服器的情況下印出它們:

254 254 

255* ``⏸ Pending approval (run `claude` to approve)``:來自 `.mcp.json`、您尚未核准的專案範圍伺服器。Claude Code 會在 `claude mcp list` 和 `claude mcp get <name>` 中都顯示它。請以互動方式執行 `claude` 來檢視並核准它。255* ``⏸ Pending approval (run `claude` to approve)``:來自 `.mcp.json`、您尚未核准的專案範圍伺服器。Claude Code 會在 `claude mcp list` 和 `claude mcp get <name>` 中都顯示此狀態。請以互動方式執行 `claude` 來檢閱並核准它。

256* `✘ Rejected (see disabledMcpjsonServers in settings)`:被 [`disabledMcpjsonServers`](https://code.claude.com/docs/zh-TW/settings-reference#disabledmcpjsonservers) 項目拒絕的 `.mcp.json` 伺服器。Claude Code 只會在 `claude mcp get <name>` 中顯示它。256* `✘ Rejected (see disabledMcpjsonServers in settings)`:被 [`disabledMcpjsonServers`](https://code.claude.com/docs/zh-TW/settings-reference#disabledmcpjsonservers) 項目拒絕的 `.mcp.json` 伺服器。Claude Code 只會在 `claude mcp get <name>` 中顯示它。

257* `⊘ Disabled for this project (re-enable via /mcp)`:專案的 [`disabledMcpServers`](#disable-a-server-without-removing-it) 清單中列出的伺服器。Claude Code 會在 `claude mcp list` 和 `claude mcp get <name>` 中都顯示它。請從 `/mcp` 面板重新開啟該伺服器。257* `⊘ Disabled for this project (re-enable via /mcp)`:專案的 [`disabledMcpServers`](#disable-a-server-without-removing-it) 清單中列出的伺服器。Claude Code 會在 `claude mcp list` 和 `claude mcp get <name>` 中都顯示它。請從 `/mcp` 面板重新開啟該伺服器。

258* `✘ Blocked by enterprise managed policy`:被您組織的某項政策拒絕的伺服器。Claude Code 會在 `claude mcp list` 和 `claude mcp get <name>` 中都顯示它。被[受管 MCP 設定](https://code.claude.com/docs/zh-TW/managed-mcp.md#how-restrictions-appear-to-users)中的允許清單、拒絕清單或其他限制封鎖的伺服器,會在這兩個命令中都被隱藏,而不是以此狀態顯示。請詢問您的管理員是哪項政策封鎖了該伺服器。258* `✘ Blocked by enterprise managed policy`:被您組織的某項政策拒絕的伺服器。Claude Code 會在 `claude mcp list` 和 `claude mcp get <name>` 中都顯示它。被[受管 MCP 設定](https://code.claude.com/docs/zh-TW/managed-mcp.md#how-restrictions-appear-to-users)中的允許清單、拒絕清單或其他限制封鎖的伺服器,會在這兩個命令中都被隱藏,而不是以此狀態顯示。請詢問您的管理員是哪項政策封鎖了該伺服器。


504 504 

505#### 停止 MCP 任務或取得其結果505#### 停止 MCP 任務或取得其結果

506 506 

507若要停止執行中的任務,請在 [`/tasks`](https://code.claude.com/docs/zh-TW/commands#all-commands) 中選取它並按 `x`,或請 Claude 代為停止。Claude Code 會停止追蹤該任務並要求伺服器取消它,但伺服器仍可能完成它。請先從 `/mcp` 重新連線已中斷的伺服器,否則不會送出取消請求,且 Claude Code 會忘記該任務而無法再次追蹤。按 `Esc` 不會停止背景任務。507若要停止執行中的任務,請在 [`/tasks`](https://code.claude.com/docs/zh-TW/commands#all-commands) 中選取它並按 `x`,或請 Claude 停止它。Claude Code 會停止追蹤該任務並要求伺服器取消它,不過伺服器仍可能完成它。請先從 `/mcp` 重新連線已中斷連線的伺服器,讓取消請求能夠送出。Claude Code 無法再次追蹤已停止的任務。按 `Esc` 不會停止背景任務。

508 508 

509任務結束時,逐字稿中會出現如下的一行:509任務結束時,逐字稿中會出現如下的一行:

510 510 


516 516 

517#### 回答來自 MCP 任務的問題517#### 回答來自 MCP 任務的問題

518 518 

519執行中的任務可以開啟[引導對話框](#respond-to-mcp-elicitation-requests)來請您提供輸入。`/tasks` 開啟期間,對話框會保持隱藏,因此請關閉 `/tasks` 以回答。拒絕或按 `Esc` 也是對伺服器的一種回答,伺服器接著會決定任務是否繼續。519執行中的任務可以開啟[誘導對話框](#respond-to-mcp-elicitation-requests)向您要求輸入。當 `/tasks` 開啟時,對話框會保持隱藏,因此請關閉 `/tasks` 以進行回答。拒絕也是對伺服器的一種回答,伺服器接著會決定任務是否繼續。

520 

521除非您已將 Claude 設為[等待結果](#make-claude-wait-for-the-result-of-an-mcp-task),否則可在對話框中按下 `Esc` 稍後再回答。若要重新開啟該問題,請執行 `/tasks`,開啟該任務的詳細資訊,然後按下 `Enter`。稍後回答需要 Claude Code v2.1.324 或更新版本。

520 522 

521在[非互動](https://code.claude.com/docs/zh-TW/headless.md)工作階段中,Claude Code 會要求伺服器取消請求輸入的任務,而不會執行您的 [`Elicitation` hook](https://code.claude.com/docs/zh-TW/hooks#elicitation) 或呼叫 Agent SDK 的 `onElicitation` 回呼。523在[非互動](https://code.claude.com/docs/zh-TW/headless.md)工作階段中,Claude Code 會要求伺服器取消請求輸入的任務,而不會執行您的 [`Elicitation` hook](https://code.claude.com/docs/zh-TW/hooks#elicitation) 或呼叫 Agent SDK 的 `onElicitation` 回呼。

522 524 


806 808 

807* 將其加入 [`disabledMcpjsonServers`](https://code.claude.com/docs/zh-TW/settings-reference#disabledmcpjsonservers),這會在每種權限模式中封鎖它。809* 將其加入 [`disabledMcpjsonServers`](https://code.claude.com/docs/zh-TW/settings-reference#disabledmcpjsonservers),這會在每種權限模式中封鎖它。

808* 使用 [`--setting-sources`](https://code.claude.com/docs/zh-TW/cli-reference#cli-flags) 或 SDK 的 `settingSources` 選項完全排除專案設定。810* 使用 [`--setting-sources`](https://code.claude.com/docs/zh-TW/cli-reference#cli-flags) 或 SDK 的 `settingSources` 選項完全排除專案設定。

809* 使用 [`--strict-mcp-config`](https://code.claude.com/docs/zh-TW/cli-reference#cli-flags) 啟動工作階段。Claude Code 隨後只會使用您透過 `--mcp-config` 傳入的 MCP 伺服器。對於 Claude Code 未載入的 project 範圍伺服器略過核准提示,需要 Claude Code v2.1.246 或更新版本;在 v2.1.246 之前,strict 工作階段仍會等待這些伺服器的核准,導致背景工作階段在啟動時停滯等待。如需此旗標在受管 MCP 檔案下的作用,請參閱[使用 managed-mcp.json 進行獨佔控制](https://code.claude.com/docs/zh-TW/managed-mcp.md#exclusive-control-with-managed-mcp-json)。811* 使用 [`--strict-mcp-config`](https://code.claude.com/docs/zh-TW/cli-reference#cli-flags) 啟動工作階段。Claude Code 隨後會載入您透過 `--mcp-config` 傳入的伺服器,並略過在 `.mcp.json` 等位置設定的伺服器。對於 Claude Code 未載入的 project 範圍伺服器略過核准提示,需要 Claude Code v2.1.246 或更新版本。如需此旗標在受管 MCP 檔案下的作用,請參閱[使用 managed-mcp.json 進行獨佔控制](https://code.claude.com/docs/zh-TW/managed-mcp.md#exclusive-control-with-managed-mcp-json)。

810 812 

811[Project 伺服器核准與工作區信任](#project-server-approvals-and-workspace-trust)說明提交至儲存庫的核准如何與工作區信任互動。813[Project 伺服器核准與工作區信任](#project-server-approvals-and-workspace-trust)說明提交至儲存庫的核准如何與工作區信任互動。

812 814 

Details

268 268 

269儲存檔案後,在專案中啟動新的 Claude Code 工作階段。Claude Code 在啟動時讀取 `.mcp.json`。269儲存檔案後,在專案中啟動新的 Claude Code 工作階段。Claude Code 在啟動時讀取 `.mcp.json`。

270 270 

271Claude Code 第一次看到專案範圍伺服器時,它會要求您批准它。提示存在是為了讓您複製的儲存庫無法在您同意的情況下在您的機器上啟動程序。批准提示,或如果您錯過了,執行 `/mcp` 稍後批准。271Claude Code 第一次看到專案範圍伺服器時,它會要求您批准它。此提示的存在是為了讓您複製的儲存庫無法在未經您同意的情況下在您的機器上啟動程序。請批准此提示。如果您已將其關閉,請執行 `claude mcp reset-project-choices` 並重新啟動 Claude Code 以再次看到它。

272 272 

273批准後,執行 `/mcp` 並檢查伺服器是否顯示為已連接。如果其中一個顯示錯誤,請參閱[疑難排解](#troubleshooting)。273批准後,執行 `/mcp` 並檢查伺服器是否顯示為已連接。如果其中一個顯示錯誤,請參閱[疑難排解](#troubleshooting)。

274 274 

Details

109 109 

110> [!WARNING]110> [!WARNING]

111>111>

112> 為每個部署固定特定的模型版本。如果不固定版本,模型別名(例如 `sonnet` 和 `opus`)會解析為 Claude Code 針對 Microsoft Foundry 的內建預設值,這可能會落後最新版本,且可能尚未在您的帳戶中提供。Microsoft Foundry 沒有啟動模型檢查,因此當預設值無法使用時,請求會失敗。建立 Azure 部署時,請選擇特定的模型版本,而不是「自動更新至最新版本」。112> 為每個部署固定特定的模型版本。如果不固定版本,模型別名(例如 `sonnet` 和 `opus`)會解析為 Claude Code 針對 Microsoft Foundry 的內建預設值。該預設值可能會落後最新版本,且可能尚未在您的帳戶中提供。

113>

114> 當您的資源沒有該預設值的部署時,Claude Code 會改用較舊的模型,或請求會失敗。切換時會顯示以 `Switched to <fallback> because <model> is not available` 開頭的訊息。建立 Azure 部署時,請選擇特定的模型版本,而不是「自動更新至最新版本」。

113 115 

114設定模型變數以符合您在步驟 1 中建立的部署名稱。116設定模型變數以符合您在步驟 1 中建立的部署名稱。

115 117 


153 155 

154## 1M token 上下文視窗156## 1M token 上下文視窗

155 157 

156在 Microsoft Foundry 上,當 Claude Code 能夠判斷您的部署所提供的模型時,Fable 模型、Sonnet 5 及更新版本,以及 Opus 4.7 及更新版本預設會以 [1M token 上下文視窗](https://platform.claude.com/docs/en/build-with-claude/context-windows#context-window-sizes-by-model)執行,無需加上 `[1m]` 後綴。Claude Code 會從模型變數中的部署名稱讀取模型。請以模型 ID 為每個部署命名,例如 `claude-opus-4-8`,或使用 [`modelOverrides`](https://code.claude.com/docs/zh-TW/model-config#override-model-ids-per-version) 將模型對應到您的部署名稱。對於無法對應到任何模型的部署名稱,Claude Code 會假設為 200K 視窗,除非您[宣告不同的視窗大小](https://code.claude.com/docs/zh-TW/model-config.md#correct-the-window-for-a-gateway-or-custom-model-id)。158在 Microsoft Foundry 上,Fable 模型、Sonnet 5 及更新版本,以及 Opus 4.7 及更新版本預設會以 [1M token 上下文視窗](https://platform.claude.com/docs/en/build-with-claude/context-windows#context-window-sizes-by-model)執行。只要 Claude Code 能夠判斷您的部署所提供的模型,就無需加上 `[1m]` 後綴。

159 

160> [!NOTE]

161>

162> Claude Code 會從模型變數中的部署名稱讀取模型。請以模型 ID 為每個部署命名,例如 `claude-opus-4-8`,或使用 [`modelOverrides`](https://code.claude.com/docs/zh-TW/model-config#override-model-ids-per-version) 將模型對應到您的部署名稱。

157 163 

158以下 `settings.json` 項目會告知 Claude Code,名為 `team-opus-prod` 的部署提供的是 Opus 4.8:164以下 `settings.json` 項目會告知 Claude Code,名為 `team-opus-prod` 的部署提供的是 Opus 4.8:

159 165 


167 173 

168若要改為保留 200K 視窗,請設定 [`CLAUDE_CODE_DISABLE_1M_CONTEXT=1`](https://code.claude.com/docs/zh-TW/model-config#turn-off-1m-context)。174若要改為保留 200K 視窗,請設定 [`CLAUDE_CODE_DISABLE_1M_CONTEXT=1`](https://code.claude.com/docs/zh-TW/model-config#turn-off-1m-context)。

169 175 

176若 Claude Code 無法將部署名稱對應到模型,預設會假設為 1M 視窗,因此若您部署的模型可接受的上下文較少,請[設定實際的視窗大小](https://code.claude.com/docs/zh-TW/model-config.md#correct-the-window-for-a-gateway-or-custom-model-id)。

177 

170當您在 `ANTHROPIC_DEFAULT_OPUS_MODEL` 或 `ANTHROPIC_DEFAULT_SONNET_MODEL` 中的部署名稱後方加上 `[1m]` 時,Opus 4.6 與 Sonnet 4.6 即可使用 1M 視窗,詳見[為第三方部署固定模型](https://code.claude.com/docs/zh-TW/model-config.md#pin-models-for-third-party-deployments)的說明。在 v2.1.287 之前,Fable 模型以及 Opus 4.7 及更新版本在 Microsoft Foundry 上同樣需要該後綴,若未加上則預設以 200K 視窗執行。178當您在 `ANTHROPIC_DEFAULT_OPUS_MODEL` 或 `ANTHROPIC_DEFAULT_SONNET_MODEL` 中的部署名稱後方加上 `[1m]` 時,Opus 4.6 與 Sonnet 4.6 即可使用 1M 視窗,詳見[為第三方部署固定模型](https://code.claude.com/docs/zh-TW/model-config.md#pin-models-for-third-party-deployments)的說明。在 v2.1.287 之前,Fable 模型以及 Opus 4.7 及更新版本在 Microsoft Foundry 上同樣需要該後綴,若未加上則預設以 200K 視窗執行。

171 179 

172## 故障排除180## 故障排除

model-config.md +41 −20

Details

45| :- | :- | :- | :- |45| :- | :- | :- | :- |

46| Anthropic API | Opus 5.5 | Sonnet 5.5 | Haiku 5.5 |46| Anthropic API | Opus 5.5 | Sonnet 5.5 | Haiku 5.5 |

47| [Claude Platform on AWS](https://code.claude.com/docs/zh-TW/claude-platform-on-aws.md) | Opus 5.5 | Sonnet 4.6 | Haiku 4.5 |47| [Claude Platform on AWS](https://code.claude.com/docs/zh-TW/claude-platform-on-aws.md) | Opus 5.5 | Sonnet 4.6 | Haiku 4.5 |

48| [Claude Models on Google Cloud (Anthropic managed)](https://code.claude.com/docs/zh-TW/claude-models-on-google-cloud-anthropic-managed.md) | Opus 5.5 | Sonnet 5.5 | Haiku 4.5 |

48| Amazon Bedrock、Google Cloud's Agent Platform | Opus 5.5 | Sonnet 4.5 | Haiku 4.5 |49| Amazon Bedrock、Google Cloud's Agent Platform | Opus 5.5 | Sonnet 4.5 | Haiku 4.5 |

49| Microsoft Foundry | Opus 4.6 | Sonnet 4.5 | Haiku 4.5 |50| Microsoft Foundry | Opus 4.6 | Sonnet 4.5 | Haiku 4.5 |

50 51 


109提示等待期間您可以執行的操作取決於工作階段:110提示等待期間您可以執行的操作取決於工作階段:

110 111 

111* 在已連線 Remote Control 或在隊員的工作階段中,於終端機按下任意鍵即可取消期限,Claude Code 會等待您的回應。112* 在已連線 Remote Control 或在隊員的工作階段中,於終端機按下任意鍵即可取消期限,Claude Code 會等待您的回應。

113* 在已連線 Remote Control 的互動式終端機工作階段中,您也可以在已連線的裝置上回應,且該回應在該工作階段中持續有效。需要 Claude Code v2.1.323 或更新版本。

112* 在背景工作階段中,請在期限前回應。114* 在背景工作階段中,請在期限前回應。

113* 如果您在任何人於終端機輸入之前從遠端用戶端傳送新訊息,Claude Code 會以相同方式結束該回合,而您的新訊息會開始下一個回合。在有人於終端機輸入之後,Claude Code 會持續等待回應,並將您的新訊息排在其後。115* 如果您在任何人於終端機輸入之前從遠端用戶端傳送新訊息,Claude Code 會以相同方式結束該回合,而您的新訊息會開始下一個回合。在有人於終端機輸入之後,Claude Code 會持續等待回應,並將您的新訊息排在其後。

114 116 


186/model sonnet188/model sonnet

187```189```

188 190 

191> [!NOTE]

192>

193> 根據預設,您在 Anthropic API 上以 Claude Opus 4 或 Opus 4.1 ID(例如 `claude-opus-4-1`)啟動的工作階段,會在 `opus` 所解析到的模型上執行。

194 

189設定檔範例:195設定檔範例:

190 196 

191```json theme={null}197```json theme={null}


273* **`/model`**:Claude Code 會以錯誤拒絕切換279* **`/model`**:Claude Code 會以錯誤拒絕切換

274* **`--model` 旗標、`ANTHROPIC_MODEL` 或 `model` 設定**:Claude Code 會在啟動時替換該值,並顯示同時列出請求模型與替代模型的警告,工作階段會以預設模型啟動280* **`--model` 旗標、`ANTHROPIC_MODEL` 或 `model` 設定**:Claude Code 會在啟動時替換該值,並顯示同時列出請求模型與替代模型的警告,工作階段會以預設模型啟動

275* **[`ANTHROPIC_DEFAULT_MODEL`](#set-a-default-model-for-new-sessions)**:Claude Code 會忽略該變數281* **[`ANTHROPIC_DEFAULT_MODEL`](#set-a-default-model-for-new-sessions)**:Claude Code 會忽略該變數

276* **Subagent 或隊員覆寫**:Claude Code 會以備援模型執行該 subagent 或隊員,而不是讓請求失敗。subagent 的備援請參閱[選擇模型](https://code.claude.com/docs/zh-TW/sub-agents.md#choose-a-model),隊員的備援請參閱[指定隊員與模型](https://code.claude.com/docs/zh-TW/agent-teams.md#specify-teammates-and-models)。282* **Subagent 或隊員覆寫**:Claude Code 會以備援模型執行該 subagent 或隊員,而不是讓請求失敗。subagent 的備援請參閱[當允許清單封鎖 subagent 模型時](https://code.claude.com/docs/zh-TW/sub-agents.md#when-an-allowlist-blocks-a-subagent-model),隊員的備援請參閱[指定隊員與模型](https://code.claude.com/docs/zh-TW/agent-teams.md#specify-teammates-and-models)。

277 283 

278 在互動式工作階段中,當 Claude Code 透過此備援或上述的最新允許版本替代來替換 subagent 的模型時,會向您發出警告,並列出請求的模型與替代的模型;隊員的備援則不會回報。284 在互動式工作階段中,當 Claude Code 替換頂層 subagent 的模型時,會向您發出警告。隊員的備援則不會回報。

279 285 

280 在上述最新允許版本替代適用的情況下,被封鎖的系列別名會改為遵循該替代方式。在 v2.1.222 之前,別名在所有提供者上都會如同其他被封鎖的值一樣改用備援286 在上述最新允許版本替代適用的情況下,被封鎖的系列別名會改為遵循該替代方式。在 v2.1.222 之前,別名在所有提供者上都會如同其他被封鎖的值一樣改用備援

281* **Skill 或命令覆寫**:Claude Code 會忽略該覆寫(包括被封鎖的系列別名),skill 或命令會以工作階段模型執行。[在 subagent 中執行](https://code.claude.com/docs/zh-TW/skills.md#run-skills-in-a-subagent)的 skill 或命令則改為遵循上述的 subagent 行為287* **Skill 或命令覆寫**:Claude Code 會忽略該覆寫(包括被封鎖的系列別名),skill 或命令會以工作階段模型執行。[在 subagent 中執行](https://code.claude.com/docs/zh-TW/skills.md#run-skills-in-a-subagent)的 skill 或命令則改為遵循上述的 subagent 行為


309 315 

310| 傳遞機制 | CLI 與 IDE | Desktop 本機工作階段 | 網頁、行動裝置與雲端工作階段 | Agent SDK 與非互動模式 | Cowork |316| 傳遞機制 | CLI 與 IDE | Desktop 本機工作階段 | 網頁、行動裝置與雲端工作階段 | Agent SDK 與非互動模式 | Cowork |

311| :- | :- | :- | :- | :- | :- |317| :- | :- | :- | :- | :- | :- |

312| 來自管理主控台的[伺服器管理設定](https://code.claude.com/docs/zh-TW/server-managed-settings.md) | 強制執行 | 強制執行 | 強制執行,[Claude Tag](https://claude.com/docs/claude-tag/overview) 工作階段除外 | 強制執行 | 遠端 Cowork 工作階段:由伺服器檢查模型。在使用者的電腦上:不會傳遞。 |318| 來自管理主控台的[伺服器管理設定](https://code.claude.com/docs/zh-TW/server-managed-settings.md) | 強制執行 | 強制執行 | 強制執行,但不會傳遞至 [Claude Tag](https://claude.com/docs/claude-tag/overview) 工作階段,也不會傳遞至[使用 Amazon Bedrock 或 Google Cloud 的 Agent Platform](https://code.claude.com/docs/zh-TW/self-hosted-environments-configuration.md#what-differs-from-sessions-on-the-anthropic-api) 之自行託管 runner 上的工作階段 | 強制執行 | 遠端 Cowork 工作階段:由伺服器檢查模型。在使用者的電腦上:不會傳遞。 |

313| [MDM 或受管設定檔](https://code.claude.com/docs/zh-TW/managed-settings.md#delivery-mechanisms) | 強制執行 | 強制執行 | 在 Anthropic 託管的環境中不會傳遞;在[自行託管的環境](https://code.claude.com/docs/zh-TW/self-hosted-environments)中,依照 [Claude Code 如何合併受管來源](https://code.claude.com/docs/zh-TW/managed-settings.md#how-claude-code-combines-managed-sources)從 runner 映像檔強制執行 | 強制執行 | 在已部署處強制執行 |319| [MDM 或受管設定檔](https://code.claude.com/docs/zh-TW/managed-settings.md#delivery-mechanisms) | 強制執行 | 強制執行 | 在 Anthropic 託管的環境中不會傳遞;在[自行託管的環境](https://code.claude.com/docs/zh-TW/self-hosted-environments)中,依照 [Claude Code 如何合併受管來源](https://code.claude.com/docs/zh-TW/managed-settings.md#how-claude-code-combines-managed-sources)從 runner 映像檔強制執行 | 強制執行 | 在已部署處強制執行 |

314 320 

315* [雲端工作階段](https://code.claude.com/docs/zh-TW/claude-code-on-the-web.md)(包括您從 Desktop 應用程式啟動的工作階段)預設在 Anthropic 管理的 VM 上執行:部署到您裝置上的設定不會傳遞至這些工作階段,因此請透過伺服器管理設定傳遞允許清單。您的組織路由至[自行託管環境](https://code.claude.com/docs/zh-TW/self-hosted-environments)的工作階段會在您自己的運算資源上執行,並且也會讀取 runner 映像檔中的受管設定檔。[Claude Code 如何合併受管來源](https://code.claude.com/docs/zh-TW/managed-settings.md#how-claude-code-combines-managed-sources)說明該檔案何時適用。在雲端工作階段中,若請求的模型被允許清單排除,工作階段中途的模型切換將被拒絕。當您伺服器管理設定中的 `availableModels` 清單不為空時,伺服器會拒絕在 claude.ai/code 或從 Desktop 應用程式以清單所排除的模型啟動雲端工作階段的請求。321* [雲端工作階段](https://code.claude.com/docs/zh-TW/claude-code-on-the-web.md)(包括您從 Desktop 應用程式啟動的工作階段)預設在 Anthropic 管理的 VM 上執行:部署到您裝置上的設定不會傳遞至這些工作階段,因此請透過伺服器管理設定傳遞允許清單。您的組織路由至[自行託管環境](https://code.claude.com/docs/zh-TW/self-hosted-environments)的工作階段會在您自己的運算資源上執行,並且也會讀取 runner 映像檔中的受管設定檔。[Claude Code 如何合併受管來源](https://code.claude.com/docs/zh-TW/managed-settings.md#how-claude-code-combines-managed-sources)說明該檔案何時適用。在雲端工作階段中,若請求的模型被允許清單排除,工作階段中途的模型切換將被拒絕。當您伺服器管理設定中的 `availableModels` 清單不為空時,伺服器會拒絕在 claude.ai/code 或從 Desktop 應用程式以清單所排除的模型啟動雲端工作階段的請求。


481`default` 的行為取決於您的帳戶類型:487`default` 的行為取決於您的帳戶類型:

482 488 

483* **Pro、Max、Ultra、Team、Enterprise 和 Anthropic API**:預設為 Opus 5.5489* **Pro、Max、Ultra、Team、Enterprise 和 Anthropic API**:預設為 Opus 5.5

484* **Claude Platform on AWS、Amazon Bedrock 和 Google Cloud's Agent Platform**:預設為 Opus 5.5490* **Claude Platform on AWS、Claude Models on Google Cloud (Anthropic managed)、Amazon Bedrock 和 Google Cloud's Agent Platform**:預設為 Opus 5.5

485* **Microsoft Foundry**:預設為 Sonnet 4.5491* **Microsoft Foundry**:預設為 Sonnet 4.5

486 492 

487在 v2.1.280 之前,`default` 在 Pro 和 Team Standard 上解析為 Sonnet 5;自 v2.1.219 起,在 Max、Ultra、Team Premium、Enterprise、Anthropic API、Claude Platform on AWS、Amazon Bedrock 和 Google Cloud's Agent Platform 上解析為 Opus 5。在 v2.1.219 之前,自 v2.1.154 起,`default` 在 Anthropic API、Max、Ultra、Team Premium 和 Enterprise 隨用隨付方案上解析為 Opus 4.8;自 v2.1.207 起,在 Claude Platform on AWS、Amazon Bedrock 和 Google Cloud's Agent Platform 上也解析為 Opus 4.8。在 v2.1.207 之前,`default` 在 Claude Platform on AWS 上解析為 Opus 4.7,在 Amazon Bedrock 和 Google Cloud's Agent Platform 上解析為 Sonnet 4.5。493在 v2.1.280 之前,`default` 在 Pro 和 Team Standard 上解析為 Sonnet 5;自 v2.1.219 起,在 Max、Ultra、Team Premium、Enterprise、Anthropic API、Claude Platform on AWS、Amazon Bedrock 和 Google Cloud's Agent Platform 上解析為 Opus 5。在 v2.1.219 之前,自 v2.1.154 起,`default` 在 Anthropic API、Max、Ultra、Team Premium 和 Enterprise 隨用隨付方案上解析為 Opus 4.8;自 v2.1.207 起,在 Claude Platform on AWS、Amazon Bedrock 和 Google Cloud's Agent Platform 上也解析為 Opus 4.8。在 v2.1.207 之前,`default` 在 Claude Platform on AWS 上解析為 Opus 4.7,在 Amazon Bedrock 和 Google Cloud's Agent Platform 上解析為 Sonnet 4.5。


527 533 

528```json theme={null}534```json theme={null}

529{535{

530 "fallbackModel": ["claude-sonnet-5", "claude-haiku-4-5"]536 "fallbackModel": ["claude-sonnet-5", "claude-haiku-5-5"]

531}537}

532```538```

533 539 


535 541 

536Claude Code 在啟動時不會確認模型鏈,`/status` 也不會顯示它。發生切換時顯示的通知,是已設定備援的第一個可見跡象。542Claude Code 在啟動時不會確認模型鏈,`/status` 也不會顯示它。發生切換時顯示的通知,是已設定備援的第一個可見跡象。

537 543 

538當請求進行容錯移轉時,Claude Code 會依序嘗試每個項目,直到其中一個接受請求為止。同樣無法連線的項目(例如在設定中釘選的已淘汰模型)也會以相同方式移轉至下一個項目。Claude Code 會在開始依序嘗試之前移除兩類項目:544#### Claude Code 會嘗試哪些項目

545 

546當請求進行容錯移轉時,Claude Code 會依序嘗試每個項目,直到其中一個接受請求為止。同樣無法連線的項目(例如在設定中釘選的已淘汰模型)也會以相同方式移轉至下一個項目。Claude Code 會在下列情況中略過項目:

539 547 

540* **不在允許清單內**:Claude Code 在讀取模型鏈時,會捨棄任何未被 [`availableModels`](#restrict-model-selection) 允許的項目。548* **不在允許清單內**:Claude Code 在讀取模型鏈時,會捨棄任何未被 [`availableModels`](#restrict-model-selection) 允許的項目。

541* **壓縮期間上下文視窗較小**:模型鏈也涵蓋[壓縮](https://code.claude.com/docs/zh-TW/context-window.md#what-survives-compaction),但 Claude Code 不會改用上下文視窗比主要模型小的模型,因為在那裡進行摘要會先截斷部分對話。如果所有備援模型的視窗都較小,壓縮會顯示原始錯誤,您可以重試。549* **壓縮期間上下文視窗較小**:模型鏈也涵蓋[壓縮](https://code.claude.com/docs/zh-TW/context-window.md#what-survives-compaction),但 Claude Code 不會改用上下文視窗比主要模型小的模型,因為在那裡進行摘要會先截斷部分對話。如果所有備援模型的視窗都較小,壓縮會顯示原始錯誤,您可以重試。

550* **自動模式不支援**:在[自動模式](https://code.claude.com/docs/zh-TW/permission-modes.md#eliminate-prompts-with-auto-mode)中,以及分類器審查命令時的 plan mode 中,Claude Code 會略過自動模式不支援的模型。如果您使用其中任一模式,請納入一個受支援的模型。

542 551 

543Claude Code 也會將模型鏈套用至 [subagent](https://code.claude.com/docs/zh-TW/sub-agents.md)。當 subagent 的請求進行容錯移轉時,Claude Code 會依序嘗試您設定的備援模型,subagent 則會在接受請求的模型上繼續執行。您工作階段的模型不會改變。在 v2.1.247 之前,模型鏈涵蓋的失敗會直接結束 subagent。552Claude Code 也會將模型鏈套用至 [subagent](https://code.claude.com/docs/zh-TW/sub-agents.md)。當 subagent 的請求進行容錯移轉時,Claude Code 會依序嘗試您設定的備援模型,subagent 則會在接受請求的模型上繼續執行。您工作階段的模型不會改變。在 v2.1.247 之前,模型鏈涵蓋的失敗會直接結束 subagent。

544 553 


714 723 

715在提示詞中的任何位置加入 `ultrathink`,即可在該回合請求更深入的推理,而不變更工作階段的 effort 設定。Claude Code 會辨識此關鍵字並加入上下文內的指示。Claude Code 會將其他片語(例如「think」、「think hard」和「think more」)當作一般提示詞文字傳遞,不會將其辨識為關鍵字。724在提示詞中的任何位置加入 `ultrathink`,即可在該回合請求更深入的推理,而不變更工作階段的 effort 設定。Claude Code 會辨識此關鍵字並加入上下文內的指示。Claude Code 會將其他片語(例如「think」、「think hard」和「think more」)當作一般提示詞文字傳遞,不會將其辨識為關鍵字。

716 725 

717在終端機提示詞中輸入時,此字詞也可以將該回合提高至 `xhigh` effort。當它可以這麼做時,此字詞會以彩虹色顯示。需要 Claude Code v2.1.311 或更新版本。如果您開始新回合時此字詞未以彩虹色顯示,請嘗試下列其中一項:726若也要將該回合提高至 `xhigh` effort,請在下列其中一個位置輸入此字詞:

727 

728* 終端機提示詞,當此字詞可以提高該回合等級時,會以彩虹色顯示。需要 Claude Code v2.1.311 或更新版本。

729* VS Code 的聊天框,此字詞在此同樣會以彩虹色顯示。需要 Claude Code v2.1.316 或更新版本。

730* 桌面應用程式 Code 分頁中的本機工作階段。需要 Claude Code v2.1.316 或更新版本。

731 

732如果您開始新回合時此字詞未以彩虹色顯示,請嘗試下列其中一項:

718 733 

719* 在不以 `/` 開頭的提示詞中,於引號、括號、路徑或命令等任何內容之外重新輸入它734* 在不以 `/` 開頭的提示詞中,於引號、括號、路徑或命令等任何內容之外重新輸入它

720* 如果 `CLAUDE_CODE_EFFORT_LEVEL` 設定為低於 `xhigh`,請取消設定它。或者將您自己的 [`maxEffortLevel`](https://code.claude.com/docs/zh-TW/settings-reference#maxeffortlevel) 提高至 `xhigh` 或以上,或請組織管理員提高您的[組織限制](#organization-effort-limits)735* 如果 `CLAUDE_CODE_EFFORT_LEVEL` 設定為低於 `xhigh`,請取消設定它。或者將您自己的 [`maxEffortLevel`](https://code.claude.com/docs/zh-TW/settings-reference#maxeffortlevel) 提高至 `xhigh` 或以上,或請組織管理員提高您的[組織限制](#organization-effort-limits)

721* 在工作階段中執行 `/model` 以切換至 Opus 5.5、Sonnet 5.5、Haiku 5.5、Fable 5.2 或 Fable 5.1 模型。在此字詞無法提高回合等級的情況下(例如在 Amazon Bedrock 上),請改為[設定 effort 等級](#set-the-effort-level)736* 在工作階段中執行 `/model` 以切換至 Opus 5.5、Sonnet 5.5、Haiku 5.5、Fable 5.2 或 Fable 5.1 模型。在此字詞無法提高回合等級的情況下(例如在 Amazon Bedrock、Google Cloud's Agent Platform 或 [Claude apps gateway](https://code.claude.com/docs/zh-TW/claude-apps-gateway) 上),請改為[設定 effort 等級](#set-the-effort-level)

737 

738若要關閉此關鍵字(包括其上下文內的指示),請在您的 shell 或[設定檔](https://code.claude.com/docs/zh-TW/env-vars.md#in-settings-files)中將 `CLAUDE_CODE_DISABLE_ULTRATHINK` 設為 `1`。需要 Claude Code v2.1.316 或更新版本。

722 739 

723#### 設定 effort 等級740#### 設定 effort 等級

724 741 


905 922 

906### 為閘道或自訂模型 ID 修正視窗923### 為閘道或自訂模型 ID 修正視窗

907 924 

908出現下列任一警告,都表示 Claude Code 無法辨識您工作階段的模型 ID,因此無法得知該模型的上下文視窗,並假定其為 200K token:925出現下列任一警告,都表示 Claude Code 無法辨識您工作階段的模型 ID,並假定其上下文視窗為警告中所指出的大小:

909 926 

910```text theme={null}927```text theme={null}

911⚠ Model "my-gateway-opus" isn't recognized · context assumed to be 200k tokens · ...928⚠ Model "my-gateway-opus" isn't recognized · context assumed to be 1m tokens · ...

912Claude Code doesn't recognize the model "my-gateway-opus", so it assumes a context window of 200k tokens. Update Claude Code, or see https://code.claude.com/docs/en/model-config#correct-the-window-for-a-gateway-or-custom-model-id to set the window.929Claude Code doesn't recognize the model "my-gateway-opus", so it assumes a context window of 1m tokens. Update Claude Code, or see https://code.claude.com/docs/en/model-config#correct-the-window-for-a-gateway-or-custom-model-id to set the window.

913```930```

914 931 

915Claude Code 會在假定的 200K [自動壓縮](#default-auto-compact-thresholds)對話,因此若模型的實際上下文視窗為 200K,就不需要修正。否則,請依您的 ID 選擇下列適合的方式,將實際視窗告知 Claude Code:932Claude Code 會[自動壓縮](#default-auto-compact-thresholds)對話以符合假定的視窗,因此若警告中指出的正是模型的實際上下文視窗,就不需要修正。否則,請將實際視窗告知 Claude Code:

916 933 

917* **比您的 Claude Code 版本更新的模型**:在 shell 中執行 `claude update`。若更新後 Claude Code 能辨識該 ID,您就不需要再設定其他項目。934* **比您的 Claude Code 版本更新的模型**:在 shell 中執行 `claude update`。若更新後 Claude Code 能辨識該 ID,您就不需要再設定其他項目。

918* **您的閘道或供應商為 Claude Code 已知模型所使用的名稱**:新增 [`modelOverrides`](#override-model-ids-per-version) 項目,將 Anthropic 模型 ID 對應至您的 ID,例如 `"claude-opus-4-8": "my-gateway-opus"`。您也可以改為在 [`modelPicker`](https://code.claude.com/docs/zh-TW/settings-reference#fields-for-modelpicker) 列中列出您的 ID,並將 `behavesAs` 設為該模型。無論採用哪種方式,Claude Code 之後都會將該 ID 視為該模型。935* **您的閘道或供應商為 Claude Code 已知模型所使用的名稱**:新增 [`modelOverrides`](#override-model-ids-per-version) 項目,將 Anthropic 模型 ID 對應至您的 ID,例如 `"claude-opus-4-8": "my-gateway-opus"`。您也可以改為在 [`modelPicker`](https://code.claude.com/docs/zh-TW/settings-reference#fields-for-modelpicker) 列中列出您的 ID,並將 `behavesAs` 設為該模型。無論採用哪種方式,Claude Code 之後都會將該 ID 視為該模型。


925 942 

926在 [LLM 閘道](https://code.claude.com/docs/zh-TW/llm-gateway)或其他自訂部署上,無論 Claude Code 是否將模型 ID 解析為 Claude 模型,它為該 ID 假定的上下文視窗都可能與模型的實際視窗不同。請將 [`CLAUDE_CODE_MAX_CONTEXT_TOKENS`](https://code.claude.com/docs/zh-TW/env-vars) 設為 Claude Code 應改為假定的視窗。943在 [LLM 閘道](https://code.claude.com/docs/zh-TW/llm-gateway)或其他自訂部署上,無論 Claude Code 是否將模型 ID 解析為 Claude 模型,它為該 ID 假定的上下文視窗都可能與模型的實際視窗不同。請將 [`CLAUDE_CODE_MAX_CONTEXT_TOKENS`](https://code.claude.com/docs/zh-TW/env-vars) 設為 Claude Code 應改為假定的視窗。

927 944 

928此變數如何套用取決於 ID。當 ID 不以 `claude-` 開頭(不分大小寫),或帶有 Claude Code 在讀取 ID 時會去除的後綴(例如 Google Cloud 的 Agent Platform 上使用的 `@YYYYMMDD` 日期)時,Claude Code 會將其視為供應商或自訂拼寫。在 v2.1.259 之前,Claude Code 不會計入被去除的後綴,因此帶有日期後綴且無法辨識的 `claude-` ID 會被視為單純的 `claude-` 名稱。945此變數對於無法辨識的 ID、帶有 `[1m]` 的無法辨識 ID,以及 Claude Code 可辨識的 ID,運作方式各不相同:

929 

930無法辨識的供應商或自訂拼寫、帶有 `[1m]` 的相同拼寫,以及其他所有 ID,是三種不同的情況:

931 946 

932* 若 Claude Code 無法將供應商或自訂拼寫解析為其可辨識的模型,且 ID 不包含 `[1m]`,則此變數會直接套用,主動壓縮會在宣告的視窗繼續進行。947* 若 Claude Code 無法辨識該 ID,且 ID 不包含 `[1m]`,則此變數會直接套用,主動壓縮會在宣告的視窗繼續進行。對於 `claude-sonnet-latest` 之類的 ID,這需要 Claude Code v2.1.324 或更新版本。

933* 若 Claude Code 無法將供應商或自訂拼寫解析為其可辨識的模型,且 ID 包含 `[1m]`(不分大小寫),Claude Code 會為其假定 1M 視窗,此變數單獨設定時不會套用。若要在保留主動壓縮的同時修正視窗,請一併設定 [`CLAUDE_CODE_DISABLE_1M_CONTEXT=1`](https://code.claude.com/docs/zh-TW/env-vars)。設定該變數後,Claude Code 會將此 ID 的大小視同不含 `[1m]` 的相同拼寫,因此 `CLAUDE_CODE_MAX_CONTEXT_TOKENS` 會在其適用於該未標記拼寫時套用。948* 若 Claude Code 無法辨識該 ID,且 ID 包含 `[1m]`(不分大小寫),Claude Code 會為其假定 1M 視窗。此變數中低於 1M 的值單獨設定時不會套用。若要在保留主動壓縮的同時修正視窗,請一併設定 [`CLAUDE_CODE_DISABLE_1M_CONTEXT=1`](https://code.claude.com/docs/zh-TW/env-vars)。設定該變數後,Claude Code 會將此 ID 的大小視同不含 `[1m]` 的相同 ID,因此 `CLAUDE_CODE_MAX_CONTEXT_TOKENS` 會套用。

934 949 

935 當宣告的視窗超過 200K 時,在此設定下出現[200K 限制未被強制執行](https://code.claude.com/docs/zh-TW/errors.md#the-200k-limit-isnt-enforced)的警告是預期的行為。950 當宣告的視窗超過 200K 時,在此設定下出現[200K 限制未被強制執行](https://code.claude.com/docs/zh-TW/errors.md#the-200k-limit-isnt-enforced)的警告是預期的行為。

936* 若 ID 解析為 Claude Code 可辨識的模型,或 ID 是沒有可供 Claude Code 去除之後綴的單純 `claude-` 名稱(不分大小寫),則只有在您同時設定 [`DISABLE_COMPACT`](https://code.claude.com/docs/zh-TW/env-vars)(此設定會停用所有壓縮)時,此變數才會生效。951* 若 ID 解析為 Claude Code 可辨識的模型,則只有在您同時設定 [`DISABLE_COMPACT`](https://code.claude.com/docs/zh-TW/env-vars)(此設定會停用所有壓縮)時,此變數才會生效。

937 952 

938 例如,包含 Claude Code 已知之 Claude 模型名稱的 ID,例如 `anthropic/claude-opus-4-8`、`us.anthropic.claude-…-v1:0` 或帶日期的 `claude-sonnet-4-5@20250929`,會解析為該模型。這也包括同時包含 `[1m]` 的 ID:即使設定了 `CLAUDE_CODE_DISABLE_1M_CONTEXT`,Claude Code 仍會將 `claude-opus-4-8[1m]` 解析為 Opus 4.8。953 例如,包含 Claude Code 已知之 Claude 模型名稱的 ID,例如 `anthropic/claude-opus-4-8`、`us.anthropic.claude-…-v1:0` 或帶日期的 `claude-sonnet-4-5@20250929`,會解析為該模型。這也包括同時包含 `[1m]` 的 ID:即使設定了 `CLAUDE_CODE_DISABLE_1M_CONTEXT`,Claude Code 仍會將 `claude-opus-4-8[1m]` 解析為 Opus 4.8。

939 954 


994 1009 

995透過 [Amazon Bedrock](https://code.claude.com/docs/zh-TW/amazon-bedrock.md)、[Google Cloud's Agent Platform](https://code.claude.com/docs/zh-TW/google-vertex-ai.md)、[Microsoft Foundry](https://code.claude.com/docs/zh-TW/microsoft-foundry.md) 或 [Claude Platform on AWS](https://code.claude.com/docs/zh-TW/claude-platform-on-aws.md) 部署 Claude Code 時,請在推出給使用者之前固定模型版本。1010透過 [Amazon Bedrock](https://code.claude.com/docs/zh-TW/amazon-bedrock.md)、[Google Cloud's Agent Platform](https://code.claude.com/docs/zh-TW/google-vertex-ai.md)、[Microsoft Foundry](https://code.claude.com/docs/zh-TW/microsoft-foundry.md) 或 [Claude Platform on AWS](https://code.claude.com/docs/zh-TW/claude-platform-on-aws.md) 部署 Claude Code 時,請在推出給使用者之前固定模型版本。

996 1011 

997若未固定,Claude Code 會使用 `fable`、`opus`、`sonnet` 和 `haiku` 等模型別名,這些別名會解析為各供應商的內建預設模型 ID。該預設值可能落後於 Anthropic 的最新版本,且其指向的模型可能尚未在使用者的帳戶中啟用。當預設模型無法使用時,Amazon Bedrock 和 Google Cloud's Agent Platform 使用者會看到通知,工作階段會改用較早版本的預設模型;若預設模型為 Opus 模型且沒有可用的 Opus 版本,則會改用預設的 Sonnet 模型。Microsoft Foundry 使用者則會看到錯誤,因為 Microsoft Foundry 沒有對等的啟動檢查。1012若未固定,Claude Code 會使用 `fable`、`opus`、`sonnet` 和 `haiku` 等模型別名,這些別名會解析為各供應商的內建預設模型 ID。該預設值可能落後於 Anthropic 的最新版本,且其指向的模型可能尚未在使用者的帳戶中啟用。當預設模型無法使用時:

1013 

1014* **Amazon Bedrock 和 Google Cloud's Agent Platform**:經過[啟動檢查](https://code.claude.com/docs/zh-TW/amazon-bedrock.md#startup-model-checks)後,使用者會看到通知,工作階段會改用較早版本的預設模型。若預設模型為 Opus 模型且沒有可用的 Opus 版本,工作階段會改用預設的 Sonnet 模型。

1015* **Microsoft Foundry**:Claude Code 會切換至較舊的模型,或請求失敗。

998 1016 

999在 Amazon Bedrock 和 Google Cloud's Agent Platform 上,若使用者以特定的 Sonnet 或 Opus 版本啟動工作階段(例如透過 `--model`、`ANTHROPIC_MODEL` 或 `model` 設定),該版本會被固定為對應別名在該工作階段中的預設值:啟動檢查會略過被其取代的內建預設值,且不會顯示備援通知。在 v2.1.211 之前,即使已明確設定工作階段模型,檢查仍會執行並可能顯示通知。1017在 Amazon Bedrock 和 Google Cloud's Agent Platform 上,若使用者以特定的 Sonnet 或 Opus 版本啟動工作階段(例如透過 `--model`、`ANTHROPIC_MODEL` 或 `model` 設定),該版本會被固定為對應別名在該工作階段中的預設值:啟動檢查會略過被其取代的內建預設值,且不會顯示備援通知。在 v2.1.211 之前,即使已明確設定工作階段模型,檢查仍會執行並可能顯示通知。

1000 1018 


1012 1030 

1013對 `ANTHROPIC_DEFAULT_FABLE_MODEL`、`ANTHROPIC_DEFAULT_SONNET_MODEL` 和 `ANTHROPIC_DEFAULT_HAIKU_MODEL` 套用相同的模式。如需所有供應商目前與舊版的模型 ID,請參閱[模型概覽](https://platform.claude.com/docs/en/about-claude/models/overview)。若要將使用者升級至新的模型版本,請更新這些環境變數並重新部署。1031對 `ANTHROPIC_DEFAULT_FABLE_MODEL`、`ANTHROPIC_DEFAULT_SONNET_MODEL` 和 `ANTHROPIC_DEFAULT_HAIKU_MODEL` 套用相同的模式。如需所有供應商目前與舊版的模型 ID,請參閱[模型概覽](https://platform.claude.com/docs/en/about-claude/models/overview)。若要將使用者升級至新的模型版本,請更新這些環境變數並重新部署。

1014 1032 

1015具有原生 1M 視窗的固定模型(例如 Opus 4.8 或 Sonnet 5),在 Claude Code 能將固定的 ID 對應到該模型時,無需任何後綴即可以 [1M 上下文視窗](#extended-context)執行。當 ID 包含該模型的 Anthropic API ID(例如 `us.anthropic.claude-opus-4-8` 包含 `claude-opus-4-8`),或有 [`modelOverrides`](#override-model-ids-per-version) 項目將該模型對應到此 ID 時,即視為相符。對於 Claude Code 無法對應到任何模型的固定 ID,除非該 ID 帶有 `[1m]` 後綴,否則工作階段預設會以 200K 視窗執行。1033在下列情況中,Claude Code 預設會將固定的 ID 視為具有 [1M 上下文視窗](#extended-context),無需加上 `[1m]` 後綴:

1034 

1035* **Claude Code 能對應到具有原生 1M 視窗之模型的 ID,例如 Opus 4.8 或 Sonnet 5**:當 ID 包含該模型的 Anthropic API ID(例如 `us.anthropic.claude-opus-4-8` 包含 `claude-opus-4-8`),或有 [`modelOverrides`](#override-model-ids-per-version) 項目將該模型對應到此 ID 時,即視為相符

1036* **Claude Code 無法對應到任何模型的 ID**:若該 ID 背後的模型接受的上下文較小,請[設定實際的視窗大小](#correct-the-window-for-a-gateway-or-custom-model-id)

1016 1037 

1017對於透過其 `[1m]` 變體達到 1M 的模型(例如 Opus 4.6 或 Sonnet 4.6),請在 `ANTHROPIC_DEFAULT_OPUS_MODEL` 或 `ANTHROPIC_DEFAULT_SONNET_MODEL` 中的模型 ID 後方附加 `[1m]` 以啟用延伸上下文:1038對於透過其 `[1m]` 變體達到 1M 的模型(例如 Opus 4.6 或 Sonnet 4.6),請在 `ANTHROPIC_DEFAULT_OPUS_MODEL` 或 `ANTHROPIC_DEFAULT_SONNET_MODEL` 中的模型 ID 後方附加 `[1m]` 以啟用延伸上下文:

1018 1039 

Details

476* **您在執行 Desktop 的電腦上設定了它**:Desktop 不會將您在那裡設定的值傳遞給 SSH 工作階段476* **您在執行 Desktop 的電腦上設定了它**:Desktop 不會將您在那裡設定的值傳遞給 SSH 工作階段

477* **您在 `/etc/profile` 或其他只有登入 shell 才會讀取的檔案中匯出了它**:當您從登入 shell 執行 `claude` 時名稱會送達,但在 Desktop SSH 工作階段中則不會。Desktop 不會透過登入 shell 啟動 Claude Code。請改為在遠端機器上的[受管設定檔](https://code.claude.com/docs/zh-TW/desktop.md#managed-settings)中,於 `env` 下設定此變數。477* **您在 `/etc/profile` 或其他只有登入 shell 才會讀取的檔案中匯出了它**:當您從登入 shell 執行 `claude` 時名稱會送達,但在 Desktop SSH 工作階段中則不會。Desktop 不會透過登入 shell 啟動 Claude Code。請改為在遠端機器上的[受管設定檔](https://code.claude.com/docs/zh-TW/desktop.md#managed-settings)中,於 `env` 下設定此變數。

478* **某個值中含有空格**:此時 Claude Code 不會將任何鍵複製到事件或資料點上。若要查看哪個值含有空格,請在遠端機器上的工作階段中執行 `/status`。[移除值中的空格](#multi-team-organization-support)。478* **某個值中含有空格**:此時 Claude Code 不會將任何鍵複製到事件或資料點上。若要查看哪個值含有空格,請在遠端機器上的工作階段中執行 `/status`。[移除值中的空格](#multi-team-organization-support)。

479* **已有其他來源設定了此變數**:在桌面應用程式啟動的工作階段中,啟動環境中已設定的變數[優先於設定檔](https://code.claude.com/docs/zh-TW/settings-reference.md#how-env-values-interact-with-your-shell)。[除錯日誌](https://code.claude.com/docs/zh-TW/debug-your-config.md)會列出每個被忽略的變數。當第三方 Desktop 部署在其提供的環境中[指定 OTLP 端點](#how-managed-settings-lock-the-otlp-destination)時,該環境會攜帶 Desktop 自己的 `OTEL_RESOURCE_ATTRIBUTES`。479* **已有其他來源設定了此變數**:在桌面應用程式啟動的工作階段中,啟動環境中已設定的變數[優先於設定檔](https://code.claude.com/docs/zh-TW/settings-reference.md#how-env-values-interact-with-your-shell)。[除錯日誌](https://code.claude.com/docs/zh-TW/debug-your-config.md)可能會指出被忽略的變數。當第三方 Desktop 部署在其提供的環境中[指定 OTLP 端點](#how-managed-settings-lock-the-otlp-destination)時,該環境會攜帶 Desktop 自己的 `OTEL_RESOURCE_ATTRIBUTES`。

480 480 

481### 設定範例481### 設定範例

482 482 


703 703 

704* 所有[標準屬性](#standard-attributes)704* 所有[標準屬性](#standard-attributes)

705* `model`:模型識別碼(例如 "claude-sonnet-5")705* `model`:模型識別碼(例如 "claude-sonnet-5")

706* `query_source`:發出請求之子系統的類別。為 `"main"`、`"subagent"` 或 `"auxiliary"` 之一706* `query_source`:發出請求之子系統的類別。為 `"main"`、`"subagent"`、`"auxiliary"`、`"plugin_model_complete"` 或 `"plugin_model_classify"` 其中之一。最後兩者標示 [mod](https://code.claude.com/docs/zh-TW/plugins/mods/overview.md) 透過 `$.model.complete` 或 `$.model.classify` 發出的請求。Claude Code 從 v2.1.324 起計入這些請求,因此升級後總數可能會上升。

707* `speed`:請求使用快速模式時為 `"fast"`。否則不存在707* `speed`:請求使用快速模式時為 `"fast"`。否則不存在

708* `effort`:套用於請求的 [effort 等級](https://code.claude.com/docs/zh-TW/model-config.md#adjust-effort-level):`"low"`、`"medium"`、`"high"`、`"xhigh"` 或 `"max"`。當 Claude Code 未傳送 effort 等級時不存在,例如在不支援 effort 的模型上。708* `effort`:套用於請求的 [effort 等級](https://code.claude.com/docs/zh-TW/model-config.md#adjust-effort-level):`"low"`、`"medium"`、`"high"`、`"xhigh"` 或 `"max"`。當 Claude Code 未傳送 effort 等級時不存在,例如在不支援 effort 的模型上。

709* `agent.name`:發出請求的 subagent 類型。內建 agent 名稱與來自官方市集外掛的 agent 會原樣顯示。其他使用者定義的 agent 名稱會被替換為 `"custom"`。當請求並非由具名的 subagent 類型發出時不存在。709* `agent.name`:發出請求的 subagent 類型。內建 agent 名稱與來自官方市集外掛的 agent 會原樣顯示。其他使用者定義的 agent 名稱會被替換為 `"custom"`。當請求並非由具名的 subagent 類型發出時不存在。

710* `skill.name`:請求當下啟用的 skill,由 Skill 工具或 `/` 命令設定,或由產生的 subagent 繼承。內建、隨附、使用者定義以及官方市集外掛的 skill 名稱會原樣顯示。第三方外掛的 skill 名稱會被替換為 `"third-party"`。沒有啟用的 skill 時不存在。710* `skill.name`:請求當下啟用的 skill,由 Skill 工具或 `/` 命令設定,或由產生的 subagent 繼承。內建、隨附、使用者定義以及官方市集外掛的 skill 名稱會原樣顯示。第三方外掛的 skill 名稱會被替換為 `"third-party"`。沒有啟用的 skill 時不存在。

711* `plugin.name`:當啟用的 skill 或 subagent 由外掛提供時,為所屬的外掛。官方市集外掛名稱會原樣顯示。第三方外掛名稱會被替換為 `"third-party"`。當 skill 與 subagent 都沒有所屬外掛時不存在。711* `plugin.name`:當作用中的 skill 或 subagent 由外掛提供時的所屬外掛,或其 `$.model` 呼叫發出該請求的外掛。官方市集外掛名稱會原樣顯示。第三方外掛名稱會被替換為 `"third-party"`。其他請求則不存在。

712* `marketplace.name`:所屬外掛的安裝來源市集。即使設定了 `OTEL_LOG_TOOL_DETAILS=1`,也只會針對官方市集外掛發出。否則不存在。712* `marketplace.name`:所屬外掛的安裝來源市集。即使設定了 `OTEL_LOG_TOOL_DETAILS=1`,也只會針對官方市集外掛發出。否則不存在。

713* `mcp_server.name`:此請求所使用之工具結果的 MCP 伺服器。內建、經 claude.ai 代理以及官方登錄的伺服器名稱會原樣顯示。使用者設定的伺服器名稱會被替換為 `"custom"`。當請求未使用任何 MCP 工具結果時不存在。在 v2.1.222 之前,Claude Code 會在 MCP 工具呼叫之後的每個請求上設定此屬性,而不僅限於使用了工具結果的請求,因此彙總此屬性的儀表板在您升級後會顯示下降。713* `mcp_server.name`:此請求所使用之工具結果的 MCP 伺服器。內建、經 claude.ai 代理以及官方登錄的伺服器名稱會原樣顯示。使用者設定的伺服器名稱會被替換為 `"custom"`。當請求未使用任何 MCP 工具結果時不存在。在 v2.1.222 之前,Claude Code 會在 MCP 工具呼叫之後的每個請求上設定此屬性,而不僅限於使用了工具結果的請求,因此彙總此屬性的儀表板在您升級後會顯示下降。

714 * 從 v2.1.312 起,由 Anthropic 官方市集外掛所宣告、具有固定 URL 之遠端伺服器的名稱也會原樣顯示,格式為 `plugin_<plugin>_<server>`。當該外掛的市集副本並非來自 Anthropic 的註冊來源時(例如在雲端工作階段中從種子目錄掛載的副本),該名稱會被替換為 `"custom"`。714 * 從 v2.1.312 起,由 Anthropic 官方市集外掛所宣告、具有固定 URL 之遠端伺服器的名稱也會原樣顯示,格式為 `plugin_<plugin>_<server>`。當該外掛的市集副本並非來自 Anthropic 的註冊來源時(例如在雲端工作階段中從種子目錄掛載的副本),該名稱會被替換為 `"custom"`。


723* 所有[標準屬性](#standard-attributes)723* 所有[標準屬性](#standard-attributes)

724* `type`:(`"input"`、`"output"`、`"cacheRead"`、`"cacheCreation"`)。`"input"` 類型不包含從提示快取讀取或寫入的 token,這些 token 會計入 `"cacheRead"` 與 `"cacheCreation"`。`"cacheCreation"` 類型會將五分鐘與一小時[快取存留時間](https://code.claude.com/docs/zh-TW/prompt-caching.md#cache-lifetime)的快取寫入合併計算。724* `type`:(`"input"`、`"output"`、`"cacheRead"`、`"cacheCreation"`)。`"input"` 類型不包含從提示快取讀取或寫入的 token,這些 token 會計入 `"cacheRead"` 與 `"cacheCreation"`。`"cacheCreation"` 類型會將五分鐘與一小時[快取存留時間](https://code.claude.com/docs/zh-TW/prompt-caching.md#cache-lifetime)的快取寫入合併計算。

725* `model`:模型識別碼(例如 "claude-sonnet-5")725* `model`:模型識別碼(例如 "claude-sonnet-5")

726* `query_source`:發出請求之子系統的類別。為 `"main"`、`"subagent"` 或 `"auxiliary"` 之一726* `query_source`:發出請求之子系統的類別。其值請參閱[費用計數器](#cost-counter)。

727* `speed`:請求使用快速模式時為 `"fast"`。否則不存在727* `speed`:請求使用快速模式時為 `"fast"`。否則不存在

728* `effort`:套用於請求的 [effort 等級](https://code.claude.com/docs/zh-TW/model-config.md#adjust-effort-level)。詳細資訊請參閱[費用計數器](#cost-counter)。728* `effort`:套用於請求的 [effort 等級](https://code.claude.com/docs/zh-TW/model-config.md#adjust-effort-level)。詳細資訊請參閱[費用計數器](#cost-counter)。

729* `agent.name`、`skill.name`、`plugin.name`、`marketplace.name`、`mcp_server.name`、`mcp_tool.name`:請求的 skill、外掛、agent 與 MCP 歸屬。定義與遮蔽行為請參閱[費用計數器](#cost-counter)。729* `agent.name`、`skill.name`、`plugin.name`、`marketplace.name`、`mcp_server.name`、`mcp_tool.name`:請求的 skill、外掛、agent 與 MCP 歸屬。定義與遮蔽行為請參閱[費用計數器](#cost-counter)。


872* `speed`:`"fast"` 或 `"normal"`,表示快速模式是否啟用872* `speed`:`"fast"` 或 `"normal"`,表示快速模式是否啟用

873* `query_source`:發出請求的子系統,例如 `"repl_main_thread"`、`"compact"` 或 subagent 名稱873* `query_source`:發出請求的子系統,例如 `"repl_main_thread"`、`"compact"` 或 subagent 名稱

874* `effort`:套用於請求的 [effort 等級](https://code.claude.com/docs/zh-TW/model-config.md#adjust-effort-level):`"low"`、`"medium"`、`"high"`、`"xhigh"` 或 `"max"`。當 Claude Code 未傳送 effort 等級時不存在,例如在不支援 effort 的模型上。874* `effort`:套用於請求的 [effort 等級](https://code.claude.com/docs/zh-TW/model-config.md#adjust-effort-level):`"low"`、`"medium"`、`"high"`、`"xhigh"` 或 `"max"`。當 Claude Code 未傳送 effort 等級時不存在,例如在不支援 effort 的模型上。

875* `agent.name`、`skill.name`、`plugin.name`、`marketplace.name`、`mcp_server.name`、`mcp_tool.name`:請求的 skill、外掛、agent 與 MCP 歸屬。定義與遮蔽行為請參閱[費用計數器](#cost-counter)。875* `agent.name`、`skill.name`、`plugin.name`、`marketplace.name`、`mcp_server.name`、`mcp_tool.name`:請求的 skill、外掛、agent 與 MCP 歸屬。定義與遮蔽行為請參閱[成本計數器](#cost-counter)。當來自官方市集與內建套件以外的 [mod](https://code.claude.com/docs/zh-TW/plugins/mods/overview.md) 呼叫 [`$.model`](https://code.claude.com/docs/zh-TW/plugins/mods/api#call-a-model) 時,也會出現 `marketplace.name`,並遮蔽為 `"third-party"`,除非您設定了 `OTEL_LOG_TOOL_DETAILS=1`。

876 876 

877#### API 錯誤事件877#### API 錯誤事件

878 878 


896* `speed`:`"fast"` 或 `"normal"`,表示快速模式是否啟用896* `speed`:`"fast"` 或 `"normal"`,表示快速模式是否啟用

897* `query_source`:發出請求的子系統,例如 `"repl_main_thread"`、`"compact"` 或 subagent 名稱897* `query_source`:發出請求的子系統,例如 `"repl_main_thread"`、`"compact"` 或 subagent 名稱

898* `effort`:套用於請求的 [effort 等級](https://code.claude.com/docs/zh-TW/model-config.md#adjust-effort-level)。當 Claude Code 未傳送 effort 等級時不存在,例如在不支援 effort 的模型上。898* `effort`:套用於請求的 [effort 等級](https://code.claude.com/docs/zh-TW/model-config.md#adjust-effort-level)。當 Claude Code 未傳送 effort 等級時不存在,例如在不支援 effort 的模型上。

899* `agent.name`、`skill.name`、`plugin.name`、`marketplace.name`、`mcp_server.name`、`mcp_tool.name`:請求的 skill、外掛、agent 與 MCP 歸屬。定義與遮蔽行為請參閱[費用計數器](#cost-counter)。899* `agent.name`、`skill.name`、`plugin.name`、`marketplace.name`、`mcp_server.name`、`mcp_tool.name`:請求的 skill、外掛、agent 與 MCP 歸屬。定義與遮蔽行為請參閱[成本計數器](#cost-counter)。關於 mod 之 `$.model` 呼叫上的 `marketplace.name`,請參閱 [`api_request`](#api-request-event)。

900 900 

901#### API 拒絕事件901#### API 拒絕事件

902 902 

Details

6 6 

7> 為企業環境設定 Claude Code,包括代理伺服器、自訂憑證授權單位 (CA) 和相互傳輸層安全性 (mTLS) 驗證。7> 為企業環境設定 Claude Code,包括代理伺服器、自訂憑證授權單位 (CA) 和相互傳輸層安全性 (mTLS) 驗證。

8 8 

9Claude Code 透過環境變數支援各種企業網路和安全設定。這包括透過公司代理伺服器路由流量、信任自訂憑證授權單位 (CA),以及使用相互傳輸層安全性 (mTLS) 憑證進行驗證以增強安全性。9Claude Code 透過環境變數支援各種企業網路和安全設定。

10 10 

11在啟動 Claude Code 之前,請設定這些環境變數。在您的 shell 中匯出的變數只會在啟動時讀取一次,因此執行中的工作階段不會取得您 shell 環境的後續變更。11在啟動 Claude Code 之前,請設定這些環境變數。在您的 shell 中匯出的變數只會在啟動時讀取一次,因此執行中的工作階段不會取得您 shell 環境的後續變更。

12 12 


14>14>

15> 本頁面顯示的所有環境變數也可以在 [`settings.json`](https://code.claude.com/docs/zh-TW/settings) 中設定。15> 本頁面顯示的所有環境變數也可以在 [`settings.json`](https://code.claude.com/docs/zh-TW/settings) 中設定。

16 16 

17當您[登入遠端 MCP 伺服器](https://code.claude.com/docs/zh-TW/mcp.md#authenticate-with-remote-mcp-servers)時,Claude Code 會將您的[代理伺服器](#proxy-configuration)、[CA](#custom-ca-certificates) 和[用戶端憑證](#mtls-authentication)變數套用至其傳送的登入請求。若使用 [`claude mcp login`](https://code.claude.com/docs/zh-TW/mcp#authenticate-from-the-command-line),請在您的 shell、`~/.claude/settings.json` 或[受管設定檔](https://code.claude.com/docs/zh-TW/managed-settings.md#deploy-a-managed-settings-file)中設定這些變數,而非在專案或本機設定中設定。

18 

17## 代理設定19## 代理設定

18 20 

19### 環境變數21### 環境變數

Details

50| 您想要 | 開始使用 | 所需的隔離 | 注意 |50| 您想要 | 開始使用 | 所需的隔離 | 注意 |

51| :- | :- | :- | :- |51| :- | :- | :- | :- |

52| 自己審查每個操作 | Manual 模式:`claude --permission-mode default` | 無 | 敏感工作、不熟悉的程式碼 |52| 自己審查每個操作 | Manual 模式:`claude --permission-mode default` | 無 | 敏感工作、不熟悉的程式碼 |

53| 在本地迭代,提示更少,無需分類器 | Manual 模式加上 Bash 沙箱在[自動允許模式](https://code.claude.com/docs/zh-TW/sandboxing.md#sandbox-modes)中:`claude --permission-mode default`,然後執行 `/sandbox` 並選擇自動允許 | 內建 Bash 沙箱,在 macOS、Linux 和 WSL2 上 | 拒絕規則仍然適用,詢問規則命名命令(例如 `Bash(git push *)`)仍然提示。[自動允許模式](https://code.claude.com/docs/zh-TW/sandboxing.md#auto-allow-mode)涵蓋其他可能提示的命令。若要改為從設定檔開啟沙箱,請將 [`sandbox.enabled`](https://code.claude.com/docs/zh-TW/settings-reference#sandbox-enabled) 設定為 `true` |53| 在本地迭代,提示更少,無需分類器 | Manual 模式加上 Bash 沙箱在[自動允許模式](https://code.claude.com/docs/zh-TW/sandboxing.md#sandbox-modes)中:`claude --permission-mode default`,然後執行 `/sandbox` 並選擇自動允許 | 內建 Bash 沙箱,在 macOS、Linux 和 WSL2 上 | 拒絕規則仍然適用,詢問規則命名命令(例如 `Bash(git push *)`)仍然提示。[自動允許模式](https://code.claude.com/docs/zh-TW/sandboxing.md#auto-allow-mode)涵蓋其他可能提示的命令。若要改為從設定檔開啟沙箱,請將 [`sandbox.enabled`](https://code.claude.com/docs/zh-TW/settings-reference#sandbox-enabled) 和 [`sandbox.autoAllowBashIfSandboxed`](https://code.claude.com/docs/zh-TW/settings-reference#sandbox-autoallowbashifsandboxed) 設定為 `true` |

54| 在變更任何內容前探索 | `claude --permission-mode plan` | 無 | Claude Code 會阻止編輯,直到您[批准計畫](#review-and-approve-a-plan) |54| 在變更任何內容前探索 | `claude --permission-mode plan` | 無 | Claude Code 會阻止編輯,直到您[批准計畫](#review-and-approve-a-plan) |

55| 在自動模式中無人值守工作 | `claude --permission-mode auto`、[內建起始權限模式](#which-mode-a-session-starts-in)(v2.1.283 或更新版本) | 無;沙箱或容器增加深度防禦 | 需要[支援的模型](#eliminate-prompts-with-auto-mode),您的組織可以[關閉自動模式](#eliminate-prompts-with-auto-mode) |55| 在自動模式中無人值守工作 | `claude --permission-mode auto`、[內建起始權限模式](#which-mode-a-session-starts-in)(v2.1.283 或更新版本) | 無;沙箱或容器增加深度防禦 | 需要[支援的模型](#eliminate-prompts-with-auto-mode),您的組織可以[關閉自動模式](#eliminate-prompts-with-auto-mode) |

56| 在 CI 中使用精確允許清單執行 | `claude -p "run the test suite" --permission-mode dontAsk --allowedTools "Bash(npm test)" "Read"` | 無,超出您的 CI 執行器提供的 | [雲端工作階段](https://code.claude.com/docs/zh-TW/claude-code-on-the-web.md)忽略設定檔中的 `dontAsk` |56| 在 CI 中使用精確允許清單執行 | `claude -p "run the test suite" --permission-mode dontAsk --allowedTools "Bash(npm test)" "Read"` | 無,超出您的 CI 執行器提供的 | [雲端工作階段](https://code.claude.com/docs/zh-TW/claude-code-on-the-web.md)忽略設定檔中的 `dontAsk` |


344 344 

345* **計畫**:所有計畫。345* **計畫**:所有計畫。

346* **組織**:在 Team 和 Enterprise 上,自動模式預設可用。管理員可以透過在[受管設定](https://code.claude.com/docs/zh-TW/managed-settings.md)中將 `permissions.disableAutoMode` 設定為 `"disable"` 來為組織關閉它。346* **組織**:在 Team 和 Enterprise 上,自動模式預設可用。管理員可以透過在[受管設定](https://code.claude.com/docs/zh-TW/managed-settings.md)中將 `permissions.disableAutoMode` 設定為 `"disable"` 來為組織關閉它。

347* **模型**:在 Anthropic API 和 [AWS 上的 Claude Platform](https://code.claude.com/docs/zh-TW/claude-platform-on-aws.md) 上,Claude Opus 4.6 或更新版本、Sonnet 4.6 或更新版本、Haiku 5.5,或 [Fable 模型](https://code.claude.com/docs/zh-TW/model-config.md#work-with-fable)。在 Amazon Bedrock、Google Cloud 的 Agent Platform、Microsoft Foundry 和已登入的 [Claude 應用程式閘道](https://code.claude.com/docs/zh-TW/claude-apps-gateway)工作階段上,僅限 Claude Sonnet 5 或更新版本、Opus 4.7 或更新版本、Haiku 5.5 和 Fable 模型。較舊的模型,包括 Sonnet 4.5、Opus 4.5、Haiku 4.5 和 claude-3 模型,在任何提供商上都不受支援。347* **提供商和模型**:在以下提供商上預設可用,搭配以下模型:

348* **提供商**:在 Anthropic API、AWS 上的 Claude Platform、Amazon Bedrock、Google Cloud 的 Agent Platform、Microsoft Foundry 和已登入的 Claude 應用程式閘道工作階段上預設可用。348 

349 * **Anthropic API、[AWS 上的 Claude Platform](https://code.claude.com/docs/zh-TW/claude-platform-on-aws.md) 和 [Google Cloud 上的 Claude Models(由 Anthropic 管理)](https://code.claude.com/docs/zh-TW/claude-models-on-google-cloud-anthropic-managed.md)**:Claude Opus 4.6 或更新版本、Sonnet 4.6 或更新版本、Haiku 5.5,或 [Fable 模型](https://code.claude.com/docs/zh-TW/model-config.md#work-with-fable)

350 * **Amazon Bedrock、Google Cloud 的 Agent Platform、Microsoft Foundry 和已登入的 [Claude 應用程式閘道](https://code.claude.com/docs/zh-TW/claude-apps-gateway)工作階段**:僅限 Claude Sonnet 5 或更新版本、Opus 4.7 或更新版本、Haiku 5.5 和 Fable 模型

351 

352 較舊的模型,包括 Sonnet 4.5、Opus 4.5、Haiku 4.5 和 claude-3 模型,在任何提供商上都不受支援。

349 353 

350如果 Claude Code 報告自動模式不可用,首先檢查這些要求以及任何設定檔是否設定了 [`disableAutoMode`](https://code.claude.com/docs/zh-TW/settings-reference#disableautomode)。Anthropic 也可能已在伺服器端關閉自動模式,或伺服器可能已為您的帳戶拒絕自動模式。收到任一答案的工作階段會保持自動模式關閉直到工作階段結束,因此請稍後啟動新工作階段。354如果 Claude Code 報告自動模式不可用,首先檢查這些要求以及任何設定檔是否設定了 [`disableAutoMode`](https://code.claude.com/docs/zh-TW/settings-reference#disableautomode)。Anthropic 也可能已在伺服器端關閉自動模式,或伺服器可能已為您的帳戶拒絕自動模式。收到任一答案的工作階段會保持自動模式關閉直到工作階段結束,因此請稍後啟動新工作階段。

351 355 

permissions.md +5 −3

Details

50您可以使用 `/permissions` 檢視和管理 Claude Code 的工具權限。此對話框列出所有權限規則及其來源的 `settings.json` 檔案。您可以在 Claude 工作時開啟此對話框:當您新增或移除規則時,Claude Code 會從 Claude 在同一輪中的下一個工具呼叫開始套用變更。在 v2.1.234 之前,Claude Code 會將命令排隊直到輪次完成。50您可以使用 `/permissions` 檢視和管理 Claude Code 的工具權限。此對話框列出所有權限規則及其來源的 `settings.json` 檔案。您可以在 Claude 工作時開啟此對話框:當您新增或移除規則時,Claude Code 會從 Claude 在同一輪中的下一個工具呼叫開始套用變更。在 v2.1.234 之前,Claude Code 會將命令排隊直到輪次完成。

51 51 

52* **Allow** 規則讓 Claude Code 使用指定的工具,無需手動批准。52* **Allow** 規則讓 Claude Code 使用指定的工具,無需手動批准。

53* **Ask** 規則在 Claude Code 嘗試使用指定工具時提示確認。53* **Ask** 規則在 Claude 嘗試使用指定工具時提示確認。

54* **Deny** 規則防止 Claude Code 使用指定的工具。54* **Deny** 規則防止 Claude Code 使用指定的工具。

55 55 

56規則按順序評估:deny、ask,然後 allow。該順序中的第一個符合項決定結果,規則特異性不會改變順序。56規則按順序評估:deny、ask,然後 allow。該順序中的第一個符合項決定結果,規則特異性不會改變順序。


86 86 

87若要防止 `bypassPermissions` 或 `auto` 模式被使用,請在任何 [settings file](https://code.claude.com/docs/zh-TW/settings.md#where-settings-live) 中將 `permissions.disableBypassPermissionsMode` 或 `permissions.disableAutoMode` 設定為 `"disable"`。這些在 [managed settings](#managed-settings) 中最有用,因為它們無法被覆蓋。87若要防止 `bypassPermissions` 或 `auto` 模式被使用,請在任何 [settings file](https://code.claude.com/docs/zh-TW/settings.md#where-settings-live) 中將 `permissions.disableBypassPermissionsMode` 或 `permissions.disableAutoMode` 設定為 `"disable"`。這些在 [managed settings](#managed-settings) 中最有用,因為它們無法被覆蓋。

88 88 

89若要拒絕會等待權限提示的呼叫,讓無人看管的工作階段能持續運作,請在您的使用者設定或受管設定中將 [`permissions.denyInsteadOfPrompting`](https://code.claude.com/docs/zh-TW/settings-reference#permissions-denyinsteadofprompting) 設定為 `true`。`dontAsk` 本身是一種權限模式,而此設定鍵則會搭配您目前所處的權限模式運作。

90 

89## 權限規則語法91## 權限規則語法

90 92 

91權限規則遵循格式 `Tool` 或 `Tool(specifier)`。指定符內的括號是字面的,因此包含括號的命令或路徑不需要逃逸。93權限規則遵循格式 `Tool` 或 `Tool(specifier)`。指定符內的括號是字面的,因此包含括號的命令或路徑不需要逃逸。


743 745 

744使用兩者進行深度防禦,因為即使提示注入繞過 Claude 的決策制定,沙箱限制仍然適用。來自沙箱設定和權限規則的路徑和網域會 [合併到最終沙箱設定](https://code.claude.com/docs/zh-TW/sandboxing.md#permission-rules)。746使用兩者進行深度防禦,因為即使提示注入繞過 Claude 的決策制定,沙箱限制仍然適用。來自沙箱設定和權限規則的路徑和網域會 [合併到最終沙箱設定](https://code.claude.com/docs/zh-TW/sandboxing.md#permission-rules)。

745 747 

746當您啟用沙箱並將 `autoAllowBashIfSandboxed` 保留在其預設值 `true` 時,沙箱化 Bash 命令無需提示即可執行,即使您的權限包括 bare `Bash` ask 規則,或 [等效的 `Bash(*)` 形式](#match-all-uses-of-a-tool):沙箱邊界替代整個工具提示。748當您啟用沙箱機制並將 [`sandbox.autoAllowBashIfSandboxed`](https://code.claude.com/docs/zh-TW/settings-reference#sandbox-autoallowbashifsandboxed) 設為 `true` 時,沙箱化 Bash 命令無需提示即可執行。即使存在 bare `Bash` ask 規則或[等效的 `Bash(*)` 形式](#match-all-uses-of-a-tool),這一點仍然成立:沙箱邊界會取代該整個工具的提示。

747 749 

748在 [plan mode](https://code.claude.com/docs/zh-TW/permission-modes.md#analyze-before-you-edit-with-plan-mode) 中,Claude Code 會跳過此替代。沒有 ask 規則時,[內建唯讀命令](#read-only-commands)仍然無需提示即可執行,任何其他 shell 命令在您仍在規劃時會通過常規權限流程;請參閱 [plan mode](https://code.claude.com/docs/zh-TW/permission-modes.md#analyze-before-you-edit-with-plan-mode) 以了解 Claude Code 如何在那裡控制命令。使用 bare `Bash` ask 規則時,每個 Bash 命令都會提示,包括沙箱化唯讀命令,與沙箱外相同。750在 [plan mode](https://code.claude.com/docs/zh-TW/permission-modes.md#analyze-before-you-edit-with-plan-mode) 中,Claude Code 會跳過此替代。沒有 ask 規則時,[內建唯讀命令](#read-only-commands)仍然無需提示即可執行,任何其他 shell 命令在您仍在規劃時會通過常規權限流程;請參閱 [plan mode](https://code.claude.com/docs/zh-TW/permission-modes.md#analyze-before-you-edit-with-plan-mode) 以了解 Claude Code 如何在那裡控制命令。使用 bare `Bash` ask 規則時,每個 Bash 命令都會提示,包括沙箱化唯讀命令,與沙箱外相同。

749 751 


807 809 

808| 儲存庫提供的內容 | 您只信任了父資料夾 | `claude -p` 或 SDK,資料夾從未被信任 |810| 儲存庫提供的內容 | 您只信任了父資料夾 | `claude -p` 或 SDK,資料夾從未被信任 |

809| :- | :- | :- |811| :- | :- | :- |

810| 設定檔案中的 [hook](https://code.claude.com/docs/zh-TW/hooks.md)、[`env`](https://code.claude.com/docs/zh-TW/settings-reference#env) 區塊和輔助命令(例如 [`apiKeyHelper`](https://code.claude.com/docs/zh-TW/settings-reference#apikeyhelper)),以及專案 skill 的 [hook](https://code.claude.com/docs/zh-TW/hooks.md#hooks-in-skills-and-agents) 和 [`allowed-tools`](https://code.claude.com/docs/zh-TW/skills#pre-approve-tools-for-a-skill) | 已使用 | 已使用。工作區信任在任何工作階段中都不會限制 skill 的 `allowed-tools` |812| 設定檔案中的 [hook](https://code.claude.com/docs/zh-TW/hooks.md)、[`env`](https://code.claude.com/docs/zh-TW/settings-reference#env) 區塊和輔助命令(例如 [`apiKeyHelper`](https://code.claude.com/docs/zh-TW/settings-reference#apikeyhelper)),以及專案 skill 的 [hook](https://code.claude.com/docs/zh-TW/hooks.md#hooks-in-skills-and-agents) 和 [`allowed-tools`](https://code.claude.com/docs/zh-TW/skills#pre-approve-tools-for-a-skill) | 已使用 | 已使用 |

811| `.claude/settings.json` 中的 `permissions.allow` 規則和 `additionalDirectories` | 在您接受信任對話框之前不使用,對話框會再次出現列出它們 | 不使用。Claude Code 會列印 [`this workspace has not been trusted`](https://code.claude.com/docs/zh-TW/errors#workspace-has-not-been-trusted) 警告到 stderr |813| `.claude/settings.json` 中的 `permissions.allow` 規則和 `additionalDirectories` | 在您接受信任對話框之前不使用,對話框會再次出現列出它們 | 不使用。Claude Code 會列印 [`this workspace has not been trusted`](https://code.claude.com/docs/zh-TW/errors#workspace-has-not-been-trusted) 警告到 stderr |

812| 專案 [subagent](https://code.claude.com/docs/zh-TW/sub-agents.md#hooks-in-subagent-frontmatter) 中的 frontmatter hook、專案 [`@skills-dir` 外掛](https://code.claude.com/docs/zh-TW/plugins/loading#plugins-shared-through-a-repository),以及來自儲存庫或 `--add-dir` 目錄的 [`extraKnownMarketplaces`](https://code.claude.com/docs/zh-TW/settings-reference#extraknownmarketplaces) 項目 | 不使用,不提供對話框 | 不使用 |814| 專案 [subagent](https://code.claude.com/docs/zh-TW/sub-agents.md#hooks-in-subagent-frontmatter) 中的 frontmatter hook、專案 [`@skills-dir` 外掛](https://code.claude.com/docs/zh-TW/plugins/loading#plugins-shared-through-a-repository),以及來自儲存庫或 `--add-dir` 目錄的 [`extraKnownMarketplaces`](https://code.claude.com/docs/zh-TW/settings-reference#extraknownmarketplaces) 項目 | 不使用,不提供對話框 | 不使用 |

813| 來自儲存庫或 `--add-dir` 目錄的 subagent 的 frontmatter 中的內聯 [`mcpServers`](https://code.claude.com/docs/zh-TW/sub-agents#scope-mcp-servers-to-a-subagent) | 不使用,不提供對話框 | 不使用 |815| 來自儲存庫或 `--add-dir` 目錄的 subagent 的 frontmatter 中的內聯 [`mcpServers`](https://code.claude.com/docs/zh-TW/sub-agents#scope-mcp-servers-to-a-subagent) | 不使用,不提供對話框 | 不使用 |

Details

777| `repo` | `owner/repo`。僅 `github` 來源 |777| `repo` | `owner/repo`。僅 `github` 來源 |

778| `url` | 複製或擷取 URL。僅 `git` 和 `url` 來源 |778| `url` | 複製或擷取 URL。僅 `git` 和 `url` 來源 |

779| `path` | 本地路徑。僅 `directory` 和 `file` 來源 |779| `path` | 本地路徑。僅 `directory` 和 `file` 來源 |

780| `ref` | 固定的分支或標籤。`github` 和 `git` 來源,僅當固定時 |780| `ref` | 固定的分支、標籤或提交 SHA。`github` 和 `git` 來源,僅當固定時 |

781| `installLocation` | Claude Code 快取市集的位置 |781| `installLocation` | Claude Code 快取市集的位置 |

782 782 

783已新增的 [claude.ai 市集](https://code.claude.com/docs/zh-TW/plugins/install.md#add-from-claude-ai) 沒有本地複製,因此其項目帶有其 claude.ai 識別碼 `marketplaceId` 和 `organizationUuid`,代替 `installLocation`。它也帶有 `scope`(當有記錄時)和 `status`。783已新增的 [claude.ai 市集](https://code.claude.com/docs/zh-TW/plugins/install.md#add-from-claude-ai) 沒有本地複製,因此其項目帶有其 claude.ai 識別碼 `marketplaceId` 和 `organizationUuid`,代替 `installLocation`。它也帶有 `scope`(當有記錄時)和 `status`。

Details

260 260 

261若要檢查 MCP 伺服器,請在工作階段中執行 `/mcp` 以查看伺服器的狀態。當伺服器健康時,`/mcp` 會將其列為已連接。如果不是,請參閱[不啟動的 MCP 伺服器](https://code.claude.com/docs/zh-TW/plugins/troubleshooting.md#invalid-mcp-server-config-for-and-mcp-servers-that-dont-start)。261若要檢查 MCP 伺服器,請在工作階段中執行 `/mcp` 以查看伺服器的狀態。當伺服器健康時,`/mcp` 會將其列為已連接。如果不是,請參閱[不啟動的 MCP 伺服器](https://code.claude.com/docs/zh-TW/plugins/troubleshooting.md#invalid-mcp-server-config-for-and-mcp-servers-that-dont-start)。

262 262 

263若要檢查 hook,請觸發它匹配的事件。例如,要求 Claude 編輯檔案以觸發 `PostToolUse` hook。然後閱讀[偵錯日誌](https://code.claude.com/docs/zh-TW/hooks.md#debug-hooks),它顯示哪些 hooks 匹配、它們的退出代碼和它們的輸出。263若要檢查 hook,請依照[偵錯 hook](https://code.claude.com/docs/zh-TW/hooks.md#debug-hooks) 所述開啟偵錯日誌,並觸發它匹配的事件。例如,要求 Claude 編輯檔案以觸發 `PostToolUse` hook。然後閱讀偵錯日誌。

264 264 

265下一部分涵蓋您在開發時最可能遇到的失敗,[疑難排解頁面](https://code.claude.com/docs/zh-TW/plugins/troubleshooting.md#build-a-plugin)對每一個都有完整的條目。265下一部分涵蓋您在開發時最可能遇到的失敗,[疑難排解頁面](https://code.claude.com/docs/zh-TW/plugins/troubleshooting.md#build-a-plugin)對每一個都有完整的條目。

266 266 

Details

223| 路徑 | 它保存什麼 |223| 路徑 | 它保存什麼 |

224| :- | :- |224| :- | :- |

225| `cache/<marketplace>/<plugin>/<version>/` | 市場 plugin 的每個已安裝版本一個目錄。`<plugin>` 是市場項目名稱,`<version>` 是 [已解決的版本](#versions-and-updates)。`${CLAUDE_PLUGIN_ROOT}` 指向此目錄 |225| `cache/<marketplace>/<plugin>/<version>/` | 市場 plugin 的每個已安裝版本一個目錄。`<plugin>` 是市場項目名稱,`<version>` 是 [已解決的版本](#versions-and-updates)。`${CLAUDE_PLUGIN_ROOT}` 指向此目錄 |

226| `data/<plugin-id>/` | plugin 的持久目錄,公開為 `${CLAUDE_PLUGIN_DATA}`。如需如何形成 `<plugin-id>`,請參閱 [路徑變數和持久資料](https://code.claude.com/docs/zh-TW/plugins/components.md#path-variables-and-persistent-data)。Claude Code 在 plugin 元件首次使用它時建立它,並在更新中保留它。當您從其最後一個範圍卸載 plugin 時,Claude Code 會刪除它,除非您傳遞 `--keep-data`。如需 `--keep-data` 和其他它保留的情況,請參閱 [plugin 卸載](https://code.claude.com/docs/zh-TW/plugins/cli-reference.md#plugin-uninstall) |226| `data/<plugin-id>/` | 外掛的持久目錄,公開為 `${CLAUDE_PLUGIN_DATA}`。如需了解 `<plugin-id>` 如何形成,請參閱[路徑變數和持久資料](https://code.claude.com/docs/zh-TW/plugins/components.md#path-variables-and-persistent-data)。Claude Code 在外掛元件首次使用它時建立它,並在更新中保留它。預設情況下,當您從其最後一個範圍解除安裝外掛時,Claude Code 會刪除它。如需 `--keep-data` 和其他它會保留的情況,請參閱[plugin uninstall](https://code.claude.com/docs/zh-TW/plugins/cli-reference.md#plugin-uninstall) |

227| `marketplaces/<name>/` | 從 GitHub、另一個 Git 主機或 URL 新增的市場的複製或下載。從本地 `file` 或 `directory` 來源新增的市場在此處沒有副本,其 `known_marketplaces.json` 中的 `installLocation` 是您提供的路徑 |227| `marketplaces/<name>/` | 從 GitHub、另一個 Git 主機或 URL 新增的市場的複製或下載。從本地 `file` 或 `directory` 來源新增的市場在此處沒有副本,其 `known_marketplaces.json` 中的 `installLocation` 是您提供的路徑 |

228| `mcpb/` | Claude Code 從外掛所宣告的 [MCP 套件](https://code.claude.com/docs/zh-TW/plugins/components.md#include-a-packaged-mcpb-server)中解壓縮出的檔案。需要 Claude Code v2.1.324 或更新版本 |

228| `synced/` | Claude Code [從您的 claude.ai 帳戶同步的 plugins](#synced-plugins) |229| `synced/` | Claude Code [從您的 claude.ai 帳戶同步的 plugins](#synced-plugins) |

229| `.trash/` | claude.ai 同步移除的 plugins,例如在您在 claude.ai 上關閉一個或停止同步後 |230| `.trash/` | claude.ai 同步移除的 plugins,例如在您在 claude.ai 上關閉一個或停止同步後 |

230| `installed_plugins.json` 和 `known_marketplaces.json` | Claude Code 已安裝的記錄和已提取的市場,在 [檢查 plugin 達到哪個階段](#check-which-stage-a-plugin-reached) 下描述。[在 claude.ai 上託管的市場](https://code.claude.com/docs/zh-TW/plugins/install.md#add-from-claude-ai) 改為記錄在 `known_marketplaces_claudeai.json` 中 |231| `installed_plugins.json` 和 `known_marketplaces.json` | Claude Code 已安裝的記錄和已提取的市場,在 [檢查 plugin 達到哪個階段](#check-which-stage-a-plugin-reached) 下描述。[在 claude.ai 上託管的市場](https://code.claude.com/docs/zh-TW/plugins/install.md#add-from-claude-ai) 改為記錄在 `known_marketplaces_claudeai.json` 中 |

Details

306| 形式 | 範例值 | Claude Code 的作用 |306| 形式 | 範例值 | Claude Code 的作用 |

307| :- | :- | :- |307| :- | :- | :- |

308| `.json` 檔案路徑 | `"./mcp/servers.json"` | 將檔案讀取為 `mcpServers` 對應 |308| `.json` 檔案路徑 | `"./mcp/servers.json"` | 將檔案讀取為 `mcpServers` 對應 |

309| MCP 套件路徑 | `"./bundle.mcpb"` | 將 `.mcpb` 或 `.dxt` 套件提取到 plugin 根目錄下的 `.mcpb-cache/` 並讀取其伺服器設定 |309| MCP 套件路徑 | `"./bundle.mcpb"` | 將 `.mcpb` 或 `.dxt` 套件提取到 [plugins 根目錄](https://code.claude.com/docs/zh-TW/plugins/loading.md#find-plugins-on-disk)下的 `mcpb/`,並讀取其伺服器設定 |

310| MCP 套件 URL | `"https://example.com/server.mcpb"` | 將套件下載到 `.mcpb-cache/`,然後讀取它 |310| MCP 套件 URL | `"https://example.com/server.mcpb"` | 下載套件,然後以相同方式提取並讀取它 |

311| 內聯對應 | `{ "deploy-api": { "command": "node", "args": ["${CLAUDE_PLUGIN_ROOT}/server.js"] } }` | 使用對應作為以名稱為鍵的伺服器設定 |311| 內聯對應 | `{ "deploy-api": { "command": "node", "args": ["${CLAUDE_PLUGIN_ROOT}/server.js"] } }` | 使用對應作為以名稱為鍵的伺服器設定 |

312 312 

313套件路徑或 URL 必須以 `.mcpb` 或 `.dxt` 結尾。任何其他副檔名無法驗證。313套件路徑或 URL 必須以 `.mcpb` 或 `.dxt` 結尾。任何其他副檔名無法驗證。

Details

46* **冒充官方 marketplace 的名稱**:名稱如 `official-claude-plugins` 或 `claude-plugins-v2`,以及任何包含非 ASCII 字元的名稱。錯誤是 `Marketplace name impersonates an official Anthropic/Claude marketplace`。名稱中的控制或雙向格式化字元也會報告 `Marketplace name cannot contain control or bidirectional-formatting characters`。已在此類名稱下註冊的 marketplace 停止載入,連同其外掛程式。46* **冒充官方 marketplace 的名稱**:名稱如 `official-claude-plugins` 或 `claude-plugins-v2`,以及任何包含非 ASCII 字元的名稱。錯誤是 `Marketplace name impersonates an official Anthropic/Claude marketplace`。名稱中的控制或雙向格式化字元也會報告 `Marketplace name cannot contain control or bidirectional-formatting characters`。已在此類名稱下註冊的 marketplace 停止載入,連同其外掛程式。

47* **保留名稱的另一種拼寫**:與保留名稱的拼寫不同,只是尾部有點,或用下劃線以外的符號代替連字號,因此 `claude.code.plugins` 計為 `claude-code-plugins`。新增 marketplace 失敗,錯誤為 [`is another spelling of "<reserved>", a reserved marketplace name`](https://code.claude.com/docs/zh-TW/errors#marketplace-name-is-another-spelling-of-a-reserved-name),而已使用此類名稱註冊的 marketplace 會停止載入。此檢查需要 Claude Code v2.1.280 或更新版本。47* **保留名稱的另一種拼寫**:與保留名稱的拼寫不同,只是尾部有點,或用下劃線以外的符號代替連字號,因此 `claude.code.plugins` 計為 `claude-code-plugins`。新增 marketplace 失敗,錯誤為 [`is another spelling of "<reserved>", a reserved marketplace name`](https://code.claude.com/docs/zh-TW/errors#marketplace-name-is-another-spelling-of-a-reserved-name),而已使用此類名稱註冊的 marketplace 會停止載入。此檢查需要 Claude Code v2.1.280 或更新版本。

48* **Claude Code 用於不來自 marketplace 的外掛程式的名稱**:`inline` 用於使用 [`--plugin-dir`](https://code.claude.com/docs/zh-TW/cli-reference) 載入的外掛程式,`builtin` 用於內建外掛程式,`skills-dir` 用於從 [`.claude/skills/`](https://code.claude.com/docs/zh-TW/skills) 自動載入的外掛程式,`synced` 用於從您的 claude.ai 帳戶同步的外掛程式。`claude-plugin-test` 也被保留。`skills-dir` 也在 `strictKnownMarketplaces` 和 `blockedMarketplaces` 中顯示為 `{"source": "skills-dir"}`,在 [Source values valid only in policy lists](#source-values-valid-only-in-policy-lists) 下描述。48* **Claude Code 用於不來自 marketplace 的外掛程式的名稱**:`inline` 用於使用 [`--plugin-dir`](https://code.claude.com/docs/zh-TW/cli-reference) 載入的外掛程式,`builtin` 用於內建外掛程式,`skills-dir` 用於從 [`.claude/skills/`](https://code.claude.com/docs/zh-TW/skills) 自動載入的外掛程式,`synced` 用於從您的 claude.ai 帳戶同步的外掛程式。`claude-plugin-test` 也被保留。`skills-dir` 也在 `strictKnownMarketplaces` 和 `blockedMarketplaces` 中顯示為 `{"source": "skills-dir"}`,在 [Source values valid only in policy lists](#source-values-valid-only-in-policy-lists) 下描述。

49* **`npm`、`pip`、`uv`、`cargo`、`github` 和 `gh`**:以任何大小寫保留。此檢查需要 Claude Code v2.1.275 或更新版本。

50* **每個 JavaScript 物件都具有的成員名稱**:`constructor`、`hasOwnProperty`、`isPrototypeOf`、`propertyIsEnumerable`、`toLocaleString`、`toString` 和 `valueOf`。`claude plugin marketplace add` 會拒絕使用其中之一的 marketplace,錯誤為 [`Claude Code reserves this name and cannot register a marketplace under it`](https://code.claude.com/docs/zh-TW/plugins/troubleshooting#claude-code-reserves-this-name)。此檢查需要 Claude Code v2.1.296 或更新版本。49* **每個 JavaScript 物件都具有的成員名稱**:`constructor`、`hasOwnProperty`、`isPrototypeOf`、`propertyIsEnumerable`、`toLocaleString`、`toString` 和 `valueOf`。`claude plugin marketplace add` 會拒絕使用其中之一的 marketplace,錯誤為 [`Claude Code reserves this name and cannot register a marketplace under it`](https://code.claude.com/docs/zh-TW/plugins/troubleshooting#claude-code-reserves-this-name)。此檢查需要 Claude Code v2.1.296 或更新版本。

51* **以 `claudeai-` 開頭的名稱**:為託管在 claude.ai 上的 marketplace 保留。`claude plugin marketplace add` 拒絕任何其他使用一個的 marketplace,錯誤為 `Cannot add marketplace "<name>": names starting with "claudeai-" are reserved for marketplaces hosted on claude.ai`。50* **以 `claudeai-` 開頭的名稱**:為託管在 claude.ai 上的 marketplace 保留。`claude plugin marketplace add` 拒絕任何其他使用一個的 marketplace,錯誤為 `Cannot add marketplace "<name>": names starting with "claudeai-" are reserved for marketplaces hosted on claude.ai`。

52* **已註冊 GitHub marketplace 的下載資料夾 `<owner>-<repo>`**:對於從 `github` 來源(例如 `acme/x-tools`)新增的 marketplace,無論該 marketplace 本身的 `name` 為何,Claude Code 都會透過名為 `acme-x-tools` 的資料夾下載它。當該 marketplace 以 `acme-x-tools` 以外的名稱註冊時,`claude plugin marketplace add` 會在下載另一個名為 `acme-x-tools` 的 marketplace 後拒絕它,並報告 `Can't use the marketplace name "acme-x-tools"`。此檢查需要 Claude Code v2.1.290 或更新版本。51* **已註冊 GitHub marketplace 的下載資料夾 `<owner>-<repo>`**:對於從 `github` 來源(例如 `acme/x-tools`)新增的 marketplace,無論該 marketplace 本身的 `name` 為何,Claude Code 都會透過名為 `acme-x-tools` 的資料夾下載它。當該 marketplace 以 `acme-x-tools` 以外的名稱註冊時,`claude plugin marketplace add` 會在下載另一個名為 `acme-x-tools` 的 marketplace 後拒絕它,並報告 `Can't use the marketplace name "acme-x-tools"`。此檢查需要 Claude Code v2.1.290 或更新版本。


405| `headers` | `url` | Claude Code 使用擷取發送的 HTTP 標頭對應,用於已驗證的主機 |404| `headers` | `url` | Claude Code 使用擷取發送的 HTTP 標頭對應,用於已驗證的主機 |

406| `headersHelper` | `url` | 列印標頭的命令,其值太短暫而無法在 `headers` 中列出。需要 Claude Code v2.1.238 或更新版本。請參閱 [Authenticate archive downloads](https://code.claude.com/docs/zh-TW/plugins/host-marketplace.md#authenticate-archive-downloads) |405| `headersHelper` | `url` | 列印標頭的命令,其值太短暫而無法在 `headers` 中列出。需要 Claude Code v2.1.238 或更新版本。請參閱 [Authenticate archive downloads](https://code.claude.com/docs/zh-TW/plugins/host-marketplace.md#authenticate-archive-downloads) |

407| `repo` | `github` | 在 `marketplace add` 和 `extraKnownMarketplaces` 中,`repo` 必須命名一個存放庫。`marketplace add` 拒絕 `owner/*` 作為無效的 `owner/repo` 簡寫;在 `extraKnownMarketplaces` 中 Claude Code 按字面意思取用,複製失敗 |406| `repo` | `github` | 在 `marketplace add` 和 `extraKnownMarketplaces` 中,`repo` 必須命名一個存放庫。`marketplace add` 拒絕 `owner/*` 作為無效的 `owner/repo` 簡寫;在 `extraKnownMarketplaces` 中 Claude Code 按字面意思取用,複製失敗 |

408| `ref` | `github`、`git` | 分支或標籤。預設為存放庫的預設分支 |407| `ref` | `github`、`git` | 分支、標籤,或分支或標籤上某個提交的完整小寫 SHA。預設為儲存庫的預設分支。SHA 需要 Claude Code v2.1.324 或更新版本,且對於具有[保留名稱](#reserved-names)的 marketplace(例如 `claude-plugins-official`)會被拒絕 |

409| `path` | `github`、`git` | marketplace 檔案在存放庫內的路徑。預設為 `.claude-plugin/marketplace.json` |408| `path` | `github`、`git` | marketplace 檔案在存放庫內的路徑。預設為 `.claude-plugin/marketplace.json` |

410| `path` | `file` | marketplace 檔案本身。Claude Code 就地讀取它,並將上面兩個級別的目錄作為 marketplace 根目錄,因此將檔案保存在 `<root>/.claude-plugin/marketplace.json` |409| `path` | `file` | marketplace 檔案本身。Claude Code 就地讀取它,並將上面兩個級別的目錄作為 marketplace 根目錄,因此將檔案保存在 `<root>/.claude-plugin/marketplace.json` |

411| `path` | `directory` | marketplace 根目錄,包含 `.claude-plugin/marketplace.json` 的目錄 |410| `path` | `directory` | marketplace 根目錄,包含 `.claude-plugin/marketplace.json` 的目錄 |


414| `name` | `settings` | 必須等於 `extraKnownMarketplaces` 鍵,不能是 [保留名稱](#reserved-names) |413| `name` | `settings` | 必須等於 `extraKnownMarketplaces` 鍵,不能是 [保留名稱](#reserved-names) |

415| `plugins` | `settings` | 內聯目錄,沒有託管檔案。每個項目採用 `name`、`source`、`description`、`version`、`strict`、`headers` 和 `headersHelper`。將每個項目的 `source` 寫為物件類型,因為相對路徑沒有要解析的存放庫 |414| `plugins` | `settings` | 內聯目錄,沒有託管檔案。每個項目採用 `name`、`source`、`description`、`version`、`strict`、`headers` 和 `headersHelper`。將每個項目的 `source` 寫為物件類型,因為相對路徑沒有要解析的存放庫 |

416 415 

416若要防止重新整理和自動更新將 `github` 或 `git` marketplace 從您已審查過的提交上移開,請將 `ref` 設定為該提交的完整 SHA,如下列來源所示:

417 

418```json theme={null}

419{ "source": "github", "repo": "acme-corp/plugins", "ref": "a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0" }

420```

421 

422請先更新每部機器上的 Claude Code,因為 v2.1.324 之前的版本無法載入以此方式固定的 marketplace。具有自己遠端來源的外掛項目仍然可以更新,因此也請固定該項目,例如在 `github`、`url` 或 `git-subdir` 來源上使用 [`sha`](#plugin-sources)。

423 

417### 僅在政策清單中有效的來源值424### 僅在政策清單中有效的來源值

418 425 

419`hostPattern`、`pathPattern`、`skills-dir` 和 `repo` 的 `owner/*` 形式僅在兩個政策清單中有效,`strictKnownMarketplaces` 和 `blockedMarketplaces`:426`hostPattern`、`pathPattern`、`skills-dir` 和 `repo` 的 `owner/*` 形式僅在兩個政策清單中有效,`strictKnownMarketplaces` 和 `blockedMarketplaces`:


472| `Marketplace name cannot contain path separators (/ or \), ".." sequences, or be "."` | 錯誤 | `name` |479| `Marketplace name cannot contain path separators (/ or \), ".." sequences, or be "."` | 錯誤 | `name` |

473| `Marketplace name impersonates an official Anthropic/Claude marketplace` | 錯誤 | `name`。請參閱[保留名稱](#reserved-names) |480| `Marketplace name impersonates an official Anthropic/Claude marketplace` | 錯誤 | `name`。請參閱[保留名稱](#reserved-names) |

474| `Marketplace name cannot contain control or bidirectional-formatting characters` | 錯誤 | `name` 包含控制字元(例如逸出或換行符)或 Unicode 雙向格式化字元 |481| `Marketplace name cannot contain control or bidirectional-formatting characters` | 錯誤 | `name` 包含控制字元(例如逸出或換行符)或 Unicode 雙向格式化字元 |

475| `Marketplace name "inline" is reserved for --plugin-dir session plugins`, and the `builtin`, `skills-dir`, `synced`, `claude-plugin-test`, `npm`, `pip`, `uv`, `cargo`, `github`, and `gh` variants | 錯誤 | `name` |482| `Marketplace name "inline" is reserved for --plugin-dir session plugins`,以及 `builtin`、`skills-dir`、`synced` 和 `claude-plugin-test` 變體 | 錯誤 | `name` |

476| `Author name cannot be empty` | 錯誤 | `owner.name` |483| `Author name cannot be empty` | 錯誤 | `owner.name` |

477| `Plugin name cannot contain spaces. Use kebab-case (e.g., "my-plugin")` | 錯誤 | `plugins[i].name` |484| `Plugin name cannot contain spaces. Use kebab-case (e.g., "my-plugin")` | 錯誤 | `plugins[i].name` |

478| `Plugin name cannot contain control or bidirectional-formatting characters` | 錯誤 | `plugins[i].name` |485| `Plugin name cannot contain control or bidirectional-formatting characters` | 錯誤 | `plugins[i].name` |

Details

40在受管設定中設定此選項後:40在受管設定中設定此選項後:

41 41 

42* **使用者帶來的任何 mod 都不會執行其 hook**:這涵蓋使用者安裝的外掛中的 mod、使用 `--plugin-dir` 載入的 mod,以及 [Claude 在工作階段期間編寫的 mod](https://code.claude.com/docs/zh-TW/plugins/mods/create.md#ask-claude-for-a-mod)42* **使用者帶來的任何 mod 都不會執行其 hook**:這涵蓋使用者安裝的外掛中的 mod、使用 `--plugin-dir` 載入的 mod,以及 [Claude 在工作階段期間編寫的 mod](https://code.claude.com/docs/zh-TW/plugins/mods/create.md#ask-claude-for-a-mod)

43* **您組織的 mod 仍會執行**:[計為您組織的](#install-your-organizations-mods) mod 不會被檢查。所有其他 mod 都計為使用者的 mod,並會遭到拒絕。這包括您從 GitHub 或其他遠端市集啟用的外掛中的 mod,以及您的組織為其成員在 claude.ai 上開啟的 mod。如果沒有任何 mod 計為您的,則不會有任何已安裝的 mod 執行其 hook。43* **您組織的 mod 仍會執行**:[計為您組織的](#install-your-organizations-mods) mod 不會被檢查。所有其他 mod 都計為使用者的 mod,並會遭到拒絕。這包括您的組織為其成員在 claude.ai 上開啟的 mod。如果沒有任何 mod 計為您的,則不會有任何已安裝的 mod 執行其 hook。

44* **使用者無法撤銷它**:防護只從受管設定讀取選項,因此使用者、專案或本機設定檔中的相同項目,或使用 `--settings` 傳遞的檔案中的項目,不會改變任何內容44* **使用者無法撤銷它**:防護只從受管設定讀取選項,因此使用者、專案或本機設定檔中的相同項目,或使用 `--settings` 傳遞的檔案中的項目,不會改變任何內容

45* **檔案或 MDM 原則涵蓋每個提供者**:當您以檔案或透過 MDM 方式提供選項時,它在 Amazon Bedrock、Google Cloud 的 Agent Platform 和 Microsoft Foundry 上的運作方式相同。如需從 claude.ai 管理員主控台進行交付,請參閱[平台可用性](https://code.claude.com/docs/zh-TW/server-managed-settings.md#platform-availability)45* **檔案或 MDM 原則涵蓋每個提供者**:當您以檔案或透過 MDM 方式提供選項時,它在 Amazon Bedrock、Google Cloud 的 Agent Platform 和 Microsoft Foundry 上的運作方式相同。如需從 claude.ai 管理員主控台進行交付,請參閱[平台可用性](https://code.claude.com/docs/zh-TW/server-managed-settings.md#platform-availability)

46* **使用者的其他自訂設定保持有效**:他們[設定檔中的 hook](https://code.claude.com/docs/zh-TW/hooks.md) 以及外掛 `hooks/hooks.json` 中的 hook、狀態列和 `/goal` 不受影響46* **使用者的其他自訂設定保持有效**:他們[設定檔中的 hook](https://code.claude.com/docs/zh-TW/hooks.md) 以及外掛 `hooks/hooks.json` 中的 hook、狀態列和 `/goal` 不受影響


126 126 

127若要讓這些 hook 執行,請以下列兩種方式之一變更受管設定:127若要讓這些 hook 執行,請以下列兩種方式之一變更受管設定:

128 128 

129* **將 mod 作為您組織的 mod 執行**:[安裝該 mod,使其算作您組織自己的](#install-your-organizations-mods)。其在這些事件上的 hook 隨後便會執行,而防護對其他所有 mod 仍保持載入。該 mod 會對所有收到這些設定的人開啟,且必須位於您放置在每台機器上的目錄中。如果您將其列在 `prependPlugins` 中,請在清單中保留 `sec-default@builtin`。129* **將 mod 作為您組織的 mod 執行**:[安裝該 mod,使其算作您組織自己的](#install-your-organizations-mods)。其在這些事件上的 hook 隨後便會執行,而防護對其他所有 mod 仍保持載入。該 mod 會對所有收到這些設定的人開啟。如果您將其列在 `prependPlugins` 中,請在清單中保留 `sec-default@builtin`。

130* **移除防護**:在 `prependPlugins` 中省略 `sec-default@builtin`。空清單 `"prependPlugins": []` 即已足夠。您失去的是整個防護,而不只是這些事件。使用者的 mod 便可以做到[防護原本會阻止的事](#know-what-happens-by-default),且[防護的選項](#set-options-on-the-built-in-guard)也不再適用。130* **移除防護**:在 `prependPlugins` 中省略 `sec-default@builtin`。空清單 `"prependPlugins": []` 即已足夠。您失去的是整個防護,而不只是這些事件。使用者的 mod 便可以做到[防護原本會阻止的事](#know-what-happens-by-default),且[防護的選項](#set-options-on-the-built-in-guard)也不再適用。

131 131 

132如果您透過[伺服器管理的設定](https://code.claude.com/docs/zh-TW/server-managed-settings.md#fetch-and-caching-behavior)傳送不含防護的清單,防護會保持載入,直到伺服器為該工作階段確認設定為止。若要在執行 v2.1.299 或更新版本的機器上確認任一變更,請在該機器的工作階段中開啟 `/plugin`,並確認說明已消失。132如果您透過[伺服器管理的設定](https://code.claude.com/docs/zh-TW/server-managed-settings.md#fetch-and-caching-behavior)傳送不含防護的清單,防護會保持載入,直到伺服器為該工作階段確認設定為止。若要在執行 v2.1.299 或更新版本的機器上確認任一變更,請在該機器的工作階段中開啟 `/plugin`,並確認說明已消失。


253* **為某個群組(例如試行群組)提供不同的政策**:[為受管設定無法強制執行的部分做規劃](https://code.claude.com/docs/zh-TW/plugins/org.md#plan-for-what-managed-settings-can’t-enforce)253* **為某個群組(例如試行群組)提供不同的政策**:[為受管設定無法強制執行的部分做規劃](https://code.claude.com/docs/zh-TW/plugins/org.md#plan-for-what-managed-settings-can’t-enforce)

254* **檢查哪些應用程式和工作階段類型會套用外掛鍵**:[各使用介面何時套用外掛鍵](https://code.claude.com/docs/zh-TW/plugins/org.md#when-each-surface-applies-the-plugin-keys)254* **檢查哪些應用程式和工作階段類型會套用外掛鍵**:[各使用介面何時套用外掛鍵](https://code.claude.com/docs/zh-TW/plugins/org.md#when-each-surface-applies-the-plugin-keys)

255* **設定 CI 和容器**:[預先配置容器和 CI](https://code.claude.com/docs/zh-TW/plugins/org.md#seed-containers-and-ci)255* **設定 CI 和容器**:[預先配置容器和 CI](https://code.claude.com/docs/zh-TW/plugins/org.md#seed-containers-and-ci)

256* **提供使用者可以安裝的 mod**:[託管市集](https://code.claude.com/docs/zh-TW/plugins/host-marketplace.md)。Claude Code 從 GitHub、git、URL 或 npm 來源複製的 mod 會計為使用者的,而不是[您組織的](#install-your-organizations-mods)。256* **提供使用者可以安裝的 mod**:[託管市集](https://code.claude.com/docs/zh-TW/plugins/host-marketplace.md)。Claude Code 從 GitHub、git、URL 或 npm 來源複製的 mod 會計為使用者的,除非您[將其安裝為您組織的 mod](#install-your-organizations-mods)。

257 257 

258### 在內建防護上設定選項258### 在內建防護上設定選項

259 259 


281 281 

282### 安裝您組織的 mod 並設定順序282### 安裝您組織的 mod 並設定順序

283 283 

284您組織的 mod 在使用者 mod 不載入的地方載入,並可以在它們之前執行,因此 Claude Code 必須能夠判斷 mod 來自您。它只在以下所有條件都成立時才將 mod 視為您組織的:284您組織的 mod 在使用者 mod 不載入的地方載入,並可以在它們之前執行,因此 Claude Code 必須能夠判斷 mod 來自您。

285 

286若要讓來自遠端市集(例如 GitHub 儲存庫)的 mod 在 v2.1.324 或更新版本上被視為您的,請在受管設定中完成以下所有事項:

287 

288* 在 `enabledPlugins` 中將 mod 的外掛設定為 `true`

289* 在 `extraKnownMarketplaces` 中宣告該市集。若要控制 mod 的程式碼何時變更,請[釘選市集和 mod 的項目](https://code.claude.com/docs/zh-TW/plugins/marketplace-reference.md#fields-by-type)。

290* 在 [`prependPlugins`](https://code.claude.com/docs/zh-TW/settings-reference#prependplugins) 或 [`appendPlugins`](https://code.claude.com/docs/zh-TW/settings-reference#appendplugins) 中列出 mod 的 id,例如 `acme-guard@acme-tools`。使用 `prependPlugins` 時,也請列出 `sec-default@builtin` 以保留內建防護。

291 

292位於使用者機器上某個目錄中的 mod,只有在以下所有條件都成立時才會被視為您的:

285 293 

286* 受管 `enabledPlugins` 將 mod 的外掛設定為 `true`294* 受管 `enabledPlugins` 將 mod 的外掛設定為 `true`

287* 受管設定以絕對路徑將外掛的[市集](https://code.claude.com/docs/zh-TW/plugins/create-marketplace.md)指定為使用者機器上的目錄。`extraKnownMarketplaces` 項目可做到這一點,並同時為使用者註冊該市集。295* 受管設定以絕對路徑將外掛的[市集](https://code.claude.com/docs/zh-TW/plugins/create-marketplace.md)指定為使用者機器上的目錄。`extraKnownMarketplaces` 項目可做到這一點,並同時為使用者註冊該市集。


316}324}

317```325```

318 326 

319Claude Code 複製到其快取中的外掛會被視為使用者的,即使受管 `enabledPlugins` 啟用了它。這涵蓋來自 GitHub、git、URL 或 npm 來源的每個外掛。其 mod 在使用者的 mod 之間執行,`prependPlugins` 和 `appendPlugins` 會跳過它,`allowManagedModsOnly` 會拒絕它,而 `allowManagedHooksOnly` 會使它無法載入。使用者的偵錯日誌中會有一行以外掛的 id 和 `is enabled by managed settings, but` 開頭。327兩組條件都不符合的已安裝外掛會被視為使用者的,即使受管 `enabledPlugins` 啟用了它。其 mod 在使用者的 mod 之間執行,`prependPlugins` 和 `appendPlugins` 會跳過它,`allowManagedModsOnly` 會拒絕它,而 `allowManagedHooksOnly` 會使它無法載入。當受管設定啟用它時,使用者的偵錯日誌中會有一行以外掛的 id 和 `is enabled by managed settings, but` 開頭。

320 328 

321Claude Code 每次即將採取行動(例如執行工具)時都會引發事件,並依次將其傳遞給每個 mod。被視為您的 mod [會在使用者的 mod 之前執行](https://code.claude.com/docs/zh-TW/plugins/mods/events.md#the-order-mods-run-in),即使您在任何地方都沒有列出它。若要設定其位置,請在兩個設定之一中列出其 id。id 是外掛的名稱、`@` 和市集的名稱,例如 `acme-guard@acme-tools`。329Claude Code 每次即將採取行動(例如執行工具)時都會引發事件,並依次將其傳遞給每個 mod。符合目錄條件的 mod [會在使用者的 mod 之前執行](https://code.claude.com/docs/zh-TW/plugins/mods/events.md#the-order-mods-run-in),即使您在任何地方都沒有列出它。若要設定其位置,請在兩個設定之一中列出其 id。id 是外掛的名稱、`@` 和市集的名稱,例如 `acme-guard@acme-tools`。

322 330 

323* **`prependPlugins`**:您的 mod 在任何使用者的 mod 之前看到事件,並在它們之後看到該事件的結果。它可以更改事件、拒絕它或跳過使用者的 mod。在 v2.1.323 或更新版本上,請確認您的 hook 仍能[觸及其他 mod 的控制項和繪製內容](https://code.claude.com/docs/zh-TW/plugins/mods/events.md#hook-other-mods-drawings-and-controls)。331* **`prependPlugins`**:您的 mod 在任何使用者的 mod 之前看到事件,並在它們之後看到該事件的結果。它可以更改事件、拒絕它或跳過使用者的 mod。在 v2.1.323 或更新版本上,請確認您的 hook 仍能[觸及其他 mod 的控制項和繪製內容](https://code.claude.com/docs/zh-TW/plugins/mods/events.md#hook-other-mods-drawings-and-controls)。

324* **`appendPlugins`**:您的 mod 在每個使用者的 mod 之後執行,因此它只看到這些 mod 傳遞的事件,以及它們傳遞的形式332* **`appendPlugins`**:您的 mod 在每個使用者的 mod 之後執行,因此它只看到這些 mod 傳遞的事件,以及它們傳遞的形式

Details

438 438 

439* **`backdrop` 欄位**:`scene` 是您為 hook 所繪製的背景選擇的[名稱](https://code.claude.com/docs/zh-TW/plugins/mods/reference.md#limits)。關於其他欄位與 `overrideColorScheme`,請參閱[適用於您建置版本的型別](https://code.claude.com/docs/zh-TW/plugins/mods/create.md#get-the-types-for-your-build)。439* **`backdrop` 欄位**:`scene` 是您為 hook 所繪製的背景選擇的[名稱](https://code.claude.com/docs/zh-TW/plugins/mods/reference.md#limits)。關於其他欄位與 `overrideColorScheme`,請參閱[適用於您建置版本的型別](https://code.claude.com/docs/zh-TW/plugins/mods/create.md#get-the-types-for-your-build)。

440* **背景是否已繪製**:當連線到工作階段的 Desktop 或行動應用程式表示它會繪製背景時,`$.theme.set` 會以 `isDrawn: true` 解析。否則 `isDrawn` 為 `false`,而 `reason` 會說明原因。440* **背景是否已繪製**:當連線到工作階段的 Desktop 或行動應用程式表示它會繪製背景時,`$.theme.set` 會以 `isDrawn: true` 解析。否則 `isDrawn` 為 `false`,而 `reason` 會說明原因。

441* **每個工作階段一個背景**:`$.theme.set` 呼叫會取代工作階段的背景,而 `$.theme.clear()` 會移除該背景,無論是哪個 mod 設定的。請只在使用者要求時才呼叫 `$.theme.clear()`。441* **每個工作階段一個主題**:呼叫 `$.theme.set` 的 mod 會取代工作階段的背景與[色彩](#change-the-colors-of-the-desktop-app),而呼叫 `$.theme.clear()` 的 mod 會移除它們,無論是哪個 mod 設定的。請只在使用者要求時才呼叫 `$.theme.clear()`。

442 

443### 變更 Desktop 應用程式的色彩

444 

445若要使用 mod 變更 Desktop 應用程式 Code 分頁的色彩,請[請 Claude 建立一個](#ask-claude-for-a-colors-mod)或[自行撰寫一個](#write-a-colors-mod-yourself)。這兩種方式都需要 Code 分頁中的 Claude Code 為 v2.1.324 或更新版本,因此請先[在該處確認版本](https://code.claude.com/docs/zh-TW/desktop.md#claude-code-version-in-the-code-tab)。終端機中的 Claude Code 會保留自己的色彩。

446 

447#### 請 Claude 建立色彩 mod

448 

449**1. 描述色彩**

450 

451在 Code 分頁中開始一個本機工作階段,並告訴 Claude 您想要的色彩。例如,輸入 `make a mod that makes the app cream in light mode and dark brown in dark mode`。Claude 會撰寫 mod 的檔案。

452 

453**2. 核准 mod**

454 

455回答 Claude Code 針對 mod 的檔案與熱重新載入所提出的問題。關於各個回答的作用,請參閱[請 Claude 建立 mod](https://code.claude.com/docs/zh-TW/plugins/mods/create.md#ask-claude-for-a-mod)。

456 

457**3. 檢查色彩**

458 

459mod 載入時,Code 分頁的色彩就會變更。若要調整某個色彩,請告訴 Claude 要變更什麼。若沒有任何變化,請參閱[修正缺少的 mod 色彩](#fix-missing-mod-colors-in-the-desktop-app)。

460 

461#### 自行撰寫色彩 mod

462 

463`makeColors` 是一個以幾個十六進位色彩建立主題的函式。以下步驟會建立一個使用它、名為 `paper` 的 mod。

464 

465**1. 請 Claude 複製 makeColors**

466 

467在 Code 分頁中開始一個本機工作階段,並輸入 `copy make-colors.js and make-colors.d.ts from your plugin-authoring skill into ~/.claude/skills/paper/hooks/`。確認這兩個檔案都在該目錄中。

468 

469**2. 儲存 manifest 與 hooks.json**

470 

471依照[自行撰寫 mod](https://code.claude.com/docs/zh-TW/plugins/mods/create.md#write-a-mod-yourself),將 `.claude-plugin/plugin.json` 和 `hooks/hooks.json` 儲存到 `~/.claude/skills/paper/` 中,並在這兩個檔案中將 `first-mod` 改為 `paper`。[位於 `~/.claude/skills/` 之下](https://code.claude.com/docs/zh-TW/plugins/create#scaffold-a-plugin-that-loads-every-session)的 mod 會在您開始工作階段時載入。

472 

473**3. 撰寫程式碼**

474 

475將此檔案儲存為 `~/.claude/skills/paper/hooks/register.js`。工作階段開始時,程式碼會以淺色模式與深色模式的色彩呼叫 `$.theme.set`:

476 

477```javascript theme={null}

478import { makeColors } from './make-colors.js'

479 

480const { theme } = makeColors({

481 label: 'Paper',

482 // surface-0 is the background, text-primary is the main text, and text-muted is the faint text

483 light: {

484 gray: { anchors: { 'surface-0': '#efe6d3', 'text-primary': '#2a241d', 'text-muted': '#6a5f50' } },

485 },

486 dark: {

487 gray: { anchors: { 'surface-0': '#1f1a15', 'text-primary': '#f0e7d7', 'text-muted': '#aca08d' } },

488 },

489})

490 

491export function register(on) {

492 on('session.start', async ($, e, next) => {

493 await $.theme.set({ colors: theme })

494 return next(e)

495 })

496}

497```

498 

499若要使用您自己的色彩,請將這些十六進位值替換為其他六位數的十六進位色彩。

500 

501**4. 檢查色彩**

502 

503在 Code 分頁中開始新的本機工作階段。使用範例中的值時,背景在淺色模式下為米色,在深色模式下為深棕色。若沒有任何變化,請參閱[修正缺少的 mod 色彩](#fix-missing-mod-colors-in-the-desktop-app)。

504 

505### 修正 Desktop 應用程式中缺少的 mod 色彩

506 

507若您在 [Claude Desktop v5.11492.5 或更早版本](https://code.claude.com/docs/zh-TW/desktop.md#check-your-version)中使用[第三方供應商](https://code.claude.com/docs/zh-TW/third-party-integrations.md)而非 Claude 帳戶,Code 分頁會保留自己的色彩,因此請略過這些檢查。否則,若 mod 的色彩未出現在 Code 分頁中,或色彩消失,請檢查下列原因:

508 

509* **版本過舊**:[更新 Desktop 應用程式](https://code.claude.com/docs/zh-TW/desktop.md#claude-code-version-in-the-code-tab)、重新啟動它,並在 Code 分頁中開始新的本機工作階段。若 mod 是 Claude 撰寫的,請在該處再次請 Claude 建立。

510* **mod 未載入**:若 mod 是 Claude 撰寫的,請參閱[請 Claude 建立 mod](https://code.claude.com/docs/zh-TW/plugins/mods/create.md#ask-claude-for-a-mod) 了解其載入時機。若 mod 是您自行撰寫的,請將您的檔案及其路徑與[自行撰寫色彩 mod](#write-a-colors-mod-yourself) 進行比對。

511* **主題遭拒絕**:請要求 Claude 執行 mod 的 [`makeColors`](#write-a-colors-mod-yourself) 呼叫。若該呼叫擲出錯誤,或其 `problems` 清單中有以 `Desktop won't paint this theme` 開頭的項目,請讓 Claude 修正主題。若 mod 是您安裝的,請將 Claude 發現的內容傳送給其作者。

512* **另一個 `$.theme` 呼叫**:當工作階段中任何 mod 呼叫 `$.theme.set` 或 `$.theme.clear()` 時,先前呼叫所設定的色彩與[背景](#put-a-backdrop-behind-the-conversation)就會消失。在您自己的 mod 中,請在同一個 `$.theme.set` 呼叫中傳入 `colors` 和 `backdrop`。一次只使用一個設定主題的 mod。

513 

514### 從 Desktop 應用程式移除 mod 色彩

515 

516若要從 Code 分頁移除 mod 的色彩,請先關閉該 mod。仍處於開啟狀態的 mod 可能會再次設定其色彩。

517 

518**1. 關閉 mod**

519 

520* **mod 由 Claude 撰寫**:將其目錄移出 Claude 撰寫它時所在工作階段的 [mod 資料夾](https://code.claude.com/docs/zh-TW/plugins/mods/create.md#ask-claude-for-a-mod)。

521* **您將 mod 放在 `~/.claude/skills/` 之下**:將其目錄(例如 `~/.claude/skills/paper/`)移到 `~/.claude/skills/` 以外的位置。

522* **mod 是您安裝的**:在 Desktop 應用程式中,從 **Manage plugins** [停用或解除安裝其外掛](https://code.claude.com/docs/zh-TW/desktop.md#install-plugins)。若您沒有看到 **Manage plugins**,且您有 [CLI](https://code.claude.com/docs/zh-TW/quickstart.md),可以[從您的 shell 停用或解除安裝市集外掛](https://code.claude.com/docs/zh-TW/plugins/install.md#manage-plugins-from-your-shell)。

523 

524**2. 開始新的工作階段**

525 

526在 Code 分頁中開始新的本機工作階段。

527 

528**3. 移除仍然保留的色彩**

529 

530若色彩仍然存在,請從 Code 分頁開啟 **Settings**,並在其中搜尋 `code appearance`。開啟搜尋結果,然後選取 **Remove colors**。

442 531 

443## 從元素建立樹532## 從元素建立樹

444 533 


677 766 

678相同的按鍵,或在全螢幕渲染中點擊該列,會再次展開帶狀區域。在此之前,沒有任何方式能按下其中的按鈕:沒有快捷鍵、沒有在空白提示詞輸入區中輸入的數字,也沒有按鈕 [`action`](https://code.claude.com/docs/zh-TW/plugins/mods/reference#elements) 的快捷鍵。如果使用者收合帶狀區域時它具有鍵盤焦點,焦點會返回提示詞輸入區,且在收合期間 Ctrl+X 然後 Tab 會略過帶狀區域。767相同的按鍵,或在全螢幕渲染中點擊該列,會再次展開帶狀區域。在此之前,沒有任何方式能按下其中的按鈕:沒有快捷鍵、沒有在空白提示詞輸入區中輸入的數字,也沒有按鈕 [`action`](https://code.claude.com/docs/zh-TW/plugins/mods/reference#elements) 的快捷鍵。如果使用者收合帶狀區域時它具有鍵盤焦點,焦點會返回提示詞輸入區,且在收合期間 Ctrl+X 然後 Tab 會略過帶狀區域。

679 768 

680帶狀區域會保持收合,直到使用者展開它,即使在 `/clear` 之後也是如此,並會在下次 Claude Code 啟動時再次展開。您的 mod 無法展開它,也無法得知它已收合:`ui.render` hook 會持續執行,`e.props` 中也沒有任何內容表明這一點。請勿讓帶狀區域成為您的 mod 顯示使用者必須回應之內容的唯一位置。769帶狀區域會保持收合,直到使用者展開它,即使在 `/clear` 之後也是如此,並會在下次 Claude Code 啟動時再次展開。您的 mod 無法展開它。請勿讓帶狀區域成為您的 mod 顯示使用者必須回應之內容的唯一位置。若要僅在帶狀區域收合時於其他位置顯示該內容,請在您的 `ui.render` hook 中讀取 `e.props.isCollapsed`,該 hook 會持續執行。`isCollapsed` 需要 Claude Code v2.1.321 或更新版本。

681 770 

682### 取得輸入的文字並為每個項目繪製一列771### 取得輸入的文字並為每個項目繪製一列

683 772 

Details

212 212 

213其中部分事件也會針對 Claude Code 自身的動作觸發,因此在拒絕某個事件之前,請先檢查 `next.origin.plugin` 是否為 `engine`。213其中部分事件也會針對 Claude Code 自身的動作觸發,因此在拒絕某個事件之前,請先檢查 `next.origin.plugin` 是否為 `engine`。

214 214 

215#### Claude Code 自身 `http.fetch` 請求上的欄位

216 

217在 `http.fetch` hook 中,值為 `{ plugin: 'engine', tier: 'core' }` 的 [`next.origin`](#the-hook-function) 標示 Claude Code 自身的請求之一,例如模型請求,而非 mod 的 `$.http.fetch` 呼叫。在已載入[內建防護](https://code.claude.com/docs/zh-TW/plugins/mods/admin.md#know-what-happens-by-default)的情況下,除非您的 mod [被視為您組織的 mod](https://code.claude.com/docs/zh-TW/plugins/mods/admin.md#install-your-organizations-mods),否則您的 hook 不會收到這些事件。

218 

219在這些事件上,`e.init` 以及 `next(e)` 所解析的 `value` 可能包含下列欄位等:

220 

221| 欄位 | 意義 |

222| :- | :- |

223| `e.init.compress` | 當 Claude Code 在您的 hook 之後壓縮本文時設定。`e.init.body` 存放未壓縮的本文。若要以未壓縮的形式傳送本文,請呼叫 `next({ ...e, init: { ...e.init, compress: undefined } })`。 |

224| `value.isStreaming` | 設為 `true`,因為 Claude Code 會自行讀取回應本文,所以 `value.text` 為空。請改為讀取 `value.status` 與 `value.headers`。若要以您自己的 `text` 回應,請回傳不含 `isStreaming` 的 `value`。 |

225 

226這些事件與欄位需要 Claude Code v2.1.321 或更新版本。

227 

215## Mods API 方法228## Mods API 方法

216 229 

217mods API 是每個 hook 接收的 `$` 引數。其方法依命名空間分組,例如 `$.ui`。此表依名稱列出每個命名空間的方法,因此 `$.ui` 列中的 `open` 即為呼叫 `$.ui.open(...)`。指南會示範常用方法的用法,而[您建置版本的型別](https://code.claude.com/docs/zh-TW/plugins/mods/create.md#get-the-types-for-your-build)則以範例記錄每個方法。230mods API 是每個 hook 接收的 `$` 引數。其方法依命名空間分組,例如 `$.ui`。此表依名稱列出每個命名空間的方法,因此 `$.ui` 列中的 `open` 即為呼叫 `$.ui.open(...)`。指南會示範常用方法的用法,而[您建置版本的型別](https://code.claude.com/docs/zh-TW/plugins/mods/create.md#get-the-types-for-your-build)則以範例記錄每個方法。


222| [`$.ui`](https://code.claude.com/docs/zh-TW/plugins/mods/interface#pick-where-to-draw) | `resolve`、`invalidate`、`open`、`close`、`panes`、[`place`](https://code.claude.com/docs/zh-TW/plugins/mods/interface#place-a-row-in-the-transcript)、`focus`、`scroll`、`toast`、`notify`、`status`、`log`、`notice`、`ask`、`copy`、`selection`、`blit`、`view`。`view` 需要 Claude Code v2.1.300 或更新版本,`place` 需要 v2.1.314 或更新版本。 |235| [`$.ui`](https://code.claude.com/docs/zh-TW/plugins/mods/interface#pick-where-to-draw) | `resolve`、`invalidate`、`open`、`close`、`panes`、[`place`](https://code.claude.com/docs/zh-TW/plugins/mods/interface#place-a-row-in-the-transcript)、`focus`、`scroll`、`toast`、`notify`、`status`、`log`、`notice`、`ask`、`copy`、`selection`、`blit`、`view`。`view` 需要 Claude Code v2.1.300 或更新版本,`place` 需要 v2.1.314 或更新版本。 |

223| [`$.theme`](https://code.claude.com/docs/zh-TW/plugins/mods/interface#put-a-backdrop-behind-the-conversation) | `set`、`clear`:設定供 Desktop 或行動應用程式繪製的背景,以及移除該背景。需要 Claude Code v2.1.319 或更新版本。 |236| [`$.theme`](https://code.claude.com/docs/zh-TW/plugins/mods/interface#put-a-backdrop-behind-the-conversation) | `set`、`clear`:設定供 Desktop 或行動應用程式繪製的背景,以及移除該背景。需要 Claude Code v2.1.319 或更新版本。 |

224| [`$.command`](https://code.claude.com/docs/zh-TW/plugins/mods/api#add-a-command) | `register`、`run`、`list` |237| [`$.command`](https://code.claude.com/docs/zh-TW/plugins/mods/api#add-a-command) | `register`、`run`、`list` |

225| [`$.tool`](https://code.claude.com/docs/zh-TW/plugins/mods/api#add-a-tool) | `register`、`call`、`check`、`list` |238| [`$.tool`](https://code.claude.com/docs/zh-TW/plugins/mods/api#add-a-tool) | `register`、`call`、`check`、`list`。當某個 `call` 需要由人員核准時,例如 hook 或您的組織以 `ask` 回應的呼叫,它會以 `{ deny: "<tool> wasn't run: this call needs a person's approval, and a mod's own call can't ask for it." }` 解析,其中 `<tool>` 為該工具的名稱。 |

226| `$.agent` | `register`、`spawn`、`list`。`list()` 會回傳此工作階段的 subagent 與隊友,每個都帶有 `status`,其值為 `pending`、`running`、`waiting`、`idle`、`completed`、`failed` 或 `killed`,其中 `idle` 與 `waiting` 需要 Claude Code v2.1.289 或更新版本。 |239| `$.agent` | `register`、`spawn`、`list`。`list()` 會回傳此工作階段的 subagent 與隊友,每個都帶有 `status`,其值為 `pending`、`running`、`waiting`、`idle`、`completed`、`failed` 或 `killed`,其中 `idle` 與 `waiting` 需要 Claude Code v2.1.289 或更新版本。 |

227| [`$.model`](https://code.claude.com/docs/zh-TW/plugins/mods/api#call-a-model) | `complete`、`fork`、`classify` |240| [`$.model`](https://code.claude.com/docs/zh-TW/plugins/mods/api#call-a-model) | `complete`、`fork`、`classify` |

228| [`$.prompt`](https://code.claude.com/docs/zh-TW/plugins/mods/api#start-a-turn-from-a-background-job) | `submit`、`read`、`fill`、`suggest`、`compose`。Claude 會在一個指明您的 mod 為傳送者的句子之後,讀取來自 `submit({ text })` 的文字。`submit({ text, asUser: true })` 會將文字當作使用者本人的話傳送,不附帶該句子。 |241| [`$.prompt`](https://code.claude.com/docs/zh-TW/plugins/mods/api#start-a-turn-from-a-background-job) | `submit`、`read`、`fill`、`suggest`、`compose`。Claude 會在一個指明您的 mod 為傳送者的句子之後,讀取來自 `submit({ text })` 的文字。`submit({ text, asUser: true })` 會將文字當作使用者本人的話傳送,不附帶該句子。 |


250| 位置 | `e.props` | `e.requestId` | 轉譯於 |263| 位置 | `e.props` | `e.requestId` | 轉譯於 |

251| :- | :- | :- | :- |264| :- | :- | :- | :- |

252| [`Pane`](https://code.claude.com/docs/zh-TW/plugins/mods/interface#pick-where-to-draw) | `title`、`isFocused`、`bodyColumns`、`placement`、`scroll`、`view` | 窗格的 `id` | 終端機、Desktop、VS Code |265| [`Pane`](https://code.claude.com/docs/zh-TW/plugins/mods/interface#pick-where-to-draw) | `title`、`isFocused`、`bodyColumns`、`placement`、`scroll`、`view` | 窗格的 `id` | 終端機、Desktop、VS Code |

253| [`AbovePrompt`](https://code.claude.com/docs/zh-TW/plugins/mods/interface#pick-where-to-draw) | `hasSurvey`、`isWorking`、`maxRows`、`bodyColumns`、`scroll`、`view` | 單一實例 | 終端機、Desktop |266| [`AbovePrompt`](https://code.claude.com/docs/zh-TW/plugins/mods/interface#pick-where-to-draw) | `hasSurvey`、[`isCollapsed`](https://code.claude.com/docs/zh-TW/plugins/mods/interface#when-the-user-collapses-the-band)、`isWorking`、`maxRows`、`bodyColumns`、`scroll`、`view` | 單一實例 | 終端機、Desktop |

254| `AbovePromptList`,即 `AbovePrompt` 列的堆疊 | `rows`,一個清單,其中每個 mod 的列各有一個 `{ plugin, tree }`,另加上 `AbovePrompt` 的 prop | 單一實例 | 終端機、Desktop。需要 Claude Code v2.1.323 或更新版本。 |267| `AbovePromptList`,即 `AbovePrompt` 列的堆疊 | `rows`,一個清單,其中每個 mod 的列各有一個 `{ plugin, tree }`,另加上 `AbovePrompt` 的 prop | 單一實例 | 終端機、Desktop。需要 Claude Code v2.1.323 或更新版本。 |

255| [`Placed`](https://code.claude.com/docs/zh-TW/plugins/mods/interface#place-a-row-in-the-transcript) | `id`、`plugin`、`onScreen` | `$.ui.place` 傳回的 `requestId` | 終端機 |268| [`Placed`](https://code.claude.com/docs/zh-TW/plugins/mods/interface#place-a-row-in-the-transcript) | `id`、`plugin`、`onScreen` | `$.ui.place` 傳回的 `requestId` | 終端機 |

256| [`Backdrop`](https://code.claude.com/docs/zh-TW/plugins/mods/interface#put-a-backdrop-behind-the-conversation) | `scene`、`plugin`、`glass`、`overrideColorScheme`。在 v2.1.323 之前,`scene` 為 `id`,`overrideColorScheme` 為 `colorScheme`。 | `backdrop` | `desktop` 與 `mobile` 使用介面。當 Desktop 或行動應用程式要求繪製背景時,您的 hook 就會執行。 |269| [`Backdrop`](https://code.claude.com/docs/zh-TW/plugins/mods/interface#put-a-backdrop-behind-the-conversation) | `scene`、`plugin`、`glass`、`overrideColorScheme`。在 v2.1.323 之前,`scene` 為 `id`,`overrideColorScheme` 為 `colorScheme`。 | `backdrop` | `desktop` 與 `mobile` 使用介面。當 Desktop 或行動應用程式要求繪製背景時,您的 hook 就會執行。 |


426| 名稱 | 位置 | 作用 |439| 名稱 | 位置 | 作用 |

427| :- | :- | :- |440| :- | :- | :- |

428| `CLAUDE_CODE_PLUGIN_DIRS` | 環境,或 `~/.claude/settings.json` 中的 `env` | 以 `--plugin-dir` 的方式載入的外掛目錄,供無法傳入旗標的應用程式使用。以 `:` 分隔的絕對路徑,在 Windows 上則以 `;` 分隔。 |441| `CLAUDE_CODE_PLUGIN_DIRS` | 環境,或 `~/.claude/settings.json` 中的 `env` | 以 `--plugin-dir` 的方式載入的外掛目錄,供無法傳入旗標的應用程式使用。以 `:` 分隔的絕對路徑,在 Windows 上則以 `;` 分隔。 |

429| `CLAUDE_CODE_PLUGIN_DIR_WATCH` | 環境 | `1` 會讓長時間執行的非互動式工作階段在儲存時重新載入 `--plugin-dir` mod |442| `CLAUDE_CODE_PLUGIN_DIR_WATCH` | 環境 | mod 是否在儲存時重新載入。預設值與可用值請參閱[環境變數參考](https://code.claude.com/docs/zh-TW/env-vars.md) |

430| `prependPlugins`、`appendPlugins` | 受管設定。僅在沒有受管設定或 [`managed-mcp.json`](https://code.claude.com/docs/zh-TW/managed-mcp#deploy-managed-mcp-json) 檔案的機器上、且工作階段的憑證不是 Team 或 Enterprise `/login` 時,才可使用使用者設定。 | 外掛 id 的清單,例如 `acme-guard@acme-tools`。`prependPlugins` 中的 mod 會在使用者安裝的每個 mod 之前執行,`appendPlugins` 中的 mod 則在之後執行,並依列出的順序。請參閱 [mod 執行順序](https://code.claude.com/docs/zh-TW/plugins/mods/events.md#the-order-mods-run-in)。 |443| `prependPlugins`、`appendPlugins` | 受管設定。僅在沒有受管設定或 [`managed-mcp.json`](https://code.claude.com/docs/zh-TW/managed-mcp#deploy-managed-mcp-json) 檔案的機器上、且工作階段的憑證不是 Team 或 Enterprise `/login` 時,才可使用使用者設定。 | 外掛 id 的清單,例如 `acme-guard@acme-tools`。`prependPlugins` 中的 mod 會在使用者安裝的每個 mod 之前執行,`appendPlugins` 中的 mod 則在之後執行,並依列出的順序。請參閱 [mod 執行順序](https://code.claude.com/docs/zh-TW/plugins/mods/events.md#the-order-mods-run-in)。 |

431| `allowManagedModsOnly` | 受管設定,作為[內建防護的選項](https://code.claude.com/docs/zh-TW/plugins/mods/admin.md#set-options-on-the-built-in-guard) | 只有[屬於您組織的](https://code.claude.com/docs/zh-TW/plugins/mods/admin.md#install-your-organizations-mods) mod,以及內建於 Claude Code 的 mod,會執行其 hook。使用者的設定 hook 會繼續執行。 |444| `allowManagedModsOnly` | 受管設定,作為[內建防護的選項](https://code.claude.com/docs/zh-TW/plugins/mods/admin.md#set-options-on-the-built-in-guard) | 只有[屬於您組織的](https://code.claude.com/docs/zh-TW/plugins/mods/admin.md#install-your-organizations-mods) mod,以及內建於 Claude Code 的 mod,會執行其 hook。使用者的設定 hook 會繼續執行。 |

432| `allowModsToOverrideDenyRules` | 受管設定,作為[內建防護的選項](https://code.claude.com/docs/zh-TW/plugins/mods/admin.md#set-options-on-the-built-in-guard) | 允許使用者安裝的 mod 核准工具呼叫,越過大部分[預設會維持生效的結果](https://code.claude.com/docs/zh-TW/permissions.md#precedence-among-rules-hooks-and-mods),包括 `deny` 規則 |445| `allowModsToOverrideDenyRules` | 受管設定,作為[內建防護的選項](https://code.claude.com/docs/zh-TW/plugins/mods/admin.md#set-options-on-the-built-in-guard) | 允許使用者安裝的 mod 核准工具呼叫,越過大部分[預設會維持生效的結果](https://code.claude.com/docs/zh-TW/permissions.md#precedence-among-rules-hooks-and-mods),包括 `deny` 規則 |

Details

115 115 

116### 遵循測試套件的規則116### 遵循測試套件的規則

117 117 

118測試套件有一些自己的規則,違反其中一個會產生新測試作者首先遇到的錯誤:

119 

120* **在測試首次呼叫 `$` 之前註冊每個 stub。** 在此之後呼叫 `on` 會拋出錯誤,例如 `on("ui.render") after the test first called $`。118* **在測試首次呼叫 `$` 之前註冊每個 stub。** 在此之後呼叫 `on` 會拋出錯誤,例如 `on("ui.render") after the test first called $`。

121 119 

122* **[`session.start`](https://code.claude.com/docs/zh-TW/plugins/mods/reference#session) 不會自行執行。** 每個測試都以您的模組新鮮載入開始,其 hooks 都未被呼叫,因此模組級變數保持其初始值。如果 hook 依賴於 `session.start` 設定的內容,請先觸發它:120* **[`session.start`](https://code.claude.com/docs/zh-TW/plugins/mods/reference#session) 不會自行執行。** 每個測試都以您的模組新鮮載入開始,其 hooks 都未被呼叫,因此模組級變數保持其初始值。如果 hook 依賴於 `session.start` 設定的內容,請先觸發它:


132 130 

133 第二個 stub 回答 `session.start` hook(例如 [tutorial's](https://code.claude.com/docs/zh-TW/plugins/mods/create.md#write-a-mod-yourself))進行的 `$.command.register` 呼叫。沒有它,該呼叫會以 `no implementation for command.register` 拒絕,套件會跳過您的 hook,因此 hook 中呼叫之後的任何內容都不會執行。測試在該點不會失敗。只有當稍後的檢查失敗時,跳過的 hook 才會在 `the engine reported:` 下列出。131 第二個 stub 回答 `session.start` hook(例如 [tutorial's](https://code.claude.com/docs/zh-TW/plugins/mods/create.md#write-a-mod-yourself))進行的 `$.command.register` 呼叫。沒有它,該呼叫會以 `no implementation for command.register` 拒絕,套件會跳過您的 hook,因此 hook 中呼叫之後的任何內容都不會執行。測試在該點不會失敗。只有當稍後的檢查失敗時,跳過的 hook 才會在 `the engine reported:` 下列出。

134 132 

135* **返回 `next(e)` 的 hook 需要 stub 來回答。** 例如,當您的 [`ui.render`](https://code.claude.com/docs/zh-TW/plugins/mods/reference#interface) hook 返回 `next(e)` 時,為了在 Claude 閒置時不繪製任何內容,[mounting it](#test-a-drawing) 會失敗,並顯示 `no implementation for ui.render`。註冊一個返回元素作為純資料的 stub:133* **註冊 `ui.render` stub 以選擇 `next(e)` 返回的內容。** 當您的 [`ui.render`](https://code.claude.com/docs/zh-TW/plugins/mods/reference#interface) hook 返回 `next(e)` 時(例如為了在 Claude 閒置時不繪製任何內容),即使沒有 stub,[掛載](#test-a-drawing)也會成功。若要讓 `next(e)` 返回您選擇的元素,請註冊一個將該元素作為純資料返回的 stub:

136 134 

137 ```typescript theme={null}135 ```typescript theme={null}

138 // Stands for what Claude Code would draw at the site136 // Stands for what Claude Code would draw at the site

139 on('ui.render', () => ({ type: 'Text', props: {}, children: ['drawn by Claude Code'] }))137 on('ui.render', () => ({ type: 'Text', props: {}, children: ['drawn by Claude Code'] }))

140 ```138 ```

141 139 

142 註冊 stub 後,掛載成功,每當您的 hook 返回 `next(e)` 時,`ui.find({ type: 'Text' })` 都會返回該元素。在 v2.1.323 或更新版本中,若是針對 band,請將您的 mod 名稱作為第二個引數傳給 `on`,例如 `{ plugin: 'my-mod' }`。若未傳入,stub 不會回答您的 `next(e)`。140 在該位置[可以繪製該元素](https://code.claude.com/docs/zh-TW/plugins/mods/interface.md#change-what-claude-code-already-draws)的情況下,當您的 hook 返回 `next(e)` 時,`ui.find({ type: 'Text' })` 會返回該元素。在 v2.1.323 或更新版本中,若是針對 band,請將您的 mod 名稱作為第二個引數傳給 `on`,例如 `{ plugin: 'my-mod' }`。若未傳入,stub 不會回答您的 `next(e)`。在 v2.1.321 之前,除非您註冊該 stub,否則掛載會失敗,並顯示 `no implementation for ui.render`。

143 141 

144* **`turn.step` 的 stub 是一個非同步生成器**,測試會讀取流直到結束以獲得結果:142* **`turn.step` 的 stub 是一個非同步生成器**,測試會讀取流直到結束以獲得結果:

145 143 


316| `press({ key: 'more' })` | 按下具有該 key 的 `Button` |314| `press({ key: 'more' })` | 按下具有該 key 的 `Button` |

317| `input({ key: 'new-note', text: 'buy milk' })` | 將文字輸入到具有該 key 的 `Input` 中並按 Enter。新增 `kind: 'change'` 以輸入而不提交。對於具有 `rows` 的欄位,文字可以包含 `\n`。 |315| `input({ key: 'new-note', text: 'buy milk' })` | 將文字輸入到具有該 key 的 `Input` 中並按 Enter。新增 `kind: 'change'` 以輸入而不提交。對於具有 `rows` 的欄位,文字可以包含 `\n`。 |

318| `select({ key: 'size', value: 'large' })` | 在具有該 key 的 `Select` 中選擇具有該值的選項 |316| `select({ key: 'size', value: 'large' })` | 在具有該 key 的 `Select` 中選擇具有該值的選項 |

317| `keepsBeneath()` | 在沒有 `ui.render` stub 的測試中,當繪圖包含 `next(e)` 傳回的內容時,它解析為 `true`;當您的 hook 將其省略時,則解析為 `false`。在有註冊 stub 的測試中,請使用 `find` 尋找該 stub 繪製的內容。需要 Claude Code v2.1.321 或更新版本。 |

319| `find({ key: 'more' })` 或 `find({ type: 'Text', text: 'Count: 2' })` | 返回第一個匹配的元素作為 `{ type, props, children }`,或 `undefined`。`text` 可以是字串或正規表達式。 |318| `find({ key: 'more' })` 或 `find({ type: 'Text', text: 'Count: 2' })` | 返回第一個匹配的元素作為 `{ type, props, children }`,或 `undefined`。`text` 可以是字串或正規表達式。 |

320| `unmount()` | 移除繪圖 |319| `unmount()` | 移除繪圖 |

321 320 

Details

15當模組未載入、hook 被跳過或另一個 mod 拒絕您的 mod 時,Claude Code 會寫入一行,其中命名您的 mod。您讀取該行的位置取決於工作階段:15當模組未載入、hook 被跳過或另一個 mod 拒絕您的 mod 時,Claude Code 會寫入一行,其中命名您的 mod。您讀取該行的位置取決於工作階段:

16 16 

17* **熱重新載入外掛目錄的工作階段**:逐字稿中的暗淡行。這是您使用 `--plugin-dir` 啟動的互動式工作階段,或您[為 Claude 編寫的 mod 啟用熱重新載入](https://code.claude.com/docs/zh-TW/plugins/mods/create.md#ask-claude-for-a-mod)的工作階段。17* **熱重新載入外掛目錄的工作階段**:逐字稿中的暗淡行。這是您使用 `--plugin-dir` 啟動的互動式工作階段,或您[為 Claude 編寫的 mod 啟用熱重新載入](https://code.claude.com/docs/zh-TW/plugins/mods/create.md#ask-claude-for-a-mod)的工作階段。

18* **任何其他互動式工作階段,例如執行您從市場安裝的 mod 的工作階段**:[偵錯日誌](#read-the-debug-log)只有。若要取得一個,請使用 `claude --debug` 啟動工作階段。18* **任何其他互動式工作階段,例如執行您從市集安裝的 mod 的工作階段**:[偵錯日誌](#read-the-debug-log)。若要取得偵錯日誌,請使用 `claude --debug` 啟動工作階段。

19* **`claude -p` 執行 `--plugin-dir`**:stderr,採用預設文字輸出格式。另一個 mod 的拒絕只會進入偵錯日誌。19* **搭配 `--plugin-dir` 的 `claude -p` 執行**:stderr,採用預設文字輸出格式。另一個 mod 的拒絕會進入偵錯日誌。

20 20 

21## 檢查 mod 是否可以載入21## 檢查 mod 是否可以載入

22 22 


68 68 

69### 來自內建防護的訊息69### 來自內建防護的訊息

70 70 

71在[內建防護](https://code.claude.com/docs/zh-TW/plugins/mods/admin.md#know-what-happens-by-default)載入的地方,它可以拒絕 mod 或其中一個答案。每條訊息都命名您的組織管理員設定以變更規則的選項。71在[內建防護](https://code.claude.com/docs/zh-TW/plugins/mods/admin.md#know-what-happens-by-default)載入的地方,它可以拒絕 mod 或其中一個答案。部分訊息會指出您的組織管理員為變更該規則而設定的選項。

72 72 

73| 訊息包含 | 這表示什麼 | 它出現在哪裡 |73| 訊息包含 | 這表示什麼 | 它出現在哪裡 |

74| :- | :- | :- |74| :- | :- | :- |

75| `mods are limited to your organization's by policy (allowManagedModsOnly)` | 您的組織僅允許[其自己的 mod](https://code.claude.com/docs/zh-TW/plugins/mods/admin.md#install-your-organizations-mods),因此您的 mod 被拒絕 | 偵錯日誌,以及[熱重新載入外掛目錄的工作階段](#find-out-why-a-mod-does-nothing)中的逐字稿 |75| `mods are limited to your organization's by policy (allowManagedModsOnly)` | 您的組織僅允許[其自己的 mod](https://code.claude.com/docs/zh-TW/plugins/mods/admin.md#install-your-organizations-mods),因此您的 mod 被拒絕 | 偵錯日誌,以及[熱重新載入外掛目錄的工作階段](#find-out-why-a-mod-does-nothing)中的逐字稿 |

76| `tried to lift a deny rule in your settings` | 您的 mod 的 [`tool.check`](https://code.claude.com/docs/zh-TW/plugins/mods/reference#tools) hook 批准了 `deny` 規則拒絕的呼叫。呼叫保持被拒絕。 | 文字記錄和偵錯日誌,每個工作階段中的每個 mod 一次。在 `claude -p` 執行中,僅偵錯日誌。 |76| `tried to lift a deny rule in your settings` | 您的 mod 的 [`tool.check`](https://code.claude.com/docs/zh-TW/plugins/mods/reference#tools) hook 批准了 `deny` 規則拒絕的呼叫。呼叫保持被拒絕。 | 逐字稿和偵錯日誌,每個工作階段中的每個 mod 一次。在 `claude -p` 執行中,僅偵錯日誌。 |

77| `the deny rules in your settings could not be checked for this call, so it is refused` | 防護在檢查 mod 批准的呼叫時失敗,因此它拒絕了呼叫 | Claude 為被拒絕的呼叫讀取的原因 |77| `the rules and hooks in your settings could not be checked for this call, so it is refused` | 防護在檢查 mod 批准的呼叫時失敗,因此它拒絕了呼叫 | Claude 為被拒絕的呼叫讀取的原因 |

78 78 

79### `validate` 通過且不列出 `hooks` 行79### `validate` 通過且不列出 `hooks` 行

80 80 


137 137 

138## hook 被跳過或 mod 被卸載138## hook 被跳過或 mod 被卸載

139 139 

140mod 已載入,然後 Claude Code 跳過了其中一個 hook 或卸載了它。

141 

142### `hook skipped`140### `hook skipped`

143 141 

144該行命名 mod 和事件,然後說 `hook skipped:` 和一個原因,例如 `first-mod: tool.call hook skipped: threw Error: boom`。hook 拋出、執行超過其[時間限制](https://code.claude.com/docs/zh-TW/plugins/mods/reference.md#limits),或返回了錯誤形狀的結果。該行針對每個事件和失敗類型出現一次,直到 mod 重新載入。142該行命名 mod 和事件,然後說 `hook skipped:` 和一個原因,例如 `first-mod: tool.call hook skipped: threw Error: boom`。hook 拋出、執行超過其[時間限制](https://code.claude.com/docs/zh-TW/plugins/mods/reference.md#limits),或返回了錯誤形狀的結果。該行針對每個事件和失敗類型出現一次,直到 mod 重新載入。


177 175 

178Claude 看不到此行,因此當您請 Claude 修復時,請將其貼到您的下一則訊息中。176Claude 看不到此行,因此當您請 Claude 修復時,請將其貼到您的下一則訊息中。

179 177 

178### `reload failed`

179 

180將該行與以下內容比對,以確認您的 mod 最後一個可運作的版本是否仍處於載入狀態:

181 

182* `reload failed, the previous version stays loaded: <reason>`:您的 mod 會繼續執行其最後一個可運作的版本。如果下次 Claude Code 重新載入所有外掛時(例如當您執行 `/reload-plugins` 時),您的變更仍無法載入,最後一個可運作的版本就會被卸載。

183* `reload failed: <reason>`:在 Claude Code 提示字元執行 `/plugin`,如果 [`mods active` 行](https://code.claude.com/docs/zh-TW/plugins/mods/overview#see-which-mods-a-session-loaded)截斷了名稱,請加寬終端機。如果該行列出該 mod,其最後一個可運作的版本仍處於載入狀態。如果沒有列出,或沒有這一行,則沒有任何版本處於載入狀態。

184 

185修正原因所指出的問題並儲存您的變更。`reloaded` 行表示它已載入。

186 

180### `$.agent.register refused: the hooks module that made the call is no longer loaded`187### `$.agent.register refused: the hooks module that made the call is no longer loaded`

181 188 

182該行以您的 mod 名稱開頭,例如 `first-mod: $.agent.register refused: the hooks module that made the call is no longer loaded (it was reloaded or removed)`,且該 agent 不會被註冊。您的 mod 在此呼叫之前已被重新載入或卸載。重新載入會載入 hook 模組的新副本,而此呼叫來自仍在舊副本中執行的程式碼,例如尚未返回的 hook。189該行以您的 mod 名稱開頭,例如 `first-mod: $.agent.register refused: the hooks module that made the call is no longer loaded (it was reloaded or removed)`,且該 agent 不會被註冊。您的 mod 在此呼叫之前已被重新載入或卸載。重新載入會載入 hook 模組的新副本,而此呼叫來自仍在舊副本中執行的程式碼,例如尚未返回的 hook。


205 212 

206### 關於您設定中的拒絕規則的訊息213### 關於您設定中的拒絕規則的訊息

207 214 

208`tried to lift a deny rule in your settings` 和 `the deny rules in your settings could not be checked for this call, so it is refused` 都來自內建防護。215`tried to lift a deny rule in your settings` 和 `the rules and hooks in your settings could not be checked for this call, so it is refused` 都來自內建防護。

209 216 

210在[來自內建防護的訊息](#messages-from-the-built-in-guard)中查詢它們。217在[來自內建防護的訊息](#messages-from-the-built-in-guard)中查詢它們。

211 218 


419 426 

420若要在日誌中寫入您自己的行,請呼叫 [`$.ui.log`](https://code.claude.com/docs/zh-TW/plugins/mods/api#show-something-without-starting-a-turn),並帶有第二個引數,例如 `$.ui.log('message', { to: 'debug' })`。沒有第二個引數,`$.ui.log` 會在逐字稿中新增暗淡行。427若要在日誌中寫入您自己的行,請呼叫 [`$.ui.log`](https://code.claude.com/docs/zh-TW/plugins/mods/api#show-something-without-starting-a-turn),並帶有第二個引數,例如 `$.ui.log('message', { to: 'debug' })`。沒有第二個引數,`$.ui.log` 會在逐字稿中新增暗淡行。

421 428 

422當您編輯使用 `--plugin-dir` 載入的 mod 時,逐字稿會為每次重新載入顯示一行,其命名 mod 並列出其 hook。如果儲存破壞了模組,該行說 `reload failed, the previous version stays loaded:` 並帶有原因,最後一個可運作的版本會保持執行,直到 Claude Code 下次重新載入外掛為止,例如當您執行 `/reload-plugins` 時。

423 

424## 後續步驟429## 後續步驟

425 430 

426* [測試 mod](https://code.claude.com/docs/zh-TW/plugins/mods/test.md):在問題到達工作階段之前捕捉它們431* [測試 mod](https://code.claude.com/docs/zh-TW/plugins/mods/test.md):在問題到達工作階段之前捕捉它們

Details

121警告讀起來相同,無論 plugin 來自哪個 marketplace:121警告讀起來相同,無論 plugin 來自哪個 marketplace:

122 122 

123```text theme={null}123```text theme={null}

124Make sure you trust a plugin before installing, updating, or using it. Anthropic does not control what MCP servers, files, or other software are included in plugins and cannot verify that they will work as intended or that they won't change. See each plugin's homepage for more information.124Plugins can run code on your computer, with access to your files and shell. Make sure you trust a plugin before installing, updating, or using it. Anthropic does not control what MCP servers, files, or other software are included in plugins and cannot verify that they will work as intended or that they won't change. See each plugin's homepage for more information.

125```125```

126 126 

127如果您的組織在[受管設定](https://code.claude.com/docs/zh-TW/plugins/org.md)中設定了 `pluginTrustMessage`,Claude Code 會將該文字附加到警告中。127如果您的組織在[受管設定](https://code.claude.com/docs/zh-TW/plugins/org.md)中設定了 `pluginTrustMessage`,Claude Code 會將該文字附加到警告中。

Details

842 842 

843#### `hook error` notices in the transcript843#### `hook error` notices in the transcript

844 844 

845形式為 `... hook error: Failed with non-blocking status code: <stderr>` 的通知表示 hook 執行且其命令失敗。例如,`Stop hook error: Failed with non-blocking status code: /bin/sh: node: command not found` 表示 Claude Code 產生的 shell 找不到 `node`。安裝它,或確保它在您啟動 `claude` 的終端機的 `PATH` 上。845形式為 `... hook error: Failed with non-blocking status code: <stderr>` 的通知表示 hook 的命令失敗。例如,`Stop hook error: Failed with non-blocking status code: /bin/sh: node: command not found` 表示 Claude Code 產生的 shell 找不到 `node`。請安裝它,或確認它位於您啟動 `claude` 的終端機的 `PATH` 上。

846 846 

847如果 stderr 顯示外掛程式的路徑在空格處被截斷,hook 的 shell 形式命令在引號外使用 `${CLAUDE_PLUGIN_ROOT}`,且安裝路徑包含空格。將變數用雙引號括起來或使用 [exec 形式](https://code.claude.com/docs/zh-TW/hooks.md#exec-form-and-shell-form)。若要找到未引用的變數,請在外掛程式目錄上執行 `claude plugin validate`,並查找其 [引用警告](https://code.claude.com/docs/zh-TW/plugins/manifest-reference.md#quoting-and-path-separators)。847如果 stderr 顯示外掛程式的路徑在空格處被截斷,hook 的 shell 形式命令在引號外使用 `${CLAUDE_PLUGIN_ROOT}`,且安裝路徑包含空格。將變數用雙引號括起來或使用 [exec 形式](https://code.claude.com/docs/zh-TW/hooks.md#exec-form-and-shell-form)。若要找到未引用的變數,請在外掛程式目錄上執行 `claude plugin validate`,並查找其 [引用警告](https://code.claude.com/docs/zh-TW/plugins/manifest-reference.md#quoting-and-path-separators)。

848 848 

849如果通知讀作 `Failed to run: Plugin directory does not exist: <path>`,請參閱 [`Plugin directory does not exist`](#plugin-directory-does-not-exist)。849* 如果通知內容為 `Failed to run: Plugin directory does not exist: <path>`,請參閱 [`Plugin directory does not exist`](#plugin-directory-does-not-exist)。

850 850* 對於任何其他錯誤,請使用 [偵錯日誌](https://code.claude.com/docs/zh-TW/hooks.md#debug-hooks) 擷取完整的 stderr。

851對於任何其他錯誤,從外掛程式目錄自行執行 hook 的命令以查看完整輸出,或使用 [偵錯記錄](https://code.claude.com/docs/zh-TW/hooks.md#debug-hooks) 捕捉完整 stderr。

852 851 

853#### A plugin hook blocks a tool call or prompt852#### A plugin hook blocks a tool call or prompt

854 853 


862 861 

863**1. 檢查事件名稱**862**1. 檢查事件名稱**

864 863 

865事件名稱區分大小寫,因此確認您的名稱完全符合,例如 `PostToolUse`。864事件名稱區分大小寫,因此請確認您的名稱完全相符,例如 `PostToolUse`。

866 865 

867**2. 檢查匹配器**866**2. 檢查 matcher**

868 867 

869確認 hook 的 `matcher` 符合工具名稱。868對於 `PostToolUse` 之類的工具事件,請確認 hook 的 `matcher` 與工具名稱相符。

870 869 

871**3. 故意觸發事件**870**3. 刻意觸發事件**

872 871 

873對於 `PostToolUse` hook,要求 Claude 編輯檔案。872依照 [偵錯 hook](https://code.claude.com/docs/zh-TW/hooks.md#debug-hooks) 的說明開啟偵錯日誌。對於 `PostToolUse` hook,請要求 Claude 編輯一個檔案。

874 873 

875**4. 讀取偵錯日誌**874**4. 讀取偵錯日誌**

876 875 

877開啟 [偵錯日誌](https://code.claude.com/docs/zh-TW/hooks.md#debug-hooks),其記錄哪些 hooks 符合。執行的 hook 會出現在那裡及其退出代碼。876開啟 [偵錯日誌](https://code.claude.com/docs/zh-TW/hooks.md#debug-hooks)。已執行的 hook 會連同其退出碼出現在那裡。

878 877 

879### `Plugin directory does not exist: <path>`878### `Plugin directory does not exist: <path>`

880 879 

Details

178已連線的裝置會即時顯示終端機中的對話。下列情況超出一般訊息的範圍:178已連線的裝置會即時顯示終端機中的對話。下列情況超出一般訊息的範圍:

179 179 

180* **壓縮與 `/clear`**:當 Claude Code [壓縮對話](https://code.claude.com/docs/zh-TW/context-window.md#what-survives-compaction)時,已連線的裝置會顯示進度,接著顯示對話被壓縮的位置。當您執行 `/clear` 時,已連線裝置上的對話也會重設。180* **壓縮與 `/clear`**:當 Claude Code [壓縮對話](https://code.claude.com/docs/zh-TW/context-window.md#what-survives-compaction)時,已連線的裝置會顯示進度,接著顯示對話被壓縮的位置。當您執行 `/clear` 時,已連線裝置上的對話也會重設。

181* **使用 `/resume` 或 `/teleport` 後中斷連線**:若已連線的工作階段具有[分享連結](https://code.claude.com/docs/zh-TW/claude-code-on-the-web.md#share-sessions),或 Claude Code 無法檢查是否有分享連結,則當任一命令開啟另一個對話時,Remote Control 會中斷連線。否則,擁有該連結的人將會看到該對話。若要連線新的對話,請在終端機中執行 `/remote-control`。分享連結檢查需要 Claude Code v2.1.324 或更新版本。

181* **使用 `/resume` 切換對話**:已連線的裝置不會收到切換後對話的標題或先前歷程,但雙向的新訊息都會傳送至終端機中目前開啟的對話,或從該對話傳出。若要再次從裝置處理原本的對話,請在終端機中執行 `/resume` 並切換回該對話。182* **使用 `/resume` 切換對話**:已連線的裝置不會收到切換後對話的標題或先前歷程,但雙向的新訊息都會傳送至終端機中目前開啟的對話,或從該對話傳出。若要再次從裝置處理原本的對話,請在終端機中執行 `/resume` 並切換回該對話。

182* **使用 `/teleport` 拉取工作階段**:當您使用 `/teleport` 將[雲端工作階段](https://code.claude.com/docs/zh-TW/claude-code-on-the-web.md#from-cloud-to-terminal)拉取至終端機時,已連線的裝置不會收到所拉取對話的先前歷程。雙向的新訊息會傳送至所拉取的對話或從該對話傳出,該對話現在即為終端機中開啟的對話。183* **使用 `/teleport` 拉取工作階段**:當您使用 `/teleport` 將[雲端工作階段](https://code.claude.com/docs/zh-TW/claude-code-on-the-web.md#from-cloud-to-terminal)拉取至終端機時,已連線的裝置不會收到所拉取對話的先前歷程。雙向的新訊息會傳送至所拉取的對話或從該對話傳出,該對話現在即為終端機中開啟的對話。

183* **來自您其他工作階段的訊息**:透過[跨工作階段傳訊](https://code.claude.com/docs/zh-TW/cross-session-messaging.md),同一個連線會傳遞您在不同機器上各工作階段之間的訊息。184* **來自您其他工作階段的訊息**:透過[跨工作階段傳訊](https://code.claude.com/docs/zh-TW/cross-session-messaging.md),同一個連線會傳遞您在不同機器上各工作階段之間的訊息。

184* **變更的差異**:當工作階段的目錄位於 git 儲存庫中時,已連線裝置的差異窗格會顯示您的變更。在具有領先儲存庫預設分支之提交的分支上,窗格會顯示自該分支從預設分支分出以來的變更,包括您尚未提交的編輯。在預設分支本身,或在未領先預設分支的分支上,窗格只會顯示您尚未提交的變更。185* **變更的差異**:當工作階段的目錄位於 git 儲存庫中時,已連線裝置的差異窗格會顯示您的變更。在具有領先儲存庫預設分支之提交的分支上,窗格會顯示自該分支從預設分支分出以來的變更,包括您尚未提交的編輯。在預設分支本身,或在未領先預設分支的分支上,窗格只會顯示您尚未提交的變更。

185* **模型**:當您從已連線的裝置選擇[模型](https://code.claude.com/docs/zh-TW/model-config.md)時,Claude Code 會以該模型執行工作階段。需要 Claude Code v2.1.238 或更新版本。您從裝置的模型控制項選擇的模型僅適用於目前的工作階段。當您從裝置向互動式工作階段傳送 `/model <name>` 時,Claude Code 也會設定新工作階段的預設值。186* **模型**:當您從已連線的裝置選擇[模型](https://code.claude.com/docs/zh-TW/model-config.md)時,Claude Code 會以該模型執行工作階段。需要 Claude Code v2.1.238 或更新版本。您從裝置的模型控制項選擇的模型僅適用於目前的工作階段。當您從裝置向互動式工作階段傳送 `/model <name>` 時,Claude Code 也會設定新工作階段的預設值。

186* **Effort 等級**:當您從已連線的裝置以 `/effort` 或裝置的 effort 控制項設定 [effort 等級](https://code.claude.com/docs/zh-TW/model-config.md#adjust-effort-level)時,Claude Code 會將其套用至您機器上的工作階段。若您已使用 `CLAUDE_CODE_EFFORT_LEVEL` 固定等級,工作階段會維持該等級,且 Claude Code 會拒絕從 effort 控制項選擇的不同等級。從 effort 控制項選擇等級需要您的機器上安裝 Claude Code v2.1.234 或更新版本。187* **Effort 等級**:當您從已連線的裝置以 `/effort` 或裝置的 effort 控制項設定 [effort 等級](https://code.claude.com/docs/zh-TW/model-config.md#adjust-effort-level)時,Claude Code 會將其套用至您機器上的工作階段。若您已使用 `CLAUDE_CODE_EFFORT_LEVEL` 固定等級,工作階段會維持該等級。從 effort 控制項選擇等級需要您的機器上安裝 Claude Code v2.1.234 或更新版本。

187* **連線失敗後重新連線**:執行 `/remote-control` 即可重新連線。若在此期間壓縮改寫了對話,或您使用 `/resume` 切換了對話,Claude Code 會封存其先前使用的伺服器工作階段,而不會將其留在工作階段清單中。您仍可在 claude.ai/code 的[已封存工作階段](https://code.claude.com/docs/zh-TW/claude-code-on-the-web.md#find-an-archived-session)中找到該工作階段。在裝置仍連線時切換對話不會封存工作階段。188* **連線失敗後重新連線**:執行 `/remote-control` 即可重新連線。若在此期間壓縮改寫了對話,或您使用 `/resume` 切換了對話,Claude Code 會封存其先前使用的伺服器工作階段,而不會將其留在工作階段清單中。您仍可在 claude.ai/code 的[已封存工作階段](https://code.claude.com/docs/zh-TW/claude-code-on-the-web.md#find-an-archived-session)中找到該工作階段。在裝置仍連線時切換對話不會封存工作階段。

188 189 

189### 從瀏覽器分叉工作階段190### 從瀏覽器分叉工作階段


369* **伺服器模式中當機的工作階段**:如果由 `claude remote-control` 提供服務的工作階段當機,請從已連線的裝置向其傳送一則訊息。Claude Code 會再次為其提供服務。您不必重新啟動伺服器。需要 Claude Code v2.1.238 或更新版本。370* **伺服器模式中當機的工作階段**:如果由 `claude remote-control` 提供服務的工作階段當機,請從已連線的裝置向其傳送一則訊息。Claude Code 會再次為其提供服務。您不必重新啟動伺服器。需要 Claude Code v2.1.238 或更新版本。

370* **已連線工作階段上的 HTTP 403 拒絕**:互動式工作階段連線後,當您的機器與 Anthropic 伺服器之間的某個環節以 HTTP 403 回應時(這可能發生在 VPN 或網路變更之後),Claude Code 會持續重試最多三分鐘。如果拒絕持續更久,Claude Code 會中斷連線,而原因會指出是什麼拒絕了連線:網路邊緣,或您自己網路上的代理伺服器、VPN 或防火牆。371* **已連線工作階段上的 HTTP 403 拒絕**:互動式工作階段連線後,當您的機器與 Anthropic 伺服器之間的某個環節以 HTTP 403 回應時(這可能發生在 VPN 或網路變更之後),Claude Code 會持續重試最多三分鐘。如果拒絕持續更久,Claude Code 會中斷連線,而原因會指出是什麼拒絕了連線:網路邊緣,或您自己網路上的代理伺服器、VPN 或防火牆。

371* **長時間網路中斷**:如果您的機器處於喚醒狀態但無法連上網路,接下來的做法取決於模式:372* **長時間網路中斷**:如果您的機器處於喚醒狀態但無法連上網路,接下來的做法取決於模式:

372 * **伺服器模式**:Claude Code 會在大約 10 分鐘後放棄,且 `claude remote-control` 程序會結束。再次執行 `claude remote-control` 以啟動新的工作階段。373 * **伺服器模式**:Claude Code 會在大約 10 分鐘後放棄,且 `claude remote-control` 程序會結束。若要重新啟動伺服器,請參閱[停止伺服器後恢復工作階段](#resume-sessions-after-stopping-the-server)。

373 * **互動式工作階段**:繼續在本機工作。Claude Code 會在中斷期間持續重試,並在網路恢復時自動重新連線。374 * **互動式工作階段**:繼續在本機工作。Claude Code 會在中斷期間持續重試,並在網路恢復時自動重新連線。

374* **無法下載的附件**:如果您從手機或瀏覽器附加的檔案無法下載到您的機器,Claude 仍會收到您的訊息以及已下載的檔案。Claude Code 會在訊息中加入一則附註(例如 `[1 of 3 attachments did not arrive]`)來取代遺失的檔案。375* **無法下載的附件**:如果您從手機或瀏覽器附加的檔案無法下載到您的機器,Claude 仍會收到您的訊息以及已下載的檔案。Claude Code 會在訊息中加入一則附註(例如 `[1 of 3 attachments did not arrive]`)來取代遺失的檔案。

375* **狀態心跳失敗**:如果互動式工作階段因 `could not reach the Remote Control server for about 30 minutes` 而中斷連線,請執行 `/remote-control` 重新連線。376* **狀態心跳失敗**:如果互動式工作階段因 `could not reach the Remote Control server for about 30 minutes` 而中斷連線,請執行 `/remote-control` 重新連線。

376* **轉發的對話框會過期**:Claude Code 會讓權限提示和 `AskUserQuestion` 問題保持開啟,直到您回答為止。當 Claude Code 將其他類型的對話框轉發到遠端工作階段時(例如在安全性拒絕後顯示的模型選擇提示),預設會等待五分鐘,然後關閉對話框並以該對話框的無動作預設值繼續。設定 [`dialogExpiry`](https://code.claude.com/docs/zh-TW/settings-reference#dialogexpiry) 以調整或停用此期限。需要 Claude Code v2.1.224 或更新版本。377* **轉發的對話框會過期**:Claude Code 會讓權限提示和 `AskUserQuestion` 問題保持開啟,直到您回答為止。當 Claude Code 將其他類型的對話框轉發到遠端工作階段時(例如在安全性拒絕後顯示的模型選擇提示),預設會等待五分鐘,然後關閉對話框並以該對話框的無動作預設值繼續。設定 [`dialogExpiry`](https://code.claude.com/docs/zh-TW/settings-reference#dialogexpiry) 以調整或停用此期限。需要 Claude Code v2.1.224 或更新版本。

377* **Fable 用量點數同意提示不會被轉發**:Claude Code 只會在工作階段執行的位置顯示工作階段中途的 [Fable 用量點數同意提示](https://code.claude.com/docs/zh-TW/model-config.md#fable-and-usage-credits),而不會顯示在您的裝置上。當工作階段在終端機中執行,且在 Claude Code 關閉提示之前沒有人在那裡回答時,該回合會在未傳送請求的情況下結束;請參閱[需要確認的提示未獲回應](https://code.claude.com/docs/zh-TW/errors.md#the-prompt-to-confirm-went-unanswered)。378* **未獲回答的 Fable 用量點數提示會結束回合**:如果在 [`dialogExpiry`](https://code.claude.com/docs/zh-TW/settings-reference#dialogexpiry) 期限之前沒有人回答 [Fable 用量點數同意提示](https://code.claude.com/docs/zh-TW/model-config.md#fable-and-usage-credits),該回合就會結束,且不會傳送任何內容;請參閱[需要確認的提示未獲回應](https://code.claude.com/docs/zh-TW/errors.md#the-prompt-to-confirm-went-unanswered)。在終端機中的互動式工作階段裡,該提示也可能出現在您已連線的裝置上,您可以在那裡回答。需要 Claude Code v2.1.323 或更新版本。

378* **部分命令僅限本機使用**:僅在終端機介面中執行的命令(例如 `/plugin` 或 `/resume`)只能從本機 CLI 使用,無論您是否傳入引數。從行動裝置或網頁輸入 `/claude-api` 時也無法使用。Claude 仍可在那裡[自行載入該 skill](https://code.claude.com/docs/zh-TW/skills.md#work-on-claude-api-projects)。以下命令可從行動裝置和網頁使用:379* **部分命令僅限本機使用**:僅在終端機介面中執行的命令(例如 `/plugin` 或 `/resume`)只能從本機 CLI 使用,無論您是否傳入引數。從行動裝置或網頁輸入 `/claude-api` 時也無法使用。Claude 仍可在那裡[自行載入該 skill](https://code.claude.com/docs/zh-TW/skills.md#work-on-claude-api-projects)。以下命令可從行動裝置和網頁使用:

379 * 文字輸出命令:`/compact`、`/clear`、`/context`、`/usage`、`/exit`、`/usage-credits`、`/recap` 和 `/reload-plugins`。`/usage-credits` 會以文字回覆,例如說明在哪裡管理用量點數。`/reload-plugins` 僅在工作階段於互動式終端機中執行時才能運作;沒有互動式終端機的工作階段會拒絕此命令。380 * 文字輸出命令:`/compact`、`/clear`、`/context`、`/usage`、`/exit`、`/usage-credits`、`/recap` 和 `/reload-plugins`。`/usage-credits` 會以文字回覆,例如說明在哪裡管理用量點數。`/reload-plugins` 僅在工作階段於互動式終端機中執行時才能運作;沒有互動式終端機的工作階段會拒絕此命令。

380 * `/model`、`/effort`、`/fast`、`/color` 和 `/rename`:以引數傳入值,例如 `/model sonnet` 或 `/effort high`。從行動裝置和網頁使用時,`/model` 和 `/effort` 會以引數取代終端機中的選擇器或滑桿。381 * `/model`、`/effort`、`/fast`、`/color` 和 `/rename`:以引數傳入值,例如 `/model sonnet` 或 `/effort high`。從行動裝置和網頁使用時,`/model` 和 `/effort` 會以引數取代終端機中的選擇器或滑桿。

381 * `/mcp`:從行動應用程式使用時,會傳回伺服器狀態的文字摘要,而不是開啟選擇器。在網頁上,單獨使用 `/mcp` 會開啟 [claude.ai 連接器](https://code.claude.com/docs/zh-TW/mcp.md#use-mcp-servers-from-claude-ai)目錄,而不是傳回摘要。當工作階段於互動式終端機中執行時,`reconnect`、`enable` 和 `disable` [子命令](https://code.claude.com/docs/zh-TW/commands.md#all-commands)在兩者上皆可使用。不指定伺服器名稱的 `/mcp reconnect` 會重試所有失敗或需要身分驗證的伺服器。若要在不使用選擇器的情況下授權 claude.ai 連接器,請參閱[從您的 shell 再次授權連接器](#authorize-a-connector-again-from-your-shell)。382 * `/mcp`:從行動應用程式使用時,會傳回伺服器狀態的文字摘要,而不是開啟選擇器。在網頁上,單獨使用 `/mcp` 會開啟 [claude.ai 連接器](https://code.claude.com/docs/zh-TW/mcp.md#use-mcp-servers-from-claude-ai)目錄,而不是傳回摘要。當工作階段於互動式終端機中執行時,`reconnect`、`enable` 和 `disable` [子命令](https://code.claude.com/docs/zh-TW/commands.md#all-commands)在兩者上皆可使用。不指定伺服器名稱的 `/mcp reconnect` 會重試所有失敗或需要身分驗證的伺服器。若要在不使用選擇器的情況下授權 claude.ai 連接器,請參閱[從您的 shell 再次授權連接器](#authorize-a-connector-again-from-your-shell)。

382 * `/config`:從行動應用程式使用時,傳入 `key=value` 以設定某個設定項目,或不帶引數執行以列出您可以設定的設定鍵。在網頁上,`/config` 會改為開啟 **Settings > Code** 或 **Settings > Claude Code**。383 * `/config`:從行動應用程式使用時,傳入 `key=value` 以設定某個設定項目,或不帶引數執行以列出您可以設定的設定鍵。在網頁上,`/config` 會改為開啟 **Settings > Code** 或 **Settings > Claude Code**。

383 * 在 Team 和 Enterprise 方案中,從行動裝置或網頁執行 `/usage-credits` 不會向您的管理員傳送[用量點數請求](https://code.claude.com/docs/zh-TW/costs.md#add-usage-credits-to-your-subscription)。傳送需要一個僅在互動式 CLI 中出現的確認,因此該命令會告知您改在那裡執行。384 * 如果您是沒有計費存取權的 Team 或 Enterprise 成員,從行動裝置或網頁執行 `/usage-credits` 不會向您的管理員傳送[用量點數請求](https://code.claude.com/docs/zh-TW/costs.md#add-usage-credits-to-your-subscription)。傳送需要一個僅在互動式 CLI 中出現的確認,因此該命令會告知您改在那裡執行。

384 * `/autocompact`,自 v2.1.221 起:以引數傳入視窗大小,例如 `/autocompact 500k`。不帶引數時,它會以文字輸出目前的視窗大小,而不是開啟該命令在終端機工作階段中顯示的對話框。385 * `/autocompact`,自 v2.1.221 起:以引數傳入視窗大小,例如 `/autocompact 500k`。不帶引數時,它會以文字輸出目前的視窗大小,而不是開啟該命令在終端機工作階段中顯示的對話框。

385 * `/advisor`,自 v2.1.260 起:以引數傳入模型,例如 `/advisor opus`,或傳入 `off` 以關閉 advisor。兩種形式都僅適用於目前的工作階段,不會變更您儲存的預設值。不帶引數時,它會以文字輸出目前的 advisor,而不是開啟選擇器。386 * `/advisor`,自 v2.1.260 起:以引數傳入模型,例如 `/advisor opus`,或傳入 `off` 以關閉 advisor。兩種形式都僅適用於目前的工作階段,不會變更您儲存的預設值。不帶引數時,它會以文字輸出目前的 advisor,而不是開啟選擇器。

386 * `/output-style`,自 v2.1.269 起:以引數傳入風格名稱,例如 `/output-style concise`,或不帶引數執行以列出各種風格。從行動裝置和網頁使用時,您只能列出和選擇[內建風格](https://code.claude.com/docs/zh-TW/output-styles.md#built-in-output-styles)。若要使用[自訂風格](https://code.claude.com/docs/zh-TW/output-styles.md#create-a-custom-output-style),請在工作階段本身中選擇。387 * `/output-style`,自 v2.1.269 起:以引數傳入風格名稱,例如 `/output-style concise`,或不帶引數執行以列出各種風格。從行動裝置和網頁使用時,您只能列出和選擇[內建風格](https://code.claude.com/docs/zh-TW/output-styles.md#built-in-output-styles)。若要使用[自訂風格](https://code.claude.com/docs/zh-TW/output-styles.md#create-a-custom-output-style),請在工作階段本身中選擇。


507 508 

508### "Remote credentials fetch failed"509### "Remote credentials fetch failed"

509 510 

510Claude Code 無法從 Anthropic API 取得短期憑證以建立連線。使用 `--verbose` 重新執行以查看完整錯誤:511Claude Code 無法從 Anthropic API 取得短期憑證以建立連線。若要查看完整錯誤,請從您的 shell 啟動附帶偵錯日誌的工作階段,然後在日誌中搜尋 `code-session`:

511 512 

512```bash theme={null}513```bash theme={null}

513claude remote-control --verbose514claude --remote-control --debug-file claude-debug.log

514```515```

515 516 

516常見原因:517常見原因:

517 518 

518* 未登入:執行 `claude` 並使用 `/login` 以您的 claude.ai 帳戶進行驗證。Remote Control 不支援 API 金鑰驗證。

519* 網路或代理伺服器問題:防火牆或代理伺服器可能阻止了出站 HTTPS 請求。Remote Control 需要存取埠 443 上的 Anthropic API。519* 網路或代理伺服器問題:防火牆或代理伺服器可能阻止了出站 HTTPS 請求。Remote Control 需要存取埠 443 上的 Anthropic API。

520* 工作階段建立失敗:如果您也看到 `Session creation failed — see debug log`,失敗發生在設定的較早階段。檢查您的訂閱是否有效。520* 工作階段建立失敗:如果您也看到 `Session creation failed — see debug log`,失敗發生在設定的較早階段。執行相同的搜尋以找出錯誤。

521 521 

522### "working folder not found"522### "working folder not found"

523 523 

Details

41 41 

42| 您想要 | 開始使用 |42| 您想要 | 開始使用 |

43| :- | :- |43| :- | :- |

44| 在您自己的機器上減少日常工作中的權限提示 | [沙箱化 Bash 工具](https://code.claude.com/docs/zh-TW/sandboxing.md),使用 `/sandbox` 設定 |44| 在您自己的機器上減少日常工作中的權限提示 | 自動允許模式下的 [沙箱化 Bash 工具](https://code.claude.com/docs/zh-TW/sandboxing.md),使用 `/sandbox` 設定 |

45| 讓 Claude 使用 `--dangerously-skip-permissions` 或自動模式無人值守工作 | 預先設定的 [開發容器](https://code.claude.com/docs/zh-TW/devcontainer.md)、任何容器或虛擬機,或 [沙箱執行時](#sandbox-runtime) |45| 讓 Claude 使用 `--dangerously-skip-permissions` 或自動模式無人值守工作 | 預先設定的 [開發容器](https://code.claude.com/docs/zh-TW/devcontainer.md)、任何容器或虛擬機,或 [沙箱執行時](#sandbox-runtime) |

46| 隔離 MCP 伺服器和 hooks 以及 Bash,無需 Docker | 沙箱執行時 |46| 隔離 MCP 伺服器和 hooks 以及 Bash,無需 Docker | 沙箱執行時 |

47| 在團隊中標準化沙箱化環境 | 預先設定的 [開發容器](https://code.claude.com/docs/zh-TW/devcontainer.md),複製到您的儲存庫中 |47| 在團隊中標準化沙箱化環境 | 預先設定的 [開發容器](https://code.claude.com/docs/zh-TW/devcontainer.md),複製到您的儲存庫中 |

sandboxing.md +4 −7

Details

6 6 

7> 使用內建沙箱限制 Claude Code 的 shell 命令可存取的檔案與網路主機。啟用沙箱、設定邊界,並修正它所造成的問題。7> 使用內建沙箱限制 Claude Code 的 shell 命令可存取的檔案與網路主機。啟用沙箱、設定邊界,並修正它所造成的問題。

8 8 

9Bash 沙箱是作業系統在 Claude 於您的電腦上執行的 shell 命令周圍所強制實施的邊界。您可以設定這些命令能存取哪些檔案和網路網域,這些限制適用於 Bash、PowerShell 和 Monitor 命令,以及它們所啟動的程序。由於作業系統會在命令執行期間套用這些限制,Claude Code 可以[執行沙箱化的命令而無需詢問您](#sandbox-modes)是否核准每一個命令。9Bash 沙箱是作業系統在 Claude 於您的電腦上執行的 shell 命令周圍所強制實施的邊界。您可以設定這些命令能存取哪些檔案和網路網域,這些限制適用於 Bash、PowerShell 和 Monitor 命令,以及它們所啟動的程序。沙箱化的命令仍會經過一般的權限流程,除非您選擇[自動允許模式](#sandbox-modes),該模式可以在不詢問您的情況下執行這些命令。

10 10 

11沙箱僅涵蓋 shell 命令。Claude 的檔案工具、MCP 伺服器和 hook [在沙箱之外執行](#what-runs-outside-the-sandbox)。11沙箱僅涵蓋 shell 命令。Claude 的檔案工具、MCP 伺服器和 hook [在沙箱之外執行](#what-runs-outside-the-sandbox)。

12 12 


394| `credentials.envVars` `deny` 和 `mask` 項目 | 強制執行。環境變數清除獨立於檔案系統層 |394| `credentials.envVars` `deny` 和 `mask` 項目 | 強制執行。環境變數清除獨立於檔案系統層 |

395| 以遮罩方式套用的 [`credentials.files` `mask` 項目](#mask-credential-files) | 強制執行:遮罩獨立於檔案系統層。[退回 `deny`](#mask-credential-files) 的項目則不強制執行,與任何 `deny` 項目相同 |395| 以遮罩方式套用的 [`credentials.files` `mask` 項目](#mask-credential-files) | 強制執行:遮罩獨立於檔案系統層。[退回 `deny`](#mask-credential-files) 的項目則不強制執行,與任何 `deny` 項目相同 |

396 396 

397另有兩項變化:397沙箱化命令也會繼承您 shell 的 `$TMPDIR`,而非每位使用者專屬的暫存目錄,因為每個暫存目錄都可寫入,Claude Code 不再將命令重新導向至每位使用者專屬的暫存目錄。

398 398 

399* 沙箱化命令會繼承您 shell 的 `$TMPDIR`,而非每位使用者專屬的暫存目錄,因為每個暫存目錄都可寫入,Claude Code 不再將命令重新導向至每位使用者專屬的暫存目錄。399在 Linux 上,此變數在父 shell 中通常未設定。Bash 工具指引會告知 Claude 使用 `mktemp -d` 建立暫用目錄,而不是依賴 `$TMPDIR`。

400 

401 在 Linux 上,此變數在父 shell 中通常未設定。Bash 工具指引會告知 Claude 使用 `mktemp -d` 建立暫用目錄,而不是依賴 `$TMPDIR`。

402* [`autoAllowBashIfSandboxed`](https://code.claude.com/docs/zh-TW/settings-reference#sandbox-autoallowbashifsandboxed) 仍預設為 `true`,因此沙箱化命令會持續在不顯示提示的情況下執行。將其設為 `false` 即可針對沙箱化命令顯示提示。

403 400 

404### 保護憑證401### 保護憑證

405 402 


1095}1092}

1096```1093```

1097 1094 

1098這會開啟[自動允許模式](#sandbox-modes)。若要使用一般權限模式,請同時將 [`sandbox.autoAllowBashIfSandboxed`](https://code.claude.com/docs/zh-TW/settings-reference#sandbox-autoallowbashifsandboxed) 設定為 `false`。此變更會在 Claude 執行下一個 shell 命令時於您執行中的工作階段生效,之後 `/sandbox` 的 **Mode** 分頁會標示目前生效的模式。1095這會開啟[一般權限模式](#sandbox-modes)。若要使用自動允許模式,請同時將 [`sandbox.autoAllowBashIfSandboxed`](https://code.claude.com/docs/zh-TW/settings-reference#sandbox-autoallowbashifsandboxed) 設定為 `true`。此變更會在 Claude 執行下一個 shell 命令時於您執行中的工作階段生效,之後 `/sandbox` 的 **Mode** 分頁會標示目前生效的模式。

1099 1096 

1100## 限制1097## 限制

1101 1098 

security.md +2 −2

Details

25 25 

26為了降低代理系統中的風險:26為了降低代理系統中的風險:

27 27 

28* **沙箱化 bash 工具**:[Sandbox](https://code.claude.com/docs/zh-TW/sandboxing.md) bash 命令具有檔案系統和網路隔離,減少權限提示同時保持安全性。使用 `/sandbox` 進行配置以定義 Claude Code 可以自主工作的邊界28* **沙箱化 Bash 工具**:以檔案系統和網路隔離將 Bash 命令置於[沙箱](https://code.claude.com/docs/zh-TW/sandboxing.md)中。使用 `/sandbox` 進行設定

29* **工作目錄邊界**:在手動模式中,Claude Code 的檔案工具在讀取或寫入啟動它的資料夾及其子資料夾以外的位置前,會先詢問您。此邊界是一種權限提示,因此您核准的 Bash 命令仍可寫入您的使用者帳戶可寫入的任何位置29* **工作目錄邊界**:在手動模式中,Claude Code 的檔案工具在讀取或寫入啟動它的資料夾及其子資料夾以外的位置前,會先詢問您。此邊界是一種權限提示,因此您核准的 Bash 命令仍可寫入您的使用者帳戶可寫入的任何位置

30 * 若要在沒有提示的情況下讀取某個資料夾,請將其新增為[額外目錄](https://code.claude.com/docs/zh-TW/permissions.md#working-directories)30 * 若要在沒有提示的情況下讀取某個資料夾,請將其新增為[額外目錄](https://code.claude.com/docs/zh-TW/permissions.md#working-directories)

31 * 若要在作業系統層級限制 Bash 命令,請開啟[沙箱機制](https://code.claude.com/docs/zh-TW/sandboxing.md#filesystem-isolation)31 * 若要在作業系統層級限制 Bash 命令,請開啟[沙箱機制](https://code.claude.com/docs/zh-TW/sandboxing.md#filesystem-isolation)


62* **信任驗證**:在互動式工作階段中,當您在尚未信任的資料夾中啟動 Claude Code 時,Claude Code 會顯示工作區信任對話框。專案 `.mcp.json` 中的伺服器有其各自的核准提示,而[專案範圍](https://code.claude.com/docs/zh-TW/mcp.md#project-scope)列出了會略過該提示的工作階段62* **信任驗證**:在互動式工作階段中,當您在尚未信任的資料夾中啟動 Claude Code 時,Claude Code 會顯示工作區信任對話框。專案 `.mcp.json` 中的伺服器有其各自的核准提示,而[專案範圍](https://code.claude.com/docs/zh-TW/mcp.md#project-scope)列出了會略過該提示的工作階段

63 * 注意:`-p` 工作階段不會顯示上述任何一種提示。[在您信任資料夾之前會執行什麼](https://code.claude.com/docs/zh-TW/permissions.md#what-runs-before-you-trust-a-folder)列出了儲存庫的檔案在該情況下可以執行的內容63 * 注意:`-p` 工作階段不會顯示上述任何一種提示。[在您信任資料夾之前會執行什麼](https://code.claude.com/docs/zh-TW/permissions.md#what-runs-before-you-trust-a-folder)列出了儲存庫的檔案在該情況下可以執行的內容

64 * 注意:當您直接在家目錄中啟動 Claude Code 時,信任接受僅在當前工作階段期間保持,不會寫入磁碟,因此提示在每次啟動時都會重新出現。沒有設定可以持久化它。改為從專案子目錄啟動 Claude Code,其中信任接受按目錄保存64 * 注意:當您直接在家目錄中啟動 Claude Code 時,信任接受僅在當前工作階段期間保持,不會寫入磁碟,因此提示在每次啟動時都會重新出現。沒有設定可以持久化它。改為從專案子目錄啟動 Claude Code,其中信任接受按目錄保存

65* **命令注入偵測**:在手動模式中,Claude Code 在執行無法完全分析的 Bash 命令之前會先詢問。針對命令一部分的允許規則(例如 `Bash(git *)`)不會略過該提示。[沙箱化的命令](https://code.claude.com/docs/zh-TW/permissions.md#how-permissions-interact-with-sandboxing)可以在沒有該提示的情況下執行65* **命令注入偵測**:在手動模式中,Claude Code 在執行無法完全分析的 Bash 命令之前會先詢問。針對命令一部分的允許規則(例如 `Bash(git *)`)不會略過該提示。在[自動允許模式](https://code.claude.com/docs/zh-TW/sandboxing.md#auto-allow-mode)中,[沙箱化的命令](https://code.claude.com/docs/zh-TW/permissions.md#how-permissions-interact-with-sandboxing)可以在沒有該提示的情況下執行

66* **故障關閉匹配**:在手動模式中,不匹配的命令預設需要批准66* **故障關閉匹配**:在手動模式中,不匹配的命令預設需要批准

67* **安全的憑證儲存**:API 金鑰和 token 在可用時儲存於 macOS Keychain 中。在 Linux 上,它們儲存在模式為 `0600` 的檔案中;在 Windows 上,則儲存在繼承您使用者設定檔目錄存取控制的檔案中。請參閱 [Credential Management](https://code.claude.com/docs/zh-TW/authentication.md#credential-management)67* **安全的憑證儲存**:API 金鑰和 token 在可用時儲存於 macOS Keychain 中。在 Linux 上,它們儲存在模式為 `0600` 的檔案中;在 Windows 上,則儲存在繼承您使用者設定檔目錄存取控制的檔案中。請參閱 [Credential Management](https://code.claude.com/docs/zh-TW/authentication.md#credential-management)

68 68 

Details

237* 在[端點受管來源](https://code.claude.com/docs/zh-TW/managed-settings.md#choose-a-delivery-mechanism)自行列出或啟用外掛的電腦上,僅由快取清單啟用的外掛在擷取確認 payload 之前,會被視為[使用者的](https://code.claude.com/docs/zh-TW/plugins/mods/admin.md#install-your-organizations-mods)外掛,而非您組織的外掛237* 在[端點受管來源](https://code.claude.com/docs/zh-TW/managed-settings.md#choose-a-delivery-mechanism)自行列出或啟用外掛的電腦上,僅由快取清單啟用的外掛在擷取確認 payload 之前,會被視為[使用者的](https://code.claude.com/docs/zh-TW/plugins/mods/admin.md#install-your-organizations-mods)外掛,而非您組織的外掛

238* Claude Code 會在背景擷取最新設定238* Claude Code 會在背景擷取最新設定

239* 如果工作階段的提供者不在快取的 [`allowedProviders`](https://code.claude.com/docs/zh-TW/settings-reference#allowedproviders) 清單中,Claude Code 可以先等待該擷取完成並再次檢查,然後才拒絕。如果擷取失敗,該工作階段會被拒絕239* 如果工作階段的提供者不在快取的 [`allowedProviders`](https://code.claude.com/docs/zh-TW/settings-reference#allowedproviders) 清單中,Claude Code 可以先等待該擷取完成並再次檢查,然後才拒絕。如果擷取失敗,該工作階段會被拒絕

240* 快取的設定在網路故障期間會持續保留。如果啟動時的擷取失敗,Claude Code 會在互動式工作階段以及 Code 分頁中警告目前生效的是快取的政策240* 請預期快取的設定會在上次成功擷取後 24 小時過期

241* 如果啟動時的擷取在快取設定過期之前失敗,Claude Code 會在互動式工作階段以及 Code 分頁中警告目前生效的是快取的政策

242* 如果啟動時的擷取在快取設定過期之後失敗,工作階段會在沒有伺服器受管設定的情況下啟動,且警告會指出沒有套用任何遠端政策。若要讓 Claude Code 改為結束,請設定 [`forceRemoteSettingsRefresh`](#enforce-fail-closed-startup)

241* 在擷取成功之前,啟動時暫緩的值會持續暫緩243* 在擷取成功之前,啟動時暫緩的值會持續暫緩

242 244 

243Claude Code 會暫緩快取 `env` 區塊中的數類變數,直到伺服器確認該工作階段的 payload 為止。這可防止快取的代理伺服器、憑證授權單位、端點或憑證值重新導向、攔截或重新驗證用來確認 payload 的設定擷取。此強化措施僅適用於從伺服器擷取的設定快取:透過 MDM 或 `managed-settings.json` 部署的[端點受管設定](https://code.claude.com/docs/zh-TW/managed-settings.md#delivery-mechanisms)不受影響。暫緩的類別包括:245Claude Code 會暫緩快取 `env` 區塊中的數類變數,直到伺服器確認該工作階段的 payload 為止。這可防止快取的代理伺服器、憑證授權單位、端點或憑證值重新導向、攔截或重新驗證用來確認 payload 的設定擷取。此強化措施僅適用於從伺服器擷取的設定快取:透過 MDM 或 `managed-settings.json` 部署的[端點受管設定](https://code.claude.com/docs/zh-TW/managed-settings.md#delivery-mechanisms)不受影響。暫緩的類別包括:


285 287 

286### 強制失敗即關閉的啟動288### 強制失敗即關閉的啟動

287 289 

288預設情況下,如果遠端設定擷取在啟動時失敗,CLI 會使用上次成功擷取時快取的設定繼續執行。Claude Code [暫緩的值](#fetch-and-caching-behavior)在擷取成功之前會持續暫緩。在從未擷取過設定的電腦上,CLI 會在沒有伺服器受管設定的情況下繼續執行,並仍會套用裝置上的任何[端點受管設定](https://code.claude.com/docs/zh-TW/managed-settings.md#delivery-mechanisms)。不過,[Anthropic 可能會改為要求取得這些設定](#fetch-and-caching-behavior)。290預設情況下,如果遠端設定擷取在啟動時失敗,CLI 會使用上次成功擷取時快取的設定繼續執行,除非這些設定已[過期](#fetch-and-caching-behavior)。Claude Code [暫緩的值](#fetch-and-caching-behavior)在擷取成功之前會持續暫緩。若快取的設定已過期或沒有快取的設定,CLI 會在沒有伺服器受管設定的情況下繼續執行,並仍會套用裝置上的任何[端點受管設定](https://code.claude.com/docs/zh-TW/managed-settings.md#delivery-mechanisms)。不過,[Anthropic 可能會改為要求取得這些設定](#fetch-and-caching-behavior)。

289 291 

290若要阻止用戶端在快取或缺少伺服器受管設定的情況下啟動,請在受管設定中設定 `forceRemoteSettingsRefresh: true`。292若要阻止用戶端在快取或缺少伺服器受管設定的情況下啟動,請在受管設定中設定 `forceRemoteSettingsRefresh: true`。

291 293 


425 427 

426| 情境 | 行為 |428| 情境 | 行為 |

427| :- | :- |429| :- | :- |

428| 使用者編輯快取的設定檔 | 遭竄改的檔案會在啟動時套用,但 [Claude Code 在伺服器確認 payload 之前暫不套用的值](#fetch-and-caching-behavior)除外。下一次從伺服器擷取時會還原正確的設定,但[僅在下次啟動時才套用的設定鍵](#fetch-and-caching-behavior)除外,例如 `model` 或新增至 `env` 區塊的變數,這些會持續生效直到重新啟動為止 |430| 使用者編輯快取的設定檔 | 遭竄改的檔案可能會在啟動時套用,但 [Claude Code 在伺服器確認 payload 之前暫不套用的值](#fetch-and-caching-behavior)除外。下一次從伺服器擷取時會還原正確的設定。若遭竄改的值屬於[僅在下次啟動時才套用的設定鍵](#fetch-and-caching-behavior),例如 `model` 或新增至 `env` 區塊的變數,則會持續生效直到重新啟動為止 |

429| 使用者刪除快取的設定檔 | 會發生[首次啟動行為](#fetch-and-caching-behavior) |431| 使用者刪除快取的設定檔 | 會發生[首次啟動行為](#fetch-and-caching-behavior) |

430| 使用者執行經修改的 Claude Code 二進位檔 | 能夠執行經修改之用戶端的使用者可以繞過任何用戶端控制 |432| 使用者執行經修改的 Claude Code 二進位檔 | 能夠執行經修改之用戶端的使用者可以繞過任何用戶端控制 |

431| 使用者執行較舊版本的 Claude Code | 早於伺服器受管設定推出的版本不會擷取或套用這些設定 |433| 使用者執行較舊版本的 Claude Code | 早於伺服器受管設定推出的版本不會擷取或套用這些設定 |

432| API 無法使用 | 若有可用的快取設定則會套用。若沒有快取,Claude Code 在下一次成功擷取之前不會強制執行任何伺服器受管設定。[擷取與快取行為](#fetch-and-caching-behavior)列出了例外情況,包括 Anthropic 要求這些設定的情況。設定 `forceRemoteSettingsRefresh: true` 時,CLI 會直接結束而非繼續執行,但 [`claude auth` 子命令](#enforce-fail-closed-startup)除外。透過 [Claude apps 閘道](#platform-availability)登入的用戶端即使沒有該設定也會在啟動時結束,並適用相同的 `claude auth` 豁免 |434| API 無法使用 | 若有可用且尚未[過期](#fetch-and-caching-behavior)的快取設定則會套用。若沒有快取,Claude Code 在下一次成功擷取之前不會強制執行任何伺服器受管設定。[擷取與快取行為](#fetch-and-caching-behavior)列出了例外情況,包括 Anthropic 要求這些設定的情況。設定 `forceRemoteSettingsRefresh: true` 時,CLI 會直接結束而非繼續執行,但 [`claude auth` 子命令](#enforce-fail-closed-startup)除外。透過 [Claude apps 閘道](#platform-availability)登入的用戶端即使沒有該設定也會在啟動時結束,並適用相同的 `claude auth` 豁免 |

433| 使用者以不同的組織進行身分驗證 | 不會向受管組織以外的帳戶傳遞設定,包括使用 [Console API 金鑰](#platform-availability)進行身分驗證的工作階段 |435| 使用者以不同的組織進行身分驗證 | 不會向受管組織以外的帳戶傳遞設定,包括使用 [Console API 金鑰](#platform-availability)進行身分驗證的工作階段 |

434| 使用者設定了[第三方模型供應商](#platform-availability) | 伺服器受管設定會被繞過。這包括設定 `CLAUDE_CODE_USE_BEDROCK`、`CLAUDE_CODE_USE_MANTLE`、`CLAUDE_CODE_USE_VERTEX`、`CLAUDE_CODE_USE_FOUNDRY`、`CLAUDE_CODE_USE_ANTHROPIC_AWS`,或非預設的 `ANTHROPIC_BASE_URL` |436| 使用者設定了[第三方模型供應商](#platform-availability) | 伺服器受管設定會被繞過。這包括設定 `CLAUDE_CODE_USE_BEDROCK`、`CLAUDE_CODE_USE_MANTLE`、`CLAUDE_CODE_USE_VERTEX`、`CLAUDE_CODE_USE_FOUNDRY`、`CLAUDE_CODE_USE_ANTHROPIC_AWS`,或非預設的 `ANTHROPIC_BASE_URL` |

435| 網路流量遭攔截或重新導向 | 停用 TLS 驗證或遭攔截的流量可能會變更用戶端接收到的設定 |437| 網路流量遭攔截或重新導向 | 停用 TLS 驗證或遭攔截的流量可能會變更用戶端接收到的設定 |

sessions.md +22 −4

Details

19| `claude --continue` | 重新開啟目前目錄中最近的工作階段 |19| `claude --continue` | 重新開啟目前目錄中最近的工作階段 |

20| `claude --resume` | 開啟[工作階段選擇器](#use-the-session-picker) |20| `claude --resume` | 開啟[工作階段選擇器](#use-the-session-picker) |

21| `claude --resume <name>` | 直接恢復已命名的工作階段 |21| `claude --resume <name>` | 直接恢復已命名的工作階段 |

22| `claude --resume <session-id>` | 恢復[具有該 ID 的工作階段](#resume-by-session-id-or-name) |

22| `claude --resume <transcript-path>` | 恢復儲存在該絕對路徑之 `.jsonl` [逐字稿檔案](#where-transcripts-are-stored)中的工作階段 |23| `claude --resume <transcript-path>` | 恢復儲存在該絕對路徑之 `.jsonl` [逐字稿檔案](#where-transcripts-are-stored)中的工作階段 |

23| `claude --from-pr <number>` | 開啟工作階段選擇器,並篩選為連結到該 pull request 的工作階段 |24| `claude --from-pr <number>` | 開啟工作階段選擇器,並篩選為連結到該 pull request 的工作階段 |

24| `/resume` | 從進行中的工作階段內切換到不同的工作階段 |25| `/resume` | 從進行中的工作階段內切換到不同的工作階段 |


54* 工作階段範圍的排程任務:[尚未過期的任務](https://code.claude.com/docs/zh-TW/scheduled-tasks.md#limitations)會被復原。背景 Bash 和監視任務則不會。55* 工作階段範圍的排程任務:[尚未過期的任務](https://code.claude.com/docs/zh-TW/scheduled-tasks.md#limitations)會被復原。背景 Bash 和監視任務則不會。

55* 背景工作:隨著前一個程序結束的[背景 subagent](https://code.claude.com/docs/zh-TW/sub-agents.md#run-subagents-in-foreground-or-background)、背景 Bash 命令或[工作流程](https://code.claude.com/docs/zh-TW/workflows.md),會在恢復的逐字稿中顯示為未完成的註記。Claude Code 不會因這些註記而開始一個回合;Claude 會在您的下一個提示詞時一併讀取它們。56* 背景工作:隨著前一個程序結束的[背景 subagent](https://code.claude.com/docs/zh-TW/sub-agents.md#run-subagents-in-foreground-or-background)、背景 Bash 命令或[工作流程](https://code.claude.com/docs/zh-TW/workflows.md),會在恢復的逐字稿中顯示為未完成的註記。Claude Code 不會因這些註記而開始一個回合;Claude 會在您的下一個提示詞時一併讀取它們。

56 57 

57並非原始啟動時的每個設定旗標都會被復原。如果工作階段依賴 `--mcp-config`、`--settings`、`--plugin-dir`、`--fallback-model` 或使用 `--add-dir` 新增的目錄,請在恢復時再次傳遞它們;在工作階段中途使用 `/add-dir` 新增的目錄也不會被復原,但工作階段選擇器仍會使用它們來定位工作階段。標準設定檔(例如 `settings.json` 和 `settings.local.json`)會在啟動時重新讀取,因此存放在其中的設定不需要再次傳遞。關於 `--system-prompt` 和 `--append-system-prompt`,請參閱[恢復對話中的系統提示詞旗標](https://code.claude.com/docs/zh-TW/cli-reference.md#system-prompt-flags-in-resumed-conversations)。58#### 恢復時需再次傳遞的旗標

59 

60> [!NOTE]

61>

62> 當您在[背景工作階段](https://code.claude.com/docs/zh-TW/agent-view.md#what-persists-across-restarts)執行期間重新開啟它,或在它停止後使用 `--bg` 依完整工作階段 ID 恢復它時,請勿重複啟動旗標。在這兩種情況下,工作階段都會保留其旗標。

63 

64對於其他任何 `claude --continue` 或 `claude --resume`,請再次傳遞如下的[旗標](https://code.claude.com/docs/zh-TW/cli-reference.md#cli-flags),因為 Claude Code 不會復原它們:

65 

66* **MCP 伺服器**:`--mcp-config`

67* **外掛**:`--plugin-dir`

68* **目錄**:`--add-dir`,例如 `claude --continue --add-dir ../shared`。對於您使用 `/add-dir` 新增的目錄,也請使用 `--add-dir`。

69* **額外設定**:`--settings`

70* **備援模型**:`--fallback-model`

71 

72關於 `--system-prompt` 和 `--append-system-prompt`,請參閱[恢復對話中的系統提示詞旗標](https://code.claude.com/docs/zh-TW/cli-reference.md#system-prompt-flags-in-resumed-conversations)。

58 73 

59#### 恢復時的權限模式74#### 恢復時的權限模式

60 75 


66* 啟動時的工作階段選擇器:您從[工作階段選擇器](#use-the-session-picker)選擇的工作階段,無論您是單獨使用 `claude --resume`、使用 `claude --from-pr`,還是使用符合多個工作階段的名稱來開啟選擇器。Claude Code 會以從相同命令列啟動新工作階段時的權限模式啟動該工作階段,但以 plan mode 結束的工作階段會在 plan mode 中恢復。如果您傳遞 `--permission-mode`、`--dangerously-skip-permissions` 或 `--fork-session`,Claude Code 不會復原 plan mode。不會復原其他已儲存的權限模式。81* 啟動時的工作階段選擇器:您從[工作階段選擇器](#use-the-session-picker)選擇的工作階段,無論您是單獨使用 `claude --resume`、使用 `claude --from-pr`,還是使用符合多個工作階段的名稱來開啟選擇器。Claude Code 會以從相同命令列啟動新工作階段時的權限模式啟動該工作階段,但以 plan mode 結束的工作階段會在 plan mode 中恢復。如果您傳遞 `--permission-mode`、`--dangerously-skip-permissions` 或 `--fork-session`,Claude Code 不會復原 plan mode。不會復原其他已儲存的權限模式。

67* 在工作階段內使用 `/resume`,帶或不帶引數:您切換到的對話會以您目前工作階段所在的權限模式繼續,但以 plan mode 結束的對話會在 plan mode 中恢復,即使您是以 `--permission-mode` 或 `--dangerously-skip-permissions` 啟動 Claude Code。如果該對話在本次 Claude Code 執行中稍早已開啟過,例如您一開始所在的對話,或您以 `/clear` 或 `/resume` 離開的對話,它則會改為以您目前的權限模式繼續。82* 在工作階段內使用 `/resume`,帶或不帶引數:您切換到的對話會以您目前工作階段所在的權限模式繼續,但以 plan mode 結束的對話會在 plan mode 中恢復,即使您是以 `--permission-mode` 或 `--dangerously-skip-permissions` 啟動 Claude Code。如果該對話在本次 Claude Code 執行中稍早已開啟過,例如您一開始所在的對話,或您以 `/clear` 或 `/resume` 離開的對話,它則會改為以您目前的權限模式繼續。

68 83 

69如果[拒絕規則](https://code.claude.com/docs/zh-TW/permissions.md#manage-permissions)移除了 [`ExitPlanMode`](https://code.claude.com/docs/zh-TW/tools-reference) 工具,Claude 就無法呈現計畫以供核准,因此 Claude Code 不會復原 plan mode。工作階段會以從相同命令列啟動新工作階段時的權限模式啟動。使用 `/resume` 時,對話會以您目前的權限模式繼續。84如果[拒絕規則](https://code.claude.com/docs/zh-TW/permissions.md#manage-permissions)移除了 [`ExitPlanMode`](https://code.claude.com/docs/zh-TW/tools-reference) 工具,或 [`permissions.denyInsteadOfPrompting`](https://code.claude.com/docs/zh-TW/settings-reference#permissions-denyinsteadofprompting) 已開啟,Claude 就無法呈現計畫以供核准,因此 Claude Code 不會復原 plan mode。工作階段會以從相同命令列啟動新工作階段時的權限模式啟動。使用 `/resume` 時,對話會以您目前的權限模式繼續。

70 85 

71在非互動式和 VS Code 路徑上復原 plan mode 需要 Claude Code v2.1.246 或更新版本。每一列列出工作階段結束時的權限模式、您透過終端機、非互動式和 VS Code 中的哪一種路徑恢復它,以及 Claude Code 啟動恢復之工作階段時採用的權限模式。86在非互動式和 VS Code 路徑上復原 plan mode 需要 Claude Code v2.1.246 或更新版本。每一列列出工作階段結束時的權限模式、您透過終端機、非互動式和 VS Code 中的哪一種路徑恢復它,以及 Claude Code 啟動恢復之工作階段時採用的權限模式。

72 87 


74| :- | :- | :- |89| :- | :- | :- |

75| `bypassPermissions` | 終端機 | 新工作階段會啟動的權限模式。若要再次[略過權限](https://code.claude.com/docs/zh-TW/permission-modes.md#skip-all-checks-with-bypasspermissions-mode),請在啟動時使用其啟動旗標之一,或在 [user、`--settings` 或受管設定](https://code.claude.com/docs/zh-TW/settings-reference#permissions-defaultmode)中使用 `permissions.defaultMode: "bypassPermissions"` 啟用它 |90| `bypassPermissions` | 終端機 | 新工作階段會啟動的權限模式。若要再次[略過權限](https://code.claude.com/docs/zh-TW/permission-modes.md#skip-all-checks-with-bypasspermissions-mode),請在啟動時使用其啟動旗標之一,或在 [user、`--settings` 或受管設定](https://code.claude.com/docs/zh-TW/settings-reference#permissions-defaultmode)中使用 `permissions.defaultMode: "bypassPermissions"` 啟用它 |

76| `plan` | 終端機 | plan mode。使用 `--fork-session` 時,則為新工作階段會啟動的權限模式 |91| `plan` | 終端機 | plan mode。使用 `--fork-session` 時,則為新工作階段會啟動的權限模式 |

77| `plan` | 終端機,當拒絕規則移除 `ExitPlanMode` 時 | 新工作階段會啟動的權限模式 |92| `plan` | 終端機,當拒絕規則移除 `ExitPlanMode` 或 `permissions.denyInsteadOfPrompting` 已開啟時 | 新工作階段會啟動的權限模式 |

78| `auto` | 終端機 | `auto`,僅當您的帳戶仍符合[自動模式要求](https://code.claude.com/docs/zh-TW/permission-modes.md#eliminate-prompts-with-auto-mode)時 |93| `auto` | 終端機 | `auto`,僅當您的帳戶仍符合[自動模式要求](https://code.claude.com/docs/zh-TW/permission-modes.md#eliminate-prompts-with-auto-mode)時 |

79| Manual | 終端機 | 當新工作階段會依[內建預設值](https://code.claude.com/docs/zh-TW/permission-modes.md#which-mode-a-session-starts-in)以自動模式啟動時,為 Manual。當設定檔中的 `defaultMode` [生效](https://code.claude.com/docs/zh-TW/permission-modes.md#which-mode-a-session-starts-in)時,Claude Code 則會改以該模式啟動恢復的工作階段 |94| Manual | 終端機 | 當新工作階段會依[內建預設值](https://code.claude.com/docs/zh-TW/permission-modes.md#which-mode-a-session-starts-in)以自動模式啟動時,為 Manual。當設定檔中的 `defaultMode` [生效](https://code.claude.com/docs/zh-TW/permission-modes.md#which-mode-a-session-starts-in)時,Claude Code 則會改以該模式啟動恢復的工作階段 |

80| `plan` | 非互動式,符合[下列條件](#resume-in-plan-mode-with-p)時 | plan mode |95| `plan` | 非互動式,符合[下列條件](#resume-in-plan-mode-with-p)時 | plan mode |


86`claude -p --resume` 或 `claude -p --continue` 執行只有在下列所有條件都成立時,才會以 plan mode 恢復:101`claude -p --resume` 或 `claude -p --continue` 執行只有在下列所有條件都成立時,才會以 plan mode 恢復:

87 102 

88* 您傳遞 [`--permission-prompt-tool`](https://code.claude.com/docs/zh-TW/cli-reference#cli-flags) 且未傳遞 [`--permission-prompts none`](https://code.claude.com/docs/zh-TW/headless#turn-off-permission-prompts-in-unattended-runs),以便 Claude Code 能呈現計畫以供核准103* 您傳遞 [`--permission-prompt-tool`](https://code.claude.com/docs/zh-TW/cli-reference#cli-flags) 且未傳遞 [`--permission-prompts none`](https://code.claude.com/docs/zh-TW/headless#turn-off-permission-prompts-in-unattended-runs),以便 Claude Code 能呈現計畫以供核准

104* [`permissions.denyInsteadOfPrompting`](https://code.claude.com/docs/zh-TW/settings-reference#permissions-denyinsteadofprompting) 未開啟

89* 您未傳遞 `--permission-mode` 或 `--dangerously-skip-permissions`105* 您未傳遞 `--permission-mode` 或 `--dangerously-skip-permissions`

90* 您未傳遞 `--fork-session`106* 您未傳遞 `--fork-session`

91* 該次執行不是透過[頻道](https://code.claude.com/docs/zh-TW/channels.md)啟動的107* 該次執行不是透過[頻道](https://code.claude.com/docs/zh-TW/channels.md)啟動的


159* 預設顯示名稱:您從未命名的互動式工作階段在啟動時仍會獲得預設顯示名稱。預設名稱結合了工作目錄的名稱和一個兩字元的後綴,例如 `my-app-3f`,並在執行中工作階段的列表中識別該工作階段,例如 [agent view](https://code.claude.com/docs/zh-TW/agent-view.md) 和 `claude agents --json` 輸出。預設名稱不是恢復控制代碼。如果您將其傳遞給 `claude --resume` 或 `/resume`,Claude Code 找不到該工作階段。175* 預設顯示名稱:您從未命名的互動式工作階段在啟動時仍會獲得預設顯示名稱。預設名稱結合了工作目錄的名稱和一個兩字元的後綴,例如 `my-app-3f`,並在執行中工作階段的列表中識別該工作階段,例如 [agent view](https://code.claude.com/docs/zh-TW/agent-view.md) 和 `claude agents --json` 輸出。預設名稱不是恢復控制代碼。如果您將其傳遞給 `claude --resume` 或 `/resume`,Claude Code 找不到該工作階段。

160* 生成的標題:如果您未命名 session,Claude Code 會為其生成 session 標題。標題是您第一個提示的簡短摘要,由對小型/快速模型(通常是 Haiku 級別模型)的背景請求編寫。您直接從 shell 或指令碼啟動的 `claude -p` 執行不會獲得一個。176* 生成的標題:如果您未命名 session,Claude Code 會為其生成 session 標題。標題是您第一個提示的簡短摘要,由對小型/快速模型(通常是 Haiku 級別模型)的背景請求編寫。您直接從 shell 或指令碼啟動的 `claude -p` 執行不會獲得一個。

161 177 

178 如果您將 [`CLAUDE_CODE_DISABLE_TERMINAL_TITLE`](https://code.claude.com/docs/zh-TW/env-vars#variables) 設定為 `1`,終端機和 Agent SDK 工作階段不會獲得此標題。

179 

162 接受計畫會將生成的標題替換為基於計畫的標題。您可以將任一標題傳遞給 `claude --resume` 或 `/resume`,Claude Code 會以與您設定的名稱相同的方式解析它。180 接受計畫會將生成的標題替換為基於計畫的標題。您可以將任一標題傳遞給 `claude --resume` 或 `/resume`,Claude Code 會以與您設定的名稱相同的方式解析它。

163 181 

164## 使用 session 選擇器182## 使用 session 選擇器


214| 執行中的 [背景子代理](https://code.claude.com/docs/zh-TW/sub-agents.md#run-subagents-in-foreground-or-background) 和 [背景 Bash 命令](https://code.claude.com/docs/zh-TW/interactive-mode.md#background-bash-commands) | 繼續執行。它們的輸出出現在您切換到的新分支中,而不是在原始 session 中 |232| 執行中的 [背景子代理](https://code.claude.com/docs/zh-TW/sub-agents.md#run-subagents-in-foreground-or-background) 和 [背景 Bash 命令](https://code.claude.com/docs/zh-TW/interactive-mode.md#background-bash-commands) | 繼續執行。它們的輸出出現在您切換到的新分支中,而不是在原始 session 中 |

215| [Remote Control](https://code.claude.com/docs/zh-TW/remote-control.md) 連線 | 保持連線。連線到 session 的手機或瀏覽器會跟隨您進入分支,並在那裡繼續接收新訊息 |233| [Remote Control](https://code.claude.com/docs/zh-TW/remote-control.md) 連線 | 保持連線。連線到 session 的手機或瀏覽器會跟隨您進入分支,並在那裡繼續接收新訊息 |

216 234 

217如果您在兩個終端中恢復同一 session 而不進行分支,來自兩者的訊息會交錯到一個文字記錄中。有關單個 session 內基於 checkpoint 的 rewind,請參閱 [Checkpointing](https://code.claude.com/docs/zh-TW/checkpointing.md)。235如果您同時在兩個終端機或兩次 `claude -p` 執行中恢復同一工作階段,兩者都會寫入同一個逐字稿。之後當您恢復該工作階段時,其中一方的訊息可能會遺失。若要保留兩個對話,請在每個 `claude` 命令中加入 `--fork-session`。有關單一工作階段內基於檢查點的倒回,請參閱[檢查點功能](https://code.claude.com/docs/zh-TW/checkpointing.md)。

218 236 

219## 在 session 內管理上下文237## 在 session 內管理上下文

220 238 

Details

240* [`allowManagedPermissionRulesOnly`](https://code.claude.com/docs/zh-TW/settings-reference#allowmanagedpermissionrulesonly) 和 [`allowManagedMcpServersOnly`](https://code.claude.com/docs/zh-TW/settings-reference#allowmanagedmcpserversonly) 使受管權限和 MCP 允許清單成為唯一適用的清單240* [`allowManagedPermissionRulesOnly`](https://code.claude.com/docs/zh-TW/settings-reference#allowmanagedpermissionrulesonly) 和 [`allowManagedMcpServersOnly`](https://code.claude.com/docs/zh-TW/settings-reference#allowmanagedmcpserversonly) 使受管權限和 MCP 允許清單成為唯一適用的清單

241* `allowedMcpServers` 透過 URL 固定 MCP 伺服器241* `allowedMcpServers` 透過 URL 固定 MCP 伺服器

242* `strictKnownMarketplaces` 允許一個外掛程式市集242* `strictKnownMarketplaces` 允許一個外掛程式市集

243* `sandbox` 沙箱化命令,具有固定的網路允許清單且無沙箱外重試。其 `failIfUnavailable` 鍵會[在沙箱無法執行的環境中阻止 Claude Code 啟動](https://code.claude.com/docs/zh-TW/sandboxing.md#enforce-sandboxing-with-managed-settings)243* `sandbox` 沙箱化命令,具有固定的網路允許清單且無沙箱外重試。其 `failIfUnavailable` 鍵會[在沙箱無法執行的環境中阻止 Claude Code 啟動](https://code.claude.com/docs/zh-TW/sandboxing.md#enforce-sandboxing-with-managed-settings),但 Anthropic 託管的環境除外

244* `requiredMinimumVersion` 設定最低 Claude Code 版本244* `requiredMinimumVersion` 設定最低 Claude Code 版本

245* `cleanupPeriodDays` 將工作階段記錄和其他本機資料的保留期縮短至七天245* `cleanupPeriodDays` 將工作階段記錄和其他本機資料的保留期縮短至七天

246* `companyAnnouncements` 在啟動時顯示訊息246* `companyAnnouncements` 在啟動時顯示訊息

Details

188| [`sandbox.enableWeakerNestedSandbox`](#sandbox-enableweakernestedsandbox) | 在非特權容器內執行 Linux [沙箱](https://code.claude.com/docs/zh-TW/sandboxing.md) | 沙箱設定 | 任何檔案 |188| [`sandbox.enableWeakerNestedSandbox`](#sandbox-enableweakernestedsandbox) | 在非特權容器內執行 Linux [沙箱](https://code.claude.com/docs/zh-TW/sandboxing.md) | 沙箱設定 | 任何檔案 |

189| [`sandbox.enableWeakerNetworkIsolation`](#sandbox-enableweakernetworkisolation) | 在 macOS 上讓 `gh`、`gcloud` 和 `terraform` 能在[沙箱](https://code.claude.com/docs/zh-TW/sandboxing.md#go-based-clis-fail-tls-verification-on-macos)內的 MITM 代理伺服器後方驗證 TLS | 沙箱設定 | 任何檔案 |189| [`sandbox.enableWeakerNetworkIsolation`](#sandbox-enableweakernetworkisolation) | 在 macOS 上讓 `gh`、`gcloud` 和 `terraform` 能在[沙箱](https://code.claude.com/docs/zh-TW/sandboxing.md#go-based-clis-fail-tls-verification-on-macos)內的 MITM 代理伺服器後方驗證 TLS | 沙箱設定 | 任何檔案 |

190| [`sandbox.excludedCommands`](#sandbox-excludedcommands) | 指定 Claude Code 可以在[沙箱](https://code.claude.com/docs/zh-TW/sandboxing.md)外執行的命令 | 沙箱設定 | 任何檔案 |190| [`sandbox.excludedCommands`](#sandbox-excludedcommands) | 指定 Claude Code 可以在[沙箱](https://code.claude.com/docs/zh-TW/sandboxing.md)外執行的命令 | 沙箱設定 | 任何檔案 |

191| [`sandbox.failIfUnavailable`](#sandbox-failifunavailable) | 在[沙箱](https://code.claude.com/docs/zh-TW/sandboxing.md)無法啟動時拒絕啟動,而非在沒有沙箱的情況下執行 | 沙箱設定 | 任何檔案 |191| [`sandbox.failIfUnavailable`](#sandbox-failifunavailable) | 在[沙箱](https://code.claude.com/docs/zh-TW/sandboxing.md)無法啟動時拒絕啟動,而非在沒有沙箱的情況下執行;但在 Anthropic 託管的環境中除外 | 沙箱設定 | 任何檔案 |

192| [`sandbox.filesystem`](#sandbox-filesystem) | 控制[沙箱中](https://code.claude.com/docs/zh-TW/sandboxing.md#filesystem-isolation)的命令可以讀取和寫入哪些路徑 | 沙箱設定 | 任何檔案 |192| [`sandbox.filesystem`](#sandbox-filesystem) | 控制[沙箱中](https://code.claude.com/docs/zh-TW/sandboxing.md#filesystem-isolation)的命令可以讀取和寫入哪些路徑 | 沙箱設定 | 任何檔案 |

193| [`sandbox.filesystem.allowManagedReadPathsOnly`](#sandbox-filesystem-allowmanagedreadpathsonly) | 阻止開發人員重新開放[您組織所封鎖的讀取路徑](https://code.claude.com/docs/zh-TW/sandboxing.md#keep-developers-from-widening-the-policy) | 沙箱設定 | 受管 |193| [`sandbox.filesystem.allowManagedReadPathsOnly`](#sandbox-filesystem-allowmanagedreadpathsonly) | 阻止開發人員重新開放[您組織所封鎖的讀取路徑](https://code.claude.com/docs/zh-TW/sandboxing.md#keep-developers-from-widening-the-policy) | 沙箱設定 | 受管 |

194| [`sandbox.filesystem.allowRead`](#sandbox-filesystem-allowread) | 在 [`denyRead`](#sandbox-filesystem-denyread) 封鎖的區域內重新開放讀取 | 沙箱設定 | 任何檔案 |194| [`sandbox.filesystem.allowRead`](#sandbox-filesystem-allowread) | 在 [`denyRead`](#sandbox-filesystem-denyread) 封鎖的區域內重新開放讀取 | 沙箱設定 | 任何檔案 |


289}289}

290```290```

291 291 

292在 advisor [無法使用](https://code.claude.com/docs/zh-TW/advisor.md#requirements)的供應商上,此鍵不會產生作用,例如 Amazon Bedrock。在 Claude Platform on AWS 上,此鍵需要 Claude Code v2.1.300 或更新版本。`"fable"` 需要 [Fable 存取權](https://code.claude.com/docs/zh-TW/advisor.md#choose-an-advisor-model)。292在 advisor [無法使用](https://code.claude.com/docs/zh-TW/advisor.md#requirements)的供應商上,此鍵不會產生作用,例如 Amazon Bedrock。在 Claude Platform on AWS 或 [Claude Models on Google Cloud (Anthropic managed)](https://code.claude.com/docs/zh-TW/claude-models-on-google-cloud-anthropic-managed.md) 上,此鍵需要 Claude Code v2.1.300 或更新版本。`"fable"` 需要 [Fable 存取權](https://code.claude.com/docs/zh-TW/advisor.md#choose-an-advisor-model)。

293 293 

294### `alwaysThinkingEnabled`294### `alwaysThinkingEnabled`

295 295 


435* **預設值**:未設定,因此失敗的請求不會在其他模型上重試435* **預設值**:未設定,因此失敗的請求不會在其他模型上重試

436* **每個工作階段的覆寫**:`--fallback-model` 在單一工作階段中優先於此鍵436* **每個工作階段的覆寫**:`--fallback-model` 在單一工作階段中優先於此鍵

437 437 

438此範例在主要模型失敗時,先嘗試 Sonnet 5,再嘗試 Haiku 4.5:438此範例在主要模型失敗時,先嘗試 Sonnet 5,再嘗試 Haiku 5.5:

439 439 

440```json settings.json theme={null}440```json settings.json theme={null}

441{441{

442 "fallbackModel": ["claude-sonnet-5", "claude-haiku-4-5"]442 "fallbackModel": ["claude-sonnet-5", "claude-haiku-5-5"]

443}443}

444```444```

445 445 


884}884}

885```885```

886 886 

887此設定鍵在 Code Mode 工作階段中的運作方式不同。請參閱[將所有 shell 命令路由到分類器](https://code.claude.com/docs/zh-TW/auto-mode-config.md#route-all-shell-commands-through-the-classifier)。887此鍵在 Code Mode 工作階段中的運作方式不同。請參閱[暫停 shell 允許規則](https://code.claude.com/docs/zh-TW/auto-mode-config.md#route-all-shell-commands-through-the-classifier)。

888 888 

889### `disableAutoMode`889### `disableAutoMode`

890 890 


1335在沙箱不支援的平台上,開啟此鍵時 Claude Code 不會啟動。請參閱[使用受管設定強制執行沙箱機制](https://code.claude.com/docs/zh-TW/sandboxing.md#enforce-sandboxing-with-managed-settings)。1335在沙箱不支援的平台上,開啟此鍵時 Claude Code 不會啟動。請參閱[使用受管設定強制執行沙箱機制](https://code.claude.com/docs/zh-TW/sandboxing.md#enforce-sandboxing-with-managed-settings)。

1336 1336 

1337* **範圍**:[`Any file`](#scopes),但[對專案和本機設定有所限制](https://code.claude.com/docs/zh-TW/sandboxing.md#repository-settings-under-an-admin-required-sandbox)1337* **範圍**:[`Any file`](#scopes),但[對專案和本機設定有所限制](https://code.claude.com/docs/zh-TW/sandboxing.md#repository-settings-under-an-admin-required-sandbox)

1338* **類型**:Boolean1338* **類型**:布林值

1339 * `true`:當 `sandbox.enabled` 為 `true` 但沙箱無法啟動時,Claude Code 會在啟動時以錯誤結束。若沙箱通過該檢查後初始化失敗,工作階段會繼續執行,而 Claude Code 會[拒絕每個沙箱化命令](https://code.claude.com/docs/zh-TW/sandboxing.md#commands-refused-with-sandbox-is-required)1339 * `true`:當 `sandbox.enabled` 為 `true` 但沙箱無法啟動時,Claude Code 會在啟動時以錯誤結束。如果沙箱通過該檢查後初始化失敗,工作階段會繼續執行。Claude Code 接著會[拒絕每個沙箱化命令](https://code.claude.com/docs/zh-TW/sandboxing.md#commands-refused-with-sandbox-is-required)。在 Anthropic 託管環境中的工作階段仍可啟動(會顯示警告),且不會強制執行您的 `sandbox.filesystem` 或 `sandbox.network` 規則

1340 * `false`:當沙箱無法啟動時,Claude Code 會在沙箱外執行命令1340 * `false`:沙箱無法啟動時,Claude Code 會在沒有沙箱的情況下執行命令

1341* **預設值**:`false`1341* **預設值**:`false`

1342 1342 

1343以下設定會為受管機器開啟沙箱,並將 `failIfUnavailable` 設為 `true`:1343以下設定會為受管機器開啟沙箱,並將 `failIfUnavailable` 設為 `true`:


1355 1355 

1356### `sandbox.autoAllowBashIfSandboxed`1356### `sandbox.autoAllowBashIfSandboxed`

1357 1357 

1358讓 Claude Code 在不顯示權限提示的情況下執行沙箱化的 Bash 命令。無法在沙箱中執行的命令仍會經過一般權限流程,且 `deny` 規則和限定內容的 `ask` 規則(例如 `Bash(git push *)`)仍然適用;單純的 `Bash` ask 規則則會對沙箱化命令略過。將其設為 `false` 可讓沙箱化命令也經過一般權限流程,`/sandbox` 的 **Mode** 分頁將此稱為一般權限模式。1358讓 Claude Code 在沒有權限提示的情況下執行沙箱中的 Bash 命令。無法在沙箱中執行的命令仍會經過一般的權限流程。`deny` 規則以及 `Bash(git push *)` 等限定內容的 `ask` 規則仍然適用,但單純的 `Bash` ask 規則會對沙箱中的命令略過。若要在受管設定中將其設為 `true`,請將其加入您[優先順序最高的受管來源](https://code.claude.com/docs/zh-TW/managed-settings.md#how-claude-code-combines-managed-sources)的 `sandbox` 區塊中。

1359 1359 

1360* **範圍**:[`Any file`](#scopes)1360* **範圍**:[`Any file`](#scopes)

1361* **類型**:布林值1361* **類型**:布林值

1362 * `true`:Claude Code 會在不顯示權限提示的情況下執行沙箱化的 Bash 命令,但[自動允許模式](https://code.claude.com/docs/zh-TW/sandboxing.md#auto-allow-mode)所述的情況除外;`CLAUDE_CODE_SUBPROCESS_ENV_SCRUB` 會關閉自動允許1362 * `true`:Claude Code 會在不顯示權限提示的情況下執行沙箱化的 Bash 命令,但[自動允許模式](https://code.claude.com/docs/zh-TW/sandboxing.md#auto-allow-mode)所述的情況除外;`CLAUDE_CODE_SUBPROCESS_ENV_SCRUB` 會關閉自動允許

1363 * `false`:沙箱化命令會經過一般權限流程,因此由您的允許規則和權限模式決定。`/sandbox` 的 **Mode** 分頁將此稱為一般權限模式1363 * `false`:沙箱化命令會經過一般權限流程,因此由您的允許規則和權限模式決定。`/sandbox` 的 **Mode** 分頁將此稱為一般權限模式

1364* **預設值**:`true`1364* **預設值**:`false`。在 v2.1.324 之前,預設值為 `true`

1365 1365 

1366以下設定會保持沙箱開啟,並讓沙箱化命令經過一般權限流程:1366若要保持沙箱開啟並在沒有權限提示的情況下執行沙箱中的命令,請在 `sandbox` 區塊中同時設定這兩個設定鍵:

1367 1367 

1368```json settings.json theme={null}1368```json settings.json theme={null}

1369{1369{

1370 "sandbox": {1370 "sandbox": {

1371 "enabled": true,1371 "enabled": true,

1372 "autoAllowBashIfSandboxed": false1372 "autoAllowBashIfSandboxed": true

1373 }1373 }

1374}1374}

1375```1375```


1653}1653}

1654```1654```

1655 1655 

1656關閉此層後,Claude Code 不會強制執行 `denyRead` 或 `credentials.files` 的 `deny` 項目,而 `credentials.envVars` 項目和已套用的 `mask` 項目則會繼續運作。[`autoAllowBashIfSandboxed`](#sandbox-autoallowbashifsandboxed) 的預設值仍為 `true`,因此若要繼續提示,請將其設為 `false`。關於可設定此鍵的完整來源清單以及關閉隔離後的變化,請參閱 [停用檔案系統隔離](https://code.claude.com/docs/zh-TW/sandboxing.md#disable-filesystem-isolation)。1656關閉此層時,Claude Code 不會強制執行 `denyRead` 或 `credentials.files` 的 `deny` 項目,而 `credentials.envVars` 項目與已套用的 `mask` 項目則會持續運作。關於可以設定此鍵之來源的完整清單,以及關閉隔離時會有哪些變化,請參閱[停用檔案系統隔離](https://code.claude.com/docs/zh-TW/sandboxing.md#disable-filesystem-isolation)。

1657 1657 

1658### `sandbox.ignoreViolations`1658### `sandbox.ignoreViolations`

1659 1659 


2455#### `env` 值如何與您的 shell 相互作用2455#### `env` 值如何與您的 shell 相互作用

2456 2456 

2457* 此處的值會覆寫在您的 shell 中匯出的相同變數,當多個設定檔設定一個變數時,[最高優先順序](https://code.claude.com/docs/zh-TW/settings.md#settings-precedence)的值適用。[Claude Code 在 `env` 中忽略的變數](#variables-claude-code-ignores-in-env)列出例外情況。2457* 此處的值會覆寫在您的 shell 中匯出的相同變數,當多個設定檔設定一個變數時,[最高優先順序](https://code.claude.com/docs/zh-TW/settings.md#settings-precedence)的值適用。[Claude Code 在 `env` 中忽略的變數](#variables-claude-code-ignores-in-env)列出例外情況。

2458* 當 Claude Desktop 應用程式或[自託管環境](https://code.claude.com/docs/zh-TW/self-hosted-environments)執行器啟動工作階段時,它建置的啟動環境優先:Claude Code 忽略任何設定檔中的 `env` 值,用於啟動環境已經設定的變數。[偵錯日誌](https://code.claude.com/docs/zh-TW/debug-your-config.md)命名每個被忽略的變數。2458* 當 Claude Desktop 應用程式或[自託管環境](https://code.claude.com/docs/zh-TW/self-hosted-environments)執行器啟動工作階段時,改由它建置的啟動環境優先。對於該環境已經設定的變數,Claude Code 會忽略設定檔中的 `env` 值。[偵錯日誌](https://code.claude.com/docs/zh-TW/debug-your-config.md)可以列出被忽略的變數名稱。

2459* 要取消 shell 匯出,請將變數設定為 `""`。Claude Code 將空值視為未設定以進行提供者選擇,子程序繼承空值。2459* 要取消 shell 匯出,請將變數設定為 `""`。Claude Code 將空值視為未設定以進行提供者選擇,子程序繼承空值。

2460* `NO_COLOR` 和 `FORCE_COLOR` 在此設定只到達子程序。要更改 Claude Code 自己的介面顏色,請在啟動 `claude` 之前在您的 shell 中設定它們。2460* `NO_COLOR` 和 `FORCE_COLOR` 在此設定只到達子程序。要更改 Claude Code 自己的介面顏色,請在啟動 `claude` 之前在您的 shell 中設定它們。

2461* 此處的值是設定檔中的純文字,到達 Claude Code 啟動的每個子程序。對於輪換的 OTLP 持有人令牌,使用 [`otelHeadersHelper`](#otelheadershelper);對於 API 認證,使用 [`apiKeyHelper`](#apikeyhelper)。2461* 此處的值是設定檔中的純文字,到達 Claude Code 啟動的每個子程序。對於輪換的 OTLP 持有人令牌,使用 [`otelHeadersHelper`](#otelheadershelper);對於 API 認證,使用 [`apiKeyHelper`](#apikeyhelper)。


4043 4043 

4044| Source | Example entry | Fields |4044| Source | Example entry | Fields |

4045| :- | :- | :- |4045| :- | :- | :- |

4046| `github` | `{ "source": "github", "repo": "acme-corp/plugins", "ref": "main", "path": "marketplace" }` | `repo` 必需;`ref` 是分支或標籤;`path` 是子目錄 |4046| `github` | `{ "source": "github", "repo": "acme-corp/plugins", "ref": "main", "path": "marketplace" }` | `repo` 必需;`ref` 是分支、標籤或提交 SHA;`path` 是子目錄 |

4047| `git` | `{ "source": "git", "url": "https://gitlab.example.com/tools/plugins.git", "ref": "production" }` | `url` 必需;`ref` 和 `path` 如 `github` |4047| `git` | `{ "source": "git", "url": "https://gitlab.example.com/tools/plugins.git", "ref": "production" }` | `url` 必需;`ref` 和 `path` 如 `github` |

4048| `url` | `{ "source": "url", "url": "https://plugins.example.com/marketplace.json", "headers": { "Authorization": "Bearer ${TOKEN}" } }` | `url` 必需;`headers` 為已驗證存取新增 HTTP 標頭 |4048| `url` | `{ "source": "url", "url": "https://plugins.example.com/marketplace.json", "headers": { "Authorization": "Bearer ${TOKEN}" } }` | `url` 必需;`headers` 為已驗證存取新增 HTTP 標頭 |

4049| `file` | `{ "source": "file", "path": "/opt/acme-corp/plugins/marketplace.json" }` | `path` 必需,`marketplace.json` 檔案的絕對路徑 |4049| `file` | `{ "source": "file", "path": "/opt/acme-corp/plugins/marketplace.json" }` | `path` 必需,`marketplace.json` 檔案的絕對路徑 |


4870 4870 

4871### `agentPushNotifEnabled`4871### `agentPushNotifEnabled`

4872 4872 

4873允許 Claude 在決定值得傳送時,向您的手機傳送推播通知,例如當長時間任務完成時。在本機工作階段中,Claude 可以在 [Remote Control](https://code.claude.com/docs/zh-TW/remote-control.md) 連線時傳送通知。在 `/config` 中顯示為 **Push when Claude decides**。當您在那裡變更此設定時,Claude Code 也會將該值儲存到您的帳戶。4873允許 Claude 在決定值得傳送時,向您的手機傳送推播通知,例如當長時間任務完成時。在本機工作階段中,Claude 可以在 [Remote Control](https://code.claude.com/docs/zh-TW/remote-control.md) 連線時傳送通知。在 `/config` 中顯示為 **Push when Claude decides**。

4874 4874 

4875* **範圍**:[`任何檔案`](#scopes)。Claude Code 也會讀取舊版本在 `~/.claude.json` 中留下的值。4875* **範圍**:[`任何檔案`](#scopes)。Claude Code 也會讀取舊版本在 `~/.claude.json` 中留下的值。

4876* **類型**:布林值4876* **類型**:布林值


4884}4884}

4885```4885```

4886 4886 

4887如果您在 [`claude remote-control`](https://code.claude.com/docs/zh-TW/remote-control#start-a-remote-control-session) 伺服器下執行工作階段,這些工作階段會遵循儲存在您帳戶中的值,而非此金鑰。若要變更該值,請在終端機中的 Claude Code 工作階段執行 `/config`,並將 **Push when Claude decides** 開啟或關閉。如果切換開關已顯示您想要的值,請先將其變更再改回,讓 Claude Code 將該值儲存到您的帳戶。4887僅設定此金鑰並不會讓您收到通知。若要設定通知,請依照[行動推播通知](https://code.claude.com/docs/zh-TW/remote-control.md#mobile-push-notifications)中的步驟操作。

4888 4888 

4889請參閱[行動推播通知](https://code.claude.com/docs/zh-TW/remote-control.md#mobile-push-notifications)。4889如果您在 [`claude remote-control`](https://code.claude.com/docs/zh-TW/remote-control#start-a-remote-control-session) 伺服器下執行工作階段,這些工作階段會遵循儲存在您帳戶中的值,而非此金鑰。若要變更該值,請在終端機中的 Claude Code 工作階段執行 `/config`,並將 **Push when Claude decides** 開啟或關閉。如果切換開關已顯示您想要的值,請先將其變更再改回,讓 Claude Code 將該值儲存到您的帳戶。

4890 4890 

4891### `awaySummaryEnabled`4891### `awaySummaryEnabled`

4892 4892 


5043}5043}

5044```5044```

5045 5045 

5046請參閱[行動推播通知](https://code.claude.com/docs/zh-TW/remote-control.md#mobile-push-notifications)。5046僅設定此金鑰並不會讓您收到通知。若要設定通知,請依照[行動推播通知](https://code.claude.com/docs/zh-TW/remote-control.md#mobile-push-notifications)中的步驟操作。

5047 5047 

5048### `preferredNotifChannel`5048### `preferredNotifChannel`

5049 5049 


5193 * `"vertex"`:[Google Cloud 的 Agent Platform](https://code.claude.com/docs/zh-TW/google-vertex-ai.md),前身為 Vertex AI5193 * `"vertex"`:[Google Cloud 的 Agent Platform](https://code.claude.com/docs/zh-TW/google-vertex-ai.md),前身為 Vertex AI

5194 * `"foundry"`:[Microsoft Foundry](https://code.claude.com/docs/zh-TW/microsoft-foundry.md)5194 * `"foundry"`:[Microsoft Foundry](https://code.claude.com/docs/zh-TW/microsoft-foundry.md)

5195 * `"anthropicAws"`:[AWS 上的 Claude Platform](https://code.claude.com/docs/zh-TW/claude-platform-on-aws.md)5195 * `"anthropicAws"`:[AWS 上的 Claude Platform](https://code.claude.com/docs/zh-TW/claude-platform-on-aws.md)

5196 * `"anthropicGoogleCloud"`:[Google Cloud 上的 Claude Models(由 Anthropic 管理)](https://code.claude.com/docs/zh-TW/claude-models-on-google-cloud-anthropic-managed.md)

5196 * `"mantle"`:Amazon Bedrock [Mantle 端點](https://code.claude.com/docs/zh-TW/amazon-bedrock.md#use-the-mantle-endpoint)。[在 Invoke API 旁邊執行 Mantle](https://code.claude.com/docs/zh-TW/amazon-bedrock.md#run-mantle-alongside-the-invoke-api) 的工作階段使用兩個提供者,因此將 `"bedrock"` 和 `"mantle"` 一起列出5197 * `"mantle"`:Amazon Bedrock [Mantle 端點](https://code.claude.com/docs/zh-TW/amazon-bedrock.md#use-the-mantle-endpoint)。[在 Invoke API 旁邊執行 Mantle](https://code.claude.com/docs/zh-TW/amazon-bedrock.md#run-mantle-alongside-the-invoke-api) 的工作階段使用兩個提供者,因此將 `"bedrock"` 和 `"mantle"` 一起列出

5197 * `"customEndpoint"`:Anthropic API 或雲端提供者的 API 傳送到另一個主機,例如由 `ANTHROPIC_BASE_URL` 或提供者的端點變數(例如 `ANTHROPIC_BEDROCK_BASE_URL`)命名的 [LLM 閘道](https://code.claude.com/docs/zh-TW/llm-gateway)。Claude Code 僅針對受管 [`env`](#env) 區塊固定的確切值允許它5198 * `"customEndpoint"`:Anthropic API 或雲端提供者的 API 傳送到另一個主機,例如由 `ANTHROPIC_BASE_URL` 或提供者的端點變數(例如 `ANTHROPIC_BEDROCK_BASE_URL`)命名的 [LLM 閘道](https://code.claude.com/docs/zh-TW/llm-gateway)。Claude Code 僅針對受管 [`env`](#env) 區塊固定的確切值允許它

5198 * `"gateway"`:[Cloud gateway](https://code.claude.com/docs/zh-TW/claude-apps-gateway) 登入5199 * `"gateway"`:[Cloud gateway](https://code.claude.com/docs/zh-TW/claude-apps-gateway) 登入


5421 5422 

5422### `minimumVersion`5423### `minimumVersion`

5423 5424 

5424防止背景自動更新和 `claude update` 安裝低於此版本的任何版本,因此移至 `"stable"` 頻道不會從較新的 `"latest"` 組建中降級您。當您在 `/config` 中選擇在切換頻道時保持在目前版本時,Claude Code 會為您寫入此金鑰,並在您切換回 `"latest"` 時清除它。5425防止背景自動更新和 `claude update` 安裝低於您所設定版本的任何版本。當您在 `/config` 中切換頻道時選擇保持在目前版本,Claude Code 會為您寫入此金鑰。當您在 `/config` 中切換回 `"latest"` 時,Claude Code 會清除此金鑰。

5425 5426 

5426* **範圍**:[`Any file`](#scopes)。在受管設定中設定以固定組織範圍的最小值,使用者和專案設定無法降低。5427* **範圍**:[`Any file`](#scopes)。在受管設定中設定此金鑰,以固定使用者和專案設定無法覆寫的組織範圍最小值。

5427* **類型**:字串,版本號碼,例如 `"2.1.100"`;不是有效版本的值會被忽略5428* **類型**:字串,版本號碼,例如 `"2.1.323"`;不是有效版本的值會被忽略

5428* **預設**:未設定,因此更新可以安裝頻道提供的任何版本5429* **預設**:未設定,因此更新可以安裝頻道提供的任何版本

5429 5430 

5430此範例遵循穩定頻道,並拒絕安裝低於 2.1.100 的任何版本:5431此範例遵循穩定頻道,並拒絕安裝低於 2.1.323 的任何版本:

5431 5432 

5432```json settings.json theme={null}5433```json settings.json theme={null}

5433{5434{

5434 "autoUpdatesChannel": "stable",5435 "autoUpdatesChannel": "stable",

5435 "minimumVersion": "2.1.100"5436 "minimumVersion": "2.1.323"

5436}5437}

5437```5438```

5438 5439 

setup.md +19 −10

Details

40>40>

41> **macOS、Linux、WSL:**41> **macOS、Linux、WSL:**

42>42>

43> ```bash theme={null}43> ```bash theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null}

44> curl -fsSL https://claude.ai/install.sh | bash44> curl -fsSL https://claude.ai/install.sh | bash

45> ```45> ```

46>46>


48>48>

49> **Windows PowerShell:**49> **Windows PowerShell:**

50>50>

51> ```powershell theme={null}51> ```powershell theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null}

52> irm https://claude.ai/install.ps1 | iex52> irm https://claude.ai/install.ps1 | iex

53> ```53> ```

54>54>

55> **Windows CMD:**55> **Windows CMD:**

56>56>

57> ```batch theme={null}57> ```batch theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null}

58> curl -fsSL https://claude.ai/install.cmd -o install.cmd && install.cmd && del install.cmd58> curl -fsSL https://claude.ai/install.cmd -o install.cmd && install.cmd && del install.cmd

59> ```59> ```

60>60>


72 72 

73> [tab] Homebrew73> [tab] Homebrew

74>74>

75> ```bash theme={null}75> ```bash theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null}

76> brew install --cask claude-code76> brew install --cask claude-code

77> ```77> ```

78>78>


84 84 

85> [tab] WinGet85> [tab] WinGet

86>86>

87> ```powershell theme={null}87> ```powershell theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null} theme={null}

88> winget install Anthropic.ClaudeCode88> winget install Anthropic.ClaudeCode

89> ```89> ```

90>90>


220}220}

221```221```

222 222 

223使用此設定時,即使穩定版本比您目前的版本舊,原生安裝仍會更新至該穩定版本。若要避免降級,請同時[固定最低版本](#pin-a-minimum-version)。

224 

223新推出的模型可能需要比穩定通道所提供版本更新的 Claude Code 版本。若要立即執行該模型,請切換至最新通道。225新推出的模型可能需要比穩定通道所提供版本更新的 Claude Code 版本。若要立即執行該模型,請切換至最新通道。

224 226 

225對於企業部署,您可以使用[受管設定](https://code.claude.com/docs/zh-TW/managed-settings.md)在整個組織中強制執行一致的發行版本通道。227對於企業部署,您可以使用[受管設定](https://code.claude.com/docs/zh-TW/managed-settings.md)在整個組織中強制執行一致的發行版本通道。


230 232 

231### 固定最低版本233### 固定最低版本

232 234 

233`minimumVersion` 設定建立一個下限。背景自動更新和 `claude update` 拒絕安裝低於此值的任何版本,因此如果您已經在較新的 `"latest"` 組建上,移至 `"stable"` 通道不會降級您。235若要將原生安裝移至 `"stable"` [發行版本通道](#configure-release-channel)而不降級,請將 [`minimumVersion`](https://code.claude.com/docs/zh-TW/settings-reference#minimumversion) 設定為您目前執行的版本。背景自動更新和 `claude update` 會拒絕安裝任何低於此最低版本的版本。

236 

237在 `/config` 中設定最低版本可讓 Claude Code 自動填入您目前的版本;在設定檔中設定則需自行輸入版本號:

234 238 

235透過 `/config` 從 `"latest"` 切換到 `"stable"` 會提示您保留目前版本或允許降級。選擇保留會將 `minimumVersion` 設定為該版本。切換回 `"latest"` 會清除它。239* **在 `/config` 中**:將**自動更新通道**切換為 stable,然後選取**保留目前版本**。如果您在 `/config` 中切換回 latest,Claude Code 會清除最低版本。

240* **在您的[設定檔](https://code.claude.com/docs/zh-TW/settings.md)中**:在 shell 中執行 `claude --version`,並將 `minimumVersion` 設定為輸出開頭的版本號。在同一次編輯中,將 `autoUpdatesChannel` 設定為 `"stable"`。

236 241 

237將其新增到您的 [settings.json 檔案](https://code.claude.com/docs/zh-TW/settings.md)以明確固定下限:242以下 `~/.claude/settings.json` 會將版本 2.1.323 上的安裝切換至 stable:

238 243 

239```json theme={null}244```json theme={null}

240{245{

241 "autoUpdatesChannel": "stable",246 "autoUpdatesChannel": "stable",

242 "minimumVersion": "2.1.100"247 "minimumVersion": "2.1.323"

243}248}

244```249```

245 250 

246在[受管設定](https://code.claude.com/docs/zh-TW/managed-settings.md)中,這會強制執行使用者和專案設定無法覆蓋的組織範圍最低版本。251該安裝會保持在 2.1.323,直到穩定通道提供更新的版本為止。

252 

253#### 為您的組織設定版本限制

254 

255在[受管設定](https://code.claude.com/docs/zh-TW/managed-settings.md)中,`minimumVersion` 會強制執行使用者和專案設定無法覆寫的組織範圍最低版本。

247 256 

248`minimumVersion` 固定只會限制更新。若要讓 Claude Code 拒絕在版本範圍外啟動,請改為使用受管設定 `requiredMinimumVersion` 和 `requiredMaximumVersion`。更新也會遵守 `requiredMaximumVersion` 上限。請參閱[`requiredMinimumVersion`](https://code.claude.com/docs/zh-TW/settings-reference#requiredminimumversion)和[`requiredMaximumVersion`](https://code.claude.com/docs/zh-TW/settings-reference#requiredmaximumversion)。257`minimumVersion` 固定只會限制更新。若要讓 Claude Code 拒絕在版本範圍外啟動,請改為使用受管設定 `requiredMinimumVersion` 和 `requiredMaximumVersion`。更新也會遵守 `requiredMaximumVersion` 上限。請參閱[`requiredMinimumVersion`](https://code.claude.com/docs/zh-TW/settings-reference#requiredminimumversion)和[`requiredMaximumVersion`](https://code.claude.com/docs/zh-TW/settings-reference#requiredmaximumversion)。

249 258 

skills.md +18 −13

Details

14>14>

15> 如需內建命令(如 `/help` 和 `/compact`)以及捆綁的 skills(如 `/debug` 和 `/code-review`),請參閱[命令參考](https://code.claude.com/docs/zh-TW/commands.md)。15> 如需內建命令(如 `/help` 和 `/compact`)以及捆綁的 skills(如 `/debug` 和 `/code-review`),請參閱[命令參考](https://code.claude.com/docs/zh-TW/commands.md)。

16>16>

17> **自訂命令已合併到 skills 中。** `.claude/commands/deploy.md` 中的檔案和 `.claude/skills/deploy/SKILL.md` 中的 skill 都會建立 `/deploy` 並以相同方式運作。您現有的 `.claude/commands/` 檔案會繼續運作。Skills 新增了選用功能:支援檔案的目錄、[控制您或 Claude 是否叫用它們](#control-who-invokes-a-skill)的 frontmatter,以及 Claude 在相關時自動載入它們的能力。17> **自訂命令已合併到 skills 中。** 您現有的 `.claude/commands/` 檔案會繼續運作。Claude 可以在您未輸入命令的情況下叫用它們。編輯命令以阻止 Claude 自行叫用它,或將需要多個檔案的命令轉換為 skill:

18>

19> * **阻止 Claude 自行叫用命令**:在命令檔案的 [frontmatter](#frontmatter-reference) 中新增 [`disable-model-invocation: true`](#control-who-invokes-a-skill)

20> * **新增[支援檔案](#add-supporting-files)(例如指令碼)**:將命令轉換為 skill。例如,將 `.claude/commands/deploy.md` 移至 `.claude/skills/deploy/SKILL.md`。[資料夾名稱會成為命令](#how-a-skill-gets-its-command-name),因此您仍然輸入 `/deploy`。

18 21 

19Claude Code skills 遵循 [Agent Skills](https://agentskills.io) 開放標準,該標準適用於多個 AI 工具。Claude Code 使用額外功能擴展了該標準,例如[叫用控制](#control-who-invokes-a-skill)、[子代理執行](#run-skills-in-a-subagent)和[動態上下文注入](#inject-dynamic-context)。請參閱[在 Claude Code 外使用 skill frontmatter](#using-skill-frontmatter-outside-claude-code),了解哪些 frontmatter 欄位是標準的一部分,哪些是 Claude Code 擴展。22Claude Code skills 遵循 [Agent Skills](https://agentskills.io) 開放標準,該標準適用於多個 AI 工具。Claude Code 使用額外功能擴展了該標準,例如[叫用控制](#control-who-invokes-a-skill)、[子代理執行](#run-skills-in-a-subagent)和[動態上下文注入](#inject-dynamic-context)。請參閱[在 Claude Code 外使用 skill frontmatter](#using-skill-frontmatter-outside-claude-code),了解哪些 frontmatter 欄位是標準的一部分,哪些是 Claude Code 擴展。

20 23 


22 25 

23Claude Code 包含一組捆綁技能,例如 `/doctor`、`/code-review`、`/batch`、`/debug`、`/loop` 和 `/claude-api`。捆綁技能是基於提示的:它們為 Claude 提供詳細的指示,並讓它使用其工具來協調工作。大多數內建命令則直接執行固定邏輯。26Claude Code 包含一組捆綁技能,例如 `/doctor`、`/code-review`、`/batch`、`/debug`、`/loop` 和 `/claude-api`。捆綁技能是基於提示的:它們為 Claude 提供詳細的指示,並讓它使用其工具來協調工作。大多數內建命令則直接執行固定邏輯。

24 27 

25您可以透過輸入 `/` 後跟 skill 名稱的方式來調用隨附 skill。Claude 會在相關時自動調用某些隨附 skill;其他 skill(包括 [`/verify`](#run-and-verify-your-app))只有在您調用時才會執行。28您可以透過輸入 `/` 後跟 skill 名稱的方式來調用隨附 skill。Claude 會在相關時自動調用某些隨附 skill。

26 29 

27大多數捆綁技能在每個工作階段中都可用。少數技能取決於特定功能:例如 `/workflow-authoring` 只有在[動態工作流程](https://code.claude.com/docs/zh-TW/workflows.md)啟用時才可用。30大多數捆綁技能在每個工作階段中都可用。少數技能取決於特定功能:例如 `/workflow-authoring` 只有在[動態工作流程](https://code.claude.com/docs/zh-TW/workflows.md)啟用時才可用。

28 31 


312 315 

313* 在雲端工作階段中,主體保持本地技能具有的行為,因為工作階段在隔離容器中執行。316* 在雲端工作階段中,主體保持本地技能具有的行為,因為工作階段在隔離容器中執行。

314* 在您桌面上的 Cowork 工作階段中,主體保持本地技能具有的行為,除了 Claude Code 將每個 `!` 命令列替換為 [`disableSkillShellExecution` 預留位置](#inject-dynamic-context),就像它對您在那裡提供的每個技能所做的一樣。317* 在您桌面上的 Cowork 工作階段中,主體保持本地技能具有的行為,除了 Claude Code 將每個 `!` 命令列替換為 [`disableSkillShellExecution` 預留位置](#inject-dynamic-context),就像它對您在那裡提供的每個技能所做的一樣。

315* 在您機器上的任何其他工作階段中,Claude Code 不執行 [`!` 命令](#inject-dynamic-context),不附加 `@` 參考命名的檔案,方式與本地技能不同,不替換 `${CLAUDE_PROJECT_DIR}` 和 `${CLAUDE_SESSION_ID}` 預留位置,因此 `@` 參考和兩個預留位置都作為字面文字到達 Claude。`!` 命令列也作為字面文字到達 Claude,或當 `disableSkillShellExecution` 開啟時作為該預留位置。此處理需要 Claude Code v2.1.228 或更新版本。318* 在終端機或 VS Code 工作階段中,Claude Code 不會執行 [`!` 命令](#inject-dynamic-context)、不會附加 `@` 參考所指定的檔案,也不會替換 `${CLAUDE_PROJECT_DIR}` 和 `${CLAUDE_SESSION_ID}` 預留位置。`@` 參考和這兩個預留位置都會以字面文字傳送給 Claude。`!` 命令列也會以字面文字傳送給 Claude,或在該設定開啟時以 `disableSkillShellExecution` 預留位置傳送。此處理需要 Claude Code v2.1.228 或更新版本。

316 319 

317### 在工作階段期間編輯技能320### 在工作階段期間編輯技能

318 321 


320 323 

321如果您建立在工作階段啟動時不存在的頂層技能目錄,請執行 [`/reload-skills`](https://code.claude.com/docs/zh-TW/commands#all-commands) 以拾取您放在那裡的技能。Claude Code 還沒有監視該目錄,因此在稍後每次變更後再次執行 `/reload-skills`。324如果您建立在工作階段啟動時不存在的頂層技能目錄,請執行 [`/reload-skills`](https://code.claude.com/docs/zh-TW/commands#all-commands) 以拾取您放在那裡的技能。Claude Code 還沒有監視該目錄,因此在稍後每次變更後再次執行 `/reload-skills`。

322 325 

323即時變更偵測僅涵蓋 `SKILL.md` 文字。對於也是[外掛程式](https://code.claude.com/docs/zh-TW/plugins/loading.md#plugins-shared-through-a-repository)的技能資料夾,`hooks/`、`.mcp.json`、`agents/` 和 `output-styles/` 的變更需要 `/reload-plugins` 才能生效。326> [!NOTE]

327>

328> 即時變更偵測涵蓋 `SKILL.md` 文字。對於同時也是[外掛](https://code.claude.com/docs/zh-TW/plugins/loading.md#plugins-shared-through-a-repository)的 skill 資料夾,`.mcp.json`、`agents/` 和 `output-styles/` 的變更需要 `/reload-plugins` 才能生效。`hooks/` 的變更也需要,但 [mod](https://code.claude.com/docs/zh-TW/plugins/mods/overview.md) 的模組檔案在[自行重新載入](https://code.claude.com/docs/zh-TW/env-vars.md)時除外。

324 329 

325### 移除技能330### 移除技能

326 331 


5784. Verify the deployment succeeded5834. Verify the deployment succeeded

579```584```

580 585 

581如果 Claude 仍然嘗試,Claude Code 會阻止呼叫並指示它不要以另一種方式重現部署步驟,因此期望 Claude 建議您自己運行 `/deploy`。586如果您的訊息未以[獨立單詞且未附加標點符號](#where-you-write-the-skills-name)的形式包含 `/deploy`,而 Claude 仍嘗試調用,Claude Code 會阻止該呼叫。預期 Claude 會建議您自己運行 `/deploy`。

582 587 

583以下是兩個欄位如何影響調用和上下文加載:588以下是兩個欄位如何影響調用和上下文加載:

584 589 

585| Frontmatter | 您可以調用 | Claude 可以調用 | 何時加載到上下文中 |590| Frontmatter | 您可以調用 | Claude 可以調用 | 何時加載到上下文中 |

586| :- | :- | :- | :- |591| :- | :- | :- | :- |

587| (預設) | 是 | 是 | 描述始終在上下文中,調用時加載完整 skill |592| (預設) | 是 | 是 | 描述在上下文中,調用時加載完整 skill |

588| `disable-model-invocation: true` | 是 | 無法自行調用 | 描述不在上下文中,調用時加載完整 skill |593| `disable-model-invocation: true` | 是 | 無法自行調用 | 描述不在上下文中,調用時加載完整 skill |

589| `user-invocable: false` | 否 | 是 | 描述始終在上下文中,調用時加載完整 skill |594| `user-invocable: false` | 否 | 是 | 描述在上下文中,調用時加載完整 skill |

590 595 

591> [!NOTE]596> [!NOTE]

592>597>


617 622 

618`allowed-tools` 欄位在調用 skill 的回合中授予列出的工具的許可,因此 Claude 可以使用它們而無需提示您批准。當您發送下一條訊息時,授予清除,即使 skill 內容[保持在上下文中](#skill-content-lifecycle);再次調用 skill 為該回合重新應用它。它不限制哪些工具可用:每個工具保持可呼叫,您的[許可設定](https://code.claude.com/docs/zh-TW/permissions.md)仍然管理未列出的工具。要為整個工作階段而不是單個回合預先批准工具,請改為向這些許可設定添加允許規則。623`allowed-tools` 欄位在調用 skill 的回合中授予列出的工具的許可,因此 Claude 可以使用它們而無需提示您批准。當您發送下一條訊息時,授予清除,即使 skill 內容[保持在上下文中](#skill-content-lifecycle);再次調用 skill 為該回合重新應用它。它不限制哪些工具可用:每個工具保持可呼叫,您的[許可設定](https://code.claude.com/docs/zh-TW/permissions.md)仍然管理未列出的工具。要為整個工作階段而不是單個回合預先批准工具,請改為向這些許可設定添加允許規則。

619 624 

620工作區信任不限制此欄位。即使在您從未信任的資料夾中的 `-p` 運行中,Claude Code 也會應用專案 skill 的 `allowed-tools`。Skill 可以授予自己廣泛的工具存取權,因此在您在那裡運行 Claude Code 之前,請檢查簽入到儲存庫的 skills 的 `allowed-tools`。若要在整個組織中對儲存庫 skills 停用此欄位,請參閱[僅套用受管權限規則時](#when-only-managed-permission-rules-apply)。625即使在您從未信任的資料夾中的 `-p` 運行中,Claude Code 也會應用專案 skill 的 `allowed-tools`。Skill 可以授予自己廣泛的工具存取權,因此在您在那裡運行 Claude Code 之前,請檢查簽入到儲存庫的 skills 的 `allowed-tools`。若要在整個組織中對儲存庫 skills 停用此欄位,請參閱[僅套用受管權限規則時](#when-only-managed-permission-rules-apply)。

621 626 

622此 skill 讓 Claude 在您調用它時運行 git 命令而無需每次使用批准:627此 skill 讓 Claude 在您調用它時運行 git 命令而無需每次使用批准:

623 628 


705 710 

706### 注入動態內容711### 注入動態內容

707 712 

708`` !`<command>` `` 語法在技能內容傳送給 Claude 之前執行 shell 命令。命令輸出會取代佔位符,所以 Claude 會收到實際資料,而不是命令本身。當技能從您的 claude.ai 帳戶[同步](#how-claude-code-handles-the-body-of-a-synced-skill)時,Claude Code 不會在您的機器上執行這些命令。此限制需要 Claude Code v2.1.228 或更新版本。713`` !`<command>` `` 語法在 skill 內容傳送給 Claude 之前執行 shell 命令。命令輸出會取代佔位符,所以 Claude 會收到實際資料,而不是命令本身。關於從您的 claude.ai 帳戶同步的 skill,請參閱 [Claude Code 如何處理同步 skill 的主體](#how-claude-code-handles-the-body-of-a-synced-skill)。

709 714 

710此技能透過使用 GitHub CLI 擷取即時 PR 資料來總結拉取請求。`` !`gh pr diff` `` 和其他命令會先執行,其輸出會插入到提示中:715此技能透過使用 GitHub CLI 擷取即時 PR 資料來總結拉取請求。`` !`gh pr diff` `` 和其他命令會先執行,其輸出會插入到提示中:

711 716 


743 748 

744若要為來自使用者、專案、外掛程式或[其他目錄](#skills-from-additional-directories)來源的技能和自訂命令停用此行為,請在[設定](https://code.claude.com/docs/zh-TW/settings.md)中設定 `"disableSkillShellExecution": true`。每個命令都會被替換為 `[shell command execution disabled by policy]` 而不是被執行。捆綁和受管理的技能不受影響。此設定在[受管理設定](https://code.claude.com/docs/zh-TW/managed-settings.md)中最有用,使用者無法覆寫它。749若要為來自使用者、專案、外掛程式或[其他目錄](#skills-from-additional-directories)來源的技能和自訂命令停用此行為,請在[設定](https://code.claude.com/docs/zh-TW/settings.md)中設定 `"disableSkillShellExecution": true`。每個命令都會被替換為 `[shell command execution disabled by policy]` 而不是被執行。捆綁和受管理的技能不受影響。此設定在[受管理設定](https://code.claude.com/docs/zh-TW/managed-settings.md)中最有用,使用者無法覆寫它。

745 750 

746當命令出現在從您的 claude.ai 帳戶[同步的技能](#how-synced-skills-behave)中時,Claude Code 永遠不會在您的機器上執行這些命令,無論此設定如何。此限制需要 Claude Code v2.1.228 或更新版本。[Claude Code 如何處理同步技能的主體](#how-claude-code-handles-the-body-of-a-synced-skill)說明了在每種工作階段中 Claude 會收到什麼來取代命令。751在終端機或 VS Code 工作階段中,無論此設定如何,Claude Code 都不會執行[從您的 claude.ai 帳戶同步的 skill](#how-synced-skills-behave) 中的這些命令。此限制需要 Claude Code v2.1.228 或更新版本。

747 752 

748> [!TIP]753> [!TIP]

749>754>


791 796 

792* **拒絕和詢問規則**:其中任一規則匹配的命令仍會中止。若要找出該規則,請參閱[管理權限](https://code.claude.com/docs/zh-TW/permissions.md#manage-permissions)。797* **拒絕和詢問規則**:其中任一規則匹配的命令仍會中止。若要找出該規則,請參閱[管理權限](https://code.claude.com/docs/zh-TW/permissions.md#manage-permissions)。

793* **僅限受管的規則**:如果工作階段中的 `/status` 將該 skill 列在 `allowed-tools ignored this session` 之下,請參閱[僅套用受管權限規則時](#when-only-managed-permission-rules-apply)。798* **僅限受管的規則**:如果工作階段中的 `/status` 將該 skill 列在 `allowed-tools ignored this session` 之下,請參閱[僅套用受管權限規則時](#when-only-managed-permission-rules-apply)。

794* **未經驗證的 Git 資料夾**:在 `HEAD` 或 `.git` 檔案可能不屬於您的位置,對於包含 `git` 或 Claude Code 無法解析的 Bash 命令,Claude Code 會忽略 `allowed-tools`。如果您信任該資料夾,例如您自己的 bare 儲存庫的 worktree,請在工作階段中使用 [`/permissions`](https://code.claude.com/docs/zh-TW/permissions#manage-permissions) 允許該命令。799* **Bare 儲存庫資料夾**:當資料夾直接在 `refs` 或 `commondir` 旁邊包含 `HEAD` 檔案時,該資料夾看起來就是 bare 儲存庫。當位於工作目錄或其上層最接近的儲存庫看起來是 bare 時,對於包含 `git` 或 Claude Code 無法解析的 Bash 命令,Claude Code 會忽略 `allowed-tools`。如果您信任該資料夾,請在工作階段中使用 [`/permissions`](https://code.claude.com/docs/zh-TW/permissions#manage-permissions) 允許該命令。

795 800 

796在自動模式中,原本需要您批准的命令不會中止呼叫。技能會載入一個指示,告訴 Claude 先執行命令,然後 Claude 自己的呼叫會通過[自動模式的常規檢查](https://code.claude.com/docs/zh-TW/permission-modes.md#how-the-classifier-evaluates-actions)。在設定 `agent` 的[分叉技能](#run-skills-in-a-subagent)中,以及在 Claude 沒有[執行注入命令的 shell 工具](#how-injected-commands-run)的工作階段中,呼叫仍會中止。801在自動模式中,原本需要您批准的命令不會中止呼叫。技能會載入一個指示,告訴 Claude 先執行命令,然後 Claude 自己的呼叫會通過[自動模式的常規檢查](https://code.claude.com/docs/zh-TW/permission-modes.md#how-the-classifier-evaluates-actions)。在設定 `agent` 的[分叉技能](#run-skills-in-a-subagent)中,以及在 Claude 沒有[執行注入命令的 shell 工具](#how-injected-commands-run)的工作階段中,呼叫仍會中止。

797 802 


874Skill879Skill

875```880```

876 881 

877**使用[權限規則](https://code.claude.com/docs/zh-TW/permissions.md)允許或拒絕特定技能**:882**使用[權限規則](https://code.claude.com/docs/zh-TW/permissions.md)允許或拒絕特定 skill**。新增允許規則時,Claude 並不會被限制只能使用規則中指名的 skill。

878 883 

879```text theme={null}884```text theme={null}

880# Allow only specific skills885# Allow rules: skip the prompt

881Skill(commit)886Skill(commit)

882Skill(review-pr *)887Skill(review-pr *)

883 888 

statusline.md +1 −1

Details

182| `cost.total_api_duration_ms` | 等待 API 回應所花費的總時間,以毫秒為單位 |182| `cost.total_api_duration_ms` | 等待 API 回應所花費的總時間,以毫秒為單位 |

183| `cost.total_lines_added`, `cost.total_lines_removed` | 變更的程式碼行數 |183| `cost.total_lines_added`, `cost.total_lines_removed` | 變更的程式碼行數 |

184| `context_window.total_input_tokens`, `context_window.total_output_tokens` | 目前位於上下文視窗中的 token 數量,來自最近一次的 API 回應。輸入包含快取讀取與寫入 |184| `context_window.total_input_tokens`, `context_window.total_output_tokens` | 目前位於上下文視窗中的 token 數量,來自最近一次的 API 回應。輸入包含快取讀取與寫入 |

185| `context_window.context_window_size` | 以 token 計的最大上下文視窗大小。預設為 200000,具有延伸上下文的模型則為 1000000。 |185| `context_window.context_window_size` | 以 token 計的最大上下文視窗大小 |

186| `context_window.used_percentage` | 預先計算的上下文視窗已使用百分比 |186| `context_window.used_percentage` | 預先計算的上下文視窗已使用百分比 |

187| `context_window.remaining_percentage` | 預先計算的上下文視窗剩餘百分比 |187| `context_window.remaining_percentage` | 預先計算的上下文視窗剩餘百分比 |

188| `context_window.current_usage` | 上一次 API 呼叫的 token 數量,說明請見 [上下文視窗欄位](#context-window-fields) |188| `context_window.current_usage` | 上一次 API 呼叫的 token 數量,說明請見 [上下文視窗欄位](#context-window-fields) |

sub-agents.md +59 −42

Details

36>36>

37> 一個快速、唯讀的代理,針對搜尋和分析程式碼庫進行最佳化。37> 一個快速、唯讀的代理,針對搜尋和分析程式碼庫進行最佳化。

38>38>

39> * **Model**:主要對話的模型。當主要對話在 Fable 上執行時,Explore 的模型取決於您的連線方式:39> * **Model**:[主要對話](#which-model-a-nested-subagent-runs-on)的模型。當主要對話在 Fable 上執行時,Explore 會在 Opus 上執行或維持使用 Fable,取決於您的連線方式。

40> * 使用 Claude 訂閱、Anthropic Console 帳戶,或透過 `ANTHROPIC_BASE_URL` 連線的 [LLM 閘道](https://code.claude.com/docs/zh-TW/llm-gateway)時,Explore 會在 [`opus` 別名](https://code.claude.com/docs/zh-TW/model-config#model-aliases)所解析的 Opus 模型上執行。40> * 使用 Claude 訂閱、Anthropic Console 帳戶,或透過 `ANTHROPIC_BASE_URL` 連線的 [LLM 閘道](https://code.claude.com/docs/zh-TW/llm-gateway)時,Explore 會在 [`opus` 別名](https://code.claude.com/docs/zh-TW/model-config#model-aliases)所解析的 Opus 模型上執行。

41> * 在 Amazon Bedrock、Google Cloud 的 Agent Platform、Microsoft Foundry、[AWS 上的 Claude Platform](https://code.claude.com/docs/zh-TW/claude-platform-on-aws.md) 或 [Claude apps 閘道](https://code.claude.com/docs/zh-TW/claude-apps-gateway)上,Explore 會維持使用主要對話的模型。41> * 在 Amazon Bedrock、Google Cloud 的 Agent Platform、Microsoft Foundry、[AWS 上的 Claude Platform](https://code.claude.com/docs/zh-TW/claude-platform-on-aws.md) 或 [Claude apps 閘道](https://code.claude.com/docs/zh-TW/claude-apps-gateway)上,Explore 會維持使用 Fable。

42> * **Tools**:唯讀工具;Write 和 Edit 被拒絕42> * **Tools**:唯讀工具;Write 和 Edit 被拒絕

43> * **Purpose**:檔案發現、程式碼搜尋、程式碼庫探索43> * **Purpose**:檔案發現、程式碼搜尋、程式碼庫探索

44>44>


52>52>

53> 一個研究代理,在 [plan mode](https://code.claude.com/docs/zh-TW/permission-modes.md#analyze-before-you-edit-with-plan-mode) 期間使用,以在呈現計畫之前收集上下文。53> 一個研究代理,在 [plan mode](https://code.claude.com/docs/zh-TW/permission-modes.md#analyze-before-you-edit-with-plan-mode) 期間使用,以在呈現計畫之前收集上下文。

54>54>

55> * **Model**:繼承自主要對話,除非您設定 `CLAUDE_CODE_SUBAGENT_MODEL` 並[強制將其套用至每個 subagent](#run-every-subagent-on-one-model)55> * **Model**:繼承自[主要對話](#which-model-a-nested-subagent-runs-on),除非您設定 `CLAUDE_CODE_SUBAGENT_MODEL` 並[強制將其套用至每個 subagent](#run-every-subagent-on-one-model)

56> * **Tools**:唯讀工具;Write 和 Edit 被拒絕56> * **Tools**:唯讀工具;Write 和 Edit 被拒絕

57> * **Purpose**:用於規劃的程式碼庫研究57> * **Purpose**:用於規劃的程式碼庫研究

58>58>


62>62>

63> 一個能力強大的代理,用於需要探索和行動的複雜多步驟任務。63> 一個能力強大的代理,用於需要探索和行動的複雜多步驟任務。

64>64>

65> * **Model**:如果您設定了 [`CLAUDE_CODE_SUBAGENT_MODEL`](#choose-a-model) 模型且沒有其他方式指派模型,則為該模型,否則為主要對話的模型;[選擇模型](#choose-a-model)說明完整順序,[在一個模型上執行每個 subagent](#run-every-subagent-on-one-model) 展示如何讓變數覆蓋這些來源65> * **Model**:預設為主要對話的模型,遵循[模型順序](#choose-a-model)

66> * **Tools**:[可供 subagents 使用](#available-tools)的每個工具66> * **Tools**:[可供 subagents 使用](#available-tools)的每個工具

67> * **Purpose**:複雜研究、多步驟操作、程式碼修改67> * **Purpose**:複雜研究、多步驟操作、程式碼修改

68>68>


346 346 

347### 選擇模型347### 選擇模型

348 348 

349`model` 欄位控制子代理使用的模型:349預設情況下,您定義的 subagent 會在與啟動它的對話相同的模型上執行。若要自行選擇其模型,請在其定義中將 [`model`](#supported-frontmatter-fields) 欄位設定為下列其中一個值:

350 350 

351* **模型別名**:使用可用別名之一:`sonnet`、`opus`、`haiku` 或 `fable`351* **模型別名**:`sonnet`、`opus`、`haiku` 或 `fable`

352* **完整模型 ID**:使用完整模型 ID,例如 `claude-opus-5-5` 或 `claude-sonnet-5`。接受與 `--model` 旗標相同的值352* **完整模型 ID**:[`--model`](https://code.claude.com/docs/zh-TW/cli-reference#cli-flags) 旗標接受的值,例如 `claude-opus-5-5` 或 `claude-sonnet-5`

353* **inherit**:使用與主對話相同的模型353* **`inherit`**:主對話的模型,或對[巢狀 subagent](#which-model-a-nested-subagent-runs-on) 而言,為產生它的 subagent 的模型

354 354 

355當 Claude 叫用 subagent 時,它也可以為該次叫用傳遞 `model` 參數。在 Agent 工具呼叫中,該參數接受模型別名:`sonnet`、`opus`、`haiku` 或 `fable`。Claude 無法在該呼叫中傳遞完整模型 ID 或 `inherit`。Claude Code 會依此順序解析 subagent 的模型:355當有多個來源設定模型時,Claude Code 會依此順序使用第一個:

356 356 

3571. 每次叫用 `model` 參數3571. 每次叫用的 `model` 參數,Claude 可在啟動 subagent 時傳遞它。在 Agent 工具呼叫中,該參數接受模型別名,而不接受完整模型 ID 或 `inherit`。

3582. 子代理定義的 `model` frontmatter,其中 `inherit` 選擇主對話的模型3582. subagent 定義中的 `model` 欄位,包括 `inherit`

3593. [`CLAUDE_CODE_SUBAGENT_MODEL`](https://code.claude.com/docs/zh-TW/model-config#environment-variables) 環境變數,當您將其設定為模型別名或模型 ID 時3593. [`CLAUDE_CODE_SUBAGENT_MODEL`](https://code.claude.com/docs/zh-TW/model-config#environment-variables) 環境變數

3604. 主對話的模型3604. 主對話的模型,或對巢狀 subagent 而言,為產生它的 subagent 的模型

361 361 

362如果已安裝的 [mod](https://code.claude.com/docs/zh-TW/plugins/mods/overview.md) 在其 [`agent.spawn`](https://code.claude.com/docs/zh-TW/plugins/mods/reference#subagents) hook 中設定了模型,Claude Code 會以該模型取代每次叫用的參數。362如果 Claude 傳遞了別名,subagent 在[被繼續或收到後續訊息](#resume-subagents)時會保留該別名。如果已安裝的 [mod](https://code.claude.com/docs/zh-TW/plugins/mods/overview.md) 在其 [`agent.spawn`](https://code.claude.com/docs/zh-TW/plugins/mods/reference#subagents) hook 中設定了模型,Claude Code 會以該模型取代每次叫用的參數。

363 

364在兩種情況下,每次叫用參數或 frontmatter 中的家族別名(例如 `opus`)解析為主對話的模型,而不是[別名指向的版本](https://code.claude.com/docs/zh-TW/model-config.md#model-aliases):

365 

366* **主對話的模型屬於該家族**:子代理在主對話的確切模型上執行,包括任何 `[1m]` 尾碼,因此它獲得與主對話相同的[擴展上下文](https://code.claude.com/docs/zh-TW/model-config.md#extended-context)視窗。

367* **Claude Code 無法判斷主對話的模型家族,在[Anthropic API 以外的提供者](https://code.claude.com/docs/zh-TW/third-party-integrations.md)上**:這可能發生在 Amazon Bedrock 上的[應用程式推論設定檔 ARN](https://code.claude.com/docs/zh-TW/amazon-bedrock.md#iam-configuration),Claude Code 尚未解析為支援模型。此情況僅涵蓋 `opus` 別名,當您設定 [`ANTHROPIC_DEFAULT_OPUS_MODEL`](https://code.claude.com/docs/zh-TW/model-config#environment-variables) 時不適用,因為 `opus` 然後解析為您設定的模型。

368 

369`CLAUDE_CODE_SUBAGENT_MODEL` 中的別名一律解析為別名指向的版本,即使它指定的是主對話的家族。將此變數設定為 `inherit` 等同於不設定它。

370 363 

371單獨設定 `CLAUDE_CODE_SUBAGENT_MODEL` 不會改變內建 Explore 和 Plan 子代理執行的模型。若要改變它,請參閱[在一個模型上執行每個子代理](#run-every-subagent-on-one-model)。364單獨設定 `CLAUDE_CODE_SUBAGENT_MODEL` 不會改變內建 Explore 和 Plan 子代理執行的模型。若要改變它,請參閱[在一個模型上執行每個子代理](#run-every-subagent-on-one-model)。

372 365 

373在 v2.1.251 之前,`CLAUDE_CODE_SUBAGENT_MODEL` 在此順序中排在第一位,並覆蓋每次叫用參數和 frontmatter,包括 `model: inherit`。366#### 巢狀 subagent 在哪個模型上執行

374 367 

375Claude Code 根據您組織的 [`availableModels`](https://code.claude.com/docs/zh-TW/model-config#restrict-model-selection) 允許清單檢查每次叫用參數、frontmatter 和環境變數值。對於被阻止的值,它替換另一個模型:368預設情況下,您定義的[巢狀 subagent](#let-subagents-spawn-their-own-subagents) 會在其父項(即產生它的 subagent)的模型上執行。若要讓巢狀 subagent 在其他模型上執行,請將其 `model` 欄位設定為該模型。

376 369 

377* 當被阻止的值是家族別名(例如 `opus`)時,Claude Code 在允許清單允許的該家族的最新版本上執行子代理,遵循與 `/model` 相同的[替換規則和提供者範圍](https://code.claude.com/docs/zh-TW/model-config.md#restrict-model-selection)。在 v2.1.222 之前,Claude Code 也在被阻止的家族別名的繼承模型上執行子代理。370例如,假設您的主對話在 Opus 上執行,並在 Haiku 上啟動一個 reviewer subagent。預設情況下,當 reviewer 產生下列 subagent 時,它們會在 Haiku 而非 Opus 上執行:

378* 對於任何其他被阻止的值,在該替換不操作的提供者上,或當允許清單允許該家族的沒有版本時,Claude Code 改為在繼承模型上執行子代理。如果您設定 `CLAUDE_CODE_SUBAGENT_MODEL`,Claude Code 首先嘗試該模型,在這些相同的規則下。

379 371 

380在互動工作階段中,Claude Code 顯示警告,命名請求的模型和子代理執行的模型,用於任一替換。372* 具有 `model: inherit` 或沒有 `model` 欄位的 subagent

373* 內建的 Explore、Plan 和 general-purpose subagent

374* [分叉](#fork-the-current-conversation)

381 375 

382若要檢查 subagent 正在執行的模型,請執行 [`/tasks`](https://code.claude.com/docs/zh-TW/commands)。Claude Code 會在 subagent 的列上列出模型,並在有為該 subagent 設定 [effort 等級](https://code.claude.com/docs/zh-TW/model-config.md#adjust-effort-level)時一併顯示。需要 Claude Code v2.1.242 或更新版本。376在 plan mode 中,如果您將工作階段的模型設定為 [`opusplan`](https://code.claude.com/docs/zh-TW/model-config#opusplan-model-setting),這些 subagent 會在 Opus 上執行;如果您將其設定為 `haiku`,則會在 Sonnet 上執行。

383 377 

384每次叫用的 `model` 參數也適用於 subagent [被繼續或收到後續訊息](#resume-subagents)時,因此 subagent 會保持在該模型上。378#### 檢查 subagent 的模型

385 379 

386從 v2.1.198 開始,子代理也繼承主對話的[擴展思考](https://code.claude.com/docs/zh-TW/model-config.md#extended-thinking)設定:如果思考在您的工作階段中開啟,它對子代理開啟,如果關閉,它保持關閉。沒有每個子代理思考設定。在 v2.1.198 之前,子代理執行時禁用擴展思考,無論主對話的設定如何。380若要檢查 subagent 正在執行的模型,請執行 [`/tasks`](https://code.claude.com/docs/zh-TW/commands)。Claude Code 會在 subagent 的列上列出模型,並在有為該 subagent 設定 [effort 等級](https://code.claude.com/docs/zh-TW/model-config.md#adjust-effort-level)時一併顯示。需要 Claude Code v2.1.242 或更新版本。

387 381 

388#### 在一個模型上執行每個子代理382#### 在一個模型上執行每個子代理

389 383 

390`CLAUDE_CODE_SUBAGENT_MODEL` 是預設值,因此子代理的定義或 Claude 傳遞的模型仍然優先於它。若要將一個模型應用於每個子代理、[隊友](https://code.claude.com/docs/zh-TW/agent-teams.md#specify-teammates-and-models) 和[工作流代理](https://code.claude.com/docs/zh-TW/workflows.md),也設定 `CLAUDE_CODE_SUBAGENT_MODEL_FORCE` 為 `1`。需要 Claude Code v2.1.257 或更新版本。384若要將同一個模型套用於每個 subagent、[隊員](https://code.claude.com/docs/zh-TW/agent-teams.md#specify-teammates-and-models)和[工作流程 agent](https://code.claude.com/docs/zh-TW/workflows.md),請將 `CLAUDE_CODE_SUBAGENT_MODEL` 設定為該模型,並將 `CLAUDE_CODE_SUBAGENT_MODEL_FORCE` 設定為 `1`。需要 Claude Code v2.1.257 或更新版本。

391 

392* 如果您設定兩個變數,子代理在 `CLAUDE_CODE_SUBAGENT_MODEL` 中的模型上執行。

393* 如果您只設定 `CLAUDE_CODE_SUBAGENT_MODEL_FORCE`,subagent 會在主對話的模型上執行,但內建的 Explore subagent 例外,它會在[內建 subagent 中為其列出的模型](#built-in-subagents)上執行。

394 385 

395例如,若要在 Haiku 上執行每個子代理,在[設定檔](https://code.claude.com/docs/zh-TW/settings.md)的 `env` 區塊中設定兩個變數:386例如,若要在 Haiku 上執行每個子代理,在[設定檔](https://code.claude.com/docs/zh-TW/settings.md)的 `env` 區塊中設定兩個變數:

396 387 


405 396 

406若要檢查設定是否生效,在子代理執行時執行 [`/tasks`](https://code.claude.com/docs/zh-TW/commands)。子代理的列顯示它執行的模型。397若要檢查設定是否生效,在子代理執行時執行 [`/tasks`](https://code.claude.com/docs/zh-TW/commands)。子代理的列顯示它執行的模型。

407 398 

408當 `CLAUDE_CODE_SUBAGENT_MODEL_FORCE` [開啟](https://code.claude.com/docs/zh-TW/env-vars.md)時,Claude Code 會忽略 subagent 定義中的 `model` 欄位,且 Claude 在啟動 subagent 時無法傳遞模型。以下 subagent 仍會在主對話的模型上執行:399當 `CLAUDE_CODE_SUBAGENT_MODEL_FORCE` [開啟](https://code.claude.com/docs/zh-TW/env-vars.md)時,Claude Code 會忽略 subagent 定義中的 `model` 欄位,且 Claude 在啟動 subagent 時無法傳遞模型。以下 subagent 仍會在其父對話的模型上執行:

409 400 

410* [分叉](#fork-the-current-conversation)401* [分叉](#fork-the-current-conversation)

411* [在子代理中執行的技能](https://code.claude.com/docs/zh-TW/skills.md#run-skills-in-a-subagent),具有 `model: inherit`402* [在子代理中執行的技能](https://code.claude.com/docs/zh-TW/skills.md#run-skills-in-a-subagent),具有 `model: inherit`

412 403 

404如果您只設定 `CLAUDE_CODE_SUBAGENT_MODEL_FORCE`,subagent 會在主對話的模型上執行,但內建的 Explore subagent 例外,它會在[內建 subagent 中為其列出的模型](#built-in-subagents)上執行。

405 

406#### 模型別名選擇哪個版本

407 

408預設情況下,具有模型別名的 subagent 會在[該別名指向的版本](https://code.claude.com/docs/zh-TW/model-config.md#model-aliases)上執行。當 `model` 欄位或每次叫用參數中使用家族別名(例如 `opus`)時,subagent 在兩種情況下會在其父對話的模型上執行:

409 

410* **相同家族**:例如,如果您的主對話在 `claude-opus-4-7` 上執行,具有 `model: opus` 的 subagent 也會在該版本上執行。若要執行其他版本,請在 `model` 欄位中設定完整模型 ID。

411* **未知家族**:Claude Code 無法判斷父模型的家族,例如使用它[無法查詢](https://code.claude.com/docs/zh-TW/amazon-bedrock.md#iam-configuration)的 Amazon Bedrock ARN 時。此情況僅適用於[Anthropic API 以外之提供者](https://code.claude.com/docs/zh-TW/third-party-integrations.md)上的 `opus` 別名。若要選擇 Opus 版本,請設定 [`ANTHROPIC_DEFAULT_OPUS_MODEL`](https://code.claude.com/docs/zh-TW/model-config#environment-variables)。

412 

413#### 當允許清單封鎖 subagent 模型時

414 

415如果您組織的 [`availableModels`](https://code.claude.com/docs/zh-TW/model-config#restrict-model-selection) 允許清單封鎖了為 subagent 設定的模型,subagent 會在下列第一個適用的模型上執行:

416 

4171. 對於被封鎖的家族別名,在[支援此替換的提供者](https://code.claude.com/docs/zh-TW/model-config.md#restrict-model-selection)上,該家族中允許的最新版本

4182. `CLAUDE_CODE_SUBAGENT_MODEL` 中的模型(如果您有設定),並適用相同的規則

4193. 主對話的模型,或對巢狀 subagent 而言,為產生它的 subagent 的模型

420 

421對於互動工作階段中的頂層 subagent,會有警告列出請求的模型及其替代模型。若要執行特定模型,請將被封鎖的值改為允許清單允許的值。

422 

423### subagent 中的延伸思考

424 

425subagent 會繼承主對話的[延伸思考](https://code.claude.com/docs/zh-TW/model-config.md#extended-thinking)設定。沒有每個 subagent 個別的思考設定。

426 

413### 選擇 effort 等級427### 選擇 effort 等級

414 428 

415若要讓 subagent 以其自己的 [effort 等級](https://code.claude.com/docs/zh-TW/model-config.md#adjust-effort-level)執行,請在其定義中設定 [`effort`](#supported-frontmatter-fields) 欄位。429若要讓 subagent 以其自己的 [effort 等級](https://code.claude.com/docs/zh-TW/model-config.md#adjust-effort-level)執行,請在其定義中設定 [`effort`](#supported-frontmatter-fields) 欄位。


426 440 

427#### 可用工具441#### 可用工具

428 442 

429子代理繼承[內建工具](https://code.claude.com/docs/zh-TW/tools-reference.md)和主對話中可用的 MCP 工具,由兩個篩選器縮小:第一個從每個子代理移除工具的簡短列表,第二個減少在[背景中](#run-subagents-in-foreground-or-background)執行的子代理的內建工具集,這是預設值。在 macOS、Linux 和 WSL 上,當主對話沒有時,子代理也可以接收 Glob 和 Grep 工具,如[Glob 工具行為](https://code.claude.com/docs/zh-TW/tools-reference.md#glob-tool-behavior)下所述。[分叉](#fork-the-current-conversation)跳過兩個篩選器並接收主對話的確切工具池。第一個篩選器移除這些工具,即使在 `tools` 欄位中列出:443subagent 會繼承主對話中可用的[內建工具](https://code.claude.com/docs/zh-TW/tools-reference.md)和 MCP 工具,並經過兩個篩選器縮小範圍。第一個篩選器會從每個 subagent 移除一小份工具清單。第二個篩選器會縮減在[背景中](#run-subagents-in-foreground-or-background)執行之 subagent 的內建工具集,這是預設情況。

444 

445在 macOS、Linux 和 WSL 上,當主對話沒有 Glob 和 Grep 工具時,subagent 也可以取得它們,如 [Glob 工具行為](https://code.claude.com/docs/zh-TW/tools-reference.md#glob-tool-behavior)中所述。[分叉](#fork-the-current-conversation)會跳過兩個篩選器,並取得其父對話完全相同的工具池。第一個篩選器會移除這些工具,即使它們列在 `tools` 欄位中:

430 446 

431* `Agent`,當子代理在[深度限制](#let-subagents-spawn-their-own-subagents)時;在[分叉](#fork-the-current-conversation)中工具保持列出但返回錯誤而不是生成447* `Agent`,當子代理在[深度限制](#let-subagents-spawn-their-own-subagents)時;在[分叉](#fork-the-current-conversation)中工具保持列出但返回錯誤而不是生成

432* `AskUserQuestion`448* `AskUserQuestion`


1077 1093 

1078使用此值,您的 subagents 可以委派給自己的第二層,該第二層無法進一步委派。設定 `1` 以關閉巢狀。1094使用此值,您的 subagents 可以委派給自己的第二層,該第二層無法進一步委派。設定 `1` 以關閉巢狀。

1079 1095 

1080巢狀 subagent 的設定方式與頂層 subagent 相同,並從相同的 [範圍](#choose-the-subagent-scope) 解析。若要在巢狀開啟時防止某個 subagent 產生 subagents,例如應保持唯讀的審查者,請從其 [`tools`](#available-tools) 列表中省略 `Agent` 或將其新增到 `disallowedTools`。1096在與頂層 subagent 相同的 [範圍](#choose-the-subagent-scope) 中定義巢狀 subagent。預設情況下,您定義的巢狀 subagent 會在 [進行產生的 subagent 的模型](#which-model-a-nested-subagent-runs-on) 上執行。若要在巢狀開啟時防止某個 subagent 產生 subagents,例如應保持唯讀的審查者,請從其 [`tools`](#available-tools) 列表中省略 `Agent` 或將其新增到 `disallowedTools`。

1081 1097 

1082在終端機中,Claude Code 會在提示輸入下方的 subagent 面板中將巢狀 subagents 顯示為樹狀結構,並用 `(+N)` 計數標記面板中仍有後代的每一列。開啟一列以查看該 subagent 的同級和直接子代,以及返回到 `main` 的路徑。1098在終端機中,Claude Code 會在提示輸入下方的 subagent 面板中將巢狀 subagents 顯示為樹狀結構,並用 `(+N)` 計數標記面板中仍有後代的每一列。開啟一列以查看該 subagent 的同級和直接子代,以及返回到 `main` 的路徑。

1083 1099 


1221>1237>

1222> 當[agent 檢視已關閉](https://code.claude.com/docs/zh-TW/agent-view.md#turn-off-agent-view)時,`/subtask` 無法使用,`/fork` 會改為啟動 forked subagent;否則 `/fork` 會將整個工作階段複製到新的[背景工作階段](https://code.claude.com/docs/zh-TW/agent-view.md#from-inside-a-session)。1238> 當[agent 檢視已關閉](https://code.claude.com/docs/zh-TW/agent-view.md#turn-off-agent-view)時,`/subtask` 無法使用,`/fork` 會改為啟動 forked subagent;否則 `/fork` 會將整個工作階段複製到新的[背景工作階段](https://code.claude.com/docs/zh-TW/agent-view.md#from-inside-a-session)。

1223 1239 

1224Fork 是一個 subagent,它繼承到目前為止的整個對話,而不是從頭開始。這會放棄 subagents 否則提供的輸入隔離:fork 看到與主工作階段相同的系統提示、工具、模型和訊息歷史記錄,因此您可以將側面任務交給它,而無需重新解釋情況。Fork 自己的工具呼叫仍然保持在您的對話之外,只有其最終結果返回,因此您的主要上下文視窗保持乾淨。當任何其他 subagent 需要太多背景才能有用時,或當您想從相同的起點並行嘗試多種方法時,使用 fork。1240Fork 是一個 subagent,它繼承到目前為止的整個對話,而不是從頭開始。當任何其他 subagent 需要太多背景資訊才能發揮作用時,或當您想從相同的起點並行嘗試多種方法時,請使用 fork。

1241 

1242* **輸入**:fork 看到的系統提示詞、工具、[模型](#which-model-a-nested-subagent-runs-on)和訊息歷史記錄與其父對話相同

1243* **輸出**:fork 自己的工具呼叫會保持在其父對話之外,只有其最終結果會傳回

1225 1244 

1226在 fork 模式開啟期間(預設即為開啟),Claude 可以自行啟動 fork。若要停止 fork,請參閱[關閉 fork 模式](#turn-fork-mode-on-or-off)。1245在 fork 模式開啟期間(預設即為開啟),Claude 可以自行啟動 fork。若要停止 fork,請參閱[關閉 fork 模式](#turn-fork-mode-on-or-off)。

1227 1246 


1257 1276 

1258### Forks 與其他 subagents 的區別1277### Forks 與其他 subagents 的區別

1259 1278 

1260Fork 繼承主工作階段在產生時擁有的所有內容。任何其他 subagent 從其定義開始新鮮。

1261 

1262| | Fork | 非 fork subagent |1279| | Fork | 非 fork subagent |

1263| :- | :- | :- |1280| :- | :- | :- |

1264| Context | 完整對話歷史記錄 | 新鮮上下文,帶有您傳遞的提示 |1281| Context | 完整對話歷史記錄 | 新鮮上下文,帶有您傳遞的提示 |

1265| 系統提示和工具 | 與主工作階段相同 | 來自 subagent 的[定義檔](#write-subagent-files),[針對背景執行進行篩選](#available-tools) |1282| 系統提示詞和工具 | 與父對話相同 | 來自 subagent 的[定義檔](#write-subagent-files),[針對背景執行進行篩選](#available-tools) |

1266| Model | 與主工作階段相同 | 來自 subagent 的 `model` 欄位 |1283| 模型 | 與[父對話](#which-model-a-nested-subagent-runs-on)相同 | 遵循 [subagent 模型順序](#choose-a-model) |

1267| Prompt cache | 與主工作階段共享 | 單獨的快取 |1284| 提示快取 | 與父對話共享 | 單獨的快取 |

1268 1285 

1269因為 fork 的系統提示詞和工具定義與父級相同,其第一個請求重複使用父級的[提示快取](https://code.claude.com/docs/zh-TW/prompt-caching.md#subagents-and-the-cache)。由於這種重複使用,對於需要相同上下文的任務,fork 的成本比新的 subagent 更低。1286因為 fork 的系統提示詞和工具定義與父級相同,其第一個請求重複使用父級的[提示快取](https://code.claude.com/docs/zh-TW/prompt-caching.md#subagents-and-the-cache)。由於這種重複使用,對於需要相同上下文的任務,fork 的成本比新的 subagent 更低。

1270 1287 

Details

332 332 

333當您貼上超過 800 個字元或超過三行的內容到提示時,Claude Code 會將輸入摺疊為預留位置,例如 `[Pasted text #1 +120 lines]`,以保持輸入框可用,並在您提交時仍會傳送完整內容。對於非常大的輸入(例如整個檔案或長日誌),請將內容寫入檔案並要求 Claude 讀取它,而不是貼上。對話記錄保持可讀,Claude 可以在稍後的回合中按路徑參考該檔案。VS Code 整合終端也可能在非常大的貼上到達 Claude Code 之前從中丟棄字元,因此在那裡使用檔案。333當您貼上超過 800 個字元或超過三行的內容到提示時,Claude Code 會將輸入摺疊為預留位置,例如 `[Pasted text #1 +120 lines]`,以保持輸入框可用,並在您提交時仍會傳送完整內容。對於非常大的輸入(例如整個檔案或長日誌),請將內容寫入檔案並要求 Claude 讀取它,而不是貼上。對話記錄保持可讀,Claude 可以在稍後的回合中按路徑參考該檔案。VS Code 整合終端也可能在非常大的貼上到達 Claude Code 之前從中丟棄字元,因此在那裡使用檔案。

334 334 

335如果貼上的內容包含[隱形 Unicode 字元](https://code.claude.com/docs/zh-TW/interactive-mode.md#invisible-characters-in-prompts),Claude Code 會在您按下 Enter 時移除它們,並將清理後的提示放回輸入框供您以另一個 Enter 傳送。335如果貼上的內容包含[隱形 Unicode 字元](https://code.claude.com/docs/zh-TW/interactive-mode.md#invisible-characters-in-prompts),Claude Code 會在您按下 Enter 時移除它們。

336 336 

337### Claude 如何處理貼上的文字337### Claude 如何處理貼上的文字

338 338 

Details

133* [Claude 應用程式閘道](https://code.claude.com/docs/zh-TW/claude-apps-gateway),一個自託管閘道,在 Amazon Bedrock、Claude Platform on AWS、Google Cloud's Agent Platform、Microsoft Foundry 或 Anthropic API 前面添加 IdP 登入133* [Claude 應用程式閘道](https://code.claude.com/docs/zh-TW/claude-apps-gateway),一個自託管閘道,在 Amazon Bedrock、Claude Platform on AWS、Google Cloud's Agent Platform、Microsoft Foundry 或 Anthropic API 前面添加 IdP 登入

134* [Amazon Bedrock](https://code.claude.com/docs/zh-TW/amazon-bedrock.md)134* [Amazon Bedrock](https://code.claude.com/docs/zh-TW/amazon-bedrock.md)

135* [Claude Platform on AWS](https://code.claude.com/docs/zh-TW/claude-platform-on-aws.md)135* [Claude Platform on AWS](https://code.claude.com/docs/zh-TW/claude-platform-on-aws.md)

136* [Google Cloud 上的 Claude 模型(由 Anthropic 管理)](https://code.claude.com/docs/zh-TW/claude-models-on-google-cloud-anthropic-managed.md)

136* [Google Cloud's Agent Platform](https://code.claude.com/docs/zh-TW/google-vertex-ai.md)137* [Google Cloud's Agent Platform](https://code.claude.com/docs/zh-TW/google-vertex-ai.md)

137* [Microsoft Foundry](https://code.claude.com/docs/zh-TW/microsoft-foundry.md)138* [Microsoft Foundry](https://code.claude.com/docs/zh-TW/microsoft-foundry.md)

138 139 

Details

49| `SendMessage` | 傳送訊息給另一個 agent:[agent team](https://code.claude.com/docs/zh-TW/agent-teams.md) 隊友、[它按 agent ID 或名稱恢復的 subagent](https://code.claude.com/docs/zh-TW/sub-agents.md#resume-subagents),或 您的其他 Claude Code 工作階段之一,在此機器上或超越它。傳訊其他工作階段需要 Claude Code v2.1.224 或更新版本。[跨工作階段傳訊](https://code.claude.com/docs/zh-TW/cross-session-messaging.md)涵蓋 Claude 可以到達的工作階段、[訊息到達時的樣子](https://code.claude.com/docs/zh-TW/cross-session-messaging.md#what-a-message-looks-like)以及 [Claude 如何在另一個工作階段閒置時收到通知](https://code.claude.com/docs/zh-TW/cross-session-messaging.md#get-a-notice-when-another-session-goes-idle)。Claude 可以包含可選的 `summary` 輸入,通常 5-10 個字,Claude Code 顯示為單行預覽。當 Claude 在[純文字訊息](https://code.claude.com/docs/zh-TW/cross-session-messaging.md#limitations)上省略它時,Claude Code 使用訊息的第一行作為摘要。Claude Code 使用省略號截斷超過 200 個字元的摘要 | 否 |49| `SendMessage` | 傳送訊息給另一個 agent:[agent team](https://code.claude.com/docs/zh-TW/agent-teams.md) 隊友、[它按 agent ID 或名稱恢復的 subagent](https://code.claude.com/docs/zh-TW/sub-agents.md#resume-subagents),或 您的其他 Claude Code 工作階段之一,在此機器上或超越它。傳訊其他工作階段需要 Claude Code v2.1.224 或更新版本。[跨工作階段傳訊](https://code.claude.com/docs/zh-TW/cross-session-messaging.md)涵蓋 Claude 可以到達的工作階段、[訊息到達時的樣子](https://code.claude.com/docs/zh-TW/cross-session-messaging.md#what-a-message-looks-like)以及 [Claude 如何在另一個工作階段閒置時收到通知](https://code.claude.com/docs/zh-TW/cross-session-messaging.md#get-a-notice-when-another-session-goes-idle)。Claude 可以包含可選的 `summary` 輸入,通常 5-10 個字,Claude Code 顯示為單行預覽。當 Claude 在[純文字訊息](https://code.claude.com/docs/zh-TW/cross-session-messaging.md#limitations)上省略它時,Claude Code 使用訊息的第一行作為摘要。Claude Code 使用省略號截斷超過 200 個字元的摘要 | 否 |

50| `SendUserFile` | 從工作階段傳送檔案給您,帶有選用的說明文字,以便生成的報告、圖表、螢幕擷取畫面或建置產物到達您的裝置,而不是僅在逐字稿中提及。選用的 `display` 輸入控制呈現方式:`render` 在用戶端中內嵌開啟檔案,`attach` 僅顯示下載卡,未設定時由用戶端根據檔案型別決定。當 [Remote Control](https://code.claude.com/docs/zh-TW/remote-control.md) 用戶端連接或在[雲端工作階段](https://code.claude.com/docs/zh-TW/claude-code-on-the-web.md)中時可用。傳遞透過 Anthropic 託管的基礎設施執行,因此該工具在 Amazon Bedrock、Google Cloud 的 Agent Platform 或 Microsoft Foundry 上不可用 | 否 |50| `SendUserFile` | 從工作階段傳送檔案給您,帶有選用的說明文字,以便生成的報告、圖表、螢幕擷取畫面或建置產物到達您的裝置,而不是僅在逐字稿中提及。選用的 `display` 輸入控制呈現方式:`render` 在用戶端中內嵌開啟檔案,`attach` 僅顯示下載卡,未設定時由用戶端根據檔案型別決定。當 [Remote Control](https://code.claude.com/docs/zh-TW/remote-control.md) 用戶端連接或在[雲端工作階段](https://code.claude.com/docs/zh-TW/claude-code-on-the-web.md)中時可用。傳遞透過 Anthropic 託管的基礎設施執行,因此該工具在 Amazon Bedrock、Google Cloud 的 Agent Platform 或 Microsoft Foundry 上不可用 | 否 |

51| `ShareOnboardingGuide` | 上傳 `ONBOARDING.md` 並返回隊友可以在 Claude Code 中開啟的分享連結。在指南寫入後從 `/team-onboarding` 呼叫。適用於 Team 和 Enterprise 方案上的 claude.ai 訂閱者 | 是 |51| `ShareOnboardingGuide` | 上傳 `ONBOARDING.md` 並返回隊友可以在 Claude Code 中開啟的分享連結。在指南寫入後從 `/team-onboarding` 呼叫。適用於 Team 和 Enterprise 方案上的 claude.ai 訂閱者 | 是 |

52| `Skill` | 在主對話中執行 [skill](https://code.claude.com/docs/zh-TW/skills.md#control-who-invokes-a-skill) | 是 |52| `Skill` | 在主對話中執行 [skill](https://code.claude.com/docs/zh-TW/skills.md#control-who-invokes-a-skill)。對於設定了 `allowed-tools`、`disallowed-tools` 或 `hooks` 的 skill,可能會提示 | 部分 skill |

53| `SubagentHandback` | 將 subagent 的最終報告傳遞給接收該 subagent 結果的任何對話。僅在[自動模式](https://code.claude.com/docs/zh-TW/permission-modes.md#eliminate-prompts-with-auto-mode)中提供,給 Agent 工具在本機執行的 subagent,除了[分支](https://code.claude.com/docs/zh-TW/sub-agents.md#fork-the-current-conversation),並在終端機 CLI、IDE 擴充功能、雲端工作階段和 Agent SDK 中可用;分類器在傳遞報告前審查它。需要 Claude Code v2.1.271 或更新版本 | 否 |53| `SubagentHandback` | 將 subagent 的最終報告傳遞給接收該 subagent 結果的任何對話。僅在[自動模式](https://code.claude.com/docs/zh-TW/permission-modes.md#eliminate-prompts-with-auto-mode)中提供,給 Agent 工具在本機執行的 subagent,除了[分支](https://code.claude.com/docs/zh-TW/sub-agents.md#fork-the-current-conversation),並在終端機 CLI、IDE 擴充功能、雲端工作階段和 Agent SDK 中可用;分類器在傳遞報告前審查它。需要 Claude Code v2.1.271 或更新版本 | 否 |

54| `TaskCreate` | 在任務清單中建立新任務。預設情況下僅在[任務工具可用性](#task-tool-availability)下列出的模型上提供,在其他模型上當您選擇加入時提供 | 否 |54| `TaskCreate` | 在任務清單中建立新任務。預設情況下僅在[任務工具可用性](#task-tool-availability)下列出的模型上提供,在其他模型上當您選擇加入時提供 | 否 |

55| `TaskGet` | 檢索特定任務的完整詳細資訊。預設情況下僅在[任務工具可用性](#task-tool-availability)下列出的模型上提供,在其他模型上當您選擇加入時提供 | 否 |55| `TaskGet` | 檢索特定任務的完整詳細資訊。預設情況下僅在[任務工具可用性](#task-tool-availability)下列出的模型上提供,在其他模型上當您選擇加入時提供 | 否 |


197* Claude 在背景啟動的命令獲得 30 分鐘,或 Claude 使用 `run_in_background` 傳遞的 `timeout`,最多 2 小時197* Claude 在背景啟動的命令獲得 30 分鐘,或 Claude 使用 `run_in_background` 傳遞的 `timeout`,最多 2 小時

198* 在前景啟動、然後在其逾時時移至背景的命令,從移動時起獲得 30 分鐘198* 在前景啟動、然後在其逾時時移至背景的命令,從移動時起獲得 30 分鐘

199 199 

200在使用 `-p` 旗標、且提示詞以文字傳遞而非使用 `--input-format stream-json` 的執行中,兩個預設值都是 10 分鐘而非 30 分鐘,因為該執行會[在其結果之後等待背景命令](https://code.claude.com/docs/zh-TW/headless.md#background-tasks-at-exit)。200在使用 `-p` 旗標、且提示詞以文字傳遞而非使用 `--input-format stream-json` 的執行中,兩個預設值都是 10 分鐘而非 30 分鐘。

201 201 

202當背景命令達到其時間限制時,Claude Code 會停止它並告訴 Claude 原因,Claude 可以使用更長的 `timeout` 重新啟動命令,如果工作仍然需要的話。停止通知讀作 `Background command "<description>" was stopped after reaching its background time limit`。202當背景命令達到其時間限制時,Claude Code 會停止它並告訴 Claude 原因,Claude 可以使用更長的 `timeout` 重新啟動命令,如果工作仍然需要的話。停止通知讀作 `Background command "<description>" was stopped after reaching its background time limit`。

203 203 


260 260 

261當 Claude 以這種方式檢視檔案時,Claude Code 也會載入適用於該檔案的任何[子目錄 `CLAUDE.md`](https://code.claude.com/docs/zh-TW/memory#how-claude-md-files-load) 和[路徑範圍規則](https://code.claude.com/docs/zh-TW/memory.md#path-specific-rules)。請參閱 [Read 和 Edit 權限規則](https://code.claude.com/docs/zh-TW/permissions.md#read-and-edit),了解您的 `Read` 和 `Edit` 拒絕規則涵蓋哪些 Bash 命令。261當 Claude 以這種方式檢視檔案時,Claude Code 也會載入適用於該檔案的任何[子目錄 `CLAUDE.md`](https://code.claude.com/docs/zh-TW/memory#how-claude-md-files-load) 和[路徑範圍規則](https://code.claude.com/docs/zh-TW/memory.md#path-specific-rules)。請參閱 [Read 和 Edit 權限規則](https://code.claude.com/docs/zh-TW/permissions.md#read-and-edit),了解您的 `Read` 和 `Edit` 拒絕規則涵蓋哪些 Bash 命令。

262 262 

263### 保護 Perforce 中的唯讀檔案

264 

265若要防止 Edit、Write 和 NotebookEdit 覆寫 Perforce 工作區中的唯讀檔案,請將 [`CLAUDE_CODE_PERFORCE_MODE`](https://code.claude.com/docs/zh-TW/env-vars#variables) 設定為 `1`。這些工具隨後會拒絕變更唯讀檔案,並告知 Claude 先執行 `p4 edit`。

266 

263### 非 UTF-8 檔案267### 非 UTF-8 檔案

264 268 

265Claude 無法對不是有效 UTF-8 的檔案使用 [NotebookEdit](#notebookedit-tool-behavior)。Edit 也是如此,除非檔案以小端序 UTF-16 位元組順序標記開頭。當 Claude 嘗試時,工具會拒絕變更並保持檔案不變。被拒絕的檔案包括以 Windows-1252 或 Shift-JIS 等舊式編碼儲存的非 ASCII 文字、二進位檔案,以及包含無效位元組序列的 UTF-8 檔案。269Claude 無法對不是有效 UTF-8 的檔案使用 [NotebookEdit](#notebookedit-tool-behavior)。Edit 也是如此,除非檔案以小端序 UTF-16 位元組順序標記開頭。當 Claude 嘗試時,工具會拒絕變更並保持檔案不變。被拒絕的檔案包括以 Windows-1252 或 Shift-JIS 等舊式編碼儲存的非 ASCII 文字、二進位檔案,以及包含無效位元組序列的 UTF-8 檔案。


446 450 

447權限規則使用 `Edit(...)` 路徑格式。像 `Edit(notebooks/**)` 這樣的規則涵蓋該目錄中檔案上的 NotebookEdit 呼叫。451權限規則使用 `Edit(...)` 路徑格式。像 `Edit(notebooks/**)` 這樣的規則涵蓋該目錄中檔案上的 NotebookEdit 呼叫。

448 452 

453### 替換儲存格會清除檔案中已儲存的輸出

454 

455當 NotebookEdit 替換程式碼儲存格時,其執行計數和已儲存的輸出會被清除。若要取回輸出,請重新執行該儲存格,以及任何使用其所定義之函式或變數的儲存格。如需 VS Code 工作流程,請參閱[使用 Jupyter notebooks](https://code.claude.com/docs/zh-TW/vs-code.md#work-with-jupyter-notebooks)。

456 

449## PowerShell 工具457## PowerShell 工具

450 458 

451PowerShell 工具讓 Claude 能夠原生執行 PowerShell 命令。在 Windows 上,這表示命令在 PowerShell 中執行,而不是透過 Git Bash 路由。工具的可用性取決於您的平台:459PowerShell 工具讓 Claude 能夠原生執行 PowerShell 命令。在 Windows 上,這表示命令在 PowerShell 中執行,而不是透過 Git Bash 路由。工具的可用性取決於您的平台:


692 700 

693> [!NOTE]701> [!NOTE]

694>702>

695> WebSearch 在 Claude API、[AWS 上的 Claude Platform](https://code.claude.com/docs/zh-TW/claude-platform-on-aws.md) 和 Microsoft Foundry 上可用。在 Google Cloud 的 Agent Platform 上,它適用於 Opus 4、Sonnet 4、Haiku 4.5 及更新版本的模型。Amazon Bedrock 不公開伺服器端網路搜尋工具。703> WebSearch 在 Claude API、[AWS 上的 Claude Platform](https://code.claude.com/docs/zh-TW/claude-platform-on-aws.md)、[Google Cloud 上的 Claude 模型(由 Anthropic 管理)](https://code.claude.com/docs/zh-TW/claude-models-on-google-cloud-anthropic-managed.md)和 Microsoft Foundry 上可用。在 Google Cloud 的 Agent Platform 上,它適用於 Opus 4、Sonnet 4、Haiku 4.5 及更新版本的模型。Amazon Bedrock 不公開伺服器端網路搜尋工具。

696 704 

697### 工作階段搜尋限制705### 工作階段搜尋限制

698 706 

vs-code.md +16 −1

Details

304* 擴充功能從 `claudeCode.initialPermissionMode` 或沿用自先前對話的選擇來[選擇起始權限模式](https://code.claude.com/docs/zh-TW/permission-modes.md#switch-permission-modes)304* 擴充功能從 `claudeCode.initialPermissionMode` 或沿用自先前對話的選擇來[選擇起始權限模式](https://code.claude.com/docs/zh-TW/permission-modes.md#switch-permission-modes)

305* 您已設定 `claudeCode.claudeProcessWrapper`305* 您已設定 `claudeCode.claudeProcessWrapper`

306* [拒絕規則](https://code.claude.com/docs/zh-TW/permissions.md#manage-permissions)移除了 [`ExitPlanMode`](https://code.claude.com/docs/zh-TW/tools-reference) 工具306* [拒絕規則](https://code.claude.com/docs/zh-TW/permissions.md#manage-permissions)移除了 [`ExitPlanMode`](https://code.claude.com/docs/zh-TW/tools-reference) 工具

307* [`permissions.denyInsteadOfPrompting`](https://code.claude.com/docs/zh-TW/settings-reference#permissions-denyinsteadofprompting) 已開啟

307 308 

308#### 對話仍在其他地方開啟309#### 對話仍在其他地方開啟

309 310 


605 606 

606例如,當您[要求 Claude 在某個 worktree 中工作](https://code.claude.com/docs/zh-TW/worktrees.md#ask-claude-to-create-a-worktree)時,對話就會移至該 worktree。當您重新開啟對話,或面板[在視窗重新載入後重新開啟對話](#continue-conversations-after-a-reload)時,如果該 worktree 是由 Claude Code 在 `.claude/worktrees/` 下建立且仍然存在,對話就會在該 worktree 中繼續。在 Claude Code v2.1.300 之前,會改為開啟一個空白對話。若使用這些版本,請更新擴充功能。607例如,當您[要求 Claude 在某個 worktree 中工作](https://code.claude.com/docs/zh-TW/worktrees.md#ask-claude-to-create-a-worktree)時,對話就會移至該 worktree。當您重新開啟對話,或面板[在視窗重新載入後重新開啟對話](#continue-conversations-after-a-reload)時,如果該 worktree 是由 Claude Code 在 `.claude/worktrees/` 下建立且仍然存在,對話就會在該 worktree 中繼續。在 Claude Code v2.1.300 之前,會改為開啟一個空白對話。若使用這些版本,請更新擴充功能。

607 608 

609## 使用 Jupyter notebook

610 

611Claude Code 使用 [NotebookEdit 工具](https://code.claude.com/docs/zh-TW/tools-reference.md#notebookedit-tool-behavior)編輯 notebook。

612 

613### 重新執行已編輯的儲存格

614 

615當 Claude 取代程式碼儲存格時,會在檔案中重寫該儲存格的原始碼,並清除該儲存格已儲存的輸出與執行計數。

616 

617此編輯不需要重新啟動 kernel:NotebookEdit 只會寫入檔案,不會連線至您的 kernel。請重新執行該儲存格,以及任何使用其所定義之函式或變數的儲存格。

618 

619### 在編輯前儲存 notebook

620 

621請在要求編輯之前先儲存 notebook;擴充功能的 [`autosave` 設定](#extension-settings)不會在 NotebookEdit 執行前進行儲存。

622 

608## 在背景執行工作623## 在背景執行工作

609 624 

610將長時間執行的命令或 subagent 移至背景,然後從提示詞輸入框查看其狀態。625將長時間執行的命令或 subagent 移至背景,然後從提示詞輸入框查看其狀態。


736| `initialPermissionMode` | - | 控制新對話的核准提示:`default`、`plan`、`acceptEdits` 或 `bypassPermissions`。`manual` 是 `default` 的別名,會選取模式指示器中標示為 **Manual** 的模式。若未設定,擴充功能會依照[切換權限模式](https://code.claude.com/docs/zh-TW/permission-modes.md#switch-permission-modes)中的說明選擇起始權限模式。 |751| `initialPermissionMode` | - | 控制新對話的核准提示:`default`、`plan`、`acceptEdits` 或 `bypassPermissions`。`manual` 是 `default` 的別名,會選取模式指示器中標示為 **Manual** 的模式。若未設定,擴充功能會依照[切換權限模式](https://code.claude.com/docs/zh-TW/permission-modes.md#switch-permission-modes)中的說明選擇起始權限模式。 |

737| `preferredLocation` | `panel` | Claude 開啟的位置:`sidebar`(右側)或 `panel`(新分頁) |752| `preferredLocation` | `panel` | Claude 開啟的位置:`sidebar`(右側)或 `panel`(新分頁) |

738| `lockEditorGroups` | `true` | [鎖定 Claude 為其分頁啟動的編輯器群組](#choose-where-claude-lives),讓您在 Claude 分頁處於焦點時開啟的檔案會移至其他群組。關閉時,擴充功能永遠不會鎖定編輯器群組。需要 Claude Code v2.1.274 或更新版本 |753| `lockEditorGroups` | `true` | [鎖定 Claude 為其分頁啟動的編輯器群組](#choose-where-claude-lives),讓您在 Claude 分頁處於焦點時開啟的檔案會移至其他群組。關閉時,擴充功能永遠不會鎖定編輯器群組。需要 Claude Code v2.1.274 或更新版本 |

739| `autosave` | `true` | 在 Claude 讀取或寫入檔案前自動儲存檔案 |754| `autosave` | `true` | 在 Read、Edit 和 Write 工具執行前自動儲存檔案 |

740| `attachOpenFile` | `true` | 將編輯器中開啟的檔案新增至您的訊息,並顯示在提示詞輸入框中。關閉時,只有在連同您選取的文字一起時才會新增該檔案。需要 Claude Code v2.1.271 或更新版本 |755| `attachOpenFile` | `true` | 將編輯器中開啟的檔案新增至您的訊息,並顯示在提示詞輸入框中。關閉時,只有在連同您選取的文字一起時才會新增該檔案。需要 Claude Code v2.1.271 或更新版本 |

741| `attachSelection` | `true` | 將您在編輯器中選取的文字新增至您的訊息,並顯示在提示詞輸入框中。關閉時,您仍可[將選取內容以 @-mention 形式新增](#automatic-context-from-your-selection-and-open-file)。需要 Claude Code v2.1.300 或更新版本 |756| `attachSelection` | `true` | 將您在編輯器中選取的文字新增至您的訊息,並顯示在提示詞輸入框中。關閉時,您仍可[將選取內容以 @-mention 形式新增](#automatic-context-from-your-selection-and-open-file)。需要 Claude Code v2.1.300 或更新版本 |

742| `useCtrlEnterToSend` | `false` | 使用 Ctrl/Cmd+Enter 而非 Enter 傳送提示詞 |757| `useCtrlEnterToSend` | `false` | 使用 Ctrl/Cmd+Enter 而非 Enter 傳送提示詞 |

workflows.md +1 −1

Details

454* 在大型執行前檢查 `/model`,如果您通常為日常工作切換到較小的模型454* 在大型執行前檢查 `/model`,如果您通常為日常工作切換到較小的模型

455* 當您描述任務時,要求 Claude 為不需要最強模型的階段使用較小的模型455* 當您描述任務時,要求 Claude 為不需要最強模型的階段使用較小的模型

456 456 

457當您組織的 [`availableModels` 允許清單](https://code.claude.com/docs/zh-TW/model-config#restrict-model-selection)封鎖指令碼為 agent 請求的模型時,該 agent 會改為在替代模型上執行,並遵循與 [subagent 相同的替代規則](https://code.claude.com/docs/zh-TW/sub-agents.md#choose-a-model)。457當您組織的 [`availableModels` 允許清單](https://code.claude.com/docs/zh-TW/model-config#restrict-model-selection)封鎖指令碼為 agent 請求的模型時,該 agent 會改為在替代模型上執行,並遵循與 [subagent 相同的替代規則](https://code.claude.com/docs/zh-TW/sub-agents.md#when-an-allowlist-blocks-a-subagent-model)。

458 458 

459### 設定大小指南459### 設定大小指南

460 460 

worktrees.md +5 −2

Details

232 232 

233使用預設 `"fresh"` [基礎](#choose-the-base-branch),當以下所有條件都成立時,重新開啟的 worktree 會重設為儲存庫的預設分支,而不是在其舊的頂端繼續:233使用預設 `"fresh"` [基礎](#choose-the-base-branch),當以下所有條件都成立時,重新開啟的 worktree 會重設為儲存庫的預設分支,而不是在其舊的頂端繼續:

234 234 

235* 它沒有未提交的變更或未追蹤的檔案。235* [沙箱](https://code.claude.com/docs/zh-TW/sandboxing.md#filesystem-isolation)未在您的工作階段中限制檔案寫入,且 worktree 和主要檢出的 `.claude` 設定檔都未啟用沙箱。

236* worktree 沒有未提交的變更或未追蹤的檔案。

236* 它仍在 Claude Code 為其建立的分支上。237* 它仍在 Claude Code 為其建立的分支上。

237* 它沒有自己的提交,或其拉取請求或合併請求已合併且其遠端分支已刪除。238* 它沒有自己的提交,或其拉取請求或合併請求已合併且其遠端分支已刪除。

238 239 


240 241 

241在所有其他情況下,Claude Code 會在其舊的頂端重新開啟 worktree:242在所有其他情況下,Claude Code 會在其舊的頂端重新開啟 worktree:

242 243 

243* worktree 有任一條件不成立。244* worktree 或工作階段有任一條件不成立。

244* Claude Code 無法驗證 worktree 的狀態。245* Claude Code 無法驗證 worktree 的狀態。

245* `worktree.baseRef` 是 `"head"`。246* `worktree.baseRef` 是 `"head"`。

246* 名稱是拉取請求或合併請求參考。247* 名稱是拉取請求或合併請求參考。

247 248 

249如果您搭配 `"fresh"` 基礎使用沙箱,請執行 `git fetch origin`,然後將新名稱傳遞給 `--worktree`,以從最新的預設分支開始。

250 

248### 使用 hook 取代 worktree 建立251### 使用 hook 取代 worktree 建立

249 252 

250配置 [`WorktreeCreate` hook](https://code.claude.com/docs/zh-TW/hooks#worktreecreate) 以完全取代預設的 `git worktree` 邏輯,包括將 worktrees 放在 `.claude/worktrees/` 以外的地方。有關完整範例,請參閱[非 git 版本控制](#non-git-version-control)。253配置 [`WorktreeCreate` hook](https://code.claude.com/docs/zh-TW/hooks#worktreecreate) 以完全取代預設的 `git worktree` 邏輯,包括將 worktrees 放在 `.claude/worktrees/` 以外的地方。有關完整範例,請參閱[非 git 版本控制](#non-git-version-control)。

Details

48| claude.ai 上的聊天 | 通過 Claude for Enterprise 網頁介面的聊天對話不受 ZDR 保護。 |48| claude.ai 上的聊天 | 通過 Claude for Enterprise 網頁介面的聊天對話不受 ZDR 保護。 |

49| Cowork | Cowork 會話不受 ZDR 保護。 |49| Cowork | Cowork 會話不受 ZDR 保護。 |

50| Artifacts | 聊天對話和 Cowork 工作階段中的 artifact 不受 ZDR 保護,並會保留至被刪除為止,除非您的組織為其設定了保留期限。在啟用 ZDR 的 Claude Code 中無法使用 artifact。 |50| Artifacts | 聊天對話和 Cowork 工作階段中的 artifact 不受 ZDR 保護,並會保留至被刪除為止,除非您的組織為其設定了保留期限。在啟用 ZDR 的 Claude Code 中無法使用 artifact。 |

51| Claude in Chrome | [Claude in Chrome](https://support.claude.com/en/articles/13065128-claude-in-chrome-admin-controls) 瀏覽器擴充功能不受 ZDR 保護。在啟用 ZDR 的情況下,它[無法在 Claude Code 中使用](https://code.claude.com/docs/zh-TW/chrome.md#chrome-availability-with-hipaa-or-zero-data-retention),但在您的組織允許的情況下,成員仍可在 Claude Code 之外使用它。 |

51| Claude Code 分析 | 不存儲提示或模型回應,但收集生產力中繼資料,例如帳戶電子郵件和使用統計資訊。對於 ZDR 組織,貢獻指標不可用;[分析儀表板](https://code.claude.com/docs/zh-TW/analytics.md)僅顯示使用指標。 |52| Claude Code 分析 | 不存儲提示或模型回應,但收集生產力中繼資料,例如帳戶電子郵件和使用統計資訊。對於 ZDR 組織,貢獻指標不可用;[分析儀表板](https://code.claude.com/docs/zh-TW/analytics.md)僅顯示使用指標。 |

52| 使用者和座位管理 | 管理資料(例如帳戶電子郵件和座位分配)根據標準政策保留。 |53| 使用者和座位管理 | 管理資料(例如帳戶電子郵件和座位分配)根據標準政策保留。 |

53| 第三方整合 | 由第三方工具、MCP servers 或其他外部整合處理的資料不受 ZDR 保護。請獨立審查這些服務的資料處理實踐。 |54| 第三方整合 | 由第三方工具、MCP servers 或其他外部整合處理的資料不受 ZDR 保護。請獨立審查這些服務的資料處理實踐。 |