--- read_when: - 添加或修改 CLI 命令或选项时 - 为新的命令界面编写文档时 summary: "`openclaw` 命令、子命令和选项的 OpenClaw CLI 参考" title: CLI 参考 x-i18n: generated_at: "2026-03-16T06:22:35Z" model: gpt-5.4 provider: openai source_hash: a2bca34fca64558a8d91fc640ad3880e79677e81d0f605083edc6cbe86bfba53 source_path: cli/index.md workflow: 15 --- # CLI 参考 本页描述当前的 CLI 行为。如果命令发生变化,请更新此文档。 ## 命令页面 - [`setup`](/cli/setup) - [`onboard`](/cli/onboard) - [`configure`](/cli/configure) - [`config`](/cli/config) - [`completion`](/cli/completion) - [`doctor`](/cli/doctor) - [`dashboard`](/cli/dashboard) - [`backup`](/cli/backup) - [`reset`](/cli/reset) - [`uninstall`](/cli/uninstall) - [`update`](/cli/update) - [`message`](/cli/message) - [`agent`](/cli/agent) - [`agents`](/cli/agents) - [`acp`](/cli/acp) - [`status`](/cli/status) - [`health`](/cli/health) - [`sessions`](/cli/sessions) - [`gateway`](/cli/gateway) - [`logs`](/cli/logs) - [`system`](/cli/system) - [`models`](/cli/models) - [`memory`](/cli/memory) - [`directory`](/cli/directory) - [`nodes`](/cli/nodes) - [`devices`](/cli/devices) - [`node`](/cli/node) - [`approvals`](/cli/approvals) - [`sandbox`](/cli/sandbox) - [`tui`](/cli/tui) - [`browser`](/cli/browser) - [`cron`](/cli/cron) - [`dns`](/cli/dns) - [`docs`](/cli/docs) - [`hooks`](/cli/hooks) - [`webhooks`](/cli/webhooks) - [`pairing`](/cli/pairing) - [`qr`](/cli/qr) - [`plugins`](/cli/plugins)(插件命令) - [`channels`](/cli/channels) - [`security`](/cli/security) - [`secrets`](/cli/secrets) - [`skills`](/cli/skills) - [`daemon`](/cli/daemon)(Gateway 网关服务命令的旧别名) - [`clawbot`](/cli/clawbot)(旧别名命名空间) - [`voicecall`](/cli/voicecall)(插件;如已安装) ## 全局标志 - `--dev`:将状态隔离到 `~/.openclaw-dev` 下,并变更默认端口。 - `--profile `:将状态隔离到 `~/.openclaw-` 下。 - `--no-color`:禁用 ANSI 颜色。 - `--update`:`openclaw update` 的简写(仅适用于源码安装)。 - `-V`, `--version`, `-v`:打印版本并退出。 ## 输出样式 - ANSI 颜色和进度指示器仅在 TTY 会话中渲染。 - OSC-8 超链接会在受支持的终端中显示为可点击链接;否则会回退为纯 URL。 - `--json`(以及在支持处的 `--plain`)会禁用样式,以获得干净输出。 - `--no-color` 会禁用 ANSI 样式;同时也支持 `NO_COLOR=1`。 - 长时间运行的命令会显示进度指示器(支持时使用 OSC 9;4)。 ## 调色板 OpenClaw 在 CLI 输出中使用龙虾色调调色板。 - `accent` (#FF5A2D):标题、标签、主要高亮。 - `accentBright` (#FF7A3D):命令名称、强调。 - `accentDim` (#D14A22):次级高亮文本。 - `info` (#FF8A5B):信息性值。 - `success` (#2FBF71):成功状态。 - `warn` (#FFB020):警告、回退、注意事项。 - `error` (#E23D2D):错误、失败。 - `muted` (#8B7F77):弱化显示、元数据。 调色板唯一来源:`src/terminal/palette.ts`(也称为 “lobster seam”)。 ## 命令树 ``` openclaw [--dev] [--profile ] setup onboard configure config get set unset completion doctor dashboard backup create verify security audit secrets reload migrate reset uninstall update channels list status logs add remove login logout directory skills list info check plugins list info install enable disable doctor memory status index search message agent agents list add delete acp status health sessions gateway call health status probe discover install uninstall start stop restart run daemon status install uninstall start stop restart logs system event heartbeat last|enable|disable presence models list status set set-image aliases list|add|remove fallbacks list|add|remove|clear image-fallbacks list|add|remove|clear scan auth add|setup-token|paste-token auth order get|set|clear sandbox list recreate explain cron status list add edit rm enable disable runs run nodes devices node run status install uninstall start stop restart approvals get set allowlist add|remove browser status start stop reset-profile tabs open focus close profiles create-profile delete-profile screenshot snapshot navigate resize click type press hover drag select upload fill dialog wait evaluate console pdf hooks list info check enable disable install update webhooks gmail setup|run pairing list approve qr clawbot qr docs dns setup tui ``` 注意:插件可以添加额外的顶层命令(例如 `openclaw voicecall`)。 ## 安全 - `openclaw security audit` — 审计配置 + 本地状态中常见的安全陷阱。 - `openclaw security audit --deep` — 尽力进行实时 Gateway 网关探测。 - `openclaw security audit --fix` — 收紧安全默认值并对状态 / 配置执行 chmod。 ## 密钥 - `openclaw secrets reload` — 重新解析引用,并以原子方式替换运行时快照。 - `openclaw secrets audit` — 扫描明文残留、未解析引用和优先级漂移。 - `openclaw secrets configure` — 用于提供商设置 + SecretRef 映射 + 预检 / 应用的交互式助手。 - `openclaw secrets apply --from ` — 应用先前生成的计划(支持 `--dry-run`)。 ## 插件 管理扩展及其配置: - `openclaw plugins list` — 发现插件(机器输出请使用 `--json`)。 - `openclaw plugins info ` — 显示插件详情。 - `openclaw plugins install ` — 安装插件(或将插件路径添加到 `plugins.load.paths`)。 - `openclaw plugins enable ` / `disable ` — 切换 `plugins.entries..enabled`。 - `openclaw plugins doctor` — 报告插件加载错误。 大多数插件更改都需要重启 gateway。参见 [/plugin](/tools/plugin)。 ## 内存 对 `MEMORY.md` + `memory/*.md` 执行向量搜索: - `openclaw memory status` — 显示索引统计信息。 - `openclaw memory index` — 重新索引内存文件。 - `openclaw memory search ""`(或 `--query ""`)— 对内存执行语义搜索。 ## 聊天斜杠命令 聊天消息支持 `/...` 命令(文本和原生)。参见 [/tools/slash-commands](/tools/slash-commands)。 重点: - `/status` 用于快速诊断。 - `/config` 用于持久化配置更改。 - `/debug` 用于仅运行时的配置覆盖(内存中,不写磁盘;要求 `commands.debug: true`)。 ## 设置 + 新手引导 ### `setup` 初始化配置 + 工作区。 选项: - `--workspace `:智能体工作区路径(默认 `~/.openclaw/workspace`)。 - `--wizard`:运行新手引导。 - `--non-interactive`:无提示运行新手引导。 - `--mode `:新手引导模式。 - `--remote-url `:远程 Gateway 网关 URL。 - `--remote-token `:远程 Gateway 网关 token。 只要存在任意新手引导标志(`--non-interactive`, `--mode`, `--remote-url`, `--remote-token`),就会自动运行新手引导。 ### `onboard` 用于设置 gateway、工作区和 Skills 的交互式新手引导。 选项: - `--workspace ` - `--reset`(在运行新手引导前重置配置 + 凭据 + 会话) - `--reset-scope `(默认 `config+creds+sessions`;使用 `full` 还会删除工作区) - `--non-interactive` - `--mode ` - `--flow `(`manual` 是 `advanced` 的别名) - `--auth-choice ` - `--token-provider `(非交互式;与 `--auth-choice token` 一起使用) - `--token `(非交互式;与 `--auth-choice token` 一起使用) - `--token-profile-id `(非交互式;默认:`:manual`) - `--token-expires-in `(非交互式;例如 `365d`、`12h`) - `--secret-input-mode `(默认 `plaintext`;使用 `ref` 可存储提供商默认环境引用,而非明文密钥) - `--anthropic-api-key ` - `--openai-api-key ` - `--mistral-api-key ` - `--openrouter-api-key ` - `--ai-gateway-api-key ` - `--moonshot-api-key ` - `--kimi-code-api-key ` - `--gemini-api-key ` - `--zai-api-key ` - `--minimax-api-key ` - `--opencode-zen-api-key ` - `--opencode-go-api-key ` - `--custom-base-url `(非交互式;与 `--auth-choice custom-api-key` 或 `--auth-choice ollama` 一起使用) - `--custom-model-id `(非交互式;与 `--auth-choice custom-api-key` 或 `--auth-choice ollama` 一起使用) - `--custom-api-key `(非交互式;可选;与 `--auth-choice custom-api-key` 一起使用;省略时回退到 `CUSTOM_API_KEY`) - `--custom-provider-id `(非交互式;可选自定义提供商 id) - `--custom-compatibility `(非交互式;可选;默认 `openai`) - `--gateway-port ` - `--gateway-bind ` - `--gateway-auth ` - `--gateway-token ` - `--gateway-token-ref-env `(非交互式;将 `gateway.auth.token` 存储为环境 SecretRef;要求该环境变量已设置;不能与 `--gateway-token` 一起使用) - `--gateway-password ` - `--remote-url ` - `--remote-token ` - `--tailscale ` - `--tailscale-reset-on-exit` - `--install-daemon` - `--no-install-daemon`(别名:`--skip-daemon`) - `--daemon-runtime ` - `--skip-channels` - `--skip-skills` - `--skip-health` - `--skip-ui` - `--node-manager `(推荐 pnpm;不推荐将 bun 用作 Gateway 网关运行时) - `--json` ### `configure` 交互式配置向导(模型、渠道、Skills、gateway)。 ### `config` 非交互式配置助手(get/set/unset/file/validate)。直接运行 `openclaw config` 而不带 子命令会启动向导。 子命令: - `config get `:打印一个配置值(点 / 方括号路径)。 - `config set `:设置一个值(JSON5 或原始字符串)。 - `config unset `:移除一个值。 - `config file`:打印当前活动配置文件路径。 - `config validate`:根据 schema 验证当前配置,而不启动 gateway。 - `config validate --json`:输出机器可读的 JSON。 ### `doctor` 健康检查 + 快速修复(配置 + gateway + 旧版服务)。 选项: - `--no-workspace-suggestions`:禁用工作区内存提示。 - `--yes`:接受默认值而不提示(无头)。 - `--non-interactive`:跳过提示;仅应用安全迁移。 - `--deep`:扫描系统服务以查找额外的 gateway 安装。 ## 渠道助手 ### `channels` 管理聊天渠道账户(WhatsApp/Telegram/Discord/Google Chat/Slack/Mattermost(插件)/Signal/iMessage/MS Teams)。 子命令: - `channels list`:显示已配置的渠道和认证配置文件。 - `channels status`:检查 gateway 可达性和渠道健康状态(`--probe` 会运行额外检查;gateway 健康探测请使用 `openclaw health` 或 `openclaw status --deep`)。 - 提示:如果能够检测到常见配置错误,`channels status` 会打印带建议修复方式的警告(随后指向 `openclaw doctor`)。 - `channels logs`:显示 gateway 日志文件中的最近渠道日志。 - `channels add`:未传入任何标志时为向导式设置;传入标志后切换为非交互模式。 - 当向仍使用单账户顶层配置的渠道添加非默认账户时,OpenClaw 会先将账户作用域值移动到 `channels..accounts.default`,再写入新账户。 - 非交互式 `channels add` 不会自动创建 / 升级绑定;仅渠道绑定会继续匹配默认账户。 - `channels remove`:默认执行禁用;传入 `--delete` 可在无提示下删除配置项。 - `channels login`:交互式渠道登录(仅 WhatsApp Web)。 - `channels logout`:登出某个渠道会话(如支持)。 通用选项: - `--channel `:`whatsapp|telegram|discord|googlechat|slack|mattermost|signal|imessage|msteams` - `--account `:渠道账户 id(默认 `default`) - `--name