OpenClaw的核心指令使用方法详解

  发布时间:2026-04-01 14:05:48   作者:yunianshu   我要评论
OpenClaw 是一个开源的个人 AI 助手框架,支持通过命令行界面(CLI)进行全面的配置、管理和操作,此外,它还支持在 macOS/iOS/Android 上进行语音交互,并提供实时画布界面供用户控制,下面小编就和大家详细介绍一下它的核心命令的使用吧

一、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 gmailGmail 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的核心指令使用方法详解的文章就介绍到这了,更多相关OpenClaw指令使用内容请搜索脚本之家以前的文章或继续浏览下面的相关文章,希望大家以后多多支持脚本之家!

相关文章

  • 一文总结openclaw小龙虾常用指令(建议收藏)

    OpenClaw是一个自主通信网关,它将WhatsApp、Telegram、Discord和iMessage等主流即时通讯应用与可编程人工智能代理连接起来,这篇文章主要为大家整理了一些openclaw常用指令
    2026-03-23
  • OpenClaw 指令大全(全网最全)

    OpenClaw 是一个强大的 AI 助手框架,但有 40+ 核心命令,本文就来介绍一下OpenClaw 指令大全,文中通过示例代码介绍的非常详细,需要的朋友们下面随着小编来一起学习学习吧
    2026-03-23
  • 浅谈windows下openclaw的操作指令小结

    本文档详细介绍了Windows系统下OpenClaw的操作指令,包括基础操作、Gateway网关管理、模型管理、技能管理、通道管理、Agent管理、浏览器自动化、定时任务、系统与日志以及配
    2026-03-16
  • OpenClaw常用操作命令完整速查手册:从入门到精通的终端 CLI & 聊

    作为 OpenClaw 生态(包括 PicoClaw、ZeroClaw、losterAI、EasyClaw 等系列开源应用)的核心用户,我根据开源资料和个人使用体验整理了这份全网最全的命令速查手册
    2026-03-09
  • openclaw常用指令的使用小结

    OpenClaw 是一款功能强大的开源 AI 助手框架,支持对接多种大模型和通讯平台,下面就来介绍一下openclaw常用指令,需要的朋友们下面随着小编来一起学习学习吧
    2026-03-04

最新评论