SpyBara
Go Premium

Documentation 2026-11-11 22:59 UTC to 2026-11-12 23:02 UTC

11 files changed +334 −206. View all changes and history on the product overview
2026
Fri 13 02:00 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
Details

254| 源 | 何时加载 | 影响 |254| 源 | 何时加载 | 影响 |

255| :- | :- | :- |255| :- | :- | :- |

256| **系统提示** | 每个请求 | 小的固定成本,始终存在 |256| **系统提示** | 每个请求 | 小的固定成本,始终存在 |

257| **CLAUDE.md 文件** | 会话开始,通过 [`settingSources`](https://code.claude.com/docs/zh-CN/agent-sdk/claude-code-features) | 每个请求中的完整内容(但提示缓存,所以仅第一个请求支付全部成本) |257| **CLAUDE.md 文件** | 会话开始,通过 [`settingSources`](https://code.claude.com/docs/zh-CN/agent-sdk/claude-code-features) | 每个请求中的完整内容(但会进行提示缓存) |

258| **工具定义** | 对于 Bash、Read 和 Edit 等核心内置工具,每个请求都会加载;对于 MCP 工具和其他内置工具则按需加载,[工具搜索](https://code.claude.com/docs/zh-CN/agent-sdk/mcp.md#mcp-tool-search)默认会延迟加载这些工具 | 在[配置工具搜索](https://code.claude.com/docs/zh-CN/agent-sdk/tool-search.md#configure-tool-search)中列出的情况下,所有 schema 都会预先加载 |258| **工具定义** | 对于 Bash、Read 和 Edit 等核心内置工具,每个请求都会加载;对于 MCP 工具和其他内置工具则按需加载,[工具搜索](https://code.claude.com/docs/zh-CN/agent-sdk/mcp.md#mcp-tool-search)默认会延迟加载这些工具 | 在[配置工具搜索](https://code.claude.com/docs/zh-CN/agent-sdk/tool-search.md#configure-tool-search)中列出的情况下,所有 schema 都会预先加载 |

259| **对话历史** | 在轮次中累积 | 随着每个轮次增长:提示、响应、工具输入、工具输出 |259| **对话历史** | 在轮次中累积 | 随着每个轮次增长:提示、响应、工具输入、工具输出 |

260| **技能描述** | 会话开始,通过设置源 | 简短摘要;完整内容仅在调用时加载 |260| **技能描述** | 会话开始,通过设置源 | 简短摘要;完整内容仅在调用时加载 |

Details

298 298 

299### 镜像写入是尽力而为的299### 镜像写入是尽力而为的

300 300 

301如果 `append()` 拒绝,SDK 会以短退避重试该批次最多两次,总共最多三次尝试。超时的调用不会重试,因为原始调用可能仍然会成功。如果批次仍然失败,SDK 记录错误,向迭代器发出 `{ type: "system", subtype: "mirror_error" }` 消息,丢弃批次,并继续查询。因为重试的批次可以重新传递已经成功的条目,请在您的 `append()` 实现中按 `entry.uuid` 进行去重。301如果 `append()` 拒绝,SDK 会以短退避重试该批次最多两次,总共最多三次尝试。超时的调用不会重试,因为原始调用可能仍然会成功。因为重试的批次可以重新传递已经成功的条目,请在您的 `append()` 实现中按 `entry.uuid` 进行去重,并保留所有没有 `uuid` 的条目。

302 302 

303存储中断不会中断 Agent,因为子进程首先在本地写入。如果您需要检测存储数据丢失,请监视 `mirror_error`。在[从存储恢复](#resume-from-the-store)的运行上,丢弃的批次在运行结束后没有幸存的副本。303如果批次仍然失败,SDK 记录错误,向迭代器发出 `{ type: "system", subtype: "mirror_error" }` 消息,丢弃批次,并继续查询。存储中断不会中断 Agent,因为子进程首先在本地写入。请监视 `mirror_error` 以检测存储数据丢失。在[从存储恢复](#resume-from-the-store)的运行上,丢弃的批次在运行结束后没有幸存的副本。

304 304 

305### `getSessionMessages` 返回后压缩链305### `getSessionMessages` 返回后压缩链

306 306 

Details

512 512 

513### 在 Invoke API 旁边运行 Mantle513### 在 Invoke API 旁边运行 Mantle

514 514 

515您在 Mantle 上可用的模型可能不包括您今天使用的每个模型。设置 `CLAUDE_CODE_USE_BEDROCK` 和 `CLAUDE_CODE_USE_MANTLE` 让 Claude Code 从同一会话调用两个端点。与 Mantle 格式匹配的模型 ID 被路由到 Mantle,所有其他模型 ID 转到 Amazon Bedrock Invoke API。515您在 Mantle 上可用的模型可能不包括您今天使用的每个模型。如果您不通过网关连接,请同时设置 `CLAUDE_CODE_USE_BEDROCK` 和 `CLAUDE_CODE_USE_MANTLE`,以便从同一会话中调用 Mantle 和 Invoke API。与 Mantle 格式匹配的模型 ID 被路由到 Mantle,所有其他模型 ID 转到 Amazon Bedrock Invoke API。

516 516 

517```bash theme={null}517```bash theme={null}

518export CLAUDE_CODE_USE_BEDROCK=1518export CLAUDE_CODE_USE_BEDROCK=1


618* 如果错误命名了 `bedrock-mantle:` 操作,请为您的 IAM 身份授予该操作。618* 如果错误命名了 `bedrock-mantle:` 操作,请为您的 IAM 身份授予该操作。

619* 如果错误没有命名任何操作且您的凭证有效,您的 AWS 账户没有被授予访问您请求的模型的权限。联系您的 AWS 账户团队以请求访问。619* 如果错误没有命名任何操作且您的凭证有效,您的 AWS 账户没有被授予访问您请求的模型的权限。联系您的 AWS 账户团队以请求访问。

620 620 

621指出模型 ID 的 `400` 意味着该模型不在 Mantle 上提供。Mantle 有其自己的模型阵容,与标准 Amazon Bedrock 目录分开,因此推理配置文件 ID(如 `us.anthropic.claude-sonnet-4-6`)不起作用。请使用 Mantle 格式的 ID,或启用[两个端点](#run-mantle-alongside-the-invoke-api),以便 Claude Code 将推理配置文件 ID 发送到 Invoke API。621指出模型 ID 的 `400` 意味着该模型不在 Mantle 上提供。Mantle 有其自己的模型阵容,与标准 Amazon Bedrock 目录分开,因此推理配置文件 ID(如 `us.anthropic.claude-sonnet-4-6`)不起作用。

622 

623要清除该错误:

624 

625* **不使用网关**:使用 Mantle 提供的 [Mantle 格式 ID](#select-a-mantle-model),或[将 Mantle 与 Invoke API 一起运行](#run-mantle-alongside-the-invoke-api),以便将其他格式的 ID 发送到该 API。

626* **通过网关**:向网关的运营方询问应使用哪些模型 ID。

622 627 

623## 其他资源628## 其他资源

624 629 

desktop.md +26 −5

Details

148 148 

149#### 为您的组织关闭 SSH 和 WSL 预览中的脚本149#### 为您的组织关闭 SSH 和 WSL 预览中的脚本

150 150 

151要阻止 [SSH 和 WSL 会话中的 HTML 预览](#preview-html-files-in-ssh-and-wsl-sessions)运行脚本,请将 [`disableBrowserExternalNavigation` 托管设置](#managed-settings)设置为 `true`。启用此设置后,用户也无法在浏览器窗格中[浏览外部网站](#restrict-external-browsing-for-your-organization)。151要阻止 [SSH 和 WSL 会话中的 HTML 预览](#preview-html-files-in-ssh-and-wsl-sessions)运行脚本,请将 [`disableRemotePreviewScripts` 托管设置](#managed-settings)设置为 `true`。用户仍然可以浏览外部网站。需要 Claude Desktop v5.1231.0 或更高版本。

152 152 

153请在您的[服务器托管设置](https://code.claude.com/docs/zh-CN/server-managed-settings.md)中设置它,或在运行 Desktop 的计算机上的 [Claude Code MDM 策略或托管设置文件](https://code.claude.com/docs/zh-CN/managed-settings.md#where-each-mechanism-stores-the-policy)中设置它。Desktop 不会从远程机器或 WSL 发行版读取它。使用[第三方提供商](https://code.claude.com/docs/zh-CN/third-party-integrations.md)时,请使用 MDM 策略或该文件。153> [!NOTE]

154>

155> 早期版本会忽略 `disableRemotePreviewScripts`。要在这些版本中阻止脚本,请更新 Desktop,或同时将 `disableBrowserExternalNavigation` 设置为 `true`。这样,在任何接收 `disableBrowserExternalNavigation` 的计算机上,用户都[无法浏览外部网站](#restrict-external-browsing-for-your-organization)。

156 

157请在您的[服务器托管设置](https://code.claude.com/docs/zh-CN/server-managed-settings.md)中设置每个键,或在运行 Desktop 的计算机上的 [Claude Code MDM 策略或托管设置文件](https://code.claude.com/docs/zh-CN/managed-settings.md#where-each-mechanism-stores-the-policy)中设置。Desktop 不会从远程机器、WSL 发行版、[`policyHelper`](https://code.claude.com/docs/zh-CN/settings-reference#policyhelper) 或 [Desktop 自身的策略](#device-management-policies)中读取这些键。使用[第三方提供商](https://code.claude.com/docs/zh-CN/third-party-integrations.md)时,请使用 MDM 策略或该文件。

154 158 

155> [!WARNING]159> [!WARNING]

156>160>


160 164 

161然后让用户重启 Desktop 以确保设置生效,并告诉他们会出现什么情况:165然后让用户重启 Desktop 以确保设置生效,并告诉他们会出现什么情况:

162 166 

163* **他们打开的文件**:预览不运行脚本,因此由脚本绘制的图表和表格会保持为空167* **他们打开的文件**:预览不运行脚本,因此由脚本绘制的图表和表格会保持为空。其提示以 `This preview doesn't run scripts` 开头。

164* **正在运行脚本的预览**:如果 Desktop 在重启之前就获取了该设置,这些预览会关闭。用户会看到 `This preview closed because scripts are turned off for previews. Open the file again to view it without scripts.`168* **正在运行脚本的预览**:如果 Desktop 在重启之前就获取了该设置,这些预览会关闭。用户会看到 `This preview closed because scripts are turned off for previews. Open the file again to view it without scripts.`

165* **他们导出的文件**:如果用户[导出文件](#preview-html-files-in-ssh-and-wsl-sessions)并在浏览器中打开,无论是否启用此设置,其脚本都会在那里运行169* **他们导出的文件**:如果用户[导出文件](#preview-html-files-in-ssh-and-wsl-sessions)并在浏览器中打开,无论是否启用此设置,其脚本都会在那里运行

166 170 

171##### 检查计算机上是否仍有脚本运行

172 

173重启后,在该计算机上从 SSH 或 WSL 会话打开一个 HTML 文件。如果预览上方的提示以 `This preview doesn't load anything from the web` 开头,说明脚本在那里仍会运行。请检查 [Desktop 的版本](#check-your-version)、您放置该键的位置,以及其值是否为 JSON 布尔值 `true`。

174 

167### 浏览外部网站175### 浏览外部网站

168 176 

169浏览器窗格是一个选项卡式浏览器,因此您可以在运行的应用旁边打开文档、问题跟踪器或任何其他网站。要打开浏览器,在 macOS 上按 **Cmd+Shift+B** 或在 Windows 上按 **Ctrl+Shift+B**,或点击会话标题栏中的 **Browser**。您可以在窗格中登录网站,包括弹出式登录流程,例如 Google OAuth。177浏览器窗格是一个选项卡式浏览器,因此您可以在运行的应用旁边打开文档、问题跟踪器或任何其他网站。要打开浏览器,在 macOS 上按 **Cmd+Shift+B** 或在 Windows 上按 **Ctrl+Shift+B**,或点击会话标题栏中的 **Browser**。您可以在窗格中登录网站,包括弹出式登录流程,例如 Google OAuth。


2037| `browserExternalPageTools` | 设置为 `"disabled"` 以防止 Claude 使用工具在[浏览器窗格](#browse-external-sites)中读取或作用于外部页面。用户仍然可以自己导航到外部网站,本地开发服务器预览不受影响。 |2045| `browserExternalPageTools` | 设置为 `"disabled"` 以防止 Claude 使用工具在[浏览器窗格](#browse-external-sites)中读取或作用于外部页面。用户仍然可以自己导航到外部网站,本地开发服务器预览不受影响。 |

2038| `disableMobileSimulatorTools` | 设置为 `true` 以阻止 Claude 在 [iOS Simulator 窗格](https://code.claude.com/docs/zh-CN/desktop-ios-simulator.md#turn-off-simulator-access)中控制和捕获设备的工具。该窗格仍可用于用户自己的点击;仅删除 Claude 的访问权限。该值必须是 JSON 布尔值 `true`;字符串 `"true"` 被忽略。 |2046| `disableMobileSimulatorTools` | 设置为 `true` 以阻止 Claude 在 [iOS Simulator 窗格](https://code.claude.com/docs/zh-CN/desktop-ios-simulator.md#turn-off-simulator-access)中控制和捕获设备的工具。该窗格仍可用于用户自己的点击;仅删除 Claude 的访问权限。该值必须是 JSON 布尔值 `true`;字符串 `"true"` 被忽略。 |

2039| `disableBrowserExternalNavigation` | 设置为 `true` 以完全关闭[浏览器窗格](#browse-external-sites)中的外部浏览。用户和 Claude 都无法导航到外部网站,localhost 开发服务器预览不受影响。SSH 和 WSL 会话中的 HTML 预览[不运行脚本](#turn-off-scripts-in-ssh-and-wsl-previews-for-your-organization)。该值必须是 JSON 布尔值 `true`;字符串 `"true"` 被忽略。 |2047| `disableBrowserExternalNavigation` | 设置为 `true` 以完全关闭[浏览器窗格](#browse-external-sites)中的外部浏览。用户和 Claude 都无法导航到外部网站,localhost 开发服务器预览不受影响。SSH 和 WSL 会话中的 HTML 预览[不运行脚本](#turn-off-scripts-in-ssh-and-wsl-previews-for-your-organization)。该值必须是 JSON 布尔值 `true`;字符串 `"true"` 被忽略。 |

2048| `disableRemotePreviewScripts` | 设置为 `true` 以[仅关闭 SSH 和 WSL 会话中 HTML 预览的脚本](#turn-off-scripts-in-ssh-and-wsl-previews-for-your-organization)。Desktop 不会从远程机器或 WSL 发行版中读取它。该值必须是 JSON 布尔值 `true`;字符串 `"true"` 被忽略。需要 Claude Desktop v5.1231.0 或更高版本。 |

2040| `sshConfigs` | 预配置[SSH 连接](#pre-configure-ssh-connections-for-your-team),在环境选择器中显示。用户无法删除托管连接,也无法编辑除其自己的 **Worktree folder** 之外的任何内容。 |2049| `sshConfigs` | 预配置[SSH 连接](#pre-configure-ssh-connections-for-your-team),在环境选择器中显示。用户无法删除托管连接,也无法编辑除其自己的 **Worktree folder** 之外的任何内容。 |

2041| `sshHostCommands` | 为用户提供[主机来自命令的 SSH 连接](#distribute-commands-to-your-team),与用户自己的连接并存。Desktop 从计算机上的托管设置文件或 MDM 策略中读取它,并在[服务器管理的设置](https://code.claude.com/docs/zh-CN/server-managed-settings.md)中忽略它。需要 macOS 或 Linux 上的 Claude Desktop v3.6556.0 或更高版本,或 Windows 上的 v4.16336.0 或更高版本,并使用 Claude 帐户登录。在 Windows 上,Desktop 还必须[通过 OpenSSH 客户端连接](#use-your-ssh-configuration)。 |2050| `sshHostCommands` | 为用户提供[主机来自命令的 SSH 连接](#distribute-commands-to-your-team),与用户自己的连接并存。Desktop 从计算机上的托管设置文件或 MDM 策略中读取它,并在[服务器管理的设置](https://code.claude.com/docs/zh-CN/server-managed-settings.md)中忽略它。需要 macOS 或 Linux 上的 Claude Desktop v3.6556.0 或更高版本,或 Windows 上的 v4.16336.0 或更高版本,并使用 Claude 帐户登录。在 Windows 上,Desktop 还必须[通过 OpenSSH 客户端连接](#use-your-ssh-configuration)。 |

2042| `sshHostAllowlist` | 限制 [SSH 会话](#restrict-which-ssh-hosts-users-can-connect-to)连接到已解析主机名与这些模式之一匹配的主机。仅从托管设置中读取。 |2051| `sshHostAllowlist` | 限制 [SSH 会话](#restrict-which-ssh-hosts-users-can-connect-to)连接到已解析主机名与这些模式之一匹配的主机。仅从托管设置中读取。 |


2044| `disableSshSavedPasswords` | 设置为 `true` 以阻止 Desktop 提供记住 SSH 密码的选项,并阻止其使用或显示之前保存的密码。启用此设置不会删除这些密码。仅从托管设置中读取。需要 Claude Desktop v1.49585.0 或更高版本。 |2053| `disableSshSavedPasswords` | 设置为 `true` 以阻止 Desktop 提供记住 SSH 密码的选项,并阻止其使用或显示之前保存的密码。启用此设置不会删除这些密码。仅从托管设置中读取。需要 Claude Desktop v1.49585.0 或更高版本。 |

2045| `managedMcpServers` | 将 MCP 服务器配置推送到所有用户。仅在第三方 (3P) Desktop 部署中可用。在每个条目中,设置 `"http"`、`"sse"` 或 `"stdio"` 的传输、连接详细信息,以及可选的 `toolPolicy` 映射,该映射限制该服务器中用户可以调用的工具。通过托管设置文件、MDM 或 Claude apps gateway 策略的 [`desktop` 块](https://code.claude.com/docs/zh-CN/claude-apps-gateway-config#claude-desktop-overlay)提供它,因为 3P 部署不接收管理员控制台设置。要通过网关提供它,您需要网关服务器上的 Claude Code v2.1.232 或更高版本。这是桌面应用自己的键;Claude Code 读取自己的[同名托管设置](https://code.claude.com/docs/zh-CN/managed-mcp.md#provide-servers-through-managed-settings),具有不同的条目形状。 |2054| `managedMcpServers` | 将 MCP 服务器配置推送到所有用户。仅在第三方 (3P) Desktop 部署中可用。在每个条目中,设置 `"http"`、`"sse"` 或 `"stdio"` 的传输、连接详细信息,以及可选的 `toolPolicy` 映射,该映射限制该服务器中用户可以调用的工具。通过托管设置文件、MDM 或 Claude apps gateway 策略的 [`desktop` 块](https://code.claude.com/docs/zh-CN/claude-apps-gateway-config#claude-desktop-overlay)提供它,因为 3P 部署不接收管理员控制台设置。要通过网关提供它,您需要网关服务器上的 Claude Code v2.1.232 或更高版本。这是桌面应用自己的键;Claude Code 读取自己的[同名托管设置](https://code.claude.com/docs/zh-CN/managed-mcp.md#provide-servers-through-managed-settings),具有不同的条目形状。 |

2046 2055 

2047如果您在计算机的[最高优先级 MDM 策略或托管设置文件](https://code.claude.com/docs/zh-CN/managed-settings.md#how-claude-code-combines-managed-sources)中使用 `browserExternalPageTools`、`disableMobileSimulatorTools` 或 `disableBrowserExternalNavigation` 关闭某项功能,该功能将在该计算机上保持关闭。即使您的[服务器管理的设置](https://code.claude.com/docs/zh-CN/server-managed-settings.md)未设置该键或允许该功能,它也会保持关闭。请勿为此使用用户级 `HKCU` 注册表值。要重新打开该功能,请在您设置该值的所有位置将其删除。需要 Claude Desktop v4.4212.0 或更高版本。2056如果您在计算机的[最高优先级 MDM 策略或托管设置文件](https://code.claude.com/docs/zh-CN/managed-settings.md#how-claude-code-combines-managed-sources)中使用以下四个键之一关闭某项功能,该功能将在该计算机上保持关闭:

2057 

2058* **`browserExternalPageTools`、`disableMobileSimulatorTools`、`disableBrowserExternalNavigation`**:需要 Claude Desktop v4.4212.0 或更高版本

2059* **`disableRemotePreviewScripts`**:需要 Claude Desktop v5.1231.0 或更高版本

2060 

2061即使您的[服务器管理的设置](https://code.claude.com/docs/zh-CN/server-managed-settings.md)未设置该键或允许该功能,它也会保持关闭。请勿为此使用用户级 `HKCU` 注册表值。要重新打开该功能,请在您设置该值的所有位置将其删除。

2048 2062 

2049哪些托管设置到达 Desktop 会话取决于该会话运行的位置。模型限制(如 [`availableModels`](https://code.claude.com/docs/zh-CN/model-config#restrict-model-selection))在 Desktop 的 Claude Code 会话中的执行方式与在终端 CLI 中相同;请参阅[使用入口覆盖范围](https://code.claude.com/docs/zh-CN/model-config.md#surface-coverage)。2063哪些托管设置到达 Desktop 会话取决于该会话运行的位置。模型限制(如 [`availableModels`](https://code.claude.com/docs/zh-CN/model-config#restrict-model-selection))在 Desktop 的 Claude Code 会话中的执行方式与在终端 CLI 中相同;请参阅[使用入口覆盖范围](https://code.claude.com/docs/zh-CN/model-config.md#surface-coverage)。

2050 2064 


2109>2123>

2110> 部署之前,请检查 `forceLoginOrgUUID` 值。如果该 ID 不是您组织的 ID,您组织中的人员将无法使用 Claude Desktop,除非他们同时属于具有该 ID 的组织。要恢复,请部署正确的 ID,并让他们重新启动 Claude Desktop。2124> 部署之前,请检查 `forceLoginOrgUUID` 值。如果该 ID 不是您组织的 ID,您组织中的人员将无法使用 Claude Desktop,除非他们同时属于具有该 ID 的组织。要恢复,请部署正确的 ID,并让他们重新启动 Claude Desktop。

2111 2125 

2112如果您在 Claude Code 的[托管设置](https://code.claude.com/docs/zh-CN/managed-settings.md)中设置 `forceLoginMethod` 和 `forceLoginOrgUUID`,并不会改变 Claude Desktop 的登录屏幕。2126如果您在 Claude Code 的[托管设置](https://code.claude.com/docs/zh-CN/managed-settings.md)中设置 `forceLoginMethod` 和 `forceLoginOrgUUID`,并不会改变 Claude Desktop 的登录屏幕。用户仍然可以使用自己的 Claude API 密钥或 [Claude Console 帐户](https://claude.com/docs/third-party/claude-desktop/claude-api#which-devices-offer-the-claude-api-account-sign-in)来使用 Claude Desktop,并以这种方式运行 Code 选项卡会话。

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 帐户。

2129 

2130部署之前,请检查以下两种情况:

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)。

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)。

2113 2134 

2114### 网络访问要求2135### 网络访问要求

2115 2136 

errors.md +162 −161

Details

5375 5375 

5376## 后台会话错误5376## 后台会话错误

5377 5377 

5378[后台会话](https://code.claude.com/docs/zh-CN/agent-view.md)在没有自己的交互式终端的情况下运行,因此需要终端的命令在那里的行为会有所不同。这些消息出现在后台会话的会话记录中、附加到后台会话的终端中、您分派的会话或 shell 中,或者对于下面的[worktree-guard 条目](#write-or-command-blocked-because-the-path-cannot-be-safely-resolved),出现在任何在 worktree 中隔离的会话或运行 worktree 隔离子代理中;当消息特定于一个使用入口时,其条目会说明这一点。5378[后台会话](https://code.claude.com/docs/zh-CN/agent-view.md)运行时没有属于自己的交互式终端,因此需要交互式终端的命令在其中的行为有所不同。这些消息会出现在后台会话的会话记录中、连接到后台会话的终端中、您从中分派会话的会话或 shell 中;对于下方的 [worktree 防护条目](#write-or-command-blocked-because-the-path-cannot-be-safely-resolved),还会出现在任何隔离在 worktree 中或正在运行 worktree 隔离子代理的会话中。如果某条消息只出现在某一个使用入口,其条目会加以说明。

5379 5379 

5380### 后台会话中拒绝的命令5380### 在后台会话中被拒绝的命令

5381 5381 

5382打开交互式对话框的命令在没有终端附加到后台会话时无法执行。`/install-github-app`、`/mcp` 设置列表和 MCP 服务器菜单中的身份验证操作会响应一条消息。对于 `/install-github-app` 和 `/mcp` 设置列表,该会话也在 [Agent 视图](https://code.claude.com/docs/zh-CN/agent-view.md)中的**需要输入**下显示,以便您可以找到它、附加并再次运行该命令。附加终端时,这些命令正常工作。5382在没有终端连接到后台会话时,会打开交互式对话框的命令无法打开对话框。`/install-github-app`、`/mcp` 设置列表以及 MCP 服务器菜单中的身份验证操作会以一条消息作为响应。对于 `/install-github-app` 和 `/mcp` 设置列表,该会话还会出现在 [agent view](https://code.claude.com/docs/zh-CN/agent-view.md) 的 **Needs input** 下,以便您找到它、连接并再次运行该命令。在有终端连接时,这些命令可正常工作。

5383 5383 

5384在 v2.1.216 之前,会话在拒绝 `/install-github-app` 或 `/mcp` 设置列表后不会在**需要输入**下显示。在 v2.1.213 到 v2.1.215 中,附加终端时命令仍然有效,拒绝消息告诉您附加并再次运行该命令。从 v2.1.208 到 v2.1.212,Claude Code 即使附加了终端也拒绝了它们,消息如 `Can't open MCP settings in a background session`;在这些版本上,从常规 `claude` 会话运行该命令,或升级。在 v2.1.208 之前,它们在后台会话内打开了对话框。在仅 v2.1.208 中,Claude Code 也拒绝了后台会话中的 `/model` 选择器,`/upgrade` 打印了升级 URL 而不是打开浏览器。5384在 v2.1.216 之前,`/install-github-app` 或 `/mcp` 设置列表被拒绝后,会话不会出现在 **Needs input** 下。在 v2.1.213 至 v2.1.215 中,这些命令在有终端连接时仍可正常工作,拒绝消息会提示您连接并再次运行该命令。从 v2.1.208 至 v2.1.212,即使有终端连接,Claude Code 也会拒绝这些命令,并显示类似 `Can't open MCP settings in a background session` 的消息;在这些版本上,请改为在常规 `claude` 会话中运行该命令,或进行升级。在 v2.1.208 之前,这些命令会在后台会话内打开其对话框。仅在 v2.1.208 中,Claude Code 还会在后台会话中拒绝 `/model` 选择器,并且 `/upgrade` 会打印升级 URL 而不是打开浏览器。

5385 5385 

5386措辞命名该命令。`/mcp` 设置列表报告:5386消息措辞中会指明具体命令。`/mcp` 设置列表会报告:

5387 5387 

5388```text theme={null}5388```text theme={null}

5389Can't open MCP settings while no terminal is attached to this background session. This session now shows "needs input" in agent view — open it and run /mcp to manage servers, or use `/mcp enable|disable|reconnect <server>` to steer without the panel.5389Can't open MCP settings while no terminal is attached to this background session. This session now shows "needs input" in agent view — open it and run /mcp to manage servers, or use `/mcp enable|disable|reconnect <server>` to steer without the panel.

5390```5390```

5391 5391 

5392**要做什么:**5392**解决方法:**

5393 5393 

5394* 从 Agent 视图附加到会话并再次运行该命令5394* 从 agent view 连接到该会话,然后再次运行该命令

5395* 或使用消息命名的形式,例如 `/mcp reconnect <server>`、`/mcp enable` 或 `/mcp disable`,这些不需要附加即可工作5395* 或者使用消息中指明的形式,例如 `/mcp reconnect <server>`、`/mcp enable` 或 `/mcp disable`,这些形式无需连接即可使用

5396 5396 

5397### 写入或命令被阻止,因为路径无法安全解析5397### Write or command blocked because the path cannot be safely resolved

5398 5398 

5399Claude 通过 [worktree 隔离保护](https://code.claude.com/docs/zh-CN/agent-view.md#how-file-edits-are-isolated)无法解析为一个可验证位置的拼写来寻址文件或工作目录。保护检查[任何在 worktree 中隔离的会话](https://code.claude.com/docs/zh-CN/worktrees.md#how-claude-code-enforces-isolation)中的写入和命令工作目录,交互式或后台,以及[worktree 隔离的子代理](https://code.claude.com/docs/zh-CN/worktrees.md#isolate-subagents-with-worktrees)中的写入和命令工作目录。它在检查操作不会到达共享检出之前解析符号链接,当解析失败时,它会阻止操作而不是让它落在那里。消息命名它拒绝的路径形式以及如何重试:5399Claude 使用了一种 [worktree 隔离防护](https://code.claude.com/docs/zh-CN/agent-view.md#how-file-edits-are-isolated)无法解析为单一可验证位置的写法来引用文件或工作目录。该防护会在[任何隔离在 worktree 中的会话](https://code.claude.com/docs/zh-CN/worktrees.md#how-claude-code-enforces-isolation)(无论是交互式还是后台会话)以及 [worktree 隔离的子代理](https://code.claude.com/docs/zh-CN/worktrees.md#isolate-subagents-with-worktrees)中检查写入操作和命令的工作目录。它会先解析符号链接,再检查该操作是否会触及共享检出;当解析失败时,它会阻止该操作,而不是任其落入共享检出。消息会指明它拒绝的路径形式以及如何重试:

5400 5400 

5401```text theme={null}5401```text theme={null}

5402This write was blocked because the path is spelled in a form that cannot be safely resolved (for example through a symlink storing a raw dot segment, a network-share or device-namespace shape, or an unreadable ancestor directory). If the file is inside the worktree /path/to/worktree, address it by its direct symlink-free path instead.5402This write was blocked because the path is spelled in a form that cannot be safely resolved (for example through a symlink storing a raw dot segment, a network-share or device-namespace shape, or an unreadable ancestor directory). If the file is inside the worktree /path/to/worktree, address it by its direct symlink-free path instead.

5403```5403```

5404 5404 

5405被阻止的命令为其工作目录报告相同的原因,并以 `re-run the command from its direct symlink-free path` 结尾。在 v2.1.217 之前,保护在不解析符号链接的情况下比较路径拼写,因此这些拼写未被阻止,通过符号链接路由的写入可能会落在共享检出中。5405被阻止的命令会针对其工作目录报告相同的原因,并以 `re-run the command from its direct symlink-free path` 结尾。在 v2.1.217 之前,该防护在比较路径写法时不解析符号链接,因此这些写法不会被阻止,经由符号链接路由的写入可能会落入共享检出。

5406 5406 

5407**要做什么:**5407**解决方法:**

5408 5408 

5409* 通常什么都不做:完整消息作为工具错误发送给 Claude,Claude 使用它命名的直接路径重试。对于被阻止的文件编辑,对话视图仅显示简短的 `Error editing file` 行;完整消息出现在您使用 `Ctrl+O` 打开的会话记录视图中。被阻止的命令在其命令输出中打印它。5409* 通常无需操作:完整消息会作为工具错误发送给 Claude,Claude 会使用消息中指明的直接路径进行重试。对于被阻止的文件编辑,对话视图只显示一行简短的 `Error editing file`;完整消息显示在会话记录视图中,您可以按 `Ctrl+O` 打开该视图。被阻止的命令会在其命令输出中打印该消息。

5410* 如果同一文件上的阻止重复出现,路径可能通过包含 `..` 的已提交符号链接运行,例如 `docs/current -> ../README.md`;要求 Claude 通过其真实路径而不是通过链接编辑目标文件5410* 如果同一文件上反复出现阻止,则该路径很可能经过一个已提交的、目标包含 `..` 的符号链接,例如 `docs/current -> ../README.md`;请让 Claude 通过目标文件的真实路径而不是通过该链接来编辑它

5411 5411 

5412### 写入或命令被阻止,因为路径命名网络位置5412### Write or command blocked because the path names a network location

5413 5413 

5414Claude 通过命名不在您机器上的驱动器、UNC 共享(如 `\\server\share\file`)或 `/net` 自动挂载路径的路径来寻址文件或工作目录,而会话的检出在本地磁盘上。相同的 [worktree 隔离保护](#write-or-command-blocked-because-the-path-cannot-be-safely-resolved)无法验证这样的路径保持在共享检出之外,因此它会阻止操作。在 worktree 中隔离会话不会解除阻止。消息命名要使用的路径形式:5414Claude 通过一个指向不在您机器上的驱动器的路径来引用文件或工作目录,例如 `\\server\share\file` 这样的 UNC 共享或 `/net` 自动挂载路径,而该会话的检出位于本地磁盘上。同一个 [worktree 隔离防护](#write-or-command-blocked-because-the-path-cannot-be-safely-resolved)无法验证此类路径不会进入共享检出,因此会阻止该操作。将会话隔离在 worktree 中并不能解除这一阻止。消息会指明应改用的路径形式:

5415 5415 

5416```text theme={null}5416```text theme={null}

5417This write was blocked because the path is network-shaped (a UNC share or /net automount spelling) while this session's checkout is local. Isolating cannot unblock it. If the file is genuinely inside the worktree /path/to/worktree, address it by its local, plainly-spelled path instead.5417This write was blocked because the path is network-shaped (a UNC share or /net automount spelling) while this session's checkout is local. Isolating cannot unblock it. If the file is genuinely inside the worktree /path/to/worktree, address it by its local, plainly-spelled path instead.

5418```5418```

5419 5419 

5420被阻止的命令为其工作目录报告相同的原因,并以 `re-run the command from its local, plainly-spelled path` 结尾。在 v2.1.217 之前,保护仅比较路径文本,因此通过 UNC 或 `/net` 路径寻址检出内的文件未被阻止。5420被阻止的命令会针对其工作目录报告相同的原因,并以 `re-run the command from its local, plainly-spelled path` 结尾。在 v2.1.217 之前,该防护只比较路径文本,因此通过 UNC 或 `/net` 路径引用检出内的文件不会被阻止。

5421 5421 

5422**要做什么:**5422**解决方法:**

5423 5423 

5424* 通常什么都不做:Claude 使用消息要求的本地拼写重试5424* 通常无需操作:Claude 会使用消息要求的本地写法进行重试

5425 5425 

5426### 命令被 worktree 隔离检查阻止5426### 命令被 worktree 隔离检查阻止

5427 5427 

5428Claude 在[在 worktree 中隔离的会话](https://code.claude.com/docs/zh-CN/worktrees.md#how-claude-code-enforces-isolation)中运行了 Bash、[PowerShell](https://code.claude.com/docs/zh-CN/tools-reference.md#powershell-tool) 或 [Monitor](https://code.claude.com/docs/zh-CN/tools-reference.md#monitor-tool) 命令,Claude Code 因以下原因之一拒绝了它:5428Claude 在[隔离在 worktree 中的会话](https://code.claude.com/docs/zh-CN/worktrees.md#how-claude-code-enforces-isolation)中运行了 Bash、[PowerShell](https://code.claude.com/docs/zh-CN/tools-reference.md#powershell-tool) 或 [Monitor](https://code.claude.com/docs/zh-CN/tools-reference.md#monitor-tool) 命令,而 Claude Code 出于以下原因之一拒绝了它:

5429 5429 

5430* 该命令将在主检出或另一个 worktree 中运行。消息会说明其工作目录 `resolved to the shared checkout` 或 `is in a different worktree`。5430* 该命令会在主检出或另一个 worktree 中运行。消息会说明其工作目录 `resolved to the shared checkout` 或 `is in a different worktree`。

5431* Bash 或 Monitor 命令将 git 指向主检出。5431* Bash 或 Monitor 命令将 git 指向了主检出。

5432* Claude Code 无法从 Bash 或 Monitor 命令的文本验证该命令运行的任何 git 都保留在 worktree 内。从不命名 git 的命令仍然可能因此原因被拒绝,因为展开变量间接寻址(如 `${!name}`)或运行 Bash 函数替换(如 `${ command; }`)会产生在运行时本身可能是命令的值。5432* Claude Code 无法从 Bash 或 Monitor 命令的文本中验证该命令运行的任何 git 都停留在 worktree 内。即使某条命令从未提及 git,也仍可能因此被拒绝,因为展开诸如 `${!name}` 的变量间接引用或运行诸如 `${ command; }` 的 Bash 函数替换会在运行时产生一个值,而这个值本身可能就是一条命令。

5433 5433 

5434消息会说 `is isolated in the worktree <path>, but this command`,后跟原因,例如 Claude Code 无法验证其文本的命令:5434消息会显示 `is isolated in the worktree <path>, but this command`,后面跟着原因,例如 Claude Code 无法验证其文本的命令:

5435 5435 

5436```text wrap theme={null}5436```text wrap theme={null}

5437This session is isolated in the worktree /path/to/worktree, but this command evaluates ${!x@P} arithmetically inside a construct too complex to verify, which can run a command hidden in a variable's value. Refusing to run it — a worktree-isolated session's git operations must target its own worktree. Split it into plain, separate commands and run them from /path/to/worktree.5437This session is isolated in the worktree /path/to/worktree, but this command evaluates ${!x@P} arithmetically inside a construct too complex to verify, which can run a command hidden in a variable's value. Refusing to run it — a worktree-isolated session's git operations must target its own worktree. Split it into plain, separate commands and run them from /path/to/worktree.

5438```5438```

5439 5439 

5440**要做什么:**5440**解决方法:**

5441 5441 

5442* **git 指向主检出,或命令文本无法验证**:什么都不用做。Claude 读取消息并按照其最后一句要求的方式重写命令。如果您要求的命令因其文本中的展开而持续被拒绝,请按字面拼写被标记的值,并从 worktree 内将 git 作为独立的纯命令运行5442* **git 指向主检出,或命令文本无法验证**:无需操作。Claude 会阅读该消息,并按照其最后一句的要求重写命令。如果您要求运行的命令因其文本中的某个展开而反复被拒绝,请以字面形式写出被标记的值,并在 worktree 内将 git 作为一条独立的简单命令运行

5443* 要有意对主检出采取行动,在会话外的终端中自己运行该命令5443* 如果确实要对主检出进行操作,请在会话之外的终端中自行运行该命令

5444 5444 

5445### 此会话没有保存的会话记录5445### This session has no saved transcript

5446 5446 

5447您附加到一个通过 `←` 或 `/background` [移至后台](https://code.claude.com/docs/zh-CN/agent-view.md#from-inside-a-session)的会话,该会话在运行自己的轮次之前就已停止。Claude Code 找不到您将其移出的那个对话,因此该会话没有可恢复的内容。消息以此会话的 `claude respawn` 命令结尾:5447您连接到了一个通过 `←` 或 `/background` [移至后台](https://code.claude.com/docs/zh-CN/agent-view.md#from-inside-a-session)、且在运行自己的任何一个轮次之前就已停止的会话。Claude Code 找不到您将其移出时所在的对话,因此该会话没有可恢复的内容。消息以该会话的 `claude respawn` 命令结尾:

5448 5448 

5449```text theme={null}5449```text theme={null}

5450This session has no saved transcript — it was stopped before its first response finished. If it was backgrounded from another conversation, that one is still intact; `claude respawn <id>` starts this one fresh.5450This session has no saved transcript — it was stopped before its first response finished. If it was backgrounded from another conversation, that one is still intact; `claude respawn <id>` starts this one fresh.

5451```5451```

5452 5452 

5453在 [Agent 视图](https://code.claude.com/docs/zh-CN/agent-view.md)中打开相同会话的行则会在列表下方显示 `Press enter again to restart this session fresh`,在该行上第二次按 `Enter` 会使用空对话重启会话。5453在 [agent view](https://code.claude.com/docs/zh-CN/agent-view.md) 中打开同一会话的行时,列表下方会改为显示 `Press enter again to restart this session fresh`,在该行上再次按 `Enter` 会以空对话重新启动该会话。

5454 5454 

5455**要做什么:**5455**解决方法:**

5456 5456 

5457* 要重新启动停止的会话,请使用消息中的 ID 运行 `claude respawn <id>`,或在 Agent 视图中的其行上按 `Enter` 两次5457* 要重新启动已停止的会话,请使用消息中的 ID 运行 `claude respawn <id>`,或在 agent view 中该会话的行上按两次 `Enter`

5458* 如果会话确实完成了回复,您仍然在 v2.1.214 之前的版本上看到此拒绝,`~/.claude/projects` 中的不可读文件夹可能会使会话记录扫描错过保存的对话;更新到 v2.1.214 或更高版本,它在扫描期间容忍不可读的文件夹5458* 如果该会话确实完成了回复,但您在 v2.1.214 之前的版本上仍看到此拒绝,则可能是 `~/.claude/projects` 中某个不可读的文件夹导致会话记录扫描遗漏了已保存的对话;请更新到 v2.1.214 或更高版本,这些版本在扫描期间会容忍不可读的文件夹

5459 5459 

5460### 此会话在另一个终端中运行5460### This session is running in another terminal

5461 5461 

5462您在 [Agent 视图](https://code.claude.com/docs/zh-CN/agent-view.md)中打开了停止的会话的行,其保存的对话已在此机器上的另一个实时 Claude Code 进程中打开,因此 Claude Code 拒绝启动将写入相同会话记录的第二个进程。您看到的消息取决于[什么持有对话](https://code.claude.com/docs/zh-CN/agent-view.md#opening-a-session-says-the-conversation-is-already-open):5462您在 [agent view](https://code.claude.com/docs/zh-CN/agent-view.md) 中打开了一个已停止会话的行,而其已保存的对话已在本机另一个正在运行的 Claude Code 进程中打开,因此 Claude Code 拒绝启动第二个会写入同一会话记录的进程。您看到哪条消息取决于[占用该对话的是什么](https://code.claude.com/docs/zh-CN/agent-view.md#opening-a-session-says-the-conversation-is-already-open):

5463 5463 

5464```text theme={null}5464```text theme={null}

5465Can't open — this session is running in another terminal5465Can't open — this session is running in another terminal

5466This conversation is already open in another running Claude session — use that one, or close it and try again5466This conversation is already open in another running Claude session — use that one, or close it and try again

5467```5467```

5468 5468 

5469* **`running in another terminal`**:终端持有对话,例如您使用 `claude --resume` 或 `/resume` 恢复它的终端。该行也显示 `Open in a terminal`。5469* **`running in another terminal`**:占用该对话的是后台会话以外的进程,例如 `claude -p` 运行,或者您通过 `claude --resume` 或 `/resume` 恢复了该对话的终端。该行还会显示 `Open in a terminal`。

5470* **`already open in another running Claude session`**:另一个非交互式 Claude Code 进程持有它,例如相同对话的[后台会话](https://code.claude.com/docs/zh-CN/agent-view.md#the-supervisor-process)进程尚未退出。5470* **`already open in another running Claude session`**:占用它的是另一个[后台会话](https://code.claude.com/docs/zh-CN/agent-view.md#the-supervisor-process)。

5471 5471 

5472**要做什么:**5472**解决方法:**

5473 5473 

5474* 在持有它的进程中继续对话,或退出该进程并再次打开该行5474* 对于 `running in another terminal`:在那个终端中继续,或者退出该进程或等待其结束,然后重试

5475* 对于 `already open in another running Claude session`:使用那个会话,或者将其停止后重试

5475 5476 

5476在 v2.1.248 之前,仅存在 `already open in another running Claude session` 拒绝:在终端中恢复的对话不计为打开,打开该行启动了第二个 Claude Code 进程写入相同的对话。5477在 v2.1.248 之前,只存在 `already open in another running Claude session` 这一种拒绝:在终端中恢复的对话不会被视为已打开,打开该行会启动第二个写入同一对话的 Claude Code 进程。

5477 5478 

5478### 此会话的保存对话不再在磁盘上5479### This session's saved conversation is no longer on disk

5479 5480 

5480您打开了一个[后台会话](https://code.claude.com/docs/zh-CN/agent-view.md),该会话在后台服务关闭时结束,[会话记录清理](https://code.claude.com/docs/zh-CN/settings-reference.md#cleanupperioddays)随后删除了其保存的对话,例如在机器关闭数周后。通常打开这样的行会[恢复其保存的对话](https://code.claude.com/docs/zh-CN/agent-view.md#sessions-show-as-failed-after-shutdown)。没有什么可恢复的,Claude Code 拒绝而不是在不询问的情况下重新运行会话的原始提示词:5481您打开了一个在后台服务关闭期间结束的[后台会话](https://code.claude.com/docs/zh-CN/agent-view.md),而此后[会话记录清理](https://code.claude.com/docs/zh-CN/settings-reference.md#cleanupperioddays)已删除了其保存的对话,例如在机器关机数周之后。打开此类行通常会[恢复其已保存的对话](https://code.claude.com/docs/zh-CN/agent-view.md#sessions-show-as-failed-after-shutdown)。由于没有任何可恢复的内容,Claude Code 会拒绝,而不是在未经询问的情况下重新运行该会话的原始提示词:

5481 5482 

5482```text theme={null}5483```text theme={null}

5483This session's saved conversation is no longer on disk (it ended while the background service was off, and old transcripts are cleaned up), so there is nothing to resume. `claude rm 7c5dcf5d` deletes the row; `claude respawn 7c5dcf5d` runs its original prompt again instead.5484This session's saved conversation is no longer on disk (it ended while the background service was off, and old transcripts are cleaned up), so there is nothing to resume. `claude rm 7c5dcf5d` deletes the row; `claude respawn 7c5dcf5d` runs its original prompt again instead.

5484```5485```

5485 5486 

5486`claude attach <id>` 打印此文本。在 Agent 视图中,页脚更短,以 `ctrl+x deletes the row` 结尾。5487`claude attach <id>` 会打印这段文本。在 agent view 中,页脚较短,并以 `ctrl+x deletes the row` 结尾。

5487 5488 

5488**要做什么:**5489**解决方法:**

5489 5490 

5490* 运行 `claude rm <id>` 删除该行。当[保留的情况](https://code.claude.com/docs/zh-CN/agent-view.md#what-deleting-a-session-removes)之一适用时,`claude rm` 保留该行和 worktree,并命名原因5491* 运行 `claude rm <id>` 删除该行。当适用某种[保留情形](https://code.claude.com/docs/zh-CN/agent-view.md#what-deleting-a-session-removes)时,`claude rm` 会改为保留该行和 worktree,并指明原因

5491* 要再次运行会话的原始提示词作为新对话,请运行 `claude respawn <id>`5492* 要将该会话的原始提示词作为全新对话再次运行,请运行 `claude respawn <id>`

5492 5493 

5493在 v2.1.248 之前,打开这样的行会重新运行会话的原始提示词,而不是拒绝,将数周前的任务拉回前台。5494在 v2.1.248 之前,打开此类行会重新运行该会话的原始提示词而不是拒绝,从而把一个几周前的任务重新拉回前台。

5494 5495 

5495### Worktree 有未推送到任何地方的提交5496### Worktree has commits that are not pushed anywhere

5496 5497 

5497您尝试删除一个[后台会话](https://code.claude.com/docs/zh-CN/agent-view.md#what-deleting-a-session-removes),其 worktree 持有 Claude Code 无法确认保存在其他地方的提交。Claude Code 保留 worktree 和会话行,而不是在未查看的情况下销毁提交。`claude rm` 命名分支和未推送的提交,并说明如何继续:5498您尝试删除一个[后台会话](https://code.claude.com/docs/zh-CN/agent-view.md#what-deleting-a-session-removes),而其 worktree 中包含 Claude Code 无法确认已保存在别处的提交。Claude Code 会保留该 worktree 和会话行,而不是在您未察看的情况下销毁这些提交。`claude rm` 会指明分支和未推送的提交,并说明如何继续:

5498 5499 

5499```text theme={null}5500```text theme={null}

5500kept 7c5dcf5d — its worktree is still at “/home/you/project/.claude/worktrees/fix-login”5501kept 7c5dcf5d — its worktree is still at “/home/you/project/.claude/worktrees/fix-login”


5502 push them and run 'claude rm 7c5dcf5d' again, or discard the worktree and its commits: claude rm 7c5dcf5d --discard-unpushed a1b2c3d000000000000000000000000000000000@0123456789abcdef0123456789abcdef5503 push them and run 'claude rm 7c5dcf5d' again, or discard the worktree and its commits: claude rm 7c5dcf5d --discard-unpushed a1b2c3d000000000000000000000000000000000@0123456789abcdef0123456789abcdef

5503```5504```

5504 5505 

5505当 Claude Code 无法总结提交时,详细行读取 `The worktree has unpushed commits`。在 [Agent 视图](https://code.claude.com/docs/zh-CN/agent-view.md)中,会话的行显示 `not deleted` 和相同的原因。5506当 Claude Code 无法汇总这些提交时,详情行会改为显示 `The worktree has unpushed commits`。在 [agent view](https://code.claude.com/docs/zh-CN/agent-view.md) 中,该会话的行会显示 `not deleted` 以及相同的原因。

5506 5507 

5507远程上的提交不会阻止删除。本地副本中您的 `origin` 远程的默认分支上的提交也不会,只要该分支在您的主检出中检出,即仓库目录本身而不是 worktree。5508远程上的提交不会阻止删除。您的 `origin` 远程默认分支的本地副本上的提交也不会阻止删除,前提是该分支已在您的主检出(即仓库目录本身,而非某个 worktree)中检出。

5508 5509 

5509**要做什么:**5510**解决方法:**

5510 5511 

5511* 要保留提交,推送 worktree 的分支,或将其合并到在主检出中检出的默认分支,然后再次删除会话5512* 要保留这些提交,请推送该 worktree 的分支,或将其合并到主检出中已检出的默认分支,然后再次删除该会话

5512* 要丢弃提交,运行消息打印的 `claude rm <id> --discard-unpushed` 命令,或在 Agent 视图中的会话行上再次按 `Ctrl+X` 两次。这会删除会话和 worktree 以及其分支、未推送的提交和任何未提交的更改。如果删除再次被拒绝,请按照新消息操作。5513* 要丢弃这些提交,请运行消息中打印的 `claude rm <id> --discard-unpushed` 命令,或在 agent view 中该会话的行上再次按两次 `Ctrl+X`。这会删除该会话和 worktree,连同其分支、未推送的提交以及所有未提交的更改。如果删除再次被拒绝,请按照新消息操作。

5513* 当消息说 worktree 也由另一个完成的会话记录时,再次删除不会丢弃它:推送提交,然后再次删除会话5514* 当消息说明该 worktree 还被另一个已结束的会话记录时,再次删除不会丢弃它:请推送这些提交,然后再次删除该会话

5514 5515 

5515在 v2.1.268 之前,`claude rm` 将提交摘要放在 `kept` 行本身上。当 `claude rm` 无法总结提交时,`kept` 行读取 `worktree has commits that are not pushed anywhere` 代替摘要。5516在 v2.1.268 之前,`claude rm` 会将提交摘要放在 `kept` 行本身。当 `claude rm` 无法汇总提交时,`kept` 行会以 `worktree has commits that are not pushed anywhere` 代替摘要。

5516 5517 

5517在 v2.1.260 之前,消息没有命名分支或提交,也没有丢弃途径。您仍然可以删除会话,这会丢失未提交的更改,但保留分支和提交。使用拒绝消息打印的路径运行 `git worktree remove --force --force <path>`,然后运行 `claude rm <id>`。对于已锁定的 worktree,Git 需要两次 `--force`。5518在 v2.1.260 之前,该消息不会指明分支或提交,也没有丢弃途径。您仍然可以删除该会话,这会丢失未提交的更改,但保留分支和提交。请使用拒绝消息中打印的路径运行 `git worktree remove --force --force <path>`,然后运行 `claude rm <id>`。对于已锁定的 worktree,Git 需要两次 `--force`。

5518 5519 

5519在 v2.1.248 之前,在主检出中检出的默认分支不计数:您已经合并到那里的分支仍然触发此拒绝,直到其提交到达远程。5520在 v2.1.248 之前,主检出中已检出的默认分支不算在内:即使某个分支已在那里合并,在其提交到达远程之前仍会触发此拒绝。

5520 5521 

5521### 终端主机进程已死亡5522### Terminal host process died

5522 5523 

5523每个[后台会话的](https://code.claude.com/docs/zh-CN/agent-view.md)终端在后台服务下的主机进程中运行,该进程在服务仍然持有其连接时死亡,因此无法到达会话。5524每个[后台会话](https://code.claude.com/docs/zh-CN/agent-view.md)的终端都运行在后台服务下的一个宿主进程中,而该进程在服务仍持有其连接时终止了,因此无法访问该会话。

5524 5525 

5525在 Linux 和 WSL 上,后台服务每隔几秒检查每个主机进程,当进程已退出但其与服务的连接从未关闭时标记会话失败,并在 [Agent 视图](https://code.claude.com/docs/zh-CN/agent-view.md#read-session-state)中的其行上显示原因:5526在 Linux 和 WSL 上,后台服务每隔几秒检查一次每个宿主进程,当进程已退出但其与服务的连接从未关闭时,会将该会话标记为失败,并在 [agent view](https://code.claude.com/docs/zh-CN/agent-view.md#read-session-state) 中该会话的行上显示原因:

5526 5527 

5527```text theme={null}5528```text theme={null}

5528terminal host process died — press Enter to restart5529terminal host process died — press Enter to restart

5529```5530```

5530 5531 

5531从 shell,`claude attach <id>` 重启已标记为死主机失败的会话,否则打印原因并退出:5532在 shell 中,`claude attach <id>` 会重新启动已因宿主终止而被标记为失败的会话,否则会打印原因并退出:

5532 5533 

5533```text theme={null}5534```text theme={null}

5534Couldn't attach to <id> — This session's terminal host process died (the conversation is saved) — run `claude attach <id>` again to restart it on a fresh host.5535Couldn't attach to <id> — This session's terminal host process died (the conversation is saved) — run `claude attach <id>` again to restart it on a fresh host.

5535```5536```

5536 5537 

5537对话无论如何都被保存。5538无论哪种情况,对话都已保存。

5538 5539 

5539运行 [shell 命令](https://code.claude.com/docs/zh-CN/agent-view.md#run-a-shell-command)的行显示 `terminal host process died — its output is gone; the command was not run again`,`claude attach` 打印 `This command's terminal host process died — its output is gone and the command was not run again`。Claude Code 从不为您重新运行该命令。5540运行 [shell 命令](https://code.claude.com/docs/zh-CN/agent-view.md#run-a-shell-command)的行则会显示 `terminal host process died — its output is gone; the command was not run again`,而 `claude attach` 会打印 `This command's terminal host process died — its output is gone and the command was not run again`。Claude Code 从不会替您重新运行该命令。

5540 5541 

5541**要做什么:**5542**解决方法:**

5542 5543 

5543* 在 Agent 视图中,在失败的行上按 `Enter`;会话在新的主机进程上重启,对话恢复5544* 在 agent view 中,在失败的行上按 `Enter`;会话会在一个新的宿主进程上重新启动,对话随之恢复

5544* 从 shell,再次运行 `claude attach <id>`。Claude Code 打印 `Session <id>'s terminal host died — restarting it on a fresh one…` 并重新打开会话5545* 在 shell 中,再次运行 `claude attach <id>`。Claude Code 会打印 `Session <id>'s terminal host died — restarting it on a fresh one…` 并重新打开该会话

5545* 您无法以这种方式重启 shell 命令行;再次分派命令以重新运行它5546* 无法以这种方式重新启动 shell 命令行;请再次分派该命令以重新运行它

5546 5547 

5547在 v2.1.247 之前,死主机进程可能通过后台服务运行的每个活跃性检查,因此打开会话无限期地显示 `opening… · esc to cancel`,`claude attach <id>` 等待而不报告错误。5548在 v2.1.247 之前,已终止的宿主进程可能会通过后台服务运行的所有存活检查,因此打开该会话时会无限期显示 `opening… · esc to cancel`,而 `claude attach <id>` 会一直等待而不报告错误。

5548 5549 

5549### 会话没有响应5550### Session isn't responding

5550 5551 

5551您打开了一个[后台会话](https://code.claude.com/docs/zh-CN/agent-view.md),后台服务接受了打开,但大约十秒钟内没有输出到达,因此 Claude Code 得出结论,中继会话终端的进程无法传递输出,并结束尝试而不是等待。5552您打开了一个[后台会话](https://code.claude.com/docs/zh-CN/agent-view.md),后台服务接受了打开请求,但大约十秒内都没有输出到达,因此 Claude Code 判定负责转发该会话终端的进程无法传递输出,并结束此次尝试而不是继续等待。

5552 5553 

5553在 Agent 视图中,Claude Code 在页脚中提供重启:5554在 agent view 中,Claude Code 会在页脚中提供重新启动选项:

5554 5555 

5555```text theme={null}5556```text theme={null}

5556Press enter again to restart this session — it isn't responding (its conversation is saved and resumes).5557Press enter again to restart this session — it isn't responding (its conversation is saved and resumes).

5557```5558```

5558 5559 

5559从 shell,`claude attach <id>` 打印原因并退出:5560在 shell 中,`claude attach <id>` 会打印原因并退出:

5560 5561 

5561```text theme={null}5562```text theme={null}

5562Couldn't attach to <id> — Session isn't responding — `claude stop <id>`, then `claude attach <id>` restarts it (the conversation is saved).5563Couldn't attach to <id> — Session isn't responding — `claude stop <id>`, then `claude attach <id>` restarts it (the conversation is saved).

5563```5564```

5564 5565 

5565Claude Code 从不为您重启运行 [shell 命令](https://code.claude.com/docs/zh-CN/agent-view.md#run-a-shell-command)的行,因为重启会再次运行该命令。5566Claude Code 从不会替您重新启动运行 [shell 命令](https://code.claude.com/docs/zh-CN/agent-view.md#run-a-shell-command)的行,因为重新启动会再次运行该命令。

5566 5567 

5567**要做什么:**5568**解决方法:**

5568 5569 

5569* 在 Agent 视图中,在同一行上再次按 `Enter`。Claude Code 停止无响应的进程并重启会话,对话恢复。没有第二次按下就不会停止任何东西5570* 在 agent view 中,再次在同一行上按 `Enter`。Claude Code 会停止无响应的进程并重新启动会话,对话随之恢复。没有第二次按键,任何内容都不会被停止

5570* 从 shell,运行 `claude stop <id>`,然后 `claude attach <id>`5571* 在 shell 中,运行 `claude stop <id>`,然后运行 `claude attach <id>`

5571* 对于 shell 命令行,在 Agent 视图中按 `Ctrl+X` 或运行 `claude stop <id>` 停止它;再次分派命令以重新运行它5572* 对于 shell 命令行,在 agent view 中按 `Ctrl+X` 或运行 `claude stop <id>` 将其停止;再次分派该命令以重新运行它

5572 5573 

5573### 会话在 respawn 进行中时被停止5574### Session was stopped while the respawn was in flight

5574 5575 

5575您打开了一个[后台会话](https://code.claude.com/docs/zh-CN/agent-view.md),其进程未运行,当 Claude Code 重启它时,另一个 Claude Code 进程停止了它,例如在另一个终端中 `claude stop`。Claude Code 保持会话停止:5576您打开了一个进程未在运行的[后台会话](https://code.claude.com/docs/zh-CN/agent-view.md),而在 Claude Code 重新启动它的过程中,另一个 Claude Code 进程停止了它,例如在另一个终端中运行的 `claude stop`。Claude Code 会让该会话保持停止状态:

5576 5577 

5577```text theme={null}5578```text theme={null}

5578Session <id> was stopped while the respawn was in flight5579Session <id> was stopped while the respawn was in flight

5579```5580```

5580 5581 

5581打开您刚刚分派的会话,当其进程仍在启动时,会改为等待进程。在 v2.1.246 之前,在那一刻打开它可能会停止它并显示此消息。5582打开一个刚分派、其进程仍在启动中的会话时,会改为等待该进程。在 v2.1.246 之前,在那个时刻打开它可能会将其停止并显示此消息。

5582 5583 

5583**要做什么:**5584**解决方法:**

5584 5585 

5585* 如果您没有停止会话,在 Agent 视图中再次打开其行或运行 `claude respawn <id>` 重启它5586* 如果不是您停止的该会话,请在 agent view 中再次打开其行,或运行 `claude respawn <id>` 来重新启动它

5586* 如果您自己停止了它,没有什么剩下要做的:会话保持停止5587* 如果是您自己停止的,则无需再做任何操作:该会话会保持停止状态

5587 5588 

5588### 会话 Agent 不再可用5589### Session agent no longer available

5589 5590 

5590您恢复了一个正在运行[自定义 Agent](https://code.claude.com/docs/zh-CN/sub-agents.md#invoke-subagents-explicitly) 的会话,该会话使用 `--agent` 或 `agent` 设置启动,Claude Code 没有找到具有该名称的 Agent。它首先搜索会话的原始目录(当您已[信任该工作区](https://code.claude.com/docs/zh-CN/permissions.md#project-allow-rules-and-workspace-trust)时),然后搜索您恢复的目录。会话仍然恢复,但使用默认工具,因此 Agent 的工具限制不再适用:5591您恢复了一个正在运行[自定义 Agent](https://code.claude.com/docs/zh-CN/sub-agents.md#invoke-subagents-explicitly)(通过 `--agent` 或 `agent` 设置启动)的会话,而 Claude Code 找不到该名称的 Agent。它会先搜索该会话的原始目录(前提是您已[信任该工作区](https://code.claude.com/docs/zh-CN/permissions.md#project-allow-rules-and-workspace-trust)),然后搜索您从中恢复的目录。该会话仍会恢复,但使用默认工具,因此该 Agent 的工具限制不再适用:

5591 5592 

5592```text theme={null}5593```text theme={null}

5593This session was running agent 'code-reviewer', which is no longer available (no agent by that name in /home/you/project). Continuing with the default tools and system prompt — the agent's tool restrictions no longer apply. To restore it, re-create the agent, or resume with an explicit --agent <name>.5594This session was running agent 'code-reviewer', which is no longer available (no agent by that name in /home/you/project). Continuing with the default tools and system prompt — the agent's tool restrictions no longer apply. To restore it, re-create the agent, or resume with an explicit --agent <name>.

5594```5595```

5595 5596 

5596警告仅命名 Claude Code 搜索的目录,它出现在恢复的对话中,无论您唤醒[后台会话](https://code.claude.com/docs/zh-CN/agent-view.md)、运行 `/resume` 或 `claude --resume`,还是在[非交互模式](https://code.claude.com/docs/zh-CN/headless.md)中恢复,在非交互模式中它也会发送到 stderr。使用 `--input-format stream-json` 的会话不显示它,因为 Agent SDK 在启动后提供 Agent。5597该警告只会列出 Claude Code 搜索过的目录,无论您是唤醒[后台会话](https://code.claude.com/docs/zh-CN/agent-view.md)、运行 `/resume` 或 `claude --resume`,还是在[非交互模式](https://code.claude.com/docs/zh-CN/headless.md)下恢复,它都会出现在恢复后的对话中;在非交互模式下,它还会输出到 stderr。使用 `--input-format stream-json` 的会话不会显示它,因为 Agent SDK 在启动后才提供 Agent。

5597 5598 

5598Claude Code 不会将回退保存到会话,因此警告在每次恢复时重复,直到您采取行动。内置 `claude` Agent 不触发警告,因为回退到默认工具集对它没有改变。在 v2.1.216 之前,Claude Code 无声地继续作为默认 Agent,查找仅覆盖您恢复的目录,因此项目范围的 Agent 在从另一个目录恢复时丢失。5599Claude Code 不会将回退结果保存到会话中,因此在您采取行动之前,每次恢复时都会重复显示该警告。内置的 `claude` Agent 不会触发该警告,因为回退到默认工具集对它来说没有任何变化。在 v2.1.216 之前,Claude Code 会静默地以默认 Agent 继续,并且查找只覆盖您从中恢复的目录,因此从其他目录进行任何恢复时都会丢失项目范围的 Agent。

5599 5600 

5600**要做什么:**5601**解决方法:**

5601 5602 

5602* 在会话的项目中的 `.claude/agents/<name>.md` 或个人 Agent 的 `~/.claude/agents/<name>.md` 重新创建 Agent 文件,然后再次恢复5603* 在该会话的项目中的 `.claude/agents/<name>.md` 重新创建 Agent 文件,或者对于个人 Agent,在 `~/.claude/agents/<name>.md` 重新创建,然后再次恢复

5603* 或使用 `--agent <name>` 恢复,命名确实存在的 Agent,以改为作为该 Agent 运行会话5604* 或者使用 `--agent <name>` 恢复,指定一个确实存在的 Agent,以该 Agent 的身份运行会话

5604* 如果 Agent 是项目范围的,您还没有信任会话的原始目录,在那里运行一次 Claude Code,接受信任对话框,然后再次恢复5605* 如果该 Agent 属于项目范围,而您尚未信任该会话的原始目录,请在那里运行一次 Claude Code,接受信任对话框,然后再次恢复

5605 5606 

5606### 此会话在其下一次 /loop 唤醒到期后才重启5607### This session restarted after its next /loop wakeup was due

5607 5608 

5608[后台会话](https://code.claude.com/docs/zh-CN/agent-view.md)中的[自定节奏 `/loop`](https://code.claude.com/docs/zh-CN/scheduled-tasks#let-claude-choose-the-interval) 已停止。会话的进程在循环等待下一次唤醒时结束,而该唤醒在会话的[下一个进程](https://code.claude.com/docs/zh-CN/agent-view.md#the-supervisor-process)启动之前就已到期。错过的唤醒不会延迟触发。通知会说明会话重启时该唤醒已逾期多久:5609[后台会话](https://code.claude.com/docs/zh-CN/agent-view.md)中一个[自定节奏的 `/loop`](https://code.claude.com/docs/zh-CN/scheduled-tasks#let-claude-choose-the-interval) 已停止。该会话的进程在循环等待下一次唤醒时结束了,而那次唤醒在该会话的[下一个进程](https://code.claude.com/docs/zh-CN/agent-view.md#the-supervisor-process)启动之前就已到期。错过的唤醒不会延后触发。通知会说明会话重新启动时该唤醒已逾期多久:

5609 5610 

5610```text theme={null}5611```text theme={null}

5611This session restarted 12m after its next /loop wakeup was due, so that wakeup will not fire. The loop stays stopped until Claude schedules it again: reply to continue it.5612This session restarted 12m after its next /loop wakeup was due, so that wakeup will not fire. The loop stays stopped until Claude schedules it again: reply to continue it.

5612```5613```

5613 5614 

5614在 v2.1.295 之前,循环在这种情况下会停止且不显示通知。5615在 v2.1.295 之前,在这种情况下循环会停止,且不会显示通知。

5615 5616 

5616**要做什么:**5617**解决方法:**

5617 5618 

5618* 要继续循环,请[回复该会话](https://code.claude.com/docs/zh-CN/agent-view.md#peek-and-reply)并说明这一点,例如 `keep the loop running`。Claude 会连同您的回复一起读取通知,并可以安排下一次唤醒5619* 要继续循环,请[回复该会话](https://code.claude.com/docs/zh-CN/agent-view.md#peek-and-reply)并说明这一点,例如 `keep the loop running`。Claude 会连同您的回复一起阅读该通知,并可以安排下一次唤醒

5619* 如果您已不再需要该循环,则无需任何操作。它已经停止5620* 如果您不再需要该循环,则无需操作。它已经停止了

5620 5621 

5621### No LLM gateway: a gateway set in your shell isn't passed to a session opened from another folder5622### No LLM gateway: a gateway set in your shell isn't passed to a session opened from another folder

5622 5623 

5623显示此消息的[后台会话](https://code.claude.com/docs/zh-CN/agent-view.md)没有使用您的 [LLM 网关](https://code.claude.com/docs/zh-CN/llm-gateway):它没有获得网关的地址,因此其请求会失败。该消息出现在对话中原本 Claude 回复的位置,并填入您的会话 ID 和文件夹:5624显示此消息的[后台会话](https://code.claude.com/docs/zh-CN/agent-view.md)没有使用您的 [LLM 网关](https://code.claude.com/docs/zh-CN/llm-gateway):它没有获得网关的地址,因此其请求会失败。该消息会出现在对话中 Claude 回复的位置,并填入您会话的 ID 和文件夹:

5624 5625 

5625```text wrap theme={null}5626```text wrap theme={null}

5626No LLM gateway: a gateway set in your shell isn't passed to a session opened from another folder. To fix, run `claude respawn abc12345` from ~/project in another terminal where your gateway is set, or set ANTHROPIC_BASE_URL and its API key or token in a settings file's env block.5627No LLM gateway: a gateway set in your shell isn't passed to a session opened from another folder. To fix, run `claude respawn abc12345` from ~/project in another terminal where your gateway is set, or set ANTHROPIC_BASE_URL and its API key or token in a settings file's env block.

5627```5628```

5628 5629 

5629当您附加到该会话时,其输入框下方的通知会显示简短形式 `No LLM gateway: opened from another folder · respawn from ~/project`。5630当您连接到该会话时,其提示符下方的通知会显示简短形式 `No LLM gateway: opened from another folder · respawn from ~/project`。

5630 5631 

5631您在 `ANTHROPIC_BASE_URL` 设置为您的网关时,从消息所指文件夹以外的文件夹分派、唤醒或重启了该会话。有关在 shell 中导出的网关确实能到达后台会话的情况,请参阅 [LLM 网关](https://code.claude.com/docs/zh-CN/agent-view.md#llm-gateway)。5632您在 `ANTHROPIC_BASE_URL` 设置为您的网关时,从消息所指文件夹以外的文件夹分派、唤醒或重新启动了该会话。关于 shell 中导出的网关确实会传递到后台会话的情形,请参阅 [LLM 网关](https://code.claude.com/docs/zh-CN/agent-view.md#llm-gateway)。

5632 5633 

5633**要做什么:**5634**解决方法:**

5634 5635 

5635* **您在一个由其设置指定网关的项目中使用了 Agent 视图**:将 `ANTHROPIC_BASE_URL` 及其 API 密钥或令牌放入[设置文件的 `env` 块](https://code.claude.com/docs/zh-CN/llm-gateway-connect#set-in-a-settings-file)。请使用 `~/.claude/settings.json`,或会话自身项目中的 `.claude/settings.local.json`,重新启动的会话会读取这两者。然后在 shell 中从任意文件夹运行 `claude respawn <id>`。5636* **您在一个其设置中设定了网关的项目中使用了 agent view**:将 `ANTHROPIC_BASE_URL` 及其 API 密钥或令牌放入[设置文件的 `env` 块](https://code.claude.com/docs/zh-CN/llm-gateway-connect#set-in-a-settings-file)中。使用 `~/.claude/settings.json`,或该会话自身项目中的 `.claude/settings.local.json`,重新启动的会话会读取这两者。然后在 shell 中从任意文件夹运行 `claude respawn <id>`。

5636* **您在终端中导出了网关**:在已导出网关变量的终端中,`cd` 到消息所指的文件夹,然后运行消息中的 `claude respawn <id>` 命令。会话会从其保存的对话重新启动。5637* **您在终端中导出了网关**:在已导出网关变量的终端中,`cd` 到消息所指的文件夹,并运行消息中的 `claude respawn <id>` 命令。该会话会从其已保存的对话重新启动。

5637 * 只有当 [supervisor](https://code.claude.com/docs/zh-CN/agent-view.md#the-supervisor-process) 本身是从导出了相同网关的 shell 启动时,网关才会到达该会话。如果不是,请按照 [Dispatch fails with `Could not resolve authentication method`](https://code.claude.com/docs/zh-CN/agent-view#dispatch-fails-with-could-not-resolve-authentication-method) 中的说明从该终端重启 supervisor,然后再次运行 respawn 命令。5638 * 只有当 [supervisor](https://code.claude.com/docs/zh-CN/agent-view.md#the-supervisor-process) 本身是从导出了相同网关的 shell 启动时,网关才会传递到该会话。如果 supervisor 不是这样启动的,请按照 [Dispatch fails with `Could not resolve authentication method`](https://code.claude.com/docs/zh-CN/agent-view#dispatch-fails-with-could-not-resolve-authentication-method) 中的说明,从该终端重新启动它,然后再次运行 respawn 命令。

5638 5639 

5639在 v2.1.302 之前,处于这种情况的后台会话会改为显示登录错误,例如 [`Not logged in · Please run /login`](#not-logged-in),且不会指出文件夹。5640在 v2.1.302 之前,处于这种情况的后台会话会改为显示登录错误,例如 [`Not logged in · Please run /login`](#not-logged-in),且不会指明文件夹。

5640 5641 

5641### CLAUDE\_CODE\_PROCESS\_WRAPPER 启动器错误5642### CLAUDE\_CODE\_PROCESS\_WRAPPER 启动器错误

5642 5643 

5643[`CLAUDE_CODE_PROCESS_WRAPPER`](https://code.claude.com/docs/zh-CN/corporate-launcher) 已设置,其值无法使用,因此 Claude Code 拒绝启动受影响的进程,而不是在没有启动器的情况下运行它。配置问题报告为以变量名开头并说明原因的消息,例如:5644已设置 [`CLAUDE_CODE_PROCESS_WRAPPER`](https://code.claude.com/docs/zh-CN/corporate-launcher),但其值无法使用,因此 Claude Code 拒绝启动受影响的进程,而不是在没有启动器的情况下运行它。配置问题会以一条以该变量名开头并说明原因的消息报告,例如:

5644 5645 

5645```text theme={null}5646```text theme={null}

5646CLAUDE_CODE_PROCESS_WRAPPER: launcher `/opt/corp/launcher` is not an executable regular file5647CLAUDE_CODE_PROCESS_WRAPPER: launcher `/opt/corp/launcher` is not an executable regular file

5647```5648```

5648 5649 

5649启动但在用 Claude Code 替换自己之前退出的启动器会使其启动的会话失败,会话在 Agent 视图中的行报告启动器 `must exec, not daemonize`,后跟启动器打印的任何内容。因启动器而无法启动或到达后台服务的会话会将启动器问题作为 `Couldn't reach the background service (...)` 内的原因报告。5650如果启动器启动后退出,却没有将自身替换为 Claude Code,则它正在启动的会话会失败,agent view 中该会话的行会报告启动器 `must exec, not daemonize`,后面跟着启动器打印的所有内容。因启动器而无法启动或无法连接后台服务的会话,会在 `Couldn't reach the background service (...)` 中将启动器问题作为原因报告。

5650 5651 

5651**要做什么:**5652**解决方法:**

5652 5653 

5653* 将变量设置为以调用 `exec "$@"` 结尾的可执行文件的绝对路径。有关完整合同,请参阅[启动器合同](https://code.claude.com/docs/zh-CN/corporate-launcher.md#the-launcher-contract)5654* 将该变量设置为一个以调用 `exec "$@"` 结束的可执行文件的绝对路径。有关完整约定,请参阅[启动器约定](https://code.claude.com/docs/zh-CN/corporate-launcher.md#the-launcher-contract)

5654* 检查 `/status`,它在其 Self-exec 条目中显示解析的启动命令,并在运行的后台服务不匹配时警告,或从 shell 运行 `claude daemon status`5655* 检查 `/status`,它会在其 Self-exec 条目中显示解析后的启动命令,并在正在运行的后台服务与之不匹配时发出警告;或者在 shell 中运行 `claude daemon status`

5655* 在[设置](https://code.claude.com/docs/zh-CN/corporate-launcher.md#set-up-the-launcher)的 `env` 块中修复值后,使用 `claude daemon stop --any` 重启后台服务,以便下一次分派启动一个包装的后台服务5656* 在[设置](https://code.claude.com/docs/zh-CN/corporate-launcher.md#set-up-the-launcher)的 `env` 块中修正该值后,使用 `claude daemon stop --any` 重新启动后台服务,以便下一次分派启动一个经过包装的服务

5656 5657 

5657### 启动后台会话时 EUNKNOWN5658### 启动后台会话时出现 EUNKNOWN

5658 5659 

5659Windows 拒绝使用没有标准名称的错误代码启动程序,因此失败显示为 `EUNKNOWN`。通常的触发器是软件限制策略,例如组策略或 AppLocker,阻止启动的程序。当您使用 `/background` 或 `claude --bg` 启动[后台会话](https://code.claude.com/docs/zh-CN/agent-view.md)时,错误出现:5660Windows 拒绝启动某个程序,并返回了一个没有标准名称的错误码,因此该失败显示为 `EUNKNOWN`。常见的诱因是软件限制策略(例如组策略或 AppLocker)阻止了正在启动的程序。当您使用 `/background` 或 `claude --bg` 启动[后台会话](https://code.claude.com/docs/zh-CN/agent-view.md)时会出现该错误:

5660 5661 

5661```text theme={null}5662```text theme={null}

5662Couldn't reach the background service (spawn background service: EUNKNOWN: unknown error, uv_spawn) — run 'claude daemon status'5663Couldn't reach the background service (spawn background service: EUNKNOWN: unknown error, uv_spawn) — run 'claude daemon status'

5663```5664```

5664 5665 

5665在某些帐户上,消息说 `daemon` 代替 `background service`。5666在某些账户上,该消息会用 `daemon` 代替 `background service`。

5666 5667 

5667在 npm 安装上,在 `npm install -g @anthropic-ai/claude-code` 替换二进制文件时出现的 `EUNKNOWN` 与[重新安装期间的 `EACCES`](#eacces-when-starting-a-background-session) 有相同的原因,并在您在安装完成后重试时清除。5668在 npm 安装中,如果 `EUNKNOWN` 出现在 `npm install -g @anthropic-ai/claude-code` 正在替换二进制文件期间,其原因与[重新安装期间的 `EACCES`](#eacces-when-starting-a-background-session) 相同,待安装完成后重试即可消除。

5668 5669 

5669Claude Code 通过 PowerShell 启动后台服务,以便服务在关闭终端后存活,在安装时使用 PowerShell 7,否则使用 Windows PowerShell 5.1。当两个 PowerShell 都无法运行时,Claude Code 直接启动服务,因此仅阻止 PowerShell 的策略不会导致此错误。5670Claude Code 通过 PowerShell 启动后台服务,以便在关闭终端后服务仍能继续运行:如果已安装 PowerShell 7,则使用 PowerShell 7,否则使用 Windows PowerShell 5.1。当两种 PowerShell 都无法运行时,Claude Code 会改为直接启动服务,因此仅阻止 PowerShell 的策略不会导致此错误。

5670 5671 

5671在 v2.1.212 之前,Claude Code 仅使用 Windows PowerShell 5.1 启动服务,因此任何组策略阻止 PowerShell 5.1 的机器失败,出现 `Couldn't start the session — EUNKNOWN: unknown error, uv_spawn`,即使安装了 PowerShell 7。5672在 v2.1.212 之前,Claude Code 只使用 Windows PowerShell 5.1 来启动服务,因此任何组策略阻止了 PowerShell 5.1 的机器都会失败并显示 `Couldn't start the session — EUNKNOWN: unknown error, uv_spawn`,即使已安装 PowerShell 7 也是如此。

5672 5673 

5673**要做什么:**5674**解决方法:**

5674 5675 

5675* 如果消息读取 `Couldn't start the session`,升级到 v2.1.212 或更高版本。在早期版本上,您也可以在单独的终端中首先运行 `claude daemon run`,然后再次启动后台会话。该命令在终端的前台运行后台服务,因此服务仅在该终端保持打开时持续。5676* 如果消息显示 `Couldn't start the session`,请升级到 v2.1.212 或更高版本。在更早的版本上,您也可以先在单独的终端中运行 `claude daemon run`,然后再次启动后台会话。该命令会在终端前台运行后台服务,因此服务只在该终端保持打开期间持续运行。

5676* 如果 npm 安装正在替换二进制文件,等待它完成,然后再次启动后台会话5677* 如果当时有 npm 安装正在替换二进制文件,请等待其完成,然后再次启动后台会话

5677* 如果错误在 v2.1.212 或更高版本上出现,而没有 npm 安装运行,请向您的 Windows 管理员确认是否有限制策略阻止了 Claude Code 可执行文件5678* 如果在 v2.1.212 或更高版本上、没有 npm 安装正在运行时出现该错误,请向您的 Windows 管理员确认是否有限制策略阻止了 Claude Code 可执行文件

5678* 如果关闭终端时后台服务停止,Claude Code 在没有 PowerShell 的情况下启动了它。安装 PowerShell 7,或要求您的管理员解除对 PowerShell 的阻止,以便服务可以超越终端。5679* 如果关闭终端时后台服务随之停止,说明 Claude Code 是在不使用 PowerShell 的情况下启动它的。请安装 PowerShell 7,或请管理员解除对 PowerShell 的阻止,以便服务能够在终端关闭后继续运行。

5679 5680 

5680### 启动后台会话时 EACCES5681### 启动后台会话时出现 EACCES

5681 5682 

5682Claude Code 无法运行其自己的二进制文件来启动[后台服务](https://code.claude.com/docs/zh-CN/agent-view.md#the-supervisor-process),该服务托管后台会话。在 npm 安装上,这通常意味着 `npm install -g @anthropic-ai/claude-code` 在那一刻替换二进制文件,无论您运行它还是[自动更新程序](https://code.claude.com/docs/zh-CN/setup.md#auto-updates)运行。当您从 [Agent 视图](https://code.claude.com/docs/zh-CN/agent-view.md)打开会话时,错误出现:5683Claude Code 无法运行自身的二进制文件来启动承载后台会话的[后台服务](https://code.claude.com/docs/zh-CN/agent-view.md#the-supervisor-process)。在 npm 安装中,这通常意味着 `npm install -g @anthropic-ai/claude-code` 当时正在替换该二进制文件,无论是您运行的还是[自动更新程序](https://code.claude.com/docs/zh-CN/setup.md#auto-updates)运行的。当您从 [agent view](https://code.claude.com/docs/zh-CN/agent-view.md) 打开会话时会出现该错误:

5683 5684 

5684```text theme={null}5685```text theme={null}

5685Couldn't start the background service — spawn background service: EACCES: permission denied, posix_spawn '/usr/local/lib/node_modules/@anthropic-ai/claude-code/bin/claude'5686Couldn't start the background service — spawn background service: EACCES: permission denied, posix_spawn '/usr/local/lib/node_modules/@anthropic-ai/claude-code/bin/claude'

5686```5687```

5687 5688 

5688当您使用 `/background` 或 `claude --bg` 启动会话时,相同的原因出现在 `Couldn't reach the background service (...)` 内。在相同的重新安装窗口期间,错误可能命名另一个代码,例如 `ENOENT` 或 `ENOEXEC`,或在 Windows 上 `EUNKNOWN` 或 `EPERM`;跨重试持续的 `EUNKNOWN` 有[不同的原因](#eunknown-when-starting-a-background-session)。5689当您使用 `/background` 或 `claude --bg` 启动会话时,相同的原因会出现在 `Couldn't reach the background service (...)` 中。在同一重新安装窗口期间,错误也可能显示其他错误码,例如 `ENOENT` 或 `ENOEXEC`,在 Windows 上则可能是 `EUNKNOWN` 或 `EPERM`;重试后仍持续出现的 `EUNKNOWN` 有[不同的原因](#eunknown-when-starting-a-background-session)。

5689 5690 

5690在 npm 安装上,Claude Code 等待重新安装完成并自动重试:最多十秒,以及在 npm 安装 Claude Code 在机器上仍然可见运行时最多两分钟,这涵盖了另一个 Claude Code 进程下载更新。当安装超过该等待时,失败命名更新而不是裸错误代码:5691在 npm 安装中,Claude Code 会等待重新安装完成并自行重试:最多等待十秒;若机器上明显仍有 Claude Code 的 npm 安装在运行,则最多等待两分钟,这涵盖了另一个 Claude Code 进程正在下载更新的情形。当安装时间超过该等待时长时,失败消息会指明更新,而不只是显示错误码:

5691 5692 

5692```text theme={null}5693```text theme={null}

5693Claude Code is being updated by npm on this machine (still not runnable after 2 min, EACCES) — try again when the update finishes5694Claude Code is being updated by npm on this machine (still not runnable after 2 min, EACCES) — try again when the update finishes

5694```5695```

5695 5696 

5696在 v2.1.257 之前,等待在每种情况下都在十秒处停止,因此此错误在另一个 Claude Code 进程仍在下载更新时出现。在 v2.1.246 之前,Claude Code 立即失败,没有等待。5697在 v2.1.257 之前,等待在任何情况下都会在十秒时停止,因此在另一个 Claude Code 进程仍在下载更新时会出现此错误。在 v2.1.246 之前,Claude Code 会立即失败,不会等待。

5697 5698 

5698**要做什么:**5699**解决方法:**

5699 5700 

5700* 等待几秒钟,然后打开会话或再次分派。当消息说 Claude Code 正在更新时,在更新完成后重试。5701* 等待几秒钟,然后再次打开会话或分派。当消息说明 Claude Code 正在更新时,请在更新完成后重试。

5701* 如果错误在没有 npm 安装运行时持续,您的用户无法运行已安装的二进制文件。检查其权限及其目录的权限,或重新安装 Claude Code。5702* 如果在没有 npm 安装运行时错误仍然存在,则说明您的用户无法运行已安装的二进制文件。请检查该文件及其所在目录的权限,或重新安装 Claude Code。

5702 5703 

5703### 后台服务在变得可达之前退出5704### 后台服务在可访问之前退出

5704 5705 

5705Claude Code 作为[后台服务](https://code.claude.com/docs/zh-CN/agent-view.md#the-supervisor-process)启动的进程在接受连接之前退出,因此 Claude Code 无法打开您的会话。当服务在退出前打印错误时,括号中的原因给出退出码或信号以及服务打印的第一行,它命名停止它的内容:5706Claude Code 作为[后台服务](https://code.claude.com/docs/zh-CN/agent-view.md#the-supervisor-process)启动的进程在接受连接之前就退出了,因此 Claude Code 无法打开您的会话。如果服务在退出前打印了错误,括号中的原因会给出退出码或信号以及服务打印的第一行,该行会指明导致其停止的原因:

5706 5707 

5707```text theme={null}5708```text theme={null}

5708Couldn't reach the background service (background service exited before it became reachable (exit code N): <the service's first error line>) — run 'claude daemon status'5709Couldn't reach the background service (background service exited before it became reachable (exit code N): <the service's first error line>) — run 'claude daemon status'

5709```5710```

5710 5711 

5711当您从 [Agent 视图](https://code.claude.com/docs/zh-CN/agent-view.md)打开会话时,相同的原因跟随 `Couldn't start the background service —`。当服务在退出前没有打印任何内容时,消息说 `nothing on stderr`。5712当您从 [agent view](https://code.claude.com/docs/zh-CN/agent-view.md) 打开会话时,相同的原因会跟在 `Couldn't start the background service —` 之后。如果服务在退出前没有打印任何内容,消息会改为显示 `nothing on stderr`。

5712 5713 

5713Claude Code 使用服务的错误行报告失败。在 v2.1.246 之前,失败仅在 45 秒等待后显示,作为 `background service did not become reachable within 45s`,没有服务的错误行。5714Claude Code 会连同服务的错误行一起报告失败。在 v2.1.246 之前,失败只会在等待 45 秒后才显示为 `background service did not become reachable within 45s`,且不包含服务的错误行。

5714 5715 

5715两个引用的原因有已知的成因:5716有两种引用的原因具有已知成因:

5716 5717 

5717* `Error: claude native binary not installed.`:npm 安装在那一刻替换 Claude Code 二进制文件,因此服务运行了 npm 的占位符。在安装完成后重试;如果在没有安装运行时该行持续出现,[完成 npm 安装](https://code.claude.com/docs/zh-CN/troubleshoot-install.md#native-binary-not-found-after-npm-install)。在 v2.1.257 之前,macOS npm 自更新在安装窗口期间的每次启动时产生此失败。5718* `Error: claude native binary not installed.`:当时有 npm 安装正在替换 Claude Code 二进制文件,因此服务运行的是 npm 的占位程序。请在安装完成后重试;如果在没有安装运行时该行仍然出现,请[完成 npm 安装](https://code.claude.com/docs/zh-CN/troubleshoot-install.md#native-binary-not-found-after-npm-install)。在 v2.1.257 之前,macOS 上的 npm 自更新会在安装窗口期间的每次启动时都产生此失败。

5718* 在 Windows 上,`nothing on stderr` 和退出码 1,每次启动:`daemon.lock` 命名一个 Claude Code 既无法发信号也无法证明已消失的进程,因此每个新服务得出结论另一个持有锁并退出。Claude Code 可以证明其编写者已消失的锁会自动替换,不会产生此失败。当失败在每次启动时重复时,删除 `~/.claude/daemon.lock`,然后打开会话或再次分派。在 v2.1.257 之前,这样的锁阻止了每次启动,直到您删除了文件。5719* 在 Windows 上每次启动都出现退出码为 1 的 `nothing on stderr`:`daemon.lock` 指向一个 Claude Code 既无法发送信号、也无法证明已不存在的进程,因此每个新服务都会认定另一个服务持有该锁并退出。如果 Claude Code 能够证明锁的写入者已不存在,则会自行替换该锁,不会产生此失败。当每次启动都重复出现该失败时,请删除 `~/.claude/daemon.lock`,然后再次打开会话或分派。在 v2.1.257 之前,这样的锁会阻止每次启动,直到您删除该文件。

5719 5720 

5720**要做什么:**5721**解决方法:**

5721 5722 

5722* 如果消息引用一行,修复它命名的内容,然后打开会话或再次分派。下一次尝试再次启动服务5723* 如果消息引用了某一行,请修复其所指的问题,然后再次打开会话或分派。下一次尝试会再次启动该服务

5723* 运行 `claude daemon status` 检查现在是否有服务运行5724* 运行 `claude daemon status` 检查当前是否有服务正在运行

5724 5725 

5725### 启动后台会话时工作目录不再存在5726### 启动后台会话时工作目录已不存在

5726 5727 

5727您启动[后台会话](https://code.claude.com/docs/zh-CN/agent-view.md)所在的目录在会话启动期间被删除。Claude Code 不启动会话,消息命名缺失的目录:5728您启动[后台会话](https://code.claude.com/docs/zh-CN/agent-view.md)所在的目录在会话启动期间被删除了。Claude Code 不会启动该会话,消息会指明缺失的目录:

5728 5729 

5729```text theme={null}5730```text theme={null}

5730Couldn't start a background session (working directory no longer exists or is not accessible: /tmp/demo)5731Couldn't start a background session (working directory no longer exists or is not accessible: /tmp/demo)

5731```5732```

5732 5733 

5733在 v2.1.257 之前,会话似乎启动,然后在 Agent 视图中显示为具有相同原因的失败行。5734在 v2.1.257 之前,该会话看起来会启动,然后在 agent view 中显示为一个带有相同原因的失败行。

5734 5735 

5735在 v2.1.281 之前,当您启动会话之前目录已经消失时,此消息也出现。该情况报告 [`could not be resolved on disk`](#workspace-not-trusted-when-dispatching-a-background-session)。5736在 v2.1.281 之前,当目录在您启动会话之前就已不存在时,也会出现此消息。这种情况现在会报告 [`could not be resolved on disk`](#workspace-not-trusted-when-dispatching-a-background-session)。

5736 5737 

5737**要做什么:**5738**解决方法:**

5738 5739 

5739* 重新创建消息命名的目录,或从存在的目录分派,然后重试5740* 重新创建消息所指的目录,或从一个存在的目录进行分派,然后重试

5740 5741 

5741### This forked session could not be started5742### This forked session could not be started

5742 5743 

5743您从 claude.ai [分叉了一个 Remote Control 会话](https://code.claude.com/docs/zh-CN/remote-control.md#fork-a-session-from-your-browser),而 Claude Code 无法完成启动在您的机器上运行该分叉的[后台会话](https://code.claude.com/docs/zh-CN/agent-view.md)。此通知出现在分叉会话的会话记录中:5744您从 claude.ai [分叉了一个 Remote Control 会话](https://code.claude.com/docs/zh-CN/remote-control.md#fork-a-session-from-your-browser),而 Claude Code 无法完成启动在您机器上运行该分叉的[后台会话](https://code.claude.com/docs/zh-CN/agent-view.md)。此通知会出现在分叉会话的会话记录中:

5744 5745 

5745```text theme={null}5746```text theme={null}

5746This forked session could not be started. Fork the conversation again to retry.5747This forked session could not be started. Fork the conversation again to retry.

5747```5748```

5748 5749 

5749您分叉的那个会话会继续运行。5750您分叉的原会话会继续运行。

5750 5751 

5751**要做什么:**5752**解决方法:**

5752 5753 

5753* 返回您分叉的那个会话,并在该会话空闲后再次分叉5754* 返回您分叉的那个会话,待该会话空闲后再次分叉

5754 5755 

5755### 分派后台会话时工作区不受信任5756### 分派后台会话时工作区不受信任

5756 5757 

5757您在未[信任](https://code.claude.com/docs/zh-CN/permissions.md#project-allow-rules-and-workspace-trust)的目录中启动或重启[后台会话](https://code.claude.com/docs/zh-CN/agent-view.md),工作区信任对话框无法出现以询问您。Claude Code 不启动会话:5758您在一个尚未[信任](https://code.claude.com/docs/zh-CN/permissions.md#project-allow-rules-and-workspace-trust)的目录中启动或重新启动了[后台会话](https://code.claude.com/docs/zh-CN/agent-view.md),而工作区信任对话框无法出现来询问您。Claude Code 不会启动该会话:

5758 5759 

5759```text theme={null}5760```text theme={null}

5760Workspace not trusted. Run `claude` in /path/to/project once and accept the trust prompt, then retry.5761Workspace not trusted. Run `claude` in /path/to/project once and accept the trust prompt, then retry.

5761```5762```

5762 5763 

5763从会话自己的目录中的终端,相同的命令会改为显示信任对话框,并在您接受后启动会话。此消息出现在无法显示对话框的地方,例如在脚本中,或当您从不同于其自己的目录重启会话时。5764如果在会话自身目录中的终端里运行同一命令,则会改为显示信任对话框,并在您接受后启动会话。此消息出现在无法显示对话框的场合,例如在脚本中,或者当您从会话自身目录以外的目录重新启动会话时。

5764 5765 

5765两个变体命名不同的原因:5766有两种变体指明了不同的原因:

5766 5767 

5767* **`The home directory is trusted one session at a time`**:会话的目录是您的主目录。Claude Code 从不保存主目录的信任,因此在早期会话中在那里接受对话框不计数。5768* **`The home directory is trusted one session at a time`**:会话的目录是您的主目录。Claude Code 从不保存对主目录的信任,因此在之前的会话中于该目录接受过对话框并不算数。

5768* **`<path> could not be resolved on disk`**:Claude Code 无法在磁盘上找到会话的目录。5769* **`<path> could not be resolved on disk`**:Claude Code 在磁盘上找不到该会话的目录。

5769 5770 

5770在 v2.1.286 之前,在 Windows 上,如果某个您已信任的目录的信任记录是以不同字母大小写的路径保存的,此消息也可能在该目录中出现。请更新到 v2.1.286 或更高版本。5771在 v2.1.286 之前,在 Windows 上,如果某个您已信任的目录的信任记录以不同的字母大小写保存了路径,也可能出现此消息。请更新到 v2.1.286 或更高版本。

5771 5772 

5772**要做什么:**5773**解决方法:**

5773 5774 

5774* 在消息命名的目录中运行 `claude` 并接受信任对话框,然后再次运行该命令5775* 在消息所指的目录中运行 `claude` 并接受信任对话框,然后再次运行该命令

5775* 对于主目录消息,从您的主目录中的终端运行该命令,以便对话框可以出现,或改为从项目目录启动会话5776* 对于主目录消息,请在位于主目录的终端中运行该命令,以便对话框能够出现,或者改为从项目目录启动会话

5776* 对于 `could not be resolved on disk` 消息,重新创建目录,或从存在的目录启动新会话5777* 对于 `could not be resolved on disk` 消息,请重新创建该目录,或从一个存在的目录启动新会话

5777 5778 

5778## 包装器和 IDE 错误5779## 包装器和 IDE 错误

5779 5780 

fast-mode.md +1 −1

Details

98 98 

99* **Pro、Max 和 Ultra**:您从使用额度中支付快速模式费用。转到 claude.ai 上的 [**Settings > Usage**](https://claude.ai/settings/usage),其中 **Usage credits** 部分显示您本月在使用额度中花费了多少。该数字包括快速模式,但不单独列出。99* **Pro、Max 和 Ultra**:您从使用额度中支付快速模式费用。转到 claude.ai 上的 [**Settings > Usage**](https://claude.ai/settings/usage),其中 **Usage credits** 部分显示您本月在使用额度中花费了多少。该数字包括快速模式,但不单独列出。

100* **Team 和 Enterprise**:您的组织从其使用额度中支付您的快速模式使用费用。要查看您自己的使用额度支出,运行 [`/usage`](https://code.claude.com/docs/zh-CN/costs#check-your-usage-credits-spend)。有关您的组织在哪里看到该支出,请参阅 [Claude for Teams and Enterprise](https://code.claude.com/docs/zh-CN/costs.md#claude-for-teams-and-enterprise)。100* **Team 和 Enterprise**:您的组织从其使用额度中支付您的快速模式使用费用。要查看您自己的使用额度支出,运行 [`/usage`](https://code.claude.com/docs/zh-CN/costs#check-your-usage-credits-spend)。有关您的组织在哪里看到该支出,请参阅 [Claude for Teams and Enterprise](https://code.claude.com/docs/zh-CN/costs.md#claude-for-teams-and-enterprise)。

101* **Claude Console**:您的组织使用其 API 使用的其余部分支付快速模式费用。在 Console [Usage](https://platform.claude.com/usage) 和 [Cost](https://platform.claude.com/cost) 页面上,在 **Group by** 菜单中选择 **Speed (research preview)** 以将快速模式与标准速度使用分开。只有当选定的日期范围包括快速模式使用时,您才会看到该选项。101* **Claude Console**:您的组织使用其 API 使用的其余部分支付快速模式费用。在 Console [Usage](https://platform.claude.com/usage) 和 [Cost](https://platform.claude.com/cost) 页面上,在 **Group by** 菜单中选择 **Speed** 以将快速模式与标准速度使用分开。只有当选定的日期范围包括快速模式使用时,您才会看到该选项。

102 102 

103## 决定何时使用快速模式103## 决定何时使用快速模式

104 104 

Details

218 218 

219## 内置于 Claude Code 的 Mods219## 内置于 Claude Code 的 Mods

220 220 

221Claude Code 的一些自己的功能是 mods。要查看您的会话拥有的,在 Claude Code 提示符处运行 `/plugin` 并转到**已安装**选项卡,它在**内置**下列出它们。您不能更新或卸载内置 mod,表的最后一列说明如何关闭每一个。[`mods active` 行](#see-which-mods-a-session-loaded)排除了内置 mods。221Claude Code 自身的一些功能就是 mod。要查看您的会话拥有哪些,请在 Claude Code 输入框中运行 `/plugin` 并转到**已安装**选项卡,它在**内置**下列出这些 mod。您不能更新或卸载内置 mod。[`mods active` 行](#see-which-mods-a-session-loaded)不包含内置 mod。

222 222 

223此表按 `/plugin` 显示的名称列出每个条目:223此表按 `/plugin` 显示的名称列出部分**内置**条目:

224 224 

225| `/plugin` 中的名称 | 它做什么 | 它在哪里打开 | 如何关闭它 |225| `/plugin` 中的名称 | 它做什么 | 它在哪里打开 | 如何关闭它 |

226| :- | :- | :- | :- |226| :- | :- | :- | :- |


231| `cc-plugin-telemetry` | 发送 Claude Code 及其内置 mods 记录的分析记录 | 无论 Claude Code 自己的分析在哪里打开 | 在 `/plugin` 中禁用它,或关闭分析,例如使用 [`DISABLE_TELEMETRY`](https://code.claude.com/docs/zh-CN/env-vars) |231| `cc-plugin-telemetry` | 发送 Claude Code 及其内置 mods 记录的分析记录 | 无论 Claude Code 自己的分析在哪里打开 | 在 `/plugin` 中禁用它,或关闭分析,例如使用 [`DISABLE_TELEMETRY`](https://code.claude.com/docs/zh-CN/env-vars) |

232| `cc-plugin-you-should-know` | [You should know](https://code.claude.com/docs/zh-CN/interactive-mode.md#you-should-know-suggestions):一个侧边 Agent 在发现您可能错过的内容时,会在输入框上方显示一条注释 | 默认关闭,直到您[将其打开](https://code.claude.com/docs/zh-CN/interactive-mode.md#you-should-know-suggestions) | 在 `/plugin` 中禁用它 |232| `cc-plugin-you-should-know` | [You should know](https://code.claude.com/docs/zh-CN/interactive-mode.md#you-should-know-suggestions):一个侧边 Agent 在发现您可能错过的内容时,会在输入框上方显示一条注释 | 默认关闭,直到您[将其打开](https://code.claude.com/docs/zh-CN/interactive-mode.md#you-should-know-suggestions) | 在 `/plugin` 中禁用它 |

233 233 

234对于不在表中的**内置**插件,请[在 `/plugin` 中打开其详细信息](https://code.claude.com/docs/zh-CN/plugins/install#manage-installed-plugins),以了解它的作用或将其禁用。

235 

234停止已安装 mods 的设置和标志,例如 `disableAllHooks`、`--bare` 和 `--safe-mode`,不会停止内置 mods。236停止已安装 mods 的设置和标志,例如 `disableAllHooks`、`--bare` 和 `--safe-mode`,不会停止内置 mods。

235 237 

236### 阅读内置 mods 的源代码238### 阅读内置 mods 的源代码

Details

194| `session.receive` | `($, e) => ({ text: e.text })`。使用 `$.session.receive({ origin: { kind: 'peer-send-message' }, text })` 触发它。 |194| `session.receive` | `($, e) => ({ text: e.text })`。使用 `$.session.receive({ origin: { kind: 'peer-send-message' }, text })` 触发它。 |

195| `ui.render` | `() => ({ type: 'Text', props: {}, children: ['...'] })` |195| `ui.render` | `() => ({ type: 'Text', props: {}, children: ['...'] })` |

196 196 

197`expect` 有断言 `toBe`、`toEqual`、`toMatch`、`toMatchObject`、`toContain`、`toBeDefined`、`toBeUndefined` 和 `toThrow`,以及任何之前的 `.not`。197### 使用 `expect` 检查结果

198 

199工具包提供以下断言,所选的断言跟在您要检查的值之后,例如 `expect(answer.text).toBe('ok')`:

200 

201* **相等性**:`toBe` 用于相同的值或对象,`toEqual` 用于结构,`toStrictEqual` 用于结构以及 `undefined` 字段和原型,`toMatchObject` 用于您指定的字段

202* **文本**:`toMatch`(接受正则表达式或子字符串)、`toStartWith` 和 `toEndWith`

203* **数字**:`toBeGreaterThan`、`toBeGreaterThanOrEqual`、`toBeLessThan`、`toBeLessThanOrEqual`

204* **内容**:`toContain` 用于子字符串或成员,`toContainEqual` 用于按结构比较的成员,以及 `toHaveLength` 和 `toHaveProperty`

205* **存在性和类型**:`toBeDefined`、`toBeUndefined`、`toBeNull`、`toBeTruthy`、`toBeFalsy`、`toBeNaN`、`toBeInstanceOf`

206* **抛出**:`toThrow`,用于由 `expect` 调用的函数,或用于您通过 `.rejects` 检查的 promise

207 

208在断言前加上 `.not` 可检查相反的情况,加上 `.resolves` 或 `.rejects` 可检查 promise 最终兑现或拒绝的结果。

198 209 

199当 `expect` 在您以普通函数(而非异步生成器)形式传给 `on` 的 stub 或 hook 中失败时,测试会失败。引擎会跳过该 hook,失败输出会指出其名称,例如 `in the test's store.set hook`。210当 `expect` 在您以普通函数(而非异步生成器)形式传给 `on` 的 stub 或 hook 中失败时,测试会失败。引擎会跳过该 hook,失败输出会指出其名称,例如 `in the test's store.set hook`。

200 211 

Details

26| 项目上下文 | CLAUDE.md、自动记忆、无作用域的规则 | 会话开始时,或在 `/clear` 或 `/compact` 之后 |26| 项目上下文 | CLAUDE.md、自动记忆、无作用域的规则 | 会话开始时,或在 `/clear` 或 `/compact` 之后 |

27| 对话 | 您的消息、Claude 的回复、工具结果 | 每个轮次 |27| 对话 | 您的消息、Claude 的回复、工具结果 | 每个轮次 |

28 28 

29对对话层的更改会使系统提示词和项目上下文保持缓存。对系统提示词的更改会使所有内容失效,因为所有后续内容现在位于不同的前缀后面。第三列给出了常见的触发条件,而不是详尽的列表,下面的部分涵盖了完整的集合。29向对话层添加内容会使系统提示词和项目上下文保持缓存。对系统提示词的更改会使所有内容失效,因为所有后续内容现在位于不同的前缀后面。第三列给出了常见的触发条件,而不是详尽的列表,下面的部分涵盖了完整的集合。

30 30 

31前缀匹配规则解释了本页上的大多数行为。例如,[计划模式](https://code.claude.com/docs/zh-CN/permission-modes.md#analyze-before-you-edit-with-plan-mode)和 [skill 加载](https://code.claude.com/docs/zh-CN/skills.md)将其指令作为对话消息附加,因此缓存的前缀保持完整。31前缀匹配规则解释了本页上的大多数行为。例如,[计划模式](https://code.claude.com/docs/zh-CN/permission-modes.md#analyze-before-you-edit-with-plan-mode)和 [skill 加载](https://code.claude.com/docs/zh-CN/skills.md)将其指令作为对话消息附加,因此缓存的前缀保持完整。

32 32 


174 174 

175### 压缩对话175### 压缩对话

176 176 

177[压缩](https://code.claude.com/docs/zh-CN/context-window.md#what-survives-compaction)会用摘要替换您的消息历史记录。按照设计,这会使对话层失效:下一个请求拥有一个新的、更短的历史记录,与旧的历史记录不共享前缀。系统提示词层和项目上下文层可以保持缓存:177[压缩](https://code.claude.com/docs/zh-CN/context-window.md#what-survives-compaction)会用摘要替换您的消息历史记录。按照设计,这会使对话层失效:下一个请求拥有一个新的、更短的历史记录,与旧的历史记录不共享前缀。

178 178 

179* **系统提示词**:下一个请求会从缓存中读取此层,除非某个[恢复的对话](#resuming-a-session)保留了现已过时的系统提示词。该对话第一次被压缩时,Claude Code 会将其切换为当前的提示词,下一个请求会重建此层的缓存一次。179* **系统提示词**:下一个请求会从缓存中读取此层,除非某个[恢复的对话](#resuming-a-session)保留了现已过时的系统提示词。该对话第一次被压缩时,Claude Code 会将其切换为当前的提示词,下一个请求会重建此层的缓存一次。

180* **项目上下文**:Claude Code 会从磁盘重新加载此层。仅当 CLAUDE.md 和记忆自会话开始以来未改变时,下一个请求才会从缓存中读取它。180* **项目上下文**:Claude Code 会从磁盘重新加载此层。它与对话一起缓存,因此在 `/compact` 或自动压缩之后,即使其文件未改变,其缓存也会被重建。

181 181 

182为了生成摘要,Claude Code 会发送一个单独的请求。该请求会重复您对话的系统提示词、工具以及正在被摘要的历史记录,并以一条摘要指令结尾。当缓存温暖时,该请求会从缓存中读取您的前缀。因此,会话中途的 `/compact` 成本只是上下文大小所暗示成本的一小部分,其大部分时间都花在生成摘要上。182为了生成摘要,Claude Code 会发送一个单独的请求。该请求会重复您对话的系统提示词、工具以及正在被摘要的历史记录,并以一条摘要指令结尾。当缓存温暖时,该请求会从缓存中读取您的前缀。因此,会话中途的 `/compact` 成本只是上下文大小所暗示成本的一小部分,其大部分时间都花在生成摘要上。

183 183 

184在超过[缓存生命周期](#cache-lifetime)的中断之后,已没有缓存可读,因此摘要请求会将该历史记录作为未缓存的输入重新处理。这就是为什么在您[恢复旧会话](https://code.claude.com/docs/zh-CN/sessions.md#resume-a-session)时 `/compact` 的成本最高。无论缓存温暖还是已冷,压缩后的轮次都只需为短得多的摘要重建对话缓存,因此该轮次并不是耗时的部分。184在超过[缓存生命周期](#cache-lifetime)的中断之后,已没有缓存可读,因此摘要请求会将该历史记录作为未缓存的输入重新处理。这就是为什么在您[恢复旧会话](https://code.claude.com/docs/zh-CN/sessions.md#resume-a-session)时 `/compact` 的成本最高。无论缓存温暖还是已冷,压缩后的轮次都只需为短得多的历史记录重建对话缓存,因此该轮次并不是耗时的部分。

185 185 

186> [!TIP]186> [!TIP]

187>187>

quickstart.md +5 −5

Details

35>35>

36> **macOS、Linux、WSL:**36> **macOS、Linux、WSL:**

37>37>

38> ```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} 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} 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} 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} theme={null} theme={null} theme={null}38> ```bash theme={null}

39> curl -fsSL https://claude.ai/install.sh | bash39> curl -fsSL https://claude.ai/install.sh | bash

40> ```40> ```

41>41>


43>43>

44> **Windows PowerShell:**44> **Windows PowerShell:**

45>45>

46> ```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} 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} 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} 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} theme={null} theme={null} theme={null}46> ```powershell theme={null}

47> irm https://claude.ai/install.ps1 | iex47> irm https://claude.ai/install.ps1 | iex

48> ```48> ```

49>49>

50> **Windows CMD:**50> **Windows CMD:**

51>51>

52> ```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} 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} 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} 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} theme={null} theme={null} theme={null}52> ```batch theme={null}

53> curl -fsSL https://claude.ai/install.cmd -o install.cmd && install.cmd && del install.cmd53> curl -fsSL https://claude.ai/install.cmd -o install.cmd && install.cmd && del install.cmd

54> ```54> ```

55>55>


67 67 

68> [tab] Homebrew68> [tab] Homebrew

69>69>

70> ```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} 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} 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} 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} theme={null} theme={null} theme={null}70> ```bash theme={null}

71> brew install --cask claude-code71> brew install --cask claude-code

72> ```72> ```

73>73>


79 79 

80> [tab] WinGet80> [tab] WinGet

81>81>

82> ```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} 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} 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} 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} theme={null} theme={null} theme={null}82> ```powershell theme={null}

83> winget install Anthropic.ClaudeCode83> winget install Anthropic.ClaudeCode

84> ```84> ```

85>85>

Details

86| [`disabledMcpjsonServers`](#disabledmcpjsonservers) | 拒绝项目 [`.mcp.json`](https://code.claude.com/docs/zh-CN/mcp#project-scope) 中的特定服务器 | MCP | 任意文件 |86| [`disabledMcpjsonServers`](#disabledmcpjsonservers) | 拒绝项目 [`.mcp.json`](https://code.claude.com/docs/zh-CN/mcp#project-scope) 中的特定服务器 | MCP | 任意文件 |

87| [`disableMobileSimulatorTools`](#disablemobilesimulatortools) | 在[桌面版](https://code.claude.com/docs/zh-CN/desktop.md) iOS Simulator 面板中屏蔽 Claude 的工具 | 工具 | 托管 |87| [`disableMobileSimulatorTools`](#disablemobilesimulatortools) | 在[桌面版](https://code.claude.com/docs/zh-CN/desktop.md) iOS Simulator 面板中屏蔽 Claude 的工具 | 工具 | 托管 |

88| [`disableRemoteControl`](#disableremotecontrol) | 在所有可启动 [Remote Control](https://code.claude.com/docs/zh-CN/remote-control.md) 的位置将其关闭 | 远程、桌面与通知 | 任意文件 |88| [`disableRemoteControl`](#disableremotecontrol) | 在所有可启动 [Remote Control](https://code.claude.com/docs/zh-CN/remote-control.md) 的位置将其关闭 | 远程、桌面与通知 | 任意文件 |

89| [`disableRemotePreviewScripts`](#disableremotepreviewscripts) | 在 SSH 和 WSL 会话中关闭[桌面版](https://code.claude.com/docs/zh-CN/desktop.md#preview-html-files-in-ssh-and-wsl-sessions)应用 HTML 预览中的脚本 | 远程、桌面与通知 | 托管 |

89| [`disableSideloadFlags`](#disablesideloadflags) | 拒绝用于旁加载[插件](https://code.claude.com/docs/zh-CN/plugins/overview.md)、[子代理](https://code.claude.com/docs/zh-CN/sub-agents.md)和 [MCP 服务器](https://code.claude.com/docs/zh-CN/mcp.md)的 CLI 标志 | 企业与托管设置 | 托管 |90| [`disableSideloadFlags`](#disablesideloadflags) | 拒绝用于旁加载[插件](https://code.claude.com/docs/zh-CN/plugins/overview.md)、[子代理](https://code.claude.com/docs/zh-CN/sub-agents.md)和 [MCP 服务器](https://code.claude.com/docs/zh-CN/mcp.md)的 CLI 标志 | 企业与托管设置 | 托管 |

90| [`disableSkillShellExecution`](#disableskillshellexecution) | 阻止 [skill](https://code.claude.com/docs/zh-CN/skills.md) 和自定义命令运行内联 shell | 插件与 skill | 任意文件 |91| [`disableSkillShellExecution`](#disableskillshellexecution) | 阻止 [skill](https://code.claude.com/docs/zh-CN/skills.md) 和自定义命令运行内联 shell | 插件与 skill | 任意文件 |

91| [`disableWorkflows`](#disableworkflows) | 为所有人关闭[动态工作流](https://code.claude.com/docs/zh-CN/workflows.md);若仅针对自己,请使用 `enableWorkflows` | hook 与自动化 | 任意文件 |92| [`disableWorkflows`](#disableworkflows) | 为所有人关闭[动态工作流](https://code.claude.com/docs/zh-CN/workflows.md);若仅针对自己,请使用 `enableWorkflows` | hook 与自动化 | 任意文件 |


147| [`permissions.blockWritesOutsideWorkingDirectories`](#permissions-blockwritesoutsideworkingdirectories) | 使 `Write`、`Edit` 和 `NotebookEdit` 工具在所有权限模式下拒绝[工作目录](https://code.claude.com/docs/zh-CN/permissions.md#working-directories)之外的路径,[Claude Code 自身的部分文件](#what-the-write-block-refuses-and-what-stays-writable)除外 | 权限设置 | 任意文件 |148| [`permissions.blockWritesOutsideWorkingDirectories`](#permissions-blockwritesoutsideworkingdirectories) | 使 `Write`、`Edit` 和 `NotebookEdit` 工具在所有权限模式下拒绝[工作目录](https://code.claude.com/docs/zh-CN/permissions.md#working-directories)之外的路径,[Claude Code 自身的部分文件](#what-the-write-block-refuses-and-what-stays-writable)除外 | 权限设置 | 任意文件 |

148| [`permissions.defaultMode`](#permissions-defaultmode) | 为新会话设置默认的[权限模式](https://code.claude.com/docs/zh-CN/permission-modes.md#which-mode-a-session-starts-in) | 权限设置 | 任意文件 |149| [`permissions.defaultMode`](#permissions-defaultmode) | 为新会话设置默认的[权限模式](https://code.claude.com/docs/zh-CN/permission-modes.md#which-mode-a-session-starts-in) | 权限设置 | 任意文件 |

149| [`permissions.deny`](#permissions-deny) | 阻止所列的[工具使用](https://code.claude.com/docs/zh-CN/permissions.md#permission-rule-syntax),包括读取包含机密的文件 | 权限设置 | 任意文件 |150| [`permissions.deny`](#permissions-deny) | 阻止所列的[工具使用](https://code.claude.com/docs/zh-CN/permissions.md#permission-rule-syntax),包括读取包含机密的文件 | 权限设置 | 任意文件 |

151| [`permissions.denyInsteadOfPrompting`](#permissions-denyinsteadofprompting) | 拒绝原本需要等待[权限提示](https://code.claude.com/docs/zh-CN/permissions.md#permission-system)的工具调用,使无人值守的会话能够继续工作 | 权限设置 | 用户或托管 |

150| [`permissions.disableBypassPermissionsMode`](#permissions-disablebypasspermissionsmode) | 阻止任何人进入 [bypassPermissions 模式](https://code.claude.com/docs/zh-CN/permission-modes.md#skip-all-checks-with-bypasspermissions-mode) | 权限设置 | 任意文件 |152| [`permissions.disableBypassPermissionsMode`](#permissions-disablebypasspermissionsmode) | 阻止任何人进入 [bypassPermissions 模式](https://code.claude.com/docs/zh-CN/permission-modes.md#skip-all-checks-with-bypasspermissions-mode) | 权限设置 | 任意文件 |

151| [`plansDirectory`](#plansdirectory) | 选择[计划模式](https://code.claude.com/docs/zh-CN/permission-modes.md#analyze-before-you-edit-with-plan-mode)写入计划文件的位置 | 记忆与上下文 | 任意文件 |153| [`plansDirectory`](#plansdirectory) | 选择[计划模式](https://code.claude.com/docs/zh-CN/permission-modes.md#analyze-before-you-edit-with-plan-mode)写入计划文件的位置 | 记忆与上下文 | 任意文件 |

152| [`pluginConfigs`](#pluginconfigs) | 存储您在[插件](https://code.claude.com/docs/zh-CN/plugins/overview.md)配置对话框中给出的答案 | 插件与 skill | 用户或托管 |154| [`pluginConfigs`](#pluginconfigs) | 存储您在[插件](https://code.claude.com/docs/zh-CN/plugins/overview.md)配置对话框中给出的答案 | 插件与 skill | 用户或托管 |


228| [`statusLine`](#statusline) | 运行您自己的命令,在输入框下方渲染[状态栏](https://code.claude.com/docs/zh-CN/statusline.md) | 界面与终端 | 任意文件 |230| [`statusLine`](#statusline) | 运行您自己的命令,在输入框下方渲染[状态栏](https://code.claude.com/docs/zh-CN/statusline.md) | 界面与终端 | 任意文件 |

229| [`strictKnownMarketplaces`](#strictknownmarketplaces) | 通过允许列表限定用户可以添加并从中安装的[市场](https://code.claude.com/docs/zh-CN/plugins/overview.md)来源 | 插件与 skill | 托管 |231| [`strictKnownMarketplaces`](#strictknownmarketplaces) | 通过允许列表限定用户可以添加并从中安装的[市场](https://code.claude.com/docs/zh-CN/plugins/overview.md)来源 | 插件与 skill | 托管 |

230| [`strictPluginOnlyCustomization`](#strictpluginonlycustomization) | 屏蔽来自用户和项目来源的 [skill](https://code.claude.com/docs/zh-CN/skills.md)、[Agent](https://code.claude.com/docs/zh-CN/sub-agents.md)、[hook](https://code.claude.com/docs/zh-CN/hooks.md) 和 [MCP 服务器](https://code.claude.com/docs/zh-CN/mcp.md) | 插件与 skill | 托管 |232| [`strictPluginOnlyCustomization`](#strictpluginonlycustomization) | 屏蔽来自用户和项目来源的 [skill](https://code.claude.com/docs/zh-CN/skills.md)、[Agent](https://code.claude.com/docs/zh-CN/sub-agents.md)、[hook](https://code.claude.com/docs/zh-CN/hooks.md) 和 [MCP 服务器](https://code.claude.com/docs/zh-CN/mcp.md) | 插件与 skill | 托管 |

231| [`strictPluginOnlyCustomization.agents`](#strictpluginonlycustomization-agents) | 将 [Agent](https://code.claude.com/docs/zh-CN/sub-agents.md) 限定为插件和托管来源 | 插件与 skill | 托管 |233| [`strictPluginOnlyCustomization.agents`](#strictpluginonlycustomization-agents) | 屏蔽来自用户和项目来源的 [Agent](https://code.claude.com/docs/zh-CN/sub-agents.md) | 插件与 skill | 托管 |

232| [`strictPluginOnlyCustomization.hooks`](#strictpluginonlycustomization-hooks) | 将 [hook](https://code.claude.com/docs/zh-CN/hooks.md) 限定为插件和托管来源 | 插件与 skill | 托管 |234| [`strictPluginOnlyCustomization.hooks`](#strictpluginonlycustomization-hooks) | 屏蔽来自用户和项目来源的 [hook](https://code.claude.com/docs/zh-CN/hooks.md) | 插件与 skill | 托管 |

233| [`strictPluginOnlyCustomization.mcp`](#strictpluginonlycustomization-mcp) | 将 [MCP 服务器](https://code.claude.com/docs/zh-CN/mcp.md)限定为插件和托管来源 | 插件与 skill | 托管 |235| [`strictPluginOnlyCustomization.mcp`](#strictpluginonlycustomization-mcp) | 屏蔽来自用户和项目来源的 [MCP 服务器](https://code.claude.com/docs/zh-CN/mcp.md) | 插件与 skill | 托管 |

234| [`strictPluginOnlyCustomization.skills`](#strictpluginonlycustomization-skills) | 将 [skill](https://code.claude.com/docs/zh-CN/skills.md) 限定为插件和托管来源 | 插件与 skill | 托管 |236| [`strictPluginOnlyCustomization.skills`](#strictpluginonlycustomization-skills) | 屏蔽来自用户和项目来源的 [skill](https://code.claude.com/docs/zh-CN/skills.md) | 插件与 skill | 托管 |

235| [`subagentPromptCacheTtl`](#subagentpromptcachettl) | 为子代理和主对话之外的其他请求选择[提示缓存生命周期](https://code.claude.com/docs/zh-CN/prompt-caching.md#cache-lifetime) | 模型与回复 | 任意文件 |237| [`subagentPromptCacheTtl`](#subagentpromptcachettl) | 为子代理和主对话之外的其他请求选择[提示缓存生命周期](https://code.claude.com/docs/zh-CN/prompt-caching.md#cache-lifetime) | 模型与回复 | 任意文件 |

236| [`subagentStatusLine`](#subagentstatusline) | 使用您自己的命令重写[子代理](https://code.claude.com/docs/zh-CN/sub-agents.md)任务显示中的行 | 界面与终端 | 任意文件 |238| [`subagentStatusLine`](#subagentstatusline) | 使用您自己的命令重写[子代理](https://code.claude.com/docs/zh-CN/sub-agents.md)任务显示中的行 | 界面与终端 | 任意文件 |

237| [`switchModelsOnFlag`](#switchmodelsonflag) | 当[安全分类器](https://code.claude.com/docs/zh-CN/model-config.md#ask-before-switching)标记某个请求时,自动切换模型或暂停 | 模型与回复 | 任意文件 |239| [`switchModelsOnFlag`](#switchmodelsonflag) | 当[安全分类器](https://code.claude.com/docs/zh-CN/model-config.md#ask-before-switching)标记某个请求时,自动切换模型或暂停 | 模型与回复 | 任意文件 |


288}290}

289```291```

290 292 

291在 advisor [不可用](https://code.claude.com/docs/zh-CN/advisor.md#requirements)的提供商上(例如 Amazon Bedrock 和 Claude Platform on AWS),此键不起作用。`"fable"` 需要 [Fable 访问权限](https://code.claude.com/docs/zh-CN/advisor.md#choose-an-advisor-model)。293在 advisor [不可用](https://code.claude.com/docs/zh-CN/advisor.md#requirements)的提供商上(例如 Amazon Bedrock),此键不起作用。在 Claude Platform on AWS 上,此键需要 Claude Code v2.1.300 或更高版本。`"fable"` 需要 [Fable 访问权限](https://code.claude.com/docs/zh-CN/advisor.md#choose-an-advisor-model)。

292 294 

293### `alwaysThinkingEnabled`295### `alwaysThinkingEnabled`

294 296 


448 450 

449在可用的会话中开启[快速模式](https://code.claude.com/docs/zh-CN/fast-mode.md),适用于快速迭代或实时调试等需要以更高的每 token 成本换取速度的交互式工作。通常无需手动编辑此键。运行 `/fast` 会将 `fastMode: true` 写入 `~/.claude/settings.json`,再次运行以关闭快速模式则会移除该键。451在可用的会话中开启[快速模式](https://code.claude.com/docs/zh-CN/fast-mode.md),适用于快速迭代或实时调试等需要以更高的每 token 成本换取速度的交互式工作。通常无需手动编辑此键。运行 `/fast` 会将 `fastMode: true` 写入 `~/.claude/settings.json`,再次运行以关闭快速模式则会移除该键。

450 452 

451只有 Fable 5.2、Opus 5.5、Opus 5 和 Opus 4.8 支持快速模式。在其他模型上运行 `/fast` 会将您切换到 Opus,而切换到不受支持的模型则会关闭快速模式。请参阅[在快速模式开启时切换模型](https://code.claude.com/docs/zh-CN/fast-mode.md#switch-models-while-fast-mode-is-on)。453在 Anthropic API 上,只有 Fable 5.2、Opus 5.5、Opus 5 和 Opus 4.8 支持快速模式。在其他模型上运行 `/fast` 会将您切换到 Opus,而切换到不受支持的模型则会关闭快速模式。请参阅[在快速模式开启时切换模型](https://code.claude.com/docs/zh-CN/fast-mode.md#switch-models-while-fast-mode-is-on)。在 Google Cloud 的 Agent Platform 上,[`/fast` 则会将您切换到 Fable 5.2](https://code.claude.com/docs/zh-CN/fast-mode#use-fast-mode-on-agent-platform),且不会写入此键,Claude Code 也会忽略已保存的 `true`。

452 454 

453* **作用域**:[`Any file`](#scopes)455* **作用域**:[`Any file`](#scopes)

454* **类型**:Boolean456* **类型**:Boolean


904控制 Claude 无需询问即可使用哪些工具、哪些工具需要提示、哪些工具被阻止。还可设置新会话的默认[权限模式](https://code.claude.com/docs/zh-CN/permission-modes.md)。下面的每个 `permissions.*` 键都嵌套在此对象下。906控制 Claude 无需询问即可使用哪些工具、哪些工具需要提示、哪些工具被阻止。还可设置新会话的默认[权限模式](https://code.claude.com/docs/zh-CN/permission-modes.md)。下面的每个 `permissions.*` 键都嵌套在此对象下。

905 907 

906* **作用域**:[`Any file`](#scopes)908* **作用域**:[`Any file`](#scopes)

907* **类型**:包含 `allow`、`ask`、`deny`、`additionalDirectories`、`blockReadsOutsideWorkingDirectories`、`blockWritesOutsideWorkingDirectories`、`defaultMode`、`disableBypassPermissionsMode` 和 `disableAutoMode` 的对象909* **类型**:包含 `allow`、`ask`、`deny`、`additionalDirectories`、`blockReadsOutsideWorkingDirectories`、`blockWritesOutsideWorkingDirectories`、`defaultMode`、`denyInsteadOfPrompting`、`disableBypassPermissionsMode` 和 `disableAutoMode` 的对象

908* **默认值**:未设置910* **默认值**:未设置

909 911 

910此示例无需询问即批准 `npm run` 命令,在 `git push` 之前进行提示,阻止读取 `.env`,并以 `acceptEdits` 启动会话:912此示例无需询问即批准 `npm run` 命令,在 `git push` 之前进行提示,阻止读取 `.env`,并以 `acceptEdits` 启动会话:


1163 1165 

1164权限规则叠加在每种模式之上:`deny` 规则在所有模式下都会阻止,包括 `bypassPermissions`。请参阅[权限模式](https://code.claude.com/docs/zh-CN/permission-modes.md)。在云端会话中,Claude Code 仅采用此键中的 `acceptEdits`、`plan`、`default` 和 `auto`。对于 VS Code 扩展启动的对话,请参阅[扩展读取哪个设置作为起始权限模式](https://code.claude.com/docs/zh-CN/permission-modes.md#switch-permission-modes)。1166权限规则叠加在每种模式之上:`deny` 规则在所有模式下都会阻止,包括 `bypassPermissions`。请参阅[权限模式](https://code.claude.com/docs/zh-CN/permission-modes.md)。在云端会话中,Claude Code 仅采用此键中的 `acceptEdits`、`plan`、`default` 和 `auto`。对于 VS Code 扩展启动的对话,请参阅[扩展读取哪个设置作为起始权限模式](https://code.claude.com/docs/zh-CN/permission-modes.md#switch-permission-modes)。

1165 1167 

1168### `permissions.denyInsteadOfPrompting`

1169 

1170将此项设置为 `true`,可在无人回答权限提示时让会话继续运行。Claude Code 会拒绝原本需要等待提示的工具调用,轮次继续进行。需要 Claude Code v2.1.319 或更高版本。

1171 

1172如果允许规则、您的[权限模式](https://code.claude.com/docs/zh-CN/permission-modes.md)或自动模式的分类器批准了某个调用,该调用会继续执行。要允许大多数原本会发出提示的调用,请通过 [`PermissionRequest` hook](https://code.claude.com/docs/zh-CN/hooks#permissionrequest) 进行应答。

1173 

1174* **作用域**:[`User or managed`](#scopes),以及 `--settings`。仓库无法替您设置它。

1175* **类型**:Boolean

1176 * `true`:Claude Code 拒绝原本会发出提示的调用

1177 * `false`:与未设置相同;如果这些来源中的另一个设置了 `true`,调用仍会被拒绝

1178* **默认值**:未设置,因此需要批准的调用会向您发出提示

1179 

1180在 `~/.claude/settings.json` 中,此示例以自动模式启动会话,并拒绝所有仍会回退到提示的操作:

1181 

1182```json settings.json theme={null}

1183{

1184 "permissions": {

1185 "defaultMode": "auto",

1186 "denyInsteadOfPrompting": true

1187 }

1188}

1189```

1190 

1191此键适用于 `-p` 运行、交互式终端会话、[VS Code 扩展](https://code.claude.com/docs/zh-CN/vs-code.md)、[Desktop 应用](https://code.claude.com/docs/zh-CN/desktop.md)中的本地会话、[子代理](https://code.claude.com/docs/zh-CN/sub-agents.md)以及 [agent team](https://code.claude.com/docs/zh-CN/agent-teams.md)。如果只想在单次[非交互式](https://code.claude.com/docs/zh-CN/headless.md)运行中拒绝会发出提示的操作,请改为将 [`--permission-prompts none`](https://code.claude.com/docs/zh-CN/headless#turn-off-permission-prompts-in-unattended-runs) 与 `-p` 一起传入。

1192 

1193#### `denyInsteadOfPrompting` 还会阻止什么

1194 

1195启用此设置后,Claude Code 还会停止以下需要应答的请求:

1196 

1197* **问题和计划工具**:Claude Code 会省略 [`AskUserQuestion`](https://code.claude.com/docs/zh-CN/tools-reference#askuserquestion-tool-behavior)、`EnterPlanMode` 和 `ExitPlanMode`,因此处于计划模式的会话无法自行退出该模式。agent team 中的队友会保留 `EnterPlanMode` 和 `ExitPlanMode`

1198* **MCP elicitation**:Claude Code 会取消 [elicitation 请求](https://code.claude.com/docs/zh-CN/mcp.md#respond-to-mcp-elicitation-requests),除非有 [`Elicitation` hook](https://code.claude.com/docs/zh-CN/hooks#elicitation) 对其作出应答

1199* **权限宿主**:Claude Code 不会询问您的 [`canUseTool` 回调](https://code.claude.com/docs/zh-CN/agent-sdk/user-input)或 [`--permission-prompt-tool`](https://code.claude.com/docs/zh-CN/cli-reference#cli-flags)。要通过代码批准调用,请通过 `PermissionRequest` hook 应答。某些调用会在询问任何 hook 之前就被拒绝,例如 `auto` 模式下未被任何 ask 规则覆盖的[关键路径删除](https://code.claude.com/docs/zh-CN/permission-modes.md#critical-path-removals-in-each-permission-mode)。

1200* **分类器计费通知**:在[关于计费分类器请求的通知](https://code.claude.com/docs/zh-CN/auto-mode-classifier-billing.md)会打开对话框的情况下,Claude Code 不会显示该通知,并会拒绝需要这些请求的操作

1201 

1202会话仍可能等待[工作区信任对话框](https://code.claude.com/docs/zh-CN/permissions.md#project-allow-rules-and-workspace-trust)和[项目 MCP 服务器批准](https://code.claude.com/docs/zh-CN/mcp.md#project-server-approvals-and-workspace-trust)。请在让会话无人值守地运行之前先应答这两项。

1203 

1204#### 来自 `denyInsteadOfPrompting` 的消息

1205 

1206这些消息报告被拒绝的调用。它们不是提示,因此不会等待您的应答。

1207 

1208Claude 读取到的拒绝信息可能以以下文本开头:

1209 

1210```text theme={null}

1211Permission for this tool use was denied. It requires approval, and this session has no approval surface

1212```

1213 

1214在 `stream-json` 输出中,[发出 `permission_denied` 消息的运行](https://code.claude.com/docs/zh-CN/agent-sdk/typescript#sdkpermissiondeniedmessage)会报告以下 `decision_reason`:

1215 

1216```text theme={null}

1217no approval surface in this session; permission request denied automatically

1218```

1219 

1220在启用此设置的自动模式下,当连续 20 次调用被分类器阻止或被[安全检查拒绝](https://code.claude.com/docs/zh-CN/errors.md#auto-mode-cannot-determine-the-safety-of-an-action)后,该轮次会结束,您会看到以下消息:

1221 

1222```text theme={null}

122320 actions were refused and no work went ahead in between, so Claude stopped.

1224```

1225 

1226`-p` 运行会将该轮次报告为 `error_during_execution`。

1227 

1166### `permissions.disableBypassPermissionsMode`1228### `permissions.disableBypassPermissionsMode`

1167 1229 

1168阻止任何人进入 `bypassPermissions` 模式。此后 Claude Code 会拒绝 `--dangerously-skip-permissions` 标志,并忽略 [Agent 定义](https://code.claude.com/docs/zh-CN/sub-agents.md#permission-modes)中的 `permissionMode: bypassPermissions`,因此子代理会以父会话的权限模式运行。1230阻止任何人进入 `bypassPermissions` 模式。此后 Claude Code 会拒绝 `--dangerously-skip-permissions` 标志,并忽略 [Agent 定义](https://code.claude.com/docs/zh-CN/sub-agents.md#permission-modes)中的 `permissionMode: bypassPermissions`,因此子代理会以父会话的权限模式运行。


1202 1264 

1203跳过 Claude Code 在会话进入 `bypassPermissions` 模式之前显示的确认对话框,无论是由 `--dangerously-skip-permissions` 还是 `defaultMode: "bypassPermissions"` 触发。当您接受过一次该对话框后,Claude Code 会在您的用户设置中此处写入 `true`。1265跳过 Claude Code 在会话进入 `bypassPermissions` 模式之前显示的确认对话框,无论是由 `--dangerously-skip-permissions` 还是 `defaultMode: "bypassPermissions"` 触发。当您接受过一次该对话框后,Claude Code 会在您的用户设置中此处写入 `true`。

1204 1266 

1205* **作用域**:[`User, local, or managed`](#scopes)。不受信任的仓库无法替您跳过该对话框。1267* **作用域**:[`User, local, or managed`](#scopes),以及通过 `--settings` 传入的文件。[后台会话](https://code.claude.com/docs/zh-CN/permission-modes.md#bypass-permissions-ignored-in-a-background-session)仅计入用户设置和托管设置。不受信任的仓库无法替您跳过该对话框。

1206* **类型**:Boolean1268* **类型**:Boolean

1207 * `true`:Claude Code 在会话进入 `bypassPermissions` 模式之前跳过确认对话框1269 * `true`:Claude Code 在会话进入 `bypassPermissions` 模式之前跳过确认对话框

1208 * `false`:与未设置相同;除非这些文件中的另一个设置了 `true`,否则对话框会出现1270 * `false`:与未设置相同;除非这些文件中的另一个设置了 `true`,否则对话框会出现


3132 3194 

3133### `syntaxHighlightingDisabled`3195### `syntaxHighlightingDisabled`

3134 3196 

3135Claude Code 使用其内置的高亮器,按语言为其在终端中显示的 diff、代码块和文件预览中的代码着色;不涉及任何插件或语言服务器。将此键设置为 `true` 可改为以纯文本显示,例如当颜色与您的终端主题冲突或拖慢屏幕阅读器时。3197Claude Code 使用其内置的高亮器,按语言为其在终端中显示的 diff、代码块和文件预览中的代码着色。将此键设置为 `true` 可改为以纯文本显示,例如当颜色与您的终端主题冲突或拖慢屏幕阅读器时。

3136 3198 

3137* **作用域**:[`Any file`](#scopes)3199* **作用域**:[`Any file`](#scopes)

3138* **类型**:布尔值3200* **类型**:布尔值


4110 4172 

4111### `strictPluginOnlyCustomization`4173### `strictPluginOnlyCustomization`

4112 4174 

4113阻止来自用户和项目来源的 skill、Agent、hook 和 MCP 服务器,使它们只能来自插件或托管设置。将其与 [`strictKnownMarketplaces`](#strictknownmarketplaces) 结合使用可控制完整的自定义供应链:市场允许列表控制用户可以安装哪些插件。4175阻止来自用户和项目来源的 skill、Agent、hook 和 MCP 服务器。将其与 [`strictKnownMarketplaces`](#strictknownmarketplaces) 结合使用,可选择用户能够从哪些市场安装插件。再添加 [`disableSideloadFlags`](#disablesideloadflags),可拒绝那些为单次运行旁加载插件、Agent 和 MCP 服务器的 CLI 标志。

4114 4176 

4115* **作用域**:[`Managed`](#scopes)4177* **作用域**:[`Managed`](#scopes)

4116* **类型**:`true` 表示锁定全部四种自定义,或者是一个数组,从 `"skills"`、`"agents"`、`"hooks"` 和 `"mcp"` 中指定要锁定的类型4178* **类型**:`true` 表示锁定全部,或者是一个数组,从 `"skills"`、`"agents"`、`"hooks"` 和 `"mcp"` 中指定要锁定的类型

4117* **默认值**:未设置,因此不锁定任何内容4179* **默认值**:未设置,因此不锁定任何内容

4118 4180 

4119此示例锁定 skill 和 hook,而不锁定 Agent 和 MCP 服务器:4181此示例锁定 skill 和 hook,而不锁定 Agent 和 MCP 服务器:


4216每个作用域有不同的用途:4278每个作用域有不同的用途:

4217 4279 

4218* **用户设置**:您的个人插件偏好4280* **用户设置**:您的个人插件偏好

4219* **项目设置**:与仓库中所有人共享的插件4281* **项目设置**:为仓库中所有人启用的插件。这并不会安装它们,因此每个用户需要[自行安装](https://code.claude.com/docs/zh-CN/plugins/org.md#require-plugins-per-repository)。

4220* **本地设置**:按机器的覆盖,Claude Code 在此保存设置时会将其加入 gitignore4282* **本地设置**:按机器的覆盖,Claude Code 在此保存设置时会将其加入 gitignore

4221* **托管设置**:组织范围的策略。在此设置为 `false` 的插件在所有作用域中都被禁止安装,并在市场中隐藏4283* **托管设置**:组织范围的策略。在此设置为 `false` 的插件在所有作用域中都被禁止安装,并在市场中隐藏

4222 4284 

4223项目设置优先于用户设置,因此在 `~/.claude/settings.json` 中将插件设置为 `false` 不会禁用项目的 `.claude/settings.json` 所启用的插件。要在您的机器上退出项目启用的插件,请改为在 `.claude/settings.local.json` 中将其设置为 `false`。由托管设置强制启用的插件无法通过这种方式禁用,因为托管设置会覆盖本地设置。4285项目设置优先于用户设置,因此在 `~/.claude/settings.json` 中将插件设置为 `false` 不会禁用项目的 `.claude/settings.json` 所启用的插件。要在您的机器上退出项目启用的插件,请改为在 `.claude/settings.local.json` 中将其设置为 `false`。由托管设置强制启用的插件无法通过这种方式禁用,因为托管设置会覆盖本地设置。

4224 4286 

4225在项目的 `.claude/settings.json` 中启用来自外部来源(例如 GitHub 仓库或 npm 包)的插件,并不会为其他人安装该插件。在每条加载插件的路径上,Claude Code 都会报告该插件未安装,直到每个用户[自行安装](https://code.claude.com/docs/zh-CN/plugins/org.md#require-plugins-per-repository)。

4226 

4227### `extraKnownMarketplaces`4287### `extraKnownMarketplaces`

4228 4288 

4229按名称注册额外的插件市场,使打开该仓库的人或您的托管设置覆盖到的所有人无需自行添加即可获得该市场。Claude Code 会注册每个它尚不知道的市场。[`enabledPlugins`](#enabledplugins) 从中指定的插件是否会安装,取决于插件的来源以及由哪个文件启用它;该条目介绍了相关规则。4289按名称注册额外的插件市场,使打开该仓库的人或您的托管设置覆盖到的所有人无需自行添加即可获得该市场。Claude Code 会注册每个它尚不知道的市场。[`enabledPlugins`](#enabledplugins) 从中指定的插件是否会安装,取决于插件的来源以及由哪个文件启用它;[已在项目设置中启用但未安装](https://code.claude.com/docs/zh-CN/plugins/loading.md#enabled-in-project-settings-but-not-installed)介绍了相关规则。

4230 4290 

4231* **作用域**:[`Any file`](#scopes)。只有在您接受该文件夹的工作区信任对话框后,Claude Code 才会识别仓库的 `.claude/settings.json` 或 `.claude/settings.local.json` 中的条目;在您尚未信任的文件夹中(包括在那里执行的 `-p` 运行),它会忽略这些条目且不显示消息。4291* **作用域**:[`Any file`](#scopes)。只有在您接受该文件夹的工作区信任对话框后,Claude Code 才会识别仓库的 `.claude/settings.json` 或 `.claude/settings.local.json` 中的条目;在您尚未信任的文件夹中(包括在那里执行的 `-p` 运行),它会忽略这些条目且不显示消息。

4232* **类型**:将市场名称映射到对象的对象,该对象包含一个 `source` 对象和一个可选的 `autoUpdate` Boolean4292* **类型**:将市场名称映射到对象的对象,该对象包含一个 `source` 对象和一个可选的 `autoUpdate` Boolean


4354 4414 

4355列出托管插件,其 [mod](https://code.claude.com/docs/zh-CN/plugins/mods/overview.md) 会按列出的顺序在用户安装的所有 mod 之前运行。在托管设置中设置此键时,请在列表中指定 `sec-default@builtin` 以保留内置守卫。在托管设置中,如果某个 id 对应的插件不算作您组织的插件,Claude Code 会跳过它。有关这些条件以及两个排序键如何协同工作,请参阅[安装您组织的 mod 并设置顺序](https://code.claude.com/docs/zh-CN/plugins/mods/admin.md#install-your-organizations-mods)。4415列出托管插件,其 [mod](https://code.claude.com/docs/zh-CN/plugins/mods/overview.md) 会按列出的顺序在用户安装的所有 mod 之前运行。在托管设置中设置此键时,请在列表中指定 `sec-default@builtin` 以保留内置守卫。在托管设置中,如果某个 id 对应的插件不算作您组织的插件,Claude Code 会跳过它。有关这些条件以及两个排序键如何协同工作,请参阅[安装您组织的 mod 并设置顺序](https://code.claude.com/docs/zh-CN/plugins/mods/admin.md#install-your-organizations-mods)。

4356 4416 

4357* **作用域**:[`User or managed`](#scopes)。Claude Code 从托管设置中读取此键。仅当机器上没有托管设置,且会话的凭据不是 Team 或 Enterprise `/login` 时,它才会从用户设置中读取此键。它会忽略项目设置、本地设置以及 `--settings` 文件中的此键。4417* **作用域**:[`User or managed`](#scopes)。Claude Code 从托管设置中读取此键。仅当机器上既没有托管设置也没有 `managed-mcp.json` 文件,且会话的凭据不是 Team 或 Enterprise `/login` 时,它才会从用户设置中读取此键。它会忽略项目设置、本地设置以及 `--settings` 文件中的此键。

4358* **类型**:`plugin-name@marketplace-name` 字符串数组4418* **类型**:`plugin-name@marketplace-name` 字符串数组

4359* **默认值**:未设置4419* **默认值**:未设置

4360 4420 


4374 4434 

4375列出托管插件,其 [mod](https://code.claude.com/docs/zh-CN/plugins/mods/overview.md) 会按列出的顺序在用户安装的所有 mod 之后运行。同时列在 `prependPlugins` 和 `appendPlugins` 中的 id 会被前置。在托管设置中,如果某个 id 对应的插件不[算作您组织的插件](https://code.claude.com/docs/zh-CN/plugins/mods/admin.md#install-your-organizations-mods),Claude Code 会跳过它。4435列出托管插件,其 [mod](https://code.claude.com/docs/zh-CN/plugins/mods/overview.md) 会按列出的顺序在用户安装的所有 mod 之后运行。同时列在 `prependPlugins` 和 `appendPlugins` 中的 id 会被前置。在托管设置中,如果某个 id 对应的插件不[算作您组织的插件](https://code.claude.com/docs/zh-CN/plugins/mods/admin.md#install-your-organizations-mods),Claude Code 会跳过它。

4376 4436 

4377* **作用域**:[`User or managed`](#scopes)。Claude Code 从托管设置中读取此键。仅当机器上没有托管设置,且会话的凭据不是 Team 或 Enterprise `/login` 时,它才会从用户设置中读取此键。它会忽略项目设置、本地设置以及 `--settings` 文件中的此键。4437* **作用域**:[`User or managed`](#scopes)。Claude Code 从托管设置中读取此键。仅当机器上既没有托管设置也没有 `managed-mcp.json` 文件,且会话的凭据不是 Team 或 Enterprise `/login` 时,它才会从用户设置中读取此键。它会忽略项目设置、本地设置以及 `--settings` 文件中的此键。

4378* **类型**:`plugin-name@marketplace-name` 字符串数组4438* **类型**:`plugin-name@marketplace-name` 字符串数组

4379* **默认值**:未设置4439* **默认值**:未设置

4380 4440 


4612 4672 

4613### `crossSessionInbound`4673### `crossSessionInbound`

4614 4674 

4615选择此会话如何处理[来自您其他 Claude Code 会话的消息](https://code.claude.com/docs/zh-CN/cross-session-messaging.md#control-inbound-messages)。当没有适用的值时,Claude Code 会根据两个会话的权限模式类别逐条消息做出决定。需要 Claude Code v2.1.224 或更高版本。4675选择此会话如何处理[来自您其他 Claude Code 会话的消息](https://code.claude.com/docs/zh-CN/cross-session-messaging.md#control-inbound-messages)。当没有适用的值时,Claude Code 会根据两个会话的权限模式类别逐条消息做出决定。

4616 4676 

4617* **作用域**:[`任意文件`](#scopes)。项目或本地值仅在比托管设置、`--settings` 标志或用户设置给出的值更严格时才生效。4677* **作用域**:[`任意文件`](#scopes)。项目或本地值仅在比托管设置、`--settings` 标志或用户设置给出的值更严格时才生效。

4618* **类型**:字符串,取值之一:4678* **类型**:字符串,取值之一:


4946}5006}

4947```5007```

4948 5008 

5009### `disableRemotePreviewScripts`

5010 

5011当用户在桌面应用中从 SSH 或 WSL 会话[预览 HTML 文件](https://code.claude.com/docs/zh-CN/desktop.md#preview-html-files-in-ssh-and-wsl-sessions)时,阻止脚本运行。Browser 窗格中的外部浏览不受影响。

5012 

5013桌面应用读取此设置项;终端 CLI 会忽略它。需要 Claude Desktop v5.1231.0 或更高版本。更早的版本会忽略此设置项:要在这些版本中阻止脚本运行,还需设置 [`disableBrowserExternalNavigation`](#disablebrowserexternalnavigation),它也会关闭外部浏览。

5014 

5015* **作用域**:[`Managed`](#scopes)。桌面应用不会从远程机器或 WSL 发行版读取此设置项。

5016* **类型**:Boolean;只有 JSON Boolean `true` 才会生效

5017 * `true`:SSH 和 WSL 会话中的 HTML 预览不运行脚本

5018 * `false`:此设置项不会关闭脚本

5019* **默认值**:未设置,因此此设置项不起作用

5020 

5021如果运行桌面应用的计算机未收到任何其他 Claude Code 托管设置,还需在您创建的托管设置中将 [`parentSettingsBehavior`](#parentsettingsbehavior) 设置为 `"merge"`。在 Windows 上,如果您创建托管设置文件,用户还会失去 WSL 会话,直到您[允许这些会话](https://code.claude.com/docs/zh-CN/admin-setup.md#wsl-sessions-in-claude-code-desktop)。[为您的组织关闭 SSH 和 WSL 预览中的脚本](https://code.claude.com/docs/zh-CN/desktop.md#turn-off-scripts-in-ssh-and-wsl-previews-for-your-organization)对这两点进行了说明,并介绍了在何处设置此设置项。

5022 

5023此示例仅显示此设置项本身,即您将其添加到计算机已接收的托管设置中时的写法:

5024 

5025```json managed-settings.json theme={null}

5026{

5027 "disableRemotePreviewScripts": true

5028}

5029```

5030 

5031桌面应用会忽略任何其他值,而非 Boolean 的值(例如字符串 `"true"` 或 `1`)还会记录一条警告。

5032 

4949### `enableArtifact`5033### `enableArtifact`

4950 5034 

4951关闭 [Artifact](https://code.claude.com/docs/zh-CN/artifacts.md) 工具,该工具会将会话输出发布为 claude.ai 上的私有网页。当您在 `/config` 中关闭 **Artifacts** 行时,Claude Code 会将此设置项写入您的用户设置,因此您通常无需手动编辑它。5035关闭 [Artifact](https://code.claude.com/docs/zh-CN/artifacts.md) 工具,该工具会将会话输出发布为 claude.ai 上的私有网页。当您在 `/config` 中关闭 **Artifacts** 行时,Claude Code 会将此设置项写入您的用户设置,因此您通常无需手动编辑它。


5219 5303 

5220### `forceLoginMethod`5304### `forceLoginMethod`

5221 5305 

5222限制用户可以使用哪种账户登录。设置为 `"claudeai"` 仅允许 claude.ai 账户,设置为 `"console"` 仅允许 Claude Console 账户,设置为 `"gateway"` 则将用户引导至 [cloud gateway](https://code.claude.com/docs/zh-CN/claude-apps-gateway),而不是第一方登录。管理员在托管设置中设置此项,并与 [`forceLoginOrgUUID`](#forceloginorguuid) 搭配使用,使开发者的 claude.ai 登录限定在一个组织内。5306限制用户可以使用哪种账户登录:`"claudeai"` 表示 claude.ai 登录,`"console"` 表示 Claude Console 登录。设置为 `"gateway"` 则将用户引导至 [cloud gateway](https://code.claude.com/docs/zh-CN/claude-apps-gateway),而不是第一方登录。管理员在托管设置中设置此项,并与 [`forceLoginOrgUUID`](#forceloginorguuid) 搭配使用,使开发者的 claude.ai 登录限定在一个组织内。

5223 5307 

5224如果您在任何设置文件中将其设置为 `"claudeai"`,Claude Code 还会在该文件适用的会话中停止提供[无密钥 Console 登录](https://code.claude.com/docs/zh-CN/authentication.md#sign-in-without-an-api-key)。仅设置 `"console"` 时,用户在登录失败后仍可访问无密钥登录。要让 Claude Code 停止提供该登录方式,请参阅[在托管机器上停止提供无密钥登录](https://code.claude.com/docs/zh-CN/authentication.md#stop-offering-the-keyless-sign-in-on-managed-machines),其中还列出了 `forceLoginOrgUUID` 带来的其他变化。5308如果您在任何设置文件中将其设置为 `"claudeai"`,Claude Code 还会在该文件适用的会话中停止提供[无密钥 Console 登录](https://code.claude.com/docs/zh-CN/authentication.md#sign-in-without-an-api-key)。仅设置 `"console"` 时,用户在登录失败后仍可访问无密钥登录。要让 Claude Code 停止提供该登录方式,请参阅[在托管机器上停止提供无密钥登录](https://code.claude.com/docs/zh-CN/authentication.md#stop-offering-the-keyless-sign-in-on-managed-machines),其中还列出了 `forceLoginOrgUUID` 带来的其他变化。

5225 5309 

5226* **作用域**:[`Any file`](#scopes)。Claude Code 仅在与 [`forceLoginGatewayUrl`](#forcelogingatewayurl) 相同的来源中认可 `"gateway"`,在其他任何地方都将其视为未设置。5310* **作用域**:[`Any file`](#scopes)。Claude Code 仅在与 [`forceLoginGatewayUrl`](#forcelogingatewayurl) 相同的来源中认可 `"gateway"`,在其他任何地方都将其视为未设置。

5227* **类型**:字符串,以下之一:5311* **类型**:字符串,以下之一:

5228 * `"claudeai"`:只有 claude.ai 账户可以登录5312 * `"claudeai"`:claude.ai 登录

5229 * `"console"`:只有 Claude Console 账户可以登录5313 * `"console"`:Claude Console 登录

5230 * `"gateway"`:Claude Code 将用户引导至 cloud gateway,而不是第一方登录5314 * `"gateway"`:Claude Code 将用户引导至 cloud gateway,而不是第一方登录

5231* **默认值**:未设置,因此用户自行选择登录方式5315* **默认值**:未设置,因此用户自行选择登录方式

5232 5316 


5471 5555 

5472设置 Claude Code 在删除[会话记录和其他应用程序数据](https://code.claude.com/docs/zh-CN/claude-directory.md#cleaned-up-automatically)之前保留它们的天数。只要 Claude Code 能够安全地确定保留期限,它就会在会话启动后以后台清理的方式执行删除。清理在删除会话记录时不会显示任何消息,因此超过保留期限未使用的会话将不再出现在 [`/resume`](https://code.claude.com/docs/zh-CN/sessions#resume-a-session) 选择器中。5556设置 Claude Code 在删除[会话记录和其他应用程序数据](https://code.claude.com/docs/zh-CN/claude-directory.md#cleaned-up-automatically)之前保留它们的天数。只要 Claude Code 能够安全地确定保留期限,它就会在会话启动后以后台清理的方式执行删除。清理在删除会话记录时不会显示任何消息,因此超过保留期限未使用的会话将不再出现在 [`/resume`](https://code.claude.com/docs/zh-CN/sessions#resume-a-session) 选择器中。

5473 5557 

5558默认情况下,对于您在 Claude Desktop 或 Cowork 中启动或最近继续的会话,Claude Code 会在超过此期限后继续保留其会话记录,即使您自己设置了此键也是如此。在某些情况下(例如在 HIPAA 配置下),[此期限仍适用于这些会话记录](https://code.claude.com/docs/zh-CN/claude-directory.md#cleaned-up-automatically)。在 v2.1.248 之前,Claude Code 会在此期限后删除它们。

5559 

5474* **作用域**:[`任意文件`](#scopes)5560* **作用域**:[`任意文件`](#scopes)

5475* **类型**:天数,整数,最小值为 `1`5561* **类型**:天数,整数,最小值为 `1`

5476* **默认值**:`30`5562* **默认值**:`30`


5485 5571 

5486### `desktopSessionCleanupPeriodDays`5572### `desktopSessionCleanupPeriodDays`

5487 5573 

5488为您在 Claude Desktop 或 Cowork 中启动或最近继续的会话的会话记录设置以天为单位的期限。如果未设置此键,Claude Code 会[无论时长都保留这些会话记录](https://code.claude.com/docs/zh-CN/claude-directory.md#cleaned-up-automatically)。当每条会话记录的时长同时超过此期限和 [`cleanupPeriodDays`](#cleanupperioddays) 时,Claude Code 会将其删除,因此在 `cleanupPeriodDays` 为默认值 30 的情况下,值 `7` 仍会保留它们 30 天。[自动清理](https://code.claude.com/docs/zh-CN/claude-directory.md#cleaned-up-automatically)列出了改用 `cleanupPeriodDays` 且 Claude Code 忽略此键的情况。需要 Claude Code v2.1.248 或更高版本。5574为您在 Claude Desktop 或 Cowork 中启动或最近继续的会话的会话记录设置以天为单位的期限。如果未设置此键,Claude Code 会[无论时长都保留这些会话记录](https://code.claude.com/docs/zh-CN/claude-directory.md#cleaned-up-automatically),但某些情况除外,例如您在 Claude Desktop 中删除的会话。需要 Claude Code v2.1.248 或更高版本。

5575 

5576当每条会话记录的时长同时超过此期限和 [`cleanupPeriodDays`](#cleanupperioddays) 时,Claude Code 会将其删除,因此在 `cleanupPeriodDays` 为默认值 30 的情况下,值 `7` 仍会保留它们 30 天。[自动清理](https://code.claude.com/docs/zh-CN/claude-directory.md#cleaned-up-automatically)列出了改用 `cleanupPeriodDays` 且 Claude Code 忽略此键的情况。

5489 5577 

5490* **作用域**:[`用户或托管`](#scopes)。Claude Code 也会从您通过 `--settings` 传入的文件中读取此键,并在项目设置和本地设置中忽略它。5578* **作用域**:[`用户或托管`](#scopes)。Claude Code 也会从您通过 `--settings` 传入的文件中读取此键,并在项目设置和本地设置中忽略它。

5491* **类型**:天数,整数,最小值为 `0`5579* **类型**:天数,整数,最小值为 `0`