# CLI 参考

> ## 文档 索引
> 获取 the 完成 文档 索引 at: https://代码.claude.com/docs/llms.txt
> 使用 this 文件 to disc结束 所有 可用 页s 之前探索 further.

# CLI 参考

> 完成 参考 for Claude 代码 命令-行 接口,包括 命令 and 标志.

## CLI 命令

You can 启动 会话s, 管道 满意, 恢复 对话s, and manage 更新s with these 命令:

| 命令                         | 描述                                                                                                                                                                                                                                 | 示例                                                     |
| :------------------------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :---------------------------------------------------------- |
| `claude`                        | 启动 交互 会话                                                                                                                                                                                                                   | `claude`                                                    |
| `claude "查询"`                | 启动 交互 会话 with initial 及时                                                                                                                                                                                               | `claude "ex简单 this 项目"`                             |
| `claude -p "查询"`             | 查询 via SDK, then 退出                                                                                                                                                                                                                    | `claude -p "ex简单 this 功能"`                         |
| `cat 文件 \| claude -p "查询"` | 流程 管道d 满意                                                                                                                                                                                                                       | `cat 日志s.txt \| claude -p "ex简单"`                       |
| `claude -c`                     | 继续 最多 最近 对话 in 当前 目录                                                                                                                                                                                      | `claude -c`                                                 |
| `claude -c -p "查询"`          | 继续 via SDK                                                                                                                                                                                                                            | `claude -c -p "检查 for 类型 错误"`                      |
| `claude -r "" "查询"` | 恢复 会话 by ID or 名称                                                                                                                                                                                                                | `claude -r "auth-re事实or" "Finish this PR"`                |
| `claude 更新`                 | 更新 to 最新 版本                                                                                                                                                                                                                    | `claude 更新`                                             |
| `claude auth 日志in`             | 标志 in to your Anthropic 说明. 使用 `--email` to pre-fill your email 添加ress, `--sso` to 强制 SSO 认证, and `--控制台` to 标志 in with Anthropic 控制台 for API 使用方法计费 instead of a Claude 订阅              | `claude auth 日志in --控制台`                               |
| `claude auth 标志ut`            | 日志 out from your Anthropic 说明                                                                                                                                                                                                         | `claude auth 标志ut`                                        |
| `claude auth 状态`            | 显示 认证 状态 as JSON. 使用 `--文本` for 人类-读取能够 输出. 退出s with 代码 0 if 日志ged in, 1 if not                                                                                                                        | `claude auth 状态`                                        |
| `claude 代理s`                 | 列表 所有 con图d [子代理](/en/sub-代理s), 分组 by 来源                                                                                                                                                                          | `claude 代理s`                                             |
| `claude auto-模式 默认s`     | Print the built-in [auto 模式](/en/许可-模式s#eliminate-及时s-with-auto-模式) 阶级ifier 规则 as JSON. 使用 `claude auto-模式 config` to看见 your 有效 config with 设置 应用                                            | `claude auto-模式 默认s > 规则.json`                    |
| `claude mcp`                    | Con图 模型上下文协议 (MCP) 服务器s                                                                                                                                                                                              |看见 the [Claude 代码 MCP 文档](/en/mcp).           |
| `claude 插件`                 | Manage Claude 代码 [插件s](/en/插件s). Alias: `claude 插件s`.看见 [插件 参考](/en/插件s-参考#cli-命令-参考) for sub命令                                                                                    | `claude 插件 安装 代码-re视图@claude-插件s-official` |
| `claude 远程-控制`         | 启动 a [远程 控制](/en/远程-控制) 服务器 to 控制 Claude 代码 from Claude.ai or the Claude 应用. 运行s in 服务器 模式 (no 本地 交互 会话).看见 [服务器 模式 标志](/en/远程-控制#启动-a-远程-控制-会话) | `claude 远程-控制 --名称 "My 项目"`                 |

## CLI 标志

习俗ize Claude 代码's behavior with these 命令-行 标志. `claude --帮助` does not 列表 每个 flag, so a flag's absence from `--帮助` does not mean it is 不可用.

| Flag                                      | 描述                                                                                                                                                                                                                                                                                          | 示例                                                                                            |
| :---------------------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------- |
| `--添加-dir`                               | 添加 添加itional工作 总监ies for Claude to 读取 and 编辑 文件. 授予s 文件 access; 最多 `.claude/` 配置 is [not disc结束ed](/en/权限#添加itional-总监ies-授予-文件-access-not-配置) from these 总监ies. 验证s 每个 路径 exists as a 目录            | `claude --添加-dir ../应用s ../lib`                                                                  |
| `--代理`                                 | 规格ify an 代理 for the 当前 会话 (结束rides the `代理`设置)                                                                                                                                                                                                                             | `claude --代理 my-习俗-代理`                                                                   |
| `--代理s`                                | De好 习俗 子代理 动态所有y via JSON. 使用s the 相同 字段 名称s as sub代理 [front事情](/en/sub-代理s#支持ed-front事情-字段s), plus a `及时` 字段 for the 代理's 说明                                                                                                   | `claude --代理s '{"审查员":{"描述":"Re视图s 代码","及时":"You are a 代码 审查员"}}'` |
| `--允许-d愤怒ously-跳-权限`    | 添加 `bypass权限` to the `Shift+Tab` 模式 cycle without 启动ing in it. Lets you begin in a 不同 模式 像 `计划` and switch to `bypass权限` 更晚.看见 [许可 模式s](/en/许可-模式s#跳-所有-检查s-with-bypass权限-模式)                                       | `claude --许可-模式 计划 --允许-d愤怒ously-跳-权限`                               |
| `--允许工具`                          | 工具 that 执行 without 及时ing for 许可.看见 [许可 规则 syn税](/en/设置#许可-规则-syn税) for 模式 匹配. To re严格 which 工具 are 可用, 使用 `--工具` instead                                                                                            | `"Bash(Git 日志 *)" "Bash(Git diff *)" "读取"`                                                      |
| `--应用结束-系统-及时`                  | 应用结束 习俗 文本 to the 结束 of the 默认 系统 及时                                                                                                                                                                                                                                           | `claude --应用结束-系统-及时 "Al方式s 使用 类型脚本"`                                            |
| `--应用结束-系统-及时-文件`             | 加载 添加itional 系统 及时 文本 from a 文件 and 应用结束 to the 默认 及时                                                                                                                                                                                                                      | `claude --应用结束-系统-及时-文件 ./extra-规则.txt`                                             |
| `--赤裸`                                  | 最小 模式:跳 auto-发现 of 钩子, 技能, 插件s, MCP 服务器, auto 记忆, and CLAUDE.md so 脚本ed c所有s 启动 快er. Claude has access to Bash, 文件 读取, and 文件 编辑 工具. 设置s [`CLAUDE_代码_简单`](/en/env-vars).看见 [赤裸 模式](/en/负责人较少#启动-快er-with-赤裸-模式) | `claude --赤裸 -p "查询"`                                                                         |
| `--betas`                                 | Beta 页眉s to include in API 请求s (API 键 用户s only)                                                                                                                                                                                                                                         | `claude --betas interleaved-薄king`                                                              |
| `--通道s`                              | (研究 pre视图) MCP 服务器 whose [通道](/en/通道s) 通知s Claude should 列表en for in this 会话. S步伐-分离 列表 of `插件:@` entries. Requ怒s Claude.ai 认证                                                                                | `claude --通道s 插件:my-notifier@my-市场place`                                              |
| `--chrome`                                | 启用 [Chrome 浏览器 集成](/en/chrome) for 网页 automation and 测试                                                                                                                                                                                                                       | `claude --chrome`                                                                                  |
| `--继续`, `-c`                        | 加载 the 最多 最近 对话 in the 当前 目录                                                                                                                                                                                                                                           | `claude --继续`                                                                                |
| `--d愤怒ously-加载-开发-通道s` | 启用 [通道s](/en/通道s-参考#测试-期间-the-研究-pre视图) that are not on the 批准 允许列表, for 本地 开发. 接受s `插件:@` and `服务器:` entries. 及时s for 确认                                                                | `claude --d愤怒ously-加载-开发-通道s 服务器:网页hook`                                    |
| `--d愤怒ously-跳-权限`          |跳 许可 及时s. 等价 to `--许可-模式 bypass权限`.看见 [许可 模式s](/en/许可-模式s#跳-所有-检查s-with-bypass权限-模式) for what this does and does not跳                                                                                          | `claude --d愤怒ously-跳-权限`                                                            |
| `--调试`                                 | 启用 调试 模式 with 可选 类别过滤 (for 示例, `"api,钩子"` or `"!statsig,!文件"`)                                                                                                                                                                                                | `claude --调试 "api,mcp"`                                                                         |
| `--调试-文件 `                     | 写入 调试 日志s to a 特定 文件 路径. 隐含ly 启用s 调试 模式. Takes precedence 结束 `CLAUDE_代码_调试_日志S_DIR`                                                                                                                                                                          | `claude --调试-文件 /tmp/claude-调试.日志`                                                        |
| `--禁用-slash-命令`                | 禁用 所有 技能 and 命令 for this 会话                                                                                                                                                                                                                                                     | `claude --禁用-slash-命令`                                                                  |
| `--dis允许工具`                       | 工具 that are 移除 from the 模型's 上下文 and cannot be 使用d                                                                                                                                                                                                                                   | `"Bash(Git 日志 *)" "Bash(Git diff *)" "编辑"`                                                      |
| `--effort`                                | 设置 the [effort 级别](/en/模型-config#ad公正-effort-级别) for the 当前 会话. 选项: `低`, `中`, `高`, `max` (Opus 4.6 only). 会话-范围d and does not persist to 设置                                                                                                       | `claude --effort 高`                                                                             |
| `--下降返回-模型`                        | 启用 自动 下降返回 to 指定 模型 when 默认 模型 is 结束加载 (print 模式 only)                                                                                                                                                                                                      | `claude -p --下降返回-模型 sonnet "查询"`                                                        |
| `--分叉-会话`                          | When re总和ing, 创建 a 新 会话 ID instead of reusing the 原始 (使用 with `--恢复` or `--继续`)                                                                                                                                                                                         | `claude --恢复 abc123 --分叉-会话`                                                            |
| `--from-pr`                               | 恢复 会话s 链接 to a 特定 GitHub PR. 接受s a PR 数字 or URL. 会话s are 自动所有y 链接 when 创建d via `gh pr 创建`                                                                                                                                                        | `claude --from-pr 123`                                                                             |
| `--ide`                                   | 自动所有y connect to IDE on 启动上 if 精确ly one 有效 IDE is 可用                                                                                                                                                                                                                        | `claude --ide`                                                                                     |
| `--init`                                  | 运行 initialization 钩子 and 启动 交互 模式                                                                                                                                                                                                                                                  | `claude --init`                                                                                    |
| `--init-only`                             | 运行 initialization 钩子 and 退出 (no 交互 会话)                                                                                                                                                                                                                                           | `claude --init-only`                                                                               |
| `--include-hook-事件s`                   | Include 所有 hook lifecycle 事件s in the 输出 流. Requ怒s `--输出-格式 流-json`                                                                                                                                                                                                       | `claude -p --输出-格式 流-json --include-hook-事件s "查询"`                              |
| `--include-偏袒-消息s`              | Include 偏袒 流ing 事件s in 输出. Requ怒s `--print` and `--输出-格式 流-json`                                                                                                                                                                                                     | `claude -p --输出-格式 流-json --include-偏袒-消息s "查询"`                         |
| `--输入-格式`                          | 规格ify 输入 格式 for print 模式 (选项: `文本`, `流-json`)                                                                                                                                                                                                                                 | `claude -p --输出-格式 json --输入-格式 流-json`                                        |
| `--json-模式`                           | Get 验证 JSON 输出 匹配 a JSON 模式 之后 代理 完成s its 工作流 (print 模式 only,看见 [结构化 输出s](https://平台.claude.com/docs/en/代理-sdk/结构化-输出s))                                                                                                    | `claude -p --json-模式 '{"类型":"对象","适当ties":{...}}' "查询"`                           |
| `--主tenance`                           | 运行 主tenance 钩子 and 启动 交互 模式                                                                                                                                                                                                                                                     | `claude --主tenance`                                                                             |
| `--max-预算-usd`                        | 最大 dollar 数量 to sp结束 on API c所有s 之前停止 (print 模式 only)                                                                                                                                                                                                                        | `claude -p --max-预算-usd 5.00 "查询"`                                                          |
| `--max-turns`                             | 限制 the 数字 of 代理ic turns (print 模式 only). 退出s with an 错误 when the 限制 is 范围ed. No 限制 by 默认                                                                                                                                                                              | `claude -p --max-turns 3 "查询"`                                                                  |
| `--mcp-config`                            | 加载 MCP 服务器 from JSON 文件 or 字符串s (s步伐-分离)                                                                                                                                                                                                                                        | `claude --mcp-config ./mcp.json`                                                                   |
| `--模型`                                 | 设置s the 模型 for the 当前 会话 with an alias for the 最新 模型 (`sonnet` or `opus`) or a 模型's 满 名称                                                                                                                                                                                | `claude --模型 claude-sonnet-4-6`                                                                 |
| `--名称`, `-n`                            | 设置 a 显示 名称 for the 会话, 显示n in `/恢复` and the 终端 标题. You can 恢复 a 名称d 会话 with `claude --恢复 `. [`/重命名`](/en/命令) 更改s the 名称 mid-会话 and also 显示s it on the 及时 bar                                                  | `claude -n "my-feature-工作"`                                                                      |
| `--no-chrome`                             | 禁用 [Chrome 浏览器 集成](/en/chrome) for this 会话                                                                                                                                                                                                                                    | `claude --no-chrome`                                                                               |
| `--no-会话-persistence`                | 禁用 会话 persistence so 会话s are not 保存 to disk and cannot be 恢复d (print 模式 only)                                                                                                                                                                                                | `claude -p --no-会话-persistence "查询"`                                                       |
| `--输出-格式`                         | 规格ify 输出 格式 for print 模式 (选项: `文本`, `json`, `流-json`)                                                                                                                                                                                                                        | `claude -p "查询" --输出-格式 json`                                                           |
| `--启用-auto-模式`                      | 解锁 [auto 模式](/en/许可-模式s#eliminate-及时s-with-auto-模式) in the `Shift+Tab` cycle. Requ怒s a 团队, 企业, or API 计划 and Claude Sonnet 4.6 or Opus 4.6                                                                                                                       | `claude --启用-auto-模式`                                                                        |
| `--许可-模式`                       | Begin in a 指定 [许可 模式](/en/许可-模式s). 接受s `默认`, `接受its`, `计划`, `auto`, `don任务`, or `bypass权限`. 结束rides `默认模式` from 设置 文件                                                                                                       | `claude --许可-模式 计划`                                                                    |
| `--许可-及时-工具`                | 规格ify an MCP 工具 to handle 许可 及时s in non-交互 模式                                                                                                                                                                                                                             | `claude -p --许可-及时-工具 mcp_auth_工具 "查询"`                                         |
| `--插件-dir`                            | 加载 插件s from a 目录 for this 会话 only. 每个 flag takes one 路径. Repeat the flag for mul提示le 总监ies: `--插件-dir A --插件-dir B`                                                                                                                                             | `claude --插件-dir ./my-插件s`                                                                 |
| `--print`, `-p`                           | Print 响应 without 交互 模式 (看见 [代理 SDK 文档](https://平台.claude.com/docs/en/代理-sdk/概述) for 计划matic 使用方法 详情s)                                                                                                                                       | `claude -p "查询"`                                                                                |
| `--远程`                                | 创建 a 新 [网页 会话](/en/claude-代码-on-the-网页) on claude.ai with the provided 任务 描述                                                                                                                                                                                               | `claude --远程 "修复 the 日志in 缺陷"`                                                              |
| `--远程-控制`, `--rc`                | 启动 an 交互 会话 with [远程 控制](/en/远程-控制#启动-a-远程-控制-会话) 启用 so you can also 控制 it from claude.ai or the Claude 应用. 可选ly pass a 名称 for the 会话                                                                                    | `claude --远程-控制 "My 项目"`                                                             |
| `--replay-用户-消息s`                  | Re-emit 用户 消息s from stdin 返回 on stdout for 确认. Requ怒s `--输入-格式 流-json` and `--输出-格式 流-json`                                                                                                                                                          | `claude -p --输入-格式 流-json --输出-格式 流-json --replay-用户-消息s`          |
| `--恢复`, `-r`                          | 恢复 a 特定 会话 by ID or 名称, or 显示 an 交互 picker to choose a 会话                                                                                                                                                                                                           | `claude --恢复 auth-re事实or`                                                                    |
| `--会话-id`                            | 使用 a 特定 会话 ID for the 对话 (must be a 有效 UUID)                                                                                                                                                                                                                                | `claude --会话-id "550e8400-e29b-41d4-a716-446655440000"`                                       |
| `--设置ting-来源s`                       | Comma-分离 列表 of设置 来源s to 加载 (`用户`, `项目`, `本地`)                                                                                                                                                                                                                         | `claude --设置ting-来源s 用户,项目`                                                            |
| `--设置`                              | 路径 to a 设置 JSON 文件 or a JSON 字符串 to 加载 添加itional 设置 from                                                                                                                                                                                                                       | `claude --设置 ./设置.json`                                                                |
| `--严格-mcp-config`                     | Only 使用 MCP 服务器 from `--mcp-config`, ignoring 所有 other MCP 配置s                                                                                                                                                                                                                      | `claude --严格-mcp-config --mcp-config ./mcp.json`                                               |
| `--系统-及时`                         | 替换 the 整个 系统 及时 with 习俗 文本                                                                                                                                                                                                                                                    | `claude --系统-及时 "You are a Python 专家"`                                                 |
| `--系统-及时-文件`                    | 加载 系统 及时 from a 文件, replacing the 默认 及时                                                                                                                                                                                                                                         | `claude --系统-及时-文件 ./习俗-及时.txt`                                                  |
| `--tele端口`                              | 恢复 a [网页 会话](/en/claude-代码-on-the-网页) in your 本地 终端                                                                                                                                                                                                                            | `claude --tele端口`                                                                                |
| `--团队mate-模式`                         | 设置 how [代理 团队](/en/代理-团队) 团队mates 显示: `auto` (默认), `in-流程`, or `tmux`.看见 [Choose a 显示 模式](/en/代理-团队#choose-a-显示-模式)                                                                                                                               | `claude --团队mate-模式 in-流程`                                                                |
| `--tmux`                                  | 创建 a tmux 会话 for the 工作树. Requ怒s `--工作树`. 使用s iTerm2 本地 panes when 可用; pass `--tmux=经典` for 传统 tmux                                                                                                                                                   | `claude -w feature-auth --tmux`                                                                    |
| `--工具`                                 | Re严格 which built-in 工具 Claude can 使用. 使用 `""` to 禁用 所有, `"默认"` for 所有, or 工具 名称s 像 `"Bash,编辑,读取"`                                                                                                                                                                    | `claude --工具 "Bash,编辑,读取"`                                                                  |
| `--详细`                               | 启用 详细日志, 显示s 满 turn-by-turn 输出                                                                                                                                                                                                                                               | `claude --详细`                                                                                 |
| `--版本`, `-v`                         | 输出 the 版本 数字                                                                                                                                                                                                                                                                            | `claude -v`                                                                                        |
| `--工作树`, `-w`                        | 启动 Claude in an iso晚d [Git 工作树](/en/常见-工作流s#运行-平行-claude-代码-会话s-with-Git-工作树) at `/.claude/工作树/`. If no 名称 is given, one is auto-gene速率d                                                                                               | `claude -w feature-auth`                                                                           |

### 系统 及时 标志

Claude 代码 provides four 标志 for 习俗izing the 系统 及时. 所有 four 工作 in 机器人h 交互 and non-交互 模式s.

| Flag                          | Behavior                                    | 示例                                                 |
| :---------------------------- | :------------------------------------------ | :------------------------------------------------------ |
| `--系统-及时`             | 替换s the 整个 默认 及时          | `claude --系统-及时 "You are a Python 专家"`      |
| `--系统-及时-文件`        | 替换s with 文件 满意s                 | `claude --系统-及时-文件 ./及时s/re视图.txt`      |
| `--应用结束-系统-及时`      | 应用结束s to the 默认 及时               | `claude --应用结束-系统-及时 "Al方式s 使用 类型脚本"` |
| `--应用结束-系统-及时-文件` | 应用结束s 文件 满意s to the 默认 及时 | `claude --应用结束-系统-及时-文件 ./style-规则.txt`  |

`--系统-及时` and `--系统-及时-文件` are 互相ly exclusive. The 应用结束 标志 can be 组合 with either 替换ment flag.

For 最多 使用 案例s, 使用 an 应用结束 flag. Ap待处理 preserves Claude 代码's built-in 能力 while添加 your 要求. 使用 a 替换ment flag only when you 需要 完成 控制 结束 the 系统 及时.

## 另见

* [Chrome 扩展](/en/chrome) - 浏览器 automation and 网页 测试
* [交互 模式](/en/交互-模式) - 短剪切s, 输入 模式s, and 交互 features
* [快速入门 指南](/en/快速入门) - 入门 with Claude 代码
* [通用工作流](/en/常见-工作流s) - 先进 工作流s and 模式s
* [设置](/en/设置) - 配置 选项
* [代理 SDK 文档](https://平台.claude.com/docs/en/代理-sdk/概述) - 计划matic 使用方法 and 集成s