--add-dir | 新增額外的工作目錄供 Claude 讀取和編輯檔案。授予檔案存取權;大多數 .claude/ 設定 未從這些目錄探索。驗證每個路徑是否存在為目錄。若要在工作階段之間持久化這些目錄,請在設定中設定 permissions.additionalDirectories | claude --add-dir ../apps ../lib |
--advisor <model> | 使用模型別名啟用此工作階段的伺服器端 advisor tool:opus、sonnet 或 fable(v2.1.170+),或完整模型 ID。優先於工作階段的 advisorModel 設定 | claude --advisor opus |
--agent | 為目前工作階段指定代理程式(覆蓋 agent 設定) | claude --agent my-custom-agent |
--agents | 透過 JSON 動態定義自訂 subagents。使用與 subagent frontmatter 相同的欄位名稱,加上代理程式指示的 prompt 欄位 | claude --agents '{"reviewer":{"description":"Reviews code","prompt":"You are a code reviewer"}}' |
--allow-dangerously-skip-permissions | 新增 bypassPermissions 到 Shift+Tab 模式循環而不立即啟動它。允許您以不同的模式(如 plan)開始,稍後切換到 bypassPermissions。請參閱 permission modes | claude --permission-mode plan --allow-dangerously-skip-permissions |
--allowedTools、--allowed-tools | 無需提示權限即可執行的工具。請參閱 permission rule syntax 以了解模式匹配。若要限制可用的工具,請改用 --tools | "Bash(git log *)" "Bash(git diff *)" "Read" |
--append-subagent-system-prompt | 將自訂文字附加到每個 subagent 系統提示的末尾,包括巢狀 subagents。僅適用於使用 -p 的非互動模式。需要 Claude Code v2.1.205 或更新版本 | claude -p --append-subagent-system-prompt "Cite file paths in every answer" "query" |
--append-system-prompt | 將自訂文字附加到預設系統提示的末尾 | claude --append-system-prompt "Always use TypeScript" |
--append-system-prompt-file | 從檔案載入額外的系統提示文字並附加到預設提示 | claude --append-system-prompt-file ./extra-rules.txt |
--ax-screen-reader | 呈現螢幕閱讀器友善的輸出:平面文字,無裝飾邊框或動畫。強制使用經典渲染器,因此 tui 設定在工作階段中無效;附加的 background sessions 仍會全螢幕呈現。優先於 CLAUDE_AX_SCREEN_READER 和 axScreenReader 設定。需要 Claude Code v2.1.181 或更新版本 | claude --ax-screen-reader |
--bare | 最小模式:跳過 hooks、skills、plugins、MCP 伺服器、自動記憶體和 CLAUDE.md 的自動探索,以便指令碼呼叫啟動更快。Claude 可以存取 Bash、檔案讀取和檔案編輯工具。設定 CLAUDE_CODE_SIMPLE。請參閱 bare mode | claude --bare -p "query" |
--betas | 要包含在 API 請求中的 Beta 標頭(僅限 API 金鑰使用者) | claude --betas interleaved-thinking |
--bg、--background | 以 background agent 身份啟動工作階段並立即返回。列印工作階段 ID 和管理命令。與 --exec 結合以執行 shell 命令作為背景工作而不是 Claude 工作階段,或與 --agent 結合以執行特定 subagent。無法與 -p/--print 結合;請參閱 error reference | claude --bg "investigate the flaky test" |
--channels | (研究預覽)MCP 伺服器,其 channel 通知 Claude 應在此工作階段中監聽。以空格分隔的 plugin:<name>@<marketplace> 項目清單。需要 Claude.ai 驗證 | claude --channels plugin:my-notifier@my-marketplace |
--chrome | 啟用 Chrome 瀏覽器整合 以進行網頁自動化和測試 | claude --chrome |
--cloud | 在 claude.ai 上建立新的 web session,並提供工作描述 | claude --cloud "Fix the login bug" |
--continue、-c | 載入目前目錄中最近的對話。包括使用 /add-dir 新增此目錄的工作階段 | claude --continue |
--dangerously-load-development-channels | 啟用不在核准允許清單上的 channels,用於本機開發。接受 plugin:<name>@<marketplace> 和 server:<name> 項目。提示確認 | claude --dangerously-load-development-channels server:webhook |
--dangerously-skip-permissions | 略過權限提示。等同於 --permission-mode bypassPermissions。請參閱 permission modes 以了解此操作會和不會略過的內容 | claude --dangerously-skip-permissions |
--debug | 啟用偵錯模式,可選類別篩選(例如,"api,hooks" 或 "!statsig,!file") | claude --debug "api,mcp" |
--debug-file <path> | 將偵錯日誌寫入特定檔案路徑。隱含啟用偵錯模式。優先於 CLAUDE_CODE_DEBUG_LOGS_DIR | claude --debug-file /tmp/claude-debug.log |
--disable-slash-commands | 為此工作階段停用所有 skills 和命令 | claude --disable-slash-commands |
--disallowedTools、--disallowed-tools | 拒絕規則。裸工具名稱會從模型的內容中移除該工具:"Edit" 移除 Edit、"*" 移除每個工具,"mcp__*" 移除每個 MCP 工具。範圍規則(例如 Bash(rm *) )會保留工具可用,但只拒絕符合的呼叫 | "Bash(git log *)" "Bash(git diff *)" "Edit" |
--effort | 為目前工作階段設定 effort level。選項:low、medium、high、xhigh、max 或 }ultracode。可用的層級取決於模型。ultracode 以 xhigh 努力開始工作階段,並啟用 ultracode,需要 Claude Code v2.1.203 或更新版本。覆蓋此工作階段的 effortLevel 設定,且不會持久化 | claude --effort high |
--enable-auto-mode | 在 v2.1.111 中移除。Auto mode 現在預設在 Shift+Tab 循環中;使用 --permission-mode auto 以它開始 | claude --permission-mode auto |
--exclude-dynamic-system-prompt-sections | 將每台機器的系統提示部分(工作目錄、環境資訊、記憶體路徑、git 狀態旗標)移至第一個使用者訊息。改善在執行相同工作的不同使用者和機器之間的提示快取重複使用。僅適用於預設系統提示;設定 --system-prompt 或 --system-prompt-file 時忽略。與 -p 搭配使用以進行指令碼化、多使用者工作負載 | claude -p --exclude-dynamic-system-prompt-sections "query" |
--exec | 執行 shell 命令作為 PTY 支援的背景工作而不是啟動 Claude 工作階段。與 --bg 搭配使用以從 shell 啟動 | claude --bg --exec 'pytest -x' |
--fallback-model | 當主要模型過載或無法使用時啟用自動回退到指定的模型,例如已淘汰的模型。接受以逗號分隔的清單,依序嘗試。請參閱 Fallback model chains。若要在工作階段之間持久化鏈,請使用 fallbackModel 設定,此旗標會覆蓋它 | claude --fallback-model sonnet,haiku |
--fork-session | 繼續時,建立新的工作階段 ID 而不是重複使用原始 ID(與 --resume 或 --continue 搭配使用) | claude --resume abc123 --fork-session |
--from-pr | 繼續連結到特定提取請求的工作階段。接受 PR 編號、GitHub 或 GitHub Enterprise PR URL、GitLab 合併請求 URL 或 Bitbucket 提取請求 URL。當 Claude 建立提取請求時,工作階段會自動連結 | claude --from-pr 123 |
--ide | 如果恰好有一個有效的 IDE 可用,在啟動時自動連線到 IDE | claude --ide |
--init | 在工作階段前執行 Setup hooks,使用 init 匹配器(僅列印模式) | claude -p --init "query" |
--init-only | 執行 Setup 和 SessionStart hooks,然後退出而不啟動對話 | claude --init-only |
--include-hook-events | 在輸出串流中包含所有 hook 生命週期事件。需要 --output-format stream-json | claude -p --output-format stream-json --verbose --include-hook-events "query" |
--include-partial-messages | 在輸出中包含部分串流事件。需要 --print 和 --output-format stream-json | claude -p --output-format stream-json --verbose --include-partial-messages "query" |
--input-format | 為列印模式指定輸入格式(選項:text、stream-json) | claude -p --output-format json --input-format stream-json |
--json-schema | 在代理程式完成其工作流程後取得符合 JSON Schema 的驗證 JSON 輸出(僅列印模式)。請參閱 structured outputs。Claude Code 在無效的 schema 上以錯誤退出,並接受 format 關鍵字作為註解而不進行用戶端驗證。在 v2.1.205 之前,無效的 schema 產生無結構輸出且無錯誤,使用 format 的 schemas 被視為無效 | claude -p --json-schema '{"type":"object","properties":{...}}' "query" |
--maintenance | 在工作階段前執行 Setup hooks,使用 maintenance 匹配器(僅列印模式) | claude -p --maintenance "query" |
--max-budget-usd | 在停止前在 API 呼叫上花費的最大美元金額(僅列印模式) | claude -p --max-budget-usd 5.00 "query" |
--max-turns | 限制代理程式轉數(僅列印模式)。達到限制時以錯誤退出。預設無限制。使用 --input-format stream-json 時,在 Claude 工作時傳送的訊息會保持佇列狀態,並在限制結束目前轉數時作為自己的轉數執行,具有自己的限制。在 v2.1.205 之前,Claude Code 丟棄該訊息 | claude -p --max-turns 3 "query" |
--mcp-config | 從 JSON 檔案或字串載入 MCP 伺服器(以空格分隔) | claude --mcp-config ./mcp.json |
--model | 使用最新模型的別名(sonnet、opus、haiku 或 fable)或模型的完整名稱為目前工作階段設定模型。覆蓋 model 設定和 ANTHROPIC_MODEL | claude --model claude-sonnet-5 |
--name、-n | 為工作階段設定顯示名稱,顯示在 /resume 和終端標題中。您可以使用 claude --resume <name> 繼續已命名的工作階段。
/rename 在工作階段中途變更名稱,也會在提示列中顯示 | claude -n "my-feature-work" |
--no-chrome | 為此工作階段停用 Chrome 瀏覽器整合 | claude --no-chrome |
--no-session-persistence | 停用工作階段持久性,使工作階段不會儲存到磁碟且無法繼續。僅列印模式。CLAUDE_CODE_SKIP_PROMPT_HISTORY 環境變數在任何模式中執行相同操作 | claude -p --no-session-persistence "query" |
--output-format | 為列印模式指定輸出格式(選項:text、json、stream-json) | claude -p "query" --output-format json |
--permission-mode | 以指定的 permission mode 開始。接受 default、acceptEdits、plan、auto、dontAsk、bypassPermissions 或 }manual 作為 default 的別名。manual 別名選擇 UI 標記為「手動」的模式,需要 Claude Code v2.1.200 或更新版本;claude --help 會列出它以取代 default,兩個值都有效。覆蓋設定檔案中的 defaultMode | claude --permission-mode plan |
--permission-prompt-tool | 指定 MCP 工具以在非互動模式下處理權限提示。自 v2.1.199 起,提示工具無法核准標記為 requiring user interaction 的 MCP 工具:一個的 allow 結果會轉換為拒絕 | claude -p --permission-prompt-tool mcp_auth_tool "query" |
--plugin-dir | 為此工作階段僅從目錄或 .zip 封存載入 plugin。每個旗標採用一個路徑。重複旗標以使用多個 plugins:--plugin-dir A --plugin-dir B.zip | claude --plugin-dir ./my-plugin |
--plugin-url | 為此工作階段僅從 URL 擷取 plugin .zip 封存。重複旗標以使用多個 plugins,或在單一引用值中傳遞以空格分隔的 URL | claude --plugin-url https://example.com/plugin.zip |
--print、-p | 列印回應而不進入互動模式(請參閱 Agent SDK 文件 以了解程式化使用詳細資訊) | claude -p "query" |
--prompt-suggestions | 在每個轉數後發出 prompt_suggestion 訊息,其中包含預測的下一個使用者提示。需要 --print、--output-format stream-json 和 --verbose。請參閱 Prompt suggestions | claude -p --prompt-suggestions --output-format stream-json --verbose "query" |
--remote | --cloud 的已棄用別名 | claude --remote "Fix the login bug" |
--remote-control、--rc | 啟動互動式工作階段,並啟用 Remote Control,以便您也可以從 claude.ai 或 Claude 應用程式控制它。可選擇傳遞工作階段的名稱 | claude --remote-control "My Project" |
--remote-control-session-name-prefix <prefix> | Remote Control 工作階段名稱的前綴,當未設定明確名稱時自動產生。預設為您的機器主機名稱,產生如 myhost-graceful-unicorn 的名稱。設定 CLAUDE_REMOTE_CONTROL_SESSION_NAME_PREFIX 以獲得相同效果 | claude remote-control --remote-control-session-name-prefix dev-box |
--replay-user-messages | 從 stdin 重新發出使用者訊息回到 stdout 以進行確認。需要 --input-format stream-json 和 --output-format stream-json | claude -p --input-format stream-json --output-format stream-json --verbose --replay-user-messages |
--resume、-r | 按 ID 或名稱繼續特定工作階段,或顯示互動式選擇器以選擇工作階段。選擇器和名稱搜尋包括使用 /add-dir 新增此目錄的工作階段;傳遞工作階段 ID 只搜尋目前專案目錄及其 git worktrees。自 v2.1.144 起,background sessions 在選擇器中出現,標記為 bg | claude --resume auth-refactor |
--safe-mode | 以所有自訂項目停用的狀態啟動以排除故障的設定:CLAUDE.md、skills、plugins、hooks、MCP 伺服器、自訂命令和代理程式、輸出樣式、工作流程、自訂主題、自訂快捷鍵、狀態列和檔案建議命令、LSP 伺服器和自動記憶體不會載入。驗證、模型選擇、內建工具和權限正常運作,這與 --bare 不同。受管設定原則仍然適用,包括原則設定的 hooks、狀態列和檔案建議命令;受管 plugins、受管 skills、受管 CLAUDE.md 和原則設定的 MCP 伺服器不會。用於檢查自訂項目是否觸發 automatic fallback from Fable 5。設定 CLAUDE_CODE_SAFE_MODE | claude --safe-mode |
--session-id | 為對話使用特定的工作階段 ID(必須是有效的 UUID) | claude --session-id "550e8400-e29b-41d4-a716-446655440000" |
--setting-sources | 要載入的設定來源的逗號分隔清單(user、project、local) | claude --setting-sources user,project |
--settings | 設定 JSON 檔案的路徑或內嵌 JSON 字串。您在此設定的值會覆蓋此工作階段中 settings.json 檔案中的相同金鑰。您省略的金鑰保留其檔案型值。請參閱 settings precedence | claude --settings ./settings.json |
--strict-mcp-config | 僅使用 --mcp-config 中的 MCP 伺服器,忽略所有其他 MCP 設定 | claude --strict-mcp-config --mcp-config ./mcp.json |
--system-prompt | 用自訂文字取代整個系統提示 | claude --system-prompt "You are a Python expert" |
--system-prompt-file | 從檔案載入系統提示,取代預設提示 | claude --system-prompt-file ./custom-prompt.txt |
--teleport | 在本機終端中繼續 web session | claude --teleport |
--teammate-mode | 設定 agent team 隊友的顯示方式:in-process(預設)、auto、tmux 或 }iterm2(在 v2.1.186 中新增)。預設在 v2.1.179 中從 auto 變更。覆蓋此工作階段的 teammateMode 設定。請參閱 選擇顯示模式 | claude --teammate-mode auto |
--tmux | 為 worktree 建立 tmux 工作階段。需要 --worktree。在可用時使用 iTerm2 原生窗格;傳遞 --tmux=classic 以使用傳統 tmux | claude -w feature-auth --tmux |
--tools | 限制 Claude 可以使用的內建工具。使用 "" 停用全部、"default" 為全部,或工具名稱如 "Bash,Edit,Read"。MCP 工具不受影響;若要拒絕這些工具,請改用 --disallowedTools "mcp__*",或傳遞 --strict-mcp-config 而不使用 --mcp-config 以便不載入 MCP 伺服器 | claude --tools "Bash,Edit,Read" |
--verbose | 啟用詳細記錄,顯示完整的逐轉輸出。覆蓋此工作階段的 viewMode 設定 | claude --verbose |
--version、-v | 輸出版本號 | claude -v |
--worktree、-w | 在隔離的 git worktree 中啟動 Claude,位於 <repo>/.claude/worktrees/<name>。如果未提供名稱,則會自動產生一個。傳遞 #<number> 或 GitHub 提取請求 URL 以從 origin 擷取該 PR 並從它分支 worktree | claude -w feature-auth |