跳到主要内容

OpenClaw 速查表

快速查阅 OpenClaw 常用命令和配置。

安装与初始化

# 安装(推荐使用 Node 24)
npm install -g openclaw@latest

# 运行 Onboarding 向导
openclaw onboard

# 高级选项
openclaw onboard --install-daemon # 同时安装为系统服务
openclaw onboard --reset # 重置配置后重新配置
openclaw onboard --non-interactive # 非交互模式
openclaw onboard --mode remote # 远程网关模式
openclaw onboard --auth-choice openai-api-key # 指定认证方式

# 初始化配置
openclaw setup

# 验证安装
openclaw --version

# 运行诊断
openclaw doctor

# 自动修复问题
openclaw doctor --fix

# 深度诊断
openclaw doctor --deep

Gateway 命令

# 前台运行
openclaw gateway

# 安装系统服务
openclaw gateway install

# 启动服务
openclaw gateway start

# 停止服务
openclaw gateway stop

# 重启服务
openclaw gateway restart

# 查看状态
openclaw gateway status

# 深度状态检查
openclaw gateway status --deep --json

# 指定端口
openclaw gateway --port 18789

# 绑定地址
openclaw gateway --bind lan # 局域网访问
openclaw gateway --bind tailnet # Tailscale 网络

# 认证配置
openclaw gateway --token YOUR_TOKEN
openclaw gateway --auth password --password YOUR_PASSWORD

# Tailscale 集成
openclaw gateway --tailscale serve # Tailscale 服务
openclaw gateway --tailscale funnel # Tailscale 公网暴露

# 详细日志
openclaw gateway --verbose

Agent 命令

# 发送消息
openclaw agent -m "你好"

# 完整参数
openclaw agent --message "分析这个项目" --thinking high

# 发送到特定目标
openclaw agent --to +15555550123 --message "状态更新" --deliver

# 指定 Agent
openclaw agent --agent ops --message "生成报告"

# 指定会话
openclaw agent --session-id 1234 --message "总结"

# 发送到特定渠道
openclaw agent --agent ops --message "报告" --deliver --reply-channel slack --reply-to "#reports"

# JSON 输出
openclaw agent -m "你好" --json

# 本地模式(不通过 Gateway)
openclaw agent -m "你好" --local

Agents 管理命令

# 列出所有 Agent
openclaw agents list

# 显示绑定信息
openclaw agents list --bindings

# 创建新 Agent
openclaw agents add work --workspace ~/.openclaw/workspace-work

# 非交互模式创建
openclaw agents add work --workspace ~/workspace-work --model anthropic/claude-sonnet-4 --non-interactive

# 查看 Agent 绑定
openclaw agents bindings --agent work

# 添加绑定
openclaw agents bind --agent work --bind telegram:personal

# 移除绑定
openclaw agents unbind --agent work --bind telegram:personal

# 删除 Agent
openclaw agents delete work --force

模型命令

# 列出可用模型
openclaw models list

# 查看模型状态
openclaw models status

# 设置默认模型
openclaw models set anthropic/claude-sonnet-4

# 配置认证
openclaw models auth login --provider anthropic

# 查看使用量
openclaw status --usage

渠道命令

# 列出渠道
openclaw channels list

# 显示使用量
openclaw channels list --usage

# 添加渠道(交互式)
openclaw channels add --channel telegram

# 非交互式添加
openclaw channels add --channel telegram --token YOUR_BOT_TOKEN --account personal

# 查看渠道状态
openclaw channels status

# 深度检查
openclaw channels status --probe

# 查看渠道日志
openclaw channels logs --channel telegram
openclaw channels logs --channel all --lines 500

# 登录渠道(WhatsApp)
openclaw channels login --channel whatsapp

# 登出渠道
openclaw channels logout --channel whatsapp

# 测试渠道
openclaw channels test telegram --message "测试消息"

# 启用/禁用渠道
openclaw channels enable telegram
openclaw channels disable telegram

# 移除渠道(保留配置)
openclaw channels remove telegram

# 完全删除渠道配置
openclaw channels remove telegram --delete

插件命令

# 列出插件
openclaw plugins list

# 查看插件详情
openclaw plugins inspect feishu

# 安装插件
openclaw plugins install @openclaw/plugin-feishu
openclaw plugins install @openclaw/plugin-wechat
openclaw plugins install @openclaw/plugin-matrix

# 启用/禁用插件
openclaw plugins enable feishu
openclaw plugins disable feishu

# 插件诊断
openclaw plugins doctor

技能命令

# 搜索技能
openclaw skills search weather

# 安装技能(安装到 workspace/skills/)
openclaw skills install skill-name

# 安装特定版本
openclaw skills install skill-name --version 1.2.0

# 强制覆盖安装
openclaw skills install skill-name --force

# 列出已安装技能
openclaw skills list

# 只显示就绪的技能
openclaw skills list --eligible

# 查看详情
openclaw skills info skill-name

# 更新技能
openclaw skills update skill-name
openclaw skills update --all

# 更新到特定版本
openclaw skills update skill-name --version 1.3.0

# 检查就绪状态
openclaw skills check

ClawHub CLI(独立安装)

# 安装 ClawHub CLI
npm install -g clawhub
# 或
bun install -g clawhub

# 登录
clawhub login
clawhub login --token YOUR_TOKEN

# 发布技能
clawhub skill publish ./my-skill \
--slug my-skill \
--name "My Skill" \
--version 1.0.0

# 同步多个技能
clawhub sync

# 删除/恢复技能
clawhub delete my-skill --yes
clawhub undelete my-skill --yes

Cron 命令

# 列出定时任务
openclaw cron list

# 添加定时任务
openclaw cron add --name daily-report --at "0 9 * * *" --message "任务描述"

# 使用间隔
openclaw cron add --name hourly --every "1h" --message "检查状态"

# 启用/禁用任务
openclaw cron enable task-name
openclaw cron disable task-name

# 手动执行
openclaw cron run task-name

# 删除任务
openclaw cron rm task-name

# 查看执行历史
openclaw cron runs --id task-name

# 查看下次执行时间
openclaw cron next task-name

记忆命令

# 查看索引状态
openclaw memory status

# 重新索引
openclaw memory index

# 搜索记忆
openclaw memory search "查询内容"

浏览器命令

# 查看状态
openclaw browser status

# 启动/停止
openclaw browser start
openclaw browser stop

# 配置文件管理
openclaw browser profiles
openclaw browser create-profile --name work --color "#2196F3"
openclaw browser delete-profile work
openclaw browser reset-profile

# 标签页操作
openclaw browser tabs
openclaw browser tab
openclaw browser tab new
openclaw browser tab select 2
openclaw browser tab close 2
openclaw browser open https://example.com
openclaw browser focus abcd1234
openclaw browser close abcd1234

# 截图和快照
openclaw browser screenshot
openclaw browser screenshot --full-page
openclaw browser screenshot --ref 12
openclaw browser screenshot --ref e12
openclaw browser snapshot
openclaw browser snapshot --format aria --limit 200
openclaw browser snapshot --interactive --compact --depth 6
openclaw browser snapshot --efficient
openclaw browser snapshot --labels
openclaw browser snapshot --selector "#main" --interactive
openclaw browser snapshot --frame "iframe#main" --interactive
openclaw browser console --level error
openclaw browser errors --clear
openclaw browser requests --filter api --clear
openclaw browser pdf
openclaw browser responsebody "**/api" --max-chars 5000

# 页面操作
openclaw browser navigate https://example.com
openclaw browser resize 1280 720
openclaw browser click 12 --double
openclaw browser click e12 --double
openclaw browser type 23 "hello" --submit
openclaw browser press Enter
openclaw browser hover 44
openclaw browser scrollintoview e12
openclaw browser drag 10 11
openclaw browser select 9 OptionA OptionB
openclaw browser download e12 report.pdf
openclaw browser waitfordownload report.pdf
openclaw browser upload /tmp/openclaw/uploads/file.pdf
openclaw browser fill --fields '[{"ref":"1","type":"text","value":"Ada"}]'
openclaw browser dialog --accept

# 等待操作
openclaw browser wait --text "Done"
openclaw browser wait "#main" --url "**/dash" --load networkidle --fn "window.ready===true"

# 调试工具
openclaw browser evaluate --fn '(el) => el.textContent' --ref 7
openclaw browser highlight e12
openclaw browser trace start
openclaw browser trace stop

# 状态管理
openclaw browser cookies
openclaw browser cookies set session abc123 --url "https://example.com"
openclaw browser cookies clear
openclaw browser storage local get
openclaw browser storage local set theme dark
openclaw browser storage session clear
openclaw browser set offline on
openclaw browser set headers --headers-json '{"X-Debug":"1"}'
openclaw browser set credentials user pass
openclaw browser set credentials --clear
openclaw browser set geo 37.7749 -122.4194 --origin "https://example.com"
openclaw browser set geo --clear
openclaw browser set media dark
openclaw browser set timezone America/New_York
openclaw browser set locale en-US
openclaw browser set device "iPhone 14"

# 安装 Playwright
openclaw browser install-playwright

配置命令

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

# 设置配置值
openclaw config set agents.defaults.model.primary "anthropic/claude-sonnet-4"

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

# 验证配置
openclaw config validate

# 查看配置 Schema
openclaw config schema

诊断命令

# 查看状态
openclaw status

# 深度检查
openclaw status --deep

# 健康检查
openclaw health

# 查看日志
openclaw logs

# 实时日志
openclaw logs --follow

# 过滤日志
openclaw logs --grep "error"
openclaw logs --level debug

# 运行诊断
openclaw doctor

# 自动修复
openclaw doctor --fix

状态与诊断

# 查看状态
openclaw status

# 深度检查
openclaw status --deep

# 健康检查
openclaw health

# 查看日志
openclaw logs

# 实时日志
openclaw logs --follow

# 过滤日志
openclaw logs --grep "error"
openclaw logs --level debug

# 运行诊断
openclaw doctor

# 自动修复
openclaw doctor --fix

Cron 表达式速查

表达式含义
* * * * *每分钟
*/5 * * * *每 5 分钟
*/30 * * * *每 30 分钟
0 * * * *每小时整点
0 9 * * *每天早上 9:00
0 18 * * *每天下午 18:00
0 9 * * 1-5周一到周五早上 9:00
0 9 * * 1每周一早上 9:00
0 9 1 * *每月 1 号早上 9:00
0 0 * * 0每周日午夜

配置文件位置

文件路径说明
主配置~/.openclaw/openclaw.json全局配置
工作空间~/.openclaw/workspace/Agent 工作目录
Agent 状态~/.openclaw/agents/各 Agent 状态
凭证~/.openclaw/credentials/渠道认证信息
技能~/.openclaw/skills/托管技能
记忆索引~/.openclaw/memory/{agentId}.sqlite搜索索引

工作空间文件

文件说明
AGENTS.md操作指令 + 记忆
SOUL.md人格定义
MEMORY.md向量搜索记忆
TOOLS.md工具使用约定
USER.md用户档案
IDENTITY.mdAgent 身份
HEARTBEAT.md心跳上下文
memory/YYYY-MM-DD.md日期记忆

环境变量

变量说明
ANTHROPIC_API_KEYClaude API Key
OPENAI_API_KEYOpenAI API Key
GEMINI_API_KEYGoogle Gemini API Key
VOYAGE_API_KEYVoyage API Key
MISTRAL_API_KEYMistral API Key
OPENCLAW_GATEWAY_TOKENGateway 访问 Token
OPENCLAW_GATEWAY_PORTGateway 端口
OPENCLAW_CONFIG_PATH自定义配置文件路径
OPENCLAW_STATE_DIR自定义状态目录

常用端口

端口服务
18789Gateway WebSocket / Control UI
18791Browser control (Gateway + 2)
9090Prometheus 指标(如果启用)

模型别名

别名模型
opusanthropic/claude-opus-4-6
sonnetanthropic/claude-sonnet-4-6
gptopenai/gpt-5.2
geminigoogle/gemini-2.5-pro

说明:模型别名在 agents.defaults.models 中配置。使用时可以直接输入别名或完整的 provider/model 格式。如果模型 ID 本身包含 /(如 OpenRouter 风格),必须包含提供商前缀,例如 openrouter/moonshotai/kimi-k2

最小配置示例

~/.openclaw/openclaw.json

{
"agent": {
"workspace": "~/.openclaw/workspace"
},
"channels": {
"whatsapp": {
"allowFrom": ["+15555550123"]
}
}
}

推荐基础配置

{
"identity": {
"name": "Clawd",
"theme": "helpful assistant",
"emoji": "🦞"
},
"agent": {
"workspace": "~/.openclaw/workspace",
"model": {
"primary": "anthropic/claude-sonnet-4-6"
}
},
"channels": {
"whatsapp": {
"allowFrom": ["+15555550123"],
"groups": {
"*": { "requireMention": true }
}
}
}
}

渠道配置示例

Telegram

{
"channels": {
"telegram": {
"enabled": true,
"accounts": {
"default": {
"botToken": "YOUR_BOT_TOKEN"
}
}
}
}
}

Discord

{
"channels": {
"discord": {
"enabled": true,
"accounts": {
"default": {
"token": "YOUR_BOT_TOKEN"
}
}
}
}
}

Slack

{
"channels": {
"slack": {
"enabled": true,
"accounts": {
"default": {
"botToken": "xoxb-YOUR-BOT-TOKEN",
"appToken": "xapp-YOUR-APP-TOKEN"
}
}
}
}
}

WhatsApp

{
"channels": {
"whatsapp": {
"enabled": true,
"dmPolicy": "pairing",
"allowFrom": []
}
}
}

多 Agent 配置示例

{
"agents": {
"list": [
{
"id": "main",
"default": true
},
{
"id": "work",
"workspace": "~/.openclaw/workspace-work",
"model": {
"primary": "anthropic/claude-opus-4-6"
}
}
]
},
"bindings": [
{
"channel": "telegram",
"accountId": "personal",
"agentId": "main"
},
{
"channel": "slack",
"agentId": "work"
}
]
}

记忆后端配置

内置引擎(默认)

{
"agents": {
"defaults": {
"memorySearch": {
"provider": "openai",
"model": "text-embedding-3-small"
}
}
}
}

QMD 后端

{
"memory": {
"backend": "qmd",
"qmd": {
"includeDefaultMemory": true,
"paths": [
{ "name": "docs", "path": "~/notes" }
],
"sessions": {
"enabled": true
}
}
}
}

常见问题快速解决

服务无法启动

# 检查端口占用
lsof -i :18789

# 运行诊断
openclaw doctor

# 查看日志
openclaw logs --limit 100

模型调用失败

# 检查模型状态
openclaw models status --probe

# 检查 API Key
openclaw models status

# 测试连接
openclaw agent -m "测试"

Node.js 版本问题

# 使用 nvm 安装 Node 24
nvm install 24
nvm use 24
nvm alias default 24

# 验证版本
node --version

权限问题

# 修复权限
sudo chown -R $(whoami) ~/.openclaw

配置验证失败

# 验证配置
openclaw config validate

# 自动修复
openclaw doctor --fix

QMD 搜索超时

{
"memory": {
"qmd": {
"limits": {
"timeoutMs": 120000
}
}
}
}

参考链接