Claude Code CLI指南:安裝、設定、指令與環境變數
# 完整的Claude Code CLI指南,已更新至v2.1.179。Tool(param:value)權限規則、巢狀.claude/skills、Claude Fable 5(Opus之上的新層級)、Opus 4.8預設值、enforceAvailableModels、--safe-mode、/cd、fallbackModel鏈、Bedrock/Vertex/Foundry上的Auto Mode、MCP、Agent View、外掛程式、hooks。
完整的Claude Code CLI指南,已更新至v2.1.179。Tool(param:value)權限規則、巢狀.claude/skills、Claude Fable 5(Opus之上的新層級)、Opus 4.8預設值、enforceAvailableModels、--safe-mode、/cd、fallbackModel鏈、Bedrock/Vertex/Foundry上的Auto Mode、MCP、Agent View、外掛程式、hooks。
TL;DR:Claude Code是一套 agentic CLI,能讀取您的程式碼庫、執行命令,並透過分層的權限、hooks、MCP整合與 subagents 系統修改檔案。掌握5個核心系統(configuration、permissions、hooks、MCP與 subagents),就能大幅提升生產力。依各任務選擇合適的 model tier:Opus 適合複雜推理,Sonnet 適合一般工作,Haiku 適合快速探索;若品質是唯一變數,也可統一使用 Opus。凡是必須每次都執行的事項,請使用 hooks(而非 prompts)。截至 v2.1.174–176(2026年6月12日),
availableModelsallowlist 現在可透過新的enforceAvailableModelsmanaged setting 限制 Default model(user/project settings 無法擴大 managed list),session titles 會以您對話的語言產生(可用languagesetting 固定語言),另有新的footerLinksRegexes與wheelScrollAccelerationEnabledsettings、VSCode/usageattribution dialog,以及修正 hookifconditions 可比對Read/Edit/Writepath patterns,讓此版本更加完整。172截至 v2.1.173(2026年6月11日),帶有[1m]suffix 的 Fable 5 model name 會自動正規化並移除該 suffix——Fable 5 預設已包含 1M context,因此 suffix 並非必要(它原本只對 Opus/Sonnet 有意義)。截至 v2.1.172(2026年6月10日),sub-agents 可遞迴產生自己的 sub-agents,最多深入5層;Bedrock 會在AWS_REGION未設定時從~/.aws讀取 region(/status會顯示來源);/plugin新增 marketplace search bar;claude_code.lines_of_code.countOTEL metric 新增modelattribute。截至 v2.1.170(2026年6月9日),Claude Fable 5——高於 Opus 的全新 model tier——在執行claude update後,可透過/model fable於 Claude Code 中選取(支援完整的low–maxeffort scale,但無法停用 thinking);Opus 4.8 仍是 agentic default。截至 v2.1.169(2026年6月8日),--safe-mode(以及CLAUDE_CODE_SAFE_MODE)會啟動停用所有自訂項目的乾淨 session,以利疑難排解;/cd可將 session 移至新的 working directory,且不破壞 prompt cache;disableBundledSkills會向 model 隱藏內建 skills 與 slash commands。截至 v2.1.166(2026年6月6日),fallbackModelsetting 可在主要 model 過載時串接最多3個備援 models;glob"*"可用於 MCP deny rules;MAX_THINKING_TOKENS=0/--thinking disabled可在預設啟用 thinking 的 models 上完全關閉 thinking。截至 v2.1.154(2026年5月28日),Opus 4.8 成為新的 default,預設使用 high effort,並新增/effort xhighlevel;dynamic workflows 會透過/workflows在背景編排數十到數百個 agents;Opus 4.8 的 Fast mode 費用為標準費率的2倍,速度為2.5倍;lean system prompt 現已成為所有 models 的預設,Haiku/Sonnet/Opus 4.7 及更早版本除外;/simplify回復為僅清理的 review(與/code-review --fix分開);claude agents接受! <command>以產生背景 shell sessions;plugins 可宣告defaultEnabled: false;streaming tool execution 一律啟用;stdio MCP servers 會在 env 中收到CLAUDE_CODE_SESSION_ID與CLAUDECODE=1。v2.1.153 為 plugin marketplaces 新增skipLfs,使/model會儲存為 default(按s則僅套用於 session),並在 status-line env 中加入COLUMNS/LINES。v2.1.152 引入/code-review --fix(將 findings 套用至 working tree)、skill frontmatter 中的disallowed-tools、/reload-skills、新的MessageDisplayhook event、SessionStarthook 的reloadSkills/sessionTitleoutputs、pluginSuggestionMarketplacesmanaged setting、session 中途切換--fallback-model,並移除 auto-mode opt-in。162 163 164 165 166 167 168 169 170 180 171
Claude Code是以 agentic system 運作,不是具備程式設計知識的 chat interface。CLI會讀取您的程式碼庫、執行命令、修改檔案、管理 git workflows、透過 MCP 連接外部服務,並將複雜任務委派給專門的 subagents。所有流程都經由 command-line interface,融入開發者實際工作的方式。截至2026年2月,公開 GitHub commits 中有4%(每天約135,000筆)由 Claude Code 撰寫——自 research preview 以來13個月成長了42,896倍——且 Anthropic 自身90%的程式碼由 AI 撰寫。103
隨興使用與有效使用 Claude Code 的差別,取決於5個核心系統。掌握這些系統後,Claude Code 就會成為倍增器:
- Configuration hierarchy:控制行為
- Permission system:把關操作
- Hook system:啟用確定性自動化
- MCP protocol:擴充能力
- Subagent system:處理複雜的多步驟任務
重要重點
- 5個系統決定您的成效:configuration hierarchy、permissions、hooks、MCP與 subagents,控制從行為到自動化的一切。
- 將工作推向 Delegation Layer:subagents 會把探索隔離在乾淨的 context windows 中,只回傳摘要,避免 context 膨脹。
- Hooks 保證執行;prompts 不保證:linting、formatting 與 security checks 等無論 model 行為如何都必須每次執行的事項,請使用 hooks。
- Model tiering 可在不犧牲品質的前提下降低成本:將 subagent exploration 導向較便宜的 models,並把 Opus 保留給真正的架構推理;若品質是唯一變數,也可統一使用 Opus。
- MCP 將 Claude 連上您的 toolchain:databases、GitHub、Sentry 與3,000多項 integrations,讓 Claude 超越檔案讀取與 bash commands。
我花了數月,在 production codebases、CI/CD pipelines 與 enterprise deployments 中將 Claude Code 推向極限。本指南將這些經驗濃縮成一份我剛開始時最希望擁有的完整參考。每項功能都包含實際 syntax、真實 configuration examples,以及連資深使用者也容易踩到的 edge cases。
選擇您的路徑
| 您需要什麼 | 前往這裡 |
|---|---|
| 安裝與第一次 session | 5分鐘快速開始 — 安裝、設定,並執行您的第一個 command |
| Commands 與 config 查詢 | Cheat Sheet — 以易掃讀表格整理每個 flag、shortcut 與 setting |
| 深入參考(本頁) | 繼續閱讀 — hooks、MCP、subagents、architecture、enterprise patterns |
如何使用本指南
這是一份超過5,000行的參考資料——您不需要從頭讀到尾。請從符合自身經驗程度的位置開始:
| 經驗 | 從這裡開始 | 接著探索 |
|---|---|---|
| 剛接觸 Claude Code | 如何安裝? → 快速開始 → Mental Model | Configuration、Permissions |
| 每日使用者 | Hooks、Subagents、Skills | MCP、Plan Mode |
| Team lead / enterprise | Enterprise Deployment → Best Practices | Decision Frameworks、Workflow Recipes |
| 從其他工具遷移 | Audience-Specific Guidance | Decision Frameworks |
使用瀏覽器的 Ctrl+F / Cmd+F 搜尋特定 flags、commands 或 configuration keys。文末的 Quick Reference Card 提供所有主要 commands 的易掃讀摘要。
相關深入文章
這些 blog posts 深入探討 Claude Code 的特定面向:
| 主題 | 文章 |
|---|---|
| Source internals:auto mode、bash security、caching | What the Claude Code Source Leak Reveals |
| Hooks 作為 orchestration layer | Anatomy of a Claw: 84 Hooks as an Orchestration Layer |
| Hook system patterns 與 examples | Claude Code Hooks Tutorial |
| Claude Code 作為 production infrastructure | Claude Code as Infrastructure |
| Autonomous agent architecture | Ralph Agent Architecture |
| Apple-platform agentic patterns | iOS Agent Development guide 與 Apple Ecosystem Series |
| iOS projects 的 XcodeBuildMCP integration | Two MCP Servers, One Xcode Project |
iOS 工作的 .pbxproj-protection hooks |
Hooks for Apple Development |
60秒快速開始
如果您只想執行Claude Code並查看輸出,請依序操作:
# 1. Install (pick one)
npm install -g @anthropic-ai/claude-code # npm users
brew install anthropic/claude/claude # macOS + Homebrew
curl -sL claude.ai/install.sh | sh # native installer
# 2. Launch in any project directory
cd ~/your-project && claude
# 3. Authenticate (browser opens automatically on first run)
/login
# 4. Ask your first question
> What does this repo do? Read the key files and summarize.
就是這樣。本節以下會延伸說明安裝選項、設定權限與 hooks、串接MCP伺服器,以及涵蓋企業部署;但開始使用並不需要這些內容。
先決條件:Node 18+僅適用於舊版 npm 路徑;建議使用的原生安裝程式不依賴 Node。支援 macOS / Linux / Windows 10+。Claude Pro、Max、Team 或 Enterprise 訂閱,或按 token 付費的Anthropic API金鑰,都可涵蓋使用量。平台細節、疑難排解,以及原生二進位檔路徑(自 v2.1.113 起為預設),請參閱如何安裝Claude Code?。本指南中的最新版本證據已對照 v2.1.154 檢查。180
Claude Code如何運作:心智模型
深入功能之前,請先了解Claude Code的架構如何形塑您使用它時的一切操作。此系統分為三層運作:
┌─────────────────────────────────────────────────────────┐
│ CLAUDE CODE LAYERS │
├─────────────────────────────────────────────────────────┤
│ EXTENSION LAYER │
│ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐ │
│ │ MCP │ │ Hooks │ │ Skills │ │ Plugins │ │
│ └─────────┘ └─────────┘ └─────────┘ └─────────┘ │
│ External tools, deterministic automation, domain │
│ expertise, packaged extensions │
├─────────────────────────────────────────────────────────┤
│ DELEGATION LAYER │
│ ┌─────────────────────────────────────────────────┐ │
│ │ Subagents (up to 10 parallel) │ │
│ │ Explore | Plan | General-purpose | Custom │ │
│ └─────────────────────────────────────────────────┘ │
│ Isolated contexts for focused work, returns summaries │
├─────────────────────────────────────────────────────────┤
│ CORE LAYER │
│ ┌─────────────────────────────────────────────────┐ │
│ │ Main Conversation Context │ │
│ │ Tools: Read, Edit, Bash, Glob, Grep, etc. │ │
│ └─────────────────────────────────────────────────┘ │
│ Your primary interaction; limited context; costs money │
└─────────────────────────────────────────────────────────┘
核心層:您的主要對話。每則訊息、檔案讀取與工具輸出,都會消耗共享視窗中的 context(標準為 200K tokens91,使用 Opus 4.6 或 extended context models 時為 1M tokens)。當 context 填滿時,Claude會失去對先前決策的掌握,品質也會下降。此層會按 token 產生成本。
委派層:Subagents 會以乾淨的 context 啟動,執行聚焦工作,並回傳摘要。探索結果不會膨脹您的主要對話;只有結論會回傳。可以將 subagents 指派到較便宜的 model tier 進行探索;若品質比成本更重要,也可以全程使用主要 model。
擴充層:MCP會連接外部服務(資料庫、GitHub、Sentry)。Hooks 可保證 shell commands 會執行,不受 model 行為影響。Skills 會編碼領域專業,讓Claude自動套用。Plugins 則將這些能力打包以便發佈。
關鍵洞見:多數使用者完全停留在核心層,看著 context 膨脹、成本攀升。進階使用者會把探索與專門工作推到委派層,讓擴充層維持符合自身工作流程的設定,並只把核心層用於協調與最終決策。
目錄
- 如何安裝Claude Code?
- 快速開始:您的第一次 session
- 核心互動模式
- 設定系統深入解析
- 我該選擇哪個 model?
- Claude Code費用是多少?
- 決策框架
- 權限系統如何運作?
- Hooks 如何運作?
- 什麼是MCP(Model Context Protocol)?
- 什麼是 Subagents?
- 什麼是 Extended Thinking Mode?
- 輸出樣式
- Slash Commands
- Skills 如何運作?
- Plugin System
- Memory 如何運作?
- 圖片與 Multimodal Input
- Voice Mode
- Git 整合如何運作?
- 如何在我的 IDE 中使用Claude Code?
- 進階使用模式
- Remote & Background Agents [RESEARCH PREVIEW]
- Chrome 中的Claude
- Slack 中的Claude Code [RESEARCH PREVIEW]
- Web 上的Claude Code [RESEARCH PREVIEW]
- 效能最佳化
- 如何偵錯問題?
- 企業部署
- 鍵盤快捷鍵參考
- 最佳實務
- Workflow Recipes
- Migration Guide
- 特定受眾指南
- 快速參考卡
- Changelog
- References
如何安裝Claude Code?
系統需求
Claude Code可在macOS 13+、Ubuntu 20.04+/Debian 10+以及Windows 10+(原生或WSL)上執行。系統需要至少4 GB記憶體與穩定的網際網路連線。92Shell相容性以Bash、Zsh或Fish最佳。
Windows方面,WSL 1與WSL 2均可運作。若您偏好原生Windows,Git Bash也可使用。Alpine Linux及其他基於musl的系統需要額外套件:
apk add libgcc libstdc++ ripgrep
export USE_BUILTIN_RIPGREP=0
平台支援矩陣
| 平台 | 是否支援 | 建議安裝方式 | 已知注意事項 |
|---|---|---|---|
| macOS 13+(Intel) | ✓ | 原生安裝程式或Homebrew | 無 |
| macOS 13+(Apple Silicon) | ✓ | 原生安裝程式或Homebrew | 無需Rosetta 2;自v2.1.113起提供原生arm64二進位檔 |
| Ubuntu 20.04+ | ✓ | 原生安裝程式 | v2.1.50修正了glibc < 2.30系統上的原生模組載入問題 |
| Debian 10+ | ✓ | 原生安裝程式 | 與Ubuntu相同的glibc相容性備註 |
| Fedora / RHEL 8+ | 盡力支援(非官方目標) | 原生安裝程式 | 仰賴v2.1.50相同的glibc相容性修正;RHEL 7非經測試之目標 |
| Alpine / musl | ✓(需apk add libgcc libstdc++ ripgrep與USE_BUILTIN_RIPGREP=0) |
原生安裝程式 | 由於內建版本僅支援glibc,需使用自訂ripgrep |
| Windows 10+(x64原生) | ✓ | 原生安裝程式(PowerShell)或winget | PowerShell工具需要CLAUDE_CODE_USE_POWERSHELL_TOOL=1環境變數(v2.1.111+) |
| Windows 10+(ARM64原生) | ✓ | 原生安裝程式 | 自v2.1.41起新增 |
| Windows 10+(WSL 1) | ✓ | 在WSL中使用原生安裝程式 | 盡可能優先使用WSL 2 |
| Windows 10+(WSL 2) | ✓ | 在WSL中使用原生安裝程式 | 推薦的Windows路徑,與Linux表現一致 |
| Windows 10+(Git Bash) | ✓ | 原生安裝程式 | 若自動偵測失敗,請設定CLAUDE_CODE_GIT_BASH_PATH(v2.1.98+) |
| Docker sandbox | ✓(實驗性) | docker sandbox run claude |
詳見上方安裝矩陣列;容器層級隔離 |
安裝、更新、解除安裝速查
可快速掃描的查詢表——所有方式、所有指令、版本檢查一次呈現。下方各小節涵蓋每種方式的特定細節與疑難排解。
| 方式 | 安裝 | 更新 | 解除安裝 | 版本檢查 |
|---|---|---|---|---|
| 原生安裝程式(macOS / Linux / WSL) | curl -fsSL https://claude.ai/install.sh \| bash |
claude update(或自動更新;參見DISABLE_AUTOUPDATER) |
rm -f ~/.local/bin/claude && rm -rf ~/.local/share/claude |
claude --version |
| 原生安裝程式(Windows PowerShell) | irm https://claude.ai/install.ps1 \| iex |
claude update |
Remove-Item -Path "$env:USERPROFILE\.local\bin\claude.exe" -Force; Remove-Item -Path "$env:USERPROFILE\.local\share\claude" -Recurse -Force |
claude --version |
| 原生安裝程式(Windows CMD) | curl -fsSL https://claude.ai/install.cmd -o install.cmd && install.cmd && del install.cmd |
claude update |
參見PowerShell列 | claude --version |
| Homebrew(macOS / Linux,穩定版) | brew install --cask claude-code |
brew upgrade --cask claude-code |
brew uninstall --cask claude-code |
claude --version |
| Homebrew(macOS / Linux,最新通道) | brew install --cask claude-code@latest |
brew upgrade --cask claude-code@latest |
brew uninstall --cask claude-code@latest |
claude --version |
| winget(Windows) | winget install Anthropic.ClaudeCode |
winget upgrade Anthropic.ClaudeCode |
winget uninstall Anthropic.ClaudeCode |
claude --version |
| npm(舊式,自v2.1.15起已棄用) | npm install -g @anthropic-ai/claude-code |
npm install -g @anthropic-ai/claude-code@latest |
npm uninstall -g @anthropic-ai/claude-code |
claude --version |
| Docker sandbox(實驗性) | 依照docker sandbox run CLI參考文件使用docker sandbox run claude;Claude Code sandbox快速入門展示等效的sbx run claude簡寫 |
拉取最新映像檔標籤 | 依Docker文件移除容器與映像檔 | 檢查映像檔標籤 |
自v2.1.113起,標準的CLI透過各平台特定的選用相依套件來啟動原生Claude Code二進位檔,而非使用打包的JavaScript——請對已測試的發行版使用原生安裝程式。npm路徑仍可運作,但會率先收到自v2.1.15起新增的棄用通知。
安裝方式
原生安裝(建議)
原生二進位檔提供最簡潔的體驗,無需Node.js相依:
# macOS and Linux
curl -fsSL https://claude.ai/install.sh | bash
# Homebrew alternative
brew install --cask claude-code
# Windows PowerShell
irm https://claude.ai/install.ps1 | iex
# Windows CMD
curl -fsSL https://claude.ai/install.cmd -o install.cmd && install.cmd && del install.cmd
針對特定版本安裝:
# Install specific version
curl -fsSL https://claude.ai/install.sh | bash -s 1.0.58
# Install latest explicitly
curl -fsSL https://claude.ai/install.sh | bash -s latest
# Windows PowerShell - specific version
& ([scriptblock]::Create((irm https://claude.ai/install.ps1))) 1.0.58
NPM安裝(已棄用)
注意:自v2.1.15起,npm安裝會顯示棄用通知。原生二進位檔現為建議的安裝方式。請使用
claude install進行遷移。
對於仍需使用npm的舊環境:
npm install -g @anthropic-ai/claude-code
切勿在npm安裝時使用sudo,這會造成權限問題並導致後續一連串的麻煩。
從現有安裝遷移
若您有較舊的npm安裝,請遷移至原生二進位檔:
claude install
驗證選項
Claude Code支援三種驗證路徑,各有不同的取捨:
Claude Console(API計費)
透過platform.claude.com(先前為console.anthropic.com)直接連線至Anthropic的API。建立帳戶、設定計費,並透過CLI進行驗證。Console提供按用量計費並可完整存取API。系統會自動建立專屬的「Claude Code」工作區;您無法為此工作區建立API金鑰,但可以監控用量。
Claude Pro或Max訂閱
使用您的claude.ai帳戶憑證。此訂閱以單一月費方案同時涵蓋網頁介面與CLI使用。對於希望成本可預測的個人使用者而言,訂閱簡化了計費流程。
企業平台
AWS Bedrock、Google Vertex AI與Microsoft Foundry皆提供企業級存取,並沿用既有的雲端計費關係。Bedrock設定精靈(v2.1.92+):登入畫面上的互動式精靈會引導您完成AWS驗證、區域選擇、憑證驗證以及模型釘選。137 Vertex AI設定精靈(v2.1.98+):Google Cloud的對應精靈,引導GCP驗證、專案與區域設定、憑證驗證以及模型釘選。142 Vertex AI mTLS Workload Identity Federation(v2.1.121+):Vertex AI現已接受基於X.509憑證的Workload Identity Federation(mTLS Application Default Credentials)——由用戶端憑證所產生的短期GCP權杖,無需服務帳戶JSON。154 OS CA憑證信任(v2.1.101+):企業TLS代理現可預設運作——Claude Code信任作業系統憑證儲存區。設定CLAUDE_CODE_CERT_STORE=bundled則僅使用打包的CA。143
# AWS Bedrock
export CLAUDE_CODE_USE_BEDROCK=1
export AWS_REGION=us-east-1
export AWS_PROFILE=your-profile
# Google Vertex AI
export CLAUDE_CODE_USE_VERTEX=1
export CLOUD_ML_REGION=us-east5
export ANTHROPIC_VERTEX_PROJECT_ID=your-project
# Microsoft Foundry
export CLAUDE_CODE_USE_FOUNDRY=1
export ANTHROPIC_FOUNDRY_RESOURCE=your-resource-name
# Optional: API key auth (otherwise uses Entra ID)
export ANTHROPIC_FOUNDRY_API_KEY=your-key
# Amazon Bedrock via Mantle (v2.1.94+)
export CLAUDE_CODE_USE_MANTLE=1
針對位於代理伺服器後方或透過LLM閘道的企業部署:
# Corporate proxy
export HTTPS_PROXY='https://proxy.example.com:8080'
# LLM gateway (skip native auth)
export CLAUDE_CODE_USE_BEDROCK=1
export ANTHROPIC_BEDROCK_BASE_URL='https://your-gateway.com/bedrock'
export CLAUDE_CODE_SKIP_BEDROCK_AUTH=1
驗證
claude doctor
此指令會回報安裝類型、版本、系統設定以及任何偵測到的問題。
驗證管理(v2.1.41+)
無需進入REPL即可管理驗證:90
claude auth login # Log in or switch accounts
claude auth status # Check current auth state (account, plan, expiry)
claude auth logout # Clear stored credentials
切換帳戶或組織的常見流程:
claude auth logout && claude auth login
另請參閱:如何除錯問題? 以排解驗證失敗問題。
更新
Claude Code預設會自動更新,於啟動時及執行階段定期檢查。更新會在背景下載,並於下次啟動時套用。
停用自動更新:
export DISABLE_AUTOUPDATER=1
或於settings.json中設定:
{
"env": {
"DISABLE_AUTOUPDATER": "1"
}
}
手動更新:
claude update
解除安裝
原生安裝(macOS/Linux/WSL):
rm -f ~/.local/bin/claude
rm -rf ~/.claude-code
原生安裝(Windows PowerShell):
Remove-Item -Path "$env:LOCALAPPDATA\Programs\claude-code" -Recurse -Force
Remove-Item -Path "$env:LOCALAPPDATA\Microsoft\WindowsApps\claude.exe" -Force
清除設定(移除所有設定):
rm -rf ~/.claude
rm ~/.claude.json
rm -rf .claude
rm -f .mcp.json
快速開始:您的第一個工作階段
1. 安裝並啟動:
claude # Launch in current directory
2. 切換到專案目錄:
cd ~/my-project && claude # Or launch from any git repo
3. 請Claude執行任務:
> "Explain the architecture of this project"
> "Find all TODO comments and create a summary"
> "Add input validation to the signup form"
4. 在工作階段中善用關鍵快捷鍵:
/cost # Check token usage and cost
/compact # Free up context when it gets large
Alt+T # Toggle extended thinking for hard problems
Ctrl+C # Cancel current response
5. 稍後繼續:
claude -c # Resume your most recent session
claude --resume # Pick from session list
專家提示: 請在專案根目錄建立一個
CLAUDE.md檔案,並寫入建置指令、程式碼撰寫慣例與架構說明。Claude在每次工作階段都會讀取此檔案,這是您能為品質做出最具槓桿效益的一件事。
核心互動模式
互動式REPL
不帶任何參數啟動Claude Code,即可進入互動式的read-eval-print loop:
cd your-project
claude
REPL會在多輪對話之間維持上下文。您可以直接輸入查詢、接收回應,並持續對話直到使用/exit或Ctrl+D離開。
也可以在啟動時帶入初始提示,讓工作階段聚焦於特定主題:
claude "explain the authentication flow in this project"
專家提示: REPL會在壓縮事件期間持續保留狀態。當上下文過於龐大時,Claude會自動摘要較舊的對話內容,同時保留關鍵決策與程式碼片段。您可以使用/compact手動觸發此功能,或加入自訂指令指定要保留哪些內容。
非互動模式
Print模式(-p)會執行單一查詢後立即結束:
# Direct query
claude -p "list all TODO comments in this project"
# Process piped input
cat error.log | claude -p "identify the root cause of these failures"
# Chain with other tools
claude -p "generate a README" > README.md
如需適合在指令稿中解析的結構化輸出:
claude -p "count lines by file type" --output-format json
JSON輸出包含自動化所需的所有資訊:
{
"type": "result",
"subtype": "success",
"total_cost_usd": 0.0034,
"is_error": false,
"duration_ms": 2847,
"duration_api_ms": 1923,
"num_turns": 4,
"result": "Response text here...",
"session_id": "abc-123-def"
}
如需即時處理串流輸出:
claude -p "build the application" --output-format stream-json | while read line; do
echo "$line" | jq -r 'select(.result) | .result'
done
輸出格式選項:
| 格式 | 旗標 | 使用情境 |
|---|---|---|
| Text(預設) | --output-format text |
人類可讀輸出、輸出至檔案 |
| JSON | --output-format json |
指令稿解析、CI/CD整合 |
| Stream JSON | --output-format stream-json |
即時處理、進度監控 |
結束代碼:
| 代碼 | 意義 |
|---|---|
| 0 | 成功 |
| 1 | 錯誤(執行階段失敗、API錯誤,或Claude回報錯誤) |
在-p模式中控制代理行為:
# Limit autonomous turns (prevents runaway loops)
claude -p "refactor the auth module" --max-turns 10
# Allow specific tools without prompting
claude -p "fix lint errors" --allowedTools "Edit,Bash(npm run lint)"
# Use with a specific model
claude -p "explain this code" --model claude-sonnet-4-5-20250929
# Bare mode: skip hooks, LSP, plugin sync, skill walks (v2.1.81+)
claude -p "count files" --bare
# Channel permission relay: send approval prompts to Telegram/Discord (v2.1.81+)
claude --channels
CI/CD整合範例:
# In a GitHub Action or CI pipeline
result=$(claude -p "review this diff for security issues" --output-format json 2>/dev/null)
is_error=$(echo "$result" | jq -r '.is_error')
if [ "$is_error" = "true" ]; then
echo "Review failed"
exit 1
fi
echo "$result" | jq -r '.result'
工作階段管理
工作階段會保留對話歷史以供延續。對於複雜的跨工作階段工作而言,工作階段持久性至關重要:
# Continue most recent session
claude -c
# Continue with additional prompt
claude -c -p "now add error handling"
# Resume specific session by ID
claude -r "abc123" "implement the remaining tests"
# Fork a session for parallel exploration
claude -r "base-session" --fork-session "try a different approach"
PR連結工作階段(v2.1.27+,v2.1.119+擴充): 啟動一個與特定pull request或merge request連結的工作階段。自v2.1.119起,--from-pr除了github.com之外,也可接受GitLab MR、Bitbucket PR與GitHub Enterprise PR的網址:74152
claude --from-pr 123 # GitHub PR number (assumes current repo's remote)
claude --from-pr https://github.com/org/repo/pull/123 # GitHub URL
claude --from-pr https://gitlab.com/org/repo/-/merge_requests/45 # GitLab MR (v2.1.119+)
claude --from-pr https://bitbucket.org/org/repo/pull-requests/67 # Bitbucket PR (v2.1.119+)
claude --from-pr https://ghe.example.com/org/repo/pull/89 # GitHub Enterprise (v2.1.119+)
當您在工作階段中透過gh pr create建立PR時,工作階段也會自動連結至該PR。這讓您日後能輕鬆恢復特定PR的工作。底部的PR標章可透過prUrlTemplate設定(v2.1.119+)指向自訂的程式碼審查網址,當您的團隊將PR連結至獨立的審查工具時尤其實用。152
/resume接受PR網址(v2.1.122+)。 將PR網址貼入/resume搜尋框,現在會找到原本建立該PR的工作階段,支援github.com、GitHub Enterprise、gitlab.com(含自架GitLab)以及bitbucket.org。154
具名工作階段: 在啟動時或工作階段中為其命名:
# Name session at startup (v2.1.76+)
claude -n "auth-refactor" # --name flag sets display name[^125]
# Name current session
> /rename auth-refactor
# Resume by name or number
> /resume 1 # Resume first session
> /resume auth-refactor # Resume by name
claude --resume auth-refactor # Resume from terminal
claude -r 3 # Resume by number from terminal
# Fork for parallel exploration
claude --resume auth-refactor --fork-session
注意:
--session-id需提供有效的UUID(例如550e8400-e29b-41d4-a716-446655440000)。如需人類可讀的工作階段命名,請改用/rename與--resume。
Claude Code會將工作階段儲存為JSONL逐字稿。代理執行會指派唯一的agentId值,逐字稿則以agent-{agentId}.jsonl格式儲存。恢復時會完整保留先前對話的上下文。
Plan模式
Plan模式將Claude限制為唯讀探索——不修改檔案、不執行bash、不進行破壞性動作。Claude會設計實作方案、將其寫入計畫檔,並在執行任何動作前等待您的核准。
進入plan模式:
# Cycle through modes during a session
Shift+Tab # Cycles: normal → plan → auto-accept
# Or use the /plan command with an optional description (v2.1.72+)
/plan # Enter plan mode
/plan refactor the auth module # Enter plan mode with a description
# Or ask Claude directly
"Plan how to refactor the auth module" # Claude may enter plan mode automatically
運作方式:
- Claude進入plan模式(複雜任務會自動進入,或透過
Shift+Tab手動切換) - 使用唯讀工具探索程式碼庫:
Read、Glob、Grep、WebSearch、WebFetch - 將計畫寫入
.claude/plans/{session-slug}.md - 透過
ExitPlanMode離開plan模式,並呈現計畫供您審閱 - 您可以核准、要求修改或拒絕
Plan模式中可用的工具: Read、Glob、Grep、LS、WebSearch、WebFetch、AskUserQuestion。編輯類工具(Edit、Write、Bash、NotebookEdit)會被封鎖。
計畫核准後(v2.1.32+): Claude提供三個選項:
- 「是,清除上下文並自動接受編輯」(Shift+Tab)——以全新上下文開始執行該計畫
- 「是,並手動核准編輯」——保留上下文,您逐項核准每次變更
- 「是,自動接受編輯」——保留上下文,Claude無需逐項核准即可執行
核准時自動清除上下文是建議採用的工作流程。它賦予計畫一個全新的上下文視窗,能顯著提升計畫的執行精準度——Claude能持續維持在正軌上,不受舊有對話干擾。
何時使用plan模式: - 涉及架構決策的全新功能實作 - 您希望先審視做法的多檔案重構 - 探索應先於修改的陌生程式碼庫 - 任何存在多種有效做法、且您希望提供意見的任務
專家提示: 您在plan模式投入愈多時間,Claude實作成功的機率就愈高。Plan模式本質上是一種免費的探索——沒有風險的工具呼叫,也不會有浪費的編輯。請盡情運用。
Configuration System 深入解析
Claude Code採用分層設定系統。理解其階層至關重要,因為較高層級會覆寫較低層級,而企業設定完全無法繞過。
Configuration 階層
| 層級 | 位置 | 範圍 | 可覆寫 |
|---|---|---|---|
| Enterprise | /etc/claude-code/managed-settings.json (Linux) |
所有使用者 | 否 |
/Library/Application Support/ClaudeCode/managed-settings.json (macOS) |
|||
C:\Program Files\ClaudeCode\managed-settings.json (Windows) |
|||
| CLI flags | 命令列引數 | 目前 session | 是 |
| Local project | .claude/settings.local.json |
個人、目前 project | 是 |
| Shared project | .claude/settings.json |
透過 git 共享給團隊 | 是 |
| User | ~/.claude/settings.json |
您所有的 projects | 是 |
| State | ~/.claude.json |
執行階段狀態、OAuth、MCP | N/A |
專家提示:在共享 project 中,將 .claude/settings.local.json 用於個人偏好設定(並加入 .gitignore)。將 .claude/settings.json 用於會提交到版本控制的團隊通用設定。
完整 settings.json 參考
以下完整設定示範所有主要選項:
{
"$schema": "https://json.schemastore.org/claude-code-settings.json",
"model": "claude-sonnet-4-5-20250929",
"permissions": {
"allow": [
"Read",
"Glob",
"Grep",
"Bash(npm run:*)",
"Bash(git:*)",
"Bash(make:*)",
"Edit(src/**)",
"Write(src/**)",
"mcp__github"
],
"deny": [
"Read(.env*)",
"Read(secrets/**)",
"Bash(rm -rf:*)",
"Bash(sudo:*)",
"Edit(package-lock.json)",
"Edit(.git/**)"
],
"ask": [
"WebFetch",
"Bash(curl:*)",
"Bash(docker:*)"
],
"additionalDirectories": [
"../shared-lib",
"../docs"
],
"defaultMode": "acceptEdits"
},
"env": {
"NODE_ENV": "development",
"DEBUG": "app:*"
},
"hooks": {
"PostToolUse": [
{
"matcher": "Edit|Write",
"hooks": [
{
"type": "command",
"command": "npx prettier --write \"$FILE_PATH\""
}
]
}
]
},
"sandbox": {
"enabled": false,
"autoAllowBashIfSandboxed": true,
"excludedCommands": ["git", "docker"]
},
"statusLine": {
"type": "command",
"command": "~/.claude/statusline.sh"
},
"includeCoAuthoredBy": true,
"cleanupPeriodDays": 30,
"outputStyle": "Explanatory",
"language": "en",
"respectGitignore": true,
"showTurnDuration": true,
"plansDirectory": ".claude/plans",
"spinnerVerbs": ["Thinking", "Processing", "Analyzing"],
"spinnerTipsOverride": {
"tips": ["Custom tip 1", "Custom tip 2"],
"excludeDefault": true
},
"skillOverrides": {
"legacy-skill": "off",
"manual-only-skill": "user-invocable-only",
"compact-skill": "name-only"
},
"includeGitInstructions": false,
"modelOverrides": {
"bedrock": "us.anthropic.claude-opus-4-6-20260312-v1:0",
"vertex": "claude-opus-4-6@20260312",
"foundry": "anthropic.claude-opus-4-6"
},
"autoMemoryDirectory": ".claude/memory",
"sandbox": {
"enableWeakerNetworkIsolation": true
}
}
當團隊擁有大型 skill library,但希望更嚴格控管執行階段可見範圍時,skillOverrides很實用。使用off可同時向模型與 slash picker 隱藏某個 skill;使用user-invocable-only可保留依名稱呼叫的能力,但從模型選取中移除;使用name-only則只顯示 skill 名稱,不顯示完整描述。156
較新的設定(v2.1.174–176):
availableModels/enforceAvailableModels(managed,v2.1.175+):availableModelsallowlist 會限制 session 可選取的模型。搭配enforceAvailableModels: true時,allowlist 也會限制 Default 模型:若 Default 解析到不允許的模型,會退回第一個允許的模型;而 user/project 設定也無法再擴大 managedavailableModels清單。配套修正(v2.1.176)補上了 alias 選取可能透過ANTHROPIC_DEFAULT_*_MODEL重新導向到被封鎖模型的漏洞,且/fast現在會拒絕切換到 allowlist 以外的模型。172language(v2.1.176 refinement):除了設定回應語言外,session 標題現在預設會以對話語言產生;設定language可固定標題使用特定語言。172footerLinksRegexes(v2.1.176):頁尾列中以 regex 比對的連結徽章,可透過 user 或 managed settings 設定。172wheelScrollAccelerationEnabled(v2.1.174):設為false可停用 fullscreen mode 中的滑鼠滾輪捲動加速。172
Environment Variables 參考
Authentication 與 API:
ANTHROPIC_API_KEY=sk-ant-... # Direct API authentication
ANTHROPIC_AUTH_TOKEN=token # Custom authorization header
ANTHROPIC_CUSTOM_HEADERS="X-Key: val" # Additional request headers
模型設定:
ANTHROPIC_MODEL=claude-opus-4-7 # Override default model (Apr 16, 2026)
ANTHROPIC_DEFAULT_OPUS_MODEL=claude-opus-4-7 # Opus 4.7 (Max/Team Premium default)
ANTHROPIC_DEFAULT_SONNET_MODEL=claude-sonnet-4-6
ANTHROPIC_DEFAULT_HAIKU_MODEL=claude-haiku-4-5-20251001
CLAUDE_CODE_SUBAGENT_MODEL=sonnet # Model for subagents
CLAUDE_CODE_WORKFLOWS=1 # Enable Workflow tool for deterministic multi-agent orchestration (v2.1.147+)
MAX_THINKING_TOKENS=10000 # (Opus 4.6 and Sonnet 4.6 only — removed in Opus 4.7)
CLAUDE_CODE_MAX_OUTPUT_TOKENS=4000 # Limit output length
CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1 # Enable agent teams (v2.1.32+)
Cloud provider 設定:
CLAUDE_CODE_USE_BEDROCK=1 # Use AWS Bedrock
CLAUDE_CODE_USE_VERTEX=1 # Use Google Vertex AI
CLAUDE_CODE_USE_FOUNDRY=1 # Use Microsoft Foundry
ANTHROPIC_BEDROCK_BASE_URL=https://... # Custom Bedrock endpoint
ANTHROPIC_BEDROCK_SERVICE_TIER=priority # Bedrock service tier (v2.1.122+): 'default', 'flex', or 'priority'; sent as X-Amzn-Bedrock-Service-Tier header[^162]
CLAUDE_CODE_SKIP_BEDROCK_AUTH=1 # Skip Bedrock auth (for gateways)
CLAUDE_CODE_SKIP_VERTEX_AUTH=1 # Skip Vertex auth
AWS_BEARER_TOKEN_BEDROCK=token # Bedrock bearer token
VERTEX_REGION_CLAUDE_3_7_SONNET=us-west1 # Override Vertex region
CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY=1 # Opt in gateway /v1/models discovery for /model picker (v2.1.129+)[^164]
行為控制:
DISABLE_AUTOUPDATER=1 # Prevent automatic background updates
DISABLE_UPDATES=1 # Block ALL update paths including manual `claude update` (v2.1.118+, stricter than DISABLE_AUTOUPDATER)[^160]
CLAUDE_CODE_PACKAGE_MANAGER_AUTO_UPDATE=1 # Homebrew/WinGet installs run package-manager upgrade in background, then prompt restart (v2.1.129+)[^164]
DISABLE_TELEMETRY=1 # Opt out of usage telemetry
DISABLE_ERROR_REPORTING=1 # Disable Sentry
DISABLE_BUG_COMMAND=1 # Disable /bug command
DISABLE_COST_WARNINGS=1 # Hide cost warnings
DISABLE_PROMPT_CACHING=1 # Disable prompt caching globally
DISABLE_PROMPT_CACHING_SONNET=1 # Disable for Sonnet only
DISABLE_PROMPT_CACHING_OPUS=1 # Disable for Opus only
DISABLE_NON_ESSENTIAL_MODEL_CALLS=1 # Skip non-critical API calls
ENABLE_PROMPT_CACHING_1H=1 # Opt into 1-hour prompt cache TTL (v2.1.108+, API/Bedrock/Vertex/Foundry)
ENABLE_PROMPT_CACHING_1H_BEDROCK=1 # Deprecated alias for the above; v2.1.108+ still honors it on Bedrock but logs a deprecation notice
FORCE_PROMPT_CACHING_5M=1 # Force 5-minute cache TTL (v2.1.108+)
ENABLE_TOOL_SEARCH=true # Re-enable tool search on Vertex AI (disabled by default v2.1.119+ to avoid unsupported beta header). Valid values: true, false, auto, auto:N[^160]
CLAUDE_CODE_HIDE_CWD=1 # Hide the working directory in the startup logo (v2.1.119+)[^160]
CLAUDE_CODE_FORK_SUBAGENT=1 # Enable forked subagents on external builds (v2.1.117+)[^160]
CLAUDE_CODE_FORCE_SYNC_OUTPUT=1 # Force synchronized terminal output when auto-detection misses it, such as Emacs eat (v2.1.129+)[^164]
CLAUDE_CODE_SESSION_ID=... # Read-only: present in the Bash tool subprocess; matches the session_id passed to hooks (v2.1.132+)[^168]
CLAUDE_CODE_DISABLE_ALTERNATE_SCREEN=1 # Skip the fullscreen alternate-screen renderer; keep the conversation in the terminal's native scrollback (v2.1.132+)[^168]
CLAUDE_EFFORT=... # Read-only: current effort level inside hooks and Bash tool subprocess (v2.1.133+)[^169]
Tool 設定:
BASH_DEFAULT_TIMEOUT_MS=30000 # Bash command timeout (30s)
BASH_MAX_TIMEOUT_MS=600000 # Maximum bash timeout (10min)
BASH_MAX_OUTPUT_LENGTH=50000 # Bash output limit
CLAUDE_BASH_MAINTAIN_PROJECT_WORKING_DIR=1 # Reset CWD after each bash
MCP_TIMEOUT=5000 # MCP server startup timeout
MCP_TOOL_TIMEOUT=30000 # MCP tool execution timeout
MAX_MCP_OUTPUT_TOKENS=25000 # MCP output limit
SLASH_COMMAND_TOOL_CHAR_BUDGET=15000 # Slash command context limit
網路與 proxy:
HTTP_PROXY=http://proxy:8080 # HTTP proxy
HTTPS_PROXY=https://proxy:8080 # HTTPS proxy
NO_PROXY=localhost,example.com # Bypass proxy for domains
CLAUDE_CODE_CLIENT_CERT=/path/to/cert # mTLS certificate
CLAUDE_CODE_CLIENT_KEY=/path/to/key # mTLS private key
CLAUDE_CODE_CLIENT_KEY_PASSPHRASE=pass # mTLS passphrase
UI 與 terminal:
CLAUDE_CODE_DISABLE_TERMINAL_TITLE=1 # Don't update terminal title
CLAUDE_CODE_IDE_SKIP_AUTO_INSTALL=1 # Skip IDE extension install
CLAUDE_CODE_SHELL=/bin/zsh # Override shell detection
USE_BUILTIN_RIPGREP=1 # Use included ripgrep (default)
CLAUDE_CONFIG_DIR=~/.myconfig # Custom config directory
IS_DEMO=1 # Hide sensitive UI elements[^37]
CLAUDE_CODE_DISABLE_BACKGROUND_TASKS=1 # Disable background tasks and Ctrl+B[^46]
CLAUDE_CODE_TMPDIR=/path/to/tmp # Override temp directory[^50]
CLAUDE_CODE_DISABLE_1M_CONTEXT=1 # Disable 1M context window (use standard 200K)[^103]
CLAUDE_CODE_PLUGIN_GIT_TIMEOUT_MS=120000 # Plugin marketplace git timeout (default 120s, was 30s)[^105]
CLAUDE_CODE_DISABLE_GIT_INSTRUCTIONS=1 # Remove built-in commit/PR instructions[^117]
CLAUDE_CODE_DISABLE_CRON=1 # Stop scheduled cron jobs mid-session[^121]
CLAUDE_CODE_SESSIONEND_HOOKS_TIMEOUT_MS=30000 # SessionEnd hooks timeout (default varies)[^123]
CLAUDE_CODE_USE_POWERSHELL_TOOL=1 # Enable Windows PowerShell tool on Linux/macOS (requires pwsh on PATH; v2.1.111+)[^153]
CLAUDE_CODE_ENABLE_AWAY_SUMMARY=1 # Force Session Recap when telemetry disabled (v2.1.108+)[^153]
OTEL_LOG_RAW_API_BODIES=1 # Emit full API request/response bodies as OTel log events (v2.1.111+)[^153]
TRACEPARENT=00-... # W3C Trace Context parent (v2.1.110+, SDK/headless)[^153]
TRACESTATE=vendor=value # W3C Trace Context state (v2.1.110+, SDK/headless)[^153]
OpenTelemetry exporters + sensitive-field gating:181
OTEL_LOGS_EXPORTER=none # OTel logs exporter (supports 'none' for disable; v2.1.85 fixed crash)
OTEL_METRICS_EXPORTER=none # OTel metrics exporter (supports 'none'; v2.1.85 fixed crash)
OTEL_TRACES_EXPORTER=none # OTel traces exporter (supports 'none'; v2.1.85 fixed crash)
OTEL_LOG_TOOL_CONTENT=1 # Opt in to emitting tool content in OTel spans (v2.1.101+, sensitive by default)
OTEL_LOG_TOOL_DETAILS=1 # Opt in to tool_parameters in OTel tool_result events (v2.1.85+)
OTEL_LOG_USER_PROMPTS=1 # Opt in to emitting user prompts in OTel traces (v2.1.101+, sensitive by default)
CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1 # Disable release-notes fetch (v2.0.17+); v2.1.110 also stopped the auto-title Haiku request in headless/SDK when set
v2.1.121+ LLM-request span attributes:stop_reason、gen_ai.response.finish_reasons與user_system_prompt現在會在 LLM-request spans 上送出。由於user_system_prompt可能包含 PII,因此受OTEL_LOG_USER_PROMPTS=1控管。154
v2.1.122+ event-level 變更:api_request與api_errorlog events 上的數值屬性現在會以數字送出(先前是字串),修正下游 OTel collectors 對 schema 進行嚴格型別檢查時的問題。新增的claude_code.at_mentionlog event 會在 Claude Code解析@-mention 時觸發。154
API / Model 控制:181
CLAUDE_CODE_EXTRA_BODY='{...}' # Inject extra body fields into API calls; v2.1.113 fixed 400 errors with output_config.effort on Vertex/subagent calls
CLAUDE_CODE_MAX_CONTEXT_TOKENS=200000 # Override max context tokens (pre-existing var; v2.1.98 fixed handling of DISABLE_COMPACT when both are set)
CLAUDE_CODE_FILE_READ_MAX_OUTPUT_TOKENS=25000 # Override default token limit for file read operations (v2.1.0+)
CLAUDE_CODE_DISABLE_NONSTREAMING_FALLBACK=1 # Do not fall back to non-streaming API on streaming failures (v2.1.83+)
ANTHROPIC_BETAS=beta1,beta2 # Enable beta API headers; v2.1.78 fixed silent ignore on Haiku models
ANTHROPIC_SMALL_FAST_MODEL=arn:... # Fast model ID (Bedrock ARN supported; v0.2.125 stopped escaping slashes in ARN)
Plugins / MCP:181
CLAUDE_CODE_PLUGIN_CACHE_DIR=~/.claude/plugins # Plugin cache directory (v2.1.72 fixed literal '~' dir on some shells)
CLAUDE_CODE_PLUGIN_KEEP_MARKETPLACE_ON_FAILURE=1 # Preserve plugin marketplace cache when git pull fails (offline-friendly; v2.1.90+)
CLAUDE_CODE_MCP_SERVER_NAME=server1 # Passed to MCP headersHelper scripts so one helper can serve multiple servers (v2.1.85+)
CLAUDE_CODE_MCP_SERVER_URL=https://... # Passed to MCP headersHelper scripts alongside the name (v2.1.85+)
Shell / IDE:181
CLAUDE_CODE_SHELL_PREFIX="time " # Wrap every Claude-invoked shell command with a prefix (v1.0.61+)
CLAUDE_CODE_GIT_BASH_PATH=C:\Program\ Files\Git\bin\bash.exe # Custom Git Bash path on Windows (v2.1.98+)
CLAUDE_CODE_EXIT_AFTER_STOP_DELAY=60000 # SDK: exit after N ms idle (v2.0.35+)
CLAUDE_CODE_AUTO_CONNECT_IDE=false # Disable IDE auto-connection (v1.0.61+)
Enterprise / auth:181
CLAUDE_CODE_PROXY_RESOLVES_HOSTS=1 # Opt into proxy-side DNS resolution (v2.0.55 moved this from default-on to opt-in)
CLAUDE_CODE_API_KEY_HELPER_TTL_MS=300000 # TTL for dynamically generated API keys via apiKeyHelper (apiKeyHelper refresh added v0.2.74 with 5-min default; env var added v0.2.117)
Skill variables(v2.1.69+):
${CLAUDE_SKILL_DIR} # Self-reference for skills to locate their own directory[^117]
SDK caller identity(v2.1.51+):
CLAUDE_CODE_ACCOUNT_UUID=uuid # Provide account UUID synchronously for SDK callers
CLAUDE_CODE_USER_EMAIL=[email protected] # Provide user email for SDK callers
CLAUDE_CODE_ORGANIZATION_UUID=uuid # Provide organization UUID for SDK callers
Debugging:
ANTHROPIC_LOG=debug # Enable API request logging
我該選擇哪個 Model?
為每項任務選對 model,會大幅影響成本與品質。Claude Code在多個層級提供彈性的 model 切換能力。
可用 Models
| Alias | Model | 最適合 | Input/1M | Output/1M |
|---|---|---|---|---|
fable |
Claude Fable 5 | 最困難的推理與長期作業;位於 Opus 之上的新最高層級(model ID claude-fable-5) |
$10.00 | $50.00 |
best |
組織有權限時使用 Fable 5,否則使用最新 Opus | 「永遠選擇可用的最強 model」 | 視情況而定 | 視情況而定 |
opus |
Claude Opus 4.8 | 複雜推理、agentic coding、長期作業(Claude Code的 agentic 預設值) | $5.00 | $25.00 |
sonnet |
Claude Sonnet 4.6 | 日常程式開發、平衡效能 | $3.00 | $15.00 |
haiku |
Claude Haiku 4.5 | 簡單任務、快速操作 | $1.00 | $5.00 |
default |
依帳號而定 | 通用用途 | 視情況而定 | 視情況而定 |
opus[1m] |
具備 1M context 的 Opus 4.8 | 大型程式碼庫、長 session | $5.00 | $25.00 |
sonnet[1m] |
具備 1M context 的 Sonnet 4.6 | 大型程式碼庫 | $3.00 | $15.00 |
opusplan |
Opus(規劃)+ Sonnet(執行) | 複雜重構 | 混合 | 混合 |
Claude Fable 5(2026年6月9日):這是位於 Opus 之上的新 model 層級,也是Anthropic最強大、最聰明的 model;在幾乎所有測試過的 benchmark 上都達到最先進水準,並且能在數百萬 tokens 的 context 中維持連貫。Fable 5 是「Mythos-class」frontier model 的通用安全版本:它內建安全分類器,遇到 cyber、bio-chem 與 model-distillation 查詢時會 fallback 到 Opus 4.8(Claude Mythos 5 是同一個 model,但移除了這些防護,供授權研究人員使用)。它從 v2.1.170(2026年6月9日)開始可在Claude Code中選用;請執行 claude update,再執行 /model fable(短 alias;/model claude-fable-5 與 best alias 也會選到它)。訂閱方案則會在 2026年6月22日前陸續開放。Model ID:claude-fable-5。Fable 5 預設即包含 1M context window,因此不需要 [1m] suffix;而且自 v2.1.173(2026年6月11日)起,claude-fable-5[1m] model name 會自動正規化/移除為 claude-fable-5(該 suffix 原本只對 Opus/Sonnet 有意義,因為它們以 [1m] 控制 1M 開關);max output 為 128K。價格為 input $10/MTok、output $50/MTok,約為 Opus 4.8 的 2 倍,因此應保留給真正困難的推理,而非例行編輯。它與 Opus 4.8 共用 request surface(僅 adaptive thinking;移除 temperature/top_p/top_k 與 budget_tokens),但有一項新細節:明確傳入 thinking: {type: "disabled"} 會回傳 400,因此若要不使用 thinking,請完全省略 thinking 參數。174
在Claude Code中特別需要注意:Fable 5 支援完整 effort scale(low/medium/high/xhigh/max,預設為 high),與 Opus 4.8 相同。Fable 5 無法關閉 thinking;session thinking toggle、alwaysThinkingEnabled 設定,以及 MAX_THINKING_TOKENS=0 都不會生效;它一律會自適應推理。完整的 fable family 設定介面與 Opus knobs 對應:ANTHROPIC_DEFAULT_FABLE_MODEL 可固定 fable alias 解析到的 model(在 Bedrock/Vertex/Foundry 上很有用)、DISABLE_PROMPT_CACHING_FABLE 可讓 Fable 不使用 prompt caching,enterprise gateways 上則適用以內容為基礎的自動 fallback。Opus 4.8 仍是Claude Code的 agentic 預設值(預設 high effort,最困難任務可用 /effort xhigh);只有在需要絕對上限時,才透過 /model fable 有意識地選擇 Fable 5。174
Opus 4.7(2026年4月16日):上一代 flagship,仍完整可用。1M token context window 採標準價格,沒有 long-context premium。128K max output,僅支援 adaptive thinking(extended thinking 已移除),並新增 xhigh effort level,建議作為 coding 與 agentic workloads 的起點。145可靠 knowledge cutoff:2026年1月。Training data cutoff:2026年1月。Model ID:claude-opus-4-7。價格與 Opus 4.6 相同,為每 MTok $5/$25,5-min cache write $6.25、1-hr cache write $10、cache read 每 MTok $0.50。144Opus 4.7 在 SWE-Bench 上解決的 production tasks 是 Opus 4.6 的 3 倍,在 CursorBench 得分 70%(4.6 為 58%),並在Anthropic內部 93-task coding benchmark 上提升 13% resolution。144它使用新的 tokenizer;同樣文字的 token 數約為 1×–1.35×,請提高 max_tokens 餘裕與 compaction 觸發門檻。145Vision 支援最高 2,576 px / 3.75 MP 的圖片,並採 1:1 pixel coordinates。145
Opus 4.7 coding benchmarks(2026年4月):151
| Benchmark | Opus 4.7 | Opus 4.6 | GPT-5.4(目前 OpenAI frontier) | GPT-5.3-Codex | GPT-5.2-Codex | GPT-5-Codex |
|---|---|---|---|---|---|---|
| SWE-bench Verified | 87.6% | ~80.9%(回報的 Opus 4.5 baseline) | ~80%(第三方;非官方頁面) | — | — | 74.9%(baseline) |
| SWE-bench Pro | 64.3% | — | 57.7%(官方) | 56.8% | 56.4% | — |
| Terminal-Bench 2.0 | 69.4% | 發表時最高 | 75.1%(官方) | 77.3% | 64.0% | — |
| CursorBench | 70% | 58% | — | — | — | — |
Opus 4.7 在 SWE-bench Verified 上領先廣泛引用的 GPT-5-Codex baseline 12.7,在 SWE-bench Pro 上則領先 GPT-5.4(57.7%)6.6。Terminal-Bench 2.0 上,GPT-5.3-Codex 仍小幅領先 GPT-5.4(77.3% 對 75.1%),兩者也都領先 Opus 4.7(69.4%)。Benchmark 領先地位變動很快;在做出跨季度選型前,請先查核供應商頁面。
依方案而定的預設 model(Claude Code):147
| Plan | Default model |
|---|---|
| Max, Team Premium | Opus 4.7 |
| Pro, Team Standard, Enterprise, Anthropic API | Sonnet 4.6(Enterprise + Anthropic API 會在 2026年4月23日改為 Opus 4.7) |
| Bedrock, Vertex AI, Foundry | Sonnet 4.5(可透過明確 pin 使用較新的 models) |
Opus 4.7 需要Claude Code v2.1.111 或更新版本;請執行 claude update 升級。147Bedrock、Vertex 與 Foundry 會透過明確完整 model name 或 ANTHROPIC_DEFAULT_OPUS_MODEL pin 暴露 Opus 4.7,而不是預設透過 opus alias。147
Opus 4.7 中 Messages API 的破壞性變更(caller-visible):145
- Extended thinking
budget_tokens已移除。請改用thinking: {type: "adaptive"}。Adaptive thinking 預設為關閉;沒有thinking欄位的 requests 會在不使用 thinking 的情況下執行。 - 將
temperature、top_p或top_k設為非預設值會回傳 HTTP 400。請省略這些參數,改透過 prompting 引導 model。 - Responses 預設會省略 thinking content。若要恢復可見推理,請設定
thinking.display: "summarized"(若您的產品會將 thinking stream 給使用者,這是必要設定)。
Task budgets(beta header task-budgets-2026-03-13)讓您可以透過 output_config.task_budget,向 model 提示整個 agentic loop 的 token 目標;最低 20K tokens。145
Opus 4.6(legacy):仍可於 claude-opus-4-6 使用,具備 1M context 與 128K max output。建議遷移到 Opus 4.7,以取得更好的 agentic coding。Opus 4.6 最初於 2026年2月5日推出。79144自 v2.1.117(2026年4月22日)起,Pro 與 Max 訂閱者在 Opus 4.6 與 Sonnet 4.6 上預設為 high effort(先前為 medium);Opus 4.7 則維持 xhigh。這項調整恢復了 4月23日 postmortem 中記錄的 3月4日 → 4月7日 effort downgrade 後的 intelligence。152153
Sonnet 4.6(2026年2月17日):平衡型 model;取代 Sonnet 4.5 成為 claude.ai 與Claude Cowork 的預設。93價格與 Sonnet 4.5 相同(每 MTok $3/$15)。它提升了 agentic search 效能,同時消耗更少 tokens。支援 extended thinking、adaptive thinking 與 1M token context window(beta)。64K max output(v2.1.77 中上限為 128K)。119Knowledge cutoff:2025年8月(可靠)、2026年1月(training data)。Model ID:claude-sonnet-4-6。
Claude Mythos Preview(2026年4月7日):Project Glasswing 下提供的防禦性資安工作 research-preview frontier model。139採邀請制,未普遍開放。Anthropic將 Opus 4.7 定位為在 cyber 面向上刻意低於 Mythos 的能力,這是安全性取捨;並已於 https://claude.com/form/cyber-use-case 開放 Cyber Verification Program,供需要更高存取權限的合法安全研究人員申請。146
為何這些價格差異很重要:典型 coding session 會消耗 50K-200K input tokens 與 10K-50K output tokens。使用 Haiku 時,每次 session 約 $0.10-$0.45。使用 Opus 時,同一個 session 會花 $0.50-$2.25,是 5 倍以上。請將 Opus 保留給真正困難的問題。1
何時使用各 Model
Haiku:適合負責探索、簡單檔案搜尋、快速問題的 subagents。它比 Opus 便宜約 5 倍,回應也更快。非常適合不需要深度推理的背景任務。
Sonnet:日常開發中在意成本時的主力。能處理多數 coding tasks:實作功能、修 bug、撰寫測試、code review。Sonnet 4.6 相較 Sonnet 4.5,提供更好的 agentic search 與 token 效率,並支援 adaptive thinking 與標準價格的 1M context window。93截至 Opus 4.7(2026年4月16日),Claude Code只有在 Max 與 Team Premium 方案上預設為 Opus;Pro、Team Standard、Enterprise 與API帳號會維持 Sonnet 4.6 作為預設,直到 Enterprise 與API於 2026年4月23日切換到 Opus 4.7。147當您需要更便宜的 tokens、更低延遲,或更符合 subagent 經濟性時,請使用 Sonnet。
Opus:截至 2026年4月16日的 flagship 層級,也是 Max 與 Team Premium 方案的預設。144147請將較高成本的推理保留在值得投入的地方:架構決策、棘手除錯、理解複雜系統、安全分析、長期 agentic work。Opus 4.7 在 SWE-Bench 上解決的 production tasks 是 Opus 4.6 的 3 倍,在 CursorBench 得分 70%(對比 58%),並在 93-task 內部 coding benchmark 上提升 13% resolution。144Claude Code在 Opus 4.7 上預設使用 xhigh effort,可透過 /effort 調整(v2.1.111+)。146147Max 訂閱者可透過Anthropic API在 Opus 4.7 上使用 Auto Mode,且不需要 --enable-auto-mode;其他方案/providers 則依方案與管理員控制而定。1461M context 採標準價格,沒有 long-context premium。值得注意的行為變更:Opus 4.7 會更逐字遵循指示,依任務複雜度校準回應長度,預設執行較少 subagents,並採用更直接的語氣,減少偏向確認與安撫的措辭。若您的 prompts 內含用來強制中途進度訊息或 double-check 行為的腳手架,不妨先嘗試移除。145
Opusplan:一種混合模式,使用 Opus 進行規劃(最需要推理品質的地方),再用 Sonnet 執行(重視速度的地方)。非常適合複雜重構:您想要最好的計畫,但不需要每個個別 edit 都使用 Opus 等級推理。
切換 Models
Session 期間:
> /model opus
> /model sonnet
> /model haiku
啟動時:
claude --model opus
透過 environment:
export ANTHROPIC_MODEL=opus
在 settings.json 中:
{
"model": "claude-sonnet-4-5-20250929"
}
專供 subagents 使用:
export CLAUDE_CODE_SUBAGENT_MODEL=haiku
Fallback model chain(v2.1.166+):fallbackModel 設定可配置最多 3 個 fallback models;當主要 model overloaded 或 unavailable 時,會依序嘗試。--fallback-model flag(先前只作為 mid-session switch)現在也會從啟動時套用到 interactive sessions。176
{
"model": "claude-opus-4-8",
"fallbackModel": ["claude-sonnet-4-6", "claude-haiku-4-5"]
}
當API回傳非預期且不可 retry 的錯誤時,Claude Code現在也會先在 fallback model 上重試該 turn 一次,再顯示失敗。因此短暫的 primary-model 問題會優雅降級,而不是直接丟失該 turn。176
截至 v2.1.178,compaction 也會遵循 fallback chain;若 primary model 在 compaction 中 overloaded 或 unavailable,compaction 步驟會 fallback 到已設定的 fallbackModel/--fallback-model chain,而不是讓該 turn 失敗。對長時間 autonomous run 而言,這補上了原本可恢復的 compaction 卻因短暫 model error 導致 session 中斷的缺口。173
Extended Context
大型程式碼庫或長 session 可啟用 1M token context:
claude --model sonnet[1m]
claude --model opus[1m] # Opus 4.7 with 1M context
或在 session 內:
> /model sonnet[1m]
> /model opus[1m]
Opus 4.7、Opus 4.6 與 Sonnet 4.6 都以標準價格包含完整 1M token context window,沒有 long-context premium。148900K-token request 與 9K-token request 會用相同的 per-token rate 計費。Prompt caching 與 batch processing discounts 在完整 context window 內皆以標準費率適用。
在 Max、Team 與 Enterprise 訂閱中,Opus 的 1M context 會自動包含,不需要 [1m] suffix(自 v2.1.75,2026年3月13日起預設啟用)。117147在 Pro 上,1M context 可透過 extra usage 使用。API與 pay-as-you-go 使用者則能以標準 per-token rates 完整使用 1M。147
若要在 model picker 中停用 1M context variants,請設定 CLAUDE_CODE_DISABLE_1M_CONTEXT=1。
檢查目前 Model
> /status
此 command 會顯示目前 model、帳號資訊、已套用設定,以及其他 session state。
Model picker labels(v2.1.51+):/model picker 現在會針對 pinned versions 顯示可讀性較高的 labels(例如「Sonnet 4.6」),而不是原始 model IDs;若有更新版本可用,也會顯示升級提示。98
Fast Mode(v2.1.36+)
Fast mode 會讓同一個 model顯著加快輸出;它不會切換到較便宜的 model。可在 session 中使用 /fast 切換。86
> /fast # Toggle fast mode on/off
價格(Opus 4.6 fast mode):
| Standard | Fast Mode | |
|---|---|---|
| Input | $5/MTok | $30/MTok(6× base rate) |
| Output | $25/MTok | $150/MTok(6× base rate) |
Fast mode 是 research preview,僅限 Opus 4.6,可帶來約 2.5 倍更快輸出,但價格為 base pricing 的 6 倍。149若您原本在其他 model 上,啟用 /fast 會自動將 session 切換到 Opus 4.6;停用 /fast 後仍會留在 Opus 4.6,直到您透過 /model 切換。Fast mode 不適用於 Opus 4.7、Sonnet、Haiku,也不支援 Bedrock/Vertex/Foundry。它需要啟用 extra usage;Team/Enterprise 則需要管理員啟用。
何時使用 fast mode: - 快速迭代小變更,且延遲是瓶頸 - 產生測試、boilerplate,或重複性程式碼,速度比成本更重要 - 依序處理一系列相似任務
何時不要使用 fast mode: - 長時間 agentic tasks(6x 費率會讓成本快速累積) - 背景 subagent 工作(沒有人在等輸出) - 成本敏感的 sessions
Opus 4.6 fast mode 包含完整 1M context window(v2.1.50+)。Fast mode pricing 在 1M context 內採固定費率,沒有額外 long-context surcharge。96149
專家提示:Fast mode 不會與 opusplan 搭配(opusplan 已混合 Opus 與 Sonnet;fast mode 只影響 Opus 4.6)。當延遲比成本更重要時,直接使用 fast mode;autonomous 或 batch work 則應停用。/fast 需要 extra usage;Team/Enterprise 管理員可能需要先啟用(v2.1.37 fix)。86149
Effort Control(v2.1.111+,Opus 4.7)
Opus 4.7 引入新的 effort dial,可調整速度與 intelligence 的取捨。在 session 中使用 /effort:
> /effort # opens an interactive slider (arrow keys + Enter)
> /effort xhigh # set directly
| Level | 用途 |
|---|---|
min / low / medium |
可由人工抽查品質的快速迭代 |
high |
intelligence-sensitive use cases 的建議最低值 |
xhigh |
Opus 4.7 上 coding 與 agentic work 的建議起點 |
max |
最高品質、最慢且最昂貴 |
Claude Code現在會在 Opus 4.7 預設使用 xhigh effort。xhigh 僅限 Opus 4.7;其他 models 會 fallback 到 high。Claude Managed Agents 會自動處理 effort;effort parameter 是 Messages API 的概念。145146
Max 上的 Auto Mode(v2.1.111+)
Auto Mode 是 --dangerously-skip-permissions 的較安全替代方案;Max 訂閱者可透過Anthropic API在 Opus 4.7 上使用,且不需要 --enable-auto-mode。146Sonnet-4.6 classifier 會在每個 action 執行前審查,檢查 intent match 與 safety。注意(v2.1.111+):--enable-auto-mode flag 已移除;請改用 --permission-mode auto 啟動 Auto Mode session。Auto Mode 不適用於 Pro;依Anthropic的 permission modes docs,它在Anthropic API上預設直接可用。Bedrock/Vertex/Foundry(v2.1.158+):在這些 gateways 上,Opus 4.7 與 Opus 4.8 的 Auto Mode 現在可用 CLAUDE_CODE_ENABLE_AUTO_MODE=1 opt in。179
不失去 defaults 的自訂 rules(v2.1.118+)。早期版本中,autoMode.allow、autoMode.soft_deny 與 autoMode.environment 是二選一:定義自己的清單就會失去內建安全 rules。$defaults sentinel 解決了這點;它會在您放置的位置 inline 展開為內建清單,因此可在其前後疊加 custom rules:152
// .claude/settings.json
{
"autoMode": {
"allow": [
"Bash(npm test:*)", // your additions, prepended
"$defaults", // built-in allow list inserted here
"Bash(git push:origin/feature/*)" // appended after
]
}
}
「Don’t ask again」opt-in(v2.1.118+)。Auto Mode opt-in prompt 現在提供「Don’t ask again」選項,讓頻繁使用者不必透過 scripting flag,也能抑制說明訊息。152
v2.1.105–v2.1.114 的新 Commands146150
| Command | Version | 功能 |
|---|---|---|
/recap |
v2.1.108+ | 在恢復 session 時回傳先前 context 摘要。可在 /config 設定;CLAUDE_CODE_ENABLE_AWAY_SUMMARY=1 會在 telemetry 停用時強制開啟。 |
/ultrareview |
v2.1.111+(v2.1.113 更新) | Cloud-run multi-agent code review。不帶 args 時 review 目前 branch;傳入 <PR#> 可抓取特定GitHub PR。v2.1.113 透過平行化 checks 加快啟動,在 launch dialog 加入 diffstat,並顯示 animated launching state。Pro/Max 訂閱者可取得 3 次免費 cloud reviews。 |
/less-permission-prompts |
v2.1.111+ | 掃描近期 transcripts 中常被核准的 read-only Bash/MCP calls,並為 .claude/settings.json 提出 prioritized allowlist。 |
/tui / /tui fullscreen |
v2.1.110+(banner 於 v2.1.132 更新) | 在對話中切換或進入 flicker-free rendering。對應的 tui setting 可保存偏好。v2.1.132 更新 startup banner,說明 renderer 的較低記憶體用量、mouse support,以及 select 時 auto-copy。159 |
/focus |
v2.1.110+ | 進入 focus mode。現在已與 Ctrl+O 分離,後者只切換 normal 與 verbose transcript。 |
/undo |
v2.1.108+ | /rewind 的 alias。 |
/proactive |
v2.1.105+ | /loop 的 alias。v2.1.113 在「next tick」倒數中加入 Esc-to-cancel。 |
/effort(無 args) |
v2.1.111+ | 開啟互動式 effort slider(方向鍵 + Enter)。也接受直接 args:/effort xhigh。 |
/extra-usage |
v2.1.113+(Remote Control client support) | 現在可從 Remote Control(mobile/web)clients 使用,不再只限本機 terminal。 |
Session Recap(v2.1.108+)
這是一項新的 session-level 功能,會在您回到暫停的 session 時顯示 context。預設啟用,可透過 /config 或 CLAUDE_CODE_ENABLE_AWAY_SUMMARY=0 opt out。Model 也可以透過 Skill tool 呼叫內建 slash commands(/init、/review、/security-review),延伸 subagent/skill pattern。146
Push Notifications(v2.1.110+)
當 Remote Control 設定啟用「Push when Claude decides」時,Claude現在可自行決定透過新的 push-notification tool 傳送 mobile push notifications。這會搭配既有的 Remote Control mobile/web surface。146/context、/exit 與 /reload-plugins 現在也可從 Remote Control clients 使用。
Windows PowerShell Tool(v2.1.111+,逐步推出)
Claude Code正在推出原生 Windows PowerShell tool。在 Linux/macOS 上,可用 CLAUDE_CODE_USE_POWERSHELL_TOOL=1 啟用(需要 PATH 中有 pwsh)。在 Windows 上,同一個變數會控制 rollout 期間的 opt-in/opt-out。146
Permission-mode auto-approval(v2.1.119+)。PowerShell tool commands 現在也能像 Bash commands 一樣,在 permission mode 中取得 auto-approval。像 PowerShell(Get-*:*) 這類 allow rules,以及既有 pattern syntax,現在可繞過 read-only operations 的 prompt,符合團隊已在 Linux/macOS 上習慣的 operator ergonomics。152
Permission Reduction:Read-Only Bash(v2.1.111+)
帶有 glob arguments 的 read-only Bash patterns(例如 ls *.ts、cat src/*.md),以及以 cd <project-dir> && 開頭的 commands,不再觸發 permission prompt。146搭配 /less-permission-prompts,日常工作流程中的中斷會明顯減少。
Distributed Tracing(v2.1.110+)
SDK與 headless sessions 現在會從 environment 讀取 TRACEPARENT 與 TRACESTATE,將Claude Code runs 串入 distributed traces。搭配 OTEL_LOG_RAW_API_BODIES=1(v2.1.111+),可將完整API request/response bodies 以 OpenTelemetry log events 輸出,方便除錯。146
Native Binary Distribution(v2.1.113+)150
v2.1.113 變更了CLI的啟動方式:claude 現在會透過 per-platform optional dependency 產生原生Claude Code binary,而不是執行 bundled JavaScript。安裝與更新 commands 保持不變,團隊也不需要修改 rollout scripts。
Prompt Editor Shortcuts(v2.1.113+)150
Prompt editor 在 multiline input 中加入 readline-style navigation,並支援 fullscreen viewport scrolling:
| Shortcut | Effect |
|---|---|
Shift+↑ / Shift+↓(fullscreen) |
當 selection 延伸超出可見邊緣時,捲動 viewport。 |
Ctrl+A |
移到目前 logical line 的開頭(readline-style)。 |
Ctrl+E |
移到目前 logical line 的結尾(readline-style)。 |
Ctrl+Backspace(Windows) |
刪除前一個 word。 |
這些預設啟用,不需要 keybinding config。
Subagent Stall Timeout(v2.1.113+)150
Subagents 若在 mid-stream 停滯,現在會在 10 分鐘後以清楚錯誤失敗,而不是靜默卡住。可搭配 CLAUDE_STREAM_IDLE_TIMEOUT_MS(v2.1.84+),為 streaming APIs 提供更廣泛的 stuck-process coverage。
v2.1.114 Stability Fix150
v2.1.114(2026年4月18日)只包含一項修正:當 agent-teams teammate 請求 tool permission 時,permission dialog 可能 crash。若您使用 Agent Teams,請升級。
Claude Code的成本是多少?
了解並控制成本對於永續使用Claude Code至關重要。另請參閱模型選擇以了解模型功能,以及決策框架以根據任務選擇合適的模型。
檢視成本
> /cost
輸出:
Total cost: $0.55
Total duration (API): 6m 19.7s
Total duration (wall): 6h 33m 10.2s
Total code changes: 247 lines added, 89 lines removed
訂閱用戶在/cost中可看到各模型與快取命中的細項分析,精確顯示哪些模型消耗了 token,以及多少由快取提供(v2.1.92+)。137
訂閱方案
| 方案 | 價格 | 用量 | 存取權限 |
|---|---|---|---|
| Free | $0 | 有限 | 無Claude Code存取權 |
| Pro | $20/月 | Free 的 5 倍 | Claude Code + Opus 存取權13 |
| Max (5x) | $100/月 | Pro 的 5 倍 | 優先存取,效能增強 |
| Max (20x) | $200/月 | Pro 的 20 倍 | 最高優先權,可購買額外用量 |
速率限制(2025年8月): Anthropic為付費訂閱者引入了每週速率限制。Max 訂閱者可以按標準API費率,購買超出速率限制的額外用量。14
速率限制翻倍(2026年5月6日): 在 Code with Claude SF 活動期間,Anthropic將Claude Code在 Pro、Max、Team 與席次制 Enterprise 方案的五小時速率限制全面翻倍,移除了 Pro 與 Max 帳戶的尖峰時段降速,並「大幅」提升了Claude Opus 模型的API速率限制。產能後盾來自 SpaceX Colossus 1 交易:「本月內超過 300 兆瓦的新產能(超過 220,000 顆 NVIDIA GPU)。」157
API Token 計價(2026年4月)1144
針對API計費用戶,每百萬 token 計價如下:
| 模型 | 輸入 | 輸出 | 備註 |
|---|---|---|---|
| Haiku 4.5 | $1 | $5 | 速度與效率 |
| Sonnet 4.6 | $3 | $15 | 智慧/成本平衡 |
| Opus 4.7 | $5 | $25 | 目前旗艦——1M 上下文採標準計價,無長上下文加價 |
| Opus 4.6 | $5 | $25 | 舊版 Opus;1M 上下文採標準計價(無加價) |
1M 上下文計價(2026年4月): Opus 4.7、Opus 4.6、Sonnet 4.6 與 Mythos Preview 全部包含 1M,採標準每百萬 token 費率——無長上下文加價。148這是近期的整合調整;先前關於 Opus 4.6 或 Sonnet 4.6 在輸入超過 200K token 後須支付 2 倍輸入/1.5 倍輸出費用的指引已不再適用。舊版 Opus 4.5 與更早的模型則保留其原本的計價結構。
資料駐留計價: 透過inference_geo指定僅限美國推論,會在所有 token 計價(包含快取讀寫)上加收 1.1 倍乘數(Opus 4.6+ 模型)。148
提示快取可大幅降低重複輸入成本:快取寫入的成本為基準的 1.25 倍(5 分鐘快取)或 2 倍(1 小時快取),但快取讀取成本僅 0.1 倍,可節省 90%。對於具有重複上下文的RAG系統與程式碼助手而言,快取可降低 88-95% 的成本。
批次API為非緊急任務(如夜間測試套件)提供 50% 折扣,於 24 小時內完成。
多帳號政策52
可以擁有多個Claude帳號嗎? 是的,只要是合法用途即可。Anthropic明確允許多帳號用於不同目的。
允許的情況:
| 情境 | 範例 | 狀態 |
|---|---|---|
| 同住家庭成員 | 您與配偶各自擁有 Max 帳號 | 允許 |
| 工作 + 個人 | 個人帳號加上雇主管理的工作帳號 | 允許 |
| 個人 + 團隊 | 個人 Pro/Max 與組織帳號並用 | 允許 |
| 同一網路 | 同一家用 WiFi 上的多個帳號 | 允許 |
| 同一電腦 | 在一台機器上切換帳號 | 允許 |
技術限制: - 同一支電話號碼最多可驗證3 個帳號 - 明確支援來自同一 IP/網路的多個付費訂閱 - 帳號之間完全分離;不可在帳號間轉移聊天或專案
禁止的行為(依使用政策): - 在被封鎖後建立帳號規避封鎖 - 跨帳號協調惡意活動以避開偵測 - 利用多帳號規避速率限制或免費方案額度
真實案例: 2026年1月,重度用戶 Jeffrey Emanuel(@doodlestein)的 22 個 Max 帳號被自動標記並暫時封鎖。Anthropic員工 Thariq(@trq212)在確認其為合法用途後,於 4 小時內處理完畢。如果您因工作與個人專案需要跨多個帳號大量使用Claude Code,這正是該服務設計的初衷,但切勿試圖鑽系統漏洞。
有疑慮時: 請聯繫Anthropic Support,書面確認您的具體使用情況。
成本因素
| 因素 | 影響 | 最佳化方式 |
|---|---|---|
| 模型選擇 | Opus >> Sonnet >> Haiku | 簡單任務使用 Haiku |
| 輸入 token | 上下文越多 = 成本越高 | 讓 CLAUDE.md 保持精簡聚焦 |
| 輸出 token | 回應越長成本越高 | 設定MAX_OUTPUT_TOKENS |
| 思考 token | Extended thinking 會增加成本 | 僅在必要時使用 |
| 提示快取 | 降低重複輸入成本 | 保持啟用(預設) |
實際成本範例
| 任務 | 模型 | 輸入 | 輸出 | 成本 |
|---|---|---|---|---|
| 快速檔案搜尋 | Haiku | 20K | 2K | $0.03 |
| 修復 bug 並含測試 | Sonnet | 100K | 30K | $0.75 |
| 架構審查 | Opus | 150K | 50K | $2.00 |
| 全日工作(Sonnet) | Sonnet | 500K | 150K | $3.75 |
| 全日工作(混合) | Haiku+Sonnet | 500K | 150K | ~$2.00 |
省成本洞見: 探索類 subagents 使用 Haiku、實作使用 Sonnet,相較於全程使用 Sonnet,通常可降低 40-50% 的成本。
團隊成本管理
依團隊規模建議的 TPM/RPM:
| 團隊規模 | 每位用戶 TPM | 每位用戶 RPM |
|---|---|---|
| 1-5 | 200k-300k | 5-7 |
| 5-20 | 100k-150k | 2.5-3.5 |
| 20-50 | 50k-75k | 1.25-1.75 |
| 50-100 | 25k-35k | 0.62-0.87 |
| 100+ | 10k-20k | 0.25-0.5 |
隱藏工具費用
除了按 token 計價之外,部分工具會產生額外費用:9
| 工具 | 費用 | 備註 |
|---|---|---|
| 程式碼執行 | $0.05/session-hour | 每組織每月前 1,550 小時免費。當請求中包含web_search或web_fetch工具時免費。33 |
| 網路搜尋 | $10/1,000 次搜尋 | 仍需支付 token 成本。失敗的搜尋不計費。 |
| 網路擷取 | 免費 | 擷取內容除標準 token 成本外,無額外費用。1 |
| Bash 工具 | 每次呼叫 +245 個輸入 token | 每次呼叫的開銷 |
| 文字編輯器 | 每次呼叫約 +700 個輸入 token | 典型開銷 |
這些費用在 agent 迴圈中會累積。一個 100 次迭代的 Bash 除錯循環,光是開銷就會多出約 24,500 個輸入 token。
省成本策略
- subagents 使用 Haiku:大部分探索並不需要 Sonnet
- 啟用提示快取:預設啟用,但要確認沒有被停用
- 設定最大回合數:
claude --max-turns 5可避免對話失控 - 以 plan mode 進行探索:不執行 = 不會意外觸發昂貴操作
- 主動壓縮上下文:上下文越小 = token 越少
- 限制輸出:
export CLAUDE_CODE_MAX_OUTPUT_TOKENS=2000 - 非緊急工作改用批次API:輸入與輸出 token 皆享 5 折優惠
監控用量
- Claude Console:platform.claude.com(需要 Admin 或 Billing 角色)
- 工作區限制:為每個工作區設定支出上限
- Bedrock/Vertex:使用雲端原生成本監控
- LiteLLM:搭配第三方供應商,可進行詳細的個別用戶追蹤
背景 Token 用量
部分操作會在背景消耗 token:
- 為/resume進行的對話摘要
- /cost與/status指令
- 自動壓縮
通常每個 session 不超過 $0.04。
Claude Code Analytics API(Team/Enterprise)46
透過 Admin API,可程式化存取貴組織的Claude Code用量分析與生產力指標。
端點: GET /v1/organizations/usage_report/claude_code
需求:
- Admin API 金鑰(sk-ant-admin...)
- Team 或 Enterprise 方案
- Admin、Billing 或 Developer 角色
可用指標:
| 指標 | 說明 |
|---|---|
num_sessions |
啟動的Claude Code獨立 session 數 |
lines_of_code.added/removed |
新增/移除的程式碼總行數 |
commits_by_claude_code |
建立的 git commit 數 |
pull_requests_by_claude_code |
建立的 PR 數 |
terminal_type |
環境(vscode、iTerm.app、tmux 等) |
customer_type |
api(API客戶)或 subscription(Pro/Team) |
範例請求:
curl "https://api.anthropic.com/v1/organizations/usage_report/claude_code?starting_at=2026-01-15" \
-H "x-api-key: sk-ant-admin..." \
-H "anthropic-version: 2023-06-01"
使用情境: - 開發者生產力分析(sessions、commits、PRs) - 工具使用指標(Edit、Write 等的接受/拒絕率) - 跨團隊的成本追蹤與分攤 - AI 程式碼工具的ROI佐證
注意: 資料會在活動完成後 1 小時內出現。為了一致性,回應中僅包含超過 1 小時的資料。
決策框架
僅僅知道功能存在還不夠,您需要知道何時使用哪一個。以下決策樹將知識轉化為行動。
我應該使用哪個模型?
START → Is the task simple? (file search, quick question, formatting)
│
├── YES → Use Haiku
│ Cost: ~$0.03/task
│ Speed: Fastest
│
└── NO → Does it require deep reasoning?
(architecture, complex debugging, security analysis)
│
├── YES → Use Opus 4.7 (xhigh effort default)
│ Cost: ~$2.00/task
│ Quality: Highest (1M context at standard price, adaptive reasoning)
│
└── NO → Use Sonnet
Cost: ~$0.75/task
Balance: Best overall when cost matters
經驗法則:Opus 4.7 是 Max 與 Team Premium 的預設模型。在 Pro/Team Standard/Enterprise/API 上,Sonnet 4.6 為預設模型(Enterprise 與 Anthropic API 將於 2026 年 4 月 23 日切換至 Opus 4.7)。147 子代理(subagent)降級使用 Haiku。當 Sonnet 的回答顯得淺薄時,升級至 Opus。搭配代理團隊(v2.1.32+),Opus 可協調多個代理並行處理不同子任務。79
Command、Skill、Subagent 還是 Agent Team?
Do you want explicit control over when it runs?
│
├── YES → Use Slash Command
│ Example: /deploy, /test, /security-review
│ You invoke it. You control timing.
│
└── NO → Should the expertise apply automatically based on context?
│
├── YES → Use Skill
│ Example: Security patterns, domain rules, code standards
│ Claude recognizes context and applies expertise.
│
└── NO → Does the work need isolated context?
│
├── YES → Is there one subtask or many parallel subtasks?
│ │
│ ├── ONE → Use Subagent (Task tool)
│ │ Example: Deep exploration, parallel analysis
│ │ Prevents context bloat in main conversation.
│ │
│ └── MANY → Use Agent Team (v2.1.32+)
│ Example: 5 agents reviewing different modules simultaneously
│ Opus coordinates; each agent works independently.
│
└── NO → Just prompt directly
Not everything needs abstraction.
Hook 還是 Prompt?
Must the action ALWAYS happen, regardless of Claude's judgment?
│
├── YES → Use Hook (deterministic)
│ Examples:
│ - Format code after every edit
│ - Log all bash commands
│ - Block access to .env files
│ Claude cannot skip, forget, or decide otherwise.
│
└── NO → Use Prompt (probabilistic)
Examples:
- "Consider adding tests"
- "Think about edge cases"
- "Review for security if relevant"
Claude decides based on context.
何時使用擴展思考(Extended Thinking)?
Is this a genuinely hard problem?
│
├── Architectural decision with many tradeoffs → YES, use thinking
├── Complex debugging with unclear root cause → YES, use thinking
├── Security analysis requiring careful reasoning → YES, use thinking
├── Understanding unfamiliar codebase → YES, use thinking
│
├── Routine bug fix → NO, skip thinking
├── Simple refactoring → NO, skip thinking
├── Code formatting → NO, skip thinking
└── Quick questions → NO, skip thinking
在工作階段中使用 Alt+T 切換。較高的思考預算成本較高;請從最低值開始,僅在回應顯得倉促時再提高。
Opus 4.6 自適應思考:Opus 4.6 會根據問題複雜度自動調整思考深度。對大多數任務而言,無需明確控制思考預算——Opus 會為困難問題擴展思考,並在處理簡單問題時保持快速。手動切換思考功能最適合搭配 Sonnet 使用,當您希望強制進行更深入的分析時。
應選擇哪個執行介面?
Where should this work happen?
│
├── Requires YOUR local files and tools
│ │
│ ├── Interactive, iterative work → Main REPL session
│ ├── One-shot scripted task → claude -p "prompt" (print mode)
│ ├── CI/CD automation → claude -p --json (non-interactive + structured output)
│ └── Parallel isolated tasks → Subagents via Task tool
│
├── Requires SOMEONE ELSE'S environment
│ │
│ └── Remote codebase or server → Background agent (cloud)
│
└── Doesn't require any environment
│
├── Research or analysis → Subagent with Explore type
└── Web content extraction → WebFetch / WebSearch tools
| 情境 | 執行介面 | 原因 |
|---|---|---|
| 除錯失敗的測試 | Main REPL | 需要本機檔案,需迭代 |
| 分流 20 個 GitHub issue | Background agent | 長時間執行,不需本機檔案 |
| 審閱 PR | Subagent 或 --from-pr |
隔離情境,聚焦輸出 |
| 產生 changelog | claude -p |
單次執行,可腳本化 |
| 每次提交時 Lint 與測試 | Hook(PreCommit) | 必須每次執行,具確定性 |
| 跨 repo 搜尋模式 | Subagent(Explore) | 防止情境膨脹 |
| 將遷移套用至 staging | Background agent | 需要遠端存取 |
| 快速程式碼說明 | Main REPL 或 /fast |
需要互動且快速回應 |
| 多模組重構 | Agent team | 跨檔案並行作業 |
Agent Teams、Subagents 與平行工作階段的比較
Do you need multiple agents working on related subtasks?
│
├── YES → Are the subtasks independent (no shared state)?
│ │
│ ├── YES → Can they share the same codebase?
│ │ │
│ │ ├── YES → Use Agent Team (v2.1.32+)
│ │ │ Opus coordinates. Agents share repo access.
│ │ │ Example: "Review auth, API, and DB modules in parallel"
│ │ │
│ │ └── NO → Use Parallel Sessions (separate terminals)
│ │ Each has its own working directory.
│ │ Example: "Fix repo-A and repo-B simultaneously"
│ │
│ └── NO → Use Sequential Subagents
│ Results from one feed into the next.
│ Example: "Explore → Plan → Implement"
│
└── NO → Use Single Subagent or Main REPL
| 方式 | 最大並行度 | 共享情境 | 協調方式 | 成本 |
|---|---|---|---|---|
| Agent Team | 5-10 個代理 | 共享 repo,情境獨立 | 由 Opus 協調 | 高(N 個代理) |
| Subagents | 不限(由您管理) | 無(隔離) | 透過提示由您協調 | 每代理中等 |
| 平行工作階段 | 受終端機數量限制 | 無 | 手動 | 每工作階段中等 |
應使用哪種 Hook 類型?
What kind of automation do you need?
│
├── Run a shell command at a specific event?
│ │
│ └── Use Command Hook
│ Trigger: PreToolUse, PostToolUse, Notification, Stop, SubagentStop
│ Example: "Run prettier after every file edit"
│ Config: hooks.PostToolUse[].command = "prettier --write $FILE"
│
├── Modify Claude's system prompt based on context?
│ │
│ └── Use Prompt Hook (v2.1.35+)
│ Trigger: Same events
│ Example: "Inject project rules when working in /src/auth/"
│ Config: hooks.PreToolUse[].prompt = "When editing auth files..."
│
└── Have Claude make a judgment call before proceeding?
│
└── Use Agent Hook (v2.1.35+)
Trigger: Same events
Example: "Evaluate if this bash command is safe before running"
Config: hooks.PreToolUse[].agent = { prompt: "Is this safe?" }
何時使用 /fast?
Is response speed more important than depth right now?
│
├── YES → Use /fast
│ Same Opus 4.6 model, faster output
│ Good for: quick questions, simple edits, code explanations,
│ file searches, formatting tasks
│
└── NO → Stay in normal mode
Good for: architecture decisions, complex debugging,
security reviews, multi-file refactors,
anything requiring deep reasoning
/fast會為目前工作階段切換至快速模式。它使用相同的模型(Opus 4.6),但輸出速度經過最佳化——它不會切換至較便宜的模型。
權限系統如何運作?
Claude Code的權限系統可細緻控制哪些操作能夠執行。理解其運作方式,對安全性與工作流程效率都至關重要。另請參閱企業部署,了解可在整個組織強制套用權限的受管設定。
權限層級
唯讀工具(自動核准):
- Read - 讀取檔案內容
- Glob - 依模式尋找檔案
- Grep - 搜尋檔案內容
- WebSearch - 搜尋網頁
- LSP - 程式碼智慧功能(前往定義、尋找參照、懸停文件)18
LSP工具功能(v2.0.74+): LSP工具提供類似IDE的程式碼智慧功能: - 前往定義:跳至符號的定義位置 - 尋找參照:列出整個程式碼庫中某個符號的所有使用位置 - 懸停文件:取得任何符號的型別資訊與文件 - 可搭配TypeScript、Python、Go、Rust,以及其他支援LSP的語言使用 - 需要可用的language server(通常隨工具鏈安裝)
修改工具(需要核准):
- Edit - 修改既有檔案
- Write - 建立新檔案
- Bash - 執行shell指令
- WebFetch - 擷取URL內容
- NotebookEdit - 修改Jupyter notebook
修改工具第一次執行時,Claude Code會提示要求核准。除非另有明確設定,核准會在該工作階段內持續有效。
權限模式
| 模式 | 行為 | 使用情境 |
|---|---|---|
default |
每個工具首次使用時提示 | 一般開發 |
acceptEdits |
自動核准檔案編輯,bash需提示 | 受信任的專案 |
auto |
分類器會檢查每個動作是否安全 | 具保護機制的自主操作(v2.1.85+) |
plan |
不允許執行或編輯 | 僅供分析 |
bypassPermissions |
略過所有提示 | CI/CD自動化 |
即使在acceptEdits下,程式碼執行設定檔現在也會提示(v2.1.160)。 acceptEdits會自動核准一般編輯,但自v2.1.160起,寫入可能授予靜默指令執行能力的檔案前會停止並提示:shell啟動檔(.zshenv、.zlogin、.bash_login)、~/.config/git/,以及建置工具設定(.npmrc、.yarnrc*、bunfig.toml、.bazelrc、.pre-commit-config.yaml、.devcontainer/等)。原因是,只要編輯這些檔案,就可能讓下一次shell、安裝或提交變成執行向量。因此,即使在其他編輯都會放行的受信任專案模式中,這類檔案仍需要一道刻意的閘門。這與既有.claude/、.git/與.vscode/寫入保護採用相同威脅模型,只是擴展到更廣泛的「編輯即成為執行」檔案類別。178
Auto Mode(v2.1.85+): 這是--dangerously-skip-permissions較安全的替代方案。另一個分類器模型(Sonnet 4.6)會在每個動作執行前進行檢查,確認其符合使用者意圖且安全。124
運作方式: - 工作目錄中的唯讀動作與檔案編輯會自動核准 - 自訂allow/deny規則會優先解析 - 其他所有動作都交由分類器評估 - 若遭封鎖,Claude會自動嘗試替代做法
預設會自動封鎖:curl | bash、強制推送到main、生產環境部署/遷移、大量雲端刪除、IAM/權限變更、將敏感資料傳送到外部。125
斷路器:同一工作階段中連續封鎖3次或總計封鎖20次,會暫停並回到手動提示。125
# Enable at startup
claude --enable-auto-mode
# Or cycle into it during a session
Shift+Tab # Cycles through: default → acceptEdits → auto → plan
可用性:Team方案使用者優先,Enterprise與API隨後提供。需要Sonnet 4.6或Opus 4.6。124
YOLO Mode(v2.0.68+): 若要在沒有任何安全分類器的情況下完全自主運作,請使用--dangerously-skip-permissions旗標。此旗標會對所有事情說是:檔案編輯、bash指令、所有工具呼叫。「dangerous」一詞是刻意使用的。對多數使用情境而言,Auto Mode是建議的替代方案。54
claude --dangerously-skip-permissions
透過CLI設定模式:
claude --permission-mode auto # or acceptEdits, plan, bypassPermissions
在工作階段中切換:
Shift+Tab # Cycles through modes
在settings.json中:
{
"permissions": {
"defaultMode": "acceptEdits"
}
}
權限規則語法
細緻規則可控制特定操作。規則會依序評估:第一個相符項勝出。
Bash指令模式:
{
"allow": [
"Bash(npm run build)",
"Bash(npm run test:*)",
"Bash(git commit:*)",
"Bash(make:*)"
],
"deny": [
"Bash(rm -rf:*)",
"Bash(sudo:*)",
"Bash(curl|wget:*)"
]
}
星號提供前綴比對:Bash(npm run test:*)允許npm run test、npm run test:unit與npm run test:integration。
重要限制: Bash模式只比對前綴,不是regex。像Bash(curl http:*)這樣的模式不會比對curl -X GET http://...,因為選項出現在URL之前。若要可靠封鎖,請直接拒絕整個指令:Bash(curl:*)。
檔案操作模式:
{
"allow": [
"Edit(src/**)",
"Write(src/**)",
"Read(docs/**)"
],
"deny": [
"Read(.env*)",
"Read(secrets/**)",
"Edit(.git/**)",
"Edit(node_modules/**)"
]
}
路徑語法:
- 相對路徑:Edit(src/**) - 相對於工作目錄
- 從設定檔起算的絕對路徑:Edit(/build/**) - 相對於設定檔位置
- 真正的絕對路徑:Edit(//tmp/**) - 以//開頭
- 家目錄:Read(~/.zshrc)
MCP工具模式:
{
"allow": [
"mcp__github",
"mcp__database__query",
"mcp__myserver__*"
],
"deny": [
"mcp__dangerous_server",
"mcp__untrusted__*"
]
}
使用萬用字元語法mcp__server__*,可允許或拒絕特定MCP伺服器的所有工具。32 萬用字元語法很適合用來快速啟用受信任伺服器的所有工具,或封鎖來自不受信任來源的整個伺服器。
自v2.1.166起,deny規則也接受工具名稱位置中的glob:工具名稱欄位中單獨的"*"會拒絕所有工具,因此您可以先封鎖一切,再允許少量特定工具。相較之下,allow規則會拒絕非MCP的glob;您無法用相同方式廣泛allow-all,這讓預設姿態維持嚴格。176
參數層級比對 — Tool(param:value)(v2.1.178):
除了工具名稱之外,規則也可以比對工具的輸入參數,並以*作為值的萬用字元:
{
"deny": [
"Agent(model:opus)"
]
}
Agent(model:opus)會封鎖任何在Opus層級上產生的subagent;被拒絕的是產生動作本身,而不只是要求prompt避免這麼做。這將權限控制從「哪個工具」延伸到「如何呼叫它」,以確定性規則取代prompt層級請求。它可與受管的enforceAvailableModels設定搭配使用:allowlist定義此工作階段可用的模型層級,而Tool(model:...)規則則限制subagents如何取用這些層級。173
WebFetch模式:
{
"allow": [
"WebFetch(domain:github.com)",
"WebFetch(domain:api.example.com)"
]
}
其他目錄
將Claude的存取範圍延伸到目前專案之外:
{
"permissions": {
"additionalDirectories": [
"../shared-lib",
"../docs",
"~/reference-projects/design-system"
]
}
}
對monorepo而言,或當Claude需要參照同層目錄中的程式碼時,其他目錄至關重要。
Sandbox Mode
啟用檔案系統與網路隔離:
> /sandbox
或在設定中配置:
{
"sandbox": {
"enabled": true,
"autoAllowBashIfSandboxed": true,
"excludedCommands": ["git", "docker"],
"network": {
"allowUnixSockets": ["~/.ssh/agent-socket"],
"allowLocalBinding": true,
"deniedDomains": ["pastebin.com", "transfer.sh", "0x0.st"]
}
}
}
在sandbox中:
- 檔案系統存取限制在專案目錄
- 網路存取受到控制
- 某些指令排除於sandbox限制之外
- 若autoAllowBashIfSandboxed為true,Bash指令會自動允許
專家提示: Sandbox mode非常適合在不受信任的程式碼庫上執行Claude。探索不熟悉的專案,或希望多一層保護時,建議啟用。Anthropic內部測試發現,sandboxing可將權限提示減少84%。38 sandbox使用作業系統層級原語(macOS seatbelt、Linux bubblewrap)進行檔案系統與網路隔離,因此即使prompt injection成功,也會被完整限制在其中。Anthropic已將sandbox runtime開源,供建立自家agents的團隊使用。82
安全性注意事項(v2.1.34+): 先前,透過sandbox.excludedCommands或dangerouslyDisableSandbox排除於sandbox之外的指令,在autoAllowBashIfSandboxed啟用時,可能繞過Bash詢問權限規則;此問題已於v2.1.34修正。87 自v2.1.38起,sandbox mode會封鎖對.claude/skills的寫入,防止prompt injection修改skill定義。88 v2.1.77新增allowRead sandbox檔案系統設定,可在denyRead區域內重新允許讀取存取;當您想封鎖大部分目錄樹,但將特定子目錄列入白名單時很有用。119
.claude/ agent-config豁免(v2.1.121+): --dangerously-skip-permissions不再對.claude/skills/、.claude/agents/與.claude/commands/的寫入提示。154
巢狀.claude/解析(v2.1.178): 當您處理某個目錄下的檔案時,巢狀.claude/skills目錄中的skills現在會自動載入,而不只從repo根目錄載入;若名稱衝突,巢狀skill可用<dir>:<name>定址,因此兩者都能保留可用。專案其餘表面也以相同方式解析:當agent、workflow或output-style名稱在巢狀.claude/目錄間衝突時,最接近工作目錄者勝出;而專案範圍workflow的儲存目標,會是最接近的既有.claude/workflows/。對monorepo或repo-of-repos而言,這可讓每個package的工具在對應情境中啟用,而不是只有一個扁平的全域表面。173
自訂bubblewrap與socat路徑(v2.1.133+): sandbox.bwrapPath與sandbox.socatPath受管設定可讓管理員將Linux/WSL部署指向非標準的bubblewrap與socat二進位檔位置。當發行版將這些工具安裝在$PATH之外,或組織使用自家加固版本時很實用。160
v2.1.113中的安全強化:150
sandbox.network.deniedDomains即使較廣泛的allowedDomains萬用字元原本會允許特定主機,也能封鎖這些主機。可使用封鎖清單阻斷pastebin、檔案投放站或已知惡意主機,而不必重寫整個allow政策。- 包裝指令deny規則。 Bash deny規則現在會比對包在
env、sudo、watch、ionice、setsid與類似exec包裝器中的指令。像Bash(rm:*)這類規則,現在能捕捉env rm -rf、sudo rm -rf與同類繞過模式。 Bash(find:*)allow規則不再自動核准find -exec或find -delete。 這些旗標會執行指令與刪除檔案,因此Claude Code會將它們導向一般權限路徑。- macOS移除保護。
Bash(rm:*)allow規則現在會將/private/etc、/private/var、/private/tmp與/private/home視為危險移除目標。/var、/etc與/tmp都是指向/private/的symlink,因此先前的規則形狀會漏掉canonical目標。
Hooks如何運作?
Hooks會在Claude Code工作流程中的特定時間點執行確定性的shell命令。不同於提示Claude執行動作,hooks能保證執行,不受模型行為影響。它們對於強制執行團隊標準與自動化重複性工作至關重要。請參閱決策框架,了解涵蓋command、prompt與agent hooks的「Which Hook Type?」決策樹。
為什麼用hooks而不是prompts:告訴Claude「編輯檔案後一律執行Prettier」有時有效。但Claude可能會忘記、優先求快,或判斷變更「太小」。Hooks保證執行:每次Edit或Write都會觸發您的formatter,次次如此,毫無例外。對於合規、安全性與團隊標準而言,確定性勝過機率性。4
可用事件
| Event | Timing | Can Block | Purpose |
|---|---|---|---|
PreToolUse |
工具執行前 | 是 | 驗證、記錄或封鎖操作 |
PostToolUse |
工具完成後 | 否 | 格式化輸出、執行linters、觸發builds |
PostToolUseFailure |
工具失敗後 | 否 | 記錄失敗、傳送警示、提供修正回饋 |
UserPromptSubmit |
使用者送出prompt | 是 | 加入context、驗證輸入、注入資料 |
Notification |
觸發警示時 | 否 | 自訂通知處理 |
Stop |
Claude完成回應 | 是 | 防止過早停止、強制完成條件。包含last_assistant_message(v2.1.47+) |
SubagentStart |
Subagent生成時 | 否 | 記錄agent類型、透過additionalContext注入context |
SubagentStop |
Subagent完成時 | 是 | 防止subagent停止、強制品質門檻。包含last_assistant_message(v2.1.47+) |
TeammateIdle |
Agent團隊成員閒置時 | 是 | 在teammate停止前強制品質門檻(v2.1.33+) |
TaskCompleted |
Task標記完成時 | 是 | 強制完成條件、執行測試(v2.1.33+) |
SessionStart |
Session開始時 | 否 | 環境設定、載入context、設定env vars |
SessionEnd |
Session關閉時 | 否 | 清理、最終記錄 |
Setup |
--init/--init-only/--maintenance flags |
否 | 環境設定工作(v2.1.10+)53 |
InstructionsLoaded |
載入CLAUDE.md或.claude/rules/*.md時 |
否 | 回應instruction檔案變更、注入context(v2.1.69+) |
ConfigChange |
Session期間config檔案變更時 | 是 | 稽核settings變更、強制安全政策(v2.1.49+) |
WorktreeCreate |
Worktree建立中 | 是 | 自訂VCS設定(取代預設git行為)(v2.1.50+) |
WorktreeRemove |
Worktree移除中 | 否 | 自訂VCS清理(v2.1.50+) |
PreCompact |
Context壓縮前 | 是(v2.1.105+) | 驗證、記錄、封鎖壓縮(exit 2或{"decision":"block"}) |
PostCompact |
Context壓縮後 | 否 | 記錄、cache重用最佳化(v2.1.76+)118 |
Elicitation |
MCP伺服器要求結構化輸入時 | 是 | 攔截/覆寫MCP elicitation dialogs(v2.1.76+)118 |
ElicitationResult |
使用者回應MCP elicitation時 | 是 | 驗證/轉換elicitation回應(v2.1.76+)118 |
StopFailure |
因API錯誤結束turn(rate limits、auth failures) | 否 | 錯誤警示、重試邏輯(v2.1.78+)120 |
PermissionRequest |
顯示權限dialog時 | 是 | 自訂核准邏輯 |
PermissionDenied |
Auto mode classifier拒絕動作時 | 否 | 記錄拒絕,回傳{retry: true}以允許重試(v2.1.88+)127 |
Hook設定
在settings.json或專用hooks.json中定義hooks:
{
"hooks": {
"PostToolUse": [
{
"matcher": "Edit|Write",
"hooks": [
{
"type": "command",
"command": "npx prettier --write \"$FILE_PATH\""
}
]
}
],
"PreToolUse": [
{
"matcher": "Bash",
"hooks": [
{
"type": "command",
"command": ".claude/hooks/validate-bash.sh"
}
]
}
],
"UserPromptSubmit": [
{
"matcher": "",
"hooks": [
{
"type": "command",
"command": ".claude/hooks/inject-context.sh"
}
]
}
]
}
}
Matchers
matcher欄位決定哪些工具會觸發hook:
{"matcher": "*"} // Match all tools
{"matcher": "Bash"} // Match Bash only
{"matcher": "Edit|Write"} // Match Edit or Write
{"matcher": "mcp__github"} // Match MCP server tools
{"matcher": ""} // Match for events without tools (like UserPromptSubmit)
Hook輸入/輸出協定
Hooks會透過stdin接收JSON:
{
"tool_name": "Bash",
"tool_input": {
"command": "npm test",
"description": "Run test suite"
},
"session_id": "abc-123"
}
Hook事件增補(v2.1.69+):所有hook事件現在若由subagent或--agent session觸發,都會包含agent_id與agent_type欄位;status line hook命令中也會包含worktree欄位。110
Stop/SubagentStop hooks(v2.1.47+)會接收額外的last_assistant_message欄位,其中包含Claude的最終回應文字,讓hooks無需剖析transcript檔案即可檢查輸出:
{
"session_id": "abc-123",
"last_assistant_message": "I've completed the refactoring. Here's what changed..."
}
不封鎖的軟性回饋(v2.1.163+):Stop與SubagentStop hooks可以在其JSON輸出中回傳hookSpecificOutput.additionalContext,將回饋交給Claude並讓turn繼續,而不會把回應標記為hook錯誤。在此之前,Stop hook唯一真正可用的手段是exit-2封鎖(會被視為錯誤,且計入連續封鎖上限);additionalContext新增了一條導引通道,可傳達「這是您漏掉的內容,請繼續」這類指引,而不會與循環機制相互衝突。177
Exit codes控制行為:
- 0:成功:操作繼續。Stdout會在verbose mode(Ctrl+O)顯示。對於UserPromptSubmit與SessionStart,stdout會加入context。
- 2:封鎖錯誤:操作停止。Stderr會成為回饋給Claude的錯誤訊息。
- 1, 3, etc.:非封鎖錯誤:操作繼續。Stderr會在verbose mode中顯示為警告。
若需進階控制,hooks可以輸出JSON:
{
"decision": "allow",
"message": "Command validated and modified",
"modifications": {
"tool_input": {
"command": "npm test -- --coverage"
}
}
}
PreToolUse決策控制(建議格式):PreToolUse hooks使用hookSpecificOutput提供更豐富的控制:3種結果(allow/deny/ask),並可修改tool input與注入context:89
{
"hookSpecificOutput": {
"hookEventName": "PreToolUse",
"permissionDecision": "allow",
"permissionDecisionReason": "Command validated and modified",
"updatedInput": {
"command": "npm test -- --coverage --ci"
},
"additionalContext": "Note: This database has a 5-second query timeout."
}
}
| Field | Values | Description |
|---|---|---|
permissionDecision |
"allow", "deny", "ask" |
Allow會略過權限,deny會封鎖,ask會提示使用者 |
permissionDecisionReason |
String | 顯示給使用者(allow/ask)或Claude(deny) |
updatedInput |
Object | 在執行前修改tool input |
additionalContext |
String | 注入Claude在該turn的context44 |
注意:PreToolUse的頂層decision與reason欄位已棄用。請改用hookSpecificOutput.permissionDecision與hookSpecificOutput.permissionDecisionReason。其他事件(PostToolUse、Stop等)仍使用頂層decision。89
UserPromptSubmit session title(v2.1.94+):UserPromptSubmit hooks可以透過hookSpecificOutput.sessionTitle設定session標題。140
Async Hooks(2026年1月)
Hooks現在可以在背景執行,而不封鎖Claude Code的執行。請在hook設定中加入async: true:81
{
"hooks": {
"PostToolUse": [
{
"matcher": "Edit|Write",
"hooks": [
{
"type": "command",
"command": ".claude/hooks/notify-slack.sh",
"async": true
}
]
}
]
}
}
何時使用async hooks: - 不應拖慢session的通知(Slack、email、Pushover) - 可在背景執行的logging與telemetry - 非關鍵post-processing(analytics、backups)
何時不要使用async hooks: - 格式化(必須在下一次編輯前完成) - 驗證(失敗時必須封鎖) - 任何需要修改tool input/output的hook
Prompt-Based與Agent-Based Hooks(v2.1.32+)
除了shell command hooks(type: "command")之外,Claude Code支援兩種由LLM驅動的hook類型,使用AI推理而非scripts來評估條件。89
Prompt hooks(type: "prompt")會將single-turn prompt傳送給快速Claude模型。模型回傳{ "ok": true }以允許,或回傳{ "ok": false, "reason": "..." }以封鎖:
{
"hooks": {
"Stop": [
{
"hooks": [
{
"type": "prompt",
"prompt": "Evaluate if Claude should stop: $ARGUMENTS. Check if all requested tasks are complete and tests pass.",
"timeout": 30
}
]
}
]
}
}
HTTP hooks(type: "http")會將事件的JSON輸入作為POST request傳送到URL,並接收JSON回應。可用於webhooks、外部通知服務,或基於API的驗證(v2.1.63+):104
{
"hooks": {
"PostToolUse": [
{
"matcher": "Edit|Write",
"hooks": [
{
"type": "http",
"url": "https://api.example.com/notify",
"headers": {
"Authorization": "Bearer $MY_TOKEN"
},
"allowedEnvVars": ["MY_TOKEN"]
}
]
}
]
}
}
HTTP hooks使用與command hooks相同的決策格式(回傳含有decision與reason的JSON)。啟用sandboxing時,它們會透過sandbox network proxy路由。不支援SessionStart/Setup事件。
Agent hooks(type: "agent")會生成具備tool access(Read、Grep、Glob)的subagent,用於multi-turn驗證。當檢查需要實際檢視檔案或測試輸出時,請使用此類型:
{
"hooks": {
"Stop": [
{
"hooks": [
{
"type": "agent",
"prompt": "Verify all unit tests pass. Run the test suite and check results. $ARGUMENTS",
"timeout": 120
}
]
}
]
}
}
使用$ARGUMENTS作為hook之JSON輸入的placeholder。兩種類型都支援model(預設為fast model)與timeout欄位。支援事件:PreToolUse、PostToolUse、PostToolUseFailure、PermissionRequest、UserPromptSubmit、Stop、SubagentStop、TaskCompleted。TeammateIdle不支援prompt/agent hooks。
MCP Tool Hooks(v2.1.118+)
Hooks現在可以透過type: "mcp_tool"直接呼叫MCP tool,不必再包一層呼叫伺服器的Bash subprocess。152
{
"hooks": {
"PostToolUse": [
{
"matcher": "Edit",
"hooks": [
{
"type": "mcp_tool",
"server": "linear",
"tool": "create_comment",
"input": {"issue_id": "ENG-123", "body": "Auto-updated by Claude Code"}
}
]
}
]
}
}
這與使用者已設定的MCP伺服器相當契合:凡是可從/mcp存取的tool,都可由hook呼叫。
PostToolUse Hooks中的duration_ms(v2.1.119+)
PostToolUse與PostToolUseFailure hook輸入現在包含duration_ms,也就是tool的執行時間,不含permission prompts與PreToolUse hooks。152這對偵測慢速tool、audit logs與逐tool latency metrics很有用:
# Stderr-flagged warning when an Edit takes more than 10 seconds
DUR=$(jq -r '.duration_ms')
if [ "$DUR" -gt 10000 ]; then
echo "[slow-edit] ${DUR}ms — investigate $TOOL_INPUT_FILE_PATH" >&2
fi
所有Tools皆支援updatedToolOutput(v2.1.121+)
在v2.1.118中,MCP Tool Hooks取得透過hookSpecificOutput.updatedToolOutput取代tool output的能力。自v2.1.121起,同一欄位適用於任何PostToolUse hook——內建tools(Bash、Read、Edit、Glob、Grep等)、subagent tools與MCP tools。使用情境包括:從任何tool output中遮蔽敏感內容、為下游消費者正規化結構、在agent讀取結果前注入metadata。154
Hook環境變數
Hooks可存取環境變數以解析路徑:89
| Variable | Available In | Description |
|---|---|---|
$CLAUDE_PROJECT_DIR |
All hooks | 專案根目錄(路徑含空格時請加引號) |
${CLAUDE_PLUGIN_ROOT} |
Plugin hooks | Plugin的根目錄 |
$CLAUDE_ENV_FILE |
僅SessionStart | 用於為後續Bash命令持久保存env vars的檔案路徑 |
$CLAUDE_CODE_REMOTE |
All hooks | 在remote web environments中設為"true" |
$CLAUDE_EFFORT |
All hooks + Bash tool subprocess | 目前effort level。Hooks也會透過effort.level JSON輸入欄位接收此值(v2.1.133+)。160 |
$CLAUDE_CODE_SESSION_ID |
Bash tool subprocess | 與傳遞給hooks的session_id相符的Session ID。讓long-running shells能關聯同一session中的輸出(v2.1.132+)。159 |
從SessionStart持久保存環境變數:
#!/bin/bash
if [ -n "$CLAUDE_ENV_FILE" ]; then
echo 'export NODE_ENV=production' >> "$CLAUDE_ENV_FILE"
fi
exit 0
HTTP hook安全性(v2.1.51+):會將環境變數插入headers的HTTP hooks現在需要明確的allowedEnvVars清單。這可防止任意環境變數透過header values外洩。啟用sandboxing時,HTTP hooks也會透過sandbox network proxy路由,並強制執行domain allowlist。HTTP hooks不支援SessionStart/Setup事件。98
{
"hooks": {
"PostToolUse": [{
"hooks": [{
"type": "command",
"command": "curl -H 'Authorization: Bearer $MY_TOKEN' https://api.example.com/notify",
"allowedEnvVars": ["MY_TOKEN"]
}]
}]
}
}
Hook workspace trust(v2.1.51+):statusLine與fileSuggestion hook命令現在需要先接受workspace trust,才會在interactive mode中執行,以關閉潛在安全向量。98
實用Hook範例
編輯後自動格式化TypeScript檔案:
{
"hooks": {
"PostToolUse": [
{
"matcher": "Edit|Write",
"hooks": [
{
"type": "command",
"command": "bash -c '[[ \"$FILE_PATH\" == *.ts ]] && npx prettier --write \"$FILE_PATH\" || true'"
}
]
}
]
}
}
記錄所有bash命令:
{
"hooks": {
"PreToolUse": [
{
"matcher": "Bash",
"hooks": [
{
"type": "command",
"command": "jq -r '.tool_input.command' >> ~/.claude/bash-history.log"
}
]
}
]
}
}
封鎖對敏感檔案的存取:
#!/bin/bash
# .claude/hooks/protect-files.sh
data=$(cat)
path=$(echo "$data" | jq -r '.tool_input.file_path // empty')
if [[ "$path" == *".env"* ]] || [[ "$path" == *"secrets/"* ]] || [[ "$path" == *".pem"* ]]; then
echo "Blocked: Cannot access sensitive file $path" >&2
exit 2 # Exit 2 = block the tool call. Exit 1 = non-blocking error (hook failure only).
fi
exit 0
程式碼變更後執行測試:
{
"hooks": {
"PostToolUse": [
{
"matcher": "Edit",
"hooks": [
{
"type": "command",
"command": "bash -c '[[ \"$FILE_PATH\" == *.test.ts ]] || npm run test:affected'"
}
]
}
]
}
}
自訂通知系統:
{
"hooks": {
"Notification": [
{
"matcher": "",
"hooks": [
{
"type": "command",
"command": "notify-send 'Claude Code' 'Waiting for your input'"
}
]
}
]
}
}
將動態context注入prompts:
#!/bin/bash
# .claude/hooks/inject-context.sh
# Add current git branch and recent commits to every prompt
branch=$(git branch --show-current 2>/dev/null)
commits=$(git log --oneline -3 2>/dev/null | tr '\n' ' ')
if [ -n "$branch" ]; then
echo "[Context: Branch '$branch', Recent: $commits]"
fi
exit 0
Hook偵錯
啟用debug mode以疑難排解hooks:
claude --debug
Debug mode會記錄: - Hook執行時間 - Input/output資料 - 錯誤訊息與stack traces - 決策結果(allow/reject/ask)
Hook來源顯示(v2.1.75+):當hook需要使用者確認時,permission prompt現在會顯示hook來源(settings、plugin或skill),更容易辨識是哪個元件正在要求存取權。117
Component-Scoped Hooks(v2.1.0+)
Hooks可以透過frontmatter直接定義在Skills、subagents與slash commands中。這些hooks的作用範圍限於該元件的生命週期,且只會在該元件啟用時執行。34
內嵌hooks的Skill:
---
name: secure-deployment
description: Deployment skill with security validation
hooks:
PreToolUse:
- matcher: Bash
command: ".claude/hooks/validate-deploy.sh"
PostToolUse:
- matcher: Bash
command: ".claude/hooks/log-deploy.sh"
Stop:
- command: ".claude/hooks/cleanup.sh"
once: true # Run only once per session
---
支援事件:PreToolUse、PostToolUse、Stop
once選項(僅skills與slash commands)可確保hook每個session只執行一次,適合cleanup或finalization工作。
長時間執行Sessions策略
對於隔夜或無人值守的Claude Code sessions,請設定hooks,讓Claude無需人工介入也能維持方向。關鍵洞見是:將linting與testing hooks當作guardrails,迫使Claude在繼續前修正問題。57
「測試通過前不要停止」模式:
{
"hooks": {
"PostToolUse": [
{
"matcher": "Edit",
"hooks": [
{
"type": "command",
"command": "npm run lint && npm run typecheck",
"timeout": 60000
}
]
}
],
"Stop": [
{
"hooks": [
{
"type": "command",
"command": "npm test || echo 'Tests failing - Claude should fix before stopping'"
}
]
}
]
}
}
隔夜sessions策略:
- Pre-flight check:使用Setup hook確認環境已就緒
- Continuous validation:PostToolUse hooks在每次變更後執行測試
- Gate completion:Stop hooks在Claude宣稱「done」前驗證所有acceptance criteria
- Notification:Stop hooks可在Claude完成或卡住時,透過Slack/Pushover通知您
在sandboxed container中搭配--dangerously-skip-permissions,即可進行完全自主的隔夜執行。Claude會持續迭代,直到測試通過或用盡可行選項。
什麼是MCP(Model Context Protocol)?
MCP透過標準化協定,讓Claude Code能夠存取外部工具、資料庫、API及各項服務。整個生態系正快速成長:MCP目前在MCP.so上每月達到1億次下載量,並收錄3,000多個伺服器(2026年1月),確立其作為AI連接工具與資料的業界標準地位。347 對於想將Claude整合進現有工具鏈的開發者而言,理解MCP至關重要。
MCP對開發者為何重要: 沒有MCP時,Claude Code只能讀取檔案並執行bash指令。有了MCP,Claude便能查詢您的正式環境資料庫、建立Jira工單、審查GitHub PR、檢查Sentry錯誤,並與您的團隊使用的任何API互動,這一切都透過自然語言請求完成。此協定標準化了AI工具與外部服務的連接方式,避免了廠商鎖定。請參閱Decision Frameworks,了解何時應使用MCP,以及何時應採用其他擴充機制。
遠端MCP支援(2025年6月)
Claude Code現已支援具備原生OAuth身分驗證的遠端MCP伺服器。21 連線到工具與資料來源時無需管理本機伺服器。只要驗證一次,Claude Code便會自動處理權杖更新。
# Connect to remote MCP server with OAuth
claude mcp add --transport http linear https://mcp.linear.app/sse
# Browser opens for OAuth flow, tokens stored securely
SDK mcp_authenticate redirectUri(v2.1.121+): Agent SDK的mcp_authenticate接受redirectUri參數,可在自訂URI scheme上完成OAuth——這對於無法使用預設loopback重新導向的桌面應用程式與claude.ai連接器流程而言是必要的。154
claude.ai MCP連接器(v2.1.46+)
Claude Code現在可以使用您在claude.ai帳戶中設定的MCP連接器。這弭平了網頁與CLI之間的鴻溝:您透過claude.ai介面設定的MCP伺服器,會自動在Claude Code中可用,無需在本機重新設定。95
停用方式: 在環境變數或settings.json的env區塊中設定ENABLE_CLAUDEAI_MCP_SERVERS=false,即可避免載入claude.ai MCP伺服器。104
MCP工具搜尋(v2.1.7+)
隨著MCP伺服器的功能日益強大(部分伺服器甚至公開50個以上的工具),工具描述開始消耗大量context。MCP工具搜尋透過動態載入工具描述(僅在需要時載入)解決此問題,這是AI工具的延遲載入機制。47
效能影響: 內部基準測試顯示準確度大幅提升: - Opus 4:MCP評估從49%提升至74% - Opus 4.5:MCP評估從79.5%提升至88.1% - Token消耗降低:85%
運作原理: 當MCP工具描述超過context window的10%(預設閾值)時,Claude Code會延後載入完整描述,直到實際需要時才載入。Claude能看到工具名稱,但會依需求取得描述。
設定方式:
{
"mcpToolSearchAutoEnable": "auto:15" // Enable when tools exceed 15% of context
}
可用值:
- true - 永遠啟用工具搜尋
- false - 永遠停用(預先載入所有工具描述)
- auto:N - 當工具超過context的N%時啟用(0-100)
專家提示: 啟用工具搜尋後,您可以連接更多MCP伺服器,無需擔心context限制。95%的context減少意味著過去爭奪context的伺服器,現在可以和平共存。
MCP永久載入覆寫(v2.1.121+)
工具搜尋會延後載入完整描述,直到工具被需要時才載入(閾值:mcpToolSearchAutoEnable,預設auto:10)。對於您預期每輪都會使用其工具的受信任伺服器,可透過alwaysLoad: true針對個別伺服器停用此延後載入——該伺服器的所有工具會在工作階段啟動時就載入到prompt中,不需要ToolSearch往返:154
{
"mcpServers": {
"github": {
"type": "http",
"url": "https://api.githubcopilot.com/mcp/",
"alwaysLoad": true
}
}
}
MCP啟動自動重試(v2.1.121+): 啟動期間發生錯誤的伺服器,現在會在被標記為中斷連線之前重試最多3次——這對於與緩慢父行程競爭的stdio伺服器,或位於冷啟動後端後方的HTTP伺服器特別有用。154
MCP引導取得(v2.1.76+)
MCP伺服器現在可以透過互動式對話框,在任務進行中向使用者請求結構化輸入。118 當MCP伺服器需要額外資訊時(例如選擇分支、輸入專案名稱、確認操作),它會發送引導取得請求,Claude Code則將其呈現為表單欄位或瀏覽器URL。
Hook整合: 兩個新的hook事件——Elicitation(對話框出現之前)與ElicitationResult(使用者回應之後)——讓您能以程式化方式攔截、驗證或覆寫引導取得的回應。這讓企業工作流程能夠預先填入MCP伺服器的提示,或依政策加以限制。
MCP結果大小覆寫(v2.1.91+)
MCP工具結果預設會被截斷。伺服器可使用_meta["anthropic/maxResultSizeChars"]註解針對個別結果覆寫此設定,最多允許500K個字元。136 這對於回傳大型負載(例如資料庫schema、API回應或檔案內容)而不被截斷非常有用。
互動式MCP設定精靈
執行不帶參數的claude mcp add,啟動逐步介面以新增MCP伺服器。此精靈會引導您完成傳輸類型選擇、身分驗證與設定。8
傳輸類型
HTTP(建議用於遠端伺服器):
claude mcp add --transport http github https://api.githubcopilot.com/mcp/
# With authentication
claude mcp add --transport http api https://api.example.com/mcp \
--header "Authorization: Bearer $API_TOKEN"
SSE(已棄用但仍可使用):
claude mcp add --transport sse asana https://mcp.asana.com/sse \
--header "X-API-Key: your-key"
Stdio(本機伺服器):
# PostgreSQL
claude mcp add --transport stdio postgres \
--env "DATABASE_URL=postgresql://user:pass@localhost/db" \
-- npx -y @anthropic-ai/mcp-server-postgres
# Custom server
claude mcp add --transport stdio custom -- python /path/to/server.py --port 8000
Windows環境的stdio需要cmd包裝器:
claude mcp add --transport stdio my-server -- cmd /c npx -y @some/package
範圍管理
MCP伺服器存在於三個範圍中,並具備明確的優先順序(local覆寫project,project覆寫user):
| 範圍 | 儲存位置 | 可見性 | 使用情境 |
|---|---|---|---|
| Local | ~/.claude.json(專案路徑) |
僅限您本人,本專案 | 個人API金鑰 |
| Project | .mcp.json |
整個團隊(透過git) | 共享整合 |
| User | ~/.claude.json(根目錄) |
您本人,所有專案 | 個人工具 |
安裝時指定範圍:
claude mcp add --scope project --transport http github https://...
claude mcp add --scope user --transport stdio personal-tool -- ./my-tool
設定檔格式
.mcp.json檔案定義專案層級的伺服器:
{
"mcpServers": {
"github": {
"type": "http",
"url": "https://api.githubcopilot.com/mcp/"
},
"database": {
"type": "stdio",
"command": "npx",
"args": ["-y", "@anthropic-ai/mcp-server-postgres"],
"env": {
"DATABASE_URL": "${DATABASE_URL}"
}
},
"sentry": {
"type": "http",
"url": "https://mcp.sentry.dev/mcp",
"headers": {
"Authorization": "Bearer ${SENTRY_API_KEY}"
}
},
"internal-api": {
"type": "http",
"url": "${API_BASE_URL:-https://api.example.com}/mcp",
"headers": {
"X-API-Key": "${INTERNAL_API_KEY}"
}
}
}
}
環境變數使用${VAR}語法展開,並可選擇預設值:${VAR:-default}。
MCP管理指令
claude mcp list # View all configured servers
claude mcp get github # Get specific server details
claude mcp remove github # Remove a server
claude mcp reset-project-choices # Reset project-scoped approvals
claude mcp add-from-claude-desktop # Import from Claude Desktop
claude mcp add-json weather '{"type":"http","url":"..."}' # Add from JSON
# Within Claude Code REPL
> /mcp # Interactive MCP management
OAuth身分驗證
對於需要OAuth的伺服器:
> /mcp
# Follow browser-based OAuth flow
# Tokens stored securely and auto-refreshed
# Use "Clear authentication" to revoke access
使用MCP資源與提示
參考資源:
@github:issue://123
@postgres:schema://users
@docs:file://api/authentication
將MCP提示作為slash command使用:
/mcp__github__list_prs
/mcp__github__pr_review 456
/mcp__jira__create_issue "Bug title" high
輸出限制
Claude Code會限制MCP輸出,以避免context溢位: - 警告閾值:10,000 tokens - 預設上限:25,000 tokens
如有需要可調高:
export MAX_MCP_OUTPUT_TOKENS=50000
熱門MCP伺服器
| 伺服器 | 用途 | 主要功能 |
|---|---|---|
| GitHub | 儲存庫管理 | PR、issue、CI/CD、程式碼審查 |
| PostgreSQL | 資料庫存取 | 查詢、schema檢查、資料分析 |
| Sentry | 錯誤監控 | 錯誤查詢、stack trace、部署關聯 |
| Linear | 專案管理 | issue、專案、衝刺 |
| Jira/Atlassian | 企業專案管理 | 工單、看板、工作流程 |
| Playwright | 網頁自動化 | E2E測試、無障礙樹 |
| Stripe | 支付 | 交易查詢、客戶資料 |
| Cloudflare | 基礎設施 | DNS、worker、分析 |
| Supabase | 後端即服務 | 資料庫、身分驗證、儲存 |
| Context7 | 文件 | 即時、特定版本的函式庫文件 |
| Figma Dev Mode | 設計轉程式碼 | 圖層階層、自動排版、tokens。Figma於2026年2月透過原生合作關係深化了與Claude Code的整合。35108 |
| Sequential Thinking | 問題解決 | 結構化推理、反思流程36 |
| Magic UI | 元件 | React + Tailwind行銷元件 |
MCP實用模式
GitHub工作流程:
> Review PR #456
> List all open issues assigned to me
> Create a bug issue for the authentication failure we found
資料庫查詢:
> What's our total revenue this quarter?
> Show the schema for the users table
> Find customers with no purchases in 90 days
錯誤監控:
> What errors occurred in production today?
> Show the stack trace for error ABC123
> Which deployment introduced these errors?
企業MCP設定
系統管理員可透過managed-mcp.json強制執行MCP政策:
{
"allowedMcpServers": [
{ "serverName": "github" },
{ "serverName": "sentry" },
{ "serverCommand": ["npx", "-y", "@approved/server"] }
],
"deniedMcpServers": [
{ "serverName": "dangerous-server" }
]
}
存放位置:
- macOS:/Library/Application Support/ClaudeCode/managed-mcp.json
- Linux:/etc/claude-code/managed-mcp.json
- Windows:C:\ProgramData\ClaudeCode\managed-mcp.json
拒絕清單具有絕對優先權。指令必須完全相符,包含參數順序。
MCP Apps(2026年1月)
Anthropic推出MCP Apps,這是Model Context Protocol的擴充功能,讓互動式工具UI能直接在Claude介面內執行。71 MCP Apps讓使用者無需離開Claude,即可檢視、編輯並與來自外部服務的內容互動,包括Asana、Box、Canva、Figma、Hex、monday.com及Slack。任何MCP伺服器都可以提供能在Claude中呈現的互動式UI。雖然MCP Apps目前出現在claude.ai網頁介面中,但隨著伺服器採用新的互動功能,底層的MCP協定擴充對Claude Code的MCP生態系亦有重大意義。
API平台:Code Execution Tool v2(2026年1月)
Anthropic在公開測試版中推出Code Execution Tool v2,取代原本僅支援Python的沙箱,加入Bash指令執行與直接檔案操作功能。72 主要變更: - 在沙箱化容器中執行Bash指令(不再僅限Python) - 以任何語言撰寫並執行程式碼 - 程式化工具呼叫(亦為公開測試版):Claude可在程式碼執行內呼叫工具,降低多工具工作流程中的延遲與token使用量
v2工具主要影響API使用者,但也預示了Claude Code雲端執行能力的發展方向。
Subagents 是什麼?
Subagents 是專門化的 Claude 實例,能獨立處理複雜任務。這是 Claude Code 中最強大的功能之一,卻也是最少被真正理解的功能之一。熟練運用 subagents,能大幅擴展您可完成的工作範圍。關於 Agent Teams、Subagents 與 Parallel Sessions 的取捨,請參閱決策框架。
為什麼需要 subagents:Claude Code 的主對話只有單一 context window。您討論的所有內容、Claude 讀取的每個檔案、每個工具輸出,都會消耗該 context。在長時間工作階段中,context 會逐漸填滿,Claude 會開始失去先前決策的脈絡,效能也會下降。Subagents 透過隔離工作來解決這個問題:探索結果不會膨脹主對話,只有摘要會回傳。Claude 也可以同時執行最多 10 個 subagents,讓原本無法循序完成的工作得以並行處理。2
Subagents 如何運作
當 Claude 遇到適合集中處理的任務(深入探索、多步驟分析、專門工作)時,可以啟動一個 subagent。該 subagent 會:
- 從乾淨的 context 開始(不受主對話污染)
- 存取指定工具
- 使用特定模型運作(通常更便宜或更快)
- 將結果回傳到主對話
這種架構能避免 context overflow,同時支援複雜工作流程。自 v2.1.172(2026年6月10日)起,sub-agents 可以遞迴啟動自己的 sub-agents,最多可達 5 層深度。因此,被委派的任務本身也能進一步展開為隔離的子任務,而不再受限於單一委派層級。171
內建 Subagent 類型
Explore(快速、唯讀):
- Model: Haiku(超快速)
- Mode: 嚴格唯讀
- Tools: Glob、Grep、Read,以及安全的 bash 指令(ls、git status、git log、git diff、find、cat、head、tail)
- Thoroughness levels: Quick、Medium、Very thorough
- Use for: 程式碼庫探索、尋找檔案、理解結構
General-purpose: - Model: 繼承自主對話 - Mode: 完整讀寫 - Tools: 所有可用工具 - Use for: 複雜研究與修改任務
Plan:
- Model: 繼承自主對話(或搭配 opusplan 使用 Opus)
- Mode: 唯讀
- Tools: Read、Glob、Grep、Bash
- Use for: 執行前規劃複雜實作
觸發 Subagents
Claude 會根據任務類型自動委派給 subagents。您也可以明確要求使用它們:
> Use the explore agent to find all authentication-related files
> Have a subagent analyze the database schema thoroughly
> Spawn an agent to research how error handling works in this codebase
專家提示:面對複雜任務時,請明確要求 subagent 委派。「Use an explore agent to find…」可避免主對話的 context 膨脹。
建立自訂 Subagents
在 .claude/agents/(專案)或 ~/.claude/agents/(個人)中定義 subagents:
---
name: security-reviewer
description: Expert security code reviewer. Use PROACTIVELY after any code changes to authentication, authorization, or data handling.
tools: Read, Grep, Glob, Bash
model: opus
permissionMode: plan
---
You are a senior security engineer reviewing code for vulnerabilities.
When invoked:
1. Identify the files that were recently changed
2. Analyze for OWASP Top 10 vulnerabilities
3. Check for secrets, hardcoded credentials, SQL injection
4. Report findings with severity levels and remediation steps
Focus on actionable security findings, not style issues.
設定欄位:
| Field | Required | Options | Purpose |
|---|---|---|---|
name |
Yes | 小寫 + 連字號 | 唯一識別碼 |
description |
Yes | 自然語言 | 何時呼叫(加入「PROACTIVELY」可鼓勵自動委派) |
tools |
No | 逗號分隔 | 若省略則繼承所有工具。支援 Agent(agent_type) 以限制可啟動的 agents(v2.1.63+;Task(...) 仍可作為 alias) |
disallowedTools |
No | 逗號分隔 | 要拒絕的工具,會從繼承或指定清單中移除。自 v2.1.178 起,這裡可正確比對 MCP 伺服器層級規格(mcp__server、mcp__server__*、mcp__*)。較早版本會默默忽略這些規則,因此原本用來封鎖 MCP 伺服器的 deny rule 實際上不會生效。173 |
model |
No | sonnet、opus、haiku、inherit |
預設為 inherit(與主對話相同模型) |
permissionMode |
No | default、acceptEdits、delegate、dontAsk、bypassPermissions、plan |
權限處理。delegate 只允許團隊管理工具 |
maxTurns |
No | 整數 | subagent 停止前的最大 agentic turns |
memory |
No | user、project、local |
agent 的持久記憶範圍(v2.1.33+) |
skills |
No | 逗號分隔 | 啟動時自動將 skill 內容載入 subagent context |
mcpServers |
No | 伺服器名稱或 inline definitions | 此 subagent 可用的 MCP 伺服器 |
hooks |
No | Hook 設定物件 | 作用於此 subagent 執行範圍的 lifecycle hooks |
background |
No | true、false |
一律作為背景任務執行(v2.1.49+) |
isolation |
No | worktree |
在臨時 git worktree 中執行,以取得隔離的 repo 副本(v2.1.49+) |
限制可啟動的 subagents(v2.1.33+,v2.1.63 重新命名):tools 欄位支援 Agent(agent_type) 語法,可限制某個 agent 能啟動哪些 subagent 類型。例如,tools: Read, Grep, Agent(Explore) 允許該 agent 直接使用 Read 與 Grep,但只能委派給 Explore 類型的 subagents。此限制可避免受限 agents 過度委派。注意:在 v2.1.63 中,Task tool 已重新命名為 Agent。設定與 agent 定義中既有的 Task(...) 參照仍可作為向後相容的 alias 使用。106
CLI 定義的 Subagents(v2.1.32+)
啟動時將 subagents 定義為 JSON,適合快速測試或自動化。這些 subagents 只存在於該工作階段,不會儲存到磁碟:89
claude --agents '{
"code-reviewer": {
"description": "Expert code reviewer. Use proactively after code changes.",
"prompt": "You are a senior code reviewer. Focus on code quality and security.",
"tools": ["Read", "Grep", "Glob", "Bash"],
"model": "sonnet"
}
}'
--agents flag 接受 JSON,並支援與檔案型 subagents 相同的 frontmatter 欄位:description、prompt、tools、disallowedTools、model、permissionMode、mcpServers、hooks、maxTurns、skills 與 memory。
Subagent skill discovery 修正(v2.1.133+):較早版本有一個 bug,導致 subagents 無法透過 Skill tool 發現專案、使用者或 plugin skills,因此啟動的 subagents 只能看到全域 skill catalog。v2.1.133 修正了這點;subagents 現在會繼承 parent session 可用的完整 skill graph。這對會將任務專用 skills 與 agents 一起提供的 plugin 作者尤其重要。160
管理 Subagents
> /agents # Interactive management
> /agents create # Create new subagent
> /agents edit # Modify existing
> /agents delete # Remove subagent
> /agents list # View all
CLI 列表(v2.1.50+):不啟動互動式工作階段,也能從命令列列出所有已設定的 agents:
claude agents # Shows agents grouped by source (built-in, user, project, plugin)
Agent View(v2.1.139+):在目前版本中,claude agents 也會開啟 Agent View。這是 research-preview 的作業畫面,可從單一位置派發並監控多個 Claude Code sessions。您可以用它查看哪些 sessions 正在執行、被阻擋或已完成;但不要把這個畫面視為品質關卡。工作是否完成,仍取決於測試、review 與 hook evidence。162
Remote control(v2.1.51+):claude remote-control subcommand 會提供您的本機環境給外部 builds 使用,讓所有使用者都能遠端存取 local-environment capabilities:98
claude remote-control # Start serving local environment
claude remote-control --name "My Project" # Custom session title visible in claude.ai/code (v2.1.69+)[^117]
在背景執行 Agents
針對長時間執行的任務:
> Run a thorough security review in the background
> /agents # Check status of running agents
稍後可使用 agent ID 取回結果。
進階模式
串接式 subagents:
> First use the code-analyzer subagent to find performance issues, then use the optimizer subagent to fix them
並行探索:
> Have three explore agents search in parallel:
> 1. Authentication code
> 2. Database models
> 3. API routes
可恢復的 agents: Agents 可以使用其 ID 恢復,以延續先前工作:
> Resume agent abc123 and continue the analysis
Async Subagents(2025年12月)
Asynchronous subagents 可為大規模專案啟用多工與平行執行:
> Run security review in the background while I continue frontend work
> /tasks # Check status of running agents
Async agents 會透過統一的 TaskOutputTool 回傳結果,支援高效率的 pipeline-style 工作流程。
Permission Denial Resilience(v2.1.0+)
從 v2.1.0 起,subagents 在遇到權限拒絕後會繼續工作,而不是完全停止。當 subagent 遇到 permissions wall 時,會自動嘗試替代方法。此變更讓自主工作流程更具韌性,也降低了需要人工介入的情況。40
Agent Teams(2026年2月,Research Preview)
Agent Teams 會協調多個 Claude Code instances 一起工作。一個 session 會擔任 team lead,啟動在各自 context windows 中獨立工作的 teammates,並透過共享 mailbox 與 task list 直接彼此溝通。7984
不同於 subagents(在單一 session 內執行,且只回報給呼叫者),teammates 是完整獨立的 sessions,可以互相傳訊、質疑彼此的發現,並自行協調。
啟用:
// settings.json
{
"env": {
"CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS": "1"
}
}
或透過環境變數:export CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1
架構:
| Component | Role |
|---|---|
| Team lead | 建立 team、啟動 teammates、協調工作的主 session |
| Teammates | 處理指派任務的獨立 Claude Code instances |
| Task list | Teammates 領取並完成的共享工作項目(file-locked) |
| Mailbox | 用於 inter-agent communication 的訊息系統 |
顯示模式:
| Mode | How | Best For |
|---|---|---|
in-process(預設) |
所有 teammates 都在主終端機中。使用 Shift+Up/Down 選取。 |
任何終端機 |
tmux / iTerm2 |
每個 teammate 位於自己的 split pane | 視覺化監控 |
在 settings 中設定:"teammateMode": "in-process" 或 "tmux"。或針對單一 session 使用:claude --teammate-mode in-process。
主要控制:
- Shift+Down: 在 teammates 間循環切換(in-process mode;最後一位 teammate 後會回到 lead)
- Shift+Tab: 啟用 delegate mode(限制 lead 只能協調,不能變更程式碼)
- Ctrl+T: 切換共享 task list
- 在 teammate 上按 Enter: 檢視其 session;按 Escape 中斷其 turn
何時使用 agent teams 或 subagents:
| Subagents | Agent Teams | |
|---|---|---|
| Communication | 只回報結果 | Teammates 直接互相傳訊 |
| Coordination | Main agent 管理所有工作 | 共享 task list 搭配自我協調 |
| Best for | 只重視結果的聚焦任務 | 需要討論與協作的複雜工作 |
| Token cost | 較低 | 較高(每個 teammate = 獨立 context window) |
最佳使用案例: - 研究與 review(同時取得多個觀點) - 新模組/功能(每位 teammate 分別負責不同部分) - 以競爭假設除錯(平行測試不同理論) - 跨層協調(frontend、backend、tests 分別由不同 teammate 負責)
Teammates 的 plan approval:針對複雜或高風險任務,要求 teammates 先規劃再實作。Teammate 會停留在唯讀 plan mode,直到 lead review 並核准其方法:
Spawn an architect teammate to refactor the authentication module.
Require plan approval before they make any changes.
Lead 會自主做出核准決策。您可以用 criteria 影響其判斷:「only approve plans that include test coverage」或「reject plans that modify the database schema」。
範例 prompts:
Create an agent team to review PR #142. Spawn three reviewers:
- One focused on security implications
- One checking performance impact
- One validating test coverage
Spawn a team with 4 teammates to refactor these modules in parallel.
Use Sonnet for each teammate.
儲存:Team configs 位於 ~/.claude/teams/{team-name}/config.json(members array 包含 name、agent ID、agent type)。Task lists 位於 ~/.claude/tasks/{team-name}/。Tasks 支援 dependencies:被阻擋的 tasks 會在其 dependencies 完成後自動解除阻擋。84
Hook integration:使用 TeammateIdle(exit code 2 可送出 feedback 並讓 teammate 繼續工作)與 TaskCompleted(exit code 2 可防止 completion)hooks,對 teammates 執行品質關卡。
限制(experimental):
- in-process teammates 不支援 session resumption(/resume 不會還原它們)
- 每個 session 只能有一個 team;不支援 nested teams
- Teammates 無法啟動自己的 teams
- Split panes 需要 tmux 或 iTerm2(不支援 VS Code terminal、Windows Terminal 或 Ghostty)
- 所有 teammates 都會從 lead 的 permission mode 開始
- Token 密集:每個 teammate 都是獨立的 Claude instance
Agent Skills(2025年12月)
Agent Skills 是由指令、scripts 與 resources 組成的有組織資料夾,agents 會動態發現並載入。24 它們提供可組合、可攜式的領域專業知識:
.claude/skills/
├── security-review/
│ ├── skill.md # Instructions and prompts
│ ├── checklist.md # Security checklist
│ └── common-vulns.sh # Detection scripts
└── performance-audit/
├── skill.md
└── profiling-guide.md
Skills 與 commands 不同:commands 需要明確呼叫,而 skills 會根據任務 context 自動啟用。Claude Agent SDK(由 Claude Code SDK 重新命名而來)提供了建立支援 skills 的自訂 agents 所需的 framework。25
什麼是 Extended Thinking Mode?
Extended thinking 讓 Claude 在回應前,有更多時間推理複雜問題。它特別適合架構決策、棘手問題除錯,以及需要審慎分析的任務。
目前狀態(2026年4月)
Opus 4.7 改變了 Claude Code 中的推理運作方式。Opus 4.7 只使用 adaptive reasoning,不再有固定的 thinking budget,MAX_THINKING_TOKENS 與 CLAUDE_CODE_DISABLE_ADAPTIVE_THINKING 也不適用於它。147模型會依照任務複雜度,並在您的 /effort 設定引導下,決定每一步是否需要思考,以及要思考多少。
在 Opus 4.6 與 Sonnet 4.6 上,舊版 extended-thinking 系統仍可運作:thinking 預設開啟,預算為 31,999 個 token,可透過 MAX_THINKING_TOKENS 或 /config 調整。63若設定 CLAUDE_CODE_DISABLE_ADAPTIVE_THINKING=1,即可回復先前的固定預算行為。147
完全關閉 thinking(v2.1.166+)。對於預設會思考的模型,MAX_THINKING_TOKENS=0、--thinking disabled flag,以及各模型的 thinking toggle,現在會真正停用 thinking,而不再被忽略。當您想在原本一定會思考的模型上,快速跑一次非推理流程時,可使用此設定。176
Effort 等級:
- 在 Opus 4.7 上,可用等級為 low、medium、high、xhigh、max。所有方案與供應商的預設值都是 xhigh。
- 在 Opus 4.6 與 Sonnet 4.6 上,可用等級為 low、medium、high、max。預設值為 high,Pro 與 Max 則為 medium。
- 若設定了目前模型不支援的等級,Claude Code 會退回至等於或低於您設定值的最高支援等級(例如,xhigh 在 Opus 4.6 上會以 high 執行)。147
「ultrathink」關鍵字仍可作為脈絡內指令,要求該輪進行更多推理;它不會改變送往 API 的 effort 等級。147
舊版注意事項:Opus 4 與 Opus 4.1 已在 v2.1.68 從第一方 API 的 Claude Code 中移除。原本固定使用這些模型的使用者,已自動遷移至 Opus 4.6。109
支援的模型
- Claude Opus 4.7(僅 adaptive reasoning;固定 thinking budget 已移除)
- Claude Opus 4.6(adaptive thinking + 固定 thinking budget)
- Claude Sonnet 4.6(adaptive thinking + 固定 thinking budget)
- Claude Opus 4.5(固定 thinking budget)
- Claude Sonnet 4.5(固定 thinking budget)
- Claude Haiku 4.5(固定 thinking budget)
控制 Extended Thinking
工作階段中的快速切換:
Press Alt+T to toggle thinking on/off
注意:Anthropic 已將 thinking toggle 從 Tab 改為 Alt+T,以避免誤觸。32
透過 /config:
前往 /config → Extended Thinking,以啟用/停用或調整預算。
環境變數(永久):
# Set custom budget (default is 31,999)
export MAX_THINKING_TOKENS=8000
claude
# Double the default for complex tasks
export MAX_THINKING_TOKENS=63999
claude
停用以節省成本:
對於不需要深入推理的簡單任務,可在 /config 中停用 thinking,或降低預算來減少成本:
export MAX_THINKING_TOKENS=8000 # Reduce from default 31,999
Thinking Token 預算
| 預算 | 使用情境 |
|---|---|
| 1,024(最低) | 簡單推理任務 |
| 8,000 | 大多數程式碼任務(具成本效益) |
| 31,999(預設) | 複雜推理、架構決策 |
| 63,999(預設的 2 倍) | 詳盡分析(需要明確設定) |
成本考量:Anthropic 會將 thinking token 視為 output token 計費。預設的 31,999 預算適合大多數任務,但對於簡單操作,降低預算或完全停用 thinking 都能節省成本。
運作方式
啟用 thinking 後,Claude 會執行內部推理,影響答案但不會出現在輸出中。Claude Code 會加密 thinking,並在 signature 欄位中回傳以供驗證。
在多輪對話並搭配 tool use 時,thinking block 必須傳回 API,以維持推理連續性。Claude Code 會自動處理這件事。
何時考慮停用/降低
Extended thinking 現在是預設值,但以下情境可考慮降低預算或停用: - 簡單檔案編輯 - 例行重構 - 快速問題 - 程式碼格式化 - 成本容易累積的大量操作
快取行為
當 thinking 參數變更時,Claude Code 會保留 system prompt 快取。若在不同輪次之間變更 thinking budget 或啟用狀態,則會使 message 快取失效。
Output Styles
Output styles 可自訂 Claude 呈現資訊的方式,適合學習、文件撰寫,或符合特定團隊偏好。12
內建樣式
| 樣式 | 用途 |
|---|---|
Explanatory |
搭配推理的詳細說明 |
Learning |
解釋概念的教學格式 |
Concise |
最精簡輸出,只保留必要內容 |
設定 Output Style
> /output-style Explanatory
> /output-style Learning
或透過 settings:
{
"outputStyle": "Explanatory"
}
自訂 Output Styles
建立於 .claude/styles/:
# my-style
## Instructions
- Always explain the WHY behind each decision
- Include relevant documentation links
- Format code examples with comments
- End with a "What to do next" section
## Format
Use markdown headers for organization.
Keep explanations under 200 words per section.
使用 /output-style my-style 呼叫。
棄用(v2.1.73+):
/output-style已棄用。請改用/config管理 output styles。115
Slash Commands
Slash commands可快速存取Claude Code功能,並啟用自訂工作流程。相較於為常見操作輸入完整提示,這些指令更有效率。
內建指令參考
| Command | 用途 | 備註 |
|---|---|---|
/init |
使用CLAUDE.md初始化專案 | 建立包含專案結構的記憶檔案 |
/memory |
管理自動記憶 | 檢視並編輯自動記憶檔案(v2.1.59+) |
/copy |
複製程式碼區塊 | 互動式選擇器,可選取個別程式碼區塊或完整回應;「Always copy full response」選項會在日後呼叫時略過選擇器;w鍵會將選取內容直接寫入檔案,在SSH上特別實用;/copy N會複製第N新的assistant回應(v2.1.59+,於v2.1.63、v2.1.72、v2.1.77增強)104114119 |
/context |
檢視context window使用量 | 顯示視覺化分解,並提供可執行建議(v2.1.74+)116 |
/compact |
壓縮對話歷史 | 加入焦點:/compact focus on tests |
/usage |
Token使用量、成本與方案用量 | 自v2.1.118起合併為同一對話框:/cost與/stats是輸入捷徑,會開啟對應分頁。訂閱使用者可查看各模型與cache-hit分解(v2.1.92+);進度列不再與「Resets …」標籤重疊(v2.1.119)。VSCode(v2.1.174+):Account & usage對話框新增歸因資訊,顯示過去24h或7d內的cache miss、long context、subagents,以及各skill/agent/plugin/MCP分解137152172 |
/cost |
輸入捷徑→開啟/usage成本分頁 |
v2.1.118之前為獨立指令;目前仍可作為捷徑使用 |
/stats |
輸入捷徑→開啟/usage統計分頁 |
v2.1.118之前為獨立指令;目前仍可作為捷徑使用 |
/theme |
管理具名自訂主題 | 從選擇器建立並切換,或手動編輯~/.claude/themes/*.json;plugins會隨附themes/目錄(v2.1.118+)152 |
/permissions |
管理權限設定 | 互動式介面 |
/mcp |
設定MCP伺服器 | 也支援/mcp enable、/mcp disable |
/hooks |
檢視hook設定 | 偵錯hooks |
/config |
開啟設定介面 | 完整設定 |
/resume |
恢復具名工作階段 | /resume <n>或/resume session-name |
/rename |
命名目前工作階段 | /rename feature-auth |
/branch |
分支對話 | 在不遺失context的情況下探索替代方案(/fork仍可作為alias使用,於v2.1.77重新命名)119 |
/clear |
清除對話歷史 | 重新開始 |
/powerup |
互動式功能教學 | 以動畫示範教您使用Claude Code功能(v2.1.90+)135 |
/ide |
連接至IDE | VS Code/JetBrains整合 |
/sandbox |
啟用sandbox mode | 隔離 |
/status |
檢視工作階段狀態 | 模型、設定等 |
/statusline |
自訂狀態列 | 設定顯示內容 |
/model |
變更AI模型 | /model opus |
/fast |
切換fast mode | 同一模型,更快輸出(v2.1.36+) |
/output-style |
設定輸出樣式 | v2.1.73+已棄用,請改用/config115 |
/agents |
管理subagents | 建立、編輯、刪除 |
/skills |
列出已安裝skills | 提供輸入篩選搜尋框,方便瀏覽長清單(v2.1.121+);skill描述仍上限為250字元154 |
/bashes |
列出背景工作 | 長時間執行的指令 |
/tasks |
列出背景agents | 監控非同步工作 |
/goal |
設定完成條件 | 讓Claude持續朝目標工作,直到條件滿足(v2.1.139+) |
/export |
匯出對話 | 儲存逐字稿 |
/add-dir |
新增工作目錄 | 擴充存取範圍 |
/terminal-setup |
設定terminal | 支援Kitty、Alacritty、Zed、Warp18 |
/login |
在工作階段中驗證身分 | 切換帳戶或重新驗證 |
/logout |
在工作階段中登出 | 清除憑證 |
/doctor |
檢查安裝 | 健全性檢查 |
/bug |
回報bug | 向Anthropic提交issue |
/release-notes |
互動式release notes | 含changelogs的版本選擇器(v2.1.92+)137 |
/rewind |
返回checkpoint | 復原變更(或Esc×2) |
/theme |
管理themes | Ctrl+T切換語法醒目提示 |
/plugin |
管理plugins | 安裝、更新、移除plugins |
/passes |
訪客通行證(僅Max) | 分享3張Claude Code Pro試用通行證55 |
/voice |
切換voice mode | Push-to-talk,按住空白鍵說話(2026年3月)111 |
/claude-api |
Claude API skill | 使用Claude API/Anthropic SDK建置app(v2.1.69+)110 |
/reload-plugins |
重新載入plugins | 無需重新啟動即可套用plugin變更(v2.1.69+)110 |
/security-review |
安全性審查 | 檢查程式碼是否有漏洞(v2.1.70修正git相容性)109 |
/color |
設定prompt顏色 | 為工作階段設定prompt列顏色。使用/color default/gray/reset/none即可還原。所有使用者皆可使用(v2.1.75+)117 |
/code-review [effort] |
正確性審查 | 於v2.1.147由/simplify重新命名;依選用的effort等級回報正確性bug,並支援--comment用於行內GitHub PR comments。169 |
/batch |
批次操作 | 隨附的slash command(v2.1.63+)104 |
/team-onboarding |
產生隊友上手指南 | 根據您的本機CC使用模式建立onboarding guide(v2.1.101+)143 |
/effort |
設定effort等級 | 將模型effort設為low/medium/high。對API-key、Bedrock/Vertex/Foundry、Team與Enterprise使用者,預設值由medium改為high(v2.1.94+)140 |
/loop |
週期性工作 | /loop 5m /foo會依固定間隔執行提示;預設為10m。適合輪詢部署、看顧PR,或執行定期檢查(v2.1.71+)112 |
/buddy |
Terminal陪伴寵物 | Tamagotchi風格的ASCII寵物,住在您的terminal中。18個物種、5個稀有度等級(Common 60%、Uncommon 25%、Rare 10%、Epic 4%、Legendary 1%)。由account ID決定且具確定性——您的寵物永遠相同。會觀察對話,並透過對話泡泡留言。需Pro訂閱(2026年4月1日)138 |
建立自訂指令
在.claude/commands/(專案)或~/.claude/commands/(個人)中建立可重複使用的指令:
---
description: Security-focused code review
allowed-tools: Read, Grep, Glob
model: claude-sonnet-4-5
---
Review this code for security vulnerabilities:
1. Injection attacks (SQL, command, XSS)
2. Authentication and authorization flaws
3. Sensitive data exposure
4. Insecure dependencies
Focus on actionable findings with specific line references.
儲存為.claude/commands/security-review.md,並以/security-review呼叫。
指令Frontmatter選項
---
description: Brief description for /help
allowed-tools: Read, Edit, Bash(npm:*)
model: opus
argument-hint: [arg1] [arg2]
disable-model-invocation: false
---
| Option | 用途 |
|---|---|
description |
說明文字與auto-delegation比對 |
allowed-tools |
限制可用工具 |
model |
覆寫此指令使用的模型 |
argument-hint |
記錄預期引數 |
disable-model-invocation |
防止SlashCommand工具使用 |
引數插值
將所有引數視為單一字串:
---
description: Fix GitHub issue
argument-hint: [issue-number]
---
Fix GitHub issue #$ARGUMENTS following our coding standards.
用法:/fix-issue 123
編號引數:
---
description: Create component
argument-hint: [name] [type]
---
Create a new $2 component named $1 in src/components/.
用法:/create-component Button functional
行內Bash執行
在指令提示中執行bash指令:
---
description: Git status summary
allowed-tools: Bash(git:*)
---
Current branch: !`git branch --show-current`
Recent commits: !`git log --oneline -5`
Changed files: !`git status --short`
Summarize the current state of this repository.
檔案參照
在指令中包含檔案內容:
---
description: Compare implementations
---
Compare these files:
@src/v1/handler.ts
@src/v2/handler.ts
Which implementation is more maintainable?
指令命名空間
在子目錄中組織指令:
.claude/commands/
├── backend/
│ ├── test.md
│ └── deploy.md
├── frontend/
│ ├── test.md
│ └── build.md
└── review.md
同名指令會在說明中顯示其命名空間:/test (project:backend)與/test (project:frontend)。
Skills如何運作?
Skills代表一種截然不同的方式,用來擴充Claude Code。不同於需要明確呼叫的slash commands,skills由模型呼叫:Claude會根據脈絡自動探索並使用。您將領域專業知識嵌入skill中,當情境需要時,Claude就會運用這些知識,不必每次都記得主動要求。
為什麼skills會改變一切:以領域專業知識為例:付款處理規則、合規要求、團隊多年累積出的架構模式。沒有skills時,您不是每個session都要重新說明這些脈絡,就是只能期待Claude從程式碼註解中推斷。有了skills,您只需編碼一次。Claude會讀取skill定義,並在相關情境中自動套用這些專業知識。初階開發者不必開口,也能取得資深層級的指引。安全性模式也能被落實,不必靠人記得呼叫。
這個差異很重要。slash command是您記得要使用的捷徑。skill則是Claude隨時可用的知識。當您建立安全性審查skill,並納入團隊特定的弱點模式與合規要求時,Claude會在遇到相關程式碼時套用這些專業知識,無論是在PR審查、重構,或任何安全性相關任務中。您不需要呼叫/security-review;Claude會辨識脈絡並自動套用skill。
Skills、Commands與Subagents比較
了解何時使用各種擴充機制,可以避免重複並發揮最大效果:
| 面向 | Slash Commands | Skills | Subagents |
|---|---|---|---|
| 呼叫方式 | 使用者呼叫(/command) |
模型呼叫(自動) | 明確委派或自動委派 |
| 觸發條件 | 您記得要使用 | Claude辨識脈絡 | 任務需要委派 |
| 結構 | 單一markdown檔案 | 含資源的目錄 | 含frontmatter的Markdown |
| 脈絡 | 主要對話 | 主要對話 | 分開的context window |
| 複雜度 | 簡單prompt | 多檔案能力 | 完整agent personality |
| 最適合 | 明確動作 | 領域專業知識 | 複雜任務委派 |
使用slash commands於需要明確控制時:/deploy、/test、/review PR 456。由您決定何時執行。
使用skills於專業知識應自動啟用時:安全性模式、程式碼風格落實、特定領域知識。由Claude決定何時套用。
使用subagents於任務需要隔離時:背景探索、平行分析、不應污染主要對話的專門推理。
Skill結構與位置
Skills放在專用目錄中,包含必要的SKILL.md檔案,以及選用的支援資源:
Personal skills(可在所有專案中使用):
~/.claude/skills/
├── code-reviewer/
│ ├── SKILL.md
│ ├── SECURITY_PATTERNS.md
│ └── PERFORMANCE_CHECKLIST.md
├── sql-analyst/
│ ├── SKILL.md
│ └── QUERY_PATTERNS.md
└── api-designer/
└── SKILL.md
Project skills(透過git與團隊共享):
.claude/skills/
├── domain-expert/
│ ├── SKILL.md
│ ├── BUSINESS_RULES.md
│ └── DATA_MODELS.md
└── deployment/
├── SKILL.md
└── RUNBOOKS.md
Project skills會提交到版本控制。隊友pull後,就會自動取得您的skills,不需要安裝,也不需要設定。自動散布能讓整個團隊的專業知識標準化。
SKILL.md格式
每個skill都需要一個含有YAML frontmatter的SKILL.md檔案:
---
name: code-reviewer
description: Review code for security vulnerabilities, performance issues, and best practice violations. Use when examining code changes, reviewing PRs, analyzing code quality, or when asked to review or audit code.
allowed-tools: Read, Grep, Glob
---
# Code Review Expertise
## Security Analysis
When reviewing code, check for:
### Input Validation
- All user input sanitized before use
- Parameterized queries for database operations
- Output encoding for rendered content
### Authentication & Authorization
- Session tokens properly validated
- Permission checks before sensitive operations
- No hardcoded credentials or API keys
### Data Exposure
- Sensitive data not logged
- PII properly masked in error messages
- API responses don't leak internal details
## Performance Patterns
### Database
- N+1 query detection
- Missing indexes on filtered columns
- Unbounded result sets
### Memory
- Large object lifecycle management
- Stream processing for big files
- Connection pool exhaustion risks
## Review Output Format
For each finding:
- **File**: path/to/file.ts:123
- **Severity**: Critical | High | Medium | Low
- **Category**: Security | Performance | Maintainability
- **Issue**: Clear description of the problem
- **Recommendation**: Specific fix with code example
- **Rationale**: Why this matters
See [SECURITY_PATTERNS.md](SECURITY_PATTERNS.md) for detailed vulnerability patterns.
See [PERFORMANCE_CHECKLIST.md](PERFORMANCE_CHECKLIST.md) for optimization guidelines.
Frontmatter參考
| 欄位 | 必填 | 限制 | 用途 |
|---|---|---|---|
name |
是 | 小寫、數字、連字號;最多64個字元 | 唯一識別碼 |
description |
是 | 最多1024個字元 | 探索觸發條件:Claude使用此欄位判斷何時套用skill |
allowed-tools |
否 | 以逗號分隔的tool名稱 | 限制Claude使用此skill時的能力 |
context |
否 | fork |
在隔離脈絡中執行skill(v2.1.0+)。避免對主要agent狀態產生副作用。40 |
字串替換(v2.1.9+):Skills可以使用${CLAUDE_SESSION_ID}替換來存取session脈絡。這對記錄、追蹤,或產生session特定輸出很有用。44
description欄位至關重要。Claude會將您的請求與skill descriptions比對,以探索skills。含糊的description會讓Claude無法辨識何時使用skill。清楚寫出觸發條件的具體description,才能可靠啟用。
不佳的description:
description: Helps with code
有效的description:
description: Review code for security vulnerabilities, performance issues, and best practice violations. Use when examining code changes, reviewing PRs, analyzing code quality, or when asked to review, audit, or check code.
有效的description包含: - skill會做什麼(針對特定問題審查程式碼) - 何時使用(檢查變更、PR、品質分析) - 觸發詞(review、audit、check)
Tool限制
allowed-tools欄位會限制skill啟用時,Claude能執行的動作。對唯讀或限定範圍的skills而言,tool限制不可或缺:
---
name: security-auditor
description: Audit code for security vulnerabilities without making changes
allowed-tools: Read, Grep, Glob
---
透過這項設定,Claude可以分析程式碼,但不能編輯檔案、執行bash命令,或進行修改。此skill會強制唯讀行為。
常見限制模式:
| 模式 | Tools | 使用情境 |
|---|---|---|
| 唯讀分析 | Read, Grep, Glob |
安全性稽核、程式碼審查 |
| 安全探索 | Read, Grep, Glob, Bash(git log:*), Bash(git diff:*) |
歷史分析 |
| 文件 | Read, Grep, Glob, Write |
產生文件但不編輯原始碼 |
| 完整存取 | (省略欄位) | skill繼承所有可用tools |
支援檔案
Skills可以包含多個檔案。Claude在啟用時會讀取主要的SKILL.md,之後再視需要存取支援檔案,以漸進揭露的方式有效管理脈絡。
結構模式:
my-skill/
├── SKILL.md # Required: overview + quick reference
├── DETAILED_GUIDE.md # Deep documentation
├── EXAMPLES.md # Concrete examples
├── PATTERNS.md # Reference patterns
├── templates/ # Reusable templates
│ └── component.tsx
└── scripts/ # Helper utilities
└── validate.py
從SKILL.md參照支援檔案:
For detailed security patterns, see [SECURITY_PATTERNS.md](SECURITY_PATTERNS.md).
Use this template for new components:
@templates/component.tsx
Validate configurations with:
```bash
python scripts/validate.py config.json
```
專家提示:將必要資訊直接放在SKILL.md中。支援檔案則保留給深入參考資料。Claude會立即讀取SKILL.md,但只會在需要時存取支援檔案。若關鍵資訊埋在支援檔案中,Claude可能找不到。
完整範例:領域專家Skill
以下是一個用於fintech應用程式的生產品質skill:
目錄結構:
.claude/skills/payments-domain/
├── SKILL.md
├── BUSINESS_RULES.md
├── COMPLIANCE.md
└── DATA_MODELS.md
SKILL.md:
---
name: payments-domain
description: Expert knowledge of payment processing domain including transaction flows, compliance requirements, and business rules. Use when working with payment code, transaction handling, refunds, disputes, or financial calculations.
---
# Payments Domain Expertise
## Core Concepts
### Transaction States
```
PENDING → AUTHORIZED → CAPTURED → SETTLED
↘ VOIDED
AUTHORIZED → DECLINED
CAPTURED → REFUNDED (partial or full)
SETTLED → CHARGEBACK → REPRESENTED
```
### Money Handling Rules
- ALL monetary values stored as integers (cents, not dollars)
- Currency always explicitly tracked (never assume USD)
- Rounding: HALF_EVEN for calculations, HALF_UP for display
- Never use floating point for money
### Idempotency Requirements
Every payment operation MUST be idempotent:
```typescript
// Required pattern
async function processPayment(idempotencyKey: string, amount: number) {
const existing = await findByIdempotencyKey(idempotencyKey);
if (existing) return existing; // Return cached result
const result = await executePayment(amount);
await storeWithIdempotencyKey(idempotencyKey, result);
return result;
}
```
## Quick Reference
### Fee Calculations
- Interchange: 1.5% + $0.10 (debit), 2.1% + $0.10 (credit)
- Platform fee: 2.9% + $0.30 (standard), 2.2% + $0.30 (enterprise)
- International: +1% cross-border fee
- Currency conversion: mid-market rate + 1%
### Compliance Thresholds
- $3,000: Enhanced due diligence trigger
- $10,000: CTR filing required
- $25,000: Additional verification required
### Refund Windows
- Full refund: 120 days from capture
- Partial refund: 180 days from capture
- Chargeback window: 120 days (Visa), 180 days (Mastercard)
## Key Files
- `src/payments/processor.ts` - Core payment logic
- `src/payments/refunds.ts` - Refund handling
- `src/compliance/aml.ts` - AML checks
- `src/models/transaction.ts` - Transaction model
See `BUSINESS_RULES.md` for detailed business logic.
See `COMPLIANCE.md` for regulatory requirements.
See `DATA_MODELS.md` for schema documentation.
有了這個skill,當您處理交易程式碼、詢問退款邏輯,或偵錯付款流程時,Claude會自動套用付款領域專業知識。您不需要呼叫任何東西;專業知識就已經在那裡。
建立有效的Skills
從description開始。先撰寫description,再建立與之相符的skill內容。description決定Claude何時使用skill,因此務必寫準:
- 說明skill提供什麼
- 列出具體觸發條件
- 納入相關關鍵字與片語
保持skills聚焦。一個skill涵蓋一個領域或能力:
| 良好(聚焦) | 不佳(過於寬泛) |
|---|---|
security-auditor |
code-helper |
react-patterns |
frontend-stuff |
postgres-optimization |
database-expert |
api-documentation |
docs-generator |
如果skill試圖涵蓋太多內容,description就會變得含糊,Claude也無法可靠辨識何時使用。
使用漸進揭露。將最重要的資訊直接放在SKILL.md中。需要深度時再參照支援檔案:
## Quick Reference
[Essential patterns here - Claude sees this immediately]
## Deep Dive
For full coverage, see [DETAILED_GUIDE.md](DETAILED_GUIDE.md).
加入具體範例。抽象描述不如具體模式實用:
## Input Validation
### Pattern
```typescript
// Good: Explicit validation with typed errors
const validated = PaymentSchema.safeParse(input);
if (!validated.success) {
throw new ValidationError(validated.error.issues);
}
// Bad: Implicit coercion
const amount = Number(input.amount); // Silent NaN on invalid input
```
用真實請求測試。建立skill後,測試Claude是否會啟用它:
> Review this payment processing code for issues
# Should activate payments-domain skill
> How should I handle refunds?
# Should activate payments-domain skill
> What's the weather like?
# Should NOT activate payments-domain skill
如果Claude沒有如預期啟用skill,請修改description,加入您正在使用的觸發片語。
團隊共享策略
Git式共享(建議用於project skills):
# Add skill to project
mkdir -p .claude/skills/team-standard
# Create SKILL.md and supporting files
# Commit
git add .claude/skills/
git commit -m "Add team coding standards skill"
git push
# Teammates get it automatically
git pull
claude # Skill now available
透過symlinks跨專案共享:
# Create canonical skill location
mkdir -p ~/shared-skills/security-reviewer
# Create SKILL.md
# Symlink into projects
ln -s ~/shared-skills/security-reviewer ~/.claude/skills/security-reviewer
# Now available in all your projects
Plugin散布: 如需更廣泛散布,請將skills封裝成plugins:
my-plugin/
├── .claude-plugin/
│ └── plugin.json
└── skills/
└── my-skill/
└── SKILL.md
封裝在plugins中的skills,會在使用者安裝plugin後變得可用。
偵錯Skills
Skill未啟用:
-
檢查description是否符合您的請求:
yaml # If you're saying "check this code" but description says "review" description: Review OR check code for issues... -
確認檔案位置: ```bash # Personal ls ~/.claude/skills/my-skill/SKILL.md
# Project ls .claude/skills/my-skill/SKILL.md ```
- 驗證YAML frontmatter:
- 第一行必須完全是
--- - markdown內容前必須有結尾
--- - YAML中不可使用tab(請用空格)
-
Name欄位僅能使用小寫與連字號
-
以debug模式執行:
bash claude --debug # Watch for skill loading messages
Skill非預期啟用:
縮小description範圍。如果skill在不應啟用時被啟用,代表description太寬泛:
# Too broad - activates on any "code" mention
description: Help with code
# Specific - activates only for security contexts
description: Audit code for security vulnerabilities including injection attacks, authentication flaws, and data exposure. Use when specifically asked about security, vulnerabilities, or when reviewing code for security issues.
找不到支援檔案:
- 使用相對於SKILL.md位置的路徑
- 只使用正斜線(即使在Windows上)
- 確認檔案確實存在:
ls .claude/skills/my-skill/REFERENCED.md
何時建立Skill
以下情況適合建立skill: - 領域專業知識應自動啟用 - 多位團隊成員需要相同知識 - 您反覆說明相同模式或規則 - 脈絡需要在沒有明確呼叫時注入 - 知識橫跨多個檔案且需要組織
以下情況不適合建立skill: - 您想明確控制呼叫時機(使用slash command) - 任務需要分開的脈絡(使用subagent) - 這是一次性的prompt(直接輸入即可) - 所謂的「skill」其實只是單一範本(使用slash command)
專家提示:如果您發現自己在處理auth程式碼前,總是反覆輸入/security-review,就把它轉成skill。讓專業知識成為環境的一部分,而不是明確呼叫的動作。若您需要明確呼叫,則保留為command。
Plugin 系統
Plugins 會封裝 Claude Code 擴充功能以供散布。一個 plugin 可以包含自訂命令、subagents、skills、hooks,以及 MCP 伺服器。Anthropic 已於 2025年12月正式推出 plugin 市集,內含 36 個精選 plugins。40
Plugin 結構
my-plugin/
├── .claude-plugin/
│ └── plugin.json # Required: metadata
├── bin/ # Executables invokable as bare commands (v2.1.91+)[^143]
├── commands/ # Slash commands
│ └── hello.md
├── agents/ # Subagents
│ └── helper.md
├── skills/ # Skills
│ └── my-skill/
│ └── SKILL.md
├── hooks/ # Event handlers
│ └── hooks.json
└── .mcp.json # MCP servers
Plugin Manifest
最小化 plugin.json:
{
"name": "my-plugin",
"description": "What this plugin does",
"version": "1.0.0",
"author": {
"name": "Your Name"
}
}
v2.1.129 manifest 注意事項:themes 與 monitors 現在應宣告在 manifest 的 "experimental" 物件底下。既有的頂層宣告仍可運作,但 claude plugin validate 會提出警告,方便 plugin 作者在發布前完成遷移。156
Plugin 管理
> /plugin # Interactive interface
> /plugin install name@marketplace # Install
> /plugin enable name@marketplace # Enable
> /plugin disable name@marketplace # Disable
> /plugin uninstall name@marketplace # Remove
> /plugin marketplace add ./local # Add local marketplace
> /plugin marketplace list # View marketplaces
若要進行一次性測試,v2.1.129 新增了一個 session flag,可直接擷取 plugin zip,而不會安裝到一般市集狀態中:
claude --plugin-url https://example.com/my-plugin.zip
自 v2.1.128 起,--plugin-dir 也接受 .zip plugin 封存檔,因此本機 smoke tests 可以指向 plugin 目錄或封存檔。156
Plugin Pruning(v2.1.121+)
Plugins 可以宣告其他 plugins 作為相依項目。安裝 plugin 時,其相依項目會自動安裝,並標記為「auto-installed」。兩個新命令可在手動解除安裝或市集移除後進行清理:
| 命令 | 行為 |
|---|---|
claude plugin prune |
移除其父項目已不存在的 auto-installed plugins |
claude plugin uninstall <name> --prune |
解除安裝,並連帶移除目前已成為孤立狀態的 auto-installed 相依項目 |
手動解除安裝或從市集移除後,請執行 prune,讓 ~/.claude/plugins/ 保持精簡。154
本機開發
建立本機市集以供測試:
mkdir dev-marketplace && cd dev-marketplace
mkdir my-plugin
# Create plugin structure
cd ..
claude
> /plugin marketplace add ./dev-marketplace
> /plugin install my-plugin@dev-marketplace
Plugin 安裝改進(v2.1.51+)
Plugins 現在支援從 npm 來源安裝時使用自訂 npm registries,以及釘選特定版本。市集操作的預設 git timeout 已從 30s 增加到 120s,並可透過 CLAUDE_CODE_PLUGIN_GIT_TIMEOUT_MS 設定。98
Plugin 元件
- 命令:可作為 slash commands 使用(
/plugin-command) - Agents:顯示於
/agents清單 - Skills:依據 skill config 自動載入
- Hooks:與使用者/專案 hooks 合併,並行執行
- MCP Servers:啟用 plugin 時自動啟動
透過 .claude/skills/ 使用本機 Plugins(v2.1.157+)
放在專案 .claude/skills/ 目錄中的 plugins 現在會自動載入,不需要市集;claude plugin init <name> 也會在該目錄中 scaffold 全新的 plugin。這讓「我想要一個專案範圍的工具」到「我有一個可運作的 plugin」之間的流程大幅縮短,不需要市集註冊,也不需要處理 manifest plumbing。/plugin 也新增了引數自動完成,與其餘命令介面保持一致。179
Memory如何運作?
Claude Code的記憶系統可在不同工作階段之間保留持續性的上下文。有效的記憶管理,決定了Claude是能深入理解您的專案,還是把每個工作階段都視為全新的開始。
CLAUDE.md階層
| 位置 | 範圍 | 共享 | 使用情境 |
|---|---|---|---|
/Library/Application Support/ClaudeCode/CLAUDE.md (macOS) |
企業 | 所有使用者 | 公司標準 |
./CLAUDE.md或./.claude/CLAUDE.md |
專案 | 透過git | 團隊上下文 |
~/.claude/CLAUDE.md |
使用者 | 所有專案 | 個人偏好 |
./CLAUDE.local.md |
專案本機 | 永不共享 | 個人專案筆記 |
有效的CLAUDE.md結構
# Project Context
## Architecture
- Monorepo with packages in /packages
- React frontend in /packages/ui
- Node.js API in /packages/api
- Shared types in /packages/types
- PostgreSQL database via Prisma
## Code Standards
- TypeScript strict mode everywhere
- ESLint + Prettier enforced (pre-commit hooks)
- No default exports
- JSDoc on all public APIs
- Tests required for all new code
## Commands
- `npm test` - Run all tests
- `npm run test:watch` - Watch mode
- `npm run lint` - Check linting
- `npm run lint:fix` - Auto-fix lint issues
- `npm run build` - Production build
- `npm run dev` - Start dev servers
- `npm run db:migrate` - Run migrations
- `npm run db:seed` - Seed database
## Patterns
### API Endpoints
Create in packages/api/src/routes/
Use Zod for request/response validation
All endpoints need OpenAPI documentation
### React Components
Create in packages/ui/src/components/
Use React Query for server state
Prefer composition over inheritance
### Database
Prisma schema in packages/api/prisma/
Always create migration for schema changes
Use transactions for multi-table operations
## Important Notes
- NEVER commit .env files
- API runs on :3000, UI on :3001
- Local DB: postgres://localhost:5432/myapp
- Feature flags in packages/api/src/flags.ts
## Recent Decisions
- 2025-12-01: Migrated to React Query v5
- 2025-11-15: Adopted Zod for all validation
- 2025-11-01: Moved to ESM modules
# Summary Instructions
When using compact, focus on:
- Recent code changes
- Test results
- Architecture decisions made this session
檔案匯入
在CLAUDE.md中參照其他檔案:
See @README.md for project overview
Coding standards: @docs/STYLE_GUIDE.md
API documentation: @docs/API.md
Personal preferences: @~/.claude/preferences.md
匯入語法:
- 相對路徑:@docs/file.md
- 從專案起算的絕對路徑:@/absolute/path.md
- 家目錄:@~/.claude/file.md
- 最大深度:5層匯入
Memory規則目錄
若要讓記憶更有條理,請使用.claude/rules/儲存分類後的規則檔案:11
.claude/rules/
├── testing.md # Testing conventions
├── security.md # Security requirements
├── api-patterns.md # API design patterns
└── deployments.md # Deployment procedures
規則會自動載入,並提供結構化上下文,不會讓CLAUDE.md變得雜亂。
快速新增Memory
在工作階段中使用#前綴新增筆記:
# Always run tests before committing
# The payment module is especially fragile
# Use the new logger from packages/api/src/logger.ts
系統會提示您選擇要將筆記儲存到哪個記憶檔案。
自動Memory(v2.1.32+)
Claude Code現在會跨工作階段自動記錄並回想專案上下文。80工作時,Claude會將觀察寫入持續性的記憶檔案,例如模式、慣例、除錯心得、關鍵檔案路徑等。位置如下:
~/.claude/projects/{project-path}/memory/MEMORY.md
您會在工作階段開始時看到Recalled memories,並在工作階段中看到Wrote memories。自動Memory與#前綴不同:
| 自動Memory | #前綴 |
|
|---|---|---|
| 觸發方式 | Claude隱含決定 | 您明確決定 |
| 內容 | 模式、慣例、架構 | 特定事實或指示 |
| 儲存位置 | MEMORY.md(自動管理) |
使用者選取的記憶檔案 |
| 編輯方式 | Claude管理;您也可以直接編輯檔案 | 由您控制儲存內容 |
自動Memory一律會載入到您的system prompt(前200行)。請保持精簡。若有詳細筆記,請建立獨立主題檔案(例如debugging.md、patterns.md),並從MEMORY.md連結過去。
管理自動Memory(v2.1.59+):使用/memory即可直接在Claude Code中檢視並管理自動Memory檔案。100這取代了先前/memory只是開啟CLAUDE.md編輯器的行為。現在您可以檢閱、編輯並整理Claude記住的內容。
Memory時間戳記(v2.1.75+):記憶檔案現在會包含最後修改時間戳記,協助Claude判斷哪些記憶仍新鮮、哪些已過時。這會在自動回想時降低舊記憶的優先權,進而提升上下文品質。117
若要退出,請在啟動時傳入--no-memory(會停用所有記憶,包括CLAUDE.md)。目前沒有旗標可在保留CLAUDE.md啟用的同時,單獨停用自動Memory(這是一項已提出的功能需求)。
使用/dream整併Memory:隨著時間推移,自動Memory會累積重複和過時項目。/dream命令會執行自動整併流程,清理並合併記憶項目,移除重複內容,並整理相關觀察。建議定期使用,讓記憶檔案保持聚焦,並維持在200行預算內。128
Context管理命令
檢視context使用量:
> /context
以視覺化網格顯示system prompt、對話、工具和檔案內容之間的context配置。
壓縮對話:
> /compact
> /compact focus on the authentication changes
> /compact preserve test output and error messages
智慧摘要較早的對話,同時保留關鍵資訊。
自訂壓縮指示(在CLAUDE.md中):
# Summary Instructions
When using compact, focus on:
- Test output and failures
- Code changes made this session
- Architecture decisions
針對context使用extended thinking:
export MAX_THINKING_TOKENS=10000
thinking tokens越多,推理能力越高,但成本也越高。
Context最佳化策略
- 使用特定檔案參照,不要請Claude自行搜尋
- 在任務之間使用
/clear清除不相關的對話 - 在長時間工作階段中主動壓縮
- 使用subagents隔離探索性工作
- 將複雜任務拆成聚焦的互動
- 使用resume sessions延續進行中的工作,而不是重新說明
圖像與多模態輸入
Claude Code可以分析圖像:螢幕截圖、圖表、mockups、錯誤訊息、資料庫schema。
輸入方式
- 拖放:將圖像檔案拖曳到Claude Code視窗中
- 貼上:使用
Ctrl+V(Mac上不是Cmd+V)從剪貼簿貼上 - 路徑參照:”Analyze this image: /path/to/screenshot.png”
檢視附加圖像
當Claude在回覆中參照圖像時,可點擊的圖像連結可讓您直接檢視:27
[Image #1] # Click to open in default image viewer
[Image #2] # Navigate attached screenshots
檢閱螢幕截圖或除錯視覺問題時,可點擊連結很有幫助。點擊參照即可看到Claude實際分析的內容。
使用情境
- 除錯UI問題:”Here’s a screenshot of the bug, what’s causing it?”
- 實作設計:”Build this component based on the mockup”
- 分析圖表:”Explain this architecture diagram”
- 資料庫schemas:”Create Prisma models matching this ERD”
- 錯誤分析:”What does this error screenshot mean?”
專家提示:根據mockups實作時,請包含多張呈現不同狀態的螢幕截圖(預設、hover、載入中、錯誤)。視覺上下文越多,實作品質越好。
PDF讀取(v2.1.30+)
Claude Code可以讀取並分析PDF文件,並支援頁面層級控制:76
基本PDF讀取:
> Analyze this PDF: /path/to/document.pdf
讀取特定頁面範圍:
> Read pages 1-5 of the PDF: /path/to/report.pdf
或透過Read工具的pages參數以程式方式指定:
- pages: "1-5" - 讀取第1頁到第5頁
- pages: "1,3,7" - 讀取特定頁面
- pages: "10-" - 從第10頁讀到結尾
限制: - 每次請求最多100頁 - 檔案大小上限20MB - 大型PDF(>10頁)在以@提及時會回傳輕量參照,完整內容則視需要載入
Voice Mode(2026年3月)
Voice mode會把Claude Code變成一位可對話而非打字互動的pair programming夥伴。透過/voice啟用後,它會使用push-to-talk,精準控制何時擷取語音。111
啟用
> /voice # Start voice mode
或在settings.json中設定voiceEnabled: true,讓它在工作階段開始時自動啟用。
運作方式
按住空白鍵說話,放開後送出。Claude會處理您的語音,並像您輸入提示一樣回應。push-to-talk設計可避免在寫程式時意外觸發。
支援語言(共20種,v2.1.69+)
英文、西班牙文、法文、德文、葡萄牙文、義大利文、日文、韓文、中文、印度文、俄文、波蘭文、土耳其文、荷蘭文、烏克蘭文、希臘文、捷克文、丹麥文、瑞典文、挪威文。110
推出狀態
Voice mode於2026年3月3日推出。採逐步推出方式(初始約5%,並在數週內逐步提高)。推出後,所有訂閱方案皆可使用。111
最適合
- 在白板上草擬時,同步描述高階架構
- 口述commit messages與PR描述
- 以對話方式說明bugs,同時雙手維持在鍵盤上
- 快速委派任務:”Run the test suite and fix any failures”
Git整合如何運作?
Claude Code具備深入的Git整合,並內建安全機制。
安全機制
- 自動遵循
.gitignore - 未經允許不會修改分支
- 提交前會顯示差異
- 遵循專案的提交慣例
- 未經明確要求絕不強制推送
- 修改提交前會檢查作者身分
常見工作流程
建立提交:
> commit these changes
> create a commit with a meaningful message
Claude會:
1. 執行git status和git diff
2. 分析變更
3. 產生符合慣例的提交訊息
4. 等待核准後再提交
建立pull request:
> create a PR for this feature
> summarize the changes and create a PR
審查程式碼:
> review the changes in this PR
> what could go wrong with these changes?
GitHub Actions整合
使用官方action在CI/CD中自動化Claude:
快速設定:
> /install-github-app
手動工作流程檔案:
name: Claude Code Review
on:
pull_request:
types: [opened, synchronize]
issue_comment:
types: [created]
jobs:
claude-review:
runs-on: ubuntu-latest
steps:
- uses: anthropics/claude-code-action@v1
with:
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
prompt: "Review this PR for bugs, security issues, and performance problems"
claude_args: "--max-turns 5"
用於Bedrock(搭配OIDC):
- name: Configure AWS
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
aws-region: us-west-2
- uses: anthropics/claude-code-action@v1
with:
use_bedrock: "true"
claude_args: '--model us.anthropic.claude-sonnet-4-5-20250929-v1:0'
Code Review [RESEARCH PREVIEW](2026年3月)
Code Review是Anthropic的多代理系統,會自動審查pull request,以捕捉人工審查者可能漏看的錯誤。當PR開啟時,一組agents會平行派出,分別從不同角度檢查程式碼庫,接著交叉驗證發現項目以過濾誤報,並依嚴重程度排序問題。結果會以單一總覽留言加上行內註解呈現。113
可用性: 針對Claude for Teams和Claude for Enterprise客戶提供research preview(2026年3月9日)。
運作方式: 1. 開發者開啟PR 2. 多個AI agents平行分析程式碼 3. Agents彼此交叉驗證發現項目 4. 最終agent彙整、去除重複,並依嚴重程度排序 5. 結果以PR留言發布(總覽+行內註解)
效能指標(Anthropic內部資料):
| 指標 | 數值 |
|---|---|
| 收到發現項目的大型PR(1,000行以上) | 84%(平均7.5個問題) |
| 收到發現項目的小型PR(少於50行) | 31%(平均0.5個問題) |
| 人工不同意率 | 標記為不正確的發現項目少於1% |
| 平均審查時間 | 約20分鐘 |
| 實質PR留言 | 54%的PR(高於原本的16%) |
成本: 每次審查15–25美元,會隨PR大小與複雜度調整。組織可透過每月支出上限、儲存庫層級啟用,以及分析儀表板來管理支出。113
設定: 管理員在Claude Code設定中啟用此功能、安裝GitHub App,並選取目標儲存庫。開發者不需要任何設定;啟用後,新PR會自動執行審查。
與GitHub Action的關鍵差異: 開放原始碼的claude-code-action(如上)會以提示詞執行單一Claude執行個體。Code Review則派出多代理團隊進行更深入的分析。人工核准仍為必要條件;Code Review提供資訊,但絕不核准合併。113
如何在IDE中使用Claude Code?
VS Code Extension
需求: VS Code 1.98.0+
安裝: 在Extensions marketplace中搜尋「Claude Code」
功能:
- 側邊欄面板(Spark圖示)
- 活動列中的session清單,sessions會以完整編輯器開啟(v2.1.70+)109
- 計畫提供完整markdown文件檢視,並支援留言(v2.1.70+)109
- 透過聊天面板中的/mcp提供原生MCP伺服器管理對話框(v2.1.70+)109
- 將壓縮內容顯示為可摺疊的「Compacted chat」卡片(v2.1.69+)110
- Plan mode搭配diff preview
- 自動接受編輯切換
- Extended thinking切換
- 檔案附件與圖片貼上
- 對話歷史記錄
- 多個同步sessions
安全性注意事項: Anthropic已在IDE extensions v1.0.24+修補WebSocket驗證繞過漏洞(CVE-2025-52882)。請確認extension已更新;Anthropic已從extension stores移除所有受影響版本。31
第三方供應商設定(在.claude/settings.json中):
{
"env": {
"CLAUDE_CODE_USE_BEDROCK": "1",
"AWS_REGION": "us-east-1",
"AWS_PROFILE": "your-profile"
}
}
JetBrains Plugin
支援: IntelliJ IDEA、PyCharm、WebStorm、GoLand、PhpStorm、DataGrip
安裝: Settings → Plugins → 搜尋「Claude Code」→ Install → Restart
主要快捷鍵:
- Cmd+Esc(Mac)/Ctrl+Esc(Windows):快速啟動
- Cmd+Option+K(Mac)/Alt+Ctrl+K(Windows):新增檔案參照
功能: - 在IDE diff viewer中檢視差異 - 自動分享選取範圍脈絡 - 診斷整合 - 多個sessions
WSL2設定: 將Claude命令設為:
wsl -d Ubuntu -- bash -lic "claude"
終端機整合
將外部終端機連接至您的IDE:
> /ide
Claude Code會自動偵測VS Code、Cursor、Windsurf和JetBrains IDEs。
Slack整合(2025年12月)
Claude Code現在可直接與Slack整合,讓開發者能從聊天thread委派程式碼工作。7
運作方式:
1. 在Slack channel或thread中提及@Claude
2. Claude會檢視訊息,判斷是否為程式碼工作
3. Claude Code session會在Anthropic基礎架構上自動啟動
4. Claude從最近的channel/thread訊息蒐集脈絡
5. 進度更新會回傳到您的Slack thread
6. 完成時提供可審查變更與開啟PR的連結
使用情境: - 從Slack中發布的錯誤報告進行錯誤調查 - 根據團隊回饋快速審查程式碼 - 從功能需求實作小型功能
需求: - 透過Slack App Marketplace安裝Claude app - 付費Slack方案 - 可存取網頁版Claude Code
隱私權: Claude遵循Slack既有的權限結構。它無法存取您未獲授權查看的對話或儲存庫。對話不會用於模型訓練。
進階使用模式
Headless與CI模式
在scripts和CI pipelines中執行Claude Code:
#!/bin/bash
# Automated code review
result=$(claude -p "Review this code for quality issues" \
--output-format json \
--allowedTools "Read,Grep,Glob" \
--permission-mode plan \
--disable-slash-commands \
--max-turns 5)
if echo "$result" | jq -e '.result | test("critical|high severity")' > /dev/null; then
echo "Issues found:"
echo "$result" | jq -r '.result'
exit 1
fi
echo "Review passed"
exit 0
Piping與Chaining
# Analyze logs
cat production.log | claude -p "summarize errors" > error-summary.md
# Process multiple files
find . -name "*.ts" -exec cat {} \; | claude -p "find security issues"
# Chain with jq
claude -p "generate config" --output-format json | jq -r '.result' > config.json
背景工作
執行長時間操作且不阻塞流程:
> start the build in the background
或在命令執行期間按下Ctrl+B。
管理背景工作:
> /bashes # List running tasks
> get output from task xyz # Retrieve output
使用Git Worktrees進行平行Sessions
# Create worktrees for parallel work
git worktree add ../project-feature-a -b feature-a
git worktree add ../project-bugfix bugfix-123
# Run Claude in each worktree (separate project dirs = separate sessions)
cd ../project-feature-a && claude
cd ../project-bugfix && claude
每個worktree都是獨立的專案目錄,並有自己的session。
JSON輸出解析
result=$(claude -p "analyze this code" --output-format json)
# Extract fields
echo "Result: $(echo $result | jq -r '.result')"
echo "Cost: $(echo $result | jq -r '.total_cost_usd')"
echo "Session: $(echo $result | jq -r '.session_id')"
echo "Duration: $(echo $result | jq -r '.duration_ms')ms"
程式化Session管理
# Name the current session for easy recall (inside Claude: /rename feature-auth)
# Then resume by name later:
claude --resume "feature-auth"
# Continue most recent session
claude -c "continue implementing the tests"
# List recent sessions to find one (shows up to 50 sessions, v2.1.47+)
claude --resume # interactive picker
Remote 與 Background Agents [研究預覽版]
Claude Code 透過兩項互補功能延伸到本機終端機之外:Remote(雲端執行並可傳送回本機)與 Background Agents(不阻塞終端機的平行任務執行)。兩者都使用 & 前綴,並共享相同的雲端基礎設施。
核心概念
claude.ai/code 的網頁介面會在雲端執行 Claude Code。當您離開終端機時,任務會在背景執行。準備繼續時,可以將工作階段傳送到本機,從 Claude 停下的位置無縫接續。
遠端執行讓過去不可能的工作流程成為可能: - 從手機啟動複雜的重構任務,讓它在通勤時執行,之後回到工作站完成收尾 - 在網頁介面排入多個任務,回到座位後再審查結果 - 需要闔上筆電時,將長時間執行的作業交給雲端處理
& 前綴
將任務送到 Claude Code web 在背景執行:
& Build a complete REST API for user management with authentication, CRUD operations, and proper error handling
& 前綴會將提示傳送到雲端。Claude 會非同步處理。您可以關閉終端機、切換裝置,或繼續處理其他工作。claude.ai/code 的網頁介面會顯示正在執行與已完成的工作階段。
--teleport 旗標
將雲端工作階段拉回本機終端機:
claude --teleport session_abc123
此旗標會從網頁取回工作階段狀態,並在本機恢復。您會取得完整對話歷史、Claude 修改過的所有檔案,並能像一路都在場一樣繼續互動。
工作階段 ID 會顯示在網頁介面中。點選任何工作階段即可查看其 ID 與目前狀態。
需求
Claude Code Remote 適用於 Pro、Max、Team(premium seats)與 Enterprise(premium seats) 訂閱者。66 網頁介面在 Anthropic 的基礎設施上執行,具備與本機相同的 Claude Code 能力(檔案操作、Bash 指令、MCP 整合),但運行於受管理的雲端環境。Anthropic 已於 2026年1月擴大 Team 與 Enterprise 的存取範圍;帳戶管理員可以在 Claude 設定中切換存取權限。
iOS App(2025年11月): Claude Code 也可在 Claude iOS app 中使用,讓您在外出時啟動程式碼任務,並從手機監控 agent 進度。15 您可以離開座位時開始任務,之後準備審查時再將它們傳送回終端機。
Remote Control(2026年2月): 這項工作階段行動功能可讓您從手機、平板或任何瀏覽器繼續本機 Claude Code 工作階段。工作階段狀態——檔案參照、對話歷史、工具設定、待處理作業——會透過加密通道作為單一原子單位移動。此功能以研究預覽版提供給 Max 使用者(v2.1.58 已擴大開放給更多使用者)。外部建置可使用 claude remote-control 子指令(v2.1.51+)。101 工作階段名稱現在預設使用以主機名稱為基礎的前綴(例如 myhost-graceful-unicorn),並可用 --remote-control-session-name-prefix 覆寫。137
實務工作流程
早晨通勤:
& Review all PRs assigned to me and prepare summaries with recommendations
回到座位:
# Check what completed
# Visit claude.ai/code to see session list
# Pull the session locally to review and act on recommendations
claude --teleport pr-review-session-xyz
下班前:
& Run the full test suite, fix any failures, and prepare a summary of what was changed
隔天早上:
claude --teleport test-fixes-session-abc
# Review what Claude did overnight, make final adjustments
Claude Code Channels [研究預覽版](2026年3月)
Claude Code Channels 可讓您從 Telegram 或 Discord 將訊息送入正在執行的 Claude Code 工作階段。122 此功能採用以 plugin 為基礎的架構來整合通訊平台,預期之後會支援更多平台。
需求: v2.1.80+、Bun runtime、claude.ai 登入。使用 --channels 旗標啟動,以便將工具核准提示轉送到您的通訊 app。Channel servers 會以 plugins 安裝。
使用情境: 當 Claude Code 在工作站執行時,可從手機監控並核准 agent 動作。這對長時間執行的 /loop 任務或隔夜 agent 工作階段特別有用,能保留核准關卡,又不必一直守在終端機前。
Claude Code Security [研究預覽版](2026年2月)
Claude Code Security 是內建於網頁版 Claude Code 的漏洞掃描能力。97 它會掃描程式碼庫中的安全漏洞,並提出針對性的修補建議供人工審查。
可用性: 針對 Enterprise、Team 與開放原始碼維護者提供的有限研究預覽版。
運作方式: 1. 將 Claude Code Security 指向一個 repository 2. 它會掃描程式碼庫中的漏洞 3. 結果會包含可供審查的具體修補建議 4. 套用變更前必須經過人工審查
此功能運用 Opus 4.6 已展現的能力:可在開放原始碼程式碼中開箱即用地找出 500+ 個 zero-day vulnerabilities。79
目前狀態
Claude Code Remote 目前處於研究預覽版。隨著 Anthropic 收集回饋,此功能預期會持續演進。核心工作流程(雲端執行並傳送回本機)可實現連續的 AI 開發:當您離開鍵盤時,Claude 仍會工作;回來後則能從它停下的位置精準接續。
目前限制: 工作階段傳送目前僅支援單向:您可以將網頁工作階段拉回終端機,但無法將既有終端機工作階段推送到網頁。也就是說,目前還無法在遠端機器上繼續本機工作階段(例如透過 SSH 連到 AWS instance)。
Background Agents
Background agents 會在您繼續工作時執行,不必等待長時間任務完成。10
Background Agents 的運作方式:
與其在 Claude 執行複雜任務時阻塞終端機,background agents 會: 1. 在獨立程序中自行執行 2. 即使關閉終端機也會繼續工作 3. 完成後透過通知回報結果 4. 執行期間可以被監控與管理
啟動 Background Agent
使用 Ctrl+B:
當 Claude 正在工作時,按下 Ctrl+B 可將目前任務送到背景。終端機會立即恢復可用。
使用 & 前綴:
& Run all tests and fix any failures
& Refactor the authentication module to use JWT
& Generate complete API documentation
& 前綴會派送到 Claude Code Remote(雲端執行)。若要在本機背景執行,請對已在執行中的任務使用 Ctrl+B。
監控背景任務
> /tasks # List all running tasks
> /task status abc123 # Check specific task
> /task cancel abc123 # Stop a task
> /task output abc123 # View task output so far
平行背景工作流程
同時執行多個 agents:
& Fix all failing tests in src/
& Update documentation for the API module
& Run security scan on the codebase
每個 agent 都會獨立執行。使用 /tasks 監控進度,並在結果完成時取回。
Chrome 中的 Claude(2025年12月)
Claude Code 現在可透過 Chrome extension 與瀏覽器整合,讓您直接從終端機控制瀏覽器。17
先決條件
- Chrome 或 Chromium-based browser(Edge、Brave、Arc 都可使用)
- 在終端機中執行的 Claude Code v2.0+
- Pro、Max、Team 或 Enterprise 方案(Free 無法使用 extension)
- 從 https://claude.ai/chrome 安裝 Chrome extension
設定
- 從 https://claude.ai/chrome 安裝 Chrome extension
- 依提示授予 extension 權限(瀏覽器控制需要頁面存取權)
- 啟動 Claude Code——整合會透過本機 WebSocket 自動偵測
- 使用自然語言控制瀏覽器
extension 會透過本機 WebSocket 連線與 Claude Code 通訊。兩者必須同時執行。
能力
從終端機進行瀏覽器自動化:
> Navigate to github.com and open my repositories
> Fill out this form with the test user data
> Take a screenshot of the current page
> Click the submit button and wait for the page to load
網頁擷取與測試:
> Extract all product prices from this e-commerce page
> Run through the signup flow and report any issues
> Check if the mobile menu works correctly
使用情境
- E2E testing:直接從 Claude Code 執行整合測試
- Web scraping:不必撰寫瀏覽器自動化程式碼,即可從頁面擷取資料
- 表單填寫:自動化重複性的網頁工作流程
- 視覺驗證:截圖並分析頁面版面
Chrome 整合會在您既有的瀏覽器工作階段內執行,可存取已登入狀態與 cookies,對測試需要驗證的流程相當有用。
限制
- 不支援多分頁:Claude 只能控制作用中的分頁;無法同時協調多個分頁
- JavaScript 對話框會阻塞執行:
alert()、confirm()與prompt()對話框會暫停 extension——自動化流程中應避免觸發 - 不支援無痕模式存取,除非您明確在無痕模式中啟用 extension
- WebSocket 連線:如果 Claude Code 重新啟動,Chrome extension 必須重新連線(通常會在數秒內自動完成)
- 使用
read_page從 accessibility tree 取得 element refs;互動時使用ref,不要使用座標
Slack 中的 Claude Code(2025年12月)[RESEARCH PREVIEW]
Anthropic 在 Slack 中推出 Claude Code,讓開發人員可以直接從聊天執行緒委派程式碼任務。19
運作方式
- 在任何 Slack 頻道或執行緒中標註
@Claude - 描述程式碼任務並附上背景脈絡
- Claude 分析 Slack 訊息以判斷 repository
- 進度更新會出現在執行緒中
- Claude 分享連結,讓您檢閱成果並開啟 PR
工作流程範例
@Claude The login form validation is broken on mobile devices.
Can you fix it? Check the bug report from earlier in this thread.
Claude 會: 1. 讀取執行緒以取得背景脈絡 2. 識別相關 repository 3. Clone 並分析 codebase 4. 發布進度更新 5. 建立包含修正的 PR 6. 分享 PR 連結供檢閱
優點
- 脈絡感知:Claude 會讀取 Slack 歷史紀錄,以了解錯誤回報、功能請求與討論
- 團隊可見性:執行緒中的進度更新讓所有人掌握狀況
- 低摩擦:不需要 terminal 或 IDE;直接從聊天開始
- GitHub 整合:自動建立 PR,並附上適當描述
先決條件
- 已安裝 Claude app 的 Slack workspace(需由 workspace admin 核准)
- 已連接到 Slack workspace 的 GitHub repository
- Pro、Max、Team 或 Enterprise方案
- Claude 必須具備目標 repository 的寫入權限(建立 branch、建立 PR)
限制
- Repository 偵測:Claude 會從 Slack 脈絡推斷 repository(頻道主題、近期訊息、執行緒內容)。若資訊不明確,請明確指定 repo:
@Claude in repo org/my-app, fix the login bug - 無本機檔案存取:Slack Claude 完全在雲端執行——它會 clone repo、進行變更並建立 PR。它無法存取您的本機檔案系統
- 執行緒脈絡視窗:Claude 會讀取目前執行緒,但來自其他頻道或 DM 的脈絡有限
- 核准流程:所有變更都會經過 PR review——Claude 絕不會直接 push 到 main
- 速率限制:受您方案的 Claude Code 使用限制約束(與 CLI 和 web 使用量共用)
Slack 整合目前針對 Pro、Max、Team 與 Enterprise 使用者提供 research preview。
Microsoft 365 中的 Claude(2026年5月)
2026年5月7日,Anthropic 將其 Microsoft 365 介面從有限推出移至付費方案的正式上線。根據公告:「Claude for Excel, PowerPoint, and Word are generally available, and Claude for Outlook is now in public beta for all paid plans.」161
其訴求是在各 app 之間提供連結式工作區。Anthropic 以具體方式描述:「Adjust an assumption in Excel and the chart in PowerPoint and the number in your Word memo automatically update, too.」161 對 Outlook 而言,新行為是 mailbox triage:「Ask Claude to triage your inbox and it sorts messages by what needs your response, what it can draft for you, and what’s noise.」161
可用性
- Excel、PowerPoint、Word。正式上線。「All Mac and Windows users on paid plans can access Claude for Microsoft 365.」161
- Outlook。Public beta。「Claude for Outlook is available in beta on all paid plans.」161
它與 Claude Code 的關係
Microsoft 365 add-ins 位於 Office apps 內,並連至支援 Claude Code 的同一套 Claude 基礎設施。它們不是 Claude Code 介面(您不會從 Excel 操作 CLI),但會與 2026年5月5日推出的 agent template 工作搭配:10 個 finance agent templates 會以 plugins 形式提供給 Claude Cowork 和 Claude Code 使用,而相同的 data-connector 與 Moody’s MCP 整合也可從兩種介面存取。158 可將 M365 視為 CLI 的 office-app 夥伴,而非替代品。
Web 上的 Claude Code [RESEARCH PREVIEW](2026年1月)
Web 上的 Claude Code 讓您可以在瀏覽器中透過 claude.com/code 委派程式碼任務,並在 Anthropic 管理的雲端基礎設施上執行。66 這是沒有 terminal 的 Claude Code——指派任務、追蹤進度,並取得回傳的 pull requests。
主要功能
- 平行任務執行:從單一介面同時啟動不同 repositories 的多項程式碼任務
- 即時進度追蹤:透過即時更新觀看 Claude 執行任務;並在 session 中途調整其處理方向
- 自動建立 PR:Claude 會產生 pull requests,並附上清楚的變更摘要
- Session teleportation:使用
claude --teleport將 web sessions 拉入本機 terminal,以便在本機繼續工作 - 行動裝置存取:早期階段的 iOS app 讓您可以從手機指派並監控程式碼任務66
安全架構
任務會在具備網路與檔案系統限制的隔離 sandbox environments中執行。Git 互動會透過安全 proxy 流動,將 repository 存取限制在已授權的 repos。Administrators 可以設定 Claude 可存取哪些 domains(例如允許下載 npm packages 以進行測試)。66
可用性
| 方案 | 存取權 |
|---|---|
| Pro / Max | 已包含 |
| Team / Enterprise | 需要 Premium seats |
Cloud sessions 會與所有其他 Claude Code 使用量(CLI、IDE、Slack)共用速率限制。
Web vs Terminal:何時使用哪一種
| 情境 | 使用 Web | 使用 Terminal |
|---|---|---|
| Bug backlog triage | 平行指派 5 個 bugs | — |
| 離開桌前時的快速修正 | 從手機指派 | — |
| 複雜架構工作 | — | 完整 codebase 脈絡 |
| Custom hooks 與 MCP | — | 完整 extension layer |
| Overnight batch work | 睡前指派,早上檢閱 | & background agents |
目前限制:Session teleportation 僅支援單向——您可以將 web sessions 拉入 terminal,但無法將 terminal sessions push 到 web。66
效能最佳化
降低延遲
模型選擇: - Haiku:回應最快、成本最低 - Sonnet:平衡性佳 - Opus:品質最佳、延遲最高
串流: 所有回應預設都會串流,因此可在產生時即時看到輸出。
提示快取: 預設啟用。可降低重複情境(系統提示、工具定義)的延遲。
快取策略
Claude Code會自動快取系統提示與工具定義: - 快取期間:5分鐘(暫時性) - 快取命中:減少輸入 token,並加快回應
多輪對話會快取前幾輪的 thinking blocks。
必要時可依模型停用快取:
export DISABLE_PROMPT_CACHING_SONNET=1
export DISABLE_PROMPT_CACHING_OPUS=1
export DISABLE_PROMPT_CACHING_HAIKU=1
平行作業
Subagent平行化: 多個 subagents 可同時執行。每個 subagent 都會獨立運作,不會污染主要情境。
背景 bash: 長時間執行的命令不會阻塞對話:
> run the full test suite in the background
Git worktrees(v2.1.49+): 在隔離的 git worktree 中啟動Claude,即可平行作業且不影響主要 working tree:
claude --worktree # or -w; creates worktree in .claude/worktrees/
claude -w --name feature-x # Named worktree
Subagents 也支援在其定義中使用 isolation: "worktree",讓每個 subagent 都有一份隔離的 repo 複本;若沒有任何變更,系統會自動清理。96 ExitWorktree 工具允許 agents 以程式方式離開 worktree session(v2.1.72+)。114 若使用非 git 的 VCS,請設定 WorktreeCreate/WorktreeRemove hooks 來處理自訂的設定與清理。96
Monorepo 的 sparse worktrees(v2.1.76+): worktree.sparsePaths 設定會為大型 monorepos 中的 worktrees 啟用 git sparse-checkout,只 checkout 您指定的路徑,而非整個 repository:118
{
"worktree": {
"sparsePaths": ["packages/my-service", "shared/utils"]
}
}
跨 worktrees 的共享狀態(v2.1.63+): Project configs(.claude/settings.json)與 auto-memory 現在會在同一個 repository 的 git worktrees 之間共享。在某個 worktree 中對 settings 或 memories 的變更,其他 worktrees 也都看得到。104
worktree.baseRef 設定(v2.1.133+,BREAKING DEFAULT): 控制 --worktree、EnterWorktree 與 agent-isolation worktrees 要從哪裡分支。共有兩個值:160
"fresh"(新的預設值):從origin/<default>分支。這會還原 v2.1.128 的行為變更。Worktree 產生時會捨棄任何尚未 push 的本機 commits。"head":從本機HEAD分支。若希望新的 worktrees 可使用尚未 push 的 commits,必須使用此值。
{
"worktree": {
"baseRef": "head"
}
}
操作者注意事項:如果您已依賴 v2.1.128–v2.1.132 將尚未 push 的工作帶入新 worktrees 的行為,請在升級前設定 worktree.baseRef: "head",否則您的 EnterWorktree worktrees 會無聲無息地改從 origin/<default> 開始。160
Session 期間切換 worktree(v2.1.157+)。 EnterWorktree 現在可在 session 期間於Claude管理的 worktrees 之間切換,而不只進入全新的 worktree。當 agent 需要在兩個平行分支間來回切換且不想重新啟動時,這很實用。背景 worktrees 也會在 agent 完成後維持解鎖,因此 git worktree remove / git worktree prune 不再會被陳舊 lock 絆住。179
記憶體最佳化
- 具體檔案參照:使用
@src/auth.ts,而不是「find the auth file」 - 精準搜尋:使用「search in src/api」,而不是「search everywhere」
- 全新 sessions:在不相關的任務之間使用
/clear - 自訂壓縮:在 CLAUDE.md 加入要保留內容的指示
- 工具結果磁碟持久化(v2.1.51+):超過 50K 字元的工具結果現在會持久化到磁碟(從 100K 降低),可減少 context window 使用量,並提升長 session 中的對話持續性98
- BashTool 略過 login shell(v2.1.51+):當 shell snapshot 可用時,BashTool 現在預設會略過 login shell
-lflag,提升命令執行效能。先前需要設定CLAUDE_BASH_NO_LOGIN=true98
如何除錯問題?
安裝問題
WSL 路徑問題:
npm config set os linux
npm install -g @anthropic-ai/claude-code --force --no-os-check
which npm # Should start with /usr not /mnt/c
Node 版本衝突(nvm):
加入 ~/.bashrc 或 ~/.zshrc:
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
權限錯誤: 使用原生安裝,而非 npm:
curl -fsSL https://claude.ai/install.sh | bash
驗證問題
# Complete reset
/logout
rm -rf ~/.config/claude-code/auth.json
claude # Fresh login
效能問題
CPU/記憶體用量過高:
- 使用 /compact 減少 context
- 在大型任務之間重新啟動
- 將大型目錄加入 .gitignore
- 執行 claude doctor
搜尋緩慢: 安裝系統 ripgrep:
# macOS
brew install ripgrep
# Windows
winget install BurntSushi.ripgrep.MSVC
# Linux
sudo apt install ripgrep
然後:
export USE_BUILTIN_RIPGREP=0
WSL 上速度緩慢:
- 將專案移到 Linux 檔案系統(不要放在 /mnt/c/)
- 搜尋時使用特定目錄篩選
IDE 整合問題
偵測不到 JetBrains(WSL2):
選項 1 - Windows Firewall:
wsl hostname -I # Get WSL IP
New-NetFirewallRule -DisplayName "Allow WSL2" -Direction Inbound -Protocol TCP -Action Allow -RemoteAddress 172.21.0.0/16
選項 2 - Mirrored networking(加入 ~/.wslconfig):
[wsl2]
networkingMode=mirrored
然後:wsl --shutdown
Escape 鍵在 JetBrains 中無法運作: Settings → Tools → Terminal → 取消勾選「Move focus to the editor with Escape」
驗證管理(v2.1.41+)
claude auth login # Log in or switch accounts
claude auth status # Check current authentication state
claude auth logout # Log out and clear stored credentials
在API key 與OAuth之間切換,或在 organizations 之間切換時,使用 claude auth logout && claude auth login 重設驗證。
Debug Mode
claude --debug # Full debug output
ANTHROPIC_LOG=debug claude # API request logging
claude doctor # Health check
/debug # Troubleshoot current session (v2.1.30+)
/debug 命令(v2.1.30+)會提供 session 專屬診斷資訊,包括:
- 目前模型與 context 使用量
- 啟用中的MCP伺服器及其狀態
- 權限狀態與近期拒絕記錄
- 記憶體壓力指標
設定重設
# Reset user settings
rm ~/.claude.json
rm -rf ~/.claude/
# Reset project settings
rm -rf .claude/
rm .mcp.json
常見錯誤訊息
| 錯誤 | 原因 | 解決方案 |
|---|---|---|
| “Rate limit exceeded” | 請求過多 | 等待或降低頻率 |
| “Context length exceeded” | 對話過長 | 使用 /compact 或 /clear |
| “Authentication failed” | Token 無效或已過期 | 執行 claude auth login |
| “Tool not permitted” | 權限遭拒 | 檢查 settings.json 權限 |
| “MCP server failed to start” | 伺服器設定錯誤 | 檢查 claude mcp get <name> |
底層機制:Source 透露了什麼
2026年3月,一個 Bun 建置錯誤讓 Claude Code npm package 釋出了 source maps,導致完整可讀的 source 外洩。133雖然 package 很快就被下架,社群仍深入分析了內部實作。其中有幾項發現,對 harness 建置者特別實用。
Auto Mode Classifier(yoloClassifier.ts)
Auto mode 權限系統實作在一個內部命名為 yoloClassifier.ts、長達 1,495 行的檔案中。134它會以獨立的 ML model call(Sonnet 4.6)執行,根據對話脈絡評估每次 tool invocation。這表示 auto mode 會為每次 tool call 增加一次 classifier inference;對高吞吐量自動化而言,這是值得納入考量的延遲與成本開銷。Classifier 檢查的是動作是否符合使用者明確表達的意圖,而不只是該命令單獨來看是否「安全」。
Bash 安全性:23 項檢查,源自真實事件
Bash 驗證模組(bashSecurity.ts)共 2,592 行,包含 23 項編號安全檢查。133關鍵防護包括:
| 攻擊向量 | 防護 |
|---|---|
Zsh =cmd expansion |
封鎖 =curl、=wget 等 |
zmodload gateway |
封鎖 18 個 Zsh builtins |
| Heredoc injection | 逐行內容比對 |
ANSI-C quoting($'\x41') |
Pattern detection |
Process substitution(<()、>()) |
在不受信任脈絡中封鎖 |
| Unicode zero-width spaces | Injection detection |
ztcp exfiltration |
封鎖網路 primitives |
這樣的深度暗示每一項檢查背後都有真實事件;這些並非紙上談兵的防護。
Prompt Cache 架構
promptCacheBreakDetection.ts 追蹤 14 種不同的 cache-break vectors,並使用「sticky latches」避免模式切換使 cache 失效。134實務含義是:重新排序 CLAUDE.md 的段落、在 session 中途切換 extended thinking,或變更 MCP server configs,都可能摧毀 prompt cache hit rate。若想獲得最佳 cache 效能,請在同一個 session 內保持 system prompt 穩定。
Autocompact Circuit Breaker
一段 source comment 揭示了過去問題的規模:“1,279 sessions had 50+ consecutive autocompact failures (up to 3,272 in a single session), wasting ~250K API calls/day.”133修正方式是:MAX_CONSECUTIVE_AUTOCOMPACT_FAILURES = 3,超過後 autocompact 會停止並顯示錯誤。如果遇到反覆的 compaction failures,原因就在這裡;系統現在會停止,而不是持續消耗 tokens。
Coordinator Mode:Prompts as Architecture
Multi-agent coordination(coordinatorMode.ts)完全以 system prompt instructions 實作,而不是 code-level orchestration。134Orchestrator model 會收到一段 prompt,描述如何 delegate、aggregate 與 synthesize;這驗證了「prompts as architecture」模式。Coordinator prompt 包含這項指令:“Never write ‘based on your findings’ — these phrases delegate understanding to workers instead of doing it yourself.”
Frustration Detection
userPromptKeywords.ts 透過 regex pattern matching 偵測使用者是否感到挫折,依據的是 profanity,而不是 LLM inference。133這比 model call 更快、成本也更低。觸發後,Claude 會調整行為:更謹慎、更明確、更謙和。如果曾注意到在表達挫折後,Claude 變得更小心,這就是背後機制。
對 Harness 建置者的啟示
這些內部實作驗證了幾種 harness patterns:
- Auto mode 的 classifier 是獨立的 model call:估算 autonomous workflows 的成本與延遲時,請把這點納入考量
- Bash security surface 很深:您的 PreToolUse hooks 可以補強,但不能取代內建的 23-check validation
- Prompt cache 很脆弱:設計 CLAUDE.md 與 rules files 時,應優先考慮穩定性,而不是在 session 中途頻繁編輯
- Multi-agent coordination 由 prompt 驅動:coordinator pattern 能在 Anthropic 的規模上運作,證實 system prompts 可以 orchestrate 複雜的 agent workflows
- Autocompact 有硬性上限:如果 sessions 進入 compaction loops,系統會在 3 次失敗後停止,而不是無限制消耗 tokens
Quality Postmortem(2026年4月23日)
Anthropic 在4月23日發布 engineering postmortem,說明 3 個彼此獨立、卻在3月到4月初互相疊加的品質退化問題。這 3 個問題都已在4月20日(v2.1.116)前解決,且所有訂閱者的 usage limits 已重設。153
| 問題 | 生效期間 | 受影響 models | 根本原因 | 解決方式 |
|---|---|---|---|---|
| Reasoning effort default | 3月4日 → 4月7日 | Sonnet 4.6、Opus 4.6 | 為減少 UI freezing,預設值從 high 降為 medium。Operators 相較於 UI 順暢度,更偏好較高 intelligence。 |
4月7日回復。(另,4月22日的 v2.1.117 為 Pro/Max users 在 4.6 models 上恢復 high defaults;Opus 4.7 發布時已是 xhigh。) |
| Prompt cache thinking-clear bug | 3月26日 → 4月10日 | Sonnet 4.6、Opus 4.6 | 原本意圖在每個 idle session 只清除一次 thinking 的 cache optimization,實際上在 session 剩餘期間每一輪都清除 thinking。造成健忘、重複,以及 usage 更快耗盡。 | 已於 v2.1.101(4月10日)修正。 |
| System-prompt verbosity constraint | 4月16日 → 4月20日 | Sonnet 4.6、Opus 4.6、Opus 4.7 | 為處理 Opus 4.7 chattiness 而加入;依 Anthropic 說法,使 Opus 4.6 與 Opus 4.7 的 coding quality 下降約 3%(Sonnet 4.6 測得的下降較小)。 | 已於 v2.1.116(4月20日)回復。 |
Operator takeaways。 特別是 cache-clear bug,會在 15 天期間內悄悄劣化 long sessions;凡是在3月下旬到4月中旬之間覺得 sessions 突然變得健忘的人,都應知道這不是 user error。Anthropic 所述的緩解措施包括:更廣泛的 pre-release evaluation suites、更嚴格的 system-prompt change controls、對影響 intelligence 的變更強制進行 code review,以及對任何觸及 model behavior 的項目採用 gradual rollouts。
Enterprise部署
Cloud Provider比較
| 功能 | Anthropic Direct | AWS Bedrock | Google Vertex | Microsoft Foundry |
|---|---|---|---|---|
| 驗證 | API key | IAM/API key | GCP credentials | Entra ID/API key |
| 成本追蹤 | Console | AWS Cost Explorer | GCP Billing | Azure Cost Mgmt |
| 稽核記錄 | 有限 | CloudTrail | Cloud Audit Logs | Azure Monitor |
| SSO | 否 | IAM | IAM | Entra ID |
Managed Settings部署
透過managed-settings.json部署全組織政策:
位置:
- macOS:/Library/Application Support/ClaudeCode/managed-settings.json
- Linux:/etc/claude-code/managed-settings.json
- Windows:C:\Program Files\ClaudeCode\managed-settings.json
政策範例:
{
"permissions": {
"allow": [
"Read",
"Glob",
"Grep",
"Bash(npm run:*)",
"Bash(git:*)"
],
"deny": [
"Bash(rm -rf:*)",
"Bash(curl:*)",
"Read(.env*)",
"WebFetch"
],
"defaultMode": "default"
},
"model": "claude-opus-4-6",
"disableBypassPermissionsMode": "disable",
"allowManagedPermissionRulesOnly": true,
"allowManagedHooksOnly": true
}
僅限Managed的settings鍵:
| 鍵 | 效果 |
|---|---|
allowManagedPermissionRulesOnly |
防止使用者/專案settings定義權限規則;僅套用managed規則 |
allowManagedHooksOnly |
防止載入使用者/專案/plugin hooks;僅執行managed與SDK hooks |
allowAllClaudeAiMcps |
Enterprise設定,可在managed-mcp.json之外一併載入claude.ai雲端MCP connectors(v2.1.149+) |
strictKnownMarketplaces |
plugin marketplaces的允許清單(空陣列=鎖定) |
allowedMcpServers |
使用者可設定的MCP servers允許清單(空陣列=鎖定) |
deniedMcpServers |
MCP servers拒絕清單(優先於允許清單) |
disableBypassPermissionsMode |
防止使用--dangerously-skip-permissions |
| disableSkillShellExecution | 防止在skills、自訂commands與plugin commands中執行inline shell136 |
| forceRemoteSettingsRefresh | 在遠端managed settings重新擷取完成前封鎖啟動;若擷取失敗則結束(fail-closed)137 |
| parentSettingsBehavior | 管理員層級鍵("first-wins" \| "merge"),可讓SDK managedSettings(parent tier)納入政策合併,而不是依預設first-wins規則落敗(v2.1.133+)160 |
使用者無法覆寫managed settings。managed settings在設定階層中具有最高優先順序。
平台原生部署(v2.1.51+):除了JSON檔案外,也可以透過macOS property lists(plist)或Windows Registry部署managed settings,便於整合既有的MDM(Mobile Device Management)與Group Policy基礎架構:107
- macOS plist:透過MDM profiles部署,或使用
defaults write寫入com.anthropic.claude-codedomain - Windows Registry:透過Group Policy部署於
HKLM\SOFTWARE\Policies\ClaudeCode
平台原生來源會與JSON檔案合併。若同一個鍵同時出現在兩者中,平台原生來源具有優先權。
Enterprise CLAUDE.md
部署全組織context:
位置:
- macOS:/Library/Application Support/ClaudeCode/CLAUDE.md
- Linux:/etc/claude-code/CLAUDE.md
內容:
# Company Standards
## Security Requirements
- Never commit secrets or credentials
- All external API calls require security review
- Use parameterized queries for all database access
## Code Standards
- Follow company style guide at @docs/STYLE.md
- All PRs require two approvals
- Test coverage minimum: 80%
## Approved Tools
- npm, yarn, pnpm for package management
- Jest for testing
- ESLint + Prettier for formatting
推出策略
- 從文件開始:部署前先把CLAUDE.md調整到位
- 試點群組:先從5-10位開發人員開始
- Q&A階段:讓試點成員使用Claude進行程式碼探索
- 引導式開發:逐步推進到小型錯誤修正
- 完整部署:搭配managed settings全面推出
- 監控成本:追蹤各團隊用量
稽核與合規
資料處理:
- Session transcripts預設儲存在本機(除API呼叫外,沒有資料離開機器)
- API請求會送至api.anthropic.com(direct),或透過您的cloud provider(Bedrock/Vertex/Foundry)
- Anthropic的commercial terms聲明,API輸入/輸出不會用於模型訓練
- 若有資料落地要求,請使用Bedrock(AWS regions)或Vertex(GCP regions),讓API流量維持在特定地理區域內
SSO與身分:
- Anthropic Direct:透過claude login進行基於OAuth的驗證(無SAML/SSO——若有SSO需求,請使用cloud providers)
- AWS Bedrock:透過AWS IAM Identity Center使用IAM roles與SSO
- Google Vertex:GCP IAM搭配Workforce Identity Federation支援SAML/OIDC
- Microsoft Foundry:Entra ID搭配原生SSO
合規框架: - Anthropic發布SOC 2 Type II報告(可透過sales在NDA下取得) - Cloud providers(AWS、GCP、Azure)各自具備合規認證(SOC 2、HIPAA BAA、ISO 27001、FedRAMP)——透過它們路由可承接其合規態勢 - 對於受監管產業(醫療、金融),請透過具備適當BAA或合規附錄的cloud provider路由,而不是直接使用API
記錄與監控: - 使用cloud provider logging進行企業稽核(CloudTrail、Cloud Audit Logs、Azure Monitor) - 可以考慮使用LiteLLM proxy,細緻追蹤跨團隊用量 - Managed settings可強制執行合規政策 - Analytics API提供每位使用者的每日用量彙總(見下方)
Analytics API(Admin)
Enterprise與Team方案可使用Claude Code Analytics API,以程式化方式追蹤用量。
Endpoint:GET /v1/organizations/usage_report/claude_code
驗證:需要Admin API key(sk-ant-admin...),由組織管理員在Console中佈建。
可用指標:
| 類別 | 指標 |
|---|---|
| 生產力 | 每位使用者的sessions、新增/移除行數、commits、PRs |
| Tool Usage | 依tool(Edit、Write、NotebookEdit)區分的接受/拒絕率 |
| 成本 | 依使用者與模型分列的預估成本明細 |
Request Parameters:
- starting_at - 每日彙總日期(YYYY-MM-DD)
- 回傳指定日期的使用者層級資料
範例:
curl -X GET "https://api.anthropic.com/v1/organizations/usage_report/claude_code?starting_at=2026-01-25" \
-H "x-api-key: sk-ant-admin-..." \
-H "anthropic-version: 2023-06-01"
限制: - 僅提供每日彙總(約1小時延遲,以確保一致性) - 若需即時監控,請使用OpenTelemetry整合 - 僅追蹤第一方API用量(不包含Bedrock/Vertex)
成本:具備Admin API存取權的組織可免費使用。
鍵盤快捷鍵參考
一般控制
| 快捷鍵 | 動作 |
|---|---|
Ctrl+C |
取消目前操作 |
Ctrl+D |
結束 session(EOF) |
Ctrl+L |
清除畫面(保留歷史記錄) |
Ctrl+O |
切換詳細輸出 |
Ctrl+R |
搜尋命令歷史記錄 |
Ctrl+V |
從剪貼簿貼上圖片 |
Ctrl+B |
將目前操作移至背景 |
Ctrl+F |
終止所有背景 agents(v2.1.47+) |
Ctrl+Y |
Yank(從 kill ring 貼上) |
Ctrl+S |
暫存 prompt 草稿(儲存目前輸入) |
Alt+Y |
Yank-pop(在 Ctrl+Y 後循環 kill ring) |
Esc Esc |
回復上一個變更 |
Tab |
接受 prompt 建議 |
! + Tab |
Bash 歷史記錄自動完成(v2.1.14+) |
Shift+Tab |
循環切換權限模式 |
Alt+P / Option+P |
輸入 prompt 時切換模型 |
Alt+T |
切換思考模式(較安全的替代方式) |
Ctrl+T |
在 /theme 中切換語法醒目提示 |
Ctrl+G |
開啟外部編輯器(在 AskUserQuestion 的「Other」輸入中) |
Shift+Down |
循環切換 agent 團隊隊友(可環狀循環,v2.1.47+) |
Up/Down |
瀏覽命令歷史記錄 |
? |
顯示快捷鍵 |
可自訂的 keybindings(v2.1.18+):執行 /keybindings 來自訂鍵盤快捷鍵。支援特定情境的綁定、chord sequences(多鍵組合),以及完整個人化設定。Claude Code 會將 keybindings 儲存在 ~/.claude/keybindings.json。完整設定參考請參閱 keybindings docs。70
Prompt 建議(2025年12月):Claude 現在會建議 prompt,加快工作流程。按 Tab 可接受建議,或按 Enter 提交自己的 prompt。6
多行輸入
| 方法 | 按鍵 |
|---|---|
| 跳脫換行 | \ 接著 Enter |
| macOS | Option+Enter |
| 開箱即用(v2.1.0+) | 在 iTerm2、WezTerm、Ghostty、Kitty 中使用 Shift+Enter30 |
| 其他終端機 | Shift+Enter(先執行 /terminal-setup) |
| 控制字元 | Ctrl+J |
| 自訂 keybinding(v2.1.47+) | 透過 /keybindings 將任意按鍵綁定到 chat:newline95 |
快速前綴
| 前綴 | 動作 | 範例 |
|---|---|---|
# |
加入記憶 | # Always use TypeScript |
/ |
Slash command | /review |
! |
直接執行 bash | ! git status |
@ |
檔案參照 | @src/index.ts |
& |
傳送到 cloud | & Build the API |
檔案參照效能(2026年1月):在 git repos 中,@ mentions 現在快了 3 倍。Claude Code 在建議檔案自動完成時,也會遵循 .ignore 和 .rgignore 檔案;這對於從建議中排除建置產物或產生的檔案很有幫助。28
Vim 模式
透過 /config → Editor mode 啟用(/vim 命令已在 v2.1.92 移除137):
Normal mode:
- h/j/k/l - 導覽
- w/e/b - 單字移動
- 0/$ - 行首/行尾
- gg/G - Buffer 開頭/結尾
- dd - 刪除整行
- cc/C - 變更整行/變更到行尾
- dw/de/db - 刪除單字的不同變體
- x - 刪除字元
- . - 重複上一個編輯
Insert mode:
- i/I - 在游標前/行首插入
- a/A - 在游標後/行尾插入
- o/O - 在下方/上方開新行
- Esc - 返回 normal mode(在 INSERT 中,不再拉回佇列中的訊息;若要中斷,請再按一次 Esc,v2.1.119+)152
Visual mode(v2.1.118+):152
- v - 進入 visual(字元)模式
- V - 進入 visual-line 模式
- 使用 h/j/k/l、w/e/b、0/$、gg/G 移動以延伸選取範圍
- 視覺回饋會醒目標示選取範圍
- 套用 operators:d(刪除)、c(變更)、y(yank);選取後會退出 visual mode
最佳實務
Session 策略
在 Claude 內使用 /rename 命名 session,之後再依名稱恢復:
# Inside a session, name it:
> /rename feature-auth
# Later, resume by name:
claude --resume "feature-auth"
# Or continue the most recent session:
claude -c
持續進行的工作應恢復既有 session,而不是重新說明脈絡。
CLAUDE.md 設計
保持易於瀏覽。 Claude 每個 session 都會讀取此檔案,過於密集的文字會浪費 context。
聚焦於不明顯的內容。 記錄專案特定模式、特殊慣例與決策。略過 Claude 可從程式碼推斷的事項。
持續更新。 開發期間用 # 新增筆記。每週檢視並整併。
納入指令參考。 記錄您經常執行的指令。
安全性:不受信任的 Repositories
警告: 複製並在不受信任的 repositories 上執行 Claude Code 時,請注意 repository 中的 CLAUDE.md 檔案、
.claude/settings.json與 hook scripts 會被讀取,且可能被執行。惡意 repos 可利用這些內容注入 prompts、覆寫權限,或執行任意指令。在不屬於您的 repos 上執行 Claude Code 前,務必先檢視 CLAUDE.md、.claude/settings.json,以及任何 hook scripts。只有在受信任的 codebases 上才使用--dangerously-skip-permissions。
已知 CVEs(請保持 Claude Code 更新): - CVE-2025-59536(v1.0.111 已修正):透過不受信任目錄的工具初始化造成程式碼注入。 - CVE-2026-21852(v2.0.65 已修正):project-load 流程中的資訊揭露,讓惡意 repos 可外洩 API key。102
Custom Commands
為重複性 workflows 建立 commands:
---
description: Start new feature
allowed-tools: Bash(git:*), Read, Edit
---
1. Create branch: !`git checkout -b feature/$ARGUMENTS`
2. Pull latest main
3. Set up boilerplate
4. Begin implementation
有效 Prompting
具體說明:
# Good
"Add email validation to LoginForm in src/components/LoginForm.tsx"
# Too vague
"Improve the login"
直接引用檔案:
"Review @src/auth/middleware.ts for security issues"
提供限制條件:
"Refactor using the same pattern as @src/repositories/UserRepository.ts"
使用 subagents 進行探索:
"Have an explore agent find all places where we handle errors"
成本控制
- 定期使用
/cost - 將 Haiku 用於簡單任務與 subagents
- 僅在需要時設定
MAX_THINKING_TOKENS - 對自動化 scripts 使用
--max-turns - 在長 session 中主動 compact
安全性
- 在
.claude/settings.json中設定敏感檔案的 deny 規則 - 對不受信任的專案使用 sandbox mode
- 絕不允許
Bash(rm -rf:*)或Bash(sudo:*) - 使用 hooks 阻擋 secrets 存取
- 為企業部署 managed settings
社群技巧與技術4951
Claude Code 社群已發現超越官方文件的強大模式。這些技巧來自進階使用者,包括 Boris Cherny(Claude Code creator)以及 40+ tips repository。
寫程式前先使用 Plan Mode
如果只能記住一個技巧,就是這個。 花在規劃上的時間越多,Claude 成功的機率就越高。開始實作前,按 Shift+Tab 切換到 plan mode。完整文件請參閱 Plan Mode。
經常清除 Context
常用 /clear。每次開始新工作時,清除 chat。不需要讓舊歷史消耗 tokens,或觸發昂貴的 compaction calls。清掉後繼續即可。
使用圖片與 Screenshots
Claude 很擅長處理視覺輸入。在 macOS 上:Cmd+Ctrl+Shift+4 將 screenshot 擷取到剪貼簿,接著用 Ctrl+V 直接貼到 Claude Code。可用來分享 UI mockups、錯誤訊息或設計參考。
安裝 GitHub App 進行 PR Reviews
執行 /install-github-app,Claude 就會自動 review 您的 PRs。隨著 AI-assisted development 讓 PR 數量增加,自動 review 特別有價值。Claude 經常能抓到 human reviewers 會漏掉的邏輯錯誤與安全性問題。
Container-Based Autonomous Operation
若要完全 autonomous operation,請在 Docker container 中執行 Claude Code,並以 tmux 作為 control layer。您的本機 Claude Code 控制 containerized instance,後者可執行長時間或實驗性任務,無需手動核准。若發生問題,也會被 sandbox 隔離。
# Conceptual pattern (varies by setup)
# Local Claude Code → tmux → Container Claude Code
# Results pulled back when complete
Docker Sandbox Mode(快速開始): 探索不受信任的 codebases 或執行實驗性 prompts 時,在 Docker container 內執行 Claude Code,以取得完整隔離。56
# Run Claude Code in a Docker container (mount your project as a volume)
docker run -it --rm -v /path/to/project:/workspace anthropic/claude-code
# Or use the open-source sandbox runtime
# See: github.com/anthropic-experimental/sandbox-runtime
以下情境適合使用 sandbox mode: - 探索陌生或不受信任的 codebases - 測試可能修改檔案的實驗性 prompts - 執行您希望完全隔離的 autonomous sessions - 在不影響實際檔案的情況下學習 Claude Code
Gemini CLI 作為 Fallback
Claude Code 的 WebFetch tool 無法存取某些網站(例如 Reddit)。建立一個 skill,指示 Claude 在需要時使用 Gemini CLI 作為 fallback。Gemini 具備 web access,可擷取 Claude 無法直接抵達的網站內容。
Meta-Agent Factory Pattern
與其建立會執行任務的 agents,不如建立一個會建立其他 agents 的 agent。對於複雜 automation workflows,這個 pattern 能真正倍增生產力,而不是靠巧妙遞迴取巧。
Claude Squad:Multi-Agent Manager
Claude Squad 可平行管理多個 Claude Code instances,每個 instance 都在自己的 tmux session 與隔離 worktrees 中。您可以同時讓多個 agents 執行不同任務,從單一 dashboard 監控進度,完成後再取回結果。58
# Install (Homebrew)
brew install claude-squad
# Or install via script (puts `cs` in ~/.local/bin)
curl -fsSL https://raw.githubusercontent.com/smtg-ai/claude-squad/main/install.sh | bash
# Launch the TUI — manages instances, tasks, and git worktrees
cs
# Auto-accept mode (experimental)
cs --autoyes
使用案例: - 在 agents 之間平行處理獨立 features - 執行 exploratory prompts,而不阻塞主要 session - 將 autonomous coding 擴展到單一 context window 之外
Power User Productivity Stats
Boris Cherny 展示了 Claude Code 的潛力:30 天內,他合併了 259 個 PRs、497 次 commits:新增 40,000 行並移除 38,000 行。這些數字顯示,當 Claude Code 完整整合進 development workflow 時,可以達到什麼成果。
值得追蹤的人
追蹤以下帳號,掌握 Claude Code 最新發展:
Anthropic Team(Primary Sources)
| 誰 | Platform | 為何追蹤 |
|---|---|---|
| Boris Cherny | @boris_cherny | Claude Code creator。發布 features、宣布 updates、主持 meetups。Primary source。 |
| Cat Wu | @_catwu | Anthropic。Claude Code feature announcements、subagent updates。 |
| @adocomplete | X | Advent of Claude series:深入的每日 tutorials(hooks、plugins、prompt stashing)。 |
| Thariq | @trq212 | Anthropic engineer on Claude Code team。解決 issues、發布 updates。 |
| Anthropic | @AnthropicAI | 官方 announcements 與 major releases。 |
Top Content Creators
| 誰 | Focus | Notable |
|---|---|---|
| @dani_avila7 | Tutorials | Hooks 深度 guide、rules 說明 |
| @mattpocockuk | MCP/Tips | 10-lesson MCP tutorial、Docker sandbox、JSON optimization |
| ykdojo | GitHub Tips | 40+ tips repo、status line script、system prompt optimization |
| @ai_for_success | MCP/Workflows | Hyperbrowser MCP、documentation caching patterns |
| @jerryjliu0 | Agents | Step-by-step agent building tutorials |
重要資源
- GitHub Releases:anthropics/claude-code/releases - 只 watch releases
- Discord:Anthropic community channels
- 完整清單:請參閱
~/.claude/docs/following-list.md,其中收錄 20+ 精選帳號
Boris 與 Anthropic team 會在 features 上線時分享,這往往是在文件補上前,最快得知新功能的方式。
常見 Anti-patterns
了解「不要做什麼」通常比最佳實務更有價值。以下 patterns 一再造成問題:
成本 Anti-patterns
| Anti-pattern | 問題 | 解法 |
|---|---|---|
| 凡事都使用 Opus | 成本 5 倍,且通常不必要 | 預設使用 Sonnet,Opus 僅用於 architecture |
從不檢查 /cost |
帳單出乎意料 | 重大任務後檢查成本 |
| 在簡單任務上使用 extended thinking | 浪費 tokens | 例行工作關閉(Alt+T) |
| 在 main context 中執行 explore | Context 膨脹 | 改用 Explore subagent |
Context Anti-patterns
| Anti-pattern | 問題 | 解法 |
|---|---|---|
| 忽略 context 直到膨脹 | 推理品質下降、忘記決策 | 在 50% capacity 時主動 /compact |
| 只需要區段卻讀取整個檔案 | 把 context 浪費在無關程式碼 | 引用特定行範圍 |
| 從不使用 subagents | 所有內容都塞進 main context | 委派 exploration 與 analysis |
| 巨大的 CLAUDE.md 檔案 | 每個 session 都浪費 context | 控制在 500 行以下,使用 imports |
Workflow Anti-patterns
| Anti-pattern | 問題 | 解法 |
|---|---|---|
| 建立重疊的 skills 與 commands | 混淆、行為難以預測 | 每個用途只用一種機制 |
| 用 prompts 確保一定會執行的動作 | Claude 可能跳過或忘記 | 對必須執行的動作使用 hooks |
| 沒有格式化 hooks | 程式碼風格不一致 | 對每次 Edit/Write 加上 formatter hook |
| 預設允許所有 bash | 安全風險 | 對安全指令使用明確 allowlist |
Configuration Anti-patterns
| Anti-pattern | 問題 | 解法 |
|---|---|---|
| 所有 config 都放在 user settings | 無法與團隊共享 | 將 team standards 放在 project settings |
| Commit 個人偏好 | 覆寫 teammates | 個人設定使用 settings.local.json |
| 沒有 deny rules | Claude 可能碰到敏感檔案 | Deny .env、credentials、secrets |
| 忽略 managed settings | Enterprise policies 被繞過 | 使用 managed settings 確保 compliance |
Prompt Anti-patterns
| Anti-pattern | 問題 | 解法 |
|---|---|---|
| 「Make it better」 | 模糊,結果不佳 | 明確說明「better」的意思 |
| 未引用檔案 | Claude 只能猜 paths | 使用 @path/to/file.ts syntax |
| 忽略 Claude 的問題 | 根據錯誤假設工作 | 先回答再繼續 |
| 片段足夠卻提供完整 docs | 浪費 context | 擷取相關區段 |
Workflow Recipes
常見情境的端到端模式。
Recipe 1:開始新專案
# 1. Initialize
cd my-project
claude
# 2. Let Claude understand the codebase
> "Explore this codebase and summarize the architecture"
# 3. Set up project configuration
> /init
# 4. Create CLAUDE.md with learned patterns
> "Create CLAUDE.md documenting the patterns you observed"
# 5. Add team commands
> "Create a /test command that runs our test suite"
> "Create a /deploy command for staging deployment"
Recipe 2:日常開發流程
# 1. Continue yesterday's session
claude -c
# 2. Quick context recap
> "What did we work on yesterday?"
# 3. Check current state
> /status
# 4. Work on feature (Sonnet handles most tasks)
> "Implement the user profile endpoint"
# 5. Proactive context management
> /compact # Before context exceeds 50%
# 6. Check spending
> /cost
# 7. End session cleanly
> "Summarize what we accomplished today"
Recipe 3:複雜重構
# 1. Use Opus for planning, Sonnet for execution
> /model opusplan
# 2. Plan the refactoring
> "Plan refactoring our authentication from sessions to JWT"
# 3. Review the plan
# (Claude presents approach, you approve or modify)
# 4. Execute with Sonnet
> "Execute the plan"
# 5. Verify nothing broke
> "Have an explore agent verify all auth-related tests pass"
# 6. Review the diff
> !git diff
Recipe 4:PR Review 自動化
# In CI/CD (GitHub Actions, etc.)
cat pr_diff.txt | claude -p "Review this PR diff for:" \
--output-format json \
--permission-mode plan \
--max-turns 5 << EOF
- Security vulnerabilities
- Performance issues
- Code style violations
- Missing test coverage
Provide findings in JSON format.
EOF
Recipe 5:偵錯正式環境問題
# 1. Configure Sentry MCP for error access
claude --add-mcp sentry
# 2. Get error context
> "Fetch the last 10 errors from Sentry for the auth service"
# 3. Deep dive with thinking
> Alt+T # Enable extended thinking
> "Analyze these errors and identify the root cause"
# 4. Fix and verify
> "Implement a fix and add a regression test"
> !npm test
遷移指南
正從其他 AI coding tools 轉換過來嗎?以下說明概念如何對應。
從 GitHub Copilot 遷移
| Copilot 概念 | Claude Code 對應項目 |
|---|---|
| Tab completion | 不是主要焦點:Claude Code 執行 agentic editing |
| Chat + agentic CLI | 搭配工具執行的 REPL 對話 |
| Copilot instructions | CLAUDE.md + Skills |
| Specialized agents(Explore、Plan) | Subagents(Task tool)+ agent teams |
| MCP 支援 | 300+ MCP integrations + remote OAuth |
| ACP(Agent Client Protocol) | Hooks(12+ lifecycle events) |
| IDE + CLI | Terminal-native + IDE extensions |
可獲得的能力:OS 層級 sandboxing、22 個 hook lifecycle events、搭配 OAuth 的 remote MCP、具備隔離 context 的 subagent delegation,以及用於 cloud-to-local handoff 的 --teleport。Copilot CLI(2026年1月+)現在也具備 agentic capabilities;這項比較是在區分功能特色,而不是能力落差。
交互借鑑(2026年2月): Claude(Opus 4.6 與 Sonnet 4.6)現在已可作為 coding agent,在 GitHub Copilot 中供 Business 與 Pro 訂閱者免費使用;過去僅限 Enterprise 與 Pro+ 方案。您可以在 github.com、GitHub Mobile 與 VS Code 中,直接於既有 GitHub workflows 內執行 Claude、Codex 與 Copilot。105
從 Cursor 遷移
| Cursor 概念 | Claude Code 對應項目 |
|---|---|
| Composer | 具備完整工具存取權的 session |
| Chat | 搭配 subagent delegation 的 REPL |
| Codebase indexing | 即時檔案存取(Glob、Grep、Read) |
| Tab autocomplete | 不是主要焦點 |
| IDE-integrated | Terminal-native + IDE extensions |
| MCP 支援(內建) | MCP 支援(300+ integrations、remote OAuth) |
| Cursor rules(.mdc)+ AGENTS.md | CLAUDE.md + Skills |
| Background agents | Remote agents(& prefix、--teleport) |
可獲得的能力:用於自動化的 22 個 hook lifecycle events、具備隔離 context 的 subagent delegation、OS 層級 sandboxing(seatbelt/bubblewrap)、搭配原生 OAuth 的 remote MCP,以及 terminal-native workflow。兩項工具都支援 MCP;Claude Code 的差異化在於 remote OAuth 與 tool search auto-deferral。
從 OpenAI Codex CLI 遷移
這是最常見的比較,也是我們的 GSC 資料確認開發者確實會問的問題。兩者都是 frontier labs 推出的 agentic coding CLI,發布時間僅相差數月。以下是直接對照矩陣。151
| 面向 | Claude Code | OpenAI Codex CLI |
|---|---|---|
| Foundation model | Opus 4.7(Max/Team Premium 預設)、Sonnet 4.6(Pro/Team Standard/Enterprise/API 預設,至 2026年4月23日)、Haiku 4.5 | GPT-5.4(目前預設,2026年3月5日發布,整合 GPT-5.3-Codex coding capability + native Computer Use);可用 GPT-5.3-Codex、GPT-5.2-Codex、GPT-5.1-Codex、GPT-5 |
| Context window | Opus 4.7 以標準價格提供 1M tokens | GPT-5.4 預設 272K / 1.05M long-context mode(超過 272K input 後,以 2× input / 1.5× output 計費);GPT-5.3-Codex 與 GPT-5.2-Codex 為 400K input / 128K output |
| SWE-bench Verified | 87.6%(Opus 4.7) | 74.9%(GPT-5-Codex baseline);GPT-5.4 未公布於官方頁面 |
| SWE-bench Pro | 64.3%(Opus 4.7) | 57.7%(GPT-5.4 官方)、56.8%(GPT-5.3-Codex)、56.4%(GPT-5.2-Codex) |
| Terminal-Bench 2.0 | 69.4%(Opus 4.7) | 77.3%(GPT-5.3-Codex)、75.1%(GPT-5.4 官方)、64.0%(GPT-5.2-Codex) |
| Execution model | 預設本機;可透過 --teleport 使用選用的 cloud sandbox |
預設本機(Codex CLI);透過 Codex Cloud 使用 container-based sandbox |
| Sandboxing | OS 層級(macOS 上的 seatbelt、Linux 上的 bubblewrap) | Codex CLI 的本機 OS sandbox;Codex Cloud 的 container isolation |
| Instruction file | CLAUDE.md(以及 CLAUDE.local.md) |
AGENTS.md |
| Hook lifecycle | 22 個 events(PreToolUse、PostToolUse、UserPromptSubmit、Stop、SubagentStop 等) | 有限,主要是 run-level hooks |
| Subagents / Agent Teams | 最多 10 個平行 subagents、隔離 context、background mode | 預設 single-agent;可透過產生獨立 runs 來平行處理 |
| MCP server ecosystem | 3,000+ MCP servers、remote OAuth、tool search | MCP 支援(較新)、ecosystem 較小 |
| Plugins | Plugin marketplace、plugin.json manifests、version pinning | 尚無第一方 plugin system |
| Pricing model | Opus 4.7 每 MTok $5/$25;訂閱 $20–200/月 | OpenAI API 採 per-token;ChatGPT Pro/Plus 方案內含部分 Codex credits |
| Voice input | /voice push-to-talk(20 種 STT 語言) |
無 CLI-native voice mode;ChatGPT apps 有 voice |
| Enterprise policy | Managed settings(managed-settings.d/)、signed plugin marketplaces、CVE fast-track |
透過 OpenAI admin 提供 cloud-native policy |
| Windows support | Native binary + PowerShell tool | Codex CLI 通常僅支援 WSL |
目前紙面上 Claude Code 勝出的情境: 以公開 benchmarks 來看,Opus 4.7 在 SWE-bench Verified 領先常被引用的 GPT-5-Codex baseline 12.7,在 SWE-bench Pro 則領先 GPT-5.4 官方 57.7% 達 6.6。Terminal-Bench 2.0 則由 GPT-5.3-Codex 領先(77.3%),其後是 GPT-5.4(官方 75.1%),兩者皆高於 Opus 4.7(69.4%)。數字會隨每次 model 發布而變動,因此在做出跨季度決策前,請確認最新 vendor pages。151
何時選擇 Claude Code: 您維護大型 codebase(1M context 很重要)、需要具 kernel-level isolation 的 local-first sandboxing、想要深入的 hook-based automation(linters、policy checks、CI/CD gates),或需要原生 Windows 支援。目前 SWE-bench Verified 與 Pro 對 production tasks 較有利於 Opus 4.7。
何時選擇 Codex CLI: 您已付費使用 ChatGPT Pro/Plus,並希望沿用同一帳號;偏好 Codex Cloud 的 container-based hermetic sandboxing 來處理一次性的 remote tasks;或團隊標準化於 OpenAI infrastructure(Azure OpenAI、Foundry for Codex)。Terminal-Bench 2.0 目前對 shell-heavy workflows 較有利於 Codex family(GPT-5.3-Codex 77.3%、GPT-5.4 75.1%)。
兩者並用,而非二選一: 許多團隊會同時使用兩者。Claude Code 處理 long-horizon refactors 與 agentic coding;Codex 則從 ChatGPT 處理快速的 cloud-sandboxed tasks。AGENTS.md 與 CLAUDE.md 可以共存於同一個 repo(它們服務不同工具)。更深入的分析,也請參閱專門的 Codex vs Claude Code 2026 architecture comparison。
遷移路徑(Codex → Claude Code): 將 AGENTS.md 內容複製到 CLAUDE.md(Claude Code 不會讀取 AGENTS.md;您需要重新命名)。透過官方 installer 安裝 Claude Code,使用 claude login 驗證,接著以 claude --print "explain this repo" 測試。多數 Codex patterns(檔案讀取、shell commands、git operations)都能 1:1 對應。
從 ChatGPT / Claude Web 遷移
| Web Interface | Claude Code |
|---|---|
| Copy-paste code | 直接檔案存取 |
| Manual file creation | 直接寫入檔案 |
| No execution | 完整 bash、git、npm 等 |
| Context resets | Session continuity(-c flag) |
| No codebase awareness | Glob、Grep、Read tools |
| No automation | Hooks、CI/CD integration |
可獲得的能力:全部。Web interfaces 需要 copy-paste workflows;Claude Code 會直接在您的 codebase 上運作。
重要心態轉換
- 停止複製程式碼。Claude Code 會直接寫入檔案。
- 停止 context-switching。MCP 會把外部工具帶入 session。
- 積極委派。Subagents 可在不膨脹您的 context 的情況下處理探索。
- 用 hooks 自動化。Formatting、linting、logging 會自動發生。
- 以 sessions 思考。使用
-c延續工作,而不是開啟全新對話。
依受眾區分的指引
給開發人員:
- Haiku成本約比Opus低5倍;適合用於subagents與簡單任務
- 在長時間session中主動使用/compact管理context
- 將context編入Session IDs(feature-${branch}-${timestamp})有助於定位先前工作
- 在常用prompt前加上#,即可加入持久記憶,無須額外輸入
給DevOps與平台團隊:
- Headless模式(-pflag)可透過JSON輸出進行解析,支援CI/CD整合
- Hooks無論model行為如何都能保證執行;適合用於linting、formatting、安全檢查
- MCP將能力延伸到資料庫、GitHub、Sentry,以及300多種整合
- Background tasks(&prefix)會在Claude Code Remote上執行,支援非同步處理
給安全團隊:
- Permission規則採用first-match-wins評估;請謹慎設計allow/deny清單結構
- Sandbox模式會隔離不受信任codebase的檔案系統與網路
- Bash模式只比對prefix,因此Bash(curl:*)會封鎖所有curl,而不只是特定URL
- Enterprise managed settings無法由使用者覆寫
給團隊主管:
- Skills會依context自動啟用;可嵌入領域專業,無須明確呼叫
- Project skills會commit到git;隊友可自動取得標準化專業能力
- 透過/cost進行成本追蹤,可查看session細項;依團隊規模為每位使用者預估10k-300k TPM
- .claude/commands/中的Custom commands可建立可重複使用的workflows
給企業架構師:
- Managed settings可透過/etc/claude-code/managed-settings.json部署全組織政策
- AWS Bedrock、Google Vertex AI與Microsoft Foundry可整合既有cloud billing
- Opus 4.6搭配1M context window,可在單一prompt中處理完整codebase
- Agent teams(v2.1.32+)可針對複雜任務進行平行multi-agent協調
- 全面導入前,先以5-10位開發人員開始pilot
快速參考卡
列印出來。貼在螢幕上。
╔═══════════════════════════════════════════════════════════════╗
║ CLAUDE CODE QUICK REFERENCE ║
╠═══════════════════════════════════════════════════════════════╣
║ MODELS (Apr 2026 — defaults vary by plan) ║
║ haiku $1/$5/M Exploration, simple tasks ║
║ sonnet $3/$15/M Pro/Team Std/Enterprise/API default ║
║ opus $5/$25/M Max/Team Premium default (Opus 4.7) ║
║ opus[1m] $5/$25/M 1M ctx at STANDARD pricing (4.7) ║
║ sonnet[1m] $3/$15/M Large codebases (1M ctx, standard) ║
╠═══════════════════════════════════════════════════════════════╣
║ ESSENTIAL COMMANDS ║
║ /compact Reduce context (do at 50% capacity) ║
║ /cost Check session spending ║
║ /model opus Switch to Opus ║
║ /status Show current state ║
║ /voice Toggle voice mode (push-to-talk) ║
║ /init Set up project config ║
║ /mcp Configure integrations ║
║ /copy [N] Copy code blocks (Nth-latest response) ║
║ /memory View and manage auto-memory ║
║ /claude-api Build apps with Claude API/SDK ║
║ /code-review Correctness review (effort + --comment) ║
║ /batch Batch operations (bundled, v2.1.63+) ║
║ /effort Slider: min/low/med/high/XHIGH/max (4.7) ║
║ /loop 5m /foo Run prompt on recurring interval ║
║ /recap Context when returning to session (.108+) ║
║ /goal target Continue until a completion target is met ║
║ /ultrareview Cloud parallel multi-agent review (.111+) ║
║ /less-permission-prompts Propose allowlist (v2.1.111+) ║
║ /tui fullscreen Switch to flicker-free render (v2.1.110+) ║
║ /focus Focus mode (separated from Ctrl+O, .110+) ║
║ /undo Alias for /rewind (v2.1.108+) ║
║ /proactive Alias for /loop (v2.1.105+) ║
║ claude -n name Start session with display name ║
║ claude agents Agent View / configured agents ║
║ claude -w Start in isolated git worktree ║
║ claude remote-control Serve local env for external builds ║
║ claude -p --bare Scripted mode (no hooks/LSP/plugins) ║
║ claude --channels Relay approvals to Telegram/Discord ║
║ claude --plugin-url URL Load plugin zip for one session ║
╠═══════════════════════════════════════════════════════════════╣
║ KEYBOARD SHORTCUTS ║
║ Alt+T Toggle extended thinking ║
║ Shift+Tab Cycle permission modes ║
║ Ctrl+C Interrupt current operation ║
║ Ctrl+X Ctrl+K Stop all agents ║
║ Esc → Esc Rewind last change ║
║ Ctrl+L Clear screen ║
╠═══════════════════════════════════════════════════════════════╣
║ PREFIXES ║
║ #message Add to persistent memory ║
║ @path/file Reference file in prompt ║
║ !command Execute bash directly ║
║ &task Send to cloud (async) ║
╠═══════════════════════════════════════════════════════════════╣
║ CONFIG FILE HIERARCHY (first found wins) ║
║ .claude/settings.local.json Personal (gitignored) ║
║ .claude/settings.json Project (shared) ║
║ ~/.claude/settings.json User global ║
║ /etc/.../managed-settings.json Enterprise (locked) ║
║ CLAUDE.md Project context ║
╠═══════════════════════════════════════════════════════════════╣
║ DAILY WORKFLOW ║
║ 1. claude -c Continue session ║
║ 2. Work on features Use Sonnet ║
║ 3. /compact Before context bloats ║
║ 4. /cost Check spending ║
║ 5. Summarize Clean exit ║
╠═══════════════════════════════════════════════════════════════╣
║ DECISION RULES ║
║ Simple task? → Haiku ║
║ Hard reasoning? → Opus ║
║ Everything else? → Sonnet ║
║ Must always run? → Hook (not prompt) ║
║ Auto-apply wisdom? → Skill (not command) ║
║ Needs isolation? → Subagent ║
╚═══════════════════════════════════════════════════════════════╝
更新日誌
本參考文件是持續更新的活文件。隨著Claude Code演進,更新會持續套用。
| 日期 | 變更 | 來源 |
|---|---|---|
| 2026-06-17 | 指南 v2.59:CLI v2.1.177–v2.1.179。v2.1.178(實質版本):Tool(param:value)權限規則會以*萬用字元比對工具輸入參數,例如Agent(model:opus)可封鎖 Opus subagents(請參閱 Permission Rules Syntax);巢狀.claude/skills現在會在處理其下方檔案時載入(名稱衝突→<dir>:<name>),而巢狀.claude/ agents/workflows/output-styles 發生衝突時,會解析為最接近 cwd者(專案範圍 workflow 儲存目標會指向最接近且既有的.claude/workflows/);auto mode 現在會在啟動前透過分類器審查 subagent 產生,補上以產生作為繞過手段的缺口;compaction 會遵循--fallback-model鏈;disallowedTools MCP規格修正(mcp__server、mcp__server__*、mcp__*先前會被靜默忽略);另有/doctor扁平樹狀版面、/bug現在需要描述、workflow 關鍵字僅在明確片語下觸發,以及多項 subagent-transcript/Remote Control/驗證修正。v2.1.179:錯誤修正版——在串流中途連線中斷時保留部分回應、修正 WSL2 滑鼠滾輪捲動(v2.1.172 的回歸問題)、修正曾讓大型樹狀 Linux 工作階段無法使用的 sandbox denyRead glob、去除歡迎畫面促銷內容重複,並改善 remote/plugin 可靠性。v2.1.177:僅為 CHANGELOG/feed.xml 維護。v2.1.179 是最新版本。 |
173 |
| 2026-06-15 | 指南 v2.58:CLI v2.1.174–v2.1.176(皆為 6月12日)。v2.1.174:wheelScrollAccelerationEnabled設定(停用全螢幕中的滑鼠滾輪捲動加速度);/model選擇器會將 Default 解析到的系列顯示為獨立列(Max/Team Premium/Enterprise/PAYG-API 為 Opus,Pro/Team 為 Sonnet);VSCode /usage新增歸因(cache misses、long context、subagents,以及 24h/7d 內依 skill/agent/plugin/MCP 區分);修正 Bedrock GovCloud inference-profile 前綴、background-session provider-env 繼承、git co-author 模型名稱,以及企業 usage-billing 帳戶上的 Fable 5「consuming usage credits」橫幅。v2.1.175:enforceAvailableModels受管設定——availableModels允許清單也會限制 Default 模型(退回第一個允許的模型),且 user/project settings 不再能擴大受管清單。v2.1.176:session titles 會以對話的語言產生(可透過language設定釘選);新增footerLinksRegexes設定,用於以 regex 比對 footer link badges;hook if條件現在會比對Read/Edit/Write路徑模式(例如Edit(src/**)、Read(.env));availableModels強制執行會補上 alias-redirect 缺口,且/fast會拒絕允許清單外的模型;Bedrock credentials 會快取至其Expiration;對於沒有 Opus 4.8 的組織,auto mode 會從 Fable 5 退回最佳可用 Opus;另外還有大量 Remote Control、background-session、claude agents、/cd git-branch,以及 tmux-over-SSH 剪貼簿修正。v2.1.176 是最新版本。 |
172 |
| 2026-06-11 | 指南 v2.57:CLI v2.1.173。Fable 5 [1m]後綴自動正規化——claude-fable-5[1m]模型名稱現在會自動正規化/移除為claude-fable-5,因為 Fable 5 預設已包含 1M context,而該後綴原本只對 Opus/Sonnet 有意義(它們將 1M 放在[1m]後方管制)。另修正 Windows 啟動時誤顯「sandbox dependencies missing」警告。 |
171 |
| 2026-06-10 | 指南 v2.57:CLI v2.1.172。遞迴 sub-agents——sub-agents 現在可以產生自己的 sub-agents,最多可達5層深度(遞迴委派)。Bedrock region 來自~/.aws——當AWS_REGION未設定時,會從~/.aws讀取 AWS region,且/status會顯示解析出的來源。Plugin marketplace search——/plugin在 marketplace 新增搜尋列。OTEL——claude_code.lines_of_code.count指標新增model屬性。修正項目:沒有 credits 的 1M context 卡住工作階段、影像處理錯誤、background sub-agent 卡住狀態、model picker/restrictions,以及 team-memory recall。 |
171 |
| 2026-06-10 | 指南 v2.56.1:來自model-config docs的Claude Code專屬 Fable 5 細節。簡短的/model fable別名(以及best=可用時為 Fable,否則為最新 Opus)是文件記載的選擇器;Fable 5 支援完整low–max effort尺度(預設high);Fable 5 無法停用 thinking(session toggle、alwaysThinkingEnabled與MAX_THINKING_TOKENS=0都不會生效——它一律自適應推理);claude-fable-5[1m]延伸 context 變體,以及ANTHROPIC_DEFAULT_FABLE_MODEL/DISABLE_PROMPT_CACHING_FABLE設定旋鈕,補齊fable系列。沒有新版本(v2.1.170 仍為最新)。 |
174 |
| 2026-06-09 | 指南 v2.56:CLI v2.1.170。Claude Fable 5——新的模型層級,位於Opus 之上(Anthropic最強大、最聰明的模型;「Mythos-class」前沿能力,已調整為可安全供一般使用)——在claude update後,可透過/model claude-fable-5於Claude Code中選取。模型 ID claude-fable-5;1M context、128K output;每 MTok $10/$50(約為 Opus 4.8 的 2 倍);安全分類器在 cyber/bio-chem/distillation 查詢時會退回 Opus 4.8;訂閱方案於 6月22日前陸續推出。其 request surface 與 Opus 4.8 相同(僅 adaptive thinking),並有一項新的破壞性變更:明確的thinking: {type: "disabled"}會回傳 400——請改為省略該參數。Opus 4.8 仍是Claude Code的 agentic default。另有錯誤修正:從 VS Code 整合式終端機(或任何繼承Claude Code環境變數的 shell)啟動的工作階段無法儲存 transcripts,且不會出現在--resume中。驗證:GitHub release v2.1.170(6月9日 17:23Z)以及 code.claude.com/docs/en/changelog 的 canonical changelog;Fable 5 規格已與 anthropic.com/news 和claude-api model catalog 交叉核對。 |
174 |
| 2026-06-08 | 指南 v2.55:CLI v2.1.169。--safe-mode旗標(以及CLAUDE_CODE_SAFE_MODE環境變數)會啟動一個停用所有自訂項目的工作階段——CLAUDE.md、plugins、skills、hooks、MCP servers——便於無污染疑難排解。/cd可將工作階段移至新的工作目錄,而不會在工作階段中途破壞 prompt cache。disableBundledSkills設定(以及CLAUDE_CODE_DISABLE_BUNDLED_SKILLS)會對模型隱藏 bundled skills、workflows,以及內建 slash commands。另有約 20 項修正:Up/Down 方向鍵可在換行後的視覺列間導覽;企業MCP政策(allowedMcpServers/deniedMcpServers)會在重新連線與 IDE 輸入的設定上強制執行;使用 claude.ai credentials 時 macOS UI 會停頓 30–50ms;Windows 上的claude -p效能;Remote Control 重新連線;Windows 上的 Git Credential Manager 彈出視窗;自訂 statusline 的 footer hints;remote sessions 上過時的 permission/dialog prompts 重新出現;claude agents --json漏列 blocked sessions;TaskCreate input 自動修復;降低串流 CPU;恢復 Vertex/Foundry 的 5 分鐘 idle timeout;skill-tag 色彩對比;background-session 旗標在 retire→wake 之間保留。驗證:code.claude.com/docs/en/changelog 的 canonical changelog 與GitHub releases 確認 v2.1.169(6月8日)為最新。 |
175 |
| 2026-06-06 | 指南 v2.54:CLI v2.1.166–v2.1.168。v2.1.166:Fallback model chain——fallbackModel設定可設定最多 3 個 fallback models,當主要模型過載或不可用時依序嘗試,且--fallback-model現在也適用於互動式工作階段(不只限於工作階段中途);當API回傳非預期且不可重試的錯誤時,Claude Code也會在 fallback model 上重試該回合一次。MCP deny globs——deny rule 工具名稱位置中的 glob("*"會拒絕所有工具)讓您可以先全部封鎖再逐項允許;allow rules 會拒絕非MCP globs,以維持預設姿態偏向限制。安全性——透過SendMessage從其他Claude sessions 轉送的訊息不再帶有使用者權限(cross-session messaging 強化)。Thinking control——MAX_THINKING_TOKENS=0、--thinking disabled與逐模型 thinking toggle,現在會在預設會思考的模型上確實停用 thinking。UX——claude update會在下載前公告目標版本。另修正影像處理、remote-session 穩定性,以及終端機繪製(JetBrains IDEs、WezTerm/Ghostty 鍵盤)。v2.1.167 與 v2.1.168(皆為 6月6日):僅錯誤修正與可靠性改善,沒有個別記載的使用者可見變更。驗證:code.claude.com/docs/en/changelog 的 canonical changelog 與GitHub releases 確認 v2.1.168(6月6日)為最新。 |
176 |
| 2026-06-05 | 指南 v2.53.1:CLI v2.1.165(6月5日)推出錯誤修正與可靠性改善,沒有個別記錄的使用者可見變更(未發布 v2.1.164)。此為僅供 changelog 版本列連續性的項目;依據canonical changelog,指南內容已更新至 v2.1.165。 | 177 |
| 2026-06-04 | 指南 v2.53:CLI v2.1.163(v2.1.161/162 未發布;changelog 從 160 跳到 163)。Hooks:Stop 與 SubagentStop hooks 現在可以回傳 hookSpecificOutput.additionalContext,把回饋交給 Claude,並讓該回合繼續進行,而不會將回應標示為 hook 錯誤;這比封鎖/核准二元選項更溫和,適合作為導引通道。企業版本釘選:新的 requiredMinimumVersion 與 requiredMaximumVersion 受管理設定,會讓 Claude Code 在版本超出允許範圍時拒絕啟動,並引導使用者改用核准版本。Plugins:/plugin list 可列出已安裝 plugins,並支援 --enabled/--disabled 篩選。Skills:\$ escape 會在命令主體中,於數字前包含字面 $。MCP:stdio 伺服器在 --resume 時會收到與 hooks/Bash 相同的 CLAUDE_CODE_SESSION_ID。UX:/btw 新增「c to copy」原始 markdown 捷徑;/ 選單描述更清楚;訂閱切換建議移至啟動公告位置。另有約 17 項修正:當背景命令永不結束時,claude -p 不再卡住(stdin 關閉後,背景 shell 會在最終結果約 5 秒後停止);Bedrock/Vertex/Foundry 上的 claude -p 在 CI=true 下不再要求 ANTHROPIC_API_KEY;$TMPDIR override 重新限縮為僅適用於沙箱命令(修正 2.1.154 中導致 bazel/受 EDR 保護的 Go 中斷的回歸);修正 Windows session-env 在 OneDrive/唯讀環境下的 EEXIST;組織管理的權限規則在新 config 目錄中延遲套用;背景 sessions 在更新期間持續保留執行中工作(並在背景更新,以避免冷啟動重啟);agent-view Esc 卡住;貼上結束標記造成輸入鎖死;hook if: "Bash(...)" patterns 現在會比對 subshell/backticks 內部,而不是對每個 $() 觸發;針對 ~ 路徑的 deny rules 現在會封鎖 $HOME 參照;移除零星的「(no content)」transcript 行。驗證:code.claude.com/docs/en/changelog 的 canonical changelog 確認 v2.1.163(6月4日)為最新版本。 |
177 |
| 2026-06-02 | 指南 v2.52:CLI v2.1.160。安全性 — 編輯轉為執行的控管:acceptEdits 現在會在寫入 shell 啟動檔(.zshenv、.zlogin、.bash_login)、~/.config/git/,以及授予程式碼執行能力的建置工具設定(.npmrc、.yarnrc*、bunfig.toml、.bazelrc、.pre-commit-config.yaml、.devcontainer/ 等)前先提示;這將既有 .claude//.git//.vscode/ 寫入保護,擴展到更廣泛的檔案類型,避免一次編輯把下一次 shell/install/commit 變成執行向量。工作流程關鍵字重新命名:dynamic-workflow 觸發關鍵字從 workflow 改為 ultracode(在提示輸入中以紫色醒目顯示);「workflow」一詞不再觸發執行,不過用自己的話要求工作流程仍可運作。編輯易用性:單一檔案的 grep/egrep/fgrep 現在可滿足編輯前讀取檢查,因此透過 grep 檢視檔案後,Edit 不再要求另行 Read。已移除:CLAUDE_CODE_OPUS_4_6_FAST_MODE_OVERRIDE 現在不再作用(已完全移除);啟動時不再出現 JetBrains plugin 安裝建議。另有約 25 項修正:WSL 透過 PowerShell interop 支援選取即複製(不是 OSC 52)、claude agents session 還原時遺失聊天記錄/重新執行原始提示、隔夜淘汰的背景 sessions 遺失對話、claude --bg「socket missing」冷啟動競態、Windows 背景 session 在負載下輸入無回應、Apple Terminal/tmux 上的 terminal sync-output artifacts、claude agents 中 CJK IME 游標位置、Windows 上 file:///C:/... 連結重寫、含非 ASCII 專案/分支名稱的 voice mode、Bedrock/Vertex/Foundry 上 auto-mode-unavailable 訊息現在會正確指向 CLAUDE_CODE_ENABLE_AUTO_MODE、/effort ultracode 不再提供給無法執行 xhigh 的模型,以及背景 session teardown 時先 SIGTERM 再 SIGKILL,讓清理 handlers 能執行。驗證:GitHub 最新 release v2.1.160 於 2026-06-02 發布;changelog 位於 code.claude.com/docs/en/changelog。 |
178 |
| 2026-05-31 | 指南 v2.51:CLI v2.1.155–v2.1.159。v2.1.155 / v2.1.156(5月29日):修正 Opus 4.8 thinking-block mutation,該問題會以 API 錯誤形式浮現。v2.1.157(5月29日):放在專案 .claude/skills/ 目錄中的 plugins 現在無須 marketplace 即可自動載入;claude plugin init <name> 會在該處 scaffold 新 plugin;/plugin 引數新增 autocomplete;EnterWorktree 現在可在 session 期間切換 Claude 管理的 worktrees;agent 完成後,背景 worktrees 會維持解鎖,讓 git worktree remove/prune 能順利運作;當 OTEL_LOG_TOOL_DETAILS=1 時,tool_decision telemetry events 會包含 tool_parameters;另修正無法處理的圖片導致 requests 當機(現在會降級為文字 placeholders)、desktop/IDE/SDK 上 auto/bypass mode 的沙箱網路權限提示、停放的 subagents 導致背景 sessions 未退役、agents 清單中緩慢的「opening…」無法以 Esc 取消、30 天 job retention 清理後留下孤立背景 worktrees、--resume 未回報執行中的背景 subagents、terminal rendering 與 clipboard 修正(tmux、VS Code、Cursor、Windsurf)、WSL 圖片貼上/Windows 11 螢幕截圖貼上/Windows Explorer 拖曳、長篇 resumed conversations 的效能,以及 /terminal-setup 在整合式 terminal 中停用 GPU acceleration,以避免文字亂碼。v2.1.158(5月30日):Auto mode 現在可在 Bedrock、Vertex 與 Foundry 上,透過 CLAUDE_CODE_ENABLE_AUTO_MODE=1 對 Opus 4.7 和 Opus 4.8 選擇啟用;這補上權限模式文件中最後一個「僅限 API-direct」缺口。v2.1.159(5月31日):僅為內部基礎架構,沒有使用者可見變更。驗證:GitHub 最新 release v2.1.159 於 2026-05-31 發布;changelog 位於 code.claude.com/docs/en/changelog。 |
179 |
| 2026-05-28 | Guide v2.50:CLI v2.1.151–v2.1.154。v2.1.151(5月23日):僅限內部基礎架構,沒有面向使用者的變更。v2.1.152(5月27日):/code-review --fix會將審查發現套用到工作樹(重用、簡化、效率、層次);/simplify會呼叫/code-review --fix;skills與slash commands可在frontmatter中設定disallowed-tools,於skill啟用期間移除工具;新增/reload-skills命令,可在不重新啟動的情況下重新掃描skill目錄;SessionStart hooks可回傳reloadSkills: true並設定hookSpecificOutput.sessionTitle;新增MessageDisplay hook事件,可在顯示時轉換或隱藏assistant文字;新增pluginSuggestionMarketplaces受管理設定,可將組織marketplaces加入允許清單,以提供情境感知建議;claude plugin marketplace remove --scope user|project|local;當主要模型找不到時,CLI會在本次session剩餘期間切換到--fallback-model;auto mode不再需要選擇加入同意;vim NORMAL /會開啟反向歷史搜尋;/usage明細透過串流讀取加入大型session檔案;thinking摘要上限為10行,並以markdown呈現;OTEL app.entrypoint屬性;另有約16項錯誤修正,涵蓋style-pool記憶體、focus-mode隱藏計數器、markdown表格邊框、具有不同環境變數的plugin MCP伺服器去重、plugin git-branch更新追蹤、透過egress proxy的遠端MCP,以及effort-change對話方塊邊界情境。v2.1.153(5月28日):github/git plugin marketplace來源新增skipLfs選項,可略過Git LFS;npm global無法自動更新時顯示一次性通知(附/doctor修正清單);status-line命令會收到COLUMNS與LINES環境變數;claude agents dispatch自動完成會建議原生slash commands與內建skills;PR欄位顯示PR #N或N PRs;/doctor顯示上次更新結果;合併MCP/connector驗證通知;macOS背景agents會在「隱私權與安全性」中顯示為「Claude Code」,並保留持久授權;/model會將選取項目儲存為新session預設值(與IDE一致),s僅切換目前session的模型(以modelPicker:thisSessionOnly取代d鍵綁定modelPicker:setAsDefault);另有25項以上修正,涵蓋有狀態MCP tools/list重新連線迴圈、自訂gateway OAuth認證外洩、subagent frontmatter MCP伺服器遵循--strict-mcp-config/--bare/remote/managed政策、Windows PowerShell安裝程式誤報成功、claude update對npm遵循release channels、transcript-resume記憶體成長、binary takeover後daemon過期、stream-json stdin-close卡住、格式錯誤的file://連結呈現、claude --help窄終端換行、摺疊視圖中的MCP進度通知、subagent subagent_type: 'claude'未記錄worktree遺失gitignored輸出、/bg回應中續接、背景中的/btw捷徑、$CLAUDE_JOB_DIR暫存檔提示、已刪除workdir錯誤清晰度、EnterWorktree即時性、cmd+k重新繪製、Windows IME定位、256色attach滲出、tmux+背景中的/copy、/agents上的Remote Control殭屍項目、/rename橫幅重新整理、Windows更新回復、VSCode非正常結束回報。v2.1.154(5月28日):Opus 4.8預設啟用,且預設為high effort;新增/effort xhigh層級,供最困難任務使用;dynamic workflows可透過/workflows在背景協調數十到數百個agents;Opus 4.8上的Fast mode以2×標準費率換取2.5×速度;lean system prompt現在成為所有模型的預設值,但Haiku、Sonnet與Opus 4.7及更早版本除外;Claude僅在真正無法決定的情況保留多選提示;/simplify恢復為僅清理的審查(不再呼叫/code-review --fix的錯誤搜尋流程);/effort滑桿標籤由「Speed」/「Intelligence」改為「Faster」/「Smarter」;claude agents支援! <command>,可將shell命令作為可分離背景session執行(也支援claude --bg --exec '<command>');claude agents中的/logout會登出,而不是路由到背景session;←← agents檢視可在Bedrock/Vertex/Foundry上運作,也支援停用telemetry;Claude可透過/chrome →「Select browser…」在Chrome多瀏覽器選擇中使用;plugins可在plugin.json或marketplace項目中宣告defaultEnabled: false;/plugin Discover分頁會釘選與目前目錄相符的plugins,並標示「suggested for this directory」;串流工具執行一律啟用(包含停用telemetry以及Bedrock/Vertex/Foundry);stdio MCP子程序會收到CLAUDE_CODE_SESSION_ID與CLAUDECODE=1環境變數;claude mcp list/get會將未核准的.mcp.json伺服器顯示為⏸ Pending approval,而非自動連線;/remote-control自動完成會在啟用時顯示「Disconnect Remote Control」;/claude-api skill中加入Opus 4.8支援與4.7→4.8遷移;已棄用CLAUDE_CODE_OPUS_4_6_FAST_MODE_OVERRIDE(6月1日移除,請改用/model claude-opus-4-6[1m]再執行/fast on);改善auto mode中大量repo傳輸的資料外洩偵測;另修正帶有結尾斜線的rm -rf $HOME、sandboxed與unsandboxed下$TMPDIR一致性、claude agents列對比、背景session「out of context」精確度、排程/command目標保留、釘選session升級後重生抖動、卡住狀態淘汰、subagent worktree隔離繞過、孤立claude --bg-pty-host 100% CPU、分隔線下方數字鍵捷徑、連結worktrees內worktree.baseRef: "head"的HEAD解析、換行前導空格、VSCode thinking-spinner顏色閃爍、plan檔名中的[Image #N]預留位置、幽靈展開提示、單一不良項目導致managed-MCP捨棄、effort-param 400s、Windows使用中更新錯誤、VSCode auto mode選擇器、task-panel「main」列、/mcp tools長名稱、fast-mode價格顯示、auto-mode token耗盡。驗證:GitHub最新release v2.1.154於2026-05-28發布;changelog位於code.claude.com/docs/en/changelog。 |
180 |
| 2026-05-24 | Guide v2.49:CLI v2.1.148-v2.1.150。v2.1.148:修正Bash工具迴歸問題;部分使用者每次執行命令都會看到exit code 127。v2.1.149:/usage現在會依類別拆解限制用量(skills、subagents、plugins,以及每個MCP伺服器成本);/diff詳細檢視支援鍵盤捲動;Markdown會呈現GFM工作清單核取方塊;Enterprise新增allowAllClaudeAiMcps;修正內容涵蓋PowerShell cd權限繞過、git-worktree sandbox寫入允許清單範圍、PowerShell prefix/wildcard與過期變數權限分析、Bash find耗盡macOS檔案/vnode表、managed-settings啟動凍結、/ultraplan/遠端session無變更擷取失敗、含空格的otelHeadersHelper路徑、來自skill/agent frontmatter的status-bar effort、Ctrl+O transcript tailing、/insights、Remote Control session重新命名同步,以及壓縮前的/feedback情境。v2.1.150:僅限內部基礎架構改進,未公布面向使用者的變更。本輪本機驗證:本機claude --version回傳2.1.144 (Claude Code),而npm @anthropic-ai/claude-code最新版本為2.1.150,time.modified為2026-05-23T04:03:10.243Z;GitHub最新release為v2.1.150,發布時間2026-05-23T04:03:51Z。 |
170 |
| 2026-05-21 | Guide v2.48:CLI v2.1.147。Workflow與review:新增預設關閉的Workflow工具,可透過CLAUDE_CODE_WORKFLOWS=1進行確定性的multi-agent協調;/simplify現在是/code-review [effort],專注於正確性錯誤,並提供--comment用於行內GitHub PR註解。Agent View與背景工作:釘選的背景sessions在閒置時會保持存活、原地重新啟動以套用更新,且只有在非釘選sessions之後,才會因記憶體壓力而被釋放。安全性與可靠性:REPL與Workflow sandboxes已加固,以防範prototype-pollution與thenable escapes;auto-updater失敗會回報類別/OS錯誤碼並顯示目前版本;大型diff呈現速度更快;prompt歷史會對連續重複項目去重;並修正企業登入限制、PowerShell輸出/規則、MCP resource/template/prompt分頁、hook if比對、貼上文字傳遞、Agent View CJK列、plugin元件計數、slash-command解析,以及剝除圖片迴圈。本輪本機驗證:本機claude --version回傳2.1.144 (Claude Code),而npm @anthropic-ai/claude-code最新版本為2.1.147,time.modified為2026-05-21T20:38:35.053Z。 |
169 |
| 2026-05-19 | Guide v2.47:CLI v2.1.145。Agent View 與指令碼:claude agents --json會將即時工作階段列為JSON,便於指令碼使用;Agent View 分頁標題會顯示等待輸入的數量;回覆窗格中的語音按住說話已修正;全螢幕 slash-command / @-mention 建議支援滑鼠懸停與點擊。可觀測性與 hooks:claude_code.tool OTEL spans 包含agent_id與parent_agent_id;背景 subagent spans 會歸屬於派送的 Agent tool span;狀態列JSON包含偵測到的GitHub repo 與 PR 資訊;Stop/SubagentStop hook 輸入現在包含background_tasks與session_crons。Plugins 與安全性:安裝前 plugin 畫面會顯示 commands、agents、skills、hooks,以及MCP/LSP 伺服器;未列入 allowlist 的裸 Bash 環境變數指派不再繞過權限提示;skill context: fork自我呼叫迴圈已修正;當整個檔案讀取超過 token 限制時,Read tool 會傳回截斷的部分檢視,而不是直接失敗。本次本機驗證:本機claude --version回傳2.1.144 (Claude Code),而 npm @anthropic-ai/claude-code最新版本為2.1.145,time.modified為2026-05-19T22:20:44.083Z。 |
168 |
| 2026-05-19 | Guide v2.46:CLI v2.1.144。背景工作階段:/resume現在包含透過claude --bg或 Agent View 啟動的工作階段,並以bg標示;背景 subagent 完成通知包含經過時間;/bg與 detach 會保留已加入的目錄。模型與用量 UX:/model現在只會變更目前工作階段,除非按下d設定預設值;/extra-usage重新命名為/usage-credits,舊指令保留為 alias。Plugins 與診斷:plugin 瀏覽/探索窗格會顯示最後更新日期;/doctor會針對缺少command的 command hooks 顯示 exec-form 範例;skill 清單截斷已移出啟動通知。可靠性:當api.anthropic.com無法連線時,啟動 side-channel 呼叫會更快逾時;終端機顯示毀損現在會自動修復;修正 macOS 在受 Full Disk Access 保護的資料夾下啟動背景工作階段的問題;MCP分頁tools/list回應不再被截斷;不支援的MCP圖片 MIME 類型會安全降級;並修正多項 Agent View/背景工作階段互動錯誤。本次本機驗證:claude --version回傳2.1.144 (Claude Code),npm @anthropic-ai/claude-code最新版本為2.1.144,time.modified為2026-05-19T17:40:52.832Z。 |
167 |
| 2026-05-18 | Guide v2.45:CLI v2.1.143。Plugins:相依性強制檢查會防止停用其他已啟用 plugin 所依賴的 plugin;啟用時則會強制啟用傳遞相依項。plugin marketplace 瀏覽窗格現在會顯示預估 context 成本。Worktrees/背景工作階段:worktree.bgIsolation: "none"讓背景工作階段可直接編輯工作副本,適用於不適合使用 worktrees 的 repos;背景工作階段從閒置喚醒後會保留模型/effort。Windows/PowerShell:PowerShell 現在會傳遞-ExecutionPolicy Bypass;CLAUDE_CODE_POWERSHELL_RESPECT_EXECUTION_POLICY=1可退出此行為;除非設定CLAUDE_CODE_USE_POWERSHELL_TOOL=0,否則 Bedrock、Vertex 與 Foundry 使用者預設會啟用 PowerShell tool。可靠性:反覆封鎖的 stop hooks 現在會限制為連續 8 次封鎖,除非以CLAUDE_CODE_STOP_HOOK_BLOCK_CAP覆寫;當背景 shells 或委派的 subagents 仍在執行時,/goal evaluator 不再觸發;claude agents派送 flags 現在會從 dashboard 與背景工作階段一致套用。本次本機驗證:claude --version回傳2.1.142 (Claude Code),而 npm @anthropic-ai/claude-code最新版本為2.1.143,time.modified為2026-05-18T19:57:55.006Z。 |
166 |
| 2026-05-15 | Guide v2.44:CLI v2.1.142。Agent View:claude agents可使用--add-dir、--settings、--mcp-config、--plugin-dir、--permission-mode、--model、--effort與--dangerously-skip-permissions設定派送的背景工作階段。Fast mode:Fast mode 現在預設為 Opus 4.7;設定CLAUDE_CODE_OPUS_4_6_FAST_MODE_OVERRIDE=1可固定使用舊的 Opus 4.6 預設值。Plugins:沒有skills/目錄的根層級 plugin SKILL.md檔案現在會顯示為 skills;plugin 詳細資料會顯示 LSP 伺服器;plugin 快取清理會避免刪除作用中版本;skills: ["./"]不再誤報 escape 錯誤。可靠性:修正範圍包括遠端 HTTP/SSE MCP伺服器上的MCP_TOOL_TIMEOUT、背景工作階段中的既有 git worktrees、daemon 睡眠/喚醒與升級後清理、Chrome extension 背景 agent 當機、Agent View 編輯器/連結處理、Windows 網路磁碟機啟動死結,以及多餘的遠端 client /model breadcrumbs。本次本機驗證:claude --version回傳2.1.141 (Claude Code),而 npm @anthropic-ai/claude-code最新版本為2.1.142,time.modified為2026-05-14T22:54:49.491Z。 |
165 |
| 2026-05-14 | Guide v2.43:CLI v2.1.141。Hooks:hook JSON輸出中的terminalSequence讓 hooks 可送出終端機控制序列,用於桌面通知、視窗標題與提示鈴聲,無需控制終端機。Plugins:在沒有GitHub SSH keys 的環境中,CLAUDE_CODE_PLUGIN_PREFER_HTTPS會透過HTTPS而非SSH複製GitHub plugin sources。企業驗證:當 federation rule 涵蓋多個 workspace 時,ANTHROPIC_WORKSPACE_ID會將 workload-identity-federated tokens 限定於特定 workspace。Agent View:claude agents --cwd <path>會將工作階段清單篩選為單一目錄。意見回饋:/feedback可納入過去 24 小時或 7 天內的近期工作階段,適用於跨越目前工作階段的問題。本次本機驗證:claude --version回傳2.1.141 (Claude Code);npm @anthropic-ai/claude-code最新版本為2.1.141。 |
164 |
| 2026-05-13 | Guide v2.42:CLI v2.1.139 + v2.1.140。v2.1.139:透過claude agents新增 Agent View,並新增/goal、command-hook args: string[]、PostToolUse的continueOnBlock、供MCP stdio 伺服器與 plugin command interpolation 使用的CLAUDE_PROJECT_DIR,並修正--print模式中的claude_code.active_time.total OTel 發送。v2.1.140:在 agent hook 輸入中加入subagent_type,並修正ConfigChange hooks、disableAllHooks、allowManagedHooksOnly、權限對話框中非預期顯示 hook-result env-var、settings-sync 樣式重設、Windows Git Bash 上的 native-package fallback,以及/scroll-speed。本次本機驗證:claude --version回傳2.1.140 (Claude Code)。 |
162 163 |
| 2026-05-09 | Guide v2.41:CLI v2.1.137 + v2.1.138 patch bump。VSCode(Windows):v2.1.137 修正 VSCode extension 在 Windows 上無法啟用的問題。v2.1.138:發布內部修正(release notes 未公布新增 command/config)。沒有新的 commands、settings 或 env vars。 | 162 |
| 2026-05-08 | Guide v2.40:CLI v2.1.133 + 5月7日 Microsoft 365 GA。重大預設變更 — worktree.baseRef:新的fresh預設值會讓--worktree、EnterWorktree與 agent-isolation worktrees 再次從origin/<default>建立分支,回復 v2.1.128 改為本機HEAD的變更。設定worktree.baseRef: "head"可在新 worktrees 中保留尚未 push 的 commits。Effort plumbing:hooks 現在會收到effort.level JSON與$CLAUDE_EFFORT;Bash tool subprocess 會繼承$CLAUDE_EFFORT。Sandbox managed settings:sandbox.bwrapPath與sandbox.socatPath(Linux/WSL)指向自訂 bubblewrap 與 socat binaries。Admin tier:parentSettingsBehavior('first-wins' \| 'merge')會讓SDK managedSettings加入 policy merge。Subagents:修正 subagents 無法透過Skill tool 發現 project、user 或 plugin skills 的問題。v2.1.133 也解決 refresh-token rotation 後的平行工作階段 401 競態、drive-root allow-rule 範圍、MCP OAuth proxy/mTLS、Remote Control stop/interrupt 完成 cancel、跨工作階段/effort外洩,並在--help列出--remote-control。Microsoft 365(5月7日):Excel、PowerPoint 與 Word 的Claude已在付費方案正式推出;Outlook 的Claude則對所有付費方案開放 public beta。 |
160 161 |
| 2026-05-07 | Guide v2.39:CLI v2.1.132。TUI:CLAUDE_CODE_DISABLE_ALTERNATE_SCREEN=1可退出全螢幕替代畫面渲染器,讓對話保留在原生捲動緩衝區;/tui fullscreen啟動橫幅已更新,強調較低記憶體用量、滑鼠支援,以及選取時自動複製。Bash子程序:CLAUDE_CODE_SESSION_ID環境變數會符合傳給hooks的session_id。另有20多項小修正,涵蓋SIGINT優雅關閉、--resume上的代理emoji毀損、plan模式--permission-mode旗標處理、Indic/ZWJ游標與NFD vim操作、貼上內容以/開頭時被吞掉、MCP無限制記憶體成長與tools/list重試、Bedrock+Vertex ENABLE_PROMPT_CACHING_1H 400錯誤,以及statusline context_window顯示累計而非目前token。 |
159 |
| 2026-05-06 | Guide v2.38:Code with Claude SF 2026當日新增內容。新增5月6日容量公告:Pro、Max、Team與按席位計費Enterprise方案的Claude Code 5小時速率限制加倍;Pro與Max移除尖峰時段降額;Claude Opus模型的API速率限制「大幅」提高。其背後由SpaceX Colossus 1運算合作支撐(「本月內新增超過300百萬瓦容量(超過220,000張NVIDIA GPU)」)。新增5月5日金融垂直化內容:10個可立即執行的agent範本(pitch builder、earnings reviewer、KYC screener、month-end closer,以及另外6個)以plugins形式隨Cowork與Claude Code推出,另有Managed Agents cookbook;Excel、PowerPoint與Word的Microsoft 365 add-ins已推出;資料connector來自Dun & Bradstreet、Fiscal AI、Financial Modeling Prep、Guidepoint、IBISWorld、SS&C IntraLinks、Third Bridge與Verisk;Moody’s MCP app可涵蓋超過6億家公司;Cowork Dispatch支援語音/文字任務指派。 | 157 158 |
| 2026-05-06 | Guide v2.37:CLI v2.1.131最新版本線差異。NPM latest為2.1.131,GitHub最新release為v2.1.131;本次檢查的本機已安裝CLI仍為2.1.126。v2.1.131是修正release,處理VS Code Windows extension啟用與Mantle endpoint驗證,release notes未公布新的command/config新增項目。涵蓋至v2.1.131。 | 156 |
| 2026-05-05 | Guide v2.36:CLI v2.1.126–v2.1.129。最新release線:NPM latest為2.1.129,GitHub最新release為v2.1.129;本次檢查的本機已安裝CLI為2.1.126。Plugins:--plugin-url <url>會為目前session載入plugin zip;--plugin-dir接受zip封存檔;plugin manifest中的themes與monitors應移至"experimental"之下,否則claude plugin validate會警告。Skills:skillOverrides現在可搭配off、user-invocable-only與name-only。Gateways:/model選擇器的/v1/models探索在2.1.126–2.1.128曾為自動,現在改為透過CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY=1選擇啟用。更新/終端機:CLAUDE_CODE_PACKAGE_MANAGER_AUTO_UPDATE讓Homebrew/WinGet安裝可在背景升級並提示重新啟動;CLAUDE_CODE_FORCE_SYNC_OUTPUT=1會為自動偵測漏判的終端機強制使用同步輸出。安全/權限:v2.1.126將--dangerously-skip-permissions改為繞過寫入.claude/、.git/、.vscode/與shell config檔案的提示,同時保留災難性移除提示作為安全防線。修正:2.1.128–2.1.129修復了plugin狀態污染、MCP引數毀損、1小時prompt-cache TTL降級、/context ASCII-grid transcript膨脹、外部編輯器空白化、OAuth/server-managed-settings回歸,以及多項全螢幕/history/session UI問題。 |
156 |
| 2026-04-29 | CLI v2.1.123:修正設定CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1時,OAuth驗證會因401重試迴圈而失敗的問題。 |
155 |
| 2026-04-28 | Guide v2.35:CLI v2.1.121 + v2.1.122。MCP:alwaysLoad: true伺服器config選項可讓伺服器退出tool-search延後載入;暫時性啟動錯誤會自動重試3次。Hooks:hookSpecificOutput.updatedToolOutput擴充至所有tools(原本僅限MCP)。Permissions:--dangerously-skip-permissions寫入.claude/skills/、.claude/agents/、.claude/commands/時不再提示。Plugins:claude plugin prune會移除孤立的自動安裝相依項;uninstall上的--prune會連帶清除。Slash commands:/skills新增輸入篩選;/resume接受PR URLs(GitHub、GHE、GitLab、Bitbucket)。Vertex AI:以X.509憑證為基礎的Workload Identity Federation(mTLS ADC)。Bedrock:ANTHROPIC_BEDROCK_SERVICE_TIER環境變數(default/flex/priority)。OTel:新的LLM-span屬性(stop_reason、gen_ai.response.finish_reasons、由OTEL_LOG_USER_PROMPTS控管的user_system_prompt);新的claude_code.at_mention事件;api_request/api_error上的數值屬性會以數字送出。SDK:mcp_authenticate新增redirectUri。另有MCP//mcp打磨、全螢幕捲動修正、claude.ai connector去重、tmux中/copy使用iTerm2剪貼簿、升級後啟動加速,以及數十項resume / memory / Bash / Bedrock / Vertex / scrollback修正(請見[^162])。 |
152 154 |
| 2026-04-24 | Guide v2.34:CLI v2.1.116–v2.1.119 + 4月23日品質事後檢討。/usage將/cost與/stats合併為單一對話框(兩個名稱仍保留為輸入捷徑)。Vim視覺模式:v(字元)與V(行),支援選取、operator與視覺回饋。Hooks現在可透過type: "mcp_tool"直接叫用MCP tools;PostToolUse/PostToolUseFailure hook輸入包含tool執行時間duration_ms。Auto Mode $defaults哨兵值會在autoMode.allow/soft_deny/environment中把自訂規則加入內建清單旁(而非取代它);選擇啟用提示新增「Don’t ask again」。PowerShell tool commands現在可在permission mode中自動核准(與Bash一致)。/config設定(theme、editor mode、verbose)現在會依完整project/local/policy優先序保存到~/.claude/settings.json。Themes現在具備名稱:可從/theme建立與切換、手動編輯~/.claude/themes/*.json,plugins可提供themes/資料夾。prUrlTemplate會將footer PR badge重新導向到自訂code-review URL;--from-pr現在接受GitLab MRs、Bitbucket PRs與GitHub Enterprise PRs。--print與--agent會遵守agent tools:/disallowedTools:/permissionMode frontmatter。原生macOS/Linux builds透過Bash tool以嵌入式bfs/ugrep取代Glob/Grep(更快,無須另一次往返)。Opus 4.7 context修正:sessions現在會根據原生1M window計算/context,而非錯誤的200K(不再過早autocompact)。預設effort變更:Sonnet 4.6與Opus 4.6上的Pro/Max現在預設為high(原為medium);Opus 4.7維持xhigh。新的環境變數:CLAUDE_CODE_HIDE_CWD(在啟動logo隱藏工作目錄)、DISABLE_UPDATES(封鎖所有更新路徑,包含手動claude update,比DISABLE_AUTOUPDATER更嚴格)、CLAUDE_CODE_FORK_SUBAGENT=1(外部builds上的forked subagents)、ENABLE_TOOL_SEARCH(Vertex AI選擇啟用)。新的managed-settings政策:wslInheritsWindowsSettings讓WSL繼承Windows端managed settings。cleanupPeriodDays保留期限清理現在也涵蓋~/.claude/tasks/、~/.claude/shell-snapshots/與~/.claude/backups/。Advisor Tool現在為experimental(標籤、了解更多連結,錯誤後不再卡住)。claude plugin tag會建立release git tags並進行版本驗證;blockedMarketplaces/strictKnownMarketplaces現在會在每個plugin install/update路徑強制執行,包含hostPattern/pathPattern。安全性:sandbox auto-allow不再對/、$HOME與其他關鍵系統根目錄上的rm/rmdir繞過危險路徑檢查。事後檢討(4月23日):Anthropic發布事後檢討,涵蓋4月20日前已解決的3項品質回歸:(1)reasoning effort預設值於3月4日至4月7日降為medium(已還原),(2)prompt cache thinking-clear bug於3月26日至4月10日發生(已於v2.1.101修正),(3)system-prompt verbosity限制於4月16日至20日發生(Opus 4.6 / Opus 4.7約3% coding品質下降;Sonnet 4.6下降較小;已於v2.1.116還原)。所有訂閱者的使用限制已於4月23日重設。另有數十項MCP/OAuth/keyboard/UI修正與OTel改進(tool_use_id、tool_input_size_bytes、status line中的effort.level/thinking.enabled)。 |
152 153 |
| 2026-04-18 | Guide v2.33:CLI v2.1.113 + v2.1.114。CLI 現在會透過各平台的選用相依套件產生原生 Claude Code binary,不再使用 bundled JavaScript。安全性:sandbox.network.deniedDomains 封鎖清單會覆寫 allowedDomains 萬用字元;Bash 拒絕規則會比對 env/sudo/watch/ionice/setsid 包裝器;Bash(find:*) 不再自動核准 -exec/-delete;macOS Bash(rm:*) 規則會將 /private/{etc,var,tmp,home} 視為危險目標。UX:全螢幕時可用 Shift+↑/Shift+↓ 在延伸選取範圍時捲動 viewport;目前邏輯行支援 readline 風格的 Ctrl+A/Ctrl+E;Windows Ctrl+Backspace 會刪除上一個字。Slash commands:/loop 可用 Esc 取消待處理的喚醒;/extra-usage 可從 Remote Control clients 使用;/ultrareview 透過平行化檢查、diffstat、動畫啟動狀態加快啟動。停滯的 subagents 會在 10 分鐘後以明確錯誤失敗。Opus 4.7 Bedrock 修正:透過 Application Inference Profile ARN 使用 extended thinking 時,不再回傳 thinking.type.enabled is not supported 400。v2.1.114 hotfix:修正 Agent Teams 隊友要求 tool permission 時的 permission-dialog 當機。 |
150 |
| 2026-04-16 | Guide v2.32:Claude Opus 4.7 發布——Max 與 Team Premium 方案立即改用新的預設模型;Enterprise 與 API 預定於 2026年4月23日切換;Pro 與 Team Standard 維持 Sonnet 4.6。1M context 採標準定價(Opus 4.7 無 long-context 加價)。最大輸出 128K。Messages API 重大變更:移除 extended thinking budget_tokens(僅保留 adaptive thinking)、temperature/top_p/top_k 非預設值會回傳 400、thinking content 預設省略(設定 display: "summarized" 可恢復)。新增 xhigh effort level;Claude Code 在 Opus 4.7 預設為 xhigh。Vision 最高支援 2,576 px / 3.75 MP,並採 1:1 pixel coordinates。CLI v2.1.105–v2.1.112:PreCompact hooks 可封鎖、/recap + Session Recap、/ultrareview、/less-permission-prompts、/tui//focus、/proactive(/loop 的 alias)、/undo(/rewind 的 alias)、透過 Remote Control 推送通知、Max 在 Opus 4.7 上支援 Auto Mode(無 --enable-auto-mode flag)、Windows PowerShell tool 推出(CLAUDE_CODE_USE_POWERSHELL_TOOL)、降低唯讀 Bash permission、ENABLE_PROMPT_CACHING_1H 環境變數、TRACEPARENT/TRACESTATE 分散式追蹤、用於除錯的 OTEL_LOG_RAW_API_BODIES。 |
144 145 146 |
| 2026-04-13 | Guide v2.31:CLI v2.1.98–v2.1.104。/team-onboarding command。Google Vertex AI 設定精靈。企業 TLS proxies 的 OS CA certificate trust。背景 scripts 的 monitor tool。跨使用者快取用的 --exclude-dynamic-system-prompt-sections。Perforce workflows 用的 CLAUDE_CODE_PERFORCE_MODE。多項 bash 安全性修正(backslash bypass、compound command bypass、/dev/tcp redirect blocking)。 |
142 143 |
| 2026-04-09 | Guide v2.30:CLI v2.1.97。修正 --dangerously-skip-permissions 在 protected path 寫入後無聲降級為 accept-edits 的問題。修正 MCP HTTP/SSE connections 重新連線時每小時洩漏約 50 MB 的問題。修正 429 重試在約 13 秒內耗盡所有嘗試次數的問題。NO_FLICKER mode 中的 focus view toggle(Ctrl+O)。refreshInterval status line 設定。Cedar policy 語法醒目提示。 |
141 |
| 2026-04-08 | Guide v2.29:CLI v2.1.94–v2.1.96。透過 Mantle 使用 Bedrock(CLAUDE_CODE_USE_MANTLE=1)。API/Bedrock/Vertex/Foundry/Team/Enterprise 的預設 effort level 從 medium 改為 high。UserPromptSubmit hooks 的 hookSpecificOutput.sessionTitle。v2.1.96 hotfix 修正 Bedrock auth regression。 |
140 |
| 2026-04-07 | Guide v2.28:新增 Claude Mythos Preview 與 Project Glasswing。這是超越 Opus 4.6 的新 frontier model,僅限 12 個防禦性安全合作夥伴使用。透過 Claude Code 在隔離容器中執行。已承諾投入 $100M credits。尚未正式公開供一般使用。 | 139 |
| 2026-04-06 | Guide v2.27:新增 /buddy terminal companion pet(18 個 species、5 個 rarity tiers,依 account ID 決定性產生)。已於 4月1日正式推出。 |
138 |
| 2026-04-04 | Guide v2.26:CLI v2.1.90–v2.1.92。/powerup 互動式課程。MCP _meta["anthropic/maxResultSizeChars"] 最高 500K。disableSkillShellExecution 設定。forceRemoteSettingsRefresh fail-closed 企業政策。互動式 Bedrock 設定精靈。依模型與 cache-hit 拆分的 /cost 明細。/release-notes 互動式選擇器。Plugin bin/ 可執行檔。Remote Control hostname prefix。移除 /tag 與 /vim。 |
135 136 137 |
| 2026-04-01 | Guide v2.25:新增 「Under the Hood」 章節,收錄與 harness builders 相關的 source leak findings:auto mode classifier internals(yoloClassifier.ts)、bash security 23-check model、prompt cache 架構(14 個 break vectors)、autocompact circuit breaker(修正每天 250K wasted calls)、coordinator mode 作為 prompt-driven orchestration、透過 regex 偵測 frustration。 | 133 134 |
| 2026-04-01 | CLI 2.1.89:PreToolUse hooks 的 "defer" permission decision(headless pause/resume 搭配 -p --resume)。MCP_CONNECTION_NONBLOCKING=true 會在 -p mode 跳過 MCP 等待。Autocompact thrash loop 偵測(連續 3 次 refills 後停止)。當 formatter/linter 修改先前已讀取的檔案時,Bash tool 會警告。支援 symlink-aware 的 Edit/Read allow rules。合併來自 v2.1.88 的 35+ bug fixes。 |
126 |
| 2026-03-31 | Guide v2.24:新增 v2.1.88 功能。PermissionDenied hook 會在 auto mode classifier 拒絕後觸發。CLAUDE_CODE_NO_FLICKER=1 alt-screen rendering。@ mention typeahead 支援命名 subagents。Thinking summaries 預設關閉(可用 showThinkingSummaries: true 恢復)。Auto mode denied commands 會出現在 /permissions Recent tab。/btw 可捲動 viewport。35+ bug fixes,包括 prompt cache misses、巢狀 CLAUDE.md 重複注入、StructuredOutput 50% failure rate、CJK/emoji history。新增 Boris Cherny tips 中的 /dream memory consolidation command。 |
127 128 |
| 2026-03-31 | CLI 2.1.88:PermissionDenied hook、CLAUDE_CODE_NO_FLICKER=1、@ typeahead 中的命名 subagents、thinking summaries 預設關閉、auto mode denied commands 顯示於 /permissions Recent tab、/env 套用到 PowerShell、/btw 可捲動 viewport。修正:prompt cache misses、巢狀 CLAUDE.md 重複注入(長 session 中可達數十次)、StructuredOutput 約 50% failure rate、Windows 上 Edit/Write CRLF 重複、JSON 大型 LRU cache memory leak、CJK/emoji prompt history、/stats 遺失歷史資料。35+ bug fixes。 |
127 |
| 2026-03-29 | CLI 2.1.86–2.1.87:用於 proxy aggregation 的 X-Claude-Code-Session-Id header。Read tool 的精簡行號格式可降低 token usage。Auto mode 顯示依方案而定的 unavailable 訊息。/skills 中 skill descriptions 上限 250 chars。@ file mentions 不再進行 JSON-escaped(降低 token overhead)。Jujutsu/Sapling VCS 目錄排除。15+ bug fixes,包括 pre-2.1.85 sessions 的 --resume、project root 外檔案的 Write/Edit、macOS/Linux 上的 plugin script permissions。 |
129 |
| 2026-03-27 | Guide v2.23:新增 v2.1.85 功能。Auto Mode——以 classifier 為基礎的 permission system,取代 --dangerously-skip-permissions,讓自主操作更安全。Sonnet 4.6 會在執行前檢閱每個動作,並搭配 auto-block list 與 circuit breaker。Hooks 支援使用 permission rule syntax 的條件式 if 欄位。PreToolUse hooks 現在可滿足 AskUserQuestion。MCP OAuth 遵循 RFC 9728。25+ bug fixes。 |
124 125 130 |
| 2026-03-27 | CLI 2.1.85:Hooks 的條件式 if 欄位、PreToolUse hooks 透過 updatedInput 滿足 AskUserQuestion、headersHelper scripts 的 MCP env vars、MCP OAuth RFC 9728、marketplace 會隱藏 organization-blocked plugins、/loop 與 CronCreate 的 timestamp markers、deep link queries 最高 5K chars、修正 oversized conversations 的 /compact、20+ bug fixes。 |
130 |
| 2026-03-26 | Guide v2.22:新增 v2.1.83 與 v2.1.84 功能。PowerShell tool(Windows,opt-in preview)。3 個新的 hook events:TaskCreated、CwdChanged、FileChanged(總計 25 個)。managed-settings.d/ drop-in 目錄,用於 team policy fragments。sandbox.failIfUnavailable 設定。CLAUDE_CODE_SUBPROCESS_ENV_SCRUB=1 會從 subprocesses 移除 credentials。Transcript search(Ctrl+O 中的 /)。initialPrompt agent frontmatter 可自動送出第一輪。Rules/skills paths: 接受 YAML glob lists。MCP tool descriptions 上限 2KB。Token counts 顯示為「1.5m」格式。閒置 75+ 分鐘後的 idle-return prompt。Stop-all-agents keybinding 從 Ctrl+F 改為 Ctrl+X Ctrl+K。TaskOutput 已 deprecated(請對 output file 使用 Read)。WorktreeCreate 支援 HTTP hook。兩個版本合計 50+ bug fixes。 |
123 131 |
| 2026-03-26 | CLI 2.1.84:PowerShell tool(Windows 選擇啟用)、TaskCreated hook、WorktreeCreate HTTP hook 支援、ANTHROPIC_DEFAULT_{OPUS,SONNET,HAIKU}_MODEL_SUPPORTS 環境變數、CLAUDE_STREAM_IDLE_TIMEOUT_MS、allowedChannelPlugins 受管理設定、rules/skills paths: YAML glob 清單、MCP 2KB 說明上限、閒置返回提示(75+ 分鐘)、deep links 會開啟偏好的終端機、token 計數採用「1.5m」格式、CJK IME 修正、25+ 項錯誤修正。 |
131 |
| 2026-03-25 | CLI 2.1.83:managed-settings.d/ drop-in 目錄、CwdChanged/FileChanged hook 事件、sandbox.failIfUnavailable、CLAUDE_CODE_SUBPROCESS_ENV_SCRUB=1、transcript 搜尋、initialPrompt agent frontmatter、Ctrl+X Ctrl+E 外部編輯器、stop-all-agents 從 Ctrl+F 改為 Ctrl+X Ctrl+K、TaskOutput 已棄用、35+ 項錯誤修正。 |
123 |
| 2026-03-21 | Guide v2.21:新增 v2.1.80 與 v2.1.81 功能。Claude Code Channels(研究預覽):透過 plugin-based channel servers,從 Telegram 或 Discord 將訊息傳送到執行中的 sessions。--bare flag 會略過 hooks、LSP、plugin 同步與 skill 目錄走訪,方便 scripted -p automation。--channels flag 會將 tool approval prompts 轉送至 channel servers。statusline scripts 可使用 rate_limits 欄位。source: 'settings' plugin marketplace source type。skills 支援 effort frontmatter。Assistant 會遵守「no memory」要求。修正 Git Bash 的 Windows PATH 繼承問題。 |
122 132 |
| 2026-03-20 | CLI 2.1.81:為 scripted -p calls 提供 --bare flag(略過 hooks、LSP、plugin 同步、skill walks)。為 channel servers 提供 --channels permission relay。Assistant 會遵守「no memory」要求。 |
132 |
| 2026-03-19 | CLI 2.1.80:statusline scripts 中的 rate_limits 欄位。source: 'settings' plugin marketplace source。skills 的 effort frontmatter。Claude Code Channels(研究預覽):透過 --channels flag,將 Telegram/Discord 訊息送入 sessions。修正 Git Bash 的 Windows PATH 繼承問題。 |
122 |
| 2026-03-19 | Guide v2.20:新增 v2.1.78 與 v2.1.79 功能。StopFailure hook 事件(總計 23 個)。Plugin 持久狀態(${CLAUDE_PLUGIN_DATA})。Agent frontmatter:plugin agents 可用 effort、maxTurns、disallowedTools。ANTHROPIC_CUSTOM_MODEL_OPTION 環境變數可用於自訂 /model 項目。逐行 response streaming。Tmux 通知 passthrough。claude auth login 的 --console flag。/remote-control VS Code command。VS Code 中的 AI-generated session titles。啟動記憶體減少約 18MB。安全性修正:sandbox dependencies 缺失時顯示可見警告。SessionEnd hooks 現在會在 /resume session switch 時觸發。20+ 項錯誤修正。 |
120 121 |
| 2026-03-18 | CLI 2.1.79:API billing auth 的 --console flag、/remote-control VS Code command、VS Code 中的 AI session titles、啟動記憶體減少約 18MB、2 分鐘 non-streaming timeout、/resume switch 時的 SessionEnd hooks。修正:-p 作為 subprocess 時卡住、print mode 中 Ctrl+C、/btw 輸出錯誤、voice mode 啟動、enterprise 429 重試。 |
121 |
| 2026-03-17 | CLI 2.1.78:StopFailure hook 事件、${CLAUDE_PLUGIN_DATA} plugin state、agent frontmatter(effort/maxTurns/disallowedTools)、ANTHROPIC_CUSTOM_MODEL_OPTION、tmux notification passthrough、逐行 streaming。安全性:sandbox deps 缺失時顯示可見警告。修正:大型 session 截斷(>5MB)、無限 stop hook 迴圈、sandbox path handling、voice WSL2、VS Code 中的 Homebrew PATH。 |
120 |
| 2026-03-17 | Guide v2.19:新增 v2.1.77 功能。Opus 4.6 預設 output tokens 提高至 64K,Opus 4.6 與 Sonnet 4.6 的上限提高至 128K。allowRead sandbox filesystem setting,可在 denyRead 區域內重新允許讀取權限。/copy N 會複製第 N 新的 assistant response。/fork 重新命名為 /branch(/fork 仍保留為 alias)。Agent tool 不再接受 resume 參數,請使用 SendMessage({to: agentId}) 繼續 agents;SendMessage 會自動恢復已停止的 agents。接受 plan 後,sessions 會依 plan 內容自動命名。Background bash tasks 在輸出達 5GB 時會被終止。claude plugin validate 會檢查 skill/agent/command frontmatter + hooks/hooks.json。macOS 啟動加快約 60ms(parallel keychain reads)。--resume 最高快 45%,peak memory 約少 100-150MB。安全性修正:PreToolUse hooks 回傳 "allow" 不再繞過包含 managed settings 在內的 deny permission rules。25+ 項錯誤修正,包括 compound bash「Always Allow」儲存無效規則、auto-updater 記憶體洩漏、Write tool CRLF 轉換、stale worktree cleanup race condition、vim mode 修正、tmux clipboard 修正。 |
119 |
| 2026-03-14 | Guide v2.18:新增 v2.1.76 功能。MCP elicitation support:MCP servers 可在任務中透過 interactive dialogs 要求 structured input。3 個新的 hook events:Elicitation、ElicitationResult、PostCompact(總計 22 個)。-n/--name CLI flag,可在啟動時設定 session display names。大型 monorepos 的 sparse-checkout 可用 worktree.sparsePaths。/effort slash command 可設定 model effort level。錯誤修正:compaction 後 deferred tools 遺失 schemas、plan mode re-approval、voice mode keypresses、auto-compaction circuit breaker(最多 3 次嘗試)、SSH 上 tmux 的 clipboard、Remote Control session 穩定性。 |
118 |
| 2026-03-13 | Guide v2.17:新增 v2.1.75 功能。1M context window 現已成為 Opus 4.6 的預設值,適用於 Max、Team 與 Enterprise plans(不需 [1m] suffix)。所有使用者皆可使用 /color command。Memory files 現在包含 last-modified timestamps,便於 freshness reasoning。Hook permission prompts 現在會顯示來源(settings/plugin/skill)。Prompt bar 會顯示 session name,並可用 /rename。錯誤修正:voice mode activation、piped commands 中的 Bash !、token estimation over-counting 導致過早 compaction、macOS 啟動效能。Breaking:移除已棄用的 Windows managed settings fallback path。 |
117 |
| 2026-03-12 | Guide v2.16:新增 v2.1.73 與 v2.1.74 功能。v2.1.73:自訂 provider model IDs(Bedrock/Vertex/Foundry)的 modelOverrides setting、已棄用 /output-style(改用 /config)、cloud providers 上預設使用 Opus 4.6、中斷後按 Up arrow 會還原 prompt + rewinds、回應期間也可使用 /effort、SSL cert error guidance、CPU freeze 與 deadlock 修正、SessionStart hooks 觸發兩次的修正。v2.1.74:/context actionable suggestions、autoMemoryDirectory setting、--plugin-dir override behavior change、CLAUDE_CODE_SESSIONEND_HOOKS_TIMEOUT_MS configurable timeout、managed policy enforcement 修正、記憶體洩漏修正(streaming buffers)、RTL text rendering 修正、MCP OAuth 修正。 |
115116 |
| 2026-03-11 | Guide v2.15:新增 v2.1.72 功能與 Code Review product。Code Review [RESEARCH PREVIEW]:Multi-agent PR review system,會派送 parallel agents 進行 cross-verified findings。Team/Enterprise,$15-25/review,約 20 分鐘。v2.1.72:/plan 接受 description arguments、/copy 中的 w key 可寫入檔案、ExitWorktree tool、CLAUDE_CODE_DISABLE_CRON 環境變數、擴充 bash allowlist(lsof、pgrep、tput、ss、fd、fdfind)、恢復 Agent tool 的 model 參數以支援 per-invocation overrides、簡化 effort symbols(○ ◐ ●)、/config 導覽改善(Esc/Enter/Space)、bundle size −510KB、VSCode URI handler。 |
113114 |
| 2026-03-10 | 新增:v2.1.72:當設定 ENABLE_TOOL_SEARCH 時,Tool search 會搭配 ANTHROPIC_BASE_URL 啟用。/copy 中的 w key 會將選取內容寫入檔案(SSH-friendly)。/plan 接受選用 description。ExitWorktree tool 可離開 worktree sessions。CLAUDE_CODE_DISABLE_CRON 會停止 scheduled jobs。Bash allowlist:lsof、pgrep、tput、ss、fd、fdfind。恢復 Agent tool 上的 model,支援 per-invocation model overrides。將 effort levels 簡化為 ○/◐/● symbols。/config 導覽:Esc 取消、Enter 儲存、Space 切換。Bundle size −510KB。提升 voice transcription accuracy。VSCode URI handler 可用於 programmatic tab opening。修正 Windows/OneDrive 上的 plugin installation、parallel tool calls cascade、agent progress tracking。 |
114 |
| 2026-03-09 | Code Review 已推出。 Multi-agent PR review system:派送 parallel agents 交叉驗證 findings,並依 severity 排序。$15-25/review。Team/Enterprise 研究預覽。54% 的 PRs 會收到 substantive comments(原為 16%)。incorrect finding rate <1%。 | 113 |
| 2026-03-09 | Guide v2.14:新增 /loop recurring task command(v2.1.71)。新增專屬「Claude Code on the Web」章節,涵蓋 capabilities、security architecture、availability,以及 web-vs-terminal decision table。新增 mobile app(iOS)提及。更新 Quick Reference Card,加入 /loop。 |
112 |
| 2026-03-07 | 新增:v2.1.71:/loop command 可依間隔重複執行 prompts(/loop 5m /foo)。Voice keybinding customization。Bash auto-approval allowlist expansion。Stdin freeze 修正。macOS 上的 CoreAudio startup optimization。 |
112 |
| 2026-03-06 | Guide v2.13:Voice mode 章節(/voice、按住說話、20種 STT 語言)。v2.1.68 effort 變更(Max/Team 的 Opus 4.6 預設為 medium effort、重新引入 ultrathink、移除 Opus 4/4.1)。v2.1.69 功能:/claude-api skill、InstructionsLoaded hook 事件、agent_id/agent_type/worktree hook 欄位、${CLAUDE_SKILL_DIR}、/reload-plugins、CLAUDE_CODE_DISABLE_GIT_INSTRUCTIONS、sandbox.enableWeakerNetworkIsolation、remote-control 自訂名稱、Ctrl+U 離開 bash mode、數字鍵盤支援。v2.1.70 修正:第三方閘道的 API 400、effort 參數錯誤、ToolSearch 後空白回應。VS Code:spark icon 工作階段清單、markdown plan view、原生 MCP 管理。效能:prompt render 減少74%,Remote Control poll rate 降低300倍。已將 subagent model 預設值更新為 inherit。hook 事件總數18個。 |
109110111 |
| 2026-03-06 | 新增:v2.1.70—修正使用 ANTHROPIC_BASE_URL 第三方閘道時的 API 400 錯誤(tool search 會對 proxy endpoint 停用 tool_reference 區塊)。修正自訂 Bedrock inference profile 的 effort 參數錯誤。修正 ToolSearch 後 model 回應為空的問題。改進 compaction,保留圖片以便重複使用 prompt cache。/rename 可在 Claude 處理程序期間運作。prompt 重新 render 減少約74%。Remote Control /poll 降至每10分鐘1次(約降低300倍)。VS Code:spark icon 工作階段清單作為完整編輯器、含註解的完整 markdown plan view、原生 /mcp 對話框。每次 --resume 約節省600個 token(修正 skill list 重複注入)。多項 Windows/voice/plugin/security 修正。 |
109 |
| 2026-03-05 | 新增:v2.1.69—/claude-api skill。InstructionsLoaded hook 事件。hook 事件中的 agent_id/agent_type/worktree 欄位。${CLAUDE_SKILL_DIR} skill 自我參照變數。/reload-plugins 命令。供 Go/MITM proxy 使用的 sandbox.enableWeakerNetworkIsolation。includeGitInstructions 設定 + CLAUDE_CODE_DISABLE_GIT_INSTRUCTIONS 環境變數。remote-control 自訂名稱(--name)。Voice STT 新增10種語言(共20種)。effort level 顯示。Ctrl+U 離開 bash mode。數字鍵盤支援。git-subdir plugin 來源類型。供 MCP 伺服器使用的 oauth.authServerMetadataUrl。Sonnet 4.5→4.6 自動遷移。安全性:從 gitignored 目錄探索巢狀 skill、symlink 寫入逃逸、信任對話框啟用所有 .mcp.json 伺服器。70多項錯誤修正,包括 macOS keychain 損毀、teammate 巢狀生成、記憶體洩漏。 |
110 |
| 2026-03-04 | 新增:v2.1.68—Max/Team 訂閱者的 Opus 4.6 預設為 medium effort。重新引入 “ultrathink” 關鍵字以啟用 high effort。從第一方 API 的 Claude Code 移除 Opus 4 和 Opus 4.1。 | 109 |
| 2026-03-03 | Voice Mode 推出。 /voice 會啟用按住說話(按住空白鍵說話)。逐步推出中(初始約5%)。採專業 pair-programming 設計,並非隨意的語音助理。 |
111 |
| 2026-03-02 | Guide v2.12:記錄 Task tool → Agent tool 重新命名(Agent(agent_type) 語法,Task(...) 作為別名)。macOS plist 和 Windows Registry 支援 managed settings(v2.1.51)。Figma 合作整合註記。 |
106107108 |
| 2026-02-28 | Guide v2.11:新增 v2.1.63 功能。/simplify 和 /batch 內建 slash commands。worktree 共用 project configs 與 auto-memory。ENABLE_CLAUDEAI_MCP_SERVERS=false 可選擇退出 claude.ai MCP connectors。HTTP hooks 正式 type: "http" handler 文件。/copy「一律複製完整回應」選項。VSCode 工作階段重新命名/移除。/clear skill cache reset 修正。多項記憶體洩漏修正。REPL bridge race condition 修正。GitHub Copilot Business/Pro Claude 可用性交叉參照。 |
104105 |
| 2026-02-27 | Guide v2.10:新增 v2.1.58–v2.1.62 功能。/copy 命令(互動式 code block picker)。/memory 命令強化 auto-memory 管理。Remote Control 擴展至更多使用者(v2.1.58)。產業採用統計:GitHub commit 的4%(約135K/日)。將 CVE-2025-59536 和 CVE-2026-21852 安全公告加入不受信任 repo 警告。prompt suggestion cache 修正(v2.1.62)。Windows 並行寫入造成 config file 損毀的修正(v2.1.61)。改進複合命令的 bash「always allow」prefix 建議。multi-agent 工作階段的記憶體使用改善。MCP OAuth token refresh race condition 修正。 |
100101102103 |
| 2026-02-25 | Guide v2.9:新增 v2.1.52–v2.1.56 錯誤修正。修正 Agent Teams 導覽(僅 Shift+Down,不是 Shift+Up/Down)。新增 team storage path 與 task dependency 詳細資訊。新增 TeammateIdle/TaskCompleted hook 整合註記。 | 99 |
| 2026-02-25 | 新增:v2.1.53–v2.1.56—Windows 上的 VS Code 當機修正、修正提交後 input 短暫消失造成 UI 閃爍、修正 bulk agent kill(Ctrl+F)以傳送單一彙總通知、修正 graceful shutdown 讓 Remote Control 留下過期工作階段、修正 --worktree 有時在首次啟動時被忽略、修正 Windows 上的 BashTool EINVAL、修正 Windows ARM64 與 Linux/Windows x64 的 WASM interpreter 當機。 |
99 |
| 2026-02-23 | Guide v2.8:新增 v2.1.51 功能。供外部 build 使用的 claude remote-control 子命令。HTTP hook 安全性:header 中的環境變數插值需要 allowedEnvVars;HTTP hooks 透過 sandbox proxy 路由。tool result 磁碟持久化閾值降至50K字元(原為100K)。BashTool 預設略過 login shell。Plugin 改進:自訂 npm registry、version pinning、可設定 git timeout。/model picker 顯示人類可讀標籤。SDK caller identity 環境變數。Agent Teams 的 teammate plan approval。 |
98 |
| 2026-02-24 | 新增:v2.1.51—供外部 build 使用的 claude remote-control 子命令、HTTP hook 環境變數插值安全性的 allowedEnvVars、HTTP hooks 透過 sandbox network proxy 路由、超過50K字元的 tool result 持久化到磁碟(原為100K)、BashTool 預設略過 login shell、plugin marketplace git timeout 可設定(CLAUDE_CODE_PLUGIN_GIT_TIMEOUT_MS)、plugins 支援自訂 npm registry 與 version pinning、/model picker 人類可讀標籤、CLAUDE_CODE_ACCOUNT_UUID/CLAUDE_CODE_USER_EMAIL/CLAUDE_CODE_ORGANIZATION_UUID SDK 環境變數、statusLine/fileSuggestion hooks 需要 workspace trust。修正:重複 control_response API 400 錯誤、YAML array SKILL.md descriptions 上的 slash command autocomplete 當機。 |
98 |
| 2026-02-22 | Guide v2.7:修正 fast mode pricing table——移除錯誤的 >200K 分級定價($60/$225)。官方 Anthropic pricing 確認整個 context window 固定為 $30/$150,沒有 long context surcharge。將 web fetch(免費)加入 Hidden Tool Fees table。新增當包含 web_search/web_fetch tools 時,code execution 免費。新增失敗的 web searches 不計費。 | 1 |
| 2026-02-21 | Guide v2.6:新增 v2.1.49 和 v2.1.50 功能。新 hook 事件:ConfigChange、WorktreeCreate、WorktreeRemove(共17個)。新的 --worktree/-w flag,可用於隔離 git worktrees。Subagent isolation: "worktree" 與 background: true 欄位。claude agents CLI 命令。CLAUDE_CODE_DISABLE_1M_CONTEXT 環境變數。Opus 4.6 fast mode 現在包含完整 1M context。Claude Code Security(research preview)。 |
— |
| 2026-02-20 | 新增:v2.1.50—LSP 伺服器的 startupTimeout、供自訂 VCS setup/teardown 使用的 WorktreeCreate/WorktreeRemove hook 事件、agent definitions 中的 isolation: worktree、claude agents CLI 命令、CLAUDE_CODE_DISABLE_1M_CONTEXT 環境變數、Opus 4.6 fast mode 現在包含完整 1M context window、VSCode /extra-usage 命令支援。CLAUDE_CODE_SIMPLE 現在會停用 MCP tools、attachments、hooks 和 CLAUDE.md 載入。修正:symlink session 不可見、SSH 中斷連線時 session data 遺失、agent teams 中的記憶體洩漏(completed tasks 未被 GC)、/mcp reconnect 對不存在的伺服器凍結、LSP diagnostic data 記憶體洩漏、prompt suggestion cache regression、Edit tool Unicode curly quote 損毀。Linux:修正 glibc < 2.30(RHEL 8)上的 native modules。針對長工作階段提供多項記憶體最佳化改善。 |
96 |
| 2026-02-19 | 新增:v2.1.49—--worktree(-w)flag,可在隔離的 git worktree 中啟動 Claude;subagents 支援 isolation: "worktree",可使用臨時 git worktree 工作;agent definitions 支援 background: true,一律作為背景任務執行;ConfigChange hook 事件供企業安全稽核使用;plugins 可附帶 settings.json 作為預設設定;SDK model info 現在包含 supportsEffort/supportedEffortLevels/supportsAdaptiveThinking 欄位。CLAUDE_CODE_SIMPLE 現在包含 file edit tool。移除具 1M context 的 Sonnet 4.5,改用 Sonnet 4.6。改進 MCP OAuth,支援 step-up auth 與 discovery caching。修正:有背景 agents 時 Ctrl+C 和 ESC 被忽略、WASM 記憶體無上限成長、disableAllHooks managed settings 階層、--resume 顯示原始 XML tags。改進 permission prompts,以顯示限制原因。 |
96 |
| 2026-02-20 | Claude Code Security(research preview):內建於網頁版Claude Code的弱點掃描。可掃描程式碼庫,並建議修補程式供人工審查。Enterprise、Team與開放原始碼維護者可使用。 | 97 |
| 2026-02-18 | 新增:v2.1.47—Ctrl+F會終止所有背景 agents(取代按兩次 ESC)、Stop/SubagentStop hook 輸入中的last_assistant_message欄位、chat:newline keybinding 動作、statusline JSON中的added_dirs、/rename會更新終端機分頁標題、resume picker 顯示 50 個 sessions(原為 10 個)、teammate 導覽簡化為僅使用 Shift+Down。效能:啟動約改善 500ms(延後 SessionStart hooks)、記憶體改善(釋放API串流緩衝區、修正 O(n²) 進度更新)。修正:壓縮後保留 plan mode、Edit tool Unicode 彎引號毀損、CJK 全形字元對齊、並行 agent API 400 錯誤、/resume遺失大型 sessions(>16KB)、壓縮後遺失 session 名稱、背景 agent 結果回傳原始 transcript,以及多項 Windows 修正(透過 Git Bash 執行 hooks、CWD 追蹤清理、磁碟機代號大小寫、WSL2 上的 BMP 貼上)。 |
95 |
| 2026-02-18 | 新增:v2.1.46—Claude Code支援 claude.ai MCP connectors,修正在 macOS 上終端機中斷連線後殘留孤立 CC 程序。v2.1.45—spinnerTipsOverride設定、SDKRateLimitInfo/SDKRateLimitEvent SDK型別,修正 Bedrock/Vertex/Foundry 上的 Agent Teams,修正 macOS 上的 sandbox 暫存檔錯誤,改善啟動與記憶體。 |
95 |
| 2026-02-18 | Guide v2.5:將Ctrl+F與Shift+Down加入鍵盤快捷鍵,將spinnerTipsOverride加入設定參考,新增last_assistant_message hook 欄位、chat:newline keybinding、claude.ai MCP connectors 章節,以及 resume picker 50-session 更新。 |
— |
| 2026-02-17 | 重大:Claude Sonnet 4.6 發布。Model ID:claude-sonnet-4-6。在 claude.ai 與Claude Cowork 上取代 Sonnet 4.5,成為預設模型。價格相同(每 MTok $3/$15)。以更少 tokens 改善 agentic search 效能。支援 adaptive thinking、extended thinking,以及 1M token context window(beta)。最大輸出 64K。知識截止:可靠至 2025 年 8 月,訓練至 2026 年 1 月。Sonnet 4.5 移至 legacy。另:搭配 web search/web fetch 時,API code execution 現已免費;web search tool 與 programmatic tool calling 現已 GA(不需 beta header)。 |
93 |
| 2026-02-17 | Guide v2.4:更新所有模型表格以納入 Sonnet 4.6,將 Sonnet 4.6 加入支援 extended thinking 的模型,更新註腳與定價參考。 | — |
| 2026-02-14 | 新增:v2.1.44—修正深層巢狀目錄路徑的 ENAMETOOLONG 錯誤,修正 auth refresh 錯誤。v2.1.43—修正 AWS auth refresh 卡住(3 分鐘逾時)、修正.claude/agents/中非 agent markdown 檔案的誤報警告、修正 structured-outputs beta header 在 Vertex/Bedrock 上無條件送出的問題。 |
94 |
| 2026-02-16 | Guide v2.3:移除已過期的 fast mode 促銷價格(2 月 16 日期限已過),新增 >200K long-context fast mode 級距($60/$225),修正 protect-files.sh 結束碼(阻擋時 1→2),修正 3 處過時的 Tab→Alt+T keybinding 參考,重寫 Copilot/Cursor 遷移表格(兩者現在皆有 agentic CLI+MCP),修正Claude Squad 安裝命令(brew/curl、csbinary、TUI app),新增 4 個缺漏的 ToC 項目(Output Styles、Slash Commands、Plugin System),更新 7 個註腳 URL(docs.anthropic.com→code.claude.com canonical),新增缺漏的 48 URL,修正 5 重新導向說明,新增 managed settings keys 表格(allowManagedPermissionRulesOnly、allowManagedHooksOnly 等),新增不受信任 repos 的 prompt injection 安全警告。新增 Quick Start 章節、專門的 Plan Mode 章節,擴充 non-interactive mode(-p)文件,加入 exit codes 與 CI/CD patterns,修正所有--session-id範例(需要 UUID;改為/rename+--resume),在 Remote 與 Slack 章節加入 [RESEARCH PREVIEW] 標記,標記 1 個未標記的 code block,驗證全部 35 個 ToC anchors。評估後修正:TL;DR 模型建議改為不偏向特定級距,jq // pattern 修正為select(),移除杜撰的--input-fileflag 並改用 pipe,修正Docker sandbox 語法,「sub-agent」連字號統一為「subagent」,將/login與/logout加入 slash commands 表格。 |
— |
| 2026-02-13 | 新增:v2.1.42—修正/resume將 interrupt 訊息顯示為 session 標題的問題,修正 Bedrock/Vertex/Foundry 使用者看到 Opus 4.6 發布公告的問題,改善多圖片尺寸限制錯誤訊息,並加入/compact建議。 |
90 |
| 2026-02-13 | 新增:v2.1.41—claude auth subcommands(login、status、logout),可不進入 REPL 即管理驗證;支援 Windows ARM64 原生 binary;/rename在未帶引數時,會依對話脈絡自動產生 session 名稱。修正:AWS auth refresh 無限期卡住(新增 3 分鐘逾時)、帶 anchor fragments 的 @-mentions(例如@README.md#installation)、FileReadTool 在 FIFOs//dev/stdin/大型檔案上阻塞、streaming Agent SDK mode 中的背景工作通知、classifier rule 輸入時游標跳動、原始 URL 的 markdown link 顯示文字遺失、自動 compact 失敗通知顯示給使用者、permission wait time 計入 subagent 經過時間、plan mode 中觸發 proactive ticks、設定變更後未清除過時 permission rules、hook blocking 錯誤在 UI 中顯示 stderr。 |
90 |
| 2026-02-12 | 準確性與完整性檢查:修正 hooks 表格—Stop、SubagentStop、TeammateIdle、TaskCompleted 皆可透過 exit code 2 阻擋。新增 PostToolUseFailure event。新增 prompt-based hooks(type: "prompt")與 agent-based hooks(type: "agent")文件。將 PreToolUse 更新為偏好的hookSpecificOutput格式(頂層decision已棄用)。新增 hook 環境變數($CLAUDE_PROJECT_DIR、$CLAUDE_ENV_FILE)。新增CLI --agents flag,可定義 session 範圍的 subagent。擴充 subagent config 表格:disallowedTools、maxTurns、mcpServers、hooks、delegate permission mode。 |
89 |
| 2026-02-10 | 新增:v2.1.39—改善終端機算繪效能。修正:fatal errors 被吞掉而非顯示、session 關閉後程序卡住、終端機畫面邊界字元遺失、verbose transcript view 中的空白行。 | 88 |
| 2026-02-10 | 新增:v2.1.38—安全性:在 sandbox mode 中阻擋寫入.claude/skills(防止 prompt injection 修改 skill definitions),改善 heredoc delimiter 解析以防止 command smuggling。修正:VS Code 終端機捲動到頂端的迴歸問題、Tab 鍵將 slash commands 排入佇列而非自動補完、使用環境變數 wrapper 的命令 bash permission matching、non-streaming mode 中 tool uses 之間的文字消失、在 VS Code 中 resume 時產生重複 sessions。 |
88 |
| 2026-02-08 | 新增:v2.1.37—修正啟用/extra-usage後/fast未立即可用的問題。 |
86 |
| 2026-02-08 | 新增:v2.1.36—Fast mode 現已可用於 Opus 4.6。相同模型,以 premium pricing 提供更快輸出(標準費率 6 倍,2 月 16 日前促銷 50% 折扣)。使用/fast切換。 |
86 |
| 2026-02-07 | 新增:v2.1.34—安全性修正:透過sandbox.excludedCommands或dangerouslyDisableSandbox排除 sandboxing 的命令,在autoAllowBashIfSandboxed啟用時,可能繞過 Bash ask permission rule。另修正 agent teams 設定在 renders 之間變更時發生的當機。 |
87 |
| 2026-02-05 | 新增:v2.1.33—多 agent 工作流程的TeammateIdle與TaskCompleted hook events、在 agent tools frontmatter 中使用Task(agent_type)語法限制可 spawn 的 subagents、agents 的memory frontmatter 欄位(user/project/local scope)、skill descriptions 與/skillsmenu 中顯示 plugin 名稱。修正:tmux 中的 agent teammate sessions 未傳送/接收訊息、不支援方案上的 agent teams 可用性警告、送出新訊息時中斷 extended thinking、含 whitespace+thinking blocks 的 mid-stream abort 發生API錯誤、API proxy 404 streaming fallback、settings.json env vars 中的 proxy settings 未套用至 WebFetch、/resume session picker 顯示原始 XML markup。改善:API連線錯誤訊息現在會顯示具體原因(ECONNREFUSED、SSL errors)。VSCode:OAuth使用者的 remote session 支援、session picker 中顯示 git branch + 訊息數並支援 branch search、scroll-to-bottom 修正。 |
85 |
| 2026-02-05 | 重大:Claude Opus 4.6 發布。 Model ID:claude-opus-4-6。1M token context window(beta)——首款具備此容量的 Opus 級模型。128K max output tokens。Adaptive thinking(自動推理深度)。Effort controls(low/medium/high/max)。Context compaction beta。Agent teams research preview(多 agent 平行協調)。Terminal-Bench 2.0 取得業界最高分。GDPval-AA:比 GPT-5.2 高 +144 Elo,比 Opus 4.5 高 +190。8-needle 1M MRCR v2 準確率 76%(競品約 18.5%)。開箱即在開放原始碼程式碼中找出 500+ 個零日漏洞。價格與 Opus 4.5 相同:每 MTok $5/$25。Long context(>200K input):$10/$37.50。 |
79 |
| 2026-02-05 | 新增:v2.1.32——Opus 4.6 support、agent teams research preview(需要 CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1)、自動記憶錄製/回想、訊息選擇器中的「Summarize from here」可摘要部分對話、從 --add-dir 目錄載入的 skills 會自動載入、skill 字元預算會隨 context window 調整(context 的 2%)。修正:子目錄中 @ 檔案補全的相對路徑錯誤、--resume 現在會重用前一個 session 的 --agent 值、heredocs 中含 JavaScript template literals 時發生 bash「Bad substitution」錯誤、泰文/寮文間距母音顯示。VSCode:slash command 執行修正、過往對話清單加入 spinner。 |
80 |
| 2026-02-04 | GitHub integration:Claude 與 Codex 現已在 GitHub 上提供 public preview——Copilot Pro+ 與 Enterprise 客戶可透過 Agent HQ 作為 coding agents 使用。Opus 4.6 已對 GitHub Copilot generally available。83 | 83 |
| 2026-02-04 | 新增:v2.1.31——結束時顯示 session resume 提示,說明如何繼續;checkbox selection 支援日文 IME 全形(zenkaku)空白輸入。修正:PDF 錯誤導致 session 永久鎖定、sandbox mode 中 bash「read-only file system」錯誤、缺少 ~/.claude.json 欄位時 plan mode 當機、temperatureOverride 在 streaming API 中被悄悄忽略、LSP shutdown 相容性。改進:system prompts 引導模型優先使用專用工具(Read、Edit、Glob、Grep),而非 bash 對應方式;PDF/request size 錯誤訊息(100 頁、20MB 限制)。 |
75 |
| 2026-02-03 | 新增:v2.1.30——Read tool 的 PDF pages parameter(讀取特定頁面範圍,例如 pages: "1-5")、大型 PDF(>10 頁)在 @-mentioned 時回傳輕量 reference、為沒有 DCR 的 MCP servers(例如 Slack)提供預先設定的 OAuth client credentials、用於 troubleshooting 的 /debug command、read-only mode 中額外的 git log/git show flags、Task tool 結果中的 token count/tool uses/duration metrics、reducedMotion config option。透過 stat-based session loading,--resume 記憶體用量減少 68%。修正:API history 中幽靈般的「(no content)」text blocks(減少 token 浪費)、tool changes 的 prompt cache invalidation、/login 後含 thinking blocks 時發生 400 errors、corrupted transcript resume 時卡住、Max 20x 的 rate limit messaging、permission dialogs 搶走焦點、subagents 無法存取 SDK 提供的 MCP tools、Windows bash 搭配 .bashrc。 |
76 |
| 2026-01-31 | 新增:v2.1.29——修正以 saved_hook_context resume sessions 時的啟動效能退化。 |
85 |
| 2026-02-01 | Enterprise adoption:ServiceNow 選擇 Claude 作為 ServiceNow Build Agent 的預設模型,並將 Claude Code 推出給 29,000+ 名員工使用——將 sales preparation time 減少 95%。Allianz 宣布合作,讓所有員工都能使用 Claude Code。 | 77 |
| 2026-01-30 | Breaking:Xcode 26.3 導入原生 Claude Agent SDK integration——與支援 Claude Code 的同一套 harness——可直接在 Xcode 中使用 subagents、background tasks 與 plugins,無需離開 IDE。在 SwiftUI 開發期間擷取 Xcode Previews 以進行視覺迭代。 | 78 |
| 2026-01-30 | 新增:v2.1.27——--from-pr flag 可 resume 連結到 GitHub PR numbers/URLs 的 sessions;透過 gh pr create 建立時,sessions 會自動連結至 PR;debug logs 中加入 tool call failures/denials;啟用 VSCode Claude in Chrome integration。修正:gateway users 的 context management validation、/context 彩色輸出、status bar 重複顯示 background task indicator、permissions precedence(content-level ask > tool-level allow)。Windows:bash execution 搭配 .bashrc、console window 閃爍。VSCode:OAuth token expiration 導致 401 errors。 |
74 |
| 2026-01-29 | 新增:v2.1.25——修正 Bedrock 與 Vertex gateway users 的 beta header validation error。因應方式:CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1。 |
73 |
| 2026-01-28 | 新增:v2.1.23——spinnerVerbs setting 可自訂 spinner text、企業環境的 mTLS/proxy connectivity 修正、per-user temp directory isolation、ripgrep timeout error reporting(先前會悄悄回傳空結果)、prompt footer 中 merged PR purple status indicator、bash timeout duration display。修正:prompt caching race condition、headless mode 中未取消 pending async hooks、tab completion 未更新 input、headless mode 中 Bedrock region display。 |
69 |
| 2026-01-28 | 新增:v2.1.22——修正 non-interactive(-p)mode 的 structured outputs。 |
68 |
| 2026-01-28 | 新增:v2.1.21——VSCode 中的 Python venv auto-activation(claudeCode.usePythonEnvironment setting)、日文 IME 全形(zenkaku)數字輸入支援、Read/search progress indicators(「Reading…」→「Read」)、Claude 現在偏好使用 file operation tools,而非 bash 對應方式。修正:退出時 shell completion cache truncation、resume 在 tool execution 期間中斷的 sessions 時發生 API errors、在具大型 output limits 的 models 上 auto-compact 過早觸發、刪除後 task ID 重用、VSCode 中 Windows file search。 |
67 |
| 2026-01-28 | 新增:MCP Apps(Claude 內的互動式 tool UIs,適用於 Asana、Figma、Slack 等)。Code Execution Tool v2(以 Bash execution 取代僅 Python 的方式、programmatic tool calling)。網頁版 Claude Code 擴大至 Team/Enterprise premium seats。 | 667172 |
| 2026-01-27 | 新增:v2.1.20——--add-dir flag 可從其他目錄載入 CLAUDE.md(需要 CLAUDE_CODE_ADDITIONAL_DIRECTORIES_CLAUDE_MD=1)、prompt footer 中的 PR review status indicator(彩色圓點顯示 approved/changes requested/pending/draft)、透過 TaskUpdate tool 刪除 task、vim arrow key history navigation、所有 users 皆可使用 /copy command、timestamped config backups(輪替保留最近 5 份)。修正:session compaction 在 resume 時載入完整 history、agents 工作時忽略 user messages、wide character(emoji/CJK)rendering artifacts、MCP responses 中含 Unicode 時的 JSON parsing。 |
65 |
| 2026-01-26 | 增強:Analytics API section 加入詳細 endpoint documentation、metrics table、curl example 與 limitations。現在包含 authentication requirements、available metrics(productivity、tool usage、cost)與 real-time monitoring alternatives。 | 46 |
| 2026-01-24 | 新增:v2.1.19——自訂 command arguments 的 $0、$1 shorthand(從 $ARGUMENTS.0 改為 $ARGUMENTS[0] bracket syntax)、用於停用新 task system 的 CLAUDE_CODE_ENABLE_TASKS env var、沒有 additional permissions/hooks 的 skills 不再需要 approval。VSCode:所有 users 皆啟用 session forking 與 rewind。SDK:queued_command replay 作為 SDKUserMessageReplay events。修正:terminal 關閉時的 dangling processes、git worktrees 中的 /rename//tag、搭配 prompt stash(Ctrl+S)時貼上的 text 遺失、agent model display、backgrounded hook commands 未及早 return、file write preview 省略空白行。 |
64 |
| 2026-01-24 | 新增:v2.1.17——修正不支援 AVX 指令的 processors 上發生的 crashes。 | 64 |
| 2026-01-24 | Breaking:Extended thinking 現在預設啟用 31,999 tokens。自然語言觸發詞(think、think hard、ultrathink)已deprecated,且不再分配 thinking tokens——請改用 MAX_THINKING_TOKENS env var 或 /config。更新 Extended Thinking section 以反映目前行為。 |
63 |
| 2026-01-24 | 新增:v2.1.18——可自訂鍵盤快捷鍵,支援 context-specific keybindings、chord sequences,並可透過 /keybindings command 完整個人化。Configuration 儲存在 ~/.claude/keybindings.json。 |
70 |
| 2026-01-24 | 新增:v2.1.16——具 dependency tracking 的 task management system、VSCode native plugin management support、OAuth users 可從 Sessions dialog 瀏覽/resume remote sessions。修正:subagent resumption 時 out-of-memory crashes、/compact warning visibility、session titles language setting、Windows IDE race condition。 |
62 |
| 2026-01-21 | 新增:v2.1.15——npm installation deprecation notice(偏好 native binary)、React Compiler UI performance improvements。修正:/compact warning 未清除、MCP stdio server timeout 未終止 child process(可能造成 UI freezes)。 |
61 |
| 2026-01-20 | 新增:v2.1.14—bash mode 中以歷史為基礎的自動完成(! + Tab)、已安裝清單中的 plugin 搜尋、將 plugins 釘選到 git commit SHAs、VSCode /usage command。重大修正:context window 阻擋限制(約65%→約98%)、parallel subagents 的記憶體當機、長時間 sessions 的記憶體洩漏、bash mode 中 @ 符號檔案自動完成、/feedback 無效 URL、/context token 數顯示、slash command 自動完成選錯項目。 |
60 |
| 2026-01-20 | 新增:v2.1.12(message rendering bug fix)。將 Setup hook 版本更正為 v2.1.10,並補上完整 release notes:用於複製 OAuth URL 的 ‘c’ 鍵盤快捷鍵、改善啟動時的按鍵擷取、可移除為 attachments 的檔案建議、VSCode plugin 安裝數與信任警告。新增 teleport 單向限制說明。 | 59 |
| 2026-01-19 | 文件更新:將 SubagentStart hook 加入 events table,擴充 PreToolUse hooks 的 additionalContext 文件(v2.1.9),擴充 LSP tool capabilities section,並強化 People to Follow,加入 content creators 與官方資源。 |
— |
| 2026-01-19 | 新增:Setup hook event(v2.1.10)—透過 --init、--init-only 或 --maintenance CLI flags 觸發,用於環境設定工作。 |
53 |
| 2026-01-18 | 新增:Multiple Accounts Policy section(允許事項、技術限制、禁止事項)。新增 Community Tips section(plan mode auto-clear context、/clear、screenshots、container patterns)。新增 People to Follow(Boris Cherny、Thariq、Jeffrey Emanuel)。新增 API token pricing table。 | 49505152 |
| 2026-01-17 | 新增:v2.1.11 release—修正 HTTP/SSE transports 過多 MCP connection requests(改善重度 MCP 使用者的穩定性)。 | 48 |
| 2026-01-16 | 新增:MCP Tool Search section,包含 benchmarks(Opus 4:49%→74%、Opus 4.5:79.5%→88.1%、token overhead 減少85%)。更新 MCP ecosystem stats(每月1億次 downloads、3,000+ servers)。 | 47 |
| 2026-01-16 | 新增:Claude Code Analytics API section—Team/Enterprise 可透過 Admin API endpoint /v1/organizations/usage_report/claude_code,以程式化方式存取 usage metrics(sessions、commits、PRs、lines of code)。記錄 ${CLAUDE_SESSION_ID} skill substitution(v2.1.9)。 |
4446 |
| 2026-01-15 | 新增:v2.1.9 auto:N syntax,用於 MCP tool search threshold;plansDirectory setting;AskUserQuestion 中的 external editor(Ctrl+G);web session commits/PRs 的 session URL attribution;PreToolUse hooks additionalContext。修正 parallel tool calls API errors、MCP reconnection hanging、Kitty 中的 Ctrl+Z。新增 Cowork(給非技術使用者的 GUI 版本)。 |
4445 |
| 2026-01-15 | 新增:v2.1.7 permission feedback feature(接受 permission prompts 時提供 feedback)。GitHub Action v1.0 GA release。小幅文件更新。 | 41 |
| 2026-01-14 | 新增:v2.1.7 MCP tool search auto mode 預設啟用(context 超過10%時延後載入 tools)、showTurnDuration setting、task notifications 中的 inline agent response、修正 wildcard permissions 匹配 compound commands 的安全問題。v2.1.6:/config search、/doctor Updates section、/stats date range filtering、nested .claude/skills discovery、context_window.used_percentage/remaining_percentage fields、修正 shell line continuation permission bypass 的安全問題。v2.1.5:CLAUDE_CODE_TMPDIR env var。 |
414243 |
| 2026-01-13 | 新增:URL 從 console.anthropic.com 改為 platform.claude.com(v2.1.4)。新增 context: fork skill frontmatter option,用於隔離 contexts。新增 subagents 的 permission denial resilience(v2.1.0+)。新增 plugin marketplace launch info(2025年12月36個 curated plugins)。 |
40 |
| 2026-01-12 | 新增:v2.1.4 CLAUDE_CODE_DISABLE_BACKGROUND_TASKS environment variable,可停用所有 background task 功能,包含 auto-backgrounding 與 Ctrl+B shortcut。修正「Help improve Claude」setting 的 OAuth token refresh。 |
39 |
| 2026-01-10 | 新增:Sandboxing 讓 permission prompts 減少84%(來自 Anthropic engineering blog)、Opus 4.5 SWE-bench performance(80.9%)與 token efficiency improvements。小幅文件更新。 | 38 |
| 2026-01-10 | 新增:v2.1.3 合併 slash commands 與 skills(統一 mental model)、/config 中的 release channel toggle(stable/latest)、/doctor 可偵測無法觸及的 permission rules、hook execution timeout 從60秒提高到10分鐘。Bug fixes:plan files 在 /clear 後仍持續存在、ExFAT 上的 skill duplicate detection、background task count mismatch、subagents 在 compaction 期間使用錯誤 model。VSCode:permissions 的 clickable destination selector。 |
37 |
| 2026-01-09 | 新增:v2.1.1(109項 CLI refinements)、Component-Scoped Hooks(skill/command frontmatter 中的 hooks,含 once option)、新的 MCP servers(Figma Dev Mode、Sequential Thinking、Magic UI、Context7)。將 MCP ecosystem count 更新為 3,000+ servers。 |
343536 |
| 2026-01-08 | 新增:settings.json reference 的 language 與 respectGitignore settings。新增 IS_DEMO env var。更新 multiline input,顯示 Shift+Enter 在 iTerm2/WezTerm/Ghostty/Kitty 中開箱即可運作。新增每個 org/month 1,550 小時免費 code execution。 |
3033 |
| 2026-01-08 | 新增:v2.1.2 tool output 中的 clickable file paths(iTerm 的 OSC 8)、Windows Package Manager(winget)支援、plan mode 中 Shift+Tab 可啟用「auto-accept edits」、FORCE_AUTOUPDATE_PLUGINS env var、SessionStart hook 中的 agent_type field。Security fixes:bash processing 中的 command injection、tree-sitter 造成的 memory leak。將 thinking toggle 更新為 Alt+T。新增 MCP wildcard permission syntax(mcp__server__*)。新增 PreToolUse hooks updatedInput 搭配 ask permission。 |
32 |
| 2026-01-07 | 新增:v2.1.0 automatic skill hot-reload(~/.claude/skills 或 .claude/skills 中的 skills 無須重新啟動即可立即使用)。Security:CVE-2025-52882 WebSocket authentication bypass 已在 IDE extensions v1.0.24+ 修補 |
3031 |
| 2026-01-06 | 新增:v2.0.74 clickable image links([Image #N])、/context grouped display、git repos 中的 file @ mentions 快3倍、支援 .ignore 與 .rgignore、Claude Agent SDK v0.1.74 |
272829 |
| 2025-12-28 | 新增:Named sessions(/rename、/resume <n>)、plugin discover search filtering、--fork-session 搭配 custom session IDs、Agent Skills section、async subagents、Claude Agent SDK(由 Claude Code SDK 重新命名)、Alt+Y yank-pop、Alt+T thinking toggle、Ctrl+T syntax highlighting toggle、holiday promotion(12月25日至31日 2× limits) |
2223242526 |
| 2025-12-24 | 新增:Claude in Chrome section、Claude Code in Slack section、LSP tool、remote MCP OAuth support、’ultrathink’ command、/theme 與 /plugin commands、Kitty/Alacritty/Zed/Warp 的 terminal support |
161718192021 |
| 2025-12-14 | 新增:Pro users Opus 4.5 access、subscription plans table、rate limits(2025年8月)、iOS app availability | 131415 |
| 2025-12-12 | 新增:Background Agents section、Output Styles section、hidden tool fees、/stats、/fork、/rename、/statusline、/tasks commands、.claude/rules/ memory directory、Batch API tip |
9101112 |
| 2025-12-12 | 新增:Slack integration、prompt suggestions、Alt+P model switching、/release-notes command、/rewind command、interactive MCP setup wizard |
678 |
| 2025-12-12 | 初始 10.0 版本:Architecture mental model、decision frameworks、anti-patterns、workflow recipes、migration guide、quick reference card | — |
執行 /update-cc-guide 以掃描並套用最新的 Claude Code updates。 |
參考資料
-
Anthropic 定價。”Claude API 定價。”2025年12月。 ↩↩↩↩
-
Claude Code Subagents。”Subagents 文件。”2025年12月。 ↩
-
Claude Code Docs。”Hooks 指南。”2025年12月由 docs.anthropic.com 重新導向;2026年2月更新 canonical URL。 ↩
-
Anthropic。”Claude Code 最佳實務。”2025年4月。注意:原始 URL 現在會重新導向至 code.claude.com/docs(內容已合併至主要文件)。另請參閱 Claude Code Docs。 ↩
-
Claude Code CHANGELOG。”提示建議:Claude 現在會建議您接下來可能想做的事。”2025年12月16日。另請參閱 TechCrunch 對 2025年12月功能的報導。 ↩↩
-
Claude Code Docs。”互動式 MCP 設定。”2025年12月由 docs.anthropic.com 重新導向;2026年2月更新 canonical URL。 ↩↩
-
Northflank。”Claude Code 隱藏工具費用。”2025年7月。 ↩↩
-
Claude Code Docs。”記憶規則目錄。”2025年12月。 ↩↩
-
GitHub CHANGELOG。”Pro 使用者現在可透過訂閱使用 Opus 4.5。”2025年12月。 ↩↩
-
Northflank。”2025年8月速率限制變更。”2025年7月。 ↩↩
-
Claude Blog。”Web 與 iOS App 上的 Claude Code。”2025年11月。 ↩↩
-
Claude Blog。”Team 與 Enterprise 使用者可用的 Web 版 Claude Code。”2025年11月。 ↩
-
GitHub Releases。”Chrome 中的 Claude(Beta)功能。”2025年12月。 ↩↩
-
GitHub Releases。”LSP 工具與終端機支援更新(v2.0.74)。”2025年12月。 ↩↩↩
-
TechCrunch。”Slack 中的 Claude Code 發表。”2025年12月。 ↩↩
-
GitHub Releases。”Thinking mode 觸發詞:think、think harder、ultrathink。”2025年12月。 ↩
-
GitHub Releases。”使用 /rename 與 /resume 的具名工作階段。”2025年12月。 ↩
-
GitHub Releases。”Plugin discover 搜尋篩選、使用 –fork-session 的自訂工作階段 ID(v2.0.73-74)。”2025年12月。 ↩
-
Anthropic Engineering。”Agent Skills:可重複使用的任務專用模組。”2025年12月。 ↩↩
-
Anthropic Engineering。”Claude Agent SDK(由 Claude Code SDK 更名)。”2025年12月。 ↩↩
-
Apidog。”Claude Code 於 2025年12月25日至31日為 Pro/Max 訂閱者提供 2 倍用量限制。”2025年12月。 ↩
-
GitHub Releases。”v2.0.73-74:可點擊圖片連結、
/context分組顯示、ctrl+t語法醒目提示切換。”2026年1月。 ↩↩ -
GitHub Releases。”v2.0.72:git repo 中 @ mention 檔案建議快 3 倍,支援
.ignore與.rgignore檔案。”2026年1月。 ↩↩ -
GitHub Claude Agent SDK。”Claude Agent SDK v0.1.74 與 Claude Code v2.0.74 功能對齊。”2026年1月。 ↩
-
GitHub Releases。”v2.1.0:自動 skill 熱重新載入、回應語言的
language設定、settings.json 中的respectGitignore、IS_DEMO環境變數、Shift+Enter 在 iTerm2/WezTerm/Ghostty/Kitty 中開箱即用。”2026年1月。 ↩↩↩ -
Datadog Security Labs。”CVE-2025-52882:Claude Code IDE extensions 中的 WebSocket 驗證繞過已於 v1.0.24+ 修補。”2026年1月。 ↩↩
-
GitHub Releases。”v2.1.2:可點擊檔案路徑(OSC 8)、winget 支援、plan mode 中 Shift+Tab 自動接受、FORCE_AUTOUPDATE_PLUGINS、SessionStart hook 中的 agent_type、安全修正(command injection、memory leak)、thinking 切換改為 Alt+T、MCP wildcard 權限、PreToolUse 搭配 ask 的 updatedInput。”2026年1月。 ↩↩↩
-
Anthropic Pricing。”每個組織每月可獲得 1,550 小時免費 code execution tool 用量。”2026年1月。 ↩↩
-
VentureBeat。”Claude Code 2.1.0 引入基礎架構層級功能。針對 agents、skills 與 slash commands 的 hooks,具備限定範圍的 PreToolUse、PostToolUse 與 Stop 邏輯。”2026年1月。Medium。”Claude Code 2.1.1 隨附 109 項 CLI 改進。” ↩↩
-
Builder.io。”Figma 官方 Dev Mode MCP 伺服器會揭露您所選 layer 的即時結構,包括階層、auto-layout、variants、text styles 與 token references。”2025年12月。 ↩↩
-
Apidog。”Sequential Thinking MCP 伺服器讓 Claude 能以結構化、反思性的思考流程,有條不紊地處理問題。”2026年1月。MCP.so。”已索引超過 3,000 個 MCP 伺服器。” ↩↩
-
GitHub Releases。”v2.1.3:合併 slash commands 與 skills、/config 中的發行通道切換、/doctor 無法到達權限偵測、hook 逾時增加至 10 分鐘。”2026年1月。 ↩
-
Anthropic。”Sandboxing 可安全地將權限提示減少 84%。”2026年1月。Anthropic。”Claude Opus 4.5 在 SWE-bench Verified 達到 80.9%,同時將 token 用量減半。” ↩↩
-
GitHub Releases。”v2.1.4:新增 CLAUDE_CODE_DISABLE_BACKGROUND_TASKS 環境變數,修正「Help improve Claude」設定的 OAuth token refresh。”2026年1月。 ↩
-
VentureBeat。”Claude Code 2.1.0:透過 skill frontmatter 中的
context: fork分叉 sub-agent context,agents 在權限被拒後仍會繼續執行。”2026年1月。GitHub ykdojo/claude-code-tips。”Anthropic 於 2025年12月正式推出 plugin marketplace,內含 36 個精選 plugins。” ↩↩↩↩ -
GitHub Releases。”v2.1.7:MCP tool search auto mode 預設啟用、showTurnDuration 設定、task notifications 中的 inline agent response、wildcard permissions 的安全修正。”2026年1月。 ↩↩
-
GitHub Releases。”v2.1.6:/config 搜尋、/doctor Updates 區段、/stats 日期範圍篩選、nested skills 探索、context_window 百分比欄位、shell line continuation 安全修正。”2026年1月。 ↩
-
GitHub Releases。”v2.1.5:CLAUDE_CODE_TMPDIR 環境變數,用於覆寫暫存目錄。”2026年1月。 ↩
-
GitHub Releases。”v2.1.9:新增auto:N語法,用於MCP工具搜尋閾值、plansDirectory設定、AskUserQuestion中的外部編輯器(Ctrl+G)、提交/PR的工作階段URL歸因、PreToolUse hooks的additionalContext。修正平行工具呼叫API錯誤、MCP重新連線卡住、Kitty中的Ctrl+Z。”2026年1月。 ↩↩↩↩
-
Wikipedia。”名為「Cowork」的版本具備圖形使用者介面,面向非技術使用者,於2026年1月[推出]。”2026年1月。 ↩
-
Claude Docs。”透過Claude Code Analytics Admin API,以程式化方式存取組織的Claude Code使用情況分析與生產力指標。”2026年1月。 ↩↩↩
-
VentureBeat。”MCP Tool Search:Opus 4準確率從49%提升至74%,Opus 4.5從79.5%提升至88.1%。Boris Cherny:「每位Claude Code使用者都獲得了多得多的脈絡。」”2026年1月。Anthropic。”MCP已達每月1億次下載,並成為業界標準。”2026年1月。 ↩↩↩
-
GitHub Releases。”Claude Code v2.1.11:修正HTTP/SSE傳輸中過多的MCP連線請求。”2026年1月17日。 ↩↩
-
Medium。”Boris Cherny:使用Claude Code在30天內完成259個PR、497次提交、新增4萬行、刪除3.8萬行。”2026年1月。 ↩↩
-
Anthropic Pricing。”API Token定價:Haiku 4.5($1/$5)、Sonnet 4.6($3/$15)、Opus 4.6($5/$25)。”2026年2月。 ↩
-
GitHub ykdojo/claude-code-tips。”社群技巧集:計畫模式、經常使用/clear、螢幕截圖、用於PR的GitHub app。”2026年1月。 ↩↩
-
Anthropic Usage Policy。多帳號政策。Anthropic Support。”您最多可用同一個電話號碼驗證3個帳號。支援同一網路下的多個付費訂閱。”2026年1月。 ↩↩
-
GitHub Releases。”v2.1.10:新增Setup hook事件,可透過–init、–init-only或–maintenance CLI旗標觸發;登入期間用於複製OAuth URL的「c」鍵盤快捷鍵;改進啟動時的按鍵捕捉;檔案建議可作為可移除附件;VSCode plugin安裝數與信任警告。”2026年1月17日。 ↩↩
-
@adocomplete。”Advent of Claude第15天:–dangerously-skip-permissions旗標(YOLO模式),用於完全自主運作。”2026年1月。 ↩
-
@adocomplete。”Claude Max訂閱者可透過/passes命令取得3張訪客通行證,與他人分享Claude Code Pro試用。”2026年1月。 ↩
-
@mattpocockuk。”Docker sandbox模式,可安全探索不受信任的程式碼庫。”2026年1月。 ↩
-
Daisy Hollman。”隔夜hooks策略:使用linting與testing hooks作為護欄,讓Claude持續迭代直到測試通過。”2026年1月。 ↩
-
@moofeez。”Claude Squad:多代理管理器,可在隔離worktrees中平行管理Claude Code執行個體。”2026年1月。 ↩
-
GitHub Releases。”v2.1.12:修正訊息呈現錯誤。”2026年1月17日。 ↩
-
GitHub Releases。”v2.1.14:bash模式中的基於歷史紀錄自動完成、plugin搜尋、將plugins釘選至git SHA、VSCode /usage命令。修正:脈絡視窗阻擋限制(約65%→約98%)、平行subagents造成的記憶體當機、長工作階段中的記憶體洩漏、@符號檔案自動完成、/feedback URL、/context token計數、slash command自動完成。”2026年1月20日。 ↩
-
GitHub Releases。”v2.1.15:npm安裝淘汰通知、React Compiler UI效能改善。修正:/compact警告持續顯示、MCP stdio伺服器逾時未終止子程序(UI凍結修正)。”2026年1月21日。 ↩
-
GitHub Releases。”v2.1.16:具備相依性追蹤的任務管理系統、VSCode原生plugin管理、OAuth使用者可瀏覽/恢復遠端工作階段。修正:subagent恢復造成的OOM當機、/compact警告可見性、工作階段標題語言、Windows IDE競態條件。”2026年1月22日。 ↩
-
GitHub Issues。”Ultrathink已淘汰。Thinking模式預設啟用,並提供31,999個token。像「think」、「think hard」、「ultrathink」等關鍵字不再分配thinking token,請改用MAX_THINKING_TOKENS環境變數。”2026年1月。Decode Claude。”UltraThink已死。Extended Thinking萬歲。” ↩↩
-
GitHub Releases。”v2.1.19:自訂命令引數的$0/$1簡寫、CLAUDE_CODE_ENABLE_TASKS環境變數、所有使用者可使用VSCode工作階段分叉/倒回。v2.1.17:修正不支援AVX指令處理器上的當機。”2026年1月23日至24日。 ↩↩
-
Claude Code Docs。”v2.1.20:–add-dir旗標可從額外目錄載入CLAUDE.md、PR審查狀態指示器、透過TaskUpdate刪除任務、vim方向鍵歷史導覽、所有使用者可用/copy命令、帶時間戳記的設定備份。修正:工作階段壓縮問題、agents忽略使用者訊息、寬字元呈現、含Unicode的JSON解析。”2026年1月27日。 ↩
-
Anthropic。”Claude Code on the web現已作為research preview提供給具備premium席位的Team與Enterprise使用者,並同時開放給Pro與Max使用者。”2026年1月26日。 ↩↩↩↩↩↩
-
GitHub Releases。”v2.1.21:日文IME全形數字輸入、VSCode中Python venv自動啟用(claudeCode.usePythonEnvironment)、Read/search進度指示器、Claude優先使用檔案工具而非bash。修正:shell completion快取、工作階段恢復API錯誤、自動壓縮時機、任務ID重複使用、Windows檔案搜尋。”2026年1月27日。 ↩
-
GitHub Releases。”v2.1.22:修正非互動(-p)模式的structured outputs。”2026年1月27日。 ↩
-
GitHub Releases。”v2.1.23:spinnerVerbs設定、mTLS/proxy連線修正、每位使用者的暫存目錄隔離、ripgrep逾時回報、已合併PR紫色指示器、bash逾時顯示。修正:prompt caching競態條件、headless中的async hooks、tab完成、Bedrock區域字串。”2026年1月28日。 ↩
-
Claude Code Docs。”v2.1.18:可自訂鍵盤快捷鍵,支援依脈絡而定的keybindings、chord sequences與個人化。執行/keybindings進行設定。”2026年1月22日。 ↩↩
-
Help Net Security。”Anthropic為Claude新增互動式工具支援(MCP Apps),讓使用者可直接在Claude介面中與Asana、Box、Canva、Figma、Hex、monday.com與Slack互動。”2026年1月26日。 ↩↩
-
Anthropic Developer Platform。”Code Execution Tool v2 public beta:可在code execution內執行Bash命令、操作檔案,以及進行程式化工具呼叫。”2026年1月。 ↩↩
-
GitHub Releases。”v2.1.25:修正Bedrock與Vertex上的gateway使用者beta header驗證錯誤。因應方式:CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1。”2026年1月29日。 ↩
-
GitHub Releases。”v2.1.27:–from-pr旗標可用於PR連結工作階段、透過gh pr create自動將工作階段連結至PR、debug logs中的工具呼叫失敗、VSCode Claude in Chrome整合。修正:脈絡管理驗證、/context彩色輸出、狀態列重複、權限優先順序、Windows bash/.bashrc、Windows主控台閃爍、VSCode OAuth 401錯誤。”2026年1月30日。 ↩↩
-
GitHub Releases。”v2.1.31:工作階段續接提示、日文 IME 全形空白輸入、修正 PDF 過大錯誤會永久鎖定工作階段的問題、修正 sandbox 中 bash 唯讀檔案系統錯誤、修正 temperatureOverride 被靜默忽略的問題、LSP 關閉相容性、改善專用工具相較於 bash 的系統提示。”2026年2月。 ↩
-
GitHub Releases。”v2.1.30:Read tool 的 PDF pages 參數、大型 PDF 回傳輕量參照、為 MCP (Slack) 預先設定 OAuth、/debug command、–resume 記憶體減少 68%、修正幽靈「(no content)」文字區塊、修正 prompt 快取失效、修正 subagents 存取 SDK MCP tools。”2026年1月30日。 ↩↩
-
Anthropic。”ServiceNow 選擇 Claude 作為 ServiceNow Build Agent 的預設 model,並將 Claude Code 推出給 29,000 多名員工,使業務人員準備時間縮短 95%。”2026年1月。 ↩
-
IT Brief Asia。”Xcode 26.3 導入原生 Claude Agent SDK integration,也就是驅動 Claude Code 的同一套 harness,讓 subagents、background tasks 與 plugins 可直接在 Xcode 中使用。”2026年1月。 ↩
-
Anthropic。”Introducing Claude Opus 4.6.”2026年2月5日。1M token context(beta)、128K max output、adaptive thinking、effort controls、agent teams、Terminal-Bench 2.0 最高分、GDPval-AA 比 GPT-5.2 高 +144 Elo、發現 500 多個 zero-day vulnerabilities。每 MTok $5/$25。另請參閱 TechCrunch、CNBC、Anthropic Pricing。 ↩↩↩↩↩
-
GitHub Releases。”v2.1.32:支援 Opus 4.6、agent teams research preview、自動記憶錄製、Summarize from here、從 –add-dir 自動載入 skills、skill 字元預算會隨 context window 調整、修正 bash heredoc JS template literal、修正泰文/寮文顯示。”2026年2月。 ↩↩
-
Dev Genius。”Claude Code async hooks:它們是什麼,以及何時使用。Hooks 現在可透過
async: true在背景執行,而不會阻塞 Claude Code 的執行。”2026年1月25日。 ↩ -
Anthropic Engineering。”讓 Claude Code 更安全且更自主。”Sandbox 使用作業系統層級的 primitives(macOS seatbelt、Linux bubblewrap)。已在 github.com/anthropic-experimental/sandbox-runtime 開源。2026年1月。 ↩
-
GitHub Blog。”Claude and Codex are now available in public preview on GitHub.”2026年2月4日。另見:GitHub Blog。”Claude Opus 4.6 is now generally available for GitHub Copilot.”2026年2月5日。 ↩↩
-
Claude Code Docs。”協調多個 Claude Code sessions 組成的團隊。”2026年2月5日。Boris Cherny:”Out now: Teams, aka. Agent Swarms in Claude Code.”另請參閱 Lydia Hallie。”Claude Code 現已支援 agent teams(research preview)——lead agent 可委派給多位 teammates,讓他們平行研究、偵錯與建置,同時彼此協調。” ↩↩
-
GitHub Releases。”v2.1.33:TeammateIdle 與 TaskCompleted hook events、Task(agent_type) sub-agent restriction syntax、agents 的 memory frontmatter、skill descriptions 中的 plugin name。修正:tmux agent teammate sessions、agent teams plan warnings、extended thinking interruption、API proxy 404 fallback、WebFetch 的 proxy settings、/resume XML markup。VSCode:OAuth 的 remote sessions、session picker 中的 git branch。”2026年2月。 ↩↩
-
GitHub Releases。”v2.1.36:Fast mode now available for Opus 4.6.”2026年2月7日。Simon Willison。”Claude:使用 fast mode 加速回應。”Fast mode pricing:標準費率的 6 倍(Opus 4.6 ≤200K input 為每 MTok $30/$150;>200K input 為 $60/$225)。上市促銷(50% 折扣)持續至 2026年2月16日。v2.1.37:修正啟用 /extra-usage 後 /fast 未立即可用的問題。Anthropic Pricing。 ↩↩↩↩
-
GitHub Releases。”v2.1.34:修正 agent teams 設定在 render 之間變更時的當機問題。修正 autoAllowBashIfSandboxed 啟用時,從 sandboxing 排除的 commands 可能繞過 Bash ask permission rule 的 bug。”2026年2月6日。 ↩↩
-
GitHub Releases。”v2.1.38:修正 VS Code terminal scroll-to-top regression、Tab 鍵 slash command queueing、env var wrappers 的 bash permission matching、non-streaming mode 中 tool uses 之間文字消失、VS Code 續接時出現重複 sessions。改善 heredoc delimiter parsing,以防止 command smuggling。阻擋 sandbox mode 中對 .claude/skills 的寫入。”2026年2月10日。v2.1.39:改善 terminal rendering performance、修正 fatal errors 被吞掉、session close 後 process 卡住、terminal 邊界字元遺失。 ↩↩↩
-
Claude Code Docs。”Hooks reference:prompt-based hooks、agent-based hooks、hook environment variables($CLAUDE_PROJECT_DIR、$CLAUDE_ENV_FILE)、PreToolUse 的 hookSpecificOutput format。”2026年2月。Claude Code Docs。”建立自訂 subagents:–agents CLI flag、disallowedTools、maxTurns、mcpServers、delegate permission mode。”2026年2月。 ↩↩↩↩↩↩
-
Claude Code GitHub Releases。v2.1.41(2月13日):
claude authsubcommands、Windows ARM64 support、/renameauto-generation。v2.1.42(2月13日):/resumetitle fix、Bedrock/Vertex/Foundry announcement fix。 ↩↩↩ -
Anthropic。”Models overview。”所有 Claude 3.5 與 Claude 4.x models 預設皆支援 200K token input context。Opus 4.6 在 beta 中將其擴展至 1M tokens。 ↩
-
Claude Code Docs。”Getting started with Claude Code。”系統需求:macOS 10.15+、Ubuntu 20.04+/Debian 10+、Windows 10+(WSL 或 Git Bash)、最低 4 GB RAM、有效的網際網路連線。 ↩
-
Anthropic。”Claude Sonnet 4.6.”2026年2月17日。Claude Developer Platform Release Notes。”Sonnet 4.6:改善 agentic search、減少 tokens、extended thinking、1M context(beta)。claude.ai 的預設 model。Sonnet 4.5 已移至 legacy。”Model ID:
claude-sonnet-4-6。Anthropic Models Overview。”64K max output、knowledge cutoff:reliable Aug 2025 / training Jan 2026。” ↩↩↩ -
Claude Code GitHub Releases。v2.1.43:修正 AWS auth refresh 3 分鐘 timeout、修正誤報
.claude/agents/markdown warnings、修正 Vertex/Bedrock 的 structured-outputs beta header。v2.1.44:修正深層巢狀 directories 的 ENAMETOOLONG、修正 auth refresh error。 ↩ -
Claude Code GitHub CHANGELOG。v2.1.45(2月17日):支援 Sonnet 4.6、
spinnerTipsOverride設定、SDKRateLimitInfo/SDKRateLimitEventtypes、Agent Teams Bedrock/Vertex/Foundry fix、sandbox temp file fix。v2.1.46(2月18日):Claude Code 中的 claude.ai MCP connectors、修正 macOS 上的孤立 process。v2.1.47(2月18日):Ctrl+Fkills background agents、Stop/SubagentStop hooks 中的last_assistant_message、chat:newlinekeybinding、added_dirsstatusline field、/renameterminal tab title、resume picker 50 sessions、啟動改善約 500ms、記憶體改善、CJK alignment fix、plan mode compaction fix、Edit tool Unicode fix、多項 Windows 修正。 ↩↩↩↩ -
Claude Code GitHub CHANGELOG。v2.1.49(2月19日):
--worktree(-w)旗標、subagents 的isolation: "worktree"、agent 定義的background: true、ConfigChangehook 事件、MCP OAuth 升級驗證、SDKsupportsEffort/supportedEffortLevels/supportsAdaptiveThinking欄位、CLAUDE_CODE_SIMPLE包含 Edit tool、Sonnet 4.5 1M 因 Sonnet 4.6 移除、WASM 記憶體修正、權限限制原因。v2.1.50(2月20日):WorktreeCreate/WorktreeRemovehooks、LSP 伺服器的startupTimeout、claude agentsCLI 命令、CLAUDE_CODE_DISABLE_1M_CONTEXT環境變數、Opus 4.6 fast mode 完整 1M context、CLAUDE_CODE_SIMPLE停用 MCP/hooks/CLAUDE.md、VSCode/extra-usage、agent teams 記憶體洩漏修正、LSP diagnostic 洩漏修正、Linux glibc < 2.30 修正、多項記憶體最佳化。 ↩↩↩↩↩ -
Cyber Unit。「Claude Code Security:企業應了解 Anthropic AI 驅動弱點掃描器的事項。」2026年2月20日。以有限研究預覽形式提供給 Enterprise、Team 與開放原始碼維護者。Anthropic。「Claude Code Security 會掃描程式碼庫中的安全弱點,並建議有針對性的修補程式供人工審查。」 ↩↩
-
GitHub Releases。「v2.1.51(2月24日):
claude remote-control子命令、用於 HTTP hook 安全性的allowedEnvVars、透過沙箱代理的 HTTP hooks、超過 50K 字元的 tool result 磁碟持久化、BashTool 登入 shell 略過、plugin npm registry/版本釘選、/model人類可讀標籤、SDK 呼叫者身分環境變數、statusLine/fileSuggestion工作區信任。」2026年2月24日。Claude Code Docs。「Agent Teams:隊友的計畫核准、TeammateIdle/TaskCompleted 品質 hooks。」 ↩↩↩↩↩↩↩↩↩ -
GitHub Releases。「v2.1.52–v2.1.56(2月24–25日):VS Code Windows 當機修正、UI 閃爍修正、批次 agent 終止彙總通知、Remote Control 過期 session 清理、–worktree 首次啟動修正、Windows 上的 BashTool EINVAL、Windows ARM64/WASM interpreter 當機修正。」2026年2月25日。Claude Code Docs。「團隊設定:~/.claude/teams/{team-name}/config.json。任務清單:~/.claude/tasks/{team-name}/。任務相依性自動解除阻塞。Shift+Down 循環切換隊友(會回到 lead)。」 ↩↩
-
GitHub Releases。「v2.1.59(2月26日):Claude 會自動將有用的 context 儲存到 auto-memory(用 /memory 管理)。/copy command 搭配 code blocks 互動式選擇器。改進複合 bash commands 的『always allow』前綴建議。改善 multi-agent sessions 的記憶體用量。MCP OAuth token refresh 競態條件修正。並行寫入造成的 config file 損毀修正。」2026年2月26日。 ↩↩
-
Anthropic。「Claude Code Remote Control:session mobility 功能,可從手機、平板或瀏覽器繼續本機 sessions。加密通道、原子式 session state transfer。」2026年2月。GitHub Releases。「v2.1.58:將 Remote Control 擴展給更多使用者。」 ↩↩
-
Check Point Research。「CVE-2025-59536:不受信任目錄中的 code injection(v1.0.111 已修正)。CVE-2026-21852:透過 project-load flow 的資訊洩露(v2.0.65 已修正)。」2026年2月。 ↩↩
-
Anthropic/GitHub Statistics。「公開 GitHub commits 中有 4%(約 135,000/日)由 Claude Code 撰寫。13 個月成長 42,896 倍。Anthropic 自家程式碼有 90% 由 AI 撰寫(Dario Amodei,2026年2月)。」2026年2月5日。 ↩↩
-
GitHub Releases。「v2.1.63(2月28日):
/simplify與/batch內建 slash commands、worktree 共用的專案 configs 與 auto-memory、ENABLE_CLAUDEAI_MCP_SERVERS=falseopt-out、HTTP hookstype: httphandler、/copy『Always copy full response』選項、VSCode session 重新命名/移除、/clear重設 skill cache、多項 memory leak 修正、REPL bridge 競態條件修正。」2026年2月28日。 ↩↩↩↩↩↩ -
GitHub Blog。「Claude 與 Codex 現已提供給 Copilot Business 與 Pro 使用者。」2026年2月26日。將 Claude 可用範圍從 Copilot Pro+ 與 Enterprise 擴展到所有付費 Copilot 方案。 ↩↩
-
Claude Code Docs。「在 2.1.63 版中,Task tool 已重新命名為 Agent。settings 與 agent definitions 中既有的
Task(...)參照仍可作為 aliases 使用。」2026年2月28日。 ↩↩ -
GitHub Releases。「v2.1.51:Managed settings——支援 macOS plist 與 Windows Registry 以供企業部署。」2026年2月24日。 ↩↩
-
CNBC。「Figma 與 Anthropic 合作推出整合 Claude Code 的 AI 功能。」2026年2月17日。 ↩↩
-
GitHub Releases。「v2.1.68:Opus 4.6 針對 Max/Team 預設為 medium effort,重新引入 high effort 的 ultrathink,移除 Opus 4/4.1。v2.1.70:修正搭配 ANTHROPIC_BASE_URL 的 API 400 errors、effort parameter errors、ToolSearch 後的空白 responses,改善 compaction 圖片保留,VS Code spark icon 與 MCP 管理。」2026年3月。 ↩↩↩↩↩↩↩↩
-
GitHub Releases。「v2.1.69:/claude-api skill、InstructionsLoaded hook event、hook events 中的 agent_id/agent_type/worktree、${CLAUDE_SKILL_DIR}、/reload-plugins、sandbox.enableWeakerNetworkIsolation、includeGitInstructions setting、remote-control 自訂名稱、Voice STT 10 種新語言(共 20 種)、effort level 顯示、Ctrl+U 離開 bash、numeric keypad 支援、Sonnet 4.5→4.6 自動遷移。70+ 項 bug fixes。」2026年3月5日。 ↩↩↩↩↩↩↩
-
TechCrunch。「Claude Code 推出 voice mode 功能。/voice 會啟用 push-to-talk。逐步推出(初期約 5%)。」2026年3月3日。9to5Mac。「Anthropic 正逐步將 voice mode 加入 Claude Code。」 ↩↩↩↩↩
-
GitHub Releases。「v2.1.71:用於重複 prompts 的 /loop command、voice keybinding 自訂、bash auto-approval allowlist 擴充、stdin freeze 修正、CoreAudio 啟動最佳化。」2026年3月7日。Threads/@boris_cherny。「Claude Code 2.1.0 已發布:/loop、shift+enter 換行、agent/skill frontmatter 中的 hooks。」 ↩↩↩
-
Anthropic Blog。「Claude Code 的 Code Review:Multi-agent PR review system。派送平行 agents、交叉驗證 findings、依嚴重性排序。$15-25/review,約 20 分鐘。54% 的 PR 會收到實質 comments(高於 16%),錯誤率 <1%。Team/Enterprise 研究預覽。」2026年3月9日。TechCrunch。「Anthropic 推出 code review tool。」 ↩↩↩↩↩
-
GitHub Releases。「v2.1.72:搭配 ANTHROPIC_BASE_URL 的 tool search、/copy 中用於 file writes 的 w key、/plan description args、ExitWorktree tool、CLAUDE_CODE_DISABLE_CRON、擴充 bash allowlist(lsof/pgrep/tput/ss/fd/fdfind)、Agent tool 上 restored model、簡化 effort symbols(○/◐/●)、/config 導覽改善、bundle size −510KB、VSCode URI handler。」2026年3月10日。 ↩↩↩↩
-
GitHub Releases。「v2.1.73:用於自訂 provider model IDs(Bedrock/Vertex/Foundry)的
modelOverridessetting。棄用/output-style(請使用/config)。Bedrock/Vertex/Foundry 上的預設 Opus 改為 4.6。中斷後按上方向鍵會還原 prompt + rewind。/effort可在 responding 時運作。SSL certificate error 指引。Bug fixes:CPU freeze、deadlock、SessionStart hooks 觸發兩次。」2026年3月11日。 ↩↩↩ -
GitHub Releases。「v2.1.74:
/context可執行建議。autoMemoryDirectorysetting。--plugin-diroverride 行為變更。CLAUDE_CODE_SESSIONEND_HOOKS_TIMEOUT_MS可設定 timeout。Managed policy enforcement 修正(使用者 allow 繞過 ask rules)。Memory leak 修正(streaming buffers)。RTL 文字呈現修正。MCP OAuth 修正。」2026年3月12日。 ↩↩ -
GitHub Releases。「v2.1.75:Max/Team/Enterprise 的 Opus 4.6 預設 1M context window。所有使用者可用
/colorcommand。Prompt bar 顯示 session name。Memory file last-modified timestamps。Permission prompts 顯示 hook source。Voice mode activation 修正。Piped commands 中 Bash!修正。Token estimation over-counting 修正。macOS 啟動效能改善。Breaking:移除已棄用的 Windows managed settings fallback。」2026年3月13日。 ↩↩↩↩↩ -
GitHub Releases。”v2.1.76:支援MCP elicitation——MCP伺服器可在任務進行中透過互動式對話方塊(表單欄位或瀏覽器URL)要求結構化輸入。新增Elicitation與ElicitationResult hooks。
-n/--nameCLI旗標可用於工作階段顯示名稱。worktree.sparsePaths可在monorepos中使用git sparse-checkout。PostCompact hook。/effortslash command。工作階段品質問卷(feedbackSurveyRate)。錯誤修正:延遲工具在壓縮後遺失輸入schema、plan mode重新核准、voice mode按鍵、自動壓縮斷路器(最多3次嘗試)、在tmux中透過SSH複製剪貼簿、Remote Control工作階段穩定性。”2026年3月14日。 ↩↩↩↩↩↩ -
GitHub CHANGELOG。”v2.1.77:將Opus 4.6預設最大輸出token提高至64K,Opus 4.6與Sonnet 4.6上限提高至128K。
allowRead沙盒檔案系統設定。/copy N會複製第N個最新回應。/fork重新命名為/branch。移除Agent工具的resume參數(請改用SendMessage)。SendMessage會自動恢復已停止的agents。工作階段會依plans自動命名。背景bash任務達5GB時終止。claude plugin validate會檢查frontmatter與hooks。macOS啟動快約60ms,--resume快45%,記憶體少用約100-150MB。安全性:PreToolUse的allow不再繞過deny規則。25項以上錯誤修正。”2026年3月17日。 ↩↩↩↩↩ -
GitHub Releases v2.1.78。”v2.1.78:
StopFailurehook事件、${CLAUDE_PLUGIN_DATA}持久化plugin狀態、agent frontmatter(effort/maxTurns/disallowedTools)、ANTHROPIC_CUSTOM_MODEL_OPTION、tmux通知傳遞、逐行回應串流。安全性:缺少沙盒相依項目時顯示警告。修正:大型工作階段截斷>5MB、無限stop hook迴圈、沙盒絕對路徑、voice WSL2、VS Code中的Homebrew PATH。”2026年3月17日。 ↩↩↩ -
GitHub Releases v2.1.79。”v2.1.79:用於API計費驗證的
--console旗標、/remote-controlVS Code命令、VS Code中由AI產生的工作階段標題、CLAUDE_CODE_PLUGIN_SEED_DIR多個目錄、啟動記憶體減少約18MB、2分鐘非串流API逾時、SessionEnd hooks會在/resume切換時觸發。修正:-p作為子程序時卡住、print mode中的Ctrl+C、/btw輸出錯誤、voice mode啟動、enterprise 429重試。”2026年3月18日。 ↩↩ -
GitHub Releases v2.1.80。”v2.1.80:statusline scripts中的
rate_limits欄位、source: 'settings'plugin marketplace來源、skills的effort frontmatter。Claude Code Channels研究預覽:透過channel server plugins與--channels旗標,將Telegram/Discord訊息傳入工作階段。修正Git Bash的Windows PATH繼承。”2026年3月19日。 ↩↩↩ -
GitHub Releases v2.1.83。”v2.1.83:managed-settings.d/ drop-in目錄、CwdChanged/FileChanged hook事件、sandbox.failIfUnavailable、CLAUDE_CODE_SUBPROCESS_ENV_SCRUB=1、transcript搜尋、initialPrompt agent frontmatter、Ctrl+X Ctrl+E外部編輯器別名、stop-all-agents改為Ctrl+X Ctrl+K、TaskOutput已棄用。35項以上錯誤修正。”2026年3月25日。 ↩↩
-
Claude Code的Auto mode。Anthropic,2026年3月24日。Auto Mode:以分類器為基礎的權限系統,由獨立的Sonnet 4.6模型在執行前審查每個動作。是比–dangerously-skip-permissions更安全的替代方案。Team方案率先推出,Enterprise與API隨後跟進。 ↩↩↩
-
Claude Code Auto Mode Documentation。Auto Mode架構:唯讀與工作目錄編輯會自動核准,自訂規則會優先解析,分類器評估其餘動作。自動封鎖:curl|bash、force-push main、生產環境部署、大量雲端刪除、IAM變更、外部資料外洩。斷路器:連續3次或總計20次封鎖後,會暫停並切換為手動。 ↩↩↩
-
GitHub Releases v2.1.89。”v2.1.89:延後headless工作階段的權限決策、MCP_CONNECTION_NONBLOCKING=true、自動壓縮thrash loop偵測、Bash過期編輯警告、可感知symlink的allow規則。合併所有v2.1.88修正。”2026年3月31日。 ↩
-
GitHub Releases v2.1.88。”v2.1.88:PermissionDenied hook、CLAUDE_CODE_NO_FLICKER=1、@ typeahead中的具名subagents、thinking summaries預設關閉、/btw可捲動viewport。修正:prompt cache miss、巢狀CLAUDE.md重新注入、StructuredOutput 50%失敗率、CJK/emoji歷史記錄、35項以上錯誤修正。”2026年3月30日。 ↩↩↩
-
Boris如何使用Claude Code。Boris Cherny(Claude Code建立者),2026年3月。72項以上技巧,涵蓋/dream記憶整合、/batch平行遷移、/schedule雲端作業、/btw側邊查詢、worktrees、自訂agents、auto mode,以及進階工作流程。 ↩↩
-
GitHub Releases v2.1.86。”v2.1.86:X-Claude-Code-Session-Id header、Read工具compact格式、auto mode plan訊息、skill描述上限、@ mention token減量、Jujutsu/Sapling排除、修正2.1.85之前工作階段的–resume、15項以上錯誤修正。”2026年3月27日。v2.1.87(3月28日):Cowork Dispatch訊息傳遞修正。 ↩
-
GitHub Releases v2.1.85。”v2.1.85:hooks的條件式
if欄位、PreToolUse hooks滿足AskUserQuestion、headersHelper的MCP環境變數、MCP OAuth RFC 9728、隱藏組織封鎖的plugins、/loop的timestamp markers、deep link查詢5K字元、修正過大對話的/compact。20項以上錯誤修正。”2026年3月26日。 ↩↩ -
GitHub Releases v2.1.84。”v2.1.84:PowerShell工具(Windows opt-in)、TaskCreated hook事件、WorktreeCreate HTTP hook支援、ANTHROPIC_DEFAULT模型能力環境變數、CLAUDE_STREAM_IDLE_TIMEOUT_MS、allowedChannelPlugins受管理設定、paths:rules/skills中的YAML glob list、MCP 2KB描述上限、閒置75分鐘以上後的idle-return prompt、token計數1.5m格式、CJK IME修正。25項以上錯誤修正。”2026年3月26日。 ↩↩
-
GitHub Releases v2.1.81。”v2.1.81:用於scripted
-p呼叫的--bare旗標(略過hooks、LSP、plugin sync、skill directory walks)。channel servers的--channels權限轉送。Assistant會尊重「no memory」要求。”2026年3月20日。 ↩↩ -
Claude Code Source Analysis: Bun Source Map Leak。2026年3月。由於已知的Bun建置錯誤,npm套件在production中發布source maps,導致完整可讀原始碼透過
.map檔案外洩。社群分析涵蓋yoloClassifier.ts(1,495行)、bashSecurity.ts(2,592行,23項檢查)、autocompact斷路器(每天浪費250K次API呼叫)、透過regex進行挫折偵測,以及companion pet system。 ↩↩↩↩↩ -
Claude Code Source Deep Dive: Architecture Internals。2026年3月。技術分析涵蓋coordinator mode(由system-prompt驅動的multi-agent orchestration)、prompt cache break偵測(14個向量搭配sticky latches)、反蒸餾防禦(fake tool injection、connector-text summarization)、用於隱藏codename的undercover mode、KAIROS自主agent原型,以及透過Bun的Zig HTTP stack進行native client attestation。 ↩↩↩↩
-
GitHub Releases v2.1.90。”v2.1.90:
/powerup互動式課程、auto mode尊重明確使用者界線、--resumeprompt cache regression修正、PreToolUse JSON stdout exit-2修正、PostToolUse format-on-save修正、PowerShell安全強化(4個向量)、SSE線性時間串流、transcript寫入效能、DNS cache隱私。”2026年4月1日。 ↩↩ -
GitHub Releases v2.1.91。”v2.1.91:MCP
_meta[\"anthropic/maxResultSizeChars\"]最高500K、disableSkillShellExecution設定、pluginbin/可執行檔、多行deep link prompts、Edit工具較短的old_stringanchors、改良的/claude-apiskill、transcript chain break修正。”2026年4月2日。 ↩↩↩ -
GitHub Releases v2.1.92。”v2.1.92:
forceRemoteSettingsRefreshfail-closed政策、互動式Bedrock設定精靈、依模型與cache-hit細分的/cost明細、/release-notes互動式選擇器、Remote Control hostname prefix、prompt cache到期footer提示、移除/tag與/vim、Linux沙盒apply-seccomphelper、Write工具對大型檔案的diff快60%。”2026年4月4日。 ↩↩↩↩↩↩↩↩ -
Claude Code Buddy terminal pet。2026年4月1日。
/buddy指令會啟動 Tamagotchi 風格的 ASCII 夥伴寵物。共有18種物種(duck、goose、cat、rabbit、owl、penguin、turtle、snail、dragon、octopus、axolotl、ghost、robot、blob、cactus、mushroom、chonk、capybara)。5個稀有度等級。5項屬性(DEBUGGING、PATIENCE、CHAOS、WISDOM、SNARK)。依帳戶 ID 雜湊(Mulberry32)決定,具確定性。需要 Pro 訂閱。最初是在原始碼外洩中被發現,並於4月1日正式推出。 ↩↩ -
Claude Mythos Preview — Project Glasswing。Anthropic,2026年4月7日。超越 Opus 4.6 的新 frontier model。僅限 Project Glasswing 合作夥伴(Apple、Amazon、Microsoft、Google、Linux Foundation 等)用於防禦性網路安全。發現數千個高/重大嚴重性的 zero-days,包含存在27年的 OpenBSD TCP SACK bug、存在16年的 FFmpeg H.264 漏洞、FreeBSD NFS RCE(CVE-2026-4747)。透過 Claude Code 在隔離容器中執行。提供1億美元使用額度,並投入400萬美元給 open-source security。由 Nicholas Carlini 領導。尚未普遍開放;未來規劃推出面向安全專業人士的「Cyber Verification Program」。另請參閱:TechCrunch、VentureBeat、Simon Willison。 ↩↩
-
GitHub Releases v2.1.94。「v2.1.94:透過 Mantle 使用 Bedrock(
CLAUDE_CODE_USE_MANTLE=1)、API/Bedrock/Vertex/Foundry/Team/Enterprise 的預設 effort level 從 medium 改為 high、精簡 Slack MCP header、UserPromptSubmit hooks 的hookSpecificOutput.sessionTitle、從 frontmatter 讀取 plugin skill name、顯示 429 rate-limit、macOS keychain 登入修正、plugin hook 修正、scrollback/rendering 修正。」2026年4月7日。v2.1.96(4月8日):Bedrock auth regression hotfix。 ↩↩↩ -
GitHub Releases v2.1.97。「v2.1.97:修正
--dangerously-skip-permissions在 protected path write 後靜默降級為 accept-edits。修正 MCP HTTP/SSE 連線在重新連線時每小時洩漏約50 MB。修正 429 retries 在約13秒內耗盡所有嘗試。NO_FLICKER mode 的 focus view toggle(Ctrl+O)。refreshIntervalstatus line setting。Cedar syntax highlighting。25項以上 bug fixes。」2026年4月8日。 ↩ -
GitHub Releases v2.1.98。「v2.1.98:Google Vertex AI setup wizard、
CLAUDE_CODE_PERFORCE_MODE、用於 background scripts 的 Monitor tool、--exclude-dynamic-system-prompt-sections、CLAUDE_CODE_SUBPROCESS_ENV_SCRUBPID namespace isolation、CLAUDE_CODE_SCRIPT_CAPSlimit。Bash security fixes:反斜線跳脫 flag bypass、compound command bypass、env-var prefix auto-allow、阻擋 /dev/tcp 與 /dev/udp redirect。」2026年4月9日。 ↩↩ -
GitHub Releases v2.1.101。「v2.1.101:
/team-onboarding指令、預設信任 OS CA certificate store(可用CLAUDE_CODE_CERT_STORE=bundled覆寫)、/ultraplan自動建立 cloud environment、改進 brief mode retry、改進 focus mode summaries、rate-limit retry 會顯示是哪個限制與 reset time、settings 對無法辨識的 hook events 更具韌性。」2026年4月10日。 ↩↩↩ -
Introducing Claude Opus 4.7。Anthropic,2026年4月16日。新的 flagship model。定價:每 MTok $5/$25(與 Opus 4.6 相同)。Model ID:
claude-opus-4-7。可用於 Claude products、API、Amazon Bedrock、Google Cloud Vertex AI 與 Microsoft Foundry。SWE-Bench:解決的 production tasks 為 Opus 4.6 的3倍。CursorBench:70%,相較於4.6的58%。另請參閱Claude model pricing。 ↩↩↩↩↩↩↩ -
What’s new in Claude Opus 4.7。Anthropic platform docs。1M token context 採標準 API 定價,無 long-context premium。128K max output。破壞性變更:extended thinking 的
budget_tokens已移除(僅 adaptive thinking)、temperature/top_p/top_k若為非預設值會回傳 400、預設省略 thinking content。新 tokenizer(約1×–1.35× token counts)。新的xhigheffort level。Task budgets beta(headertask-budgets-2026-03-13)。Vision:2,576 px / 3.75 MP,採1:1 pixel coordinates。 ↩↩↩↩↩↩↩↩ -
Claude Code CHANGELOG。v2.1.105 至 v2.1.112 的主要來源。v2.1.105(PreCompact hooks 可阻擋、
monitorsplugin manifest、EnterWorktreepath arg、/proactivealias、skill description cap 提高至1536)。v2.1.107(thinking hint timing)。v2.1.108(ENABLE_PROMPT_CACHING_1H、Session Recap//recap、model 可透過 Skill tool 呼叫內建 slash commands、/undoalias、/modelconversation 中途警告)。v2.1.109(extended-thinking indicator)。v2.1.110(/tui//tui fullscreen、Remote Control 的 push notifications tool、/focus從Ctrl+O分離、autoScrollEnabled、--resume/--continue會復原 scheduled tasks、Remote Control clients 可使用/context//exit//reload-plugins、Session Recap 支援 telemetry-disabled users、TRACEPARENT/TRACESTATEdistributed tracing、Write tool 會在使用者編輯 diff 時通知 model、針對 PermissionRequest hooks 與 open-in-editor 的 security hardening)。v2.1.111(Opus 4.7 launch support、xhigheffort、/effortinteractive slider、Max 無需 flag 即可使用 Auto Mode、/less-permission-prompts、/ultrareview、「Auto (match terminal)」theme、透過CLAUDE_CODE_USE_POWERSHELL_TOOL使用 Windows PowerShell tool、以 glob patterns 降低 read-only Bash permission、/setup-vertex與/setup-bedrock改進、OTEL_LOG_RAW_API_BODIES)。v2.1.112(修正 Opus 4.7 在 Auto Mode 中「temporarily unavailable」的 hotfix)。另請參閱:GitHub blog on Opus 4.7 GA、Cyber Verification Program form。 ↩↩↩↩↩↩↩↩↩↩↩↩ -
Claude Code — Model Configuration。各方案預設值的權威來源(Max/Team Premium → Opus 4.7;Pro/Team Standard/Enterprise/API → Sonnet 4.6;Bedrock/Vertex/Foundry → Sonnet 4.5;Enterprise + API 於2026年4月23日改為 Opus 4.7)。涵蓋
/effortlevels(Opus 4.7 可用low/medium/high/xhigh/max;Opus 4.6 與 Sonnet 4.6 可用low/medium/high/max)、effort fallback behavior、adaptive reasoning(Opus 4.7 僅使用 adaptive;CLAUDE_CODE_DISABLE_ADAPTIVE_THINKING=1會讓4.6回復固定 budgets),以及各方案 extended context rules(Max/Team/Enterprise:包含 Opus 1M;Pro:透過 extra usage;API:完整存取)。Opus 4.7 需要 Claude Code v2.1.111+。 ↩↩↩↩↩↩↩↩↩↩↩↩↩ -
Anthropic — Pricing。權威定價參考(2026年4月)。Base input/output rates:Opus 4.7 與4.6 為每 MTok $5/$25;Sonnet 4.6 為 $3/$15;Haiku 4.5 為 $1/$5。Prompt caching multipliers:5-min cache write 1.25×、1-hour cache write 2×、cache hit 為 base input price 的0.1×。Long-context:「Claude Mythos Preview、Opus 4.7、Opus 4.6、Sonnet 4.6 均以標準定價包含完整 1M token context window」——任何 current-generation model 都沒有 long-context premium。Data residency(
inference_geo="us"):Opus 4.6 及更新模型的所有 token categories 套用1.1× multiplier。Batch API:50% discount。 ↩↩↩ -
Claude Code — Fast Mode。Research-preview feature。僅限 Opus 4.6——「Fast mode is not available on Opus 4.7 or other models.」提供約2.5×更快輸出,價格為 base pricing 的6×(每 MTok $30 input / $150 output)。啟用
/fast會自動將 session 切換到 Opus 4.6;停用後 session 仍留在 Opus 4.6。不適用於 Bedrock/Vertex/Foundry。需要 extra usage;Team/Enterprise 需要 admin enablement。可用CLAUDE_CODE_DISABLE_FAST_MODE=1完全停用。 ↩↩↩ -
Claude Code CHANGELOG。v2.1.113(2026年4月17日):CLI改為透過各平台的選用相依套件啟動原生Claude Code二進位檔,而非內建JavaScript;即使
allowedDomains萬用字元原本會允許,sandbox.network.deniedDomains仍會封鎖特定網域;全螢幕下以Shift+↑/Shift+↓將選取範圍延伸到可見邊緣之外時,會捲動視窗;多行輸入中,Ctrl+A/Ctrl+E會移到目前邏輯行的開頭/結尾(readline風格);Windows的Ctrl+Backspace會刪除前一個字;/loop中的Esc會取消待處理的喚醒,並顯示「Claude resuming /loop wakeup」訊息;/extra-usage現在可從Remote Control(行動裝置/網頁)用戶端使用;/ultrareview透過平行化檢查、更快啟動,啟動對話框加入diffstat,並提供啟動動畫狀態;串流中途停滯的subagents會在10分鐘後以明確錯誤失敗;第一行是註解的Bash多行命令,會在逐字稿中顯示完整命令(修正UI偽裝);cd <current-directory> && git …在無動作時不再提示;macOS的Bash(rm:*)允許規則會將/private/{etc,var,tmp,home}視為危險刪除目標;Bash拒絕規則會比對包在env/sudo/watch/ionice/setsid及類似包裝器中的命令;Bash(find:*)允許規則不再自動核准find -exec/-delete;透過Bedrock Application Inference Profile ARN使用Opus 4.7時,不再回傳thinking.type.enabled is not supported400;另修正MCP並行呼叫逾時處理、含有管線字元內嵌程式碼的markdown表格、撰寫期間自動觸發工作階段回顧、Remote Control subagent串流與封存、SDK圖片區塊失敗時降級為文字,以及dangerouslyDisableSandbox略過權限提示等問題。v2.1.114(2026年4月18日):單一修正,解決agent-teams隊友要求工具權限時,權限對話框發生當機的問題。 ↩↩↩↩↩↩↩ -
Codex vs Claude Code基準測試與能力來源(2026年4月)。 Opus 4.7數據來自Anthropic: Introducing Claude Opus 4.7:87.6% SWE-bench Verified、64.3% SWE-bench Pro、69.4% Terminal-Bench 2.0。GPT-5.4規格來自OpenAI GPT-5.4 model docs:2026年3月5日發布(快照
gpt-5.4-2026-03-05)、272K預設上下文/1.05M長上下文模式、128K最大輸出、每MTok $2.50輸入/$0.25快取/$15輸出,超過272K輸入時長上下文倍率為2×/1.5×。GPT-5.4官方程式碼基準測試來自Introducing GPT-5.4:57.7% SWE-bench Pro、75.1% Terminal-Bench 2.0;官方頁面未發布SWE-bench Verified。GPT-5-Codex基準SWE-bench Verified 74.9%來自OpenAI原始Codex發布素材。GPT-5.2-Codex與GPT-5.3-Codex數據來自OpenAI: Introducing GPT-5.3-Codex:GPT-5.2-Codex為56.4% SWE-bench Pro / 64.0% Terminal-Bench 2.0;GPT-5.3-Codex為56.8% SWE-bench Pro / 77.3% Terminal-Bench 2.0。GPT-5.2-Codex上下文視窗(400K / 128K最大輸出)來自OpenAI model docs for gpt-5.2-codex。Codex CLI執行模型(預設在本機)來自OpenAI Codex CLI help;Codex Cloud容器沙盒則是另一套機制。Claude Code指令檔(CLAUDE.md+CLAUDE.local.md,不支援AGENTS.md)來自Anthropic memory docs。競品比較格式則交叉參照Builder.io: Codex vs Claude Code與DataCamp: Codex vs Claude Code。 ↩↩↩ -
Claude Code CHANGELOG — v2.1.116(2026年4月20日)、v2.1.117(2026年4月22日)、v2.1.118(2026年4月23日)與v2.1.119(2026年4月23日)的綜合參考。v2.1.116:
/resume在40MB以上工作階段快67%;多個stdio伺服器的MCP啟動更快(resources/templates/list延後到第一次@提及);行內思考spinner(「still thinking」、「thinking more」、「almost done thinking」);/config搜尋現在會比對選項值;/doctor可在一輪對話中開啟;plugin自動安裝缺少的相依套件;Bash工具顯示ghGitHub API速率限制提示;Settings Usage分頁會立即顯示,且在用量端點受速率限制時仍可保留;透過--agent作為主執行緒agent執行時,agent frontmatter的hooks:會觸發;安全性修正 — sandbox自動允許不再略過危險路徑檢查,適用於目標為/、$HOME或其他關鍵根目錄的rm/rmdir。(v2.1.116還原的4月16日系統提示詳細度限制,記錄於153的事後檢討,而非v2.1.116發行說明。)v2.1.117:外部建置的分叉subagents使用CLAUDE_CODE_FORK_SUBAGENT=1;透過--agent啟動主執行緒agent工作階段時,會載入agent frontmatter的mcpServers;即使專案釘選不同模型,/model選項也會在重新啟動後保留,且啟動標頭會顯示釘選來源;/resume提供過期工作階段摘要;預設並行啟動MCP(本機+claude.ai);plugin安裝/更新/重新整理/自動更新時會強制執行blockedMarketplaces/strictKnownMarketplaces;Advisor Tool實驗功能,包含標籤、深入了解連結、啟用時的啟動通知;cleanupPeriodDays保留清理涵蓋~/.claude/tasks/、~/.claude/shell-snapshots/、~/.claude/backups/;OTeluser_prompt事件包含command_name/command_source(自訂/MCP名稱會遮蔽,除非設定OTEL_LOG_TOOL_DETAILS=1);cost.usage/token.usage/api_request/api_error包含effort屬性;原生macOS/Linux建置會透過Bash工具,以內嵌bfs/ugrep取代Glob/Grep;Pro/Max在Sonnet 4.6與Opus 4.6上的預設effort現在為high(原為medium);修正 — Opus 4.7工作階段原本會以200K視窗計算/context,而非原生1M,導致過早自動壓縮。v2.1.118:vim視覺模式(v)與視覺行模式(V),支援選取、運算子與視覺回饋;/cost與/stats合併為/usage(保留輸入捷徑);透過/theme或~/.claude/themes/*.json使用具名佈景主題(plugins可提供themes/目錄);hooks透過type: "mcp_tool"直接叫用MCP工具;DISABLE_UPDATES環境變數會封鎖所有更新路徑,包括手動claude update(比DISABLE_AUTOUPDATER更嚴格);WSL透過wslInheritsWindowsSettings政策繼承Windows端受管理設定;autoMode.allow/soft_deny/environment中的$defaults哨兵值,會在內建清單旁加入自訂規則;「Don’t ask again」自動模式加入選項;claude plugin tag會建立發行版git標籤,並驗證版本。v2.1.119:/config設定(佈景主題、編輯器模式、詳細模式)會依專案/本機/政策優先順序保存到~/.claude/settings.json;prUrlTemplate設定會讓頁尾PR徽章指向自訂程式碼審查URL,而非github.com;CLAUDE_CODE_HIDE_CWD會在啟動標誌中隱藏工作目錄;--from-pr接受GitLab MR、Bitbucket PR、GitHub Enterprise PR URL;--print遵循agenttools:/disallowedTools:frontmatter;--agent <name>遵循內建agents的permissionMode;PowerShell工具命令會在權限模式中自動核准(與Bash一致);PostToolUse/PostToolUseFailurehook輸入包含duration_ms(工具執行時間,不含權限提示與PreToolUse hooks);subagent與SDK MCP伺服器重新設定會平行連線伺服器;安全性 —blockedMarketplaces會正確強制套用hostPattern與pathPattern項目;OTeltool_result與tool_decision事件包含tool_use_id;tool_result包含tool_input_size_bytes;狀態列stdin JSON包含effort.level與thinking.enabled;Vertex AI預設停用工具搜尋(可用ENABLE_TOOL_SEARCH選擇加入)。 ↩↩↩↩↩↩↩↩↩↩↩↩↩↩ -
近期 Claude Code 品質報告更新。Anthropic 工程事後檢討,2026年4月23日。涵蓋3個已於4月20日(v2.1.116)前解決的獨立品質退化問題,並於4月23日重設所有訂閱者的使用限制:(1)推理投入預設值——為降低 UI 凍結,於2026年3月4日從
high改為medium;在操作人員回饋使用者較偏好更高智慧而非 UI 順暢度後,於4月7日還原。影響 Sonnet 4.6 和 Opus 4.6。(2)Prompt 快取 thinking 清除錯誤——原本用於在每個閒置工作階段清除一次 thinking 內容的快取最佳化,卻在該工作階段其後每一輪都清除,造成健忘、重複,以及更快耗盡使用限制。3月26日至4月10日期間生效,已於 v2.1.101 修復。影響 Sonnet 4.6 和 Opus 4.6。(3)系統 prompt 冗長度限制——4月16日新增,用於處理 Opus 4.7 話多的問題;根據 Anthropic,約 3% 的程式碼品質下降是在 Opus 4.6 和 Opus 4.7 上量測到的(Sonnet 4.6 也受影響,但下降幅度較小);已於4月20日在 v2.1.116 中還原。Anthropic 聲明的緩解措施包括:擴大發布前評估套件、更嚴格的系統 prompt 變更控管、對影響智慧表現的變更強制進行程式碼審查,以及逐步推出。 ↩↩↩↩ -
Claude Code release notes——v2.1.121(2026年4月28日,00:31 UTC)與 v2.1.122(2026年4月28日,22:05 UTC)的複合參考。v2.1.121:
alwaysLoadMCP 伺服器設定選項(略過工具搜尋延遲);MCP 啟動時自動重試 3 次;claude plugin prune和--prune串級清理;/skills可輸入篩選;PostToolUsehookSpecificOutput.updatedToolOutput從僅限 MCP 擴充至所有工具;.claude/skills/、.claude/agents/、.claude/commands/免於--dangerously-skip-permissions提示;Vertex AI 以 X.509 憑證為基礎的 Workload Identity Federation(mTLS ADC);SDKmcp_authenticateredirectUri;OTel 將stop_reason、gen_ai.response.finish_reasons和user_system_prompt(受OTEL_LOG_USER_PROMPTS閘控)新增至 LLM 要求 span;/terminal-setup啟用 iTerm2 剪貼簿存取,以便從 tmux 使用/copy;language設定中的分頁標題;CLAUDE_CODE_FORK_SUBAGENT=1擴充至非互動式claude -p;升級後啟動更快(release-notes 啟動畫面移除 Recent Activity 面板);claude.ai connector 會依相同上游 URL 去重。v2.1.122:ANTHROPIC_BEDROCK_SERVICE_TIER環境變數(default/flex/priority)會作為X-Amzn-Bedrock-Service-Tier傳送;/resume可跨 GitHub、GHE、GitLab、Bitbucket 搜尋 PR URL;/mcp顯示隱藏 connector,提供移除重複項目的提示,並釐清瀏覽器後未授權訊息;OTelclaude_code.at_mention記錄事件用於@提及解析;api_request/api_error上的數值屬性會以數字送出(先前為字串)。兩版的高訊號修復包括:/usage中約 2GB 的記憶體洩漏、影像密集工作階段造成多 GB RSS 成長、--resume略過損毀逐字稿行與大型外部建置工作階段當機修復、CWD 被刪除/移動時的 Bash 復原、Bedrock application-inference-profile 上 thinking 修復、Vertex/Bedrock 在結構化輸出時因output_config額外輸入遭拒、ToolSearch 遺漏工作階段開始後才連線的非阻塞 MCP 工具、較新模型上的影像調整大小上限由 2576 降至 2000 px、bash 模式中的!exit/!quit不再終止 CLI、tmux/GNOME/Windows Terminal/Konsole 上的 scrollback 重複、格式錯誤的hooks項目不再使整個settings.json失效。 ↩↩↩↩↩↩↩↩↩↩↩↩ -
Claude Code v2.1.123 release notes。2026年4月29日,03:29 UTC。單一錯誤修復:「修正設定
CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1時,OAuth 驗證因 401 重試迴圈而失敗的問題。」 ↩ -
2026年5月6日最新版本線的複合驗證:Claude Code v2.1.126 release notes、Claude Code v2.1.128 release notes、Claude Code v2.1.129 release notes、Claude Code v2.1.131 release notes、Claude Code CHANGELOG,以及
@anthropic-ai/claude-code的 NPM 套件中繼資料。v2.1.126 新增/model的閘道模型探索、claude project purge、OAuth 程式碼貼上後援、skill 啟用 OTel、Windows 上的 PowerShell 主要 shell 行為,並變更--dangerously-skip-permissions受保護路徑提示。v2.1.128 為--plugin-dir新增 zip 支援、MCP 工具數量與零工具可見性、console-auth--channels,修正EnterWorktree,並修復 plugin/cache/MCP/工作階段問題。v2.1.129 新增--plugin-url、CLAUDE_CODE_FORCE_SYNC_OUTPUT、CLAUDE_CODE_PACKAGE_MANAGER_AUTO_UPDATE、skillOverrides、透過CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY=1選擇啟用的閘道模型探索,以及 plugin manifestthemes/monitors驗證警告。v2.1.131 修復 Windows 上 VS Code 擴充功能啟用與 Mantle endpoint 驗證;release notes 未宣布額外命令或設定新增項目。 ↩↩↩↩↩ -
Claude 更高使用限制,以及與 SpaceX 的算力交易。Anthropic,2026年5月6日。3項變更:(1)Claude Code 對 Pro、Max、Team 和按席次計價的 Enterprise 方案之 5 小時速率限制加倍;(2)移除 Pro 和 Max Claude Code 帳戶的尖峰時段降額;(3)Claude Opus 模型的 API 速率限制「大幅」提高,公告頁面提供各層級表格。算力後盾:Anthropic 取得「其 Colossus 1 資料中心的全部算力容量」——「當月內新增超過 300 百萬瓦容量(超過 220,000 個 NVIDIA GPU)」。Anthropic 也表達有興趣與 SpaceX 開發「多 GW 等級的軌道 AI 算力容量」。 ↩↩
-
金融服務 Agents。Anthropic,2026年5月5日。10 個可立即執行的 agent 範本:pitch builder、earnings reviewer、KYC screener、month-end closer,以及另外 6 個。每個都以 plugin 形式隨 Claude Cowork 和 Claude Code 提供,也以 cookbook 形式提供給 Claude Managed Agents。Microsoft 365 add-ins:Excel、PowerPoint 和 Word 中的 Claude,具備跨應用程式情境;Outlook 整合即將推出。資料 connector 合作夥伴包括 Dun & Bradstreet、Fiscal AI、Financial Modeling Prep、Guidepoint、IBISWorld、SS&C IntraLinks、Third Bridge 和 Verisk。Moody’s MCP app:提供超過 6 億家公司信用評等與資料,可在 Claude 內存取。Claude Cowork Dispatch:供分析師透過語音與文字指派任務。Opus 4.7 在 Vals AI Finance Agent benchmark 中被引用的成績為 64.37%。 ↩↩
-
Claude Code v2.1.132 release notes。2026年5月6日。將
CLAUDE_CODE_SESSION_ID環境變數新增至 Bash 工具子處理程序(與傳給 hooks 的session_id相符)。新增CLAUDE_CODE_DISABLE_ALTERNATE_SCREEN=1環境變數,可選擇停用全螢幕 alternate-screen renderer,並將對話保留在終端機原生 scrollback 中。更新/tui fullscreen啟動橫幅,以描述額外 renderer 優點(較低記憶體用量、滑鼠支援、選取時自動複製)。另有 20 多項修復,涵蓋終端機/輸入處理(SIGINT、SSH 中斷連線、終端機模式、游標定位)、文字編輯與貼上(emoji 與 grapheme 損毀、vim operators、escape sequences、貼上內容以/開頭後文字遭吞掉)、UI/算繪(睡眠後全螢幕空白、捲動速度、滑鼠滾輪處理、自動完成彈出視窗)、工作階段管理(--resume失敗、emoji 截斷、plan-mode--permission-mode旗標)、命令工具(/usage、/terminal-setup、/effort、/status、/login、/upgrade)、MCP 伺服器整合(工具擷取、授權顯示、非協定資料、stdio MCP 伺服器中的無界限記憶體成長、tools/list重試)、平台特定問題(Windows Terminal、JetBrains IDE、macOS 鍵盤、X11 Linux),以及設定ENABLE_PROMPT_CACHING_1H時 Bedrock+Vertex 的 400 錯誤。 ↩↩↩ -
Claude Code v2.1.133 發行說明。2026年5月7日。新增
worktree.baseRef設定(fresh|head)——且依發行說明所述:「預設的fresh會將EnterWorktree的 base 改回origin/<default>(自 2.1.128 起原本是本機HEAD)——設定worktree.baseRef: \"head\",即可在新 worktrees 中保留尚未 push 的 commit。」hooks 現在會透過effort.levelJSON 輸入欄位與$CLAUDE_EFFORT環境變數接收目前作用中的 effort level;Bash tool 命令也可以讀取$CLAUDE_EFFORT。新增sandbox.bwrapPath與sandbox.socatPath受管理設定(Linux/WSL),用於自訂 bubblewrap 與 socat binary 位置。新增parentSettingsBehavior管理員層級 key('first-wins' | 'merge'),可選擇將 SDKmanagedSettings(父層級)納入 policy merge。修正 subagents 無法透過Skilltool 發現專案、使用者或 plugin skills 的問題。其他修正:平行 session 在 refresh token 後發生 401 的競態、drive-root allow-rule 作用範圍、MCP OAuth proxy 與 mTLS 支援、Remote Control stop/interrupt 完成取消、跨 session/effort洩漏、--remote-control已列於--help。 ↩↩↩↩↩↩↩ -
在 Excel、PowerPoint、Word 和 Outlook 中與 Claude 協作。Anthropic,2026年5月7日。Excel、PowerPoint 與 Word 版 Claude 已正式推出;Outlook 版 Claude 則對所有付費方案開放 public beta。跨應用程式反應能力(「在 Excel 調整假設,PowerPoint 中的圖表與 Word 備忘錄中的數字也會自動更新」)。Outlook 新增收件匣分類(「Claude……會依需要您回覆的郵件、可代您草擬的郵件,以及雜訊郵件進行分類」)。所有付費方案的 Mac 與 Windows 使用者皆可使用。 ↩↩↩↩↩↩
-
Claude Code v2.1.137 至 v2.1.139 發行說明。v2.1.137(2026年5月9日):「[VSCode] 修正 extension 在 Windows 上無法啟用的問題。」v2.1.138(2026年5月9日):「內部修正。」v2.1.139(2026年5月11日):Agent View(
claude agents)、/goal、command-hookargs: string[]、PostToolUse的continueOnBlock、供 MCP stdio servers 使用的CLAUDE_PROJECT_DIR、plugin commands 中的${CLAUDE_PROJECT_DIR}插值、--print中的 OpenTelemetry active-time 修正,以及相關可靠性修正。另請參閱:Agent View docs 與 Goal docs。 ↩↩↩↩ -
Claude Code v2.1.140 發行說明。2026年5月12日。將
subagent_type新增至 agent hook 輸入,並修正:ConfigChangehooks 對設定變更未觸發;未設定其他設定時,disableAllHooks無法停用 hooks;allowManagedHooksOnly與disableAllHooks無法在不同設定層級正確組合;hooks 回傳結果時,權限對話框意外顯示環境變數;設定更新後自訂樣式被重設;Windows Git Bash 的 native package resolution fallback;以及/scroll-speed未生效。 ↩↩ -
Claude Code v2.1.141 發行說明。2026年5月13日。新增 hook JSON 輸出的
terminalSequence,用於桌面通知、視窗標題與提示鈴聲;新增CLAUDE_CODE_PLUGIN_PREFER_HTTPS,用於 HTTPS plugin-source cloning;新增ANTHROPIC_WORKSPACE_ID,用於 workload identity federation workspace scoping;新增claude agents --cwd <path>,用於 Agent View 目錄篩選;並新增/feedbacksession 附件選項,可附上最近 24 小時或 7 天。2026年5月14日的目前 session 驗證:claude --version回傳2.1.141 (Claude Code),且npm view @anthropic-ai/claude-code version dist-tags.latest time.modified --json回傳 latest2.1.141。 ↩↩ -
Claude Code v2.1.142 發行說明與Claude Code CHANGELOG。2026年5月14日。為
claude agents新增 background-session 設定 flags;將 Fast mode 預設切換為 Opus 4.7,並以CLAUDE_CODE_OPUS_4_6_FAST_MODE_OVERRIDE=1作為固定版本 override;當不存在skills/目錄時,將根層級 pluginSKILL.md檔案作為 skills 呈現;在 plugin 詳細資料中顯示 plugin 提供的 LSP servers;在/web-setup中取代既有 GitHub App 連線前提出警告;修正遠端 HTTP/SSE MCP servers 的MCP_TOOL_TIMEOUT;並解決 background-session、daemon、Agent View、plugin cache、plugin advisory 與 reactive-compaction 的可靠性問題。2026年5月15日的目前 session 驗證:claude --version回傳2.1.141 (Claude Code),且npm view @anthropic-ai/claude-code version dist-tags.latest time.modified --json回傳 latest2.1.142,time.modified為2026-05-14T22:54:49.491Z。 ↩↩ -
Claude Code v2.1.143 發行說明、Claude Code changelog與Claude Code CHANGELOG。2026年5月15日。新增 plugin dependency enforcement、預估 plugin context cost、
worktree.bgIsolation: "none"、Agent View dispatch flag 一致性、PowerShell policy 行為,以及 stop-hook 迴圈、/goalevaluator timing、background sessions、credentials startup、Agent View、color env handling 與 plugin-contributed agents 的可靠性修正。2026年5月18日的目前 session 驗證:claude --version回傳2.1.142 (Claude Code),且npm view @anthropic-ai/claude-code version dist-tags.latest time.modified --json回傳 latest2.1.143,time.modified為2026-05-18T19:57:55.006Z。 ↩↩ -
Claude Code v2.1.144 發行說明、Claude Code changelog與Claude Code CHANGELOG。2026年5月19日。新增 background sessions 的
/resume支援、background subagent duration 通知、plugin last-updated 顯示、/model目前 session/default 行為、/usage-credits,以及 startup network timeouts、terminal display corruption、macOS background-session startup、不一致的 image extensions、MCP pagination 與不支援的 image MIME types、Agent View interactions、background-session detach/resume、skill reload file-descriptor exhaustion 的可靠性修正。2026年5月19日的目前 session 驗證:claude --version回傳2.1.144 (Claude Code),且npm view @anthropic-ai/claude-code version dist-tags.latest time.modified --json回傳 latest2.1.144,time.modified為2026-05-19T17:40:52.832Z。 ↩↩ -
Claude Code v2.1.145 發行說明、Claude Code changelog與Claude Code CHANGELOG。2026年5月19日。新增
claude agents --json、GitHub repo/PR status-line JSON 欄位、更完整的 pre-install plugin discovery、Agent View awaiting-input tab counts、fullscreen slash-command / @-mention mouse interactions、Stop/SubagentStopbackground_tasks與session_crons輸入欄位、OTELagent_id與parent_agent_idspan attributes,並修正 permission-prompt bypass、MCP prompt validation errors、spinner/elapsed-time display freezes、Windows cross-project resume hints、Agent View voice push-to-talk、task-list ordering、stale marketplace banners、PR badge refresh、非 ASCII Agent Teams teammate names、/reviewClassic Projects errors、claude plugin validate、skillcontext: fork迴圈,以及過大的 Read tool 失敗。2026年5月19日的目前 session 驗證:本機claude --version回傳2.1.144 (Claude Code),而npm view @anthropic-ai/claude-code version dist-tags.latest time.modified --json回傳 latest2.1.145,time.modified為2026-05-19T22:20:44.083Z。 ↩↩ -
Claude Code v2.1.147 版本資訊與Claude Code CHANGELOG。2026年5月21日。新增預設關閉的
Workflow工具,用於確定性的多代理協調流程(CLAUDE_CODE_WORKFLOWS=1)、釘選的Agent View背景工作階段,以及取代/simplify的/code-review [effort] --comment。此版本強化REPL與Workflow沙箱;改善自動更新程式診斷、大型diff轉譯,以及提示歷史去重;並修正企業登入限制、PowerShell輸出/規則、MCP分頁式resources/list、resources/templates/list與prompts/list、Agent View CJK列轉譯、貼上文字傳遞、plugin元件計數、hook條件比對、headless/SDK模式中的未知slash command,以及剝除影像迴圈。2026年5月21日的目前工作階段驗證:本機claude --version傳回2.1.144 (Claude Code),而npm view @anthropic-ai/claude-code version dist-tags.latest time.modified --json傳回最新版本2.1.147,time.modified為2026-05-21T20:38:35.053Z。 ↩↩↩ -
Claude Code v2.1.148 版本資訊、Claude Code v2.1.149 版本資訊、Claude Code v2.1.150 版本資訊,以及Claude Code CHANGELOG。v2.1.148(2026年5月22日)修正部分使用者每次執行命令時,Bash工具都傳回退出碼127的迴歸問題。v2.1.149(2026年5月22日)新增
/usage依類別顯示限制用量、/diff鍵盤捲動、GFM工作清單核取方塊轉譯,以及EnterpriseallowAllClaudeAiMcps;也修正PowerShell權限繞過與權限分析缺口、git-worktree沙箱寫入允許清單範圍、Bashfind導致macOS vnode耗盡、受管理設定啟動凍結、/ultraplan與遠端工作階段無變更擷取失敗、含空格的otelHeadersHelper路徑、來自skill/agent frontmatter的狀態列effort顯示、Ctrl+O逐尾讀取transcript、/insights、Remote Control工作階段重新命名同步,以及壓縮前的/feedback上下文擷取。v2.1.150(2026年5月23日)僅包含內部基礎設施變更。2026年5月24日的目前工作階段驗證:本機claude --version傳回2.1.144 (Claude Code),而npm view @anthropic-ai/claude-code version dist-tags.latest time.modified --json傳回最新版本2.1.150,time.modified為2026-05-23T04:03:10.243Z;GitHub最新release傳回v2.1.150,發布時間為2026-05-23T04:03:51Z。 ↩↩ -
Claude Code v2.1.172 版本資訊、Claude Code v2.1.173 版本資訊,以及Claude Code Changelog(canonical)。2026年6月10日至11日。v2.1.172(6月10日):sub-agent可以產生自己的sub-agent,最多可達5層深度(遞迴委派);未設定
AWS_REGION時,AWS Bedrock區域會從~/.aws讀取,且/status會顯示解析後的來源;/plugin新增marketplace搜尋列;claude_code.lines_of_code.countOTEL指標新增model屬性。修正項目:1M上下文且無credits時工作階段卡住、影像處理錯誤、背景sub-agent卡住狀態、模型選擇器/限制,以及team-memory召回。v2.1.173(6月11日,UTC):帶有[1m]後綴的Fable 5模型名稱會自動正規化/移除後綴(Fable 5預設已包含1M上下文,因此這個僅對Opus/Sonnet有意義的後綴是多餘的);另有一項Windows修正,解決啟動時誤報「sandbox dependencies missing」警告。驗證:GitHub releasesv2.1.172與v2.1.173,以及code.claude.com/docs/en/changelog上的canonical changelog,確認v2.1.173為最新release。 ↩↩↩↩ -
Claude Code v2.1.174 版本資訊、Claude Code v2.1.175 版本資訊、Claude Code v2.1.176 版本資訊,以及Claude Code Changelog(canonical)。2026年6月12日。v2.1.174:
wheelScrollAccelerationEnabled設定(在全螢幕模式停用滑鼠滾輪捲動加速);/model選擇器會將Default解析到的family顯示為自己的列(Max/Team Premium/Enterprise與隨用隨付API為Opus,Pro/Team為Sonnet);當ANTHROPIC_DEFAULT_SONNET_MODEL釘選不同Sonnet時,/model選擇器不再顯示硬編碼的Sonnet標籤;VSCode Account & usage對話框(/usage)新增歸因資訊,顯示過去24小時或7天的cache miss、長上下文、subagents,以及依skill/agent/plugin/MCP拆分的明細;修正Bedrock GovCloud(us-gov-*)inference-profile前綴推導出global而非us-gov、背景工作階段繼承另一個工作階段的ANTHROPIC_*供應商環境變數、git commit共同作者模型名稱歸因、/advisor預先選取遭封鎖的advisor模型、skill熱重新載入重新傳送整份清單,以及Fable 5「consuming usage credits」橫幅對企業用量計費帳戶顯示的問題。v2.1.175:enforceAvailableModels受管理設定:啟用後,availableModels允許清單也會限制Default模型(解析到不允許模型的Default,會退回第一個允許模型),而且使用者/專案設定無法再擴大受管理的availableModels清單。v2.1.176:工作階段標題會以您對話的語言產生(設定language可釘選特定語言);footerLinksRegexes設定可在頁尾列顯示以regex比對的連結徽章(使用者或受管理設定);來自awsCredentialExport的Bedrock憑證會快取到其Expiration,不再固定為1小時;強化availableModels執行,讓alias選擇無法透過ANTHROPIC_DEFAULT_*_MODEL重導到遭封鎖的模型,且/fast會拒絕切換到允許清單外的模型;auto mode會為沒有Opus 4.8的org,從Fable 5退回最佳可用Opus;Read/Edit/Write工具路徑的hookif條件(Edit(src/**)、Read(~/.ssh/**)、Read(.env))現在可正確比對;Linux沙箱符號連結設定啟動修正;在SSH上的tmux內,/copy與滑鼠選取複製可到達系統剪貼簿;/cd與worktree移動不再回報前一個目錄的git分支;另有多項Remote Control、claude agents與背景工作階段修正。2026年6月15日(PST)的目前工作階段驗證:GitHub releasesv2.1.174至v2.1.176,以及code.claude.com/docs/en/changelog上的canonical changelog,確認v2.1.176為最新release。 ↩↩↩↩↩↩↩ -
Claude Code v2.1.178 版本資訊與v2.1.179 版本資訊,以及Claude Code Changelog(canonical)。2026年6月15日至16日。v2.1.178:
Tool(param:value)權限規則語法,可用*萬用字元比對工具輸入參數(例如Agent(model:opus));在巢狀.claude/skills中的skills會於處理該處檔案時載入,名稱衝突時以<dir>:<name>消歧;巢狀.claude/中的agents、workflows與output-styles發生碰撞時,會解析為最接近cwd者(專案範圍workflow儲存目標會指向最接近的既有.claude/workflows/);auto mode會在啟動前用分類器評估subagent產生;壓縮現在會在過載/可用性錯誤時遵循--fallback-model鏈;subagentdisallowedTools中的MCP伺服器層級規格(mcp__server、mcp__server__*、mcp__*)不再被靜默忽略;/doctor平面樹版面;/bug必須提供說明;workflow提示關鍵字只會在明確詞句時觸發;另有多項subagent-transcript、Remote Control、auth/credential與claude agents修正。v2.1.179:在串流中途連線中斷時保留部分回應;修正WSL2滑鼠滾輪捲動(v2.1.172迴歸)、Linux上大型樹狀結構的沙箱denyRead/allowReadglob使Bash工具描述變得過於龐大、feedback survey單位數擷取、welcome screen促銷堆疊、Ctrl+O檢視subagent transcript,以及遠端背景任務與plugin載入可靠性。v2.1.177:僅為CHANGELOG.md/feed.xml例行維護。2026年6月17日(PST)的目前工作階段驗證:GitHub releases v2.1.177至v2.1.179與canonical changelog確認v2.1.179為最新release。 ↩↩↩↩↩ -
Claude Code v2.1.170發行說明、Claude Code Changelog(正式來源),以及Anthropic新聞:Claude Fable 5。2026年6月9日。v2.1.170讓Claude Fable 5可在Claude Code中選用(執行
claude update後使用/model claude-fable-5),這是高於Opus的新層級,模型ID為claude-fable-5,具備1M context / 128K output,每MTok價格為$10/$50,並搭載安全分類器;遇到網路安全、生化、蒸餾查詢時會fallback到Opus 4.8,且到2026年6月22日前逐步推出至訂閱方案。Fable 5與Opus 4.8共用相同請求介面(僅支援adaptive thinking;移除temperature/top_p/top_k與budget_tokens),但新增一項破壞性變更:明確傳入thinking: {type: "disabled"}會回傳HTTP 400,因此若要在不啟用thinking的情況下執行,請省略該參數。此版本也修正了從VS Code整合式終端機(或任何繼承Claude Code環境變數的shell)啟動的session無法儲存transcripts,且不會出現在--resume下的問題。價格、context window與請求介面細節已與內建claude-api模型目錄交叉核對(快取日期:2026-05-26)。Claude Code專屬的Fable 5行為,包括fable/best別名、完整low到maxeffort尺度(預設high)、無法停用的thinking(session toggle /alwaysThinkingEnabled/MAX_THINKING_TOKENS=0皆無效)、claude-fable-5[1m]延伸context變體,以及ANTHROPIC_DEFAULT_FABLE_MODEL/DISABLE_PROMPT_CACHING_FABLE設定,已於2026年6月10日依據Claude Code模型設定文件驗證。當前session驗證時間為2026年6月9日至10日(PST):確認GitHub releasev2.1.170於6月9日(17:23Z)發布,且為最新release。 ↩↩↩↩ -
Claude Code v2.1.169發行說明與Claude Code Changelog(正式來源)。2026年6月8日。新增
--safe-modeflag與CLAUDE_CODE_SAFE_MODE環境變數(啟動時停用CLAUDE.md、plugins、skills、hooks與MCP servers,以便疑難排解)、/cd命令(將session移至新的工作目錄,且不破壞prompt cache),以及disableBundledSkills設定與CLAUDE_CODE_DISABLE_BUNDLED_SKILLS環境變數(向模型隱藏內建skills、workflows與內建slash commands)。另外約有20項修正:換行列的Up/Down導覽、重新連線與IDE輸入設定中的企業MCP政策強制執行、使用claude.ai認證時30–50ms的macOS UI停頓、claude -pWindows效能、Remote Control重新連線、Windows Git Credential Manager彈出視窗、自訂statusline頁尾提示、過期remote-session提示、claude agents --json遺漏被封鎖的sessions、TaskCreate輸入自動修復、降低streaming CPU、恢復Vertex/Foundry閒置逾時、skill-tag對比,以及背景session在retire→wake期間保留flag。當前session驗證時間為2026年6月9日(PST):正式changelog與GitHub releases確認v2.1.169為最新release。 ↩ -
Claude Code v2.1.166發行說明、Claude Code v2.1.167發行說明、Claude Code v2.1.168發行說明,以及Claude Code Changelog(正式來源)。2026年6月6日。v2.1.166新增
fallbackModel設定(primary過載或無法使用時,依序嘗試最多3個fallback models),將--fallback-model延伸至interactive sessions,並在發生非預期、不可重試的API錯誤時,於fallback model上重試該turn一次;在deny-rule的tool-name位置新增glob支援("*"拒絕所有tools),但allow rules會拒絕非MCP glob;強化跨session訊息,使其他Claude sessions透過SendMessage轉送的訊息不再帶有使用者權限;讓MAX_THINKING_TOKENS=0、--thinking disabled與各模型thinking toggle可在預設啟用thinking的模型上停用thinking;並讓claude update在下載前宣告目標版本。此外也修正影像處理、remote-session穩定性與終端機渲染(JetBrains、WezTerm/Ghostty)。v2.1.167與v2.1.168(皆為6月6日)僅包含bug fix與可靠性改善,沒有個別記錄的使用者可見變更。當前session驗證時間為2026年6月6日(PST):正式changelog與GitHub releases確認v2.1.168為最新release。 ↩↩↩↩↩ -
Claude Code v2.1.163發行說明與Claude Code Changelog(正式來源)。2026年6月4日;changelog從v2.1.160跳到v2.1.163,未發布161/162。新增
requiredMinimumVersion/requiredMaximumVersion受管理設定(若不在核准版本範圍內則拒絕啟動)、帶有--enabled/--disabled篩選器的/plugin list、Stop/SubagentStop的hookSpecificOutput.additionalContext,可提供不中斷turn的非錯誤回饋、/btw的「c to copy」原始markdown、skills的\$文字美元符號逸出,以及stdio MCP servers在--resume時接收session的CLAUDE_CODE_SESSION_ID。修正包含claude -p卡在永不結束的背景命令、Bedrock/Vertex/Foundry在CI=true下執行claude -p時要求Anthropic key、v2.1.154的$TMPDIR回歸問題破壞bazel/受EDR保護的Go、Windows上的OneDrive/唯讀session-envEEXIST、組織管理permission rules套用過晚、背景sessions在更新期間遺失tasks、hookif: "Bash(...)"過度匹配$()/$VAR,以及~路徑deny rules未封鎖$HOME參照。當前session驗證時間為2026年6月4日(PST):正式changelog確認v2.1.163為最新版本。 ↩↩↩ -
Claude Code v2.1.160發行說明與Claude Code Changelog(正式來源)。2026年6月2日。新增在寫入shell啟動檔(
.zshenv、.zlogin、.bash_login)與~/.config/git/前的權限提示;acceptEdits現在也會在處理會授予程式碼執行能力的build-tool設定檔前提示(.npmrc、.yarnrc*、bunfig.toml、.bazelrc、.pre-commit-config.yaml、.devcontainer/及類似項目)。單一檔案的grep/egrep/fgrep現在可滿足編輯前讀取檢查。將dynamic-workflow觸發關鍵字從workflow重新命名為ultracode(在prompt輸入中以紫色醒目提示);「workflow」一詞不再觸發執行。移除CLAUDE_CODE_OPUS_4_6_FAST_MODE_OVERRIDE(現在無效)以及啟動時的JetBrains plugin安裝建議。另外約有25項修正:WSL透過PowerShell interop實作選取即複製,而非OSC 52;claude agentssession還原會遺失chat history並重新執行原始prompt;隔夜retired的背景sessions遺失conversation;claude --bg「socket missing」冷啟動競態;Windows背景session在高CPU負載下輸入無回應;Apple Terminal/tmux上的terminal sync-output artifacts;claude agents檢視中的CJK IME游標位置;Windows hyperlink terminals上的file:///C:/...連結重寫;voice mode在非ASCII專案/branch名稱下失敗;第三方providers上的auto-mode-unavailable訊息現在指向CLAUDE_CODE_ENABLE_AUTO_MODE,而不是歸咎於模型;/effort ultracode不再於無法執行xhigh的模型上提供;model-not-found錯誤不再於SDK下建議--model;vim在v$yank後的p貼上位置;以及背景session teardown時先SIGTERM再SIGKILL。當前session驗證時間為2026年6月2日(PST):code.claude.com/docs/en/changelog的正式changelog確認v2.1.160為最新release。 ↩↩ -
Claude Code v2.1.155版本資訊、Claude Code v2.1.156版本資訊、Claude Code v2.1.157版本資訊、Claude Code v2.1.158版本資訊、Claude Code v2.1.159版本資訊,以及Claude Code變更記錄(權威)。v2.1.155與v2.1.156(2026年5月29日)交付相同的Opus 4.8 thinking-block mutation修正;該問題曾以API錯誤形式浮現。v2.1.157(2026年5月29日)讓
.claude/skills/plugins無須 marketplace 註冊即可自動載入,新增claude plugin init <name>鷹架,提供/plugin引數自動完成,讓EnterWorktree可在工作階段中切換由Claude管理的 worktrees,在 agent 完成後讓背景 worktrees 維持未鎖定,讓git worktree remove/prune無須手動解鎖即可運作;當OTEL_LOG_TOOL_DETAILS=1時,tool_decision遙測事件會包含tool_parameters。此外也修正無法處理圖片導致的當機(現改為文字 placeholder)、桌面/IDE/SDK介面在 auto/bypass 模式下的 sandbox 網路權限提示、背景工作階段 park 後退役、agents-list 按 Esc 取消「opening…」、30天保留清理造成背景 worktrees 孤立、--resume背景 subagent 回報、tmux + VS Code + Cursor + Windsurf 中的終端機轉譯/剪貼簿、WSL圖片/螢幕截圖/拖曳路徑、長時間 resumed conversation 效能,以及/terminal-setup在整合式終端機中停用GPU加速。v2.1.158(2026年5月30日)讓Bedrock、Vertex與Foundry可透過CLAUDE_CODE_ENABLE_AUTO_MODE=1在Opus 4.7與Opus 4.8使用Auto Mode。v2.1.159(2026年5月31日)僅為內部基礎架構更新,未公布任何使用者可見變更。目前工作階段於2026年5月31日(PST)驗證:code.claude.com/docs/en/changelog的權威變更記錄確認v2.1.155–v2.1.159項目;v2.1.159確認為最新版本。 ↩↩↩↩ -
Claude Code v2.1.151版本資訊、Claude Code v2.1.152版本資訊、Claude Code v2.1.153版本資訊、Claude Code v2.1.154版本資訊,以及Claude Code變更記錄(權威)。v2.1.151(2026年5月23日)僅為內部基礎架構更新。v2.1.152(2026年5月27日)引入
/code-review --fix套用至 working tree、disallowed-toolsskill/command frontmatter、/reload-skills、SessionStarthook 的reloadSkills/sessionTitle輸出、MessageDisplayhook事件、pluginSuggestionMarketplaces受管理設定、--fallback-model工作階段中切換、移除 auto-mode opt-in、vim/反向歷史記錄,以及轉譯、效能與可靠性修正。v2.1.153(2026年5月28日)為 plugin marketplaces 新增skipLfs,讓/model儲存為新工作階段預設值(s代表僅限工作階段,並以modelPicker:thisSessionOnlykeybind取代modelPicker:setAsDefault),並將COLUMNS/LINES放入 status-line env;macOS背景 agents 會保留「隱私權與安全性」授權;另有25項以上修正,涵蓋 stateful MCPtools/list重新連線迴圈、自訂 gateway 的OAuth認證洩漏、subagent MCP政策強制執行、Windows installer/update channel修正,以及背景工作階段 attach 可靠性。v2.1.154(2026年5月28日)讓Opus 4.8成為預設,並預設使用高 effort;新增/effort xhigh層級;引入 dynamic workflows,可透過/workflows在背景協調數十到數百個 agents;讓Opus 4.8上的Fast mode以2倍標準費率提供2.5倍速度;除了Haiku/Sonnet/Opus 4.7及更早版本外,所有模型預設使用 lean system prompt;將多選題提示限縮為真正無法自行決定的情況;將/simplify還原為僅清理的 review,與/code-review --fix的 bug-hunting pass 分離;將/effort滑桿重新標示為「Faster」/「Smarter」;新增claude agents的! <command>背景 shell 工作階段,以及claude --bg --exec '<command>';允許 plugins 宣告defaultEnabled: false;在/pluginDiscover 中將建議 plugins 釘選到目前目錄;讓 streaming tool execution 永遠啟用;將CLAUDE_CODE_SESSION_ID與CLAUDECODE=1傳給 stdio MCP subprocess env;將未核准的.mcp.json伺服器標示為⏸ Pending approval而非自動連線;並棄用CLAUDE_CODE_OPUS_4_6_FAST_MODE_OVERRIDE(6月1日移除;請改用/model claude-opus-4-6[1m],再執行/fast on)。目前工作階段於2026年5月28日(PST)驗證:code.claude.com/docs/en/changelog的權威變更記錄確認v2.1.151–v2.1.154項目;v2.1.154確認為最新版本。 ↩↩↩ -
Claude Code CHANGELOG——2026年4月 parity audit 中記錄的23個 env vars 綜合參考。OTel exporters(
OTEL_LOGS_EXPORTER、OTEL_METRICS_EXPORTER、OTEL_TRACES_EXPORTER)在v2.1.85取得none停用處理。敏感欄位閘控:OTEL_LOG_TOOL_DETAILS(v2.1.85tool_parameters)、OTEL_LOG_TOOL_CONTENT與OTEL_LOG_USER_PROMPTS(v2.1.101 opt-in,預設視為敏感)。CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC會停用版本資訊擷取(v2.0.17);v2.1.110在設定後,也會停止 headless/SDK中的 auto-title Haiku request。API/model:CLAUDE_CODE_EXTRA_BODY(v2.1.113修正:Vertex/subagent 搭配output_config.effort時不再出現400)、CLAUDE_CODE_MAX_CONTEXT_TOKENS(既有;v2.1.98修正DISABLE_COMPACT互動)、CLAUDE_CODE_FILE_READ_MAX_OUTPUT_TOKENS(v2.1.0)、CLAUDE_CODE_DISABLE_NONSTREAMING_FALLBACK(v2.1.83)、ANTHROPIC_BETAS(v2.1.78在Haiku上的修正)、ANTHROPIC_SMALL_FAST_MODEL(v0.2.125停止逸出Bedrock ARN斜線)。Plugins/MCP:CLAUDE_CODE_PLUGIN_CACHE_DIR(v2.1.72修正 literal-tilde 目錄)、CLAUDE_CODE_PLUGIN_KEEP_MARKETPLACE_ON_FAILURE(v2.1.90更適合離線使用)、CLAUDE_CODE_MCP_SERVER_NAME+CLAUDE_CODE_MCP_SERVER_URL(v2.1.85headersHelpercontext)。Shell/IDE:CLAUDE_CODE_SHELL_PREFIX(v1.0.61)、CLAUDE_CODE_GIT_BASH_PATH(v2.1.98 Windows)、CLAUDE_CODE_EXIT_AFTER_STOP_DELAY(v2.0.35 SDK idle)、CLAUDE_CODE_AUTO_CONNECT_IDE(v1.0.61)。Enterprise:CLAUDE_CODE_PROXY_RESOLVES_HOSTS(v2.0.55從預設啟用改為 opt-in)、CLAUDE_CODE_API_KEY_HELPER_TTL_MS(apiKeyHelper refresh + 5分鐘預設值於v0.2.74新增;用於覆寫TTL的 env var 於v0.2.117新增)。另有:ENABLE_PROMPT_CACHING_1H_BEDROCK——ENABLE_PROMPT_CACHING_1H的Bedrock範圍 alias;已於v2.1.108棄用,但仍會生效並顯示棄用通知。 ↩↩↩↩↩