Claude Code速查表:指令、設定與快捷鍵
# 快速查閱的Claude Code速查表,已更新至v2.1.140:CLI旗標、斜線指令、鍵盤快捷鍵、hooks、外掛、Agent View、/goal與環境變數。
一站掌握所有CLI旗標、斜線指令、鍵盤快速鍵、設定鍵、hook 事件與環境變數。如需深入說明,請參閱完整的Claude Code指南。若是首次設定,請參閱快速入門。
1. 安裝
3種安裝方式,依建議優先順序排列。
# Native binary (recommended)
curl -fsSL https://claude.ai/install.sh | bash
# Homebrew (macOS)
brew install --cask claude-code
# NPM (deprecated — migrate with `claude install`)
npm install -g @anthropic-ai/claude-code
安裝特定版本:
curl -fsSL https://claude.ai/install.sh | bash -s 1.0.58
驗證安裝:
claude doctor
驗證身分:
claude auth login # Log in or switch accounts
claude auth status # Check current auth state
claude auth logout # Clear stored credentials
2. CLI旗標
| 旗標 | 說明 | 範例 |
|---|---|---|
-p |
列印模式——單次查詢後結束 | claude -p "list TODOs" |
-c |
接續最近的session | claude -c |
-r, --resume |
恢復具名或編號的session | claude -r "auth-refactor" |
-n, --name |
啟動時設定session顯示名稱 | claude -n "feature-x" |
--model |
覆寫此session使用的model | claude --model opus |
--max-turns |
限制自主回合數 | claude -p "fix lint" --max-turns 10 |
--output-format |
以text、json或stream-json輸出 |
claude -p "count files" --output-format json |
--allowedTools |
限制可用tools | claude -p "fix" --allowedTools "Edit,Bash(npm:*)" |
--permission-mode |
設定permission模式 | claude --permission-mode auto |
--enable-auto-mode |
啟動時啟用Auto Mode | claude --enable-auto-mode |
--dangerously-skip-permissions |
YOLO模式——略過所有提示 | claude --dangerously-skip-permissions |
--from-pr |
啟動連結至PR的session(v2.1.27+);接受GitHub、GHE、GitLab MR、Bitbucket PR URL(v2.1.119+) | claude --from-pr 123 |
--fork-session |
從已恢復的session分岔 | claude -r base --fork-session |
-w |
在隔離的git worktree中啟動 | claude -w |
--bare |
腳本模式——略過hooks、LSP、plugins | claude -p "count files" --bare |
--plugin-url <url> |
為目前session擷取plugin.zip封存檔(v2.1.129+) |
claude --plugin-url https://example.com/plugin.zip |
--plugin-dir <path> |
為目前session載入plugin目錄或.zip封存檔(.zip支援v2.1.128+) |
claude --plugin-dir ./my-plugin.zip |
--channels |
將核准提示轉送至Telegram/Discord | claude --channels |
--debug |
啟用debug記錄 | claude --debug |
--init |
使用CLAUDE.md初始化專案 | claude --init |
3. Slash Commands
| 指令 | 功能 |
|---|---|
/init |
使用CLAUDE.md初始化專案 |
/compact |
壓縮對話歷史。可加上焦點:/compact focus on tests |
/context |
檢視context window使用量與可執行建議 |
/usage |
Token使用量、成本、方案使用量;合併對話框(v2.1.118+:/cost與/stats是typing shortcuts,會開啟/usage分頁) |
/cost |
Typing shortcut→開啟/usage成本分頁(v2.1.118+) |
/model |
變更model。/model opus、/model sonnet |
/fast |
切換快速輸出模式 |
/effort |
設定effort層級:low、medium、high |
/status |
檢視session狀態、model、settings |
/permissions |
以互動方式管理permission設定 |
/config |
開啟完整settings介面 |
/mcp |
設定MCP伺服器。/mcp enable、/mcp disable |
/hooks |
檢視hook設定 |
/memory |
檢視並管理auto-memory檔案 |
/copy |
複製程式碼區塊。/copy N代表第N新的回應 |
/resume |
恢復具名session。/resume 1或/resume name |
/rename |
命名目前session。/rename feature-auth |
/branch |
分岔對話以便平行探索 |
/clear |
清除對話歷史 |
/plan |
進入plan模式。/plan refactor the auth module |
/powerup |
具動畫示範的互動式功能教學(v2.1.90+) |
/voice |
切換按住說話voice模式 |
/loop |
週期性任務。/loop 5m /foo每5分鐘執行一次 |
/rewind |
回到checkpoint(或按兩次Esc) |
/export |
匯出對話transcript |
/add-dir |
新增工作目錄以擴充檔案存取範圍 |
/agents |
管理subagents |
/goal |
設定完成條件;Claude會持續執行,直到達成目標(v2.1.139+) |
/skills |
列出已安裝的skills;支援輸入篩選的搜尋框(v2.1.121+) |
/bashes |
列出背景bash任務 |
/tasks |
列出背景agents |
/theme |
管理具名themes(v2.1.118+);plugins會提供themes/目錄 |
/color |
設定prompt-bar顏色。用/color default重設 |
/simplify |
檢視程式碼是否可簡化 |
/batch |
批次操作 |
/security-review |
檢查程式碼是否有弱點 |
/claude-api |
使用ClaudeAPI/AnthropicSDK建置apps |
/doctor |
檢查安裝健康狀態 |
/bug |
向Anthropic回報bug |
/release-notes |
具changelogs的互動式版本選擇器(v2.1.92+) |
/buddy |
終端機陪伴寵物——18個物種、5個稀有度層級,依account ID決定且結果固定 |
/login / /logout |
在session中驗證身分或登出 |
自訂指令:建立.claude/commands/my-command.md(專案)或~/.claude/commands/my-command.md(個人),並用/my-command呼叫。指令支援YAML frontmatter,可設定description、allowed tools、model override,並透過$ARGUMENTS或位置參數$1、$2插入arguments。
---
description: Fix a GitHub issue
allowed-tools: Read, Edit, Bash(git:*)
model: opus
argument-hint: [issue-number]
---
Fix GitHub issue #$ARGUMENTS following our coding standards.
用法:/fix-issue 123
4. 鍵盤快捷鍵
一般控制
| 快捷鍵 | 動作 |
|---|---|
Ctrl+C |
取消目前操作 |
Ctrl+D |
結束session(EOF) |
Ctrl+L |
清除畫面(保留歷史) |
Ctrl+O |
切換詳細輸出 |
Ctrl+R |
搜尋指令歷史 |
Ctrl+V |
從剪貼簿貼上圖片 |
Ctrl+B |
將目前操作移至背景 |
Ctrl+X Ctrl+K |
停止所有agents(v2.1.83起由Ctrl+F改為此組合) |
Ctrl+S |
暫存prompt草稿 |
Ctrl+G |
開啟外部編輯器 |
Esc Esc |
回復最後一次變更 |
Tab |
接受prompt建議 |
! Tab |
Bash歷史自動完成 |
Shift+Tab |
循環切換permission模式 |
Alt+P / Option+P |
輸入時切換models |
Alt+T |
切換thinking模式 |
Ctrl+T |
切換語法醒目顯示 |
Shift+Down |
循環切換agent team隊友 |
Up/Down |
瀏覽指令歷史 |
v |
Vim visual mode——字元選取(v2.1.118+;僅vim模式) |
V |
Vim visual-line mode(v2.1.118+;僅vim模式) |
? |
顯示快捷鍵 |
快速前綴
| 前綴 | 動作 | 範例 |
|---|---|---|
# |
加入持久memory | # Always use TypeScript |
/ |
Slash command | /review |
! |
直接執行bash | ! git status |
@ |
參照檔案 | @src/index.ts |
& |
將任務送到cloud | & Build the API |
多行輸入
| 方法 | 按鍵 |
|---|---|
| 跳脫換行 | \接著Enter |
| macOS | Option+Enter |
| iTerm2/WezTerm/Ghostty/Kitty | Shift+Enter |
| 其他終端機 | Shift+Enter(先執行/terminal-setup) |
| 控制字元 | Ctrl+J |
Keybindings可透過/keybindings自訂(儲存在~/.claude/keybindings.json)。
5. 設定檔案
優先順序階層(由高到低)
| 層級 | 位置 | 範圍 |
|---|---|---|
| Enterprise(鎖定) | /Library/Application Support/ClaudeCode/managed-settings.json(macOS) |
所有使用者,不可覆寫 |
| CLI旗標 | Command-line arguments | 目前session |
| 本機專案 | .claude/settings.local.json |
個人、目前專案(gitignored) |
| 共享專案 | .claude/settings.json |
團隊,提交到git |
| 使用者全域 | ~/.claude/settings.json |
您所有的專案 |
| 執行階段狀態 | ~/.claude.json |
OAuth tokens、MCP config |
第一個符合者生效。Enterprise設定無法繞過。
6. Settings.json參考
主要settings的型別與範例。可放在上述階層中的任何settings檔案。
{
"$schema": "https://json.schemastore.org/claude-code-settings.json",
"model": "claude-sonnet-4-6",
"permissions": {
"allow": ["Read", "Glob", "Grep", "Bash(npm run:*)", "Bash(git:*)", "Edit(src/**)"],
"deny": ["Read(.env*)", "Bash(rm -rf:*)", "Bash(sudo:*)"],
"ask": ["WebFetch", "Bash(docker:*)"],
"defaultMode": "acceptEdits",
"additionalDirectories": ["../shared-lib"]
},
"env": {
"NODE_ENV": "development"
},
"hooks": {},
"sandbox": {
"enabled": false,
"autoAllowBashIfSandboxed": true
},
"includeCoAuthoredBy": true,
"cleanupPeriodDays": 30,
"respectGitignore": true,
"showTurnDuration": true,
"language": "en",
"autoMemoryDirectory": ".claude/memory",
"plansDirectory": ".claude/plans"
}
Permission規則語法:Tool(pattern:*)提供前綴比對。Bash(npm run test:*)允許npm run test、npm run test:unit等。檔案pattern使用glob語法:Edit(src/**)。
新增keys(v2.1.118+):
| Key | 行為 |
|---|---|
autoMode.allow $defaults |
Sentinel,會在內建清單旁加入自訂規則(也適用於soft_deny、environment)——v2.1.118+ |
prUrlTemplate |
頁尾PR badge URL template——v2.1.119+ |
wslInheritsWindowsSettings |
WSL繼承Windows端managed settings——v2.1.118+ |
skillOverrides |
隱藏或收合skills:off、user-invocable-only或name-only——v2.1.129+ |
完整settings schema請參閱完整指南中的Configuration Deep Dive。
7. CLAUDE.md快速參考
CLAUDE.md是您專案的指令檔案。Claude會在每個 session 開始時讀取它。
存放位置:
| 位置 | 範圍 |
|---|---|
CLAUDE.md (project root) |
此專案中的所有使用者、所有 session |
.claude/CLAUDE.md |
相同範圍,替代位置 |
~/.claude/CLAUDE.md |
個人設定,適用所有專案 |
建議納入內容:
# Project Name
## Stack
- Backend: FastAPI, Python 3.11+
- Frontend: HTMX + Alpine.js + Bootstrap 5
## Commands
- Dev: `uvicorn app.main:app --reload --port 8000`
- Test: `python -m pytest -v`
- Lint: `ruff check .`
## Conventions
- Conventional commits: feat:, fix:, docs:, refactor:
- Never force push to main
- Always activate venv before Python commands
## Key Files
- app/main.py — FastAPI app and routes
- app/models.py — SQLAlchemy models
保持易於掃描。密集長文會在每個 session 浪費 context tokens。使用項目符號、表格和短程式碼區塊。避免長段落:Claude會在每個 session 開始時讀取 CLAUDE.md,因此每個字都會消耗 context。
實用技巧:
- 在 REPL 中使用 # 前綴,可將內容加入自動記憶,而不必編輯 CLAUDE.md:# Always use TypeScript strict mode
- 當 Claude 讀取某個目錄中的檔案時,該子目錄內的 CLAUDE.md 也會被載入
- 團隊共用規則可放在 .claude/rules/*.md,方便模組化整理
8. 權限模式
| 模式 | 行為 | 使用情境 |
|---|---|---|
default |
每個 tool 首次使用時提示 | 一般開發 |
acceptEdits |
自動核准檔案編輯,bash 仍會提示 | 可信任專案 |
auto |
分類器(Sonnet 4.6)會審查每個動作的安全性 | 具防護措施的自主執行 |
plan |
唯讀,不允許編輯或執行 | 僅用於分析與規劃 |
bypassPermissions |
略過所有提示 | CI/CD 自動化 |
Auto Mode(v2.1.85+)是建議用來取代 --dangerously-skip-permissions 的模式。唯讀操作與檔案編輯會自動核准。自訂 allow/deny 規則會先解析;其他動作則交由安全分類器判斷。預設會自動封鎖:curl | bash、force-push 到 main、生產環境部署、大量刪除雲端資源、IAM 變更,以及將敏感資料傳送到外部。1
斷路機制:單一 session 內連續封鎖 3 次或總計封鎖 20 次,就會暫停並回到手動提示。
# Enable at startup
claude --enable-auto-mode
# Cycle during session
Shift+Tab # default -> acceptEdits -> auto -> plan
PowerShell自動核准(v2.1.119+): PowerShell tool 指令會和 Bash 指令一樣,依照權限模式自動核准。像 PowerShell(Get-*:*) 這類 allow 規則,可讓唯讀操作略過提示。
9. hooks 事件
| 事件 | 觸發時機 | 可封鎖? |
|---|---|---|
PreToolUse |
tool 執行前 | 是 |
PostToolUse |
tool 完成後 | 否 |
PostToolUseFailure |
tool 失敗後 | 否 |
UserPromptSubmit |
使用者送出 prompt 時 | 是 |
Stop |
Claude完成回覆時 | 是 |
SubagentStart |
subagent 產生時 | 否 |
SubagentStop |
subagent 完成時 | 是 |
SessionStart |
session 開始時 | 否 |
SessionEnd |
session 關閉時 | 否 |
Notification |
觸發警示時 | 否 |
| InstructionsLoaded | CLAUDE.md 載入時 | 否 |
| ConfigChange | Config 檔案在 session 中途變更時 | 是 |
| WorktreeCreate | 正在建立 worktree 時 | 是 |
| WorktreeRemove | 正在移除 worktree 時 | 否 |
| PreCompact | context compact 前 | 否 |
| PostCompact | context compact 後 | 否 |
| Elicitation | MCP要求結構化輸入時 | 是 |
| ElicitationResult | 使用者回應 MCP對話框時 | 是 |
| StopFailure | 回合因 API錯誤而結束時 | 否 |
| PermissionRequest | 顯示權限對話框時 | 是 |
| PermissionDenied | Auto mode 拒絕某個動作時(v2.1.88+) | 否 |
| CwdChanged | 工作目錄變更時(v2.1.83+) | 否 |
| FileChanged | 受監看檔案遭外部修改時(v2.1.83+) | 否 |
| TaskCreated | 建立新 task 時(v2.1.84+) | 否 |
| TeammateIdle | Agent team member 閒置時 | 是 |
| TaskCompleted | task 標記為完成時 | 是 |
完整 hook protocol(input/output JSON、matchers、exit codes)請參閱完整指南中的 Hooks Deep Dive。
10. hooks 設定
Hooks 位於 settings.json 或專用的 hooks.json。最小範例如下:
{
"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"
}
]
}
]
}
}
Matcher語法:
| Pattern | 符合對象 |
|---|---|
* |
所有 tools |
Bash |
僅 Bash |
Edit\|Write |
Edit 或 Write |
mcp__github |
MCP server tools |
"" (empty) |
沒有 tools 的事件(例如 UserPromptSubmit) |
Exit codes:
| Code | 意義 |
|---|---|
0 |
成功,操作繼續 |
2 |
封鎖,操作停止,stderr 會提供給 Claude |
1, 3+ |
非封鎖警告 |
Async hooks 會在背景執行且不封鎖流程:在 hook 物件中加入 "async": true。2
Hook output / input 欄位:
duration_ms位於PostToolUse/PostToolUseFailurehook input(v2.1.119+):tool 執行時間,不包含權限提示與 PreToolUse hooks。hookSpecificOutput.updatedToolOutput(v2.1.121+):替換任意 tool 的輸出(v2.1.118 起僅支援 MCP;v2.1.121 擴展至所有 tools)。hookSpecificOutput.sessionTitle(v2.1.96+):透過UserPromptSubmithook 設定 session title。args: string[]位於 command hooks(v2.1.139+):不需 shell quoting,即可傳遞結構化 argv。continueOnBlock位於PostToolUsehooks(v2.1.139+):將封鎖原因回傳給 Claude,並繼續該回合。subagent_type位於 agent hook input(v2.1.140+):識別正在執行的 agent 類型。
11. MCP快速設定
用一個指令加入 MCP server:
# Remote HTTP server (recommended)
claude mcp add --transport http github https://api.githubcopilot.com/mcp/
# Remote with auth header
claude mcp add --transport http api https://api.example.com/mcp \
--header "Authorization: Bearer $TOKEN"
# Local stdio server
claude mcp add --transport stdio postgres \
--env "DATABASE_URL=postgresql://user:pass@localhost/db" \
-- npx -y @anthropic-ai/mcp-server-postgres
Scope控制:
claude mcp add --scope project ... # Team-shared (.mcp.json)
claude mcp add --scope user ... # Personal (~/.claude.json)
專案 .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": "postgresql://user:pass@localhost/db"
}
}
}
}
MCP目前每月下載量已達 1 億次,並有 3,000 多個已索引的 servers。3 關於 transport 類型、elicitation 與 tool search 設定,請參閱完整指南中的 MCP section。
alwaysLoad(v2.1.121+): 讓可信任 server 不受 Tool Search 延遲載入影響。所有 tools 會在 session 開始時載入,不需要 ToolSearch 往返:
{
"mcpServers": {
"github": {
"type": "http",
"url": "https://api.githubcopilot.com/mcp/",
"alwaysLoad": true
}
}
}
Auto-retry(v2.1.121+): MCP servers 若在啟動時發生錯誤,會最多重試 3 次,之後才標記為 disconnected。
SDK mcp_authenticate redirectUri(v2.1.121+): 若要在自訂 URI schemes 上完成 OAuth,此欄位為必要項目,例如 desktop apps 與 claude.ai connector 流程。
11.5. Plugin CLI指令
| 指令 | 行為 |
|---|---|
claude --plugin-url <url> |
擷取目前 session 使用的 plugin .zip 封存檔(v2.1.129+) |
claude --plugin-dir <path> |
載入目前 session 使用的 plugin 目錄或 .zip 封存檔(.zip 支援自 v2.1.128+ 起) |
claude plugin prune |
移除父項已不存在的自動安裝 plugins(v2.1.121+) |
claude plugin uninstall <name> --prune |
解除安裝並連帶移除孤立的自動安裝相依項(v2.1.121+) |
claude plugin tag |
建立 release git tags,並進行版本驗證(v2.1.118+) |
12. Subagent 類型
| 類型 | 預設模型 | 模式 | 用途 |
|---|---|---|---|
| Explore | Haiku(快速) | 唯讀 | 搜尋codebase、尋找檔案、理解結構 |
| General-purpose | 繼承主模型 | 完整讀寫 | 複雜研究與修改任務 |
| Plan | 繼承主模型 | 唯讀 | 執行前規劃實作 |
| Custom | 可設定 | 可設定 | 特定領域工作(security review、測試等) |
Claude會自動委派給subagents。您也可以明確要求使用它們:
> Use the explore agent to find all auth-related files
> Have a subagent analyze the database schema
Custom subagents會以含有YAML frontmatter的markdown檔案形式,定義於.claude/agents/(專案)或~/.claude/agents/(個人)。最多可平行執行10個subagents。4
claude agents會在目前版本中開啟Agent View:這是一個research-preview作業畫面,用於檢視執行中、受阻與已完成的Claude Code sessions。它適合用來監控,不應作為工作已通過品質門檻的證明。6
Custom agent frontmatter欄位:
| 欄位 | 用途 |
|---|---|
name |
唯一識別碼(小寫、連字號) |
description |
何時呼叫(加入”PROACTIVELY”以啟用自動委派) |
tools |
以逗號分隔的工具清單。支援Agent(Explore)以限制可spawn的類型 |
disallowedTools |
從繼承集合中拒用的工具 |
model |
opus、sonnet、haiku或inherit(預設) |
permissionMode |
default、acceptEdits、plan、bypassPermissions等 |
maxTurns |
agentic turns上限 |
background |
設為true可一律作為背景任務執行 |
isolation |
worktree表示隔離的git worktree副本 |
Custom agent範例(.claude/agents/security-reviewer.md):
---
name: security-reviewer
description: Expert security code reviewer. Use PROACTIVELY after code changes to auth or data handling.
tools: Read, Grep, Glob, Bash
model: opus
permissionMode: plan
---
You are a senior security engineer. Analyze for OWASP Top 10 vulnerabilities,
secrets, hardcoded credentials, and SQL injection. Report findings with severity
levels and remediation steps.
13. Environment Variables
Authentication與API
| 變數 | 用途 |
|---|---|
ANTHROPIC_API_KEY |
直接API authentication |
ANTHROPIC_AUTH_TOKEN |
自訂authorization header |
ANTHROPIC_CUSTOM_HEADERS |
額外request headers |
Model Configuration
| 變數 | 用途 |
|---|---|
ANTHROPIC_MODEL |
覆寫預設模型 |
CLAUDE_CODE_SUBAGENT_MODEL |
subagents使用的模型 |
MAX_THINKING_TOKENS |
啟用extended thinking |
CLAUDE_CODE_MAX_OUTPUT_TOKENS |
限制輸出長度 |
Cloud Providers
| 變數 | 用途 |
|---|---|
CLAUDE_CODE_USE_BEDROCK=1 |
使用AWS Bedrock |
CLAUDE_CODE_USE_VERTEX=1 |
使用Google Vertex AI |
CLAUDE_CODE_USE_FOUNDRY=1 |
使用Microsoft Foundry |
ANTHROPIC_BEDROCK_SERVICE_TIER=priority |
Bedrock service tier — default/flex/priority(v2.1.122+);會以X-Amzn-Bedrock-Service-Tier送出 |
ENABLE_TOOL_SEARCH=true |
在Vertex AI選擇啟用Tool Search(v2.1.119+;預設關閉,以避免不支援的beta header) |
CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY=1 |
選擇啟用gateway /v1/models探索,用於/model picker(v2.1.129+) |
Behavior Control
| 變數 | 用途 |
|---|---|
DISABLE_AUTOUPDATER=1 |
防止自動更新 |
DISABLE_UPDATES=1 |
封鎖所有更新路徑,包含手動claude update(v2.1.118+,比DISABLE_AUTOUPDATER更嚴格) |
CLAUDE_CODE_PACKAGE_MANAGER_AUTO_UPDATE=1 |
Homebrew/WinGet安裝會在背景執行package-manager升級,並提示重新啟動(v2.1.129+) |
DISABLE_TELEMETRY=1 |
選擇退出usage telemetry |
DISABLE_COST_WARNINGS=1 |
隱藏成本警告 |
DISABLE_PROMPT_CACHING=1 |
全域停用prompt caching |
CLAUDE_CODE_DISABLE_1M_CONTEXT=1 |
使用標準200K,而非1M |
CLAUDE_CODE_DISABLE_GIT_INSTRUCTIONS=1 |
移除內建commit/PR指示 |
CLAUDE_CODE_HIDE_CWD=1 |
在啟動畫面標誌中隱藏工作目錄(v2.1.119+) |
CLAUDE_CODE_FORK_SUBAGENT=1 |
在外部builds上使用forked subagents(v2.1.117+;v2.1.121+可在非互動式-p模式運作) |
CLAUDE_CODE_FORCE_SYNC_OUTPUT=1 |
自動偵測漏判時,強制使用同步terminal output(v2.1.129+) |
Tool Configuration
| 變數 | 用途 |
|---|---|
BASH_DEFAULT_TIMEOUT_MS |
Bash命令timeout(預設30000) |
BASH_MAX_TIMEOUT_MS |
Bash timeout上限(預設600000) |
MCP_TIMEOUT |
MCP伺服器啟動timeout(預設5000) |
MCP_TOOL_TIMEOUT |
MCP工具執行timeout(預設30000) |
Network與Proxy
| 變數 | 用途 |
|---|---|
HTTP_PROXY / HTTPS_PROXY |
Proxy設定 |
NO_PROXY |
對特定網域略過proxy |
CLAUDE_CODE_CLIENT_CERT |
mTLS憑證路徑 |
完整清單請參閱完整指南中的Environment Variables。
14. Cost Reference
每100萬tokens的價格(截至2026年4月)。5
| 模型 | 輸入 | 輸出 | 備註 |
|---|---|---|---|
| Opus 4.7 | $5.00 | $25.00 | 目前旗艦模型。1M context採標準定價,沒有long-context加價。 |
| Opus 4.6(legacy) | $5.00 | $25.00 | 1M context目前也採標準定價 |
| Sonnet 4.6 | $3.00 | $15.00 | 平衡型模型。1M context採標準定價,沒有long-context加價。 |
| Haiku 4.5 | $1.00 | $5.00 | 探索、簡單任務 |
典型session會消耗50K-200K input tokens與10K-50K output tokens。Haiku session:約$0.10-$0.45。Opus session:約$0.50-$2.25。
依方案的預設模型(截至2026年4月16日的Claude Code):
- Max、Team Premium → Opus 4.7
- Pro、Team Standard、Enterprise、Anthropic API → Sonnet 4.6(Enterprise + API將於2026年4月23日切換為Opus 4.7)
- Bedrock、Vertex、Foundry → Sonnet 4.5(可透過
ANTHROPIC_DEFAULT_OPUS_MODEL釘選較新版本)
Opus 4.7需要Claude Code v2.1.111或更新版本。它僅使用adaptive reasoning(沒有固定thinking budgets)。新的xhigh effort level是Opus 4.7在coding/agentic工作負載上的預設值。
在session期間切換模型:
/model opus # Switch to Opus (resolves to 4.7 on API, 4.6 on Bedrock/Vertex/Foundry)
/model sonnet # Switch to Sonnet 4.6
/model haiku # Switch to Haiku 4.5
/effort xhigh # Opus 4.7 only — recommended for coding/agentic
決策規則:簡單探索交給Haiku。重視成本的日常coding交給Sonnet。高難度推理、架構、agentic loops與security analysis交給Opus。複雜重構使用opusplan(Opus規劃,Sonnet執行)。
15. Key File Locations
| 路徑 | 用途 |
|---|---|
~/.claude/settings.json |
使用者全域設定 |
~/.claude/keybindings.json |
自訂keyboard shortcuts |
~/.claude/CLAUDE.md |
個人指示(所有專案) |
~/.claude/commands/ |
個人slash commands |
~/.claude/skills/ |
個人skills |
~/.claude/agents/ |
個人subagent定義 |
~/.claude.json |
Runtime state、OAuth tokens、MCP config |
.claude/settings.json |
專案設定(透過git共享) |
.claude/settings.local.json |
專案設定(個人、gitignored) |
.claude/CLAUDE.md |
專案指示 |
.claude/commands/ |
專案slash commands |
.claude/agents/ |
專案subagent定義 |
.claude/skills/ |
專案skills |
.claude/plans/ |
Plan mode輸出檔案 |
.claude/memory/ |
Auto-memory檔案 |
.mcp.json |
專案MCP伺服器config |
CLAUDE.md |
專案指示(root替代位置) |
16. 變更記錄
| 日期 | 變更 |
|---|---|
| 2026年5月13日 | 已同步最新版本線證據至 Claude Code v2.1.140。新增 /goal、Agent View 註記、command-hook args、PostToolUse continueOnBlock,以及 agent hook input 上的 subagent_type。註明 v2.1.140 修正了 ConfigChange、disableAllHooks 和 allowManagedHooksOnly 的行為。本機驗證:claude --version 回傳 2.1.140 (Claude Code)。6 |
| 2026年5月6日 | 已同步最新版本線證據至 Claude Code v2.1.131。由於 v2.1.131 是針對 VS Code Windows 啟用與 Mantle endpoint 驗證的修補版本,因此 command、config、shortcut、hook、plugin 或 env-var 表格皆不需變更。6 |
| 2026年5月5日 | 已同步至 CC guide v2.36(CLI v2.1.126–v2.1.129)。新增:用於載入 plugin zip 的 --plugin-url、--plugin-dir 的 .zip 支援、skillOverrides、CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY、CLAUDE_CODE_PACKAGE_MANAGER_AUTO_UPDATE、CLAUDE_CODE_FORCE_SYNC_OUTPUT,以及 v2.1.129 plugin manifest 對實驗性 themes/monitors 的指引。涵蓋至 v2.1.129。6 |
| 2026年4月29日 | 已同步至 CC guide v2.35(CLI v2.1.117–v2.1.123)。新增:alwaysLoad MCP 選項+啟動時自動重試;claude plugin prune 與 --prune 串連;claude plugin tag;/skills 輸入即篩選;/theme 具名主題;/usage 合併對話框;vim visual modes(v/V);PowerShell 自動核准;hook input 上的 duration_ms+所有 tools 適用的 updatedToolOutput;prUrlTemplate、wslInheritsWindowsSettings、autoMode.allow $defaults;env vars ANTHROPIC_BEDROCK_SERVICE_TIER、ENABLE_TOOL_SEARCH、CLAUDE_CODE_HIDE_CWD、DISABLE_UPDATES、CLAUDE_CODE_FORK_SUBAGENT;--from-pr 接受 GitLab/Bitbucket/GHE PR URLs。涵蓋至 v2.1.123。 |
| 2026年4月19日 | 更新:Sonnet 4.6 1M context 現已顯示為標準 $3/$15(無 long-context premium);pricing 註腳改為 platform.claude.com/docs/en/about-claude/pricing。涵蓋至 v2.1.116。 |
| 2026年4月4日 | 依 CC guide v2.26 重新推導。新增 /powerup、更新 /release-notes、移除 /vim。更新 Ctrl+X Ctrl+K shortcut。新增 4 個 hook events(CwdChanged、FileChanged、TaskCreated、PermissionDenied)。更新 /cost,加入依 model 分列的明細。涵蓋至 v2.1.92。 |
| 2026年3月28日 | cheat sheet 初版發布,涵蓋 Claude Code CLI 至 v2.1.85 |
17. 參考資料
本 cheat sheet 是 完整 Claude Code CLI guide 的快速查閱搭配資料。若需 setup walkthroughs,請參閱 Claude Code quickstart。若是 iOS 與 macOS 專案,請參閱 iOS Agent Development guide、XcodeBuildMCP integration patterns,以及 Apple Ecosystem Series。最後更新日期:2026年5月13日。