完整命令手册,收藏备用
基础命令
安装与初始化
# 安装
npm install -g openclaw
# 初始化
openclaw init
# 检查状态
openclaw status
# 检查版本
openclaw version
启动与停止
# 启动
openclaw start
# 停止
openclaw stop
# 重启
openclaw restart
# 后台运行
openclaw start --daemon
对话命令
开始对话
# 基础对话
openclaw chat "你好"
# 指定模型
openclaw chat --model deepseek-chat "你好"
# 指定渠道
openclaw chat --channel telegram "你好"
# 交互模式
openclaw chat --interactive
历史记录
# 查看历史
openclaw history
# 导出历史
openclaw history --export --format markdown
# 清除历史
openclaw clear
# 只清除指定会话
openclaw clear --session abc123
配置命令
配置管理
# 检查配置
openclaw config check
# 编辑配置
openclaw config edit
# 查看配置
openclaw config show
# 重置配置
openclaw config reset
环境变量
# 设置变量
openclaw config set DEEPSEEK_API_KEY sk-xxx
# 获取变量
openclaw config get DEEPSEEK_API_KEY
# 删除变量
openclaw config unset DEEPSEEK_API_KEY
# 列出所有变量
openclaw config list
渠道命令
渠道管理
# 列出渠道
openclaw channel list
# 添加渠道
openclaw channel add telegram --token xxx
# 删除渠道
openclaw channel remove telegram
# 启动渠道
openclaw channel start telegram
# 停止渠道
openclaw channel stop telegram
# 测试渠道
openclaw channel test telegram
心跳命令
心跳管理
# 心跳状态
openclaw heartbeat status
# 启用心跳
openclaw heartbeat start
# 停止心跳
openclaw heartbeat stop
# 暂停心跳
openclaw heartbeat pause
# 恢复心跳
openclaw heartbeat resume
# 测试任务
openclaw heartbeat test --task daily-report
Skills 命令
Skill 管理
# 列出 Skills
openclaw skill list
# 安装 Skill
openclaw skill install weather
# 卸载 Skill
openclaw skill uninstall weather
# 更新 Skill
openclaw skill update weather
# 测试 Skill
openclaw skill test weather
# 创建 Skill
openclaw skill create my-skill
日志命令
日志查看
# 实时查看
openclaw logs
# 查看最后 100 行
openclaw logs --tail 100
# 只看错误
openclaw logs --level error
# 搜索关键词
openclaw logs --grep "错误"
# 导出日志
openclaw logs --export
# 清除日志
openclaw logs --clear
数据库命令
数据库管理
# 初始化数据库
openclaw db init
# 检查数据库
openclaw db check
# 备份数据库
openclaw db backup
# 恢复数据库
openclaw db restore backup.sql
# 迁移数据库
openclaw db migrate
# 重置数据库
openclaw db reset
用户命令
用户管理
# 列出用户
openclaw user list
# 添加用户
openclaw user add --email test@example.com
# 删除用户
openclaw user remove test@example.com
# 设置权限
openclaw user set-permission test@example.com admin
Webhook 命令
Webhook 管理
# 启动 Webhook 服务器
openclaw webhooks start
# 停止 Webhook 服务器
openclaw webhooks stop
# 列出 Webhook
openclaw webhooks list
# 测试 Webhook
openclaw webhooks test --payload '{"event":"test"}'
Docker 命令
# 构建 Docker 镜像
openclaw docker build
# 推送镜像
openclaw docker push
# 拉取镜像
openclaw docker pull
# 运行容器
openclaw docker run
高级命令
批量操作
# 批量对话
openclaw chat --batch --file prompts.txt
# 批量测试
openclaw test --batch --file tests.json
# 批量导出
openclaw export --batch --format json
性能测试
# 压力测试
openclaw test --load --concurrent 10
# 延迟测试
openclaw test --latency --iterations 100
# 内存测试
openclaw test --memory
统计分析
# 使用统计
openclaw stats
# Token 消耗
openclaw stats --tokens
# 性能指标
openclaw stats --performance
# 用户行为
openclaw stats --users
快捷别名
# 简写
alias oc=openclaw
alias oc-chat='openclaw chat'
alias oc-status='openclaw status'
alias oc-logs='openclaw logs'
# 配置到 ~/.zshrc 或 ~/.bashrc
echo "alias oc=openclaw" >> ~/.zshrc
source ~/.zshrc
Tab 补全
# 启用 Tab 补全
eval "$(openclaw completion zsh)"
# 或 bash
eval "$(openclaw completion bash)"
# 永久启用
echo 'eval "$(openclaw completion zsh)"' >> ~/.zshrc
常用场景
场景 1:快速对话
# 交互模式
openclaw chat -i
# 单次提问
openclaw chat "用 Python 写个爬虫"
场景 2:调试问题
# 查看日志
openclaw logs --tail 50
# 检查配置
openclaw config check
# 测试连接
openclaw test --model deepseek-chat
场景 3:批量处理
# 批量对话
openclaw chat --batch --file prompts.txt
# 批量测试
openclaw test --batch
场景 4:管理监控
# 查看状态
openclaw status
# 查看统计
openclaw stats
# 查看日志
openclaw logs -f
💬 你常用哪些命令?评论区分享!
🎯 需要 CLI 优化服务?微信:yang1002378395