CLI 常用命令速查
本文档是 openclaw(中文社区版)和 openclaw(官方版)CLI 的常用命令速查表。两者命令结构完全一致,仅二进制名不同。
INFO
以下示例统一使用 openclaw。如果你使用官方版,将 openclaw 替换为 openclaw 即可。
安装与初始化
bash
# npm 全局安装
sudo npm i -g openclaw
# 安装指定版本/通道
sudo npm i -g openclaw@latest # 稳定版
sudo npm i -g openclaw@beta # 内测版
# 交互式引导(首次使用推荐)
openclaw onboard
# 快速引导(最少交互)
openclaw onboard --flow quickstart
# 非交互式引导(脚本/自动化)
openclaw onboard --non-interactive --auth-choice token --token-provider anthropic --token "$TOKEN"配置管理
bash
# 交互式配置向导
openclaw configure
# 读取配置
openclaw config get agents.defaults.model.primary
openclaw config get gateway.port
# 设置配置
openclaw config set agents.defaults.model.primary "volcengine-coding-plan/doubao-seed-2.0-code"
openclaw config set gateway.port 19001 --json
openclaw config set channels.whatsapp.groups '["*"]' --json
# 删除配置
openclaw config unset tools.web.search.apiKey网关 (Gateway)
bash
# 前台运行网关
openclaw gateway run --bind loopback --port 18789
# 强制运行(杀掉已有监听)
openclaw gateway run --bind loopback --port 18789 --force
# 后台运行(生产环境)
nohup openclaw gateway run --bind loopback --port 18789 --force > /tmp/clawdbot-gateway.log 2>&1 &
# 安装为系统服务(launchd/systemd)
openclaw gateway install
openclaw gateway install --port 18789 --runtime node
# 服务管理
openclaw gateway start
openclaw gateway stop
openclaw gateway restart
openclaw gateway uninstall
# 网关状态与健康检查
openclaw gateway status
openclaw gateway status --deep
openclaw gateway health
openclaw gateway probe
# 查看网关日志
openclaw logs --follow
openclaw logs --limit 200 --json
# 发现局域网/Tailnet 网关
openclaw gateway discover
# 低级 RPC 调用
openclaw gateway call status
openclaw gateway call config.get
openclaw gateway call logs.tail --params '{"sinceMs": 60000}'模型管理
bash
# 查看模型状态(默认模型 + 认证概览)
openclaw models status
openclaw models status --probe # 在线探测认证状态(会消耗 token)
# 列出可用模型
openclaw models list
openclaw models list --provider volcengine-coding-plan
# 设置默认模型
openclaw models set volcengine-coding-plan/doubao-seed-2.0-code
openclaw models set-image openai/gpt-4o # 设置图像模型
# 模型别名
openclaw models aliases list
openclaw models aliases add fast volcengine-coding-plan/doubao-seed-2.0-code
# 模型回退
openclaw models fallbacks list
openclaw models fallbacks add openrouter/moonshotai/kimi-k2
# 认证管理
openclaw models auth add # 交互式添加
openclaw models auth setup-token # Claude Code token
openclaw models auth paste-token # 粘贴 token
# 扫描可用模型(自动探测)
openclaw models scan
openclaw models scan --provider openrouter --set-default渠道管理
bash
# 列出已配置渠道
openclaw channels list
openclaw channels list --json
# 渠道状态检查
openclaw channels status
openclaw channels status --probe # 深度探测
# 添加渠道
openclaw channels add # 交互式
openclaw channels add --channel telegram --token "$TELEGRAM_BOT_TOKEN"
openclaw channels add --channel discord --token "$DISCORD_BOT_TOKEN"
openclaw channels add --channel slack --token "$SLACK_BOT_TOKEN" --app-token "$SLACK_APP_TOKEN"
# 移除渠道
openclaw channels remove --channel telegram
openclaw channels remove --channel discord --delete # 同时删除配置
# WhatsApp 登录/登出
openclaw channels login --channel whatsapp
openclaw channels logout --channel whatsapp
# 渠道日志
openclaw channels logs --channel all
openclaw channels logs --channel telegram --lines 100
# 渠道能力探测
openclaw channels capabilities
openclaw channels capabilities --channel discord --target channel:123456代理 (Agent)
bash
# 列出代理
openclaw agents list
openclaw agents list --json --bindings
# 添加代理
openclaw agents add work --workspace ~/clawd-work
openclaw agents add work --workspace ~/clawd-work --model volcengine-coding-plan/glm-4.7
# 删除代理
openclaw agents delete work
# 设置代理身份
openclaw agents set-identity --agent main --name "Clawd" --emoji "🦞"
openclaw agents set-identity --workspace ~/clawd --from-identity
# 单次代理调用
openclaw agent --message "你好" --local
openclaw agent --message "帮我写个脚本" --to "+15555550123" --deliver消息发送
bash
# 发送文本消息
openclaw message send --channel telegram --target "123456789" --message "你好"
openclaw message send --channel discord --target "channel:123" --message "Hello"
openclaw message send --channel whatsapp --target "+15555550123" --message "Hi"
# 发送媒体
openclaw message send --channel telegram --target "123456789" --media ./photo.jpg
# 投票
openclaw message poll --channel discord --target "channel:123" --poll-question "午饭吃什么?" --poll-option "披萨" --poll-option "寿司"
# 表情回应
openclaw message react --channel discord --target "channel:123" --message-id "456" --emoji "👍"
# 搜索消息
openclaw message search --channel slack --target "channel:C123" --query "部署"状态与诊断
bash
# 综合状态
openclaw status
openclaw status --all # 完整诊断(可粘贴分享)
openclaw status --deep # 深度探测渠道
openclaw status --usage # 显示模型用量
# 健康检查
openclaw health
openclaw health --json
# 诊断修复
openclaw doctor
openclaw doctor --deep # 深度扫描
openclaw doctor --repair # 自动修复
# 安全审计
openclaw security audit
openclaw security audit --deep # 在线 Gateway 探测
openclaw security audit --fix # 自动加固插件管理
bash
# 列出插件
openclaw plugins list
openclaw plugins info <plugin-id>
# 安装插件
openclaw plugins install <path-or-npm-spec>
openclaw plugins install -l ./my-plugin # 链接本地目录
# 启用/禁用
openclaw plugins enable <plugin-id>
openclaw plugins disable <plugin-id>
# 更新插件
openclaw plugins update <plugin-id>
openclaw plugins update --all
# 插件诊断
openclaw plugins doctorHooks (事件钩子)
bash
# 列出所有钩子
openclaw hooks list
openclaw hooks list --eligible # 仅显示可用钩子
# 查看钩子详情
openclaw hooks info session-memory
# 启用/禁用内置钩子
openclaw hooks enable session-memory # 会话记忆(/new 时自动保存)
openclaw hooks enable boot-md # 启动时执行 BOOT.md
openclaw hooks enable command-logger # 命令审计日志
openclaw hooks disable command-logger
# 安装外部钩子
openclaw hooks install ./my-hook-pack
openclaw hooks update --all定时任务 (Cron)
bash
# 查看状态和任务列表
openclaw cron status
openclaw cron list
# 添加定时任务
openclaw cron add --name "日报" --every 24h --system-event "生成今日工作日报"
openclaw cron add --name "提醒" --at "2026-03-03T09:00:00" --message "开会提醒"
openclaw cron add --name "周报" --cron "0 9 * * 1" --system-event "生成本周周报" --announce --channel telegram --to "123456789"
# 管理任务
openclaw cron enable <job-id>
openclaw cron disable <job-id>
openclaw cron edit <job-id> --every 12h
openclaw cron rm <job-id>
# 手动触发
openclaw cron run <job-id>
openclaw cron runs --id <job-id> # 查看运行历史语义记忆 (Memory)
bash
# 记忆状态
openclaw memory status
openclaw memory status --deep # 探测向量 + embedding 可用性
# 索引
openclaw memory index
openclaw memory index --agent main --verbose
# 搜索
openclaw memory search "发布流程"会话管理
bash
# 列出会话
openclaw sessions
openclaw sessions --json --verbose技能 (Skills)
bash
# 列出技能
openclaw skills list
openclaw skills list --eligible # 仅显示可用技能
openclaw skills info <skill-name>
openclaw skills check # 就绪摘要沙盒 (Sandbox)
bash
# 查看沙盒容器
openclaw sandbox list
openclaw sandbox list --json
# 查看沙盒策略
openclaw sandbox explain
openclaw sandbox explain --agent work
# 重建沙盒容器
openclaw sandbox recreate --all
openclaw sandbox recreate --agent work浏览器控制
bash
# 启动/停止
openclaw browser start
openclaw browser stop
openclaw browser status
# 标签页管理
openclaw browser tabs
openclaw browser open https://example.com
openclaw browser close
# 截图与快照
openclaw browser screenshot --full-page
openclaw browser snapshot --format ai
# 页面操作
openclaw browser navigate https://example.com
openclaw browser click <ref>
openclaw browser type <ref> "Hello"
openclaw browser press Enter远程节点 (Nodes)
bash
# 查看节点
openclaw nodes status
openclaw nodes list --connected
# 审批节点
openclaw nodes pending
openclaw nodes approve <requestId>
# 远程执行
openclaw nodes run --node <id> -- ls -la
openclaw nodes invoke --node <id> --command status
# 远程摄像头
openclaw nodes camera snap --node <id>
openclaw nodes camera clip --node <id> --duration 10s更新与重置
bash
# 更新
openclaw update
openclaw update --channel beta
openclaw update --channel dev
openclaw update status
# 重置(保留 CLI)
openclaw reset --scope config
openclaw reset --scope full --yes
# 卸载
openclaw uninstall --all --yes其他工具
bash
# 控制面板(Web UI)
openclaw dashboard
# 终端 UI
openclaw tui
openclaw tui --session agent:main:main
# ACP 桥接(IDE 连接)
openclaw acp
# 文档搜索
openclaw docs "如何配置 Telegram"
# DM 配对
openclaw pairing list whatsapp
openclaw pairing approve whatsapp <code>
# DNS 发现
openclaw dns setup --apply全局选项
所有命令均支持以下全局选项:
| 选项 | 说明 |
|---|---|
--dev | 开发模式,状态隔离到 ~/.openclaw-dev |
--profile \<name\> | 使用命名配置文件,隔离到 ~/.openclaw-\<name\> |
--no-color | 禁用 ANSI 颜色 |
--json | 机器可读 JSON 输出(大部分命令支持) |
-V / --version | 显示版本号 |
配置文件路径
| 项目 | 路径 |
|---|---|
| 配置文件 | ~/.openclaw/openclaw.json |
| 凭证目录 | ~/.openclaw/credentials/ |
| 会话目录 | ~/.openclaw/sessions/ |
| 默认工作区 | ~/clawd |
| 网关日志 | /tmp/clawdbot-gateway.log(手动运行时) |
常见运维操作速查
bash
# 完整健康检查流程
openclaw doctor && openclaw status --deep && openclaw models status --probe
# 重启网关(生产环境)
pkill -9 -f clawdbot-gateway || true
nohup openclaw gateway run --bind loopback --port 18789 --force > /tmp/clawdbot-gateway.log 2>&1 &
# 验证网关运行
openclaw channels status --probe
ss -ltnp | grep 18789
tail -n 120 /tmp/clawdbot-gateway.log
# 全新安装一键流程
sudo npm i -g openclaw && openclaw onboard