OpenClaw Console CLI 完整参考手册
版本:OpenClaw 2026.6.1 · 官方文档:docs.openclaw.ai/cli
全局选项
运行任何子命令前可附加以下全局 flag:
| Flag | 说明 |
|---|---|
--dev | 使用开发模式:状态隔离到 ~/.openclaw-dev,默认端口 19001 |
--profile <name> | 使用命名 profile,状态隔离到 ~/.openclaw-<name> |
--container <name> | 在指定的 Podman/Docker 容器内运行 CLI(也可用环境变量 OPENCLAW_CONTAINER) |
--no-color | 关闭 ANSI 颜色输出(等效于 NO_COLOR=1) |
--log-level <level> | 全局日志级别:silent|fatal|error|warn|info|debug|trace |
-V, --version | 输出版本号并退出 |
一、安装 & 初始化
onboard
首次安装引导:交互式完成 Gateway 配置、模型鉴权、工作区创建、频道接入、技能安装和健康检查的完整流程。
openclaw onboard
openclaw onboard --mode local
openclaw onboard --reset # 重置配置和凭据后重新引导
- 重新运行不会清除已有数据,除非主动选择 Reset 或传入
--reset --reset-scope full可同时清除工作区- 如配置无效或有旧版遗留字段,会提示先运行
openclaw doctor - 远程模式(remote)只配置本地客户端连接到已有 Gateway,不在远端安装任何内容
setup
静默初始化:创建基础配置和工作区目录,不走完整引导流程。适合脚本或 CI 场景。
openclaw setup
configure
交互式配置修改:针对已有安装,修改模型鉴权、Gateway、频道、插件、技能等特定部分。
openclaw configure
crestodian
交互式修复助手:打开图形化的配置检查和修复向导,引导排查常见问题。
openclaw crestodian
doctor
自动诊断和修复:检查并修复配置、Gateway 服务、插件和频道的常见问题。
openclaw doctor
openclaw doctor --fix # 自动修复发现的问题
- 配置无效或旧版迁移失败时优先运行此命令
- 频道账号状态异常(如多账号混合配置)推荐用
--fix自动整理
completion
生成 Shell 自动补全脚本(支持 bash / zsh / fish 等)。
openclaw completion bash >> ~/.bashrc
openclaw completion zsh >> ~/.zshrc
二、Gateway 管理
gateway
运行和管理 OpenClaw Gateway(WebSocket 服务器,负责频道、节点、会话、hooks)。
# 启动 Gateway(前台运行)
openclaw gateway
openclaw gateway run
# 强制替换已占用端口的 Gateway
openclaw gateway run --force
# 开发模式 Gateway(隔离状态,端口 19001)
openclaw --dev gateway
# 指定端口和绑定方式
openclaw gateway --port 18789 --bind loopback
# 通过 Tailscale 暴露
openclaw gateway --tailscale serve
# 启动但不要求配置文件存在(临时测试)
openclaw gateway --allow-unconfigured
主要选项:
| 选项 | 说明 |
|---|---|
--port <port> | WebSocket 端口(默认 18789) |
--bind <loopback|lan|tailnet|auto|custom> | 监听绑定模式 |
--auth <token|password> | 鉴权模式 |
--token <token> | Token 覆盖 |
--password-file <path> | 从文件读取密码(比命令行传密更安全) |
--tailscale <off|serve|funnel> | Tailscale 暴露方式 |
--force | 启动前杀掉占用端口的进程 |
--allow-unconfigured | 跳过 gateway.mode=local 检查(仅用于临时调试) |
--verbose | 详细日志 |
--compact | 紧凑 WebSocket 日志 |
查询运行中的 Gateway:
# 健康检查
openclaw gateway health
openclaw gateway health --url ws://127.0.0.1:18789
# 费用统计(默认最近 30 天)
openclaw gateway usage-cost
openclaw gateway usage-cost --days 7 --json
# 稳定性诊断
openclaw gateway stability
openclaw gateway stability --bundle latest
openclaw gateway stability --export # 导出诊断 zip 包
# 导出诊断包(用于提交 bug report)
openclaw gateway diagnostics export
# 查看状态
openclaw gateway status
# 探针检查
openclaw gateway probe
health
直接获取 Gateway 详细健康状态(包含 eventLoop 延迟、CPU 利用率等)。
openclaw health
openclaw health --json
status
查看 Gateway、频道、模型和最近会话的综合状态。
openclaw status
openclaw status --deep # 深度探针,包含频道连通性检查
openclaw status --usage # 显示提供商用量/配额明细
openclaw status --json
logs
实时跟踪 Gateway 日志。
openclaw logs
openclaw logs --lines 100
openclaw logs --json
daemon
Gateway 服务管理(gateway 命令的旧版别名,功能一致)。
openclaw daemon start
openclaw daemon stop
openclaw daemon restart
openclaw daemon status
三、Agent 管理
agent
通过 Gateway 执行单次 Agent 请求(非交互式,适合脚本和 CI)。
# 向指定目标发送一次 agent 请求
openclaw agent --to +15555550123 --message "生成本周摘要" --deliver
# 指定模型运行
openclaw agent --message "分析这段代码" --model claude-sonnet-4-6
# 指定 agent 运行
openclaw agent --agent work --message "检查邮件"
agents
管理多个隔离 Agent(工作区、鉴权、路由绑定)。
# 列出所有 agent
openclaw agents
openclaw agents list
# 添加新 agent(交互式)
openclaw agents add
# 非交互式添加(需要 name 和 workspace)
openclaw agents add coder --workspace ~/.openclaw/workspace-coder
# 查看路由绑定
openclaw agents bindings
# 绑定频道到 agent
openclaw agents bind --agent work --bind telegram
openclaw agents bind --agent work --bind telegram:ops # 绑定到指定账号
openclaw agents bind --agent work --bind discord:* # 绑定频道所有账号
# 解除绑定
openclaw agents unbind --agent work --bind telegram
# 设置 agent 身份(名称、emoji、头像)
openclaw agents set-identity --agent main --name "OpenClaw" --emoji "🦞"
openclaw agents set-identity --workspace ~/.openclaw/workspace --from-identity
# 删除 agent(不含 main)
openclaw agents delete work
openclaw agents delete work --force # 跳过确认
main是保留名称,不能作为新 agent ID- 删除操作将工作区移入回收站,非硬删除
- 每个 agent 工作区可包含
IDENTITY.md定义身份信息
sessions
列出和查看存储的会话记录。
openclaw sessions
openclaw sessions list
openclaw sessions list --agent main
openclaw sessions list --json
memory
搜索、检查和重建 agent 的记忆文件索引。
openclaw memory status
openclaw memory index # 重建索引
openclaw memory search "关键词"
openclaw memory search "API 配置" --agent main
commitments
列出和管理 agent 推断出的待跟进承诺(follow-up commitments)。
openclaw commitments list
openclaw commitments dismiss <id>
transcripts
检查存储的会话转录文件。
openclaw transcripts list
openclaw transcripts list --agent main --json
四、频道管理
channels
添加、移除、登录和检查消息频道账号。
# 查看所有频道状态
openclaw channels list
openclaw channels status
openclaw channels status --probe # 实时探针检查(需要 Gateway 在线)
# 查看频道能力
openclaw channels capabilities
openclaw channels capabilities --channel discord --target channel:123456
# 解析名称为 ID
openclaw channels resolve --channel slack "#general" "@jane"
openclaw channels resolve --channel discord "My Server/#support"
openclaw channels resolve --channel matrix "Project Room"
# 查看频道日志
openclaw channels logs --channel telegram
openclaw channels logs --channel all
# 添加频道账号(交互式)
openclaw channels add
# 非交互式添加(Telegram)
openclaw channels add --channel telegram --token <bot-token>
# 添加 Nostr 频道
openclaw channels add --channel nostr --private-key "$NOSTR_PRIVATE_KEY"
# 删除频道账号
openclaw channels remove --channel telegram --delete
# 交互式登录(WhatsApp 等需要扫码的频道)
openclaw channels login --channel whatsapp
openclaw channels logout --channel whatsapp
channels status --probe是实时路径,Gateway 不在线时回退到仅显示配置摘要- 非交互式
add不会自动创建路由绑定;交互式向导可以可选地添加账号绑定 - 配置混乱时用
openclaw doctor --fix修复
directory
查找联系人和群组 ID(支持 self、peers、groups)。
openclaw directory self
openclaw directory peers list --channel telegram
openclaw directory groups list --channel discord
openclaw directory groups members <groupId> --channel slack
devices
设备配对和 Token 管理(移动端节点连接)。
openclaw devices list
openclaw devices pair
openclaw devices revoke <deviceId>
pairing
安全 DM 配对:审批入站配对请求。
openclaw pairing list # 列出待审批请求
openclaw pairing approve <id>
openclaw pairing deny <id>
qr
生成移动端配对 QR 码或设置码。
openclaw qr
message
发送、读取和管理频道消息(脚本/自动化场景)。
# 发送消息
openclaw message send --channel telegram --target @mychat --message "你好"
openclaw message send --channel discord --target channel:123456 --message "部署完成"
# 广播到多个目标
openclaw message broadcast --channel telegram --message "系统维护通知"
# 轮询消息状态
openclaw message poll
# 添加表情反应
openclaw message react --channel discord --message-id 123 --emoji "✅"
# 读取消息
openclaw message read --channel telegram --target @mychat
# 编辑消息
openclaw message edit --channel telegram --message-id 456 --message "修正内容"
# 删除消息
openclaw message delete --channel telegram --message-id 456
# 置顶/取消置顶
openclaw message pin --channel slack --message-id 789
openclaw message unpin --channel slack --message-id 789
# 在 Discord 论坛频道创建新线程
openclaw message thread create --channel discord --target channel:<forumId> --message "标题\n正文"
五、模型管理
models
列出、扫描和设置模型提供商。
# 查看模型和提供商鉴权状态
openclaw models status
# 列出所有可用模型
openclaw models list
openclaw models list --provider anthropic
openclaw models list --json
# 扫描提供商支持的模型(动态发现)
openclaw models scan
openclaw models scan --provider openai
# 设置默认模型
openclaw models set claude-sonnet-4-6
openclaw models set openai/gpt-4o
infer / capability
运行提供商支持的模型推断、媒体、搜索、嵌入等能力命令(capability 是 infer 的别名)。
openclaw infer --message "总结这段文字:..." --model claude-sonnet-4-6
openclaw capability --help # 查看子命令
六、技能 & 插件
skills
列出、搜索、安装和管理 agent 技能。
# 列出当前已安装的技能
openclaw skills list
openclaw skills list --agent main
# 搜索 ClawHub 技能市场
openclaw skills search "weather"
openclaw skills search "github"
# 安装技能
openclaw skills install weather
openclaw skills install github --agent work
# 更新技能
openclaw skills update
openclaw skills update weather
# 查看技能详情
openclaw skills info weather
# 检查技能健康状态
openclaw skills check
plugins
安装、启用、禁用和检查插件。
# 列出所有插件(已启用、已禁用、已安装)
openclaw plugins list
# 查看插件详情
openclaw plugins inspect open-prose
# 安装插件
openclaw plugins install clawhub:open-prose # 从 ClawHub 安装
openclaw plugins install ./my-local-plugin # 从本地路径安装
openclaw plugins install my-plugin-npm-package # 从 npm 安装
# 卸载插件
openclaw plugins uninstall open-prose
# 更新插件
openclaw plugins update
openclaw plugins update open-prose
# 启用/禁用插件
openclaw plugins enable open-prose
openclaw plugins disable open-prose
# 诊断插件问题
openclaw plugins doctor
# 浏览插件市场
openclaw plugins marketplace list
七、配置管理
config
非交互式配置读写(读写 ~/.openclaw/openclaw.json)。
# 读取配置值
openclaw config get messages.responsePrefix
openclaw config get channels.telegram.botToken
# 写入配置值
openclaw config set messages.responsePrefix="[bot]"
openclaw config set gateway.port=18789
# 删除配置项
openclaw config unset messages.responsePrefix
# 显示配置文件路径
openclaw config file
# 验证配置合法性
openclaw config validate
# 查看配置 schema
openclaw config schema
configure
见「安装 & 初始化」章节。
mcp
管理 OpenClaw 控制的 MCP(Model Context Protocol)服务器配置。
openclaw mcp list
openclaw mcp show context7
openclaw mcp set context7='{"command":"uvx","args":["context7-mcp"]}'
openclaw mcp unset context7
webhooks
Webhook 助手和集成配置。
openclaw webhooks list
openclaw webhooks add --url https://example.com/hook --event message
openclaw webhooks remove <id>
八、自动化 & 任务
cron
调度和检查 Gateway 后台任务(定时任务)。
openclaw cron list
openclaw cron add --schedule "0 9 * * *" --message "早安汇报"
openclaw cron remove <id>
openclaw cron status
tasks
检查持久后台任务和工作流状态。
openclaw tasks list
openclaw tasks list --session <sessionId>
openclaw tasks info <taskId>
hooks
管理 agent 内部 hooks(触发器)。
openclaw hooks list
openclaw hooks enable <hookName>
openclaw hooks disable <hookName>
九、执行 & 沙箱
approvals
管理 exec 执行审批(在 Gateway 或节点主机上)。
openclaw approvals list # 列出待审批项
openclaw approvals approve <id>
openclaw approvals deny <id>
openclaw approvals policy show # 查看执行策略
exec-policy
显示或同步 exec 策略与主机审批设置(approvals 的别名命令)。
openclaw exec-policy show
openclaw exec-policy sync
sandbox
管理 agent 隔离用的沙箱容器。
openclaw sandbox list
openclaw sandbox create --name my-sandbox
openclaw sandbox remove my-sandbox
openclaw sandbox status
node
运行和管理无头节点主机服务(headless node host)。
openclaw node start
openclaw node stop
openclaw node status
openclaw node logs
nodes
通过 Gateway 管理已配对的远程节点。
openclaw nodes list
openclaw nodes pair <nodeId>
openclaw nodes status
十、界面 & 交互
tui
打开终端 UI(连接到 Gateway)。别名:chat、terminal。
openclaw tui
openclaw tui --local # 本地模式,不连接 Gateway
openclaw chat # 同 tui --local
openclaw terminal # 同 tui --local
dashboard
在浏览器中打开 Control UI(包含聊天、配置、会话管理)。
openclaw dashboard
十一、安全 & 凭据
security
安全工具和本地配置审计。
openclaw security audit # 审计安全配置
secrets
审计、应用和重载 SecretRef 凭据。
openclaw secrets audit # 审计 SecretRef 配置
openclaw secrets apply # 应用凭据变更
openclaw secrets reload # 重载凭据(不重启 Gateway)
openclaw secrets configure # 交互式配置凭据
十二、网络 & 发现
dns
DNS 助手,用于广域发现(Tailscale + CoreDNS)。
openclaw dns status
openclaw dns setup
proxy
运行 OpenClaw 调试代理,检查捕获的流量(开发/调试用)。
openclaw proxy start
openclaw proxy logs
openclaw proxy stop
十三、数据管理
backup
创建和验证本地 OpenClaw 状态备份归档。
openclaw backup create
openclaw backup create --output ~/backups/openclaw-backup.tar.gz
openclaw backup verify ~/backups/openclaw-backup.tar.gz
reset
重置本地配置和状态(CLI 本身保留不卸载)。
openclaw reset
openclaw reset --scope full # 同时清除工作区
uninstall
卸载 Gateway 服务和本地数据(CLI 保留)。
openclaw uninstall
migrate
从其他 agent 系统导入状态(如 Codex)。
openclaw migrate plan codex # 预览迁移计划
openclaw migrate codex # 执行迁移
update
更新 OpenClaw 并查看更新通道状态。
openclaw update
openclaw update status
openclaw update wizard # 交互式更新向导
十四、辅助工具
docs
搜索 OpenClaw 在线文档。
openclaw docs "slash commands"
openclaw docs "gateway configuration"
sessions / transcripts
见「Agent 管理」章节。
acp
运行和管理 ACP(Agent Coordination Protocol)支持的编码 agent。
openclaw acp status
openclaw acp spawn
openclaw acp sessions
openclaw acp doctor
openclaw acp install
clawbot
旧版 clawbot 命令命名空间(兼容别名,新版推荐用 agents)。
openclaw clawbot --help
附录:命令速查表
| 分类 | 命令 | 核心用途 |
|---|---|---|
| 初始化 | onboard setup configure crestodian doctor | 安装、引导、修复 |
| Gateway | gateway health status logs daemon | 服务运行和监控 |
| Agent | agent agents sessions memory commitments transcripts | agent 生命周期管理 |
| 频道 | channels directory message pairing qr devices | 消息频道接入 |
| 模型 | models infer / capability | 模型配置和推断 |
| 技能 | skills plugins | 能力扩展 |
| 配置 | config configure mcp webhooks | 配置读写 |
| 自动化 | cron tasks hooks | 定时和后台任务 |
| 执行 | approvals exec-policy sandbox node nodes | 执行策略和沙箱 |
| 界面 | tui / chat / terminal dashboard | 终端和浏览器界面 |
| 安全 | security secrets | 凭据和审计 |
| 数据 | backup reset uninstall migrate update | 数据生命周期 |
| 工具 | docs dns proxy acp completion | 辅助功能 |
整理自 OpenClaw 官方文档,版本:2026.6.1