OpenClaw 的命令行结构设计得相当清晰,遵循了现代 CLI 工具的主流范式。其核心语法可以概括为:
openclaw [全局选项] <命令> [子命令] [命令参数]
简单来说,就是先指定全局的运行方式,再选择要执行的具体操作。下面这个表格帮你快速理解各个部分的作用和典型用法:
| 参数/命令 | 含义 | 常见用法 |
|---|---|---|
--dev |
使用开发隔离配置(~/.openclaw-dev,端口默认 19001) |
openclaw --dev gateway |
-h, --help |
显示帮助 | openclaw --help |
--log-level |
全局日志级别(silent/fatal/error/warn/info/debug/trace) |
openclaw --log-level debug gateway |
--no-color |
关闭彩色输出 | openclaw --no-color status |
--profile |
使用命名配置隔离环境(~/.openclaw-) |
openclaw --profile test gateway |
-V, --version |
显示版本 | openclaw --version |
核心命令一览
OpenClaw 的功能相当丰富,通过不同的命令来组织。这里有一份核心命令的速查表,方便你按图索骥:
| 命令 | 含义 | 常见用法 |
|---|---|---|
acp * |
Agent Control Protocol 工具 | openclaw acp --help |
agent |
通过 Gateway 执行一次 agent 轮次 | openclaw agent --to +1555... --message "Hi" |
agents * |
管理多 agent(工作区、路由、认证) | openclaw agents --help |
approvals * |
管理执行授权(exec approvals) | openclaw approvals --help |
browser * |
管理 OpenClaw 专用浏览器 | openclaw browser --help |
channels * |
管理聊天渠道连接(Telegram/Discord等) | openclaw channels status |
clawbot * |
旧命令别名兼容 | openclaw clawbot --help |
completion |
生成 shell 补全脚本 | openclaw completion |
config * |
非交互配置操作(get/set/unset/file) | openclaw config set ... |
configure |
交互式配置向导 | openclaw configure |
cron * |
管理定时任务 | openclaw cron --help |
daemon * |
Gateway 服务(旧别名) | openclaw daemon --help |
dashboard |
打开控制台 UI | openclaw dashboard |
devices * |
设备配对和 token 管理 | openclaw devices --help |
directory * |
查询联系人/群组 ID | openclaw directory --help |
dns * |
DNS 相关辅助(广域发现) | openclaw dns --help |
docs |
搜索在线文档 | openclaw docs |
doctor |
健康检查和自动修复建议 | openclaw doctor |
gateway * |
启动/管理 WebSocket Gateway | openclaw gateway run |
health |
查询当前 gateway 健康状态 | openclaw health |
help |
显示帮助 | openclaw help models |
hooks * |
管理内部 hooks | openclaw hooks --help |
logs |
读取 gateway 日志 | openclaw logs |
memory * |
记忆检索和重建索引 | openclaw memory --help |
message * |
消息发送/读取/管理 | openclaw message send ... |
models * |
模型发现、扫描、配置 | openclaw models list |
node * |
运行/管理 headless node host | openclaw node --help |
nodes * |
管理 node 配对与命令 | openclaw nodes --help |
onboard |
交互式首次引导 | openclaw onboard |
pairing * |
安全 DM 配对 | openclaw pairing --help |
plugins * |
插件与扩展管理 | openclaw plugins list |
qr |
生成 iOS 配对二维码/码串 | openclaw qr |
reset |
重置本地配置/状态(不卸载 CLI) | openclaw reset |
sandbox * |
管理沙箱容器 | openclaw sandbox --help |
secrets * |
secrets 运行时重载控制 | openclaw secrets --help |
security * |
安全审计与工具 | openclaw security audit --deep |
sessions * |
会话记录管理 | openclaw sessions list |
setup |
初始化本地配置与工作区 | openclaw setup |
skills * |
查看与检查 skills | openclaw skills list |
status |
查看渠道健康和近期会话目标 | openclaw status --all |
system * |
系统事件/心跳/在线状态 | openclaw system --help |
tui |
打开终端 UI | openclaw tui |
uninstall |
卸载 gateway 服务和本地数据(CLI 仍保留) | openclaw uninstall |
update * |
更新 OpenClaw、查看更新通道 | openclaw update --help |
webhooks * |
Webhook 集成工具 | openclaw webhooks --help |
这里有两个关键点需要注意:
- 命令后面带
*星号的,意味着它下面还有更细分的子命令。这时候,先用openclaw <命令> --help查看详细参数列表,是最高效的做法。 - 如果你主要使用 MiniMax 的场景,那么最常用的命令组合会是
openclaw plugins enable minimax-portal-auth和openclaw onboard --auth-choice minimax-portal。
安装与运行
最后,关于如何获取和运行 OpenClaw,通常有两种方式:
1. 正式安装(推荐)
首先确保你的 Node.js 版本在 22.12.0 或以上,然后通过 npm 全局安装。
# 先升级 Node 到 22+
node -v
# 确认 >=22.12.0 后再安装
npm i -g openclaw@latest
which openclaw
openclaw --version
2. 临时运行(不依赖全局命令)
如果你不想全局安装,也可以直接通过 Node.js 运行下载好的入口文件。
node /path/to/openclaw/dist/entry.js --version