OpenClaw 是开源 AI 网关,连接 Discord、Telegram、微信等 20+ 通道。掌握这 30 个核心命令,5 分钟上手。
一、安装启动
安装 OpenClaw
macOS/Linux
curl -fsSL https://openclaw.ai/install.sh | bashWindows
iwr -useb https://openclaw.ai/install.ps1 | iex初始化配置
openclaw onboard --install-daemon # 交互式向导,配置模型和 Gatewayopenclaw gateway start # 启动 Gateway 服务openclaw dashboard # 打开浏览器控制面板
onboard会引导你完成:选择模型提供商 → 填写 API Key → 启动 Gateway。
二、Gateway 管理
Gateway 是 OpenClaw 的核心服务,负责消息路由和会话管理。
openclaw gateway start # 启动服务(后台运行)openclaw gateway stop # 停止服务openclaw gateway restart # 重启(修改配置后常用)openclaw gateway status # 查看运行状态常用选项
openclaw gateway --port 19001 # 自定义端口openclaw gateway --dev # 开发模式(隔离配置)openclaw gateway --tailscale serve # 通过 Tailscale 暴露三、配置管理
OpenClaw 使用 JSON 配置文件,默认路径 ~/.openclaw/openclaw.json。
openclaw config file # 查看配置文件路径openclaw config get gateway.port # 读取配置项openclaw config set gateway.port 19001 # 修改配置项openclaw config validate # 验证配置格式配置向导(适合修改复杂配置)
openclaw config --section model # 配置模型openclaw config --section channels # 配置通道openclaw config --section skills # 配置技能四、Agent 控制
Agent 是执行任务的 AI 实体。你可以通过命令直接调用 Agent,无需打开聊天界面。
openclaw agent -m "你好"# 发送消息给默认 Agentopenclaw agent -m "总结日志" --agent ops # 指定 Agentopenclaw agent -m "分析代码" --thinking high # 提高思考深度openclaw agent -m "快速任务" --local# 本地执行(不经过 Gateway)管理多 Agent
openclaw agents list # 列出所有 Agentopenclaw agents add --id my-agent # 创建新 Agentopenclaw agents bind --agent my-agent --channel telegram # 绑定通道多 Agent 场景:一个 Agent 处理运维,一个处理客服,一个处理开发。
五、技能管理
技能(Skills)是 OpenClaw 的扩展机制,让 Agent 获得新能力,如 Docker 管理、代码审查等。
openclaw skills search "docker"# 搜索技能openclaw skills install docker-manager # 安装技能openclaw skills update --all # 更新所有技能openclaw skills list # 查看已安装技能六、通道管理
通道是 OpenClaw 与外部聊天平台的连接。配置后,你可以从 Telegram、Discord 等直接对话 Agent。
添加通道
# Telegram(最简单,只需 Bot Token)openclaw channels add --channel telegram --token <bot-token># Discordopenclaw channels add --channel discord --token <bot-token># Slackopenclaw channels add --channel slack --token <xoxb-token>查看状态
openclaw channels list # 列出所有通道openclaw channels status --probe # 检查连接状态openclaw channels logs --channel all # 查看通道日志获取 Bot Token:Telegram 找 @BotFather,Discord 在开发者后台创建 Bot。
七、定时任务
让 Agent 按固定时间自动执行任务,如日报、健康检查等。
创建任务
# 每小时执行openclaw cron add --name "health" --schedule "0 * * * *" -m "检查系统健康"# 每天上午 9 点openclaw cron add --name "daily" --schedule "0 9 * * *" -m "生成日报"# 每 30 分钟openclaw cron add --name "sync" --every 1800000 -m "同步数据"管理任务
openclaw cron list # 列出任务openclaw cron enable <id> # 启用任务openclaw cron disable <id> # 暂停任务openclaw cron rm <id> # 删除任务openclaw cron run <id> # 立即执行一次Cron 表达式格式:
分 时 日 月 周,如0 9 * * *表示每天 9:00。
八、节点管理
节点是配对的移动设备(iOS/Android),可远程控制相机、屏幕、位置等。
配对设备
openclaw nodes pending # 查看待配对请求openclaw nodes approve <id> # 批准配对openclaw nodes list --connected # 查看已连接设备远程控制
openclaw nodes camera snap --node <id> # 拍照openclaw nodes screen record --node <id> --duration 30 # 录屏 30 秒openclaw nodes location get --node <id> # 获取位置使用场景:远程监控、自动化测试、位置签到等。
九、系统维护
诊断修复
openclaw doctor # 系统诊断openclaw doctor --fix # 自动修复常见问题openclaw security audit # 安全审计openclaw health # 健康检查日志查看
openclaw logs --lines 100 # 查看最近 100 行日志openclaw channels logs --channel all # 查看通道日志十、插件与模型
插件管理
openclaw plugins list # 列出插件openclaw plugins install <id> # 安装插件openclaw plugins enable <id> # 启用插件模型管理
openclaw models list # 列出可用模型openclaw models set <model-id> # 设置默认模型速查表
日常必用
openclaw gateway start | |
openclaw agent -m "任务" | |
openclaw skills install <name> | |
openclaw channels add --channel telegram --token <t> | |
openclaw cron add --name <n> --schedule <s> -m <msg> |
问题排查
openclaw gateway status | |
openclaw logs --lines 100 | |
openclaw doctor | |
openclaw doctor --fix |
全局选项
所有命令都支持以下选项:
openclaw --dev <command> # 开发模式(隔离配置)openclaw --no-color <command> # 禁用颜色输出openclaw <command> --json # JSON 格式输出(便于脚本处理)学习路径
新手(5 分钟)
openclaw onboard --install-daemon— 初始化openclaw agent -m "你好"— 测试 Agent
进阶(30 分钟)
openclaw channels add --channel telegram— 连接 Telegramopenclaw skills install docker-manager— 安装技能openclaw cron add --name "daily" --schedule "0 9 * * *"— 创建定时任务
高阶
配置多 Agent 分工 开发自定义技能 集成 Tailscale 远程访问
官方资源
文档:https://docs.openclaw.ai 技能市场:https://clawhub.ai GitHub:https://github.com/openclaw/openclaw
夜雨聆风