Claude Code v2.1.323:新增Code Mode实验功能,修复大量安全与认证问题
v2.1.323
推荐理由
本次更新包含多项 Bash 权限检查绕过和沙箱失效的安全修复,以及严重的后台会话身份漂移问题。建议开发者立即升级以消除潜在的安全风险,并启用新的 Code Mode 提升自动化效率。
What's changed
变更内容
- Added Code Mode, an experimental opt-in in which Claude writes JavaScript to call its tools; see https://code.claude.com/docs/en/code-mode to turn it on, or to turn it off for an organization
- Added engines["claude-code"] to plugin.json: plugins outside their stated Claude Code version range are not installed, updated or loaded, and install and update pick the newest version that fits
- Added type checking of a plugin's TypeScript hooks module to claude plugin validate; each finding is a warning, and --strict fails on it
- Added to claude plugin validate the $ nouns a mod's engine.create hook adds, withholds or replaces
- Added support for CLAUDE_CODE_AUTO_MODE_MODEL in managed settings for Claude Desktop sessions on third-party providers (takes effect once Claude Desktop includes this version)
- Added an options menu (stop, switch to usage credits, upgrade) when a model needs usage credits that are turned off or used up
- Added a progress heartbeat every 30 seconds while hooks run long in claude -p and SDK sessions, so a host such as Claude Desktop won't end the turn as hung (once it includes this version)
- Added .docx support to Artifact tool asset uploads
- Added a /diff to close hint to the diff panel, and the keys that focus and close a panel to the ? shortcut guide
- Added a start-up warning for Bash allow rules with a * in a variable's value, such as Bash(PORT=* npm run dev)
- Added a warning when a plugin's language server can't start, naming the server and what to check
- Added a one-time startup notice naming CLAUDE_CODE_PERFORCE_MODE when Perforce settings are found and the mode is off
- Added CLAUDE_CODE_DISABLE_AGENT_PROGRESS_SUMMARIES (available since 2.1.318): set it to 1 to turn off subagent progress summaries and the requests that write them (#86879)
- Added CLAUDE_CODE_RESUME_HINT_COMMAND, which a program that starts Claude Code can set to have the exit hint name its own resume command
- Added unsetOptionCount to the claude plugin install --json result: how many userConfig options are not yet set
- Added isPromptCovered to the props a mod's pane is drawn with, telling it when a dialog or a field above the prompt covers the prompt
- Fixed running /compact again, or after a command such as /context, summarizing away a message that Claude had not answered yet
- Fixed a resumed session joining your next message to an old interrupted message that was not resumed
- Fixed a memory spike at the next prompt after Claude changed a very large file
- Fixed a setting saved in a running session undoing a hand edit made to settings.json moments earlier; a settings file you delete during a session now stays deleted
- Fixed claude plugin commands and claude mcp list signing you out of a Console profile when they ended while the token was being renewed
- Fixed Edit and Bash running out of memory on certain /proc files, and Edit hanging or running out of memory on devices and named pipes
- Fixed Claude Code failing to start, or to clear stored credentials at sign-out, when saving its configuration file failed with "Out of memory"
- Fixed requests sent without streaming failing on errors that streamed requests recover from, such as a rejected image, thinking block or beta header
- Fixed ExitWorktree, the worktree exit dialog and /resume leaving the session in the wrong folder when the folder the shell was in before entering the worktree had been deleted
- Fixed accents and other combining marks sometimes landing left of the text, leaving stale copies on screen, or silently disappearing when text wraps
- Fixed the last key of a key chord, such as Enter in ctrl+x enter, acting on a dialog's text field when the chord's own action isn't available there
- Fixed ps processes piling up when the process listing Claude Code runs before stopping a command takes too long
- Fixed subagent transcripts and large tool results being saved apart from the session's transcript after entering a worktree created by a WorktreeCreate hook or belonging to a nested repository
- Fixed a session on a named Anthropic profile moving to another sign-in when /fork, the Left arrow or --bg continued it in the background; reopen any session that was open during the update
- Fixed a background session sending a conversation under another sign-in when its named Anthropic profile is missing, changed or overridden; it now stops and says so
- Fixed a session on an API key, auth token or workload identity from its shell (not a setup token) moving to another sign-in in the background; it now stops and says so
- Fixed MCP tool calls ending in the sign-in server's error, such as TOKEN_EXPIRED, instead of asking you to sign in again
- Fixed an expired claude.ai login showing "Credit balance too low" when a saved Console key or ant auth login profile without credit was used instead
- Fixed a session on a named Anthropic profile being handed to an older background service that could not keep its sign-in; it now says to restart the service
- Fixed a background session's sign-in leaving the previous account's login or other credentials in place; it now clears them for every session on the computer, and a refused sign-in can leave no login
- Fixed background sessions moving between a profile and the stored login when an update restarted them
- Fixed sessions opened before a sign-in keeping signed-out feature flags after the sign-in
- Fixed sessions that kept failing after a Claude apps gateway sign-in expired: once you sign in again with /login in another terminal, they carry on at the next message
- Fixed the billing notice naming your ant auth login organization when a custom X-Api-Key header is set
- macOS: Fixed "Not logged in · Please run /login" coming back right after a successful /login or a token refresh when the keychain was slow to answer
- Fixed turns failing in Claude Desktop when an organization's gateway answers an expired token with 403: Claude Code now asks Desktop for a fresh token and retries
- Fixed the error shown when Amazon Bedrock refuses your account a model: it no longer says to refresh your AWS credentials, it says to enable the model
- Fixed the awsAuthRefresh or gcpAuthRefresh command sometimes running twice for one request when three or more sessions needed a fresh sign-in at once
- Fixed the claude -p warning about an ended claude.ai login to say that claude auth logout also removes saved MCP server logins and plugin secrets
- Fixed Bash permission prompts offering "don't ask again" for commands that write to sensitive paths such as .git or .claude, where the saved rule did not stop the next prompt
- Fixed a case where some lsof commands ran without a permission prompt
- Fixed Bash commands that write a file with cat > file <<EOF being shown as "Read 1 file"
- Fixed a case where Bash permission checks judged an rm from the wrong folder and skipped the dangerous-removal prompt under bypass permissions or a Bash allow rule
- Fixed --permission-mode auto or a settings defaultMode: auto starting in a mode that could allow more when auto mode was unavailable. It now starts in Manual mode, which asks first
- Fixed plan files sometimes being written outside the project when plansDirectory is set; a write that can't be shown to stay inside the project is now refused
- Fixed a permission prompt when Claude read the output of its own background command or agent after entering a worktree
- Fixed a case where Bash permission checks missed part of a command
- Fixed a case where the Bash sandbox could switch off during a session
- Fixed Bash allow rules with an attached wildcard, such as Bash(ls*), skipping the permission prompt in some cases; a rule that names a variable, such as Bash(NODE_ENV*), now asks
- Fixed auto mode running behind a gateway at ANTHROPIC_BASE_URL on a model whose gateway name contains "haiku"; such a model, other than claude-haiku-5-5, is now refused, as Haiku 4.5 is
- 新增 Code Mode(代码模式),这是一个实验性的可选功能,Claude 会编写 JavaScript 来调用其工具;请参阅 https://code.claude.com/docs/en/code-mode 以开启该功能,或为组织关闭它
- 在 plugin.json 中添加了 engines["claude-code"]:超出其声明的 Claude Code 版本范围的插件将不会被安装、更新或加载,且安装和更新操作会选择符合范围的最新版本
- 在 claude plugin validate 中增加了对插件 TypeScript hooks 模块的类型检查;每个发现的问题都会作为警告显示,而使用 --strict 参数时则会将其视为失败
- 在 claude plugin validate 中增加了对 mod 的 engine.create hook 添加、保留或替换的 $ 名词的检查
- 为第三方提供商上的 Claude Desktop 会话的管理设置新增了对 CLAUDE_CODE_AUTO_MODE_MODEL 的支持(需 Claude Desktop 包含此版本后生效)
- 当模型需要但已关闭或用尽使用额度时,新增一个选项菜单(停止、切换至使用额度、升级)
- 在 claude -p 和 SDK 会话中,当 hooks 运行时间过长时,每 30 秒发送一次进度心跳信号,以防止主机(如 Claude Desktop)将当前轮次判定为挂起(需主机包含此版本后生效)
- Artifact 工具的文件上传功能新增对 .docx 格式的支持
- 在 diff 面板中新增了用于关闭提示的 /diff 命令,并在 ? 快捷键指南中增加了聚焦和关闭面板的按键说明
- 当 Bash 允许规则中的变量值包含 * 时(例如 Bash(PORT=* npm run dev)),新增启动警告
- 当插件的语言服务器无法启动时,新增警告信息,指明服务器名称及需要检查的内容
- 当检测到 Perforce 设置且该模式处于关闭状态时,新增一次性启动通知,指明 CLAUDE_CODE_PERFORCE_MODE
- 新增 CLAUDE_CODE_DISABLE_AGENT_PROGRESS_SUMMARIES(自 2.1.318 版本起可用):将其设置为 1 可关闭子代理进度摘要及其写入请求 (#86879)
- 新增 CLAUDE_CODE_RESUME_HINT_COMMAND,启动 Claude Code 的程序可设置此变量,以便退出提示能指明其自身的恢复命令
- 在 claude plugin install --json 的结果中新增 unsetOptionCount:表示尚未设置的 userConfig 选项数量
- 在 mod 的面板绘制属性中新增 isPromptCovered,用于告知面板何时对话框或输入框上方的字段覆盖了提示区域
- 修复了再次运行 /compact 或在执行 /context 等命令后,将 Claude 尚未回复的消息进行摘要处理的问题
- 修复了恢复会话时将你的下一条消息附加到未恢复的旧中断消息上的问题
- 修复了 Claude 修改超大文件后,下一个提示处出现的内存激增问题
- 修复了运行中的会话中保存的设置会撤销对 settings.json 的先前手动编辑的问题;在会话期间删除的设置文件现在会保持删除状态
- 修复了 claude 插件命令和 claude mcp list 在 token 续期过程中结束时,导致从 Console 配置文件中登出的问题
- 修复了 Edit 和 Bash 在处理某些 /proc 文件时内存耗尽,以及在设备和命名管道上卡死或内存耗尽的问题
- 修复了当保存配置文件失败并提示“内存不足”时,Claude Code 无法启动或在登出时无法清除已存储凭据的问题
- 修复了未使用流式传输的请求在处理可恢复的错误(如被拒绝的图片、思考块或 beta 标头)时失败的问题
- 修复了 ExitWorktree、worktree 退出对话框和 /resume 在进入 worktree 之前 shell 所在的文件夹已被删除时,将会话留在错误文件夹中的问题
- 修复了重音符号和其他组合标记有时出现在文本左侧、屏幕上残留旧副本,或在文本换行时无声消失的问题
- 修复了键序列(如 ctrl+x enter 中的 Enter)的最后一个键在键序列自身的操作不可用时,作用于对话框文本字段的问题
- 修复了 Claude Code 在停止命令前运行的进程列表耗时过长,导致 ps 进程堆积的问题
- 修复了子代理转录记录和大型工具结果在输入由 WorktreeCreate 钩子创建的 worktree 或属于嵌套仓库的 worktree 后,与主会话转录记录分开保存的问题
- 修复了在使用 /fork、左箭头键或 --bg 在后台继续运行时,基于命名 Anthropic 配置文件的会话切换到另一个登录账户的问题;请重新打开更新期间处于打开状态的会话
- 修复了当命名 Anthropic 配置文件缺失、更改或被覆盖时,后台会话在其他登录账户下发送对话的问题;现在它会停止并提示该情况
- 修复了基于其 shell 中的 API 密钥、身份验证令牌或工作负载身份(非安装令牌)的会话在后台切换到另一个登录账户的问题;现在它会停止并提示该情况
- 修复了 MCP 工具调用以登录服务器的错误(如 TOKEN_EXPIRED)结束,而不是要求您重新登录的问题
- 修复了当改用没有余额的已保存 Console 密钥或 ant auth 登录配置文件时,过期的 claude.ai 登录显示“信用余额过低”的问题
- 修复了基于命名 Anthropic 配置文件的会话被分配给无法维持其登录状态的旧后台服务的问题;现在它会提示重启服务
- 修复了后台会话登录时保留上一个账户的登录信息或其他凭据的问题;现在它会在计算机上的每个会话中清除这些凭据,且被拒绝的登录可能不会保留任何登录状态。
- 修复了在更新重启后,后台会话在配置文件和存储的登录信息之间移动的问题。
- 修复了在登录后,之前打开的会话仍保留已登出功能标志的问题。
- 修复了在 Claude 应用网关登录过期后会话持续失败的问题:一旦你在另一个终端中使用 /login 重新登录,它们将在下一条消息处继续运行。
- 修复了在设置自定义 X-Api-Key 标头时,计费通知错误地命名了你的 ant auth 登录组织的问题。
- macOS:修复了在成功执行 /login 或令牌刷新后,由于钥匙串响应缓慢而立即再次出现“未登录 · 请运行 /login”的问题。
- 修复了在组织的网关对过期令牌返回 403 时,Claude Desktop 中的回合失败的问题:Claude Code 现在会向 Desktop 请求新令牌并重试。
- 修复了当 Amazon Bedrock 拒绝你的账户使用某个模型时显示的错误信息:不再提示刷新 AWS 凭据,而是提示启用该模型。
- 修复了在三个或更多会话同时需要重新登录时,awsAuthRefresh 或 gcpAuthRefresh 命令有时因单个请求而运行两次的问题。
- 修复了 claude -p 关于已结束的 claude.ai 登录的警告,使其说明 claude auth logout 也会移除保存的 MCP 服务器登录信息和插件密钥。
- 修复了 Bash 权限提示为写入敏感路径(如 .git 或 .claude)的命令提供“不再询问”选项的问题,其中保存的规则未能阻止下一次提示。
- 修复了某些 lsof 命令在未进行权限提示的情况下运行的情况。
- 修复了使用 cat > file <<EOF 写入文件的 Bash 命令被显示为“读取 1 个文件”的问题。
- 修复了 Bash 权限检查误判来自错误文件夹的 rm 命令,并在绕过权限或 Bash 允许规则下跳过危险删除提示的情况。
- 修复了 --permission-mode auto 或 settings defaultMode: auto 在自动模式不可用时启动于可能允许更多操作的模式的问题。现在它启动于手动模式,该模式会先进行询问。
- 修复了在设置 plansDirectory 时计划文件有时被写入项目外的问题;无法确保留在项目内的写入操作现在会被拒绝。
- 修复了在进入工作树后,Claude 读取其自身后台命令或代理输出时的权限提示问题。
- 修复了 Bash 权限检查遗漏部分命令的情况。
- 修复了 Bash 沙箱在会话期间可能关闭的情况。
- 修复了附带通配符的 Bash 允许规则(如 Bash(ls*))在某些情况下跳过权限提示的问题;现在,命名变量的规则(如 Bash(NODE_ENV*))会进行询问
- 修复了在 ANTHROPIC_BASE_URL 网关后运行自动模式时,对网关名称包含 "haiku" 的模型的处理问题;除 claude-haiku-5-5 外,此类模型现均被拒绝,因为 Haiku 4.5 是
更进一步:量化金融体系
看懂新闻只是起点——沿量化金融路径,把它变成能交付的工程能力