OpenClaw 的命令行接口设计清晰,主要分为配置管理、通道消息、网关服务、模型管理和诊断维护几个功能模块。下面总结下OpenClaw CLI 的简明使用。
一个AI智能体平台是一台精密的机器。Web UI 提供了观察其灵魂的窗口,但真正的掌控权,源自命令行(CLI)——工程师的中央控制台。在这里,每一次敲击都直接与系统的核心交互,每一次命令的执行都可能重塑智能体的行为。然而,将 CLI 仅仅视为命令的集合,会极大地限制您的潜力。

1. 快速启动
openclaw --help- 查看全局选项、主要命令及说明。
openclaw configure- 图形化向导,配置凭证、聊天通道、Gateway 地址等。第一次使用请务必运行一次。
openclaw onboard- 更全面的入门向导,会提示你配置 Gateway、技能、默认模型。
openclaw status- 查看 Gateway 状态、活跃通道和最近的对话对象。
2. 全局选项
| 选项 | 说明 |
|---|---|
--dev | 使用开发 profile(状态、配置独立于主配置)并把默认 Gateway 端口切到 19001。 |
-h, --help | 输出帮助文本。 |
--log-level <level> | 覆盖日志等级(silent/fatal/error/warn/info/debug/trace)。 |
--no-color | 关闭 ANSI 彩色输出。 |
--profile <name> | 使用命名 profile,在 ~/.openclaw-<name> 下存状态和配置。 |
-V, --version | 显示当前 CLI 版本。 |
小贴士:
openclaw <command> --help可以查看该命令的子命令及选项。
3. 核心命令分类与常见用法
3.1 会话与消息
openclaw sessions list/openclaw sessions history- 查看已保存的对话、最新消息。
openclaw message send --target <id> --message "Hi"- 通过 Gateway 发送消息,可指定
--channel、--json、--deliver等。
- 通过 Gateway 发送消息,可指定
3.2 代理与技能
openclaw agent --to <target> --message "..."- 直接通过 Gateway 对某目标发起一次助理 turn。
openclaw agents系列- 管理隔离 agent(创建、授权、路由)。
openclaw skills list/openclaw skills info <skill>- 查看已安装技能、需求。
3.3 Gateway 与节点
openclaw gateway start|stop|restart|status- 控制本地 WebSocket Gateway 服务。
openclaw nodes list/openclaw nodes pairing- 管理可选的 node host,用于运行 exec、browser、canvas 等。
openclaw node start --token <...>- 启动 headless node 实例。
3.4 配置与安全
openclaw config(有 get/set/unset/file/validate)- 非交互式修改 CLI 配置项。
openclaw configure/openclaw reset- 重置、初始化本地配置和 workspace。
openclaw security、openclaw doctor- 运行健康检查、审计本地设置。
3.5 定时任务与自动化
openclaw cron系列- 创建/列出周期任务,定时触发 skills。
openclaw hooks、openclaw system- 管理内部 hook、事件。
3.6 其他常用工具
| 命令 | 用途 |
|---|---|
openclaw docs | 搜索 https://docs.openclaw.ai 文档。 |
openclaw models | 浏览/配置模型、调度策略。 |
openclaw update | 检查/应用 CLI 或 Gateway 更新。 |
openclaw plugins | 管理插件/扩展。 |
openclaw onboarding | 重新执行入门。 |
openclaw dashboard | 打开控制台 UI(默认浏览器)。 |
openclaw health | 快速查看 Gateway 的健康指标。 |
openclaw webhooks | 设置 webhook。 |
openclaw logs | 查看日志。 |
4. 示例工作流
- 启动 Gateway
openclaw gateway start
openclaw status
- 登录聊天通道(如 Telegram)
openclaw channels login --channel telegram
- 发送消息
openclaw message send --channel telegram --target @mygroup --message "任务提醒" --json
- 检查 session
openclaw sessions list --limit 5
openclaw sessions history --session-id <id>
- 管理自定义 agent
openclaw agents create --name "dev-helper" --model gpt5
openclaw agents approve --agent <id>
- 配置模型指令 举例:
openclaw config set models.providers.openaichattop
'{"baseUrl":"https://openaichat.top/v1","apiKey":"sk-4e75632bc21058aa52997f1b4e45caae6819ebe74df71","api":"openai-responses","models":[{"id":"gpt-5.1-codex-mini","name":"gpt-5.1-codex-mini"}]}'
--strict-json
- 配置微信通道命令 举例:
openclaw config set channels.wecom-app '{
"enabled": true,
"webhookPath": "/wecom-app",
"token": "yanxxxcd",
"encodingAESKey": "tBMDXX9popL9LxxxKHJva5NvwRu",
"corpId": "ww753xxx0ae3",
"corpSecret": "NDJvUwPf_rVTxxx1HvNYeu8QbJBw3KEEA",
"agentId": 1000002,
"apiBaseUrl": "http://49.xxx.xx.102:18789"
}' --json
或者可以直接修改.openclaw/目录下的openclaw.json文件。
5. 高级提示
- 可以把
openclaw --profile dev当作隔离环境,用于测试新技能或 Sandbox。 openclaw configure --help会列出可设置的凭证路径、默认模型、channel token 等。- 需要跨终端使用 CLI 时,配合
openclaw status+openclaw sessions快速定位会话上下文。 - 使用
openclaw message send --json-file可以批量导入消息。
6. 参考链接
- 官方文档:https://docs.openclaw.ai/cli
- OpenClaw 仓库:https://github.com/openclaw/openclaw
- OpenClaw CLI 所有命令整理 《命令速查》
OpenClaw-CLI命令详解
掌控 OpenClaw:核心命令行
2818

被折叠的 条评论
为什么被折叠?



