OpenClaw 常用指令全解:从入门到实战
OpenClaw(社区昵称 “龙虾”)是开源、本地优先的 AI 智能体执行网关,核心是让大模型 “动手” 完成系统操作、消息收发、文件处理与自动化任务。本文按五大场景,整理高频指令与实战用法,新手可直接复制使用。
·
OpenClaw 常用指令全解:从入门到实战
OpenClaw(社区昵称 “龙虾”)是开源、本地优先的 AI 智能体执行网关,核心是让大模型 “动手” 完成系统操作、消息收发、文件处理与自动化任务。本文按网关管理、消息交互、系统 / 文件操作、配置 / 监控、聊天斜杠命令五大场景,整理高频指令与实战用法,新手可直接复制使用。
一、网关管理(启动 / 停止 / 状态)
网关是 OpenClaw 核心服务,负责连接模型、渠道与本地系统,所有操作依赖网关运行。
表格
| 指令 | 功能 | 常用参数 | 场景 |
|---|---|---|---|
openclaw gateway run |
前台运行网关(调试用) | --port 18789(指定端口)、--bind lan(局域网访问) |
开发调试、查看实时日志 |
openclaw gateway start |
后台启动网关(开机自启) | --force(强制启动,杀占用端口进程) |
日常使用、服务器部署 |
openclaw gateway stop |
停止后台网关 | - | 维护、重启前操作 |
openclaw gateway status |
查看网关运行状态、RPC 连通性 | - | 排查启动失败、渠道连接问题 |
openclaw gateway restart |
重启网关 | - | 配置修改后生效、服务异常恢复 |
实战示例
bash
运行
# 前台启动网关,指定端口18789,允许局域网访问
openclaw gateway run --port 18789 --bind lan
# 后台强制启动网关
openclaw gateway start --force
# 查看网关状态
openclaw gateway status
二、消息交互(多渠道收发 / 管理)
支持 Telegram、Discord、WhatsApp、企业微信等 20+ 渠道,可发消息、投票、管理频道成员。
1. 基础消息发送
bash
运行
# 发送文本到 Telegram(@用户名)
openclaw message send --channel telegram --target @username --message "OpenClaw 指令教程"
# 发送文本到 Discord(频道ID)
openclaw message send --channel discord --target channel:123456 --message "测试消息"
# 发送文本到 WhatsApp(手机号)
openclaw message send --target +15555550123 --message "Hi, OpenClaw"
2. 高级消息操作
bash
运行
# 发送投票到 Discord(多选项)
openclaw message poll --channel discord --target channel:123456 \
--poll-question "午餐吃什么?" \
--poll-option 米饭 --poll-option 面条 --poll-option 火锅
# 编辑已发送消息(需消息ID)
openclaw message edit --channel telegram --target @username --message-id 123 --message "更新后的内容"
# 删除消息
openclaw message delete --channel discord --target channel:123456 --message-id 456
# 查看频道成员信息
openclaw message member info --channel telegram --target @username
三、系统与文件操作(本地自动化核心)
无需代码,直接执行文件批量处理、系统命令、版本管理,是 OpenClaw 区别于普通聊天 AI 的核心能力。
1. 文件批量操作(高频)
bash
运行
# 批量重命名:当前目录所有 .txt 文件 → file_001.txt、file_002.txt
openclaw file rename --path ./ --type txt --prefix file_ --suffix "" --digits 3
# 批量格式转换:jpg → png
openclaw file convert --path ./ --from jpg --to png
# 批量删除:清理临时 .tmp 文件
openclaw file delete --path ./ --type tmp
2. 系统与版本管理
bash
运行
# 查看当前版本与历史版本
openclaw version --history
# 更新到最新版
openclaw update --latest
# 回滚到指定版本(如1.7.0)
openclaw update --version 1.7.0
# 执行系统命令(Linux/macOS)
openclaw exec "ls -l"
openclaw exec "echo 'Hello OpenClaw' > test.txt"
四、配置、监控与故障排查
1. 状态与日志(快速定位问题)
bash
运行
# 查看全量状态(通道+会话+模型配额)
openclaw status --all
# 深度检测各渠道连通性
openclaw status --deep
# 查看网关运行日志
openclaw logs
# 检查系统健康(自动体检)
openclaw health
2. 故障修复(必备)
bash
运行
# 自动诊断问题(网关起不来、渠道连不上先跑这个)
openclaw doctor
# 自动修复已知问题(备份原配置)
openclaw doctor --fix
# 深度扫描(排查端口占用、多网关冲突)
openclaw doctor --deep
3. 配置管理
bash
运行
# 初始化引导(首次部署)
openclaw onboard --install-daemon
# 查看当前配置
openclaw config list
# 修改配置(如切换模型)
openclaw config set model gpt-4o
五、聊天界面斜杠命令(无需终端,直接交互)
在 OpenClaw 聊天窗口输入斜杠命令,快速控制会话、模型与任务,不消耗 Token。
表格
| 命令 | 功能 | 场景 |
|---|---|---|
/new |
重置会话,清空上下文 | 开启新任务、避免历史干扰 |
/stop |
立即中止当前运行任务 | 任务卡死、误操作时终止 |
/status |
查看会话健康与上下文 | 排查响应慢、任务卡住 |
/model <模型名> |
切换当前会话模型 | 临时用 GPT-4o、Claude 等 |
/context list |
列出上下文来源 | 调试模型理解偏差 |
/restart |
重启 OpenClaw 服务 | 程序无响应、功能异常 |
六、常用指令速查(新手收藏)
启动与维护
bash
运行
openclaw gateway start --force # 后台强制启动
openclaw gateway status # 查看状态
openclaw doctor --fix # 一键修复问题
openclaw logs # 查看日志
消息发送
bash
运行
# Telegram
openclaw message send --channel telegram --target @user --message "内容"
# Discord
openclaw message send --channel discord --target channel:123 --message "内容"
# 投票
openclaw message poll --channel discord --target channel:123 --poll-question "问题" --poll-option A --poll-option B
文件与系统
bash
运行
openclaw file rename --path ./ --type txt --prefix file_ # 批量重命名
openclaw file convert --path ./ --from jpg --to png # 格式转换
openclaw exec "ls -l" # 执行系统命令
openclaw update --latest # 更新版本
七、使用建议
- 新手优先用
openclaw doctor排查问题,90% 常见故障可自动修复。 - 消息发送前用
openclaw gateway status确认渠道连通,避免发送失败。 - 批量文件操作前备份数据,防止误删。
- 聊天窗口用
/new清空上下文,减少 Token 消耗、提升响应速度。
更多推荐




所有评论(0)