OpenClaw常用命令说明
OpenClaw 常用命令说明
本文档整理了 OpenClaw CLI 的常用命令,包括命令格式、参数说明和使用示例。
目录
Gateway 控制命令
Gateway 是 OpenClaw 的核心服务,提供 WebSocket 连接和消息路由功能。
gateway start
启动 Gateway 服务(后台运行,使用 launchd/systemd/schtasks)。
命令格式:
openclaw gateway start [options]参数说明:
| 参数 | 说明 |
|---|---|
--port <port> | 指定 Gateway WebSocket 端口 |
--force | 强制启动,终止占用端口的进程 |
--dev | 使用开发模式配置 |
--verbose | 启用详细日志输出 |
使用示例:
# 启动 Gateway 服务
openclaw gateway start
# 强制启动并指定端口
openclaw gateway start --force --port 19001
# 开发模式启动
openclaw gateway start --devgateway stop
停止 Gateway 服务。
命令格式:
openclaw gateway stop [options]使用示例:
# 停止 Gateway 服务
openclaw gateway stopgateway restart
重启 Gateway 服务。
命令格式:
openclaw gateway restart [options]使用示例:
# 重启 Gateway 服务
openclaw gateway restart
# 强制重启
openclaw gateway restart --forcegateway status
查看 Gateway 服务状态和健康检查。
命令格式:
openclaw gateway status [options]使用示例:
# 查看 Gateway 状态
openclaw gateway status
# 查看详细状态
openclaw gateway status --verbosegateway run
以前台模式运行 Gateway(用于调试或手动运行)。
命令格式:
openclaw gateway run [options]常用参数:
| 参数 | 说明 |
|---|---|
--port <port> | WebSocket 端口,默认 18789 |
--bind <mode> | 绑定模式:loopback/lan/tailnet/auto/custom |
--auth <mode> | 认证模式:token 或 password |
--token <token> | 连接认证令牌 |
--verbose | 详细日志输出 |
--compact | 紧凑的 WebSocket 日志格式 |
--force | 终止占用端口的进程后启动 |
使用示例:
# 前台运行 Gateway
openclaw gateway run
# 指定端口并启用详细日志
openclaw gateway run --port 19001 --verbose
# 强制运行(终止占用端口的进程)
openclaw gateway run --force
# 开发模式运行
openclaw gateway --devgateway health
获取 Gateway 健康状态。
命令格式:
openclaw gateway healthgateway probe
探测 Gateway 可达性和状态摘要。
命令格式:
openclaw gateway probeAgent 管理命令
Agent 是 OpenClaw 的智能代理实例,可以独立运行和管理。
agent
运行单个 Agent 交互回合。
命令格式:
openclaw agent [options]常用参数:
| 参数 | 说明 |
|---|---|
--to <target> | 目标接收者(电话号码或用户ID) |
--message <text> | 要发送的消息内容 |
--deliver | 发送回复到指定渠道 |
--local | 使用嵌入式模式运行 |
--json | 以 JSON 格式输出结果 |
使用示例:
# 向 Agent 发送消息
openclaw agent --to +15555550123 --message "生成今日报告"
# 运行 Agent 并发送回复到 WhatsApp
openclaw agent --to +15555550123 --message "运行摘要" --deliver
# 本地模式运行
openclaw agent --localagents
管理多个独立的 Agent 实例(工作空间、认证和路由)。
命令格式:
openclaw agents <command> [options]子命令:
| 命令 | 说明 |
|---|---|
list | 列出所有 Agent |
add | 添加新的 Agent |
remove | 移除 Agent |
show | 显示 Agent 详情 |
使用示例:
# 列出所有 Agent
openclaw agents list
# 添加新 Agent
openclaw agents add --name my-agent
# 显示 Agent 详情
openclaw agents show my-agent消息发送命令
通过配置的渠道发送消息。
message send
发送消息到指定目标。
命令格式:
openclaw message send [options]常用参数:
| 参数 | 说明 |
|---|---|
--target <target> | 目标接收者(电话号码、用户名或群组ID) |
--message <text> | 消息内容 |
--channel <name> | 使用的渠道(whatsapp, telegram 等) |
--json | 以 JSON 格式输出结果 |
--file <path> | 附加文件路径 |
使用示例:
# 发送 WhatsApp 消息
openclaw message send --target +15555550123 --message "你好!"
# 发送 Telegram 消息
openclaw message send --channel telegram --target @mychat --message "Hi"
# 发送消息并输出 JSON 结果
openclaw message send --target +15555550123 --message "Hi" --json
# 发送带附件的消息
openclaw message send --target +15555550123 --message "请查收文件" --file ./report.pdf渠道管理命令
管理消息渠道的登录和配置。
channels login
登录消息渠道。
命令格式:
openclaw channels login [options]常用参数:
| 参数 | 说明 |
|---|---|
--verbose | 显示详细的连接日志和二维码 |
--channel <name> | 指定要登录的渠道 |
使用示例:
# 登录 WhatsApp Web(显示二维码)
openclaw channels login --verbose
# 登录指定渠道
openclaw channels login --channel telegram --verbosechannels 其他命令
# 列出所有渠道状态
openclaw channels list
# 登出渠道
openclaw channels logout --channel whatsapp配置管理命令
管理 OpenClaw 的配置项。
config get
获取配置值。
命令格式:
openclaw config get <key>使用示例:
# 获取 Gateway 模式配置
openclaw config get gateway.mode
# 获取默认模型配置
openclaw config get agents.defaults.modelconfig set
设置配置值。
命令格式:
openclaw config set <key> <value>使用示例:
# 设置 Gateway 模式为本地模式
openclaw config set gateway.mode local
# 设置默认模型
openclaw config set agents.defaults.model claude-3-sonnetconfig unset
删除配置项。
命令格式:
openclaw config unset <key>使用示例:
# 删除配置项
openclaw config unset gateway.modeconfig(交互式配置向导)
不带参数运行 config 命令会启动交互式配置向导。
命令格式:
openclaw config健康检查命令
doctor
运行健康检查和快速修复工具。
命令格式:
openclaw doctor [options]常用参数:
| 参数 | 说明 |
|---|---|
--fix | 自动修复发现的问题 |
--verbose | 显示详细信息 |
使用示例:
# 运行健康检查
openclaw doctor
# 运行检查并自动修复问题
openclaw doctor --fix
# 详细模式检查
openclaw doctor --verbose其他常用命令
status
显示渠道健康状态和最近会话接收者。
命令格式:
openclaw status [options]使用示例:
# 查看整体状态
openclaw status
# 查看详细状态
openclaw status --verboseonboard
交互式向导,用于设置 Gateway、工作空间和技能。
命令格式:
openclaw onboard [options]使用示例:
# 启动设置向导
openclaw onboardsetup
初始化 OpenClaw 配置文件和工作空间。
命令格式:
openclaw setup [options]使用示例:
# 初始化配置
openclaw setup
# 开发模式初始化
openclaw setup --devconfigure
交互式配置向导,设置凭证、设备和 Agent 默认值。
命令格式:
openclaw configurereset
重置本地配置和状态(保留 CLI 安装)。
命令格式:
openclaw reset [options]使用示例:
# 重置配置
openclaw resetuninstall
卸载 Gateway 服务和本地数据(CLI 保留)。
命令格式:
openclaw uninstall全局选项
以下选项适用于所有命令:
| 选项 | 说明 |
|---|---|
--dev | 使用开发配置(隔离状态到 ~/.openclaw-dev) |
--profile <name> | 使用命名配置文件(隔离到 ~/.openclaw-) |
--no-color | 禁用 ANSI 颜色输出 |
-h, --help | 显示命令帮助信息 |
-V, --version | 显示版本号 |
使用示例:
# 使用开发模式
openclaw --dev gateway start
# 使用命名配置文件
openclaw --profile work gateway start
# 查看命令帮助
openclaw gateway --help常见工作流程
初始化 OpenClaw
# 首次设置
openclaw setup
openclaw onboard
# 配置凭证
openclaw configure启动和使用 Gateway
# 启动 Gateway
openclaw gateway start
# 检查状态
openclaw gateway status
# 登录消息渠道
openclaw channels login --verbose
# 发送消息
openclaw message send --target +15555550123 --message "Hello!"故障排查
# 运行健康检查
openclaw doctor
# 查看日志
openclaw logs
# 查看 Gateway 状态
openclaw gateway status --verbose参考文档
官方文档:https://docs.openclaw.ai/cli
文档版本:2026.2.12
