CLI 参考

CLI 参考

OpenClaw 命令行界面所有命令的完整参考。

全局标志

这些标志适用于所有命令:

  • --dev - 开发模式,启用详细日志
  • --profile <名称> - 使用特定配置文件
  • --json - 以 JSON 格式输出
  • --no-color - 禁用彩色输出
  • --help - 显示任何命令的帮助

设置与初始化

openclaw onboard

首次配置的交互式设置向导。

openclaw onboard [选项]

选项:

  • --install-daemon - 将网关安装为系统服务(launchd/systemd)
  • --skip-channels - 跳过渠道配置
  • --skip-skills - 跳过技能安装

示例:

openclaw onboard --install-daemon

openclaw setup

具有更多控制的替代设置命令。

openclaw setup [选项]

网关管理

openclaw gateway

启动网关控制平面。

openclaw gateway [选项]

选项:

  • --port <数字> - WebSocket 端口(默认:18789)
  • --host <地址> - 绑定地址(默认:127.0.0.1)
  • --verbose - 启用详细日志
  • --daemon - 作为后台守护进程运行
  • --no-watch - 禁用配置热重载

示例:

# 启动网关并启用详细日志
openclaw gateway --verbose

# 在自定义端口上启动
openclaw gateway --port 18790

# 作为守护进程运行
openclaw gateway --daemon

openclaw gateway status

检查网关状态。

openclaw gateway status

openclaw gateway stop

停止网关守护进程。

openclaw gateway stop

openclaw gateway restart

重启网关守护进程。

openclaw gateway restart

代理交互

openclaw agent

执行单个代理回合。

openclaw agent [选项]

选项:

  • --message <文本> - 要发送的消息
  • --thinking <级别> - 思考级别(off|minimal|low|medium|high|xhigh)
  • --model <名称> - 覆盖模型
  • --workspace <路径> - 使用特定工作区
  • --session <ID> - 继续特定会话

示例:

# 简单查询
openclaw agent --message "天气怎么样?"

# 复杂任务使用高思考级别
openclaw agent --message "设计一个分布式系统" --thinking xhigh

# 使用特定模型
openclaw agent --message "你好" --model "anthropic/claude-opus-4-6"

openclaw chat

启动交互式聊天会话。

openclaw chat [选项]

选项:

  • --workspace <路径> - 使用特定工作区
  • --session <ID> - 恢复会话

示例:

openclaw chat

openclaw agents

管理隔离的代理实例。

openclaw agents list
openclaw agents create <名称>
openclaw agents delete <名称>

消息发送

openclaw message send

通过渠道发送消息。

openclaw message send [选项]

选项:

  • --channel <类型> - 渠道类型(whatsapp|telegram|slack|discord)
  • --to <接收者> - 接收者(电话/用户名/频道)
  • --message <文本> - 消息内容
  • --file <路径> - 附加文件

示例:

# 发送 WhatsApp 消息
openclaw message send --channel whatsapp --to "+1234567890" --message "你好"

# 发送到 Slack 频道
openclaw message send --channel slack --to "#general" --message "状态更新"

# 发送带附件的消息
openclaw message send --channel telegram --to "@username" --message "报告" --file ./report.pdf

配置管理

openclaw config

管理配置。

openclaw config <命令>

命令:

  • get <> - 获取配置值
  • set <> <> - 设置配置值
  • unset <> - 删除配置值
  • edit - 在编辑器中打开配置
  • show - 显示完整配置
  • validate - 验证配置

示例:

# 获取值
openclaw config get agent.model

# 设置值
openclaw config set agent.temperature 0.8

# 编辑配置
openclaw config edit

# 验证配置
openclaw config validate

技能管理

openclaw skills

列出可用技能。

openclaw skills [选项]

选项:

  • --workspace <路径> - 显示工作区技能
  • --bundled - 显示捆绑技能
  • --managed - 显示托管技能

clawhub

从 ClawHub 注册表管理技能。

clawhub <命令>

命令:

  • search <查询> - 搜索技能
  • install <slug> - 安装技能
  • update [slug] - 更新技能
  • sync --all - 同步所有技能
  • list - 列出已安装的技能
  • info <slug> - 显示技能详情

示例:

# 搜索技能
clawhub search "天气"

# 安装技能
clawhub install nano-banana-pro

# 更新所有技能
clawhub update --all

# 显示技能信息
clawhub info peekaboo

会话管理

openclaw sessions

管理对话会话。

openclaw sessions <命令>

命令:

  • list - 列出活动会话
  • info <ID> - 显示会话详情
  • reset <ID> - 重置会话上下文
  • delete <ID> - 删除会话
  • export - 导出会话
  • import - 导入会话

示例:

# 列出会话
openclaw sessions list

# 显示会话详情
openclaw sessions info abc123

# 重置会话
openclaw sessions reset abc123

# 导出会话
openclaw sessions export --output ./sessions.json

配对管理

openclaw pairing

管理配对请求。

openclaw pairing <命令>

命令:

  • list - 列出待处理的配对请求
  • approve <渠道> <代码> - 批准配对
  • reject <渠道> <代码> - 拒绝配对
  • revoke <渠道> <对等方> - 撤销现有配对

示例:

# 列出待处理的请求
openclaw pairing list

# 批准配对
openclaw pairing approve whatsapp ABC123

# 拒绝配对
openclaw pairing reject telegram XYZ789

# 撤销配对
openclaw pairing revoke whatsapp "+1234567890"

渠道管理

openclaw channels

管理通信渠道。

openclaw channels <命令>

命令:

  • list - 列出已配置的渠道
  • status - 显示渠道状态
  • enable <类型> - 启用渠道
  • disable <类型> - 禁用渠道
  • test <类型> - 测试渠道连接
  • pair <类型> - 配对设备(WhatsApp 等)

示例:

# 列出渠道
openclaw channels list

# 检查状态
openclaw channels status

# 配对 WhatsApp
openclaw channels pair whatsapp

# 测试 Telegram
openclaw channels test telegram

浏览器控制

openclaw browser

控制专用浏览器实例。

openclaw browser <命令>

命令:

  • launch - 启动浏览器实例
  • close - 关闭浏览器
  • navigate <URL> - 导航到 URL
  • screenshot - 截屏
  • status - 显示浏览器状态

示例:

# 启动浏览器
openclaw browser launch

# 导航到 URL
openclaw browser navigate https://github.com

# 截屏
openclaw browser screenshot --output ./screenshot.png

系统操作

openclaw status

显示系统状态。

openclaw status

openclaw health

检查系统健康状况。

openclaw health [选项]

选项:

  • --json - 以 JSON 格式输出

openclaw logs

查看网关日志。

openclaw logs [选项]

选项:

  • --follow - 跟踪日志输出
  • --lines <n> - 显示最后 N 行
  • --level <级别> - 按日志级别过滤

示例:

# 跟踪日志
openclaw logs --follow

# 显示最后 100 
openclaw logs --lines 100

# 仅显示错误
openclaw logs --level error

openclaw doctor

诊断系统问题。

openclaw doctor

模型管理

openclaw models

管理 AI 模型。

openclaw models <命令>

命令:

  • list - 列出可用模型
  • test <名称> - 测试模型连接
  • set-primary <名称> - 设置主模型
  • add-fallback <名称> - 添加备用模型

示例:

# 列出模型
openclaw models list

# 测试模型
openclaw models test anthropic/claude-sonnet-4-6

# 设置主模型
openclaw models set-primary anthropic/claude-opus-4-6

自动化

openclaw cron

管理计划任务。

openclaw cron <命令>

命令:

  • list - 列出计划任务
  • add <计划> <命令> - 添加 cron 任务
  • remove <ID> - 删除 cron 任务
  • run <ID> - 立即运行任务

示例:

# 列出任务
openclaw cron list

# 添加每日任务
openclaw cron add "0 9 * * *" "openclaw agent --message '每日摘要'"

# 立即运行任务
openclaw cron run job-123

安全

openclaw security

安全操作。

openclaw security <命令>

命令:

  • audit - 运行安全审计
  • check-updates - 检查安全更新
  • rotate-keys - 轮换加密密钥

示例:

# 运行安全审计
openclaw security audit

# 检查更新
openclaw security check-updates

openclaw secrets

管理密钥。

openclaw secrets <命令>

命令:

  • list - 列出密钥引用
  • set <> <> - 设置密钥
  • delete <> - 删除密钥
  • rotate <> - 轮换密钥

高级功能

openclaw nodes

管理配对的设备节点。

openclaw nodes <命令>

命令:

  • list - 列出配对的节点
  • pair - 配对新节点
  • unpair <ID> - 取消配对节点
  • status <ID> - 显示节点状态

openclaw memory

在记忆中进行向量搜索。

openclaw memory search <查询> [选项]

选项:

  • --limit <n> - 最大结果数
  • --workspace <路径> - 搜索特定工作区

openclaw webhooks

管理 webhooks。

openclaw webhooks <命令>

命令:

  • list - 列出 webhooks
  • add <URL> - 添加 webhook
  • remove <ID> - 删除 webhook
  • test <ID> - 测试 webhook

环境变量

OpenClaw 遵循这些环境变量:

  • OPENCLAW_CONFIG - 配置文件路径
  • OPENCLAW_WORKSPACE - 默认工作区路径
  • OPENCLAW_LOG_LEVEL - 日志级别(debug|info|warn|error)
  • OPENCLAW_PORT - 网关端口
  • OPENCLAW_HOST - 网关主机
  • ANTHROPIC_API_KEY - Anthropic API 密钥
  • OPENAI_API_KEY - OpenAI API 密钥

退出代码

  • 0 - 成功
  • 1 - 一般错误
  • 2 - 配置错误
  • 3 - 连接错误
  • 4 - 身份验证错误
  • 5 - 权限错误

下一步