OpenClaw 指令使用方法详解
OpenClaw指令详解
OpenClaw 指令使用方法详解
一、OpenClaw 简介
OpenClaw 是一个开源的个人 AI 助手框架,支持通过命令行界面(CLI)进行全面的配置、管理和操作。OpenClaw 能够在本地设备运行,并通过多种通信渠道回复消息,包括 WhatsApp、Telegram、Slack、Discord、Google Chat、Signal、iMessage 等。此外,它还支持在 macOS/iOS/Android 上进行语音交互,并提供实时画布界面供用户控制。
核心特点
- 支持多种通信平台(WhatsApp、Telegram、Discord 等)
- 本地运行,响应速度快
- 始终在线
- 支持语音唤醒和对话模式
- 高度可扩展的技能系统
二、安装配置
2.1 环境要求
在安装 OpenClaw 之前,需要确保满足以下前置条件:
| 要求 | 说明 |
|---|---|
| 操作系统 | macOS、Linux、Windows(通过 WSL2) |
| Node.js | 版本必须 >= 22 |
| 包管理器 | npm、pnpm 或 bun |
| 网络连接 | 用于下载依赖和配置通信渠道 |
| 推荐 | Brave Search API 密钥(用于网页搜索) |
2.2 安装步骤
Linux/macOS 系统安装:
curl -fsSL https://openclaw.ai/install.sh | bash
Windows 系统安装(PowerShell):
iwr -useb https://openclaw.ai/install.ps1 | iex
替代方案(全局 npm 安装):
npm install -g openclaw@latest
# 或
pnpm add -g openclaw@latest
2.3 初始化配置
安装完成后,运行引导设置工具进行初始化配置:
openclaw onboard --install-daemon
该命令会完成以下配置:
- 创建必要的配置文件
- 设置工作区
- 安装为守护进程(在后台自动运行)
- 配置网关令牌
向导会提示设置:本地或远程网关、认证信息(支持 OpenAI Codex 订阅或 API 密钥)、通信频道(WhatsApp QR 登录、Telegram/Discord 机器人令牌等)、后台服务配置。
2.4 启动 Gateway
配置完成后,启动 OpenClaw Gateway:
# 检查网关状态
openclaw gateway status
# 手动前台运行
openclaw gateway --port 18789 --verbose
Gateway 启动后,可以通过以下地址访问 Dashboard:http://127.0.0.1:18789/
三、全局选项
OpenClaw CLI 提供以下全局选项:
| 选项 | 说明 |
|---|---|
--dev |
在 ~/.openclaw-dev 下隔离状态,并转移默认端口 |
--profile <name> |
在 ~/.openclaw-<name> 下隔离状态 |
--no-color |
禁用 ANSI 颜色输出 |
--update |
执行 openclaw update 更新程序 |
-V, --version |
打印版本信息并退出 |
四、核心指令系统
4.1 设置与入门命令
| 命令 | 说明 | 使用场景 |
|---|---|---|
openclaw setup |
初始化配置和工作区 | 首次安装时设置基础配置 |
openclaw onboard |
交互式向导设置 | 完整引导配置过程 |
openclaw configure |
交互式配置向导 | 配置模型、频道、技能、网关 |
openclaw config |
非交互式配置 | get/set/unset 操作 |
openclaw doctor |
健康检查和快速修复 | 诊断和修复问题 |
setup 常用选项:
openclaw setup --workspace <path> # 指定工作区路径(默认 ~/.openclaw/workspace)
openclaw setup --wizard # 运行入门向导
openclaw setup --non-interactive # 无提示运行
openclaw setup --mode <mode> # 向导模式
openclaw setup --remote-url <url> # 远程 Gateway URL
openclaw setup --remote-token <token> # 远程 Gateway token
config 子命令使用方法:
# 查看配置值
openclaw config get <key>
# 设置配置值
openclaw config set <key> <value>
# 移除配置
openclaw config unset <key>
4.2 消息与代理命令
| 命令 | 说明 |
|---|---|
openclaw message |
统一出站消息和频道操作 |
openclaw agent |
通过 Gateway 运行单个 agent 回合 |
openclaw agents |
管理隔离的 agents |
openclaw status |
显示链接会话健康状况和最近收件人 |
openclaw health |
从运行中的 Gateway 获取健康状态 |
openclaw sessions |
列出存储的对话会话 |
openclaw acp |
运行连接 IDEs 到 Gateway 的 ACP 桥接 |
message 子命令包括:
# 发送消息
openclaw message send --target +15555550123 --message "Hello from OpenClaw"
# 读取消息
openclaw message read
# 搜索消息
openclaw message search <query>
# 消息反应
openclaw message react <message-id> <emoji>
# 编辑消息
openclaw message edit <message-id> <new-content>
# 删除消息
openclaw message delete <message-id>
# 置顶消息
openclaw message pin <message-id>
openclaw message unpin <message-id>
# 消息超时设置
openclaw message timeout <channel> <seconds>
# 踢出成员
openclaw message kick <member-id>
# 封禁成员
openclaw message ban <member-id>
# 线程操作
openclaw message thread <threadId>
# Emoji 操作
openclaw message emoji <emojiId>
# 贴纸操作
openclaw message sticker <stickerId>
# 角色操作
openclaw message role <roleId>
# 频道操作
openclaw message channel <channelId>
# 成员信息
openclaw message member info
# 语音状态
openclaw message voice status
# 事件操作
openclaw message event <eventId>
agent 命令使用:
# 基本用法
openclaw agent --message <text> --to <recipient>
# 完整选项
openclaw agent --message <text> --to <recipient> \
--session-id <id> \
--thinking <text> \ # GPT-5.2 + Codex 模型专用
--verbose \
--channel <channel> \
--local \ # 嵌入式本地运行
--deliver \
--json \
--timeout <seconds>
status 命令选项:
openclaw status --json # JSON 格式输出
openclaw status --all # 完整诊断
openclaw status --deep # 探测频道
openclaw status --usage # 显示模型使用量
openclaw status --timeout <seconds>
openclaw status --verbose
openclaw status --debug
agents 子命令:
# 列出 agents
openclaw agents list [--json] [--bindings]
# 添加新 agent
openclaw agents add [name]
# 删除 agent
openclaw agents delete <id> [--force]
4.3 Gateway 管理命令
| 命令 | 说明 |
|---|---|
openclaw gateway |
运行 WebSocket Gateway |
openclaw logs |
通过 RPC 尾随 Gateway 文件日志 |
gateway 常用选项:
# 指定端口和地址
openclaw gateway --port 18789 --bind 0.0.0.0
# 指定认证令牌
openclaw gateway --token <your-token>
# 启用认证
openclaw gateway --auth --password <password>
# 启用 Tailscale
openclaw gateway --tailscale
# 重置配置
openclaw gateway --reset
# 强制执行
openclaw gateway --force
# 详细输出
openclaw gateway --verbose
# Claude CLI 日志
openclaw gateway --claude-cli-logs
# WebSocket 日志
openclaw gateway --ws-log <path>
# 紧凑输出
openclaw gateway --compact
# 原始流
openclaw gateway --raw-stream
openclaw gateway --raw-stream-path <path>
gateway service 子命令:
openclaw gateway status # 查看状态
openclaw gateway install # 安装服务
openclaw gateway uninstall # 卸载服务
openclaw gateway start # 启动服务
openclaw gateway stop # 停止服务
openclaw gateway restart # 重启服务
logs 命令使用:
openclaw logs --follow # 实时跟踪日志
openclaw logs --limit 200 # 限制输出行数
openclaw logs --plain # 纯文本格式
openclaw logs --json # JSON 格式输出
openclaw logs --no-color # 禁用颜色
4.4 模型管理命令
| 命令 | 说明 |
|---|---|
openclaw models |
等同于 models status |
openclaw models list |
列出可用模型 |
openclaw models status |
显示模型状态和认证信息 |
openclaw models set <model> |
设置默认主模型 |
openclaw models set-image <model> |
设置默认图像模型 |
openclaw models scan |
扫描可用模型 |
openclaw models auth |
管理模型认证 |
models 子命令:
# 列出所有模型
openclaw models list --all
openclaw models list --local
openclaw models list --provider <name>
openclaw models list --json
openclaw models list --plain
# 查看模型状态
openclaw models status --json
openclaw models status --plain
openclaw models status --check
openclaw models status --probe
# 设置默认模型
openclaw models set claude-3-5-sonnet-20241022
openclaw models set-image claude-3-5-sonnet-20241022
# 模型别名管理
openclaw models aliases list
openclaw models aliases add <alias> <model>
openclaw models aliases remove <alias>
# 回退模型管理
openclaw models fallbacks list
openclaw models fallbacks add <model>
openclaw models fallbacks remove <model>
openclaw models fallbacks clear
# 图像回退模型管理
openclaw models image-fallbacks list
openclaw models image-fallbacks add <model>
openclaw models image-fallbacks remove <model>
openclaw models image-fallbacks clear
# 扫描可用模型
openclaw models scan --min-params <n>
openclaw models scan --max-age-days <n>
openclaw models scan --provider <name>
openclaw models scan --set-default
openclaw models scan --set-image
# 认证管理
openclaw models auth add
openclaw models auth setup-token
openclaw models auth paste-token
# 认证顺序
openclaw models auth order get
openclaw models auth order set <order>
openclaw models auth order clear
4.5 频道管理命令
OpenClaw 支持多种通信频道,包括 WhatsApp、Telegram、Discord、Google Chat、Slack、Mattermost、Signal、iMessage、Microsoft Teams 等。
| 命令 | 说明 |
|---|---|
openclaw channels list |
列出所有配置的频道 |
openclaw channels status |
查看频道状态 |
openclaw channels logs |
查看频道日志 |
openclaw channels add |
添加新频道 |
openclaw channels remove |
移除频道 |
openclaw channels login |
频道登录(QR 码) |
openclaw channels logout |
频道登出 |
添加频道示例:
# 添加 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
# 添加 WhatsApp
openclaw channels add --channel whatsapp --account personal
# 添加 Slack
openclaw channels add --channel slack --account team --token $SLACK_BOT_TOKEN
# 检查频道连接状态
openclaw channels status --probe
WhatsApp 登录:
openclaw channels login
# 然后扫描 QR 码:设置 → 已关联的设备
4.6 技能管理命令
Skills(技能)是赋予 OpenClaw 执行特定任务能力的插件。
| 命令 | 说明 |
|---|---|
openclaw skills list |
列出可用技能 |
openclaw skills info <skill> |
查看技能详情 |
openclaw skills check |
检查技能状态 |
openclaw skills list
openclaw skills info <skill-name>
openclaw skills check [--eligible] [--json] [-v]
4.7 插件管理命令
| 命令 | 说明 |
|---|---|
openclaw plugins list |
列出已安装插件 |
openclaw plugins info <plugin> |
查看插件详情 |
openclaw plugins install <plugin> |
安装插件 |
openclaw plugins enable <plugin> |
启用插件 |
openclaw plugins disable <plugin> |
禁用插件 |
openclaw plugins doctor |
诊断插件问题 |
4.8 内存管理命令
| 命令 | 说明 |
|---|---|
openclaw memory status |
显示索引统计 |
openclaw memory index |
重新索引内存文件 |
openclaw memory search <query> |
语义搜索内存 |
4.9 定时任务命令
| 命令 | 说明 |
|---|---|
openclaw cron status |
查看定时任务状态 |
openclaw cron list |
列出所有定时任务 |
openclaw cron add |
添加新定时任务 |
openclaw cron edit <id> |
编辑定时任务 |
openclaw cron rm <id> |
删除定时任务 |
openclaw cron enable <id> |
启用定时任务 |
openclaw cron disable <id> |
禁用定时任务 |
openclaw cron runs --id <id> |
查看任务执行记录 |
openclaw cron run <id> |
手动执行定时任务 |
添加定时任务示例:
# 使用 at 指定时间
openclaw cron add --name "daily-report" --at "0 9 * * *" --system-event "daily-report"
# 使用 every 指定间隔
openclaw cron add --name "check-updates" --every 1h --message "check-updates"
# 使用 cron 表达式
openclaw cron add --name "weekly-task" --cron "0 10 * * 1" --system-event "weekly-task"
4.10 节点管理命令
| 命令 | 说明 |
|---|---|
openclaw nodes status |
查看节点状态 |
openclaw nodes list |
列出所有节点 |
openclaw nodes describe --node <id> |
查看节点详情 |
openclaw nodes pending |
查看待批准节点 |
openclaw nodes approve <id> |
批准节点 |
openclaw nodes reject <id> |
拒绝节点 |
openclaw nodes rename |
重命名节点 |
openclaw nodes invoke |
调用节点命令 |
openclaw nodes run |
在节点上运行命令 |
openclaw nodes notify |
通知节点 |
openclaw nodes camera |
节点相机控制 |
openclaw nodes canvas |
节点画布控制 |
openclaw nodes screen |
节点屏幕控制 |
openclaw nodes location |
获取节点位置 |
node 子命令:
openclaw node run --host <host> --port 18789
openclaw node status
openclaw node install [--host <host>] [--port <port>] [--tls]
openclaw node uninstall
openclaw node stop
openclaw node restart
4.11 浏览器控制命令
OpenClaw 提供强大的浏览器控制功能:
| 命令 | 说明 |
|---|---|
openclaw browser status |
查看浏览器状态 |
openclaw browser start |
启动浏览器 |
openclaw browser stop |
停止浏览器 |
openclaw browser reset-profile |
重置浏览器配置 |
openclaw browser tabs |
查看标签页 |
openclaw browser open <url> |
打开网址 |
openclaw browser focus <targetId> |
聚焦标签页 |
openclaw browser close |
关闭标签页 |
openclaw browser profiles |
管理浏览器配置 |
openclaw browser create-profile |
创建配置 |
openclaw browser delete-profile |
删除配置 |
浏览器检查和操作命令:
# 截图
openclaw browser screenshot [targetId]
openclaw browser snapshot
# 导航和操作
openclaw browser navigate <url>
openclaw browser resize <width> <height>
openclaw browser click <x> <y>
openclaw browser type <text>
openclaw browser press <key>
openclaw browser hover <x> <y>
openclaw browser drag <start> <end>
openclaw browser select <select>
openclaw browser upload <file>
openclaw browser fill --fields <json>
# 对话框处理
openclaw browser dialog --accept|--dismiss
# 等待和执行
openclaw browser wait
openclaw browser evaluate --fn <function>
openclaw browser console
# 导出
openclaw browser pdf
4.12 系统命令
| 命令 | 说明 |
|---|---|
openclaw system event |
入队系统事件并触发心跳 |
openclaw system heartbeat |
心跳控制 |
openclaw system presence |
列出系统在线状态 |
openclaw system event --text <text> [--mode <mode>] [--json]
openclaw system heartbeat last|enable|disable
openclaw system presence
4.13 审批管理命令
| 命令 | 说明 |
|---|---|
openclaw approvals get |
获取审批设置 |
openclaw approvals set |
设置审批配置 |
openclaw approvals allowlist add |
添加到允许列表 |
openclaw approvals allowlist remove |
从允许列表移除 |
4.14 沙箱命令
| 命令 | 说明 |
|---|---|
openclaw sandbox list |
列出沙箱 |
openclaw sandbox recreate |
重新创建沙箱 |
openclaw sandbox explain |
解释沙箱 |
4.15 钩子管理命令
| 命令 | 说明 |
|---|---|
openclaw hooks list |
列出钩子 |
openclaw hooks info <hook> |
显示钩子详情 |
openclaw hooks check |
检查钩子 |
openclaw hooks enable |
启用钩子 |
openclaw hooks disable |
禁用钩子 |
openclaw hooks install |
安装钩子 |
openclaw hooks update |
更新钩子 |
4.16 其他常用命令
| 命令 | 说明 |
|---|---|
openclaw docs [query] |
搜索实时文档 |
openclaw tui |
打开终端 UI |
openclaw reset |
重置本地配置 |
openclaw uninstall |
卸载程序 |
openclaw update |
更新 OpenClaw |
openclaw security audit |
安全审计 |
openclaw pairing |
管理跨频道 DM 配对 |
openclaw webhooks gmail |
Gmail Webhook 设置 |
tui 命令选项:
openclaw tui --url <url>
openclaw tui --token <token>
openclaw tui --password <password>
openclaw tui --session <session>
openclaw tui --deliver
openclaw tui --thinking <text>
openclaw tui --message <text>
openclaw tui --timeout-ms <ms>
openclaw tui --history-limit <n>
reset 命令选项:
openclaw reset --scope <scope>
openclaw reset --yes
openclaw reset --non-interactive
openclaw reset --dry-run
uninstall 命令选项:
openclaw uninstall --service
openclaw uninstall --state
openclaw uninstall --workspace
openclaw uninstall --app
openclaw uninstall --all
openclaw uninstall --yes
openclaw uninstall --non-interactive
openclaw uninstall --dry-run
安全审计:
openclaw security audit # 基本审计
openclaw security audit --deep # 深度审计
配对管理:
openclaw pairing list whatsapp
openclaw pairing approve whatsapp <message-id>
五、快速验证步骤
安装配置完成后,可以通过以下命令验证系统状态:
# 检查整体状态
openclaw status
# 检查健康状态
openclaw health
# 安全审计
openclaw security audit --deep
# 发送测试消息
openclaw message send --target +15555550123 --message "Hello from OpenClaw"
# 查看模型状态
openclaw models status
# 检查频道连接
openclaw channels status --probe
六、命令树汇总
openclaw [--dev] [--profile <name>]
├── setup
├── onboard
├── configure
├── config
│ ├── get <key>
│ ├── set <key> <value>
│ └── unset <key>
├── 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
│ ├── read
│ ├── edit
│ ├── delete
│ ├── pin/unpin
│ ├── search
│ ├── timeout
│ ├── kick
│ ├── ban
│ ├── thread
│ ├── emoji
│ ├── sticker
│ ├── role
│ ├── channel
│ ├── member
│ └── voice
├── agent
├── agents
│ ├── list
│ ├── add
│ └── delete
├── acp
├── status
├── health
├── sessions
├── gateway
│ ├── call
│ ├── health
│ ├── status
│ ├── probe
│ ├── discover
│ ├── install/uninstall/start/stop/restart/run
│ └── logs
├── system
│ ├── event
│ ├── heartbeat
│ └── presence
├── models
│ ├── list
│ ├── status
│ ├── set
│ ├── set-image
│ ├── aliases
│ ├── fallbacks
│ ├── image-fallbacks
│ ├── scan
│ └── auth
├── sandbox
│ ├── list
│ ├── recreate
│ └── explain
├── cron
│ ├── status
│ ├── list
│ ├── add/edit/rm
│ ├── enable/disable
│ └── runs/run
├── nodes
│ ├── status
│ ├── describe
│ ├── list
│ ├── pending
│ ├── approve/reject
│ ├── rename
│ ├── invoke
│ ├── run
│ ├── notify
│ ├── camera
│ ├── canvas
│ ├── screen
│ └── location
├── node
│ ├── run
│ ├── status
│ ├── install/uninstall/start/stop/restart
├── browser
│ ├── status/start/stop/reset-profile
│ ├── tabs/open/focus/close
│ ├── profiles
│ ├── screenshot/snapshot
│ └── navigate/click/type/press/hover/drag/select...
├── approvals
│ ├── get/set
│ └── allowlist
├── docs
├── dns
│ └── setup
├── tui
├── hooks
│ ├── list/info/check/enable/disable/install/update
├── webhooks
│ └── gmail setup/run
└── pairing
├── list
└── approve
七、常见问题处理
7.1 配置问题
如果遇到配置文件问题,可以运行诊断:
openclaw doctor
7.2 频道连接问题
检查频道状态并重新探测:
openclaw channels status
openclaw channels status --probe
7.3 模型认证问题
检查模型认证状态:
openclaw models status --check
openclaw models auth add
7.4 环境变量说明
| 环境变量 | 说明 |
|---|---|
OPENCLAW_HOME |
配置根目录 |
OPENCLAW_STATE_DIR |
状态目录 |
OPENCLAW_CONFIG_PATH |
配置文件路径 |
八、参考链接
- OpenClaw 官网:https://openclaw.ai/
- 官方文档:https://docs.openclaw.ai/
- CLI 参考:https://docs.openclaw.ai/cli
- 入门指南:https://docs.openclaw.ai/start/getting-started
- ClawHub 技能市场:https://clawhub.com
九、输出样式说明
- ANSI 颜色和进度指示器仅在 TTY 会话中渲染
- OSC-8 超链接在支持的终端中可点击
--json和--plain禁用样式--no-color禁用 ANSI 样式NO_COLOR=1环境变量也被支持
颜色调色板
| 名称 | 颜色值 | 用途 |
|---|---|---|
| accent | #FF5A2D | 标题、标签、主要高亮 |
| accentBright | #FF7A3D | 命令名称、强调 |
| accentDim | #D14A22 | 次要高亮文本 |
| info | #FF8A5B | 信息值 |
| success | #2FBF71 | 成功状态 |
| warn | #FFB020 | 警告、回退、注意力 |
| error | #E23D2D | 错误、失败 |
| muted | #8B7F77 | 降强调、元数据 |
本文档基于 OpenClaw 官方文档整理,欢迎访问 https://docs.openclaw.ai/ 获取最新信息。
更多推荐

所有评论(0)