知识库 · AI 智能体
OpenClaw 命令行手册
OpenClaw 完整命令行手册,涵盖终端 CLI 命令(setup、onboard、config、channels、agents 等)和 Discord 等频道的斜杠命令。包含全局参数、安装配置、通道管理及使用示例。
OpenClaw 命令行手册
3月15日修改
作者:小ai
建议复制全文制作成一个可视化的html 更方便使用
第一部分:终端命令(CLI)
以下命令在终端(Terminal / Shell)中运行,用于管理 OpenClaw 的安装、配置、服务和设备。
📦 全局参数
所有 CLI 命令都支持以下全局参数:
参数 | 说明 |
|---|
🚀 安装与初始化
setup
初始化配置和工作区。
选项:
--workspace <dir> - 指定工作区路径(默认 ~/.openclaw/workspace)
--wizard - 运行入职向导
--non-interactive - 非交互模式运行向导
--mode <local|remote> - 向导模式
--remote-url <url> - 远程 Gateway URL
--remote-token <token> - 远程 Gateway token
示例:
代码块
openclaw setup --wizard
openclaw setup --workspace /custom/path --non-interactiveonboard
交互式向导,设置 gateway、工作区和技能。
选项:
--workspace <dir> - 工作区路径
--reset - 重置配置和凭证
--reset-scope <config|config+creds+sessions|full> - 重置范围
--non-interactive - 非交互模式
--mode <local|remote> - 运行模式
--flow <quickstart|advanced|manual> - 流程类型
--auth-choice <...> - 认证方式选择
--gateway-port <port> - Gateway 端口
--gateway-bind <loopback|lan|tailnet|auto> - 绑定模式
--gateway-auth <token|password> - 认证方式
--install-daemon - 安装守护进程
--skip-channels - 跳过通道配置
--skip-skills - 跳过技能配置
示例:
代码块
openclaw onboard --flow quickstart
openclaw onboard --mode remote --remote-url https://gateway.example.comconfigure
交互式配置向导(模型、通道、技能、Gateway)。
⚙️ 配置管理
config get
获取配置值。
代码块
openclaw config get <path>
openclaw config get agents.defaults.model.primaryconfig set
设置配置值。
代码块
openclaw config set <path> <value>
openclaw config set agents.defaults.model.primary zai/glm-4.7config unset
移除配置值。
代码块
openclaw config unset <path>config file
打印当前使用的配置文件路径。
config validate
验证当前配置(不启动 Gateway)。
代码块
openclaw config validate --json📱 通道管理
channels list
列出已配置的通道和账号。
代码块
openclaw channels list
openclaw channels list --json
openclaw channels list --no-usagechannels status
检查 Gateway 可达性和通道健康状态。
代码块
openclaw channels status
openclaw channels status --probechannels logs
显示通道最近的日志。
代码块
openclaw channels logs --channel all --lines 200
openclaw channels logs --channel discord --jsonchannels add
添加新通道账号(非交互模式)。
选项:
--channel <name> - 通道类型(whatsapp/telegram/discord/googlechat/slack/signal/imessage/msteams)
--account <id> - 账号 ID
--name <label> - 显示名称
--token <token> - Bot token
示例:
代码块
openclaw channels add --channel telegram --account alerts --name "Alerts Bot" --token $TELEGRAM_BOT_TOKEN
openclaw channels add --channel discord --account work --name "Work Bot" --token $DISCORD_BOT_TOKENchannels remove
移除通道账号。
代码块
openclaw channels remove --channel discord --account work
openclaw channels remove --channel discord --account work --deletechannels login
交互式通道登录(WhatsApp Web)。
代码块
openclaw channels login --channel whatsappchannels logout
登出通道会话。
代码块
openclaw channels logout --channel whatsapp🤖 Agent 管理
agents list
列出已配置的 agent。
代码块
openclaw agents list
openclaw agents list --bindings --jsonagents add
添加新的独立 agent。
选项:
--workspace <dir> - 工作区路径(必填)
--model <id> - 默认模型
--agent-dir <dir> - agent 目录
--bind <channel[:accountId]> - 绑定通道(可重复)
--non-interactive - 非交互模式
示例:
代码块
openclaw agents add --workspace /path/to/agent --bind discord:work
openclaw agents add my-agent --workspace /custom/path --model openrouter/auto --non-interactiveagents delete
删除 agent 及其工作区和状态。
代码块
openclaw agents delete <id>
openclaw agents delete my-agent --forceagents bindings
列出路由绑定。
代码块
openclaw agents bindings
openclaw agents bindings --agent my-agent --jsonagents bind
添加路由绑定。
代码块
openclaw agents bind --agent my-agent --bind telegram
openclaw agents bind --agent my-agent --bind discord:alerts --bind whatsapp:personalagents unbind
移除路由绑定。
代码块
openclaw agents unbind --agent my-agent --bind discord:work🧠 模型管理
models
查看模型状态(models status 的别名)。
models list
列出可用模型。
选项:
--all - 显示所有模型
--local - 仅本地模型
--provider <name> - 按提供者筛选
--json - JSON 输出
示例:
代码块
openclaw models list --provider anthropic
openclaw models list --jsonmodels status
显示认证状态和模型配置。
选项:
--json - JSON 输出
--plain - 纯文本输出
--check - 检查过期状态(退出码 1=过期/缺失,2=即将过期)
--probe - 探测配置的认证配置
--probe-provider <name> - 探测指定提供者
--probe-profile <id> - 探测指定 profile
示例:
代码块
openclaw models status
openclaw models status --probe
openclaw models status --checkmodels set
设置默认模型。
代码块
openclaw models set zai/glm-4.7models set-image
设置默认图像模型。
代码块
openclaw models set-image openrouter/openai/dall-e-3models aliases
管理模型别名。
代码块
openclaw models aliases list
openclaw models aliases add fast zai/glm-4.7-mini
openclaw models aliases remove fastmodels fallbacks
管理模型备选列表。
代码块
openclaw models fallbacks list
openclaw models fallbacks add openrouter/claude-3.5-sonnet
openclaw models fallbacks remove zai/glm-4.7
openclaw models fallbacks clearmodels image-fallbacks
管理图像模型备选列表。
代码块
openclaw models image-fallbacks list
openclaw models image-fallbacks add openrouter/openai/dall-e-3models scan
扫描 OpenRouter 的免费模型。
选项:
--min-params <b> - 最小参数量
--max-age-days <days> - 最大模型年龄
--provider <name> - 按提供者筛选
--max-candidates <n> - 最大候选数
--set-default - 设置为默认模型
--set-image - 设置为默认图像模型
--yes - 自动确认
--no-input - 无输入模式
示例:
代码块
openclaw models scan --provider anthropic --set-default
openclaw models scan --yes --no-inputmodels auth add
添加模型认证。
代码块
openclaw models auth addmodels auth setup-token
使用 Anthropic setup-token 认证。
代码块
openclaw models auth setup-token --provider anthropicmodels auth paste-token
粘贴 token 认证。
代码块
openclaw models auth paste-token --provider openai --profile-id my-profile --expires-in 365dmodels auth order
管理认证顺序。
代码块
openclaw models auth order get --provider anthropic
openclaw models auth order set --provider openai --agent my-agent profile1 profile2
openclaw models auth order clear --provider anthropic📊 系统与健康
status
显示链接的会话健康状态和最近收件人。
选项:
--json - JSON 输出
--all - 完整诊断
--deep - 深度探测通道
--usage - 显示提供者使用情况/配额
--verbose - 详细输出
--timeout <ms> - 超时时间
示例:
代码块
openclaw status
openclaw status --deep --usage
openclaw status --jsohealth
从运行的 Gateway 获取健康状态。
选项:
--json - JSON 输出
--verbose - 详细输出
--timeout <ms> - 超时时间
doctor
健康检查和快速修复(配置 + Gateway + 遗留服务)。
选项:
--no-workspace-suggestions - 禁用工作区提示
--yes - 自动接受默认值
--non-interactive - 跳过提示
--deep - 扫描系统服务的额外 Gateway 安装
示例:
代码块
openclaw doctor
openclaw doctor --deep --yeslogs
通过 RPC 追踪 Gateway 文件日志。
选项:
--follow - 持续跟踪
--limit <n> - 限制行数
--plain - 纯文本输出
--json - JSON 输出
--no-color - 禁用颜色
示例:
代码块
openclaw logs --follow
openclaw logs --limit 200
openclaw logs --json🌐 Gateway 服务
gateway
运行 WebSocket Gateway。
选项:
--port <port> - 监听端口
--bind <loopback|tailnet|lan|auto> - 绑定模式
--token <token> - 认证 token
--auth <token|password> - 认证方式
--password <password> - 密码
--password-file <path> - 密码文件路径
--tailscale <off|serve|funnel> - Tailscale 模式
--dev - 开发模式
--force - 强制占用端口
--verbose - 详细输出
--ws-log <auto|full|compact> - WebSocket 日志级别
示例:
代码块
openclaw gateway --bind lan --port 3000
openclaw gateway --tailscale serve --devgateway status
显示 Gateway 状态。
代码块
openclaw gateway status
openclaw gateway status --jsongateway install
安装 Gateway 服务(launchd/systemd)。
选项:
--port <port> - 端口
--runtime <node|bun> - 运行时
--token <token> - 认证 token
--force - 强制安装
--json - JSON 输出
gateway uninstall
卸载 Gateway 服务。
代码块
openclaw gateway uninstallgateway start / stop / restart
管理 Gateway 服务。
代码块
openclaw gateway start
openclaw gateway stop
openclaw gateway restartgateway call
调用 Gateway RPC 方法。
代码块
openclaw gateway call config.get
openclaw gateway call config.apply --params '{"key":"value"}'gateway health
检查 Gateway 健康状态。
gateway probe
探测 Gateway 服务。
gateway discover
发现 Gateway 实例。
🎯 节点与设备
nodes status
显示节点状态。
选项:
--connected - 仅显示已连接的节点
--last-connected <duration> - 最近连接的节点
nodes list
列出节点。
代码块
openclaw nodes list --connected
openclaw nodes list --last-connected 1hnodes describe
查看节点详细信息。
代码块
openclaw nodes describe --node node-001nodes pending
列出待审批的节点请求。
nodes approve / reject
审批或拒绝节点请求。
代码块
openclaw nodes approve <requestId>
openclaw nodes reject <requestId>nodes rename
重命名节点。
代码块
openclaw nodes rename --node node-001 --name "New Name"nodes invoke
在节点上调用命令。
代码块
openclaw nodes invoke --node node-001 --command system.exec --params '{"command":"ls -la"}'nodes run
在节点上运行命令。
代码块
openclaw nodes run --node node-001 --cwd /tmp --command-timeout 60000 python script.pynodes notify
发送通知到节点(macOS only)。
代码块
openclaw nodes notify --node node-001 --title "Hello" --body "Message"nodes camera list / snap / clip
节点摄像头控制。
代码块
openclaw nodes camera list --node node-001
openclaw nodes camera snap --node node-001 --facing front --max-width 1920
openclaw nodes camera clip --node node-001 --duration 10snodes canvas snapshot / present / hide / navigate / eval / a2ui
节点画布和屏幕操作。
代码块
openclaw nodes canvas snapshot --node node-001 --format png
openclaw nodes canvas present --node node-001 --target https://example.com
openclaw nodes canvas hide --node node-001
openclaw nodes canvas navigate https://example.com --node node-001
openclaw nodes canvas eval "document.title" --node node-001nodes screen record
节点屏幕录制。
代码块
openclaw nodes screen record --node node-001 --duration 30s --fps 30nodes location get
获取节点位置信息。
代码块
openclaw nodes location get --node node-001 --accuracy precise🌐 浏览器控制
browser status / start / stop
管理浏览器服务。
代码块
openclaw browser status
openclaw browser start
openclaw browser stopbrowser tabs
列出浏览器标签页。
代码块
openclaw browser tabsbrowser open
打开 URL。
代码块
openclaw browser open https://example.combrowser focus
聚焦到指定标签页。
代码块
openclaw browser focus <targetId>browser close
关闭标签页。
代码块
openclaw browser close <targetId>browser screenshot
截图。
代码块
openclaw browser screenshot
openclaw browser screenshot --full-page
openclaw browser screenshot --target-id <id> --type pngbrowser snapshot
获取页面快照。
代码块
openclaw browser snapshot --format aria
openclaw browser snapshot --target-id <id> --limit 50browser navigate
导航到 URL。
代码块
openclaw browser navigate https://example.com --target-id <id>browser resize
调整窗口大小。
代码块
openclaw browser resize 1920 1080browser click / type / press / hover / drag / select
页面交互操作。
代码块
openclaw browser click <ref> --double
openclaw browser type <ref> "Hello" --submit
openclaw browser press Enter
openclaw browser hover <ref>
openclaw browser drag <startRef> <endRef>
openclaw browser select <ref> option1 option2browser upload
上传文件。
代码块
openclaw browser upload /path/to/file.png --ref <input-ref>browser fill
填充表单。
代码块
openclaw browser fill --fields '{"name":"John","email":"john@example.com"}'browser dialog
处理对话框。
代码块
openclaw browser dialog --accept
openclaw browser dialog --dismiss --prompt "Enter textbrowser wait
等待条件。
代码块
openclaw browser wait --time 1000
openclaw browser wait --text "Loading..." --text-gonebrowser evaluate / execute
执行 JavaScript。
代码块
openclaw browser evaluate --fn "document.title" --ref <ref>browser console
控制台操作。
代码块
openclaw browser console --level info --target-id <id>browser pdf
导出 PDF。
代码块
openclaw browser pdf --target-id <id>browser profiles / create-profile / delete-profile
管理浏览器配置文件。
代码块
openclaw browser profiles
openclaw browser create-profile --name MyProfile --color "#FF0000"
openclaw browser delete-profile --name MyProfilebrowser reset-profile
重置浏览器配置文件。
代码块
openclaw browser reset-profile📅 计划任务(Cron)
cron status
显示 cron 服务状态。
代码块
openclaw cron status --jsoncron list
列出计划任务。
代码块
openclaw cron list
openclaw cron list --all --jsoncron add
添加计划任务。
必需参数:
--name <name> - 任务名称
以下之一:--at <time> | --every <duration> | --cron <expression>
以下之一:--system-event <event> | --message <text>
示例:
代码块
openclaw cron add --name "Daily Brief" --every 1d --message "HEARTBEAT.md"
openclaw cron add --name "Event" --at "2025-03-15T09:00:00+08:00" --message "Morning"
openclaw cron add --name "Cron Job" --cron "0 9 * * *" --message "Run daily"cron edit
编辑计划任务。
代码块
openclaw cron edit <id> --message "New message"cron rm
删除计划任务。
代码块
openclaw cron rm <id>cron enable / disable
启用/禁用任务。
代码块
openclaw cron enable <id>
openclaw cron disable <id>cron runs
查看任务运行历史。
代码块
openclaw cron runs --id <task-id> --limit 10cron run
手动运行任务。
代码块
openclaw cron run <id>
openclaw cron run <id> --force🔧 其他工具
memory status / index / search
管理内存向量搜索。
代码块
openclaw memory status
openclaw memory index
openclaw memory search "what did I do yesterday"system event / heartbeat / presence
系统事件和心跳控制。
代码块
openclaw system event --text "Event message" --mode now
openclaw system heartbeat enable --json
openclaw system presence --jsonsecurity audit
安全审计。
代码块
openclaw security audit
openclaw security audit --deep
openclaw security audit --fixsecrets reload / migrate / configure
密钥管理。
代码块
openclaw secrets reload
openclaw secrets migrate
openclaw secrets configureskills list / info / check
技能管理。
代码块
openclaw skills list
openclaw skills list --eligible --json
openclaw skills info weather
openclaw skills check --verboseplugins list / info / install / enable / disable / doctor
插件管理。
代码块
openclaw plugins list
openclaw plugins info <id>
openclaw plugins install /path/to/plugin
openclaw plugins enable <id>
openclaw plugins disable <id>
openclaw plugins doctorpairing list / approve
配对管理。
代码块
openclaw pairing list --channel discord
openclaw pairing approve discord ABC123 --notifydevices list / approve / reject / remove / clear
设备管理。
代码块
openclaw devices list
openclaw devices approve <requestId>
openclaw devices reject <requestId>
openclaw devices remove <deviceId>
openclaw devices clear --yesmessage
统一消息发送和通道操作。
子命令:
send - 发送消息
poll - 创建投票
react - 添加反应
reactions - 查看反应
read - 标记已读
edit - 编辑消息
delete - 删除消息
pin / unpin - 置顶/取消置顶
pins - 查看置顶
permissions - 权限管理
search - 搜索消息
timeout - 设置超时
kick - 踢出成员
ban - 封禁用户
示例:
代码块
openclaw message send --target +1234567890 --message "Hello"
openclaw message poll --channel discord --target channel:123 --poll-question "Choice?" --poll-option A --poll-option Bagent
运行 agent 轮次。
选项:
--message <text> - 消息内容(必填)
--to <dest> - 目标
--session-id <id> - 会话 ID
--thinking <off|minimal|low|medium|high|xhigh> - 推理级别
--verbose <on|full|off> - 详细输出
--channel <whatsapp|telegram|discord...> - 通道
--local - 本地运行
--deliver - 递送消息
--json - JSON 输出
示例:
代码块
openclaw agent --message "Help me with coding" --thinking medium
openclaw agent --message "Test" --to session:xyz --deliveracp
运行 ACP 桥接器(连接 IDE 到 Gateway)。详见 openclaw acp --help。
sessions
列出会话。
代码块
openclaw sessions --verbose
openclaw sessions --active 60 --jsondocs
搜索实时文档索引。
代码块
openclaw docs search query
openclaw docs gateway authenticationtui
打开终端 UI 连接到 Gateway。
代码块
openclaw tui
openclaw tui --session <key> --deliver第二部分:斜杠命令(Slash Commands)
以下命令在频道(飞书 等)的聊天窗口中直接输入,用于实时控制会话和 Agent 行为。
📋 会话管理(Session)
命令 | 说明 |
|---|
⚙️ 选项配置(Options)
命令 | 说明 |
|---|
📊 状态查询(Status)
命令 | 说明 |
|---|
🔧 管理(Management)
命令 | 说明 |
|---|
🎙️ 媒体(Media)
命令 | 说明 |
|---|
🛠️ 工具(Tools)
命令 | 说明 |
|---|
🚢 停靠切换(Docks)
命令 | 说明 |
|---|
🔌 飞书插件(Plugins)
命令 | 说明 |
|---|
🔗 相关链接
官方网站:https://openclaw.ai