CLI 操作与命令分层
为什么单独做这一页
OpenClaw CLI 覆盖面广(安装、配置、网关、渠道、会话、工具、安全、节点)。 将命令按运维场景分层后,更适合团队日常执行。
参考:
命令分层
入门层
bash
# 安装与初始化
openclaw onboard # 交互式配置向导
openclaw onboard --install-daemon # 安装为系统服务
# 启动与访问
openclaw dashboard # 打开控制台
openclaw status # 查看整体状态
# 基础诊断
openclaw gateway status # 网关状态
openclaw doctor # 系统诊断配置层
bash
# 配置管理
openclaw config list # 列出所有配置
openclaw config get <key> # 获取配置值
openclaw config set <key> <value> # 设置配置值
openclaw config export # 导出配置
openclaw config import # 导入配置
openclaw config validate # 验证配置
openclaw config reload # 重载配置
# 密钥管理
openclaw secrets list # 列出密钥(脱敏)
openclaw secrets set <key> # 设置密钥
openclaw secrets rotate <key> # 轮换密钥
openclaw secrets validate # 验证密钥有效性运行层
bash
# 网关管理
openclaw gateway start # 启动网关
openclaw gateway stop # 停止网关
openclaw gateway restart # 重启网关
openclaw gateway status # 网关状态
openclaw gateway status --deep # 深度检查
openclaw gateway logs # 网关日志
# 渠道管理
openclaw channels list # 列出渠道
openclaw channels status # 渠道状态
openclaw channels status --probe # 探测渠道连接
openclaw channels pair <name> # 配对渠道
openclaw channels unpair <name> # 解除配对
# 会话管理
openclaw sessions list # 列出会话
openclaw sessions clear # 清除会话
openclaw sessions export # 导出会话工具层
bash
# 工具管理
openclaw tools list # 列出可用工具
openclaw tools profile # 查看当前 profile
openclaw tools profile <name> # 设置 profile
# 技能管理
openclaw skills list # 列出技能
openclaw skills create <name> # 创建技能
openclaw skills test <name> # 测试技能
openclaw skills publish <name> # 发布技能
openclaw skills install <name> # 安装技能
# 插件管理
openclaw plugins list # 列出插件
openclaw plugins install <name> # 安装插件
openclaw plugins update <name> # 更新插件
openclaw plugins remove <name> # 移除插件安全层
bash
# 安全审计
openclaw security audit # 基础安全审计
openclaw security audit --deep # 深度审计
openclaw security audit --fix # 自动修复
# 权限检查
openclaw security check-tools # 检查工具权限
openclaw security check-channels # 检查渠道安全
openclaw security check-secrets # 检查密钥存储诊断层
bash
# 系统诊断
openclaw doctor # 全面诊断
openclaw health # 健康检查
openclaw logs --follow # 实时日志
openclaw logs --filter <pattern> # 过滤日志
openclaw logs --export # 导出日志
# 网络诊断
openclaw diagnose network # 网络连接诊断
openclaw diagnose providers # Provider 连接诊断
openclaw diagnose channels # 渠道连接诊断
# 性能诊断
openclaw stats # 统计信息
openclaw stats usage # 使用统计
openclaw stats cost # 成本统计常用命令组合
每日检查
bash
# 快速健康检查
openclaw status && openclaw gateway status && openclaw channels status部署前检查
bash
# 完整部署检查
openclaw config validate && \
openclaw doctor && \
openclaw security audit && \
openclaw channels status --probe故障排查
bash
# 故障诊断流程
openclaw gateway status --deep
openclaw logs --follow --filter error
openclaw diagnose network
openclaw doctor日志分析
bash
# 查看错误日志
openclaw logs --filter error --tail 100
# 查看特定渠道日志
openclaw logs --filter "channel:discord" --tail 50
# 导出日志分析
openclaw logs export --start "2026-03-08T00:00:00" --end "2026-03-08T23:59:59"输出格式
bash
# JSON 输出(适合脚本处理)
openclaw status --json
openclaw channels list --json
# 表格输出(适合查看)
openclaw sessions list --table
# 安静模式(只输出结果)
openclaw config get gateway.port --quiet命令别名
bash
# 常用别名(可添加到 ~/.bashrc 或 ~/.zshrc)
alias ocl='openclaw'
alias ocls='openclaw status'
alias oclg='openclaw gateway'
alias oclc='openclaw channels'
alias ocll='openclaw logs --follow'
alias oclt='openclaw tools'
alias ocls='openclaw skills'推荐的团队约定
变更前检查
bash
# 任何生产变更前执行
openclaw status && \
openclaw doctor && \
openclaw security audit故障处理
bash
# 任何生产故障先保留日志
openclaw logs export --output incident-$(date +%Y%m%d-%H%M%S).log
# 然后再做诊断
openclaw gateway status --deep
openclaw doctor自动化脚本
bash
#!/bin/bash
# daily-health-check.sh
echo "=== OpenClaw Daily Health Check ==="
echo "Time: $(date)"
echo ""
echo "1. Gateway Status:"
openclaw gateway status --json | jq '.status, .uptime'
echo ""
echo "2. Channels Status:"
openclaw channels status --json | jq '.[] | {name: .name, status: .status}'
echo ""
echo "3. Error Count (last 24h):"
openclaw logs --filter error --since 24h | wc -l
echo ""
echo "4. Security Audit:"
openclaw security audit --json | jq '.issues | length'
echo ""
echo "=== Check Complete ==="开发者/产品经理协作点
- 开发者:维护命令手册和自动化脚本
- 产品经理:维护"命令触发的业务流程"与审批门槛
