CLI 命令参考
CLI 命令参考 ⌨️
Section titled “CLI 命令参考 ⌨️”本文档提供 OpenClaw 命令行工具的完整参考。
🚀 快速命令
Section titled “🚀 快速命令”# 最常用命令openclaw onboard # 启动配置向导openclaw gateway # 启动网关服务openclaw dashboard # 打开控制面板openclaw doctor # 诊断问题📋 命令分类
Section titled “📋 命令分类”🏠 核心命令
Section titled “🏠 核心命令”openclaw onboard - 配置向导
Section titled “openclaw onboard - 配置向导”启动交互式配置向导。
openclaw onboard [选项]
选项: --install-daemon 安装系统服务 --config <path> 使用指定配置文件 --yes 自动确认所有选项 --verbose 显示详细日志openclaw gateway - 网关管理
Section titled “openclaw gateway - 网关管理”管理网关服务。
# 启动网关openclaw gateway [选项]
选项: --port <port> 指定端口(默认18789) --host <host> 绑定地址(默认127.0.0.1) --daemon 后台运行 --verbose 详细日志 --dev 开发模式 --force 强制启动(终止占用端口的进程)
# 停止网关openclaw gateway stop
# 重启网关openclaw gateway restart
# 查看状态openclaw gateway statusopenclaw dashboard - 控制面板
Section titled “openclaw dashboard - 控制面板”打开浏览器控制界面。
openclaw dashboard [选项]
选项: --port <port> 指定端口 --browser <name> 指定浏览器(chrome/firefox/safari)⚙️ 配置命令
Section titled “⚙️ 配置命令”openclaw config - 配置管理
Section titled “openclaw config - 配置管理”# 查看配置openclaw config get [key]
# 设置配置项openclaw config set <key> <value>
# 删除配置项openclaw config delete <key>
# 验证配置openclaw config validate
# 编辑配置文件openclaw config edit
# 查看配置路径openclaw config path
# 导出配置openclaw config export [path]
# 导入配置openclaw config import <path>示例:
# 设置 WhatsApp 频道openclaw config set channels.whatsapp.enabled true
# 设置代理模型openclaw config set agents.default.model claude-3.5-sonnet
# 验证配置openclaw config validate📱 频道命令
Section titled “📱 频道命令”openclaw channels - 频道管理
Section titled “openclaw channels - 频道管理”# 列出所有频道openclaw channels list
# 查看频道状态openclaw channels status
# 登录/连接频道openclaw channels login <platform> # platform: whatsapp, telegram, discord
# 重新连接频道openclaw channels reconnect <platform>
# 断开频道连接openclaw channels disconnect <platform>
# 测试频道连接openclaw channels test <platform>
# 查看频道日志openclaw channels logs <platform>示例:
# WhatsApp 登录(显示二维码)openclaw channels login whatsapp
# 检查 Telegram 状态openclaw channels status telegram
# 重新连接 Discordopenclaw channels reconnect discord💬 消息命令
Section titled “💬 消息命令”openclaw message - 发送消息
Section titled “openclaw message - 发送消息”# 发送消息openclaw message send [选项]
选项: --target <id> 目标用户ID --platform <name> 平台(whatsapp/telegram/discord) --message <text> 消息内容 --file <path> 附件文件
# 发送测试消息openclaw message test
# 查看消息历史openclaw message history [选项] --session <id> 指定会话 --limit <n> 限制条数示例:
# 发送私信openclaw message send \ --target "+8613800138000" \ --platform whatsapp \ --message "你好!"
# 发送带附件的消息openclaw message send \ --target "@username" \ --platform telegram \ --message "查看这个文件" \ --file document.pdf🧠 代理命令
Section titled “🧠 代理命令”openclaw agent - 代理管理
Section titled “openclaw agent - 代理管理”# 列出所有代理openclaw agent list
# 查看代理状态openclaw agent status [agent-id]
# 切换代理openclaw agent switch <agent-id>
# 重新加载代理openclaw agent reload [agent-id]
# 测试代理openclaw agent test [agent-id]📊 会话命令
Section titled “📊 会话命令”openclaw session - 会话管理
Section titled “openclaw session - 会话管理”# 列出所有会话openclaw session list [选项] --active 仅显示活跃会话 --platform <name> 按平台筛选
# 查看会话详情openclaw session info <session-id>
# 重置会话openclaw session reset <session-id>
# 删除会话openclaw session delete <session-id>
# 备份会话openclaw session backup <session-id> [path]
# 恢复会话openclaw session restore <path>
# 清理会话openclaw session clean [选项] --hibernated 清理休眠会话 --older-than <time> 清理超过指定时间的会话 --all 清理所有会话(谨慎!)🔍 诊断命令
Section titled “🔍 诊断命令”openclaw doctor - 系统诊断
Section titled “openclaw doctor - 系统诊断”openclaw doctor [选项]
选项: --fix 自动修复问题 --yes 确认修复 --verbose 详细输出 --check <type> 检查特定类型 # types: config, sessions, channels, network, storage
# 示例openclaw doctor --check configopenclaw doctor --check network --fixopenclaw logs - 查看日志
Section titled “openclaw logs - 查看日志”openclaw logs [选项]
选项: --follow 实时跟踪 --lines <n> 显示最后n行(默认100) --level <level> 日志级别(debug/info/warn/error) --module <name> 模块筛选 --since <time> 从指定时间开始 --until <time> 到指定时间结束 --grep <pattern> 文本搜索
# 示例openclaw logs --follow --level debugopenclaw logs --module gateway --lines 50openclaw logs --since "1 hour ago" --grep "error"🛠️ 工具命令
Section titled “🛠️ 工具命令”openclaw tools - 工具管理
Section titled “openclaw tools - 工具管理”# 列出可用工具openclaw tools list
# 查看工具详情openclaw tools info <tool-name>
# 测试工具openclaw tools test <tool-name>
# 启用/禁用工具openclaw tools enable <tool-name>openclaw tools disable <tool-name>🔧 系统命令
Section titled “🔧 系统命令”openclaw service - 系统服务
Section titled “openclaw service - 系统服务”# 安装服务openclaw service install
# 卸载服务openclaw service uninstall
# 启动服务openclaw service start
# 停止服务openclaw service stop
# 重启服务openclaw service restart
# 查看服务状态openclaw service statusopenclaw update - 更新
Section titled “openclaw update - 更新”# 检查更新openclaw update check
# 执行更新openclaw update
# 更新到指定版本openclaw update --version <version>
# 强制重新安装openclaw update --force🌍 全局选项
Section titled “🌍 全局选项”所有命令都支持以下全局选项:
--config <path> 指定配置文件--verbose 详细输出--quiet 静默模式--json JSON格式输出--help 显示帮助--version 显示版本🔧 环境变量
Section titled “🔧 环境变量”# 配置文件路径export OPENCLAW_CONFIG_PATH=~/.openclaw/openclaw.json
# 状态目录export OPENCLAW_STATE_DIR=~/.openclaw/state
# 日志级别export OPENCLAW_LOG_LEVEL=debug
# 跳过画布服务export OPENCLAW_SKIP_CANVAS_HOST=1
# API密钥export ANTHROPIC_API_KEY=your-keyexport OPENAI_API_KEY=your-key📁 文件路径
Section titled “📁 文件路径”~/.openclaw/├── openclaw.json # 主配置文件├── state/│ ├── sessions/ # 会话数据│ └── cache/ # 缓存文件├── workspace/│ ├── canvas/ # 画布文件│ ├── memory/ # 记忆存储│ └── skills/ # 技能脚本├── logs/│ └── gateway.log # 网关日志└── backups/ # 配置备份💡 使用示例
Section titled “💡 使用示例”完整工作流程
Section titled “完整工作流程”# 1. 安装并配置npm install -g openclawopenclaw onboard
# 2. 启动网关openclaw gateway --daemon
# 3. 连接 WhatsAppopenclaw channels login whatsapp# 扫描二维码...
# 4. 发送测试消息openclaw message test
# 5. 查看状态openclaw gateway statusopenclaw channels status
# 6. 诊断问题openclaw doctor
# 7. 查看日志openclaw logs --follow# 网关无法启动openclaw doctor --check networkopenclaw logs --level error --lines 20
# 频道连接失败openclaw channels disconnect whatsappopenclaw channels login whatsapp
# 配置错误openclaw config validateopenclaw doctor --fix
# 完全重置openclaw service stoprm -rf ~/.openclawopenclaw onboard