CLI参考
约 2881 字大约 10 分钟
CLI总览
本页描述当前 CLI 行为。
命令页面
- setup - 初始化设置
- onboard - 入门向导
- configure - 配置向导
- doctor - 健康检查与修复
- dashboard - 打开控制台
- reset - 重置配置/状态
- uninstall - 卸载
- update - 更新
- message - 消息发送
- agent - 运行智能体
- agents - 管理智能体
- status - 状态查看
- health - 健康检查
- sessions - 会话管理
- gateway - 网关控制
- logs - 日志查看
- models - 模型管理
- memory - 记忆管理
- channels - 通道管理
- nodes - 节点管理
- browser - 浏览器控制
- cron - 定时任务
- skills - 技能管理
- plugins - 插件管理
全局标志
--dev: 在~/.openclaw-dev下隔离状态并切换默认端口--profile: 在~/.openclaw->下隔离状态--no-color: 禁用 ANSI 颜色--update:openclaw update的简写(仅源码安装)-V,--version,-v: 打印版本并退出
输出样式
- ANSI 颜色和进度指示器仅在 TTY 会话中渲染
--json(以及支持的--plain)禁用样式以获得干净输出--no-color禁用 ANSI 样式;也支持NO_COLOR=1
命令树
openclaw [--dev] [--profile ]
setup
onboard
configure
config get|set|unset
doctor
security audit
reset
uninstall
update
channels list|status|logs|add|remove|login|logout
skills list|info|check
plugins list|info|install|enable|disable|doctor
memory status|index|search
message send|poll|react|...
agent
agents list|add|delete
status
health
sessions
gateway call|health|status|probe|discover|install|...
logs
system event|heartbeat|presence
models list|status|set|set-image|aliases|fallbacks|...
sandbox list|recreate|explain
cron status|list|add|edit|rm|enable|disable|run|runs
nodes status|list|invoke|run|...
browser status|start|stop|navigate|click|...
tui聊天斜杠命令
聊天消息支持 /... 命令。参见 斜杠命令。
常用:
/status- 快速诊断/config- 持久化配置更改/new- 开始新会话/model- 切换模型/models- 列出可用模型
onboard命令
交互式向导,设置网关、工作区和技能。
用法
openclaw onboard [选项]选项
基本选项
--workspace: 工作区路径--reset: 向导前重置配置 + 凭据 + 会话 + 工作区--non-interactive: 非交互模式--mode: 向导模式--flow: 流程类型
认证选项
--auth-choice: 认证方式选择setup-token- Anthropic setup-tokenopenai-codex- OpenAI Codex OAuthopenai-api-key- OpenAI API 密钥anthropic-api-key- Anthropic API 密钥skip- 跳过--anthropic-api-key: Anthropic API 密钥--openai-api-key: OpenAI API 密钥--openrouter-api-key: OpenRouter API 密钥
网关选项
--gateway-port: 网关端口--gateway-bind: 绑定模式--gateway-auth: 认证方式--gateway-token: 网关 token--gateway-password: 网关密码
远程选项
--remote-url: 远程网关 URL--remote-token: 远程网关 token
Tailscale 选项
--tailscale: Tailscale 模式--tailscale-reset-on-exit: 退出时重置
服务选项
--install-daemon: 安装守护进程--no-install-daemon/--skip-daemon: 跳过守护进程安装--daemon-runtime: 守护进程运行时
跳过选项
--skip-channels: 跳过通道配置--skip-skills: 跳过技能配置--skip-health: 跳过健康检查--skip-ui: 跳过 UI
其他
--node-manager: 包管理器(推荐 pnpm)--json: JSON 输出
示例
## 交互式入门
openclaw onboard
## 安装守护进程
openclaw onboard --install-daemon
## 非交互式快速设置
openclaw onboard --non-interactive --flow quickstart --auth-choice skip
## 使用 Anthropic API 密钥
openclaw onboard --anthropic-api-key sk-xxx
## 远程模式
openclaw onboard --mode remote --remote-url ws://server:18789 --remote-token xxx向导流程
向导会引导你完成:
- 模型/认证设置 - 推荐 Anthropic setup-token 用于 Claude 订阅
- 工作区位置 + 引导文件
- 网关设置 - 绑定/端口/认证/Tailscale
- Provider - WhatsApp、Telegram、Discord 等
- 守护进程安装 - macOS 使用 LaunchAgent,Linux 使用 systemd
- 健康检查和技能选择
相关命令
channels命令
管理聊天通道账户(WhatsApp/Telegram/Discord/Google Chat/Slack/Mattermost/Signal/iMessage/MS Teams)。
用法
openclaw channels 子命令> [选项]子命令
channels list
显示配置的通道和认证配置文件。
openclaw channels list [选项]选项:
--no-usage: 跳过模型 provider 使用量/配额快照--json: JSON 输出
channels status
检查网关可达性和通道健康状态。
openclaw channels status [选项]选项:
--probe: 运行额外检查
提示:channels status 在检测到常见配置错误时会打印警告和建议修复(然后指向 openclaw doctor)。
channels logs
显示网关日志文件中的最近通道日志。
openclaw channels logs [选项]选项:
--channel: 通道名称(默认all)--lines: 行数(默认 200)--json: JSON 输出
channels add
添加通道。无标志时使用向导式设置;有标志时切换到非交互模式。
openclaw channels add [选项]channels remove
移除通道。默认禁用;传入 --delete 可无提示删除配置条目。
openclaw channels remove [选项]选项:
--delete: 删除配置条目
channels login
交互式通道登录(仅 WhatsApp Web)。
openclaw channels login [选项]选项:
--channel: 通道(默认whatsapp;支持whatsapp/web)--account: 账户 ID--verbose: 详细输出
channels logout
登出通道会话(如果支持)。
openclaw channels logout [选项]选项:
--channel: 通道(默认whatsapp)--account: 账户 ID
通用选项
--channel: 通道名称whatsapptelegramdiscordgooglechatslackmattermostsignalimessagemsteams--account: 通道账户 ID(默认default)--name: 账户显示名称
示例
## 列出通道
openclaw channels list
## 查看通道状态
openclaw channels status --probe
## 添加 Telegram 通道
openclaw channels add --channel telegram --account alerts --name "Alerts Bot" --token $TELEGRAM_BOT_TOKEN
## 添加 Discord 通道
openclaw channels add --channel discord --account work --name "Work Bot" --token $DISCORD_BOT_TOKEN
## 移除通道
openclaw channels remove --channel discord --account work --delete
## WhatsApp 登录
openclaw channels login
## 查看通道日志
openclaw channels logs --channel whatsapp --lines 100相关文档
gateway命令
运行 WebSocket 网关。
用法
openclaw gateway [选项]选项
网络选项
--port: 端口(默认 18789)--bind: 绑定模式
认证选项
--token: 网关 token--auth: 认证方式--password: 网关密码
Tailscale 选项
--tailscale: Tailscale 模式--tailscale-reset-on-exit: 退出时重置
运行选项
--allow-unconfigured: 允许未配置运行--dev: 开发模式--reset: 重置开发配置 + 凭据 + 会话 + 工作区--force: 强制启动(杀死端口上的现有监听器)--verbose: 详细输出
日志选项
--claude-cli-logs: Claude CLI 日志--ws-log: WebSocket 日志模式--compact:--ws-log compact的别名--raw-stream: 原始流输出--raw-stream-path: 原始流路径
子命令
gateway status
探测网关 RPC。
openclaw gateway status [选项]选项:
--no-probe: 不探测--deep: 深度探测--json: JSON 输出
gateway service
管理网关服务(launchd/systemd/schtasks)。
openclaw gateway install # 安装服务
openclaw gateway uninstall # 卸载服务
openclaw gateway start # 启动服务
openclaw gateway stop # 停止服务gateway probe
探测网关 RPC 可达性。
openclaw gateway probegateway health
获取网关健康状态。
openclaw gateway health [--json]gateway call
调用网关 RPC 方法。
openclaw gateway call method> [--params json>]常用 RPC:
config.apply- 验证 + 写入配置 + 重启 + 唤醒config.patch- 合并部分更新 + 重启 + 唤醒update.run- 运行更新 + 重启 + 唤醒
示例
## 前台运行网关
openclaw gateway
## 指定端口
openclaw gateway --port 19000
## 使用 token 认证
openclaw gateway --token mytoken
## 强制启动(杀死现有进程)
openclaw gateway --force
## 安装为服务
openclaw gateway install
## 重启服务服务管理
网关通常作为后台服务运行:
- macOS: LaunchAgent
- Linux: systemd user unit
- Windows: schtasks
安装服务:
openclaw gateway install服务会在系统启动时自动运行。
相关命令
models命令
模型管理命令。
用法
openclaw models [子命令] [选项]openclaw models 是 models status 的别名。
子命令
models list
列出可用模型。
openclaw models list [选项]选项:
--all: 显示所有模型--local: 仅本地模型--provider: 按 provider 过滤--json: JSON 输出--plain: 纯文本输出
models status
显示模型状态和认证信息。
openclaw models status [选项]选项:
--json: JSON 输出--plain: 纯文本输出--check: 检查模式(退出码:1=过期/缺失,2=即将过期)--probe: 实时探测配置的认证配置文件--probe-provider: 探测指定 provider--probe-profile: 探测指定配置文件--probe-timeout: 探测超时--probe-concurrency: 并发数--probe-max-tokens: 最大 token 数
models set
设置默认模型。
openclaw models set model>设置 agents.defaults.model.primary。
models set-image
设置默认图像模型。
openclaw models set-image model>设置 agents.defaults.imageModel.primary。
models aliases
管理模型别名。
openclaw models aliases list [--json] [--plain]
openclaw models aliases add alias> model>models fallbacks
管理故障转移模型。
openclaw models fallbacks list [--json] [--plain]
openclaw models fallbacks add model>
openclaw models fallbacks remove model>models image-fallbacks
管理图像模型故障转移。
openclaw models image-fallbacks list [--json] [--plain]
openclaw models image-fallbacks add model>
openclaw models image-fallbacks remove model>models scan
扫描可用模型。
openclaw models scan [选项]选项:
--min-params: 最小参数量--max-age-days: 最大天数--provider: Provider 名称--max-candidates: 最大候选数--timeout: 超时--concurrency: 并发数--no-probe: 不探测--yes: 自动确认--no-input: 无输入--set-default: 设为默认--set-image: 设为图像模型--json: JSON 输出
models auth
管理认证。
## 交互式添加认证
openclaw models auth add
## 使用 setup-token(推荐用于 Anthropic)
openclaw models auth setup-token --provider anthropic
## 粘贴 tokenmodels auth order
管理认证顺序。
openclaw models auth order get [--provider name>] [--agent id>] [--json]
openclaw models auth order set --provider name> [--agent id>] profileIds...>示例
## 查看模型状态
openclaw models status
## 设置默认模型
openclaw models set anthropic/claude-sonnet-4-20250514
## 添加故障转移模型
openclaw models fallbacks add openai/gpt-4o
## 添加 Anthropic 认证
openclaw models auth setup-token --provider anthropic
## 扫描可用模型
openclaw models scan --set-default相关文档
status命令
显示链接的会话健康状态和最近的收件人。
用法
openclaw status [选项]选项
--json: JSON 输出--all: 完整诊断(只读,可粘贴分享)--deep: 探测通道--usage: 显示模型 provider 使用量/配额--timeout: 超时时间--verbose/--debug: 详细输出
输出内容
Status 命令会显示:
- 网关状态 - 运行状态、端口、版本
- 节点主机服务状态 - 如果可用
- 会话信息 - 活跃会话数量
- 通道状态 - 各通道连接状态
- 模型状态 - 当前模型和认证状态
示例
## 基本状态
openclaw status
## 完整诊断(用于提交 issue)
openclaw status --all
## 深度探测
openclaw status --deep
## 查看使用量
openclaw status --usage
## JSON 输出用于故障排除
当遇到问题时,建议运行:
openclaw status --all这会生成一个安全的(token 已脱敏)报告,可以粘贴到 GitHub issue 中。
相关命令
- health - 健康检查
- doctor - 诊断与修复
- gateway status - 网关状态
doctor命令
健康检查 + 快速修复(配置 + 网关 + 遗留服务)。
用法
openclaw doctor [选项]选项
--no-workspace-suggestions: 禁用工作区记忆提示--yes: 无需提示接受默认值(无头模式)--non-interactive: 跳过提示;仅应用安全迁移--deep: 扫描系统服务以查找额外的网关安装--repair: 自动修复检测到的问题
功能
Doctor 命令会:
- 验证配置 - 检查配置文件语法和有效性
- 检查网关状态 - 确认网关服务运行正常
- 检测遗留服务 - 查找旧版本的服务配置
- 修复常见问题 - 自动修复可安全修复的问题
- 迁移配置 - 处理配置格式升级
示例
## 运行健康检查
openclaw doctor
## 自动修复问题
openclaw doctor --repair
## 深度扫描
openclaw doctor --deep
## 无头模式(CI/CD)
openclaw doctor --non-interactive --yes输出说明
Doctor 会输出:
- ✅ 通过的检查
- ⚠️ 警告(可能需要注意)
- ❌ 错误(需要修复)
常见修复
服务入口点不匹配
当在 npm 和 git 安装之间切换时,Doctor 会检测并提供修复服务配置的选项。
配置迁移
Doctor 会自动处理配置格式的向后兼容迁移。
端口冲突
检测到端口被占用时,会提供建议。
相关命令
- status - 状态查看
- health - 健康检查
- gateway status - 网关状态
