OpenClaw 命令行完整版 OpenClaw 常用指令大全_持续更新

内容管家 AI领域评论78字数 2720阅读9分4秒阅读模式
OpenClaw 命令行完整版 OpenClaw 常用指令大全_持续更新插图

OpenClaw 完整命令行参考指南 全命令汇总 持续更新

OpenClaw 提供了丰富的命令行工具,支持从基础设置到高级自动化的完整功能集。本文档汇总了所有可用的 CLI 命令、安装方法、升级与卸载命令,以及入门向导命令。OpenClaw文档中的所有命令都包含在本文中里,只有简单注释,无废话,方便快速查找。本文会持续更新,建议收藏。

一、安装与初始化

1.1 推荐的安装方式

使用安装脚本是最简单的方式,会自动检测并安装 Node.js:

# macOS / Linux / WSL2
curl -fsSL https://openclaw.ai/install.sh | bash

# Windows (PowerShell)
iwr -useb https://openclaw.ai/install.ps1 | iex

跳过向导仅安装二进制:

curl -fsSL https://openclaw.ai/install.sh | bash -s -- --no-onboard

1.2 npm/pnpm 安装

# npm 安装
npm install -g openclaw@latest
openclaw onboard --install-daemon

# pnpm 安装
pnpm add -g openclaw@latest
pnpm approve-builds -g
openclaw onboard --install-daemon

1.3 Docker 安装

# 克隆仓库并运行安装脚本
git clone https://github.com/openclaw/openclaw.git
cd openclaw
./docker-setup.sh

1.4 初始化命令

# 初始化配置和工作区
openclaw setup
openclaw setup --workspace ~/.openclaw/workspace
openclaw setup --wizard

# 交互式向导设置
openclaw onboard
openclaw onboard --flow quickstart
openclaw onboard --flow manual
openclaw onboard --mode remote --remote-url ws://gateway-host:18789

1.5 配置管理

# 交互式配置向导
openclaw configure
openclaw configure --section models --section channels

# 非交互式配置
openclaw config get <path>
openclaw config set <path> <value>
openclaw config unset <path>

二、升级与更新

2.1 使用安装脚本升级

# 推荐:重新运行安装脚本
curl -fsSL https://openclaw.ai/install.sh | bash

# 跳过向导
curl -fsSL https://openclaw.ai/install.sh | bash -s -- --no-onboard

2.2 npm/pnpm 升级

# npm 升级
npm i -g openclaw@latest

# pnpm 升级
pnpm add -g openclaw@latest

2.3 使用 openclaw update 命令

# 基础更新
openclaw update

# 查看更新状态
openclaw update status

# 交互式更新向导
openclaw update wizard

# 切换更新通道
openclaw update --channel stable
openclaw update --channel beta
openclaw update --channel dev

# 跳过重启
openclaw update --no-restart

# --update 简写
openclaw --update

三、卸载

# 交互式卸载
openclaw uninstall

# 非交互式卸载
openclaw uninstall --all --yes

# 预览卸载内容
openclaw uninstall --dry-run

四、状态监控

4.1 核心状态命令

# 查看网关状态 ⭐⭐⭐⭐⭐
openclaw status
openclaw status --all
openclaw status --deep
openclaw status --usage

# 健康检查
openclaw health
openclaw health --json

# 医生检查
openclaw doctor
openclaw doctor --deep
openclaw doctor --fix

4.2 网关服务管理

# 查看网关服务状态
openclaw gateway status
openclaw gateway status --json

# 启动/停止/重启网关
openclaw gateway start
openclaw gateway stop
openclaw gateway restart

# 前台运行网关
openclaw gateway
openclaw gateway --port 18789
openclaw gateway --bind lan

4.3 日志查看

# 实时日志
openclaw logs --follow

# 查看最近日志
openclaw logs --limit 200

# JSON 格式
openclaw logs --json

# 无颜色输出
openclaw logs --plain
openclaw logs --no-color

4.4 会话管理

# 列出所有会话
openclaw sessions
openclaw sessions --json
openclaw sessions --active 30

五、消息与通信

5.1 发送消息

# 发送消息 (Discord/Telegram/WhatsApp/Slack 等)
openclaw message send --channel discord --target channel:123 --message "Hello"
openclaw message send --channel telegram --target @username --message "Hello"
openclaw message send --channel whatsapp --target +15555550123 --message "Hello"

# 发送媒体文件
openclaw message send --channel discord --target channel:123 --media /path/to/image.png

# 回复消息
openclaw message send --channel discord --target channel:123 --message "Hi" --reply-to 456

5.2 投票功能

# 创建投票
openclaw message poll --channel discord --target channel:123 \
  --poll-question "你更喜欢哪个?" \
  --poll-option 选项A --poll-option 选项B \
  --poll-multi --poll-duration-hours 48

5.3 消息交互

# 添加反应
openclaw message react --channel discord --target C123 --message-id 456 --emoji "✅"

# 搜索消息
openclaw message search --channel discord --guild-id G123 --query "关键词"

# 编辑/删除消息
openclaw message edit --channel discord --message-id 123 --message "新内容"
openclaw message delete --channel discord --message-id 123 --target channel:456

5.4 频道操作

# 线程操作
openclaw message thread create --channel discord --target 123 --thread-name "新线程" --message "内容"
openclaw message thread list --channel discord --guild-id G123

# 创建活动
openclaw message event create --channel discord --guild-id G123 --event-name "会议" --start-time "2026-03-01T10:00:00"

六、频道管理

6.1 频道列表与状态

# 列出已配置的频道
openclaw channels list
openclaw channels list --no-usage

# 检查频道健康状态
openclaw channels status
openclaw channels status --probe

# 查看频道能力
openclaw channels capabilities
openclaw channels capabilities --channel discord

6.2 添加/移除频道

# 添加频道 (Telegram)
openclaw channels add --channel telegram --token $TELEGRAM_BOT_TOKEN

# 添加频道 (Discord)
openclaw channels add --channel discord --token $DISCORD_BOT_TOKEN

# 添加频道 (WhatsApp)
openclaw channels add --channel whatsapp

# 移除频道
openclaw channels remove --channel discord --account work
openclaw channels remove --channel discord --account work --delete

6.3 频道登录/登出

# 登录 (WhatsApp QR 码)
openclaw channels login --channel whatsapp

# 登出
openclaw channels logout --channel whatsapp

6.4 配对管理

# 列出配对请求
openclaw pairing list telegram

# 批准配对
openclaw pairing approve telegram 123456

七、网关管理

7.1 网关运行选项

# 运行网关
openclaw gateway
openclaw gateway run

# 指定端口和绑定模式
openclaw gateway --port 18789 --bind lan

# 认证选项
openclaw gateway --token my-token
openclaw gateway --auth password

# Tailscale 集成
openclaw gateway --tailscale serve
openclaw gateway --tailscale funnel

# 开发模式
openclaw gateway --dev
openclaw gateway --reset

7.2 网关 RPC 调用

# 健康检查
openclaw gateway health

# 状态探测
openclaw gateway status
openclaw gateway status --deep

# 发现网关
openclaw gateway discover

# 调用 RPC 方法
openclaw gateway call status
openclaw gateway call config.get

7.3 网关服务安装

# 安装网关服务
openclaw gateway install
openclaw gateway install --port 18789
openclaw gateway install --runtime node

# 卸载服务
openclaw gateway uninstall

八、模型管理

8.1 模型状态与列表

# 查看模型状态
openclaw models status
openclaw models status --json
openclaw models status --probe

# 列出可用模型
openclaw models list
openclaw models list --all
openclaw models list --provider anthropic

8.2 设置默认模型

# 设置主模型
openclaw models set claude-sonnet-4-20250514

# 设置图像模型
openclaw models set-image claude-3-5-sonnet-20241022

8.3 模型别名管理

# 列出别名
openclaw models aliases list

# 添加别名
openclaw models aliases add my-model claude-sonnet-4-20250514

# 移除别名
openclaw models aliases remove my-model

8.4 备用模型管理

# 列出备用模型
openclaw models fallbacks list

# 添加备用模型
openclaw models fallbacks add claude-3-haiku-20240307

# 清除备用模型
openclaw models fallbacks clear

8.5 认证管理

# 添加认证
openclaw models auth add

# 设置 Token
openclaw models auth setup-token --provider anthropic
openclaw models auth paste-token --provider anthropic

8.6 模型扫描

# 扫描可用模型
openclaw models scan
openclaw models scan --provider anthropic
openclaw models scan --set-default

九、节点管理

9.1 节点列表与状态

# 列出所有节点
openclaw nodes list
openclaw nodes list --connected

# 查看节点状态
openclaw nodes status
openclaw nodes status --connected

# 列出待批准的请求
openclaw nodes pending

9.2 节点操作

# 批准节点
openclaw nodes approve <requestId>

# 拒绝节点
openclaw nodes reject <requestId>

# 重命名节点
openclaw nodes rename --node my-node --name "新名称"

9.3 节点远程执行

# 在节点上执行命令
openclaw nodes run --node <node-id> "ls -la"
openclaw nodes run --node <node-id> --cwd /home/user "git status"

# 调用节点命令
openclaw nodes invoke --node <node-id> --command <command> --params '{}'

9.4 节点相机控制

# 列出相机
openclaw nodes camera list --node <node-id>

# 拍照
openclaw nodes camera snap --node <node-id> --facing front

# 录像
openclaw nodes camera clip --node <node-id> --facing back --duration 10s

9.5 节点屏幕控制

# 屏幕快照
openclaw nodes canvas snapshot --node <node-id>

# 屏幕录制
openclaw nodes screen record --node <node-id> --duration 10s

# 显示内容
openclaw nodes canvas present --node <node-id> --target https://example.com

十、浏览器控制

10.1 浏览器管理

# 查看浏览器状态
openclaw browser status

# 启动/停止浏览器
openclaw browser start
openclaw browser stop

# 重置浏览器配置
openclaw browser reset-profile

10.2 标签页管理

# 列出标签页
openclaw browser tabs

# 打开新标签页
openclaw browser open https://example.com

# 聚焦标签页
openclaw browser focus <targetId>

# 关闭标签页
openclaw browser close <targetId>

10.3 浏览器操作

# 截屏
openclaw browser screenshot
openclaw browser screenshot --full-page

# 页面快照
openclaw browser snapshot
openclaw browser snapshot --format aria

# 导航
openclaw browser navigate https://example.com

# 调整窗口大小
openclaw browser resize 1920 1080

10.4 UI 自动化

# 点击元素
openclaw browser click <ref>
openclaw browser click <ref> --double

# 输入文本
openclaw browser type <ref> "hello"
openclaw browser type <ref> "hello" --slowly

# 按键
openclaw browser press Enter

# 悬停
openclaw browser hover <ref>

# 拖拽
openclaw browser drag <startRef> <endRef>

# 选择
openclaw browser select <ref> value1 value2

# 上传文件
openclaw browser upload /path/to/file.png --ref <input-ref>

# 填写表单
openclaw browser fill --fields '[{"ref":"email","value":"test@example.com"}]'

# 对话框
openclaw browser dialog --accept
openclaw browser dialog --dismiss

# 等待
openclaw browser wait --text "加载完成"

# 执行 JavaScript
openclaw browser evaluate --fn "return document.title"

# 查看控制台
openclaw browser console --level error

10.5 浏览器配置

# 列出配置
openclaw browser profiles

# 创建配置
openclaw browser create-profile --name work --color "#FF5A36"

# 删除配置
openclaw browser delete-profile --name work

十一、定时任务

11.1 任务管理

# 查看任务状态
openclaw cron status

# 列出所有任务
openclaw cron list
openclaw cron list --all
openclaw cron list --json

11.2 创建任务

# 创建一次性任务
openclaw cron add --name "提醒" --at "2026-03-01T10:00:00" --system-event "记得开会"

# 创建重复任务
openclaw cron add --name "每日报告" --every 1d --system-event "生成日报"

# 创建定时任务
openclaw cron add --name "每周清理" --cron "0 2 * * 0" --message --channel telegram --to "123456"

11.3 任务操作

# 编辑任务
openclaw cron edit <job-id> --announce --channel telegram --to "123456"

# 删除任务
openclaw cron rm <job-id>

# 启用/禁用任务
openclaw cron enable <job-id>
openclaw cron disable <job-id>

11.4 任务执行

# 查看任务运行历史
openclaw cron runs --id <job-id> --limit 10

# 手动运行任务
openclaw cron run <job-id>
openclaw cron run <job-id> --force

十二、技能与插件

12.1 技能管理

# 列出所有技能
openclaw skills list
openclaw skills list --eligible

# 查看技能详情
openclaw skills info <skill-name>

# 检查技能状态
openclaw skills check

12.2 插件管理

# 列出插件
openclaw plugins list
openclaw plugins list --json

# 查看插件详情
openclaw plugins info <plugin-id>

# 安装插件
openclaw plugins install <path-or-npm>

# 启用/禁用插件
openclaw plugins enable <plugin-id>
openclaw plugins disable <plugin-id>

# 插件诊断
openclaw plugins doctor

12.3 内存管理

# 查看内存索引状态
openclaw memory status

# 重新索引内存
openclaw memory index

# 搜索内存
openclaw memory search "之前讨论的内容"

十三、安全与维护

13.1 安全审计

# 安全审计
openclaw security audit
openclaw security audit --deep

# 自动修复安全问题
openclaw security audit --fix

# JSON 格式输出
openclaw security audit --json | jq '.summary'

13.2 系统操作

# 发送系统事件
openclaw system event --text "自定义事件"

# 心跳控制
openclaw system heartbeat last
openclaw system heartbeat enable
openclaw system heartbeat disable

# 在线状态
openclaw system presence

13.3 沙箱管理

# 列出沙箱
openclaw sandbox list

# 重建沙箱
openclaw sandbox recreate

# 解释沙箱配置
openclaw sandbox explain

13.4 重置操作

# 重置配置
openclaw reset --scope config

# 重置配置+凭证+会话
openclaw reset --scope "config+creds+sessions"

# 完全重置
openclaw reset --scope full --yes

13.5 审批管理

# 获取审批设置
openclaw approvals get

# 设置审批
openclaw approvals set --allow

# 白名单管理
openclaw approvals allowlist add user123
openclaw approvals allowlist remove user123

13.6 Webhooks

# Gmail Webhook 设置
openclaw webhooks gmail setup --account user@gmail.com

# 运行 Gmail Webhook
openclaw webhooks gmail run

十四、其他命令

14.1 TUI 终端界面

# 打开终端 UI
openclaw tui

# 带消息打开
openclaw tui --message "Hello"

# 指定会话
openclaw tui --session <session-key>

14.2 文档搜索

# 搜索文档
openclaw docs
openclaw docs "安装教程"

14.3 DNS 设置

# DNS 设置 (macOS)
openclaw dns setup
openclaw dns setup --apply

14.4 Agent 管理

# 列出 Agent
openclaw agents list

# 添加 Agent
openclaw agents add my-agent

# 删除 Agent
openclaw agents delete my-agent

14.5 运行单次对话

# 运行单次 Agent
openclaw agent --message "你好"
openclaw agent --message "总结一下当前会话" --thinking medium

14.6 ACP 桥接

# 运行 ACP 桥接
openclaw acp

十五、全局标志

--dev          # 开发模式,隔离状态
--profile <name>  # 指定配置名称
--no-color    # 禁用颜色输出
--update      # 更新命令简写
-V, --version # 显示版本
-v            # 详细输出

总结

OpenClaw 提供了全面的命令行工具集,涵盖了从安装、配置到日常管理的各个环节。通过熟练掌握这些命令,您可以高效地管理您的 AI 代理系统。

建议收藏本文,以便随时查阅。

 最后更新:2026-2-22
内容管家

发表评论