OpenClaw 完整命令参考指南
版本: OpenClaw 2026.3.13 (61d=171a)
文档来源: 官方 CLI 帮助输出 (openclaw --help及各子命令--help)
官方文档: https://docs.openclaw.ai/cli

前期回归:
OpenClaw 本地操控机制详解
OpenClaw 接入 Telegram Bot(纸飞机机器人)实现机制详解
OpenClaw 故障转移配置实战指南:让你的AI助手永不掉线
1. 快速入门
安装与初始化
# 安装 OpenClaw CLI (通过 npm/pnpm)
npm install -g openclaw
# 初始化配置和工作空间
openclaw setup
# 启动交互式配置向导
openclaw configure
# 启动网关服务
openclaw gateway start检查状态
# 查看整体状态
openclaw status
# 深度状态检查
openclaw status --deep
# 健康检查
openclaw health
# 查看日志
openclaw logs --follow2. 全局选项
所有 openclaw 命令都支持以下全局选项:
--dev | ~/.openclaw-dev,默认网关端口 19001 |
--profile <name> | ~/.openclaw-<name> |
--log-level <level> | silent|fatal|error|warn|info|debug|trace |
--no-color | |
-h, --help | |
-V, --version |
示例:
# 在开发模式下运行网关
openclaw --dev gateway run
# 使用特定配置文件
openclaw --profile work status3. 核心命令详解
3.1 Gateway 网关管理
Gateway 是 OpenClaw 的核心服务,负责 WebSocket 通信和代理管理。
openclaw gateway [options] [command]服务生命周期
gateway run | |
gateway start | |
gateway stop | |
gateway restart | |
gateway status | |
gateway install | |
gateway uninstall |
探测与诊断
gateway probe | |
gateway discover | |
gateway health | |
gateway call <method> | |
gateway usage-cost |
启动选项
--port <port> | |
--bind <mode> | loopback|lan|tailnet|auto|custom |
--auth <mode> | none|token|password|trusted-proxy |
--token <token> | OPENCLAW_GATEWAY_TOKEN 环境变量) |
--password <password> | |
--force | |
--allow-unconfigured | |
--tailscale <mode> | off|serve|funnel |
--verbose |
示例:
# 前台运行网关
openclaw gateway run
# 指定端口运行
openclaw gateway run --port 18789
# 开发模式运行
openclaw --dev gateway run
# 强制启动(关闭占用端口的进程)
openclaw gateway run --force
# 查看网关状态
openclaw gateway status
# 探测网关连通性
openclaw gateway probe3.2 Security 安全审计
openclaw security [command]security audit | |
security audit --deep | |
security audit --fix | |
security audit --json |
安全审计检查项:
• 危险的配置标志(如 dangerouslyAllowHostHeaderOriginFallback)• 文件权限问题 • 攻击面摘要(工具组权限、elevated 权限、webhooks 等) • 通道安全状态 • 浏览器控制配置
示例:
# 运行基础安全审计
openclaw security audit
# 深度审计
openclaw security audit --deep
# 自动修复安全问题
openclaw security audit --fix
# JSON 输出供脚本处理
openclaw security audit --json3.3 Channels 通道管理
管理已连接的聊天通道(Telegram、Discord、WhatsApp 等)。
openclaw channels [command]channels list | |
channels add | |
channels remove | |
channels login | |
channels logout | |
channels status | |
channels logs | |
channels capabilities | |
channels resolve |
示例:
# 列出所有通道
openclaw channels list
# 添加 Telegram Bot
openclaw channels add --channel telegram --token <bot_token>
# 链接 WhatsApp
openclaw channels login --channel whatsapp
# 检查通道状态
openclaw channels status
# 深度探测
openclaw channels status --probe3.4 Models 模型管理
openclaw models [command]models list | |
models set <model> | |
models set-image <model> | |
models status | |
models scan | |
models aliases | |
models auth | |
models fallbacks | |
models image-fallbacks |
全局选项:
--agent <id> | |
--status-json | |
--status-plain |
示例:
# 列出所有模型
openclaw models list
# 设置默认模型
openclaw models set kimi-coding/k2p5
# 设置图像模型
openclaw models set-image gpt-4o
# 查看模型状态
openclaw models status
# 扫描 OpenRouter 免费模型
openclaw models scan3.5 Cron 定时任务
通过 Gateway 调度器管理定时任务。
openclaw cron [command]cron list | |
cron add | |
cron edit <id> | |
cron rm <id> | |
cron run <id> | |
cron runs <id> | |
cron status | |
cron enable <id> | |
cron disable <id> |
任务类型:
• systemEvent: 向会话注入系统事件 • agentTurn: 运行代理(仅隔离会话)
调度类型:
• at: 一次性任务(ISO-8601 时间戳)• every: 周期性间隔(毫秒)• cron: Cron 表达式
示例:
# 列出所有定时任务
openclaw cron list
# 添加每日安全审计
openclaw cron add --name "daily-audit" \
--schedule "0 9 * * *" \
--command "openclaw security audit"
# 查看任务运行历史
openclaw runs healthcheck:security-audit
# 立即运行任务
openclaw cron run healthcheck:security-audit3.6 Config 配置管理
openclaw config [command]config file | |
config get <path> | |
config set <path> <value> | |
config unset <path> | |
config validate | |
| (无子命令) |
配置向导选项:
--section <section> |
示例:
# 查看配置文件位置
openclaw config file
# 获取特定配置值
openclaw config get gateway.port
# 设置配置值
openclaw config set gateway.port 19001
# 删除配置项
openclaw config unset gateway.controlUi.dangerouslyAllowHostHeaderOriginFallback
# 验证配置
openclaw config validate
# 启动配置向导(仅特定区域)
openclaw config --section gateway --section models3.7 Sessions 会话管理
openclaw sessions [options] [command]--active <minutes> | |
--agent <id> | |
--all-agents | |
--json | |
--store <path> | |
--verbose |
sessions cleanup |
示例:
# 列出所有会话
openclaw sessions
# 仅显示最近2小时的活跃会话
openclaw sessions --active 120
# 查看特定代理的会话
openclaw sessions --agent work
# 聚合所有代理
openclaw sessions --all-agents
# JSON 输出
openclaw sessions --json3.8 Skills 技能管理
openclaw skills [command]skills list | |
skills info <skill> | |
skills check |
示例:
# 列出所有技能
openclaw skills list
# 查看技能详情
openclaw skills info healthcheck
# 检查技能依赖
openclaw skills check3.9 Browser 浏览器自动化
管理 OpenClaw 的专用浏览器(Chrome/Chromium),支持完整的浏览器自动化。
openclaw browser [command]生命周期管理
browser start | |
browser stop | |
browser status | |
browser profiles | |
browser create-profile <name> | |
browser delete-profile <name> | |
browser reset-profile <name> |
标签页管理
browser tabs | |
browser open <url> | |
browser focus <targetId> | |
browser close [targetId] | |
browser tab <index> |
页面操作
browser navigate <url> | |
browser click <ref> | |
browser type <ref> <text> | |
browser press <key> | |
browser hover <ref> | |
browser drag <from> <to> | |
browser select <ref> <options...> | |
browser fill --fields <json> | |
browser upload <path> | |
browser scrollintoview <ref> | |
browser highlight <ref> |
等待与条件
browser wait | |
browser waitfordownload |
数据捕获
browser snapshot | |
browser screenshot | |
browser pdf | |
browser evaluate --fn <function> | |
browser console | |
browser errors | |
browser requests | |
browser responsebody | |
browser trace |
存储与 Cookie
browser cookies | |
browser storage |
对话框处理
browser dialog |
浏览器选项
--browser-profile <name> | |
--timeout <ms> | |
--json | |
--url <url> | |
--token <token> |
示例:
# 启动浏览器
openclaw browser start
# 打开页面
openclaw browser open https://example.com
# 捕获快照
openclaw browser snapshot
# 使用 aria 格式快照
openclaw browser snapshot --format aria --limit 200
# 截图
openclaw browser screenshot
openclaw browser screenshot --full-page
openclaw browser screenshot --ref 12
# 点击元素(引用来自快照)
openclaw browser click 12 --double
# 输入文本并提交
openclaw browser type 23 "hello" --submit
# 导航
openclaw browser navigate https://example.com
# 调整窗口大小
openclaw browser resize 1280 720
# 等待页面加载
openclaw browser wait --text "Done"
# 保存为 PDF
openclaw browser pdf3.10 Message 消息操作
发送、读取和管理消息及通道操作。
openclaw message [command]消息操作
message send | |
message read | |
message edit | |
message delete | |
message react | |
message reactions | |
message pin | |
message unpin | |
message pins |
成员管理
message kick | |
message ban | |
message timeout | |
message member |
频道操作
message channel | |
message permissions | |
message role | |
message thread |
高级功能
message broadcast | |
message poll | |
message search | |
message emoji | |
message sticker | |
message event | |
message voice |
示例:
# 发送文本消息
openclaw message send --target +15555550123 --message "Hi"
# 发送带媒体的消息
openclaw message send --target +15555550123 --message "Hi" --media photo.jpg
# 创建 Discord 投票
openclaw message poll \
--channel discord \
--target channel:123 \
--poll-question "Snack?" \
--poll-option Pizza \
--poll-option Sushi
# 对消息添加反应
openclaw message react \
--channel discord \
--target 123 \
--message-id 456 \
--emoji "✅"3.11 Devices & Nodes 设备管理
Devices - 设备配对和令牌管理
openclaw devices [command]devices list | |
devices approve | |
devices reject | |
devices remove | |
devices clear | |
devices revoke | |
devices rotate |
Nodes - 网关节点管理
openclaw nodes [command]nodes status | |
nodes list | |
nodes pending | |
nodes approve | |
nodes reject | |
nodes rename | |
nodes describe | |
nodes invoke | |
nodes run | |
nodes camera | |
nodes canvas | |
nodes screen | |
nodes location | |
nodes notify | |
nodes push |
示例:
# 查看节点状态
openclaw nodes status
# 查看待处理请求
openclaw nodes pairing pending
# 批准配对
openclaw nodes approve --id <device_id>
# 在节点上运行命令
openclaw nodes run --node <id> --raw "uname -a"
# 捕获照片
openclaw nodes camera snap --node <id>
# 获取位置
openclaw nodes location get --node <id>3.12 Agents 隔离代理
管理隔离代理(工作空间 + 认证 + 路由)。
openclaw agents [command]agents list | |
agents add | |
agents delete | |
agents set-identity | |
agents bind | |
agents unbind | |
agents bindings |
示例:
# 列出所有代理
openclaw agents list
# 添加新代理
openclaw agents add --id work --name "Work Agent"
# 设置代理身份
openclaw agents set-identity --id work --name "Work Helper" --emoji "💼"
# 添加路由绑定
openclaw agents bind --id work --channel telegram --target @workchat3.13 其他重要命令
Update 更新管理
openclaw update [options] [command]update status | |
update wizard | |
| (无子命令) |
--channel <stable|beta|dev> | |
--tag <dist-tag|version> | |
--dry-run | |
--no-restart | |
--yes | |
--timeout <seconds> |
示例:
# 检查更新状态
openclaw update status
# 执行更新
openclaw update
# 切换到 beta 通道
openclaw update --channel beta
# 预览更新
openclaw update --dry-run
# 不重启更新
openclaw update --no-restartDoctor 健康检查
openclaw doctor [options]--fix--repair | |
--force | |
--deep | |
--generate-gateway-token | |
--non-interactive | |
--yes |
示例:
# 运行健康检查
openclaw doctor
# 自动修复问题
openclaw doctor --fix
# 生成网关令牌
openclaw doctor --generate-gateway-tokenBackup 备份管理
openclaw backup [command]backup create | |
backup verify |
示例:
# 创建备份
openclaw backup create
# 验证备份
openclaw backup verify <backup-file>ACP (Agent Control Protocol)
openclaw acp [command]用于管理 ACP 工具和代理控制协议。
Memory 记忆管理
openclaw memory [command]搜索和重新索引记忆文件。
Webhooks Webhook 管理
openclaw webhooks [command]Webhook 助手和集成。
Logs 日志查看
openclaw logs通过 RPC 查看网关文件日志。
Dashboard 控制面板
openclaw dashboard使用当前令牌打开控制 UI。
TUI 终端界面
openclaw tui打开连接到网关的终端 UI。
4. 实用场景示例
场景 1: 初次设置 OpenClaw
# 1. 初始化
openclaw setup
# 2. 配置凭证和通道
openclaw configure
# 3. 验证配置
openclaw config validate
# 4. 启动网关
openclaw gateway start
# 5. 检查状态
openclaw status
# 6. 运行安全审计
openclaw security audit --fix场景 2: 配置 Telegram Bot
# 1. 添加 Telegram Bot
openclaw channels add --channel telegram --token "YOUR_BOT_TOKEN"
# 2. 验证通道状态
openclaw channels status
# 3. 发送测试消息
openclaw message send \
--channel telegram \
--target @your_channel \
--message "Hello from OpenClaw!"场景 3: 设置定时安全审计
# 1. 创建定时任务(每天早上 9 点运行)
openclaw cron add \
--name "daily-security-audit" \
--schedule "cron" \
--cron-expr "0 9 * * *" \
--payload-type "systemEvent" \
--payload-text "Run security audit"
# 2. 列出所有定时任务
openclaw cron list
# 3. 查看任务运行历史
openclaw cron runs daily-security-audit场景 4: 浏览器自动化任务
# 1. 启动浏览器
openclaw browser start
# 2. 打开目标网站
openclaw browser open https://example.com
# 3. 捕获页面快照
openclaw browser snapshot > page.json
# 4. 截图
openclaw browser screenshot --full-page
# 5. 执行操作(根据快照中的 ref)
openclaw browser click 12
openclaw browser type 23 "search query" --submit
# 6. 等待结果
openclaw browser wait --text "Results"
# 7. 保存 PDF
openclaw browser pdf
# 8. 停止浏览器
openclaw browser stop场景 5: 多代理设置
# 1. 创建工作代理
openclaw agents add --id work --name "Work Assistant"
openclaw agents set-identity --id work --emoji "💼" --theme professional
# 2. 创建个人代理
openclaw agents add --id personal --name "Personal Assistant"
openclaw agents set-identity --id personal --emoji "🏠" --theme casual
# 3. 绑定路由
openclaw agents bind --id work --channel telegram --target @work_group
openclaw agents bind --id personal --channel telegram --target @personal_chat
# 4. 列出代理
openclaw agents list场景 6: 备份与迁移
# 1. 创建完整备份
openclaw backup create --output openclaw-backup-$(date +%Y%m%d).zip
# 2. 验证备份
openclaw backup verify openclaw-backup-20260323.zip
# 3. 导出配置(供手动检查)
openclaw config file
# 4. 在新机器上恢复:
# - 安装 OpenClaw
# - 解压备份到配置目录
# - 运行 doctor 修复权限
openclaw doctor --fix5. 故障排查
5.1 网关无法启动
# 检查端口占用
openclaw gateway probe
# 强制启动(关闭占用进程)
openclaw gateway run --force
# 查看详细日志
openclaw logs --follow
# 运行诊断
openclaw doctor --deep --fix5.2 通道连接问题
# 检查通道状态
openclaw channels status --probe
# 查看通道日志
openclaw channels logs
# 重新登录
openclaw channels logout --channel telegram
openclaw channels login --channel telegram5.3 安全问题修复
# 运行安全审计
openclaw security audit --deep
# 自动修复
openclaw security audit --fix
# 手动修复特定配置
openclaw config unset gateway.controlUi.dangerouslyAllowHostHeaderOriginFallback5.4 性能问题
# 清理会话存储
openclaw sessions cleanup
# 检查资源使用
openclaw gateway usage-cost
# 深度检查
openclaw doctor --deep参考资源
• 官方文档: https://docs.openclaw.ai • CLI 文档: https://docs.openclaw.ai/cli • GitHub: https://github.com/openclaw/openclaw • Discord 社区: https://discord.com/invite/clawd

夜雨聆风