OpenClaw 常用命令手册 🦞

版本:2026.3.8 | 整理时间:2026-04-04


📌 全局选项

openclaw --dev              # 开发模式,隔离状态到 ~/.openclaw-dev
openclaw --profile <name>   # 使用命名配置文件
openclaw --no-color         # 禁用颜色输出
openclaw -V, --version      # 显示版本号
openclaw -h, --help         # 显示帮助

🚀 入门命令

安装和初始化

# 安装 OpenClaw
npm install -g openclaw@latest

# 交互式引导(推荐首次使用)
openclaw onboard

# 引导并安装守护进程
openclaw onboard --install-daemon

# 初始化配置和工作区
openclaw setup

# 交互式配置向导
openclaw configure

快速检查

# 查看状态
openclaw status

# 深度检查(包含通道探测)
openclaw status --deep

# 健康检查
openclaw doctor

# 查看日志
openclaw logs --follow

🦮 Gateway(网关)管理

运行网关

# 启动网关(默认端口 18789)
openclaw gateway

# 指定端口
openclaw gateway --port 18789

# 强制启动(杀死占用端口的进程)
openclaw gateway --force

# 开发模式
openclaw --dev gateway

网关服务管理

# 查看服务状态
openclaw gateway status

# 安装为系统服务
openclaw gateway install

# 卸载服务
openclaw gateway uninstall

# 启动/停止/重启服务
openclaw gateway start
openclaw gateway stop
openclaw gateway restart

网关高级操作

# 健康检查
openclaw gateway health

# 探测网关
openclaw gateway probe

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

# 发现网关
openclaw gateway discover

💬 通道管理(Channels)

通道基本操作

# 列出所有通道
openclaw channels list

# 查看通道状态
openclaw channels status

# 深度探测通道
openclaw channels status --probe

# 查看通道日志
openclaw channels logs --lines 200

添加/移除通道

# 添加通道(交互式)
openclaw channels add

# 添加 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

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

WhatsApp 登录

# WhatsApp Web 登录(显示二维码)
openclaw channels login

# 显示详细日志
openclaw channels login --verbose

# 登出
openclaw channels logout

🤖 Agent(代理)管理

Agent 基本操作

# 列出所有 Agent
openclaw agents list

# 显示绑定关系
openclaw agents list --bindings

# 添加新 Agent(交互式向导)
openclaw agents add

# 添加 Agent(非交互式)
openclaw agents add my-agent --workspace /path/to/workspace --model qwen-portal/coder-model

# 删除 Agent
openclaw agents delete <agent-id> --force

Agent 绑定

# 查看绑定
openclaw agents bindings

# 添加绑定
openclaw agents bind --agent <agent-id> --bind whatsapp --bind telegram

# 移除绑定
openclaw agents unbind --agent <agent-id> --bind whatsapp

# 移除所有绑定
openclaw agents unbind --agent <agent-id> --all

运行 Agent

# 运行一次 Agent 调用
openclaw agent --message "你好" --deliver

# 发送到指定目标
openclaw agent --to +15555550123 --message "运行摘要" --deliver

# 指定思考级别(仅支持部分模型)
openclaw agent --message "分析这个代码" --thinking high

📩 消息管理

发送消息

# 发送消息
openclaw message send --target +15555550123 --message "你好"

# 通过指定通道发送
openclaw message send --channel telegram --target @mychat --message "Hi"

# JSON 输出
openclaw message send --target +15555550123 --message "Hi" --json

消息操作

# 投票
openclaw message poll --channel discord --target channel:123 \
  --poll-question "零食?" --poll-option Pizza --poll-option Sushi

# 反应(emoji)
openclaw message react --target <message-id> --emoji 👍

# 查看反应
openclaw message reactions --target <message-id>

# 标记已读
openclaw message read --target <message-id>

# 编辑消息
openclaw message edit --target <message-id> --message "新内容"

# 删除消息
openclaw message delete --target <message-id>

# 置顶/取消置顶
openclaw message pin --target <message-id>
openclaw message unpin --target <message-id>

# 查看置顶消息
openclaw message pins

线程管理

# 创建线程
openclaw message thread create --channel discord --target channel:123 --message "新话题"

# 列出线程
openclaw message thread list --channel discord --target channel:123

# 回复线程
openclaw message thread reply --thread-id <id> --message "回复内容"

🧠 记忆系统(Memory)

# 查看记忆状态
openclaw memory status

# 重新索引记忆文件
openclaw memory index

# 搜索记忆
openclaw memory search "上周讨论的 Java 项目"

📅 定时任务(Cron)

# 查看定时任务状态
openclaw cron status

# 列出所有任务
openclaw cron list
openclaw cron list --all  # 包含禁用的任务

# 添加任务
openclaw cron add --name "日报提醒" --cron "0 9 * * *" --message "该写日报了"

# 编辑任务
openclaw cron edit <job-id> --name "新名字"

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

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

# 立即运行任务
openclaw cron run <job-id>
openclaw cron run <job-id> --force  # 强制运行

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

🔧 配置管理

Config 命令

# 查看配置值
openclaw config get agents.defaults.model

# 设置配置值
openclaw config set agents.defaults.model qwen-portal/coder-model

# 删除配置值
openclaw config unset agents.defaults.model

# 查看配置文件路径
openclaw config file

# 验证配置
openclaw config validate
openclaw config validate --json

模型管理

# 查看模型状态
openclaw models
openclaw models status

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

# 设置默认模型
openclaw models set qwen-portal/coder-model

# 设置图像模型
openclaw models set-image qwen-portal/image-model

# 模型别名
openclaw models aliases list
openclaw models aliases add qwen qwen-portal/coder-model
openclaw models aliases remove qwen

# 模型回退
openclaw models fallbacks list
openclaw models fallbacks add backup-model
openclaw models fallbacks remove backup-model
openclaw models fallbacks clear

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

# 认证管理
openclaw models auth add
openclaw models auth setup-token --provider anthropic
openclaw models auth order get

Secrets 管理

# 重新加载 secrets
openclaw secrets reload

# 审计 secrets
openclaw secrets audit

# 交互式配置
openclaw secrets configure

# 应用计划
openclaw secrets apply --from plan.json

📊 会话管理(Sessions)

# 列出会话
openclaw sessions

# 详细输出
openclaw sessions --verbose

# JSON 输出
openclaw sessions --json

# 只显示活跃会话(最近 30 分钟)
openclaw sessions --active 30

🌐 节点管理(Nodes)

节点主机

# 运行节点主机
openclaw node run --host <gateway-host> --port 18789

# 查看节点状态
openclaw node status

# 安装节点服务
openclaw node install

# 卸载节点服务
openclaw node uninstall

# 启动/停止/重启
openclaw node start
openclaw node stop
openclaw node restart

节点控制

# 列出节点
openclaw nodes list

# 查看节点状态
openclaw nodes status

# 查看节点详情
openclaw nodes describe --node <node-id>

# 重命名节点
openclaw nodes rename --node <node-id> --name "新名字"

# 批准待处理节点
openclaw nodes pending
openclaw nodes approve <requestId>
openclaw nodes reject <requestId>

# 调用节点命令
openclaw nodes invoke --node <node-id> --command system.info

# 在节点上运行命令
openclaw nodes run --node <node-id> --cwd /path --env KEY=VAL ls -la

摄像头和屏幕

# 列出摄像头
openclaw nodes camera list --node <node-id>

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

# 录制视频
openclaw nodes camera clip --node <node-id> --duration 10s

# 屏幕截图
openclaw nodes canvas snapshot --node <node-id>

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

🌍 浏览器控制(Browser)

# 查看浏览器状态
openclaw browser status

# 启动浏览器
openclaw browser start

# 停止浏览器
openclaw browser stop

# 重置配置文件
openclaw browser reset-profile

# 打开网页
openclaw browser open https://example.com

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

# 截图
openclaw browser screenshot --full-page

# 快照
openclaw browser snapshot --format aria

# 点击
openclaw browser click <ref>

# 输入
openclaw browser type <ref> "要输入的文本"

# 调整大小
openclaw browser resize 1920 1080

# 配置文件管理
openclaw browser profiles
openclaw browser create-profile --name work
openclaw browser delete-profile --name work

🔒 安全管理

# 安全审计
openclaw security audit

# 深度审计
openclaw security audit --deep

# 自动修复
openclaw security audit --fix

📦 插件管理

# 列出插件
openclaw plugins list

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

# 安装插件
openclaw plugins install <path|.tgz|npm-spec>

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

# 诊断插件问题
openclaw plugins doctor

🛠️ 系统维护

更新和重置

# 更新 OpenClaw
openclaw update

# 重置配置(保留 CLI)
openclaw reset

# 重置范围选择
openclaw reset --scope config+creds+sessions --yes

# 完全卸载(保留 CLI)
openclaw uninstall --all --yes

# 生成 Shell 补全
openclaw completion

备份

# 创建备份
openclaw backup create

# 验证备份
openclaw backup verify

日志

# 跟踪日志
openclaw logs --follow

# 限制行数
openclaw logs --limit 200

# 纯文本输出
openclaw logs --plain

# JSON 输出
openclaw logs --json

🎯 其他实用命令

设备配对

# 列出设备
openclaw devices list

# 批准设备
openclaw devices approve --latest

# 移除设备
openclaw devices remove <device-id>

# 清除所有设备
openclaw devices clear --yes

配对请求

# 列出配对请求
openclaw pairing list

# 批准配对
openclaw pairing approve <channel> <code> --notify

二维码

# 生成配对二维码
openclaw qr

系统事件

# 发送系统事件
openclaw system event --text "提醒:开会了" --mode now

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

# 查看在线状态
openclaw system presence

DNS 设置

# 设置 DNS(CoreDNS + Tailscale)
openclaw dns setup --apply

文档搜索

# 搜索文档
openclaw docs <搜索词>

TUI(终端界面)

# 打开终端 UI
openclaw tui

Dashboard

# 打开控制面板
openclaw dashboard

📋 常用场景示例

场景 1:首次设置

# 1. 安装
npm install -g openclaw@latest

# 2. 引导
openclaw onboard --install-daemon

# 3. 登录 WhatsApp
openclaw channels login

# 4. 启动网关
openclaw gateway

# 5. 打开控制面板
openclaw dashboard

场景 2:添加新通道

# 添加 Telegram Bot
openclaw channels add --channel telegram --account mybot --name "我的机器人" --token $TELEGRAM_TOKEN

# 验证状态
openclaw channels status --probe

场景 3:创建定时提醒

# 每天早上 9 点提醒写日报
openclaw cron add --name "日报提醒" --cron "0 9 * * *" \
  --message "🟡 老黄,该写日报了!"

场景 4:排查问题

# 1. 查看状态
openclaw status --deep

# 2. 健康检查
openclaw doctor

# 3. 查看日志
openclaw logs --follow --limit 500

# 4. 安全审计
openclaw security audit

场景 5:管理多个 Agent

# 创建开发 Agent
openclaw agents add dev-agent --workspace ~/projects/dev --model qwen-portal/coder-model

# 创建写作 Agent
openclaw agents add writer-agent --workspace ~/projects/writing --model qwen-portal/writer-model

# 绑定不同通道
openclaw agents bind --agent dev-agent --bind whatsapp
openclaw agents bind --agent writer-agent --bind telegram

# 查看绑定
openclaw agents bindings

🔗 相关资源

  • 官方文档: https://docs.openclaw.ai
  • GitHub: https://github.com/openclaw/openclaw
  • 社区: https://discord.com/invite/clawd
  • 技能市场: https://clawhub.com

Logo

Agent 垂直技术社区,欢迎活跃、内容共建。

更多推荐