<style>.toc-chapters{max-height:none!important}.copy-btn,#sidebar-toggle,#fullscreen-toggle{display:none!important}@media(max-width:768px){.tutorial-app{display:flex;height:auto;overflow:visible;flex-direction:column}.tutorial-main{order:0;overflow:visible}.tutorial-content{overflow:visible}.tutorial-sidebar{order:1;position:static!important;width:100%!important;min-width:0!important;max-height:none!important;display:flex!important;transform:none!important}.sidebar-toc{overflow:visible}}</style>

附录 A:CLI 命令速查

快速查找 OpenClaw 常用命令,不用每次都翻文档。


🚀 首次使用

# 交互式初始化:Gateway + 工作区 + 技能 + 通道
openclaw onboard

# 只初始化配置和目录(不启动 Gateway)
openclaw setup

⚙️ Gateway 管理

# 启动 Gateway(后台服务)
openclaw gateway start

# 停止 Gateway
openclaw gateway stop

# 重启 Gateway
openclaw gateway restart

# 查看 Gateway 运行状态
openclaw gateway status

# 前台运行(调试用,退出即停)
openclaw gateway run

🖥️ 控制面板

# 在浏览器打开控制面板
openclaw dashboard

会自动打开默认浏览器,显示控制界面。

📊 系统状态

# 查看网关、通道、模型、最近的会话状态
openclaw status

# 更详细的诊断信息
openclaw status --all

# 额外探测各通道连接(Telegram、WhatsApp 等)
openclaw status --deep

# 输出 JSON 格式
openclaw status --json

# 查看模型用量/配额
openclaw status --usage

🔧 配置管理

# 交互式配置(更改模型、Gateway、通道等)
openclaw configure

# 查看某个配置值
openclaw config get gateway.port

# 设置配置值
openclaw config set gateway.port 19001

# 查看当前配置文件路径
openclaw config file

# 验证配置文件
openclaw config validate

💬 会话管理

# 列出所有会话
openclaw sessions

# 只看最近 2 小时内的会话
openclaw sessions --active 120

# 只看最新 25 条
openclaw sessions --limit 25

# 清理过期会话数据
openclaw sessions cleanup

📝 日志

# 实时查看 Gateway 日志
openclaw logs

# 查看某个通道的日志
openclaw channels logs --channel telegram

🧑‍🤝‍🧑 代理 (Agent) 管理

# 列出所有 Agent
openclaw agents list

# 查看路由绑定(哪个通道连到哪个 Agent)
openclaw agents bindings

# 新建一个 Agent
openclaw agents add

🩺 健康诊断

# 检查配置、Gateway、插件、通道问题
openclaw doctor

# 发现问题并自动修复
openclaw doctor --fix

# 只检查不修改
openclaw doctor --lint

📡 通道管理

# 列出已配置的通道
openclaw channels list

# 添加/配置一个新通道
openclaw channels add

# 查看通道状态
openclaw channels status

# 删除一个通道
openclaw channels remove --channel telegram

🔍 其他实用命令

# 查看 CLI 版本
openclaw --version

# 生成命令补全脚本(支持 bash/zsh/fish)
openclaw completion

# 查看某个命令的详细帮助
openclaw <command> --help

# 搜索在线文档
openclaw docs "如何配置模型"

小技巧:大部分命令都支持 --help,记不住参数就加它。

系统教程,帮你把工具用好,再回到任务中。 浏览任务方案 →