安装配置过五六次 openclaw 之后,我发现小龙虾最大的问题是配置文件变更太快且很多时候不考虑兼容性。
经常是查资料发现资料已经过时了,或者一升级,发现配置文件出错,启动不起来。
在这种背景下,我发现要搞定 openclaw 最好的办法是尽量用命令行操作,不要直接修改配置文件。
所以我做了这份速查表(cheatsheet)。
这份速查表按照真实的使用生命周期编排:从零开始的初始化、全局配置、Agent 管理、渠道接入,一直到后期的日常运维与安全隔离。
🦞 OpenClaw CLI 全流程速查表 (Cheatsheet)
❝版本参考: OpenClaw 2026.3.28
核心理念: 将你的设备转化为私人的、永远在线的 AI Agent 运行环境。
1. 🚀 初始化与基础设置 (Setup & Init)
第一次接触 OpenClaw 时,需要建立本地环境与初始配置。
openclaw setup | ||
openclaw configure | ||
openclaw qr | ||
openclaw completion | source <(openclaw completion) | |
openclaw doctor | openclaw doctor --fix |
2. ⚙️ 配置与凭证管理 (Config & Secrets)
OpenClaw 采用“双层配置模型”(全局 ~/.config/openclaw/ 与 项目级 openclaw.json),局部配置优先。
openclaw config get <key> | openclaw config get agents.defaults.model.primary | |
openclaw config set <k> <v> | openclaw config set agents.defaults.model.primary gpt-5.4 | |
openclaw config validate | ||
openclaw config reset | openclaw config reset agents.defaults | |
openclaw secrets * |
3. 🧠 智能体管理 (Agent Management)
OpenClaw 允许你运行多个隔离的 Agent,每个可以有独立的人设、模型路由和绑定的通讯渠道。
openclaw agents add <name> | openclaw agents add ops-bot --workspace ~/.openclaw/ops | |
openclaw agents list | --verbose 或 --format json 查看详情 | |
openclaw agents bind | openclaw agents bind --agent ops-bot --bind telegram:ops | |
openclaw agents unbind | openclaw agents unbind --agent ops-bot --all | |
openclaw agents set-identity | openclaw agents set-identity --agent ops-bot --emoji "👷" | |
openclaw agent | openclaw agent --agent ops-bot --message "汇总今日日志" |
4. 💬 渠道与消息互动 (Channels & Messaging)
这是 OpenClaw 的杀手锏,让 Agent 直接寄宿在你常用的聊天软件中(WhatsApp, Telegram 等)。
openclaw channels login | openclaw channels login --verbose | |
openclaw channels * | ||
openclaw message send | openclaw message send --channel telegram --target @username --message "Hi" |
5. 🔌 技能与扩展 (Skills & Plugins)
让 Agent 拥有与外界交互的能力(如读写文件、发邮件、调用 MCP 服务器)。
openclaw skills * | clawhub install <skill> 安装 | |
openclaw plugins * |
6. 🛠️ 服务启动与日常运维 (Gateway & Operations)
Gateway(网关)是 OpenClaw 的心脏,负责维持长连接、计划任务和分发消息。
openclaw gateway | openclaw gateway --port 18789 | |
openclaw gateway --force | ||
openclaw tui | ||
openclaw status | ||
openclaw sessions * | ||
openclaw cron * | ||
openclaw system * |
7. 🛡️ 安全隔离与备份 (Security, Isolation & Backup)
为了防止 AI 执行危险操作,OpenClaw 提供了强大的沙盒与安全管控。
openclaw sandbox * | ||
openclaw approvals * | rm -rf)时,需推送到手机端人工确认 | |
openclaw security * | ||
openclaw backup * | openclaw backup createverify |
8. 🧰 环境标签与全局选项 (Global Options)
这些参数可以附加在任何命令上,用于控制运行环境。
--dev | 开发者模式 | ~/.openclaw-dev,默认网关端口偏移到 19001,非常适合测试环境。 |
--profile <name> | 多租户/环境隔离 | openclaw --profile work gateway |
--container <name> | 容器内执行 | |
--log-level <lv> | 日志级别控制 | tracedebug, info, warn, error, fatal, silent |
9. 🗑️ 卸载与重置 (Reset & Uninstall)
当你需要从头再来时的急救命令。
openclaw reset | ||
openclaw uninstall |
10. 🧠 模型管理 (Models)
定位:Agent 的“大脑”。管理本地运行的开源模型(如 Llama、Qwen)以及云端商业 API(如 Gemini、GPT-4)。
openclaw models add | ||
openclaw models list | ||
openclaw models pull <name> | openclaw models pull llama3:8b | |
openclaw models add-provider | ||
openclaw models set-default | openclaw models set-default gpt-4o | |
openclaw models inspect <name> | openclaw models inspect gemini-1.5-pro |
11. 🛠️ 技能与工具 (Skills)
定位:Agent 的“手脚”。Skills 相当于 Function Calling(函数调用)的封装集合,让 Agent 能够执行具体的任务(如联网搜索、读写文件、操作日历)。
openclaw skills list | openclaw skills list --agent ops-bot | |
openclaw skills install | openclaw skills install mcp-github | |
openclaw skills remove | openclaw skills remove web-scraper | |
openclaw skills inspect | ||
openclaw skills grant | openclaw skills grant --agent ops-bot --skill mcp-github |
12. 🧩 插件与底层扩展 (Plugins)
定位:OpenClaw 系统的“神经系统”。Plugins 用于扩展 CLI 框架自身的能力,例如新增一种 Vector DB(向量数据库)支持、新增一种聊天渠道(Channel)协议等。
openclaw plugins list | ||
openclaw plugins add | openclaw plugins add @openclaw/plugin-wechat-weipad | |
openclaw plugins enable <name> | openclaw plugins enable custom-logger | |
openclaw plugins disable <name> | ||
openclaw plugins update | openclaw plugins update --all |
💡 核心概念辨析 (TL;DR):
Model (模型): 决定你的 Agent 有多聪明(智商)。 Skill (技能): 决定你的 Agent 能干什么活(行动力),是面向 Agent 的功能。 Plugin (插件): 决定 OpenClaw 系统能支持什么基础设施,是面向系统的架构扩展。
💡 高阶玩法提示: 如果想要调试特定的新模型,你可以直接使用 --dev 启动隔离环境(openclaw --dev gateway),然后在这个沙盒环境中进行破坏性测试,完全不会影响你主线日常使用的 Agent 记忆和配置。
夜雨聆风