用了几个月 OpenClaw,踩过不少坑,也积累了一套自己的指令习惯。把常用的、容易忘的、文档里不太好找的指令整理成一份速查表,方便自己翻,也分享给同样在用 OpenClaw 的人。
指令按使用场景分组,不按字母排序。你大概率不会从头读到尾,直接跳到需要的章节就行。
系统状态 & 诊断
装好 OpenClaw 之后,第一件事是确认它活着。
# 版本和基本状态
openclaw --version
openclaw status --json
openclaw health --json
# 出问题时用 doctor 自检
openclaw doctor
openclaw doctor --fix # 自动修复已知问题
openclaw doctor --heartbeat # 单独检查心跳
# 安全审计
openclaw security audit --deep
openclaw security audit --deep --fix # 自动修复安全问题
openclaw security audit --report ~/audit.log
status --json 和 health --json 的区别:前者看整体运行状态,后者侧重服务健康度。日常用 status 就够了,排障时上 health。
Gateway 控制
Gateway 是 OpenClaw 的核心网关,所有请求经过它路由。
# 启动
openclaw gateway # 前台运行
openclaw gateway --daemon # 后台运行
openclaw gateway --port 18789 --verbose
# 状态管理
openclaw gateway status
openclaw gateway status --deep # 深度诊断
openclaw gateway restart
openclaw gateway stop
openclaw gateway install --force # 重装 gateway 服务
# RPC 调用(高级)
openclaw gateway call config.get --params '{}'
openclaw gateway call sessions.list --params '{}'
openclaw gateway call config.apply --params '{"key":"value"}'
openclaw gateway call config.patch --params '{"key":"value"}'
改完配置记得 restart。Gateway 是常驻进程,启动时加载配置并缓存,不重启不生效。
Agent 交互
跟 Agent 对话是最高频的操作。
# 基本用法
openclaw agent --message "你好"
openclaw agent -m "分析这段日志" --agent main
openclaw agent -m "测试一下" --agent main --local # 本地执行,不走远端
# 指定模型
openclaw agent -m "写个脚本" --with-model foxcode
openclaw agent -m "帮我查一下" --model cliproxy/gpt-5.3-codex
# 高级参数
openclaw agent --message "深度分析" --thinking high # 开启深度思考
openclaw agent --json --timeout 90000 # JSON 输出 + 超时控制
openclaw agent --to +1234567890 --message "通知" # 通过 WhatsApp 发送
# Agent 管理
openclaw agent create my-agent --sandbox
openclaw agent suspend <agent-id>
--local 参数很实用,调试时避免消耗远端额度。
模型管理
openclaw models list
openclaw models list --json
openclaw models status --json
openclaw models status --plain
模型注册有两道门:providers.models(注册)和 agents.defaults.models(白名单)。两个都通过了模型才能用,漏一个就会报模型不存在。
配置管理
OpenClaw 的配置项很多,config 是个万能工具。
# 读配置
openclaw config get agents.defaults.workspace
openclaw config get agents.list
openclaw config get channels
openclaw config get gateway.auth.mode
openclaw config get gateway.bind
# 写配置
openclaw config set commands.restart true --json
openclaw config set gateway.port 19001 --json
openclaw config set gateway.auth.token "your-token"
openclaw config set gateway.bind "127.0.0.1"
# 删配置
openclaw config unset tools.web.search.apiKey
# 备份
openclaw config export ~/config-backup.json
安全相关配置
openclaw config set dm.policy allowlist # DM 策略:allowlist / open / pairing / disabled
openclaw config set groups.policy allowlist
openclaw config set tools.policy allow # allow / deny
openclaw config set sandbox.enabled true
openclaw config set log.sanitize true # 日志脱敏
心跳配置
openclaw config set agents.defaults.heartbeat.every "2h"
openclaw config set agents.defaults.heartbeat.target "discord"
openclaw config set agents.defaults.heartbeat.session "agent:...:heartbeat"
openclaw config set agents.defaults.heartbeat.to "channel:..."
openclaw system heartbeat enable
openclaw system heartbeat last
Memory 配置
openclaw config set agents.defaults.memorySearch.enabled true
openclaw config set memory.encryption.enabled true
openclaw config set memory.retention.days 365
openclaw config set memory.retention.important_forever true
Cron 定时任务
# 查看
openclaw cron list
openclaw cron list --json
openclaw cron status
# 创建
openclaw cron add --name "日报" --at "2h" --session main ...
openclaw cron add --name "早报" --cron "0 7 * * *" --session isolated ...
# 编辑(delivery 三要素:mode + channel + to,缺一不可)
openclaw cron edit <job-id> --agent main --to <channel_id> --channel discord
# 手动触发
openclaw cron run <job-id> --timeout 90000
# 历史记录
openclaw cron runs --id <job-id> --limit 20
Cron 的 delivery 配置是个坑。mode、channel、to 三个字段是原子结构,cron add 不会校验完整性,少填一个运行时才报错。建议用脚本包一层前置校验。
通道 & 通讯
# 通道管理
openclaw channels list --json
openclaw channels status --probe
openclaw channels disconnect --all
openclaw channels logs --channel whatsapp
# 白名单
openclaw allowlist add @alice
openclaw allowlist add +1234567890
openclaw allowlist add group:12345678
# 配对
openclaw pairing list whatsapp
openclaw pairing approve whatsapp <code>
openclaw pairing approve discord <code>
# 发消息
openclaw message send --to +1234567890 --message "Hello"
日志
openclaw logs --follow # 实时跟踪
openclaw logs --limit 200 --plain --local-time # 最近 200 条,本地时区
排障时建议远端开三个日志开关:
# 在远端配置中设置
debug: true
logging-to-file: true
request-log: true
Memory(记忆系统)
openclaw memory search "关键词"
openclaw memory init
openclaw memory reindex --full
openclaw memory reindex --incremental
openclaw memory reindex --deep
openclaw memory cleanup --dry-run # 预览,不执行
openclaw memory cleanup # 真正清理
openclaw memory export ~/backup/memory-backup.zip
openclaw memory import ~/backup/memory-backup.zip --merge
Sessions
openclaw sessions list
openclaw sessions --json
openclaw sessions --json --active 30 # 最近 30 分钟活跃的
openclaw sessions delete sess-123
插件 & Skills
# 插件
openclaw plugins install @openclaw/mattermost
openclaw plugins enable diagnostics-otel
# Skills
openclaw skill create my-first --template=schedule
openclaw skills list
openclaw skills audit <skill-name>
# Hooks
openclaw hooks list
openclaw hooks enable self-improvement
节点 & 设备
openclaw devices list
openclaw nodes status
openclaw nodes describe --node <id>
openclaw node pair --generate
openclaw approvals get --node <id>
浏览器
openclaw browser start --browser-profile openclaw
openclaw browser profiles
openclaw browser status
其他实用指令
openclaw update # 更新到最新版
openclaw update --yes # 跳过确认
openclaw chat "Hello" # 快速对话
openclaw chat "msg" --model model-name
openclaw help # 帮助
openclaw dns setup --apply # DNS 配置
启动参数
这几个全局参数在任何子命令前都能用:
openclaw --config # 只读配置,不执行
openclaw --profile <name> # 使用指定 profile
openclaw --dev # 开发模式
openclaw --ignore-scripts # 跳过钩子脚本
踩坑备忘
记几个文档里不会写、但你一定会遇到的问题:
- Provider 注册两道门:
providers.models注册 +agents.defaults.models白名单,都过了才能用 - agent 级 models.json 没法注册新 provider,必须在全局
openclaw.json声明 - 改配置必须重启 Gateway,常驻进程启动时缓存配置
- HTTP 200 不代表成功,部分站点认证失效返回 200 + 错误 body,查日志才能发现
- Cron delivery 三件套(mode / channel / to)是原子结构,少一个运行时静默失败
- Anthropic API 类型必须用
anthropic-messages,不能用anthropic - IP 级限流:同一个 key,不同 IP 的限流阈值可能不同,本地能用不代表远端能用
如果你也在用 OpenClaw 管理自己的 AI Agent,建议把这份速查表存个书签。指令记不住不丢人,能快速查到就行。