--add-dir | 新增額外的工作目錄供 Claude 讀取和編輯檔案。授予檔案存取權;大多數 .claude/ 設定 未從這些目錄探索。驗證每個路徑是否存在為目錄。若要在工作階段之間持久化這些目錄,請在設定中設定 permissions.additionalDirectories | claude --add-dir ../apps ../lib |
--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 | 無需提示權限即可執行的工具。請參閱 permission rule syntax 以了解模式匹配。若要限制可用的工具,請改用 --tools | "Bash(git log *)" "Bash(git diff *)" "Read" |
--append-system-prompt | 將自訂文字附加到預設系統提示的末尾 | claude --append-system-prompt "Always use TypeScript" |
--append-system-prompt-file | 從檔案載入額外的系統提示文字並附加到預設提示 | claude --append-system-prompt-file ./extra-rules.txt |
--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 agent 身份啟動工作階段並立即返回。列印工作階段 ID 和管理命令。與 --exec 結合以執行 shell 命令作為背景工作而不是 Claude 工作階段,或與 --agent 結合以執行特定 subagent | 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 |
--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 | 拒絕規則。裸工具名稱會從模型的內容中移除該工具。範圍規則(例如 Bash(rm *) )會保留工具可用,但只拒絕符合的呼叫 | "Bash(git log *)" "Bash(git diff *)" "Edit" |
--effort | 為目前工作階段設定 effort level。選項:low、medium、high、xhigh、max;可用的層級取決於模型。覆蓋此工作階段的 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 | 當預設模型過載或無法使用時啟用自動回退到指定的模型,例如已淘汰的模型。在列印模式(-p)和 background sessions 中生效,這些工作階段以非互動方式執行;在互動式工作階段中忽略 | claude -p --fallback-model sonnet "query" |
--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 -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 | 限制代理程式轉數(僅列印模式)。達到限制時以錯誤退出。預設無限制 | claude -p --max-turns 3 "query" |
--mcp-config | 從 JSON 檔案或字串載入 MCP 伺服器(以空格分隔) | claude --mcp-config ./mcp.json |
--model | 使用最新模型的別名(sonnet 或 opus)或模型的完整名稱為目前工作階段設定模型。覆蓋 model 設定和 ANTHROPIC_MODEL | claude --model claude-sonnet-4-6 |
--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。覆蓋設定檔案中的 defaultMode | claude --permission-mode plan |
--permission-prompt-tool | 指定 MCP 工具以在非互動模式下處理權限提示 | 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 | 在 claude.ai 上建立新的 web session,並提供工作描述 | 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 新增此目錄的工作階段。自 v2.1.144 起,background sessions 在選擇器中出現,標記為 bg | claude --resume auth-refactor |
--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 隊友的顯示方式:auto(預設)、in-process 或 tmux。覆蓋此工作階段的 teammateMode 設定。請參閱 選擇顯示模式 | claude --teammate-mode in-process |
--tmux | 為 worktree 建立 tmux 工作階段。需要 --worktree。在可用時使用 iTerm2 原生窗格;傳遞 --tmux=classic 以使用傳統 tmux | claude -w feature-auth --tmux |
--tools | 限制 Claude 可以使用的內建工具。使用 "" 停用全部,"default" 為全部,或工具名稱如 "Bash,Edit,Read" | 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 |