OpenClaw的核心指令使用方法詳解
一、OpenClaw 簡介
OpenClaw 是一個開源的個人 AI 助手框架,支持通過命令行界面(CLI)進行全面的配置、管理和操作。OpenClaw 能夠在本地設備運行,并通過多種通信渠道回復消息,包括 WhatsApp、Telegram、Slack、Discord、Google Chat、Signal、iMessage 等。此外,它還支持在 macOS/iOS/Android 上進行語音交互,并提供實時畫布界面供用戶控制。
核心特點
- 支持多種通信平臺(WhatsApp、Telegram、Discord 等)
- 本地運行,響應速度快
- 始終在線
- 支持語音喚醒和對話模式
- 高度可擴展的技能系統(tǒng)
二、安裝配置
2.1 環(huán)境要求
在安裝 OpenClaw 之前,需要確保滿足以下前置條件:
| 要求 | 說明 |
|---|---|
| 操作系統(tǒng) | macOS、Linux、Windows(通過 WSL2) |
| Node.js | 版本必須 >= 22 |
| 包管理器 | npm、pnpm 或 bun |
| 網(wǎng)絡連接 | 用于下載依賴和配置通信渠道 |
| 推薦 | Brave Search API 密鑰(用于網(wǎng)頁搜索) |
2.2 安裝步驟
Linux/macOS 系統(tǒng)安裝:
curl -fsSL https://openclaw.ai/install.sh | bash
Windows 系統(tǒng)安裝(PowerShell):
iwr -useb https://openclaw.ai/install.ps1 | iex
替代方案(全局 npm 安裝):
npm install -g openclaw@latest # 或 pnpm add -g openclaw@latest
2.3 初始化配置
安裝完成后,運行引導設置工具進行初始化配置:
openclaw onboard --install-daemon
該命令會完成以下配置:
- 創(chuàng)建必要的配置文件
- 設置工作區(qū)
- 安裝為守護進程(在后臺自動運行)
- 配置網(wǎng)關令牌
向?qū)崾驹O置:本地或遠程網(wǎng)關、認證信息(支持 OpenAI Codex 訂閱或 API 密鑰)、通信頻道(WhatsApp QR 登錄、Telegram/Discord 機器人令牌等)、后臺服務配置。
2.4 啟動 Gateway
配置完成后,啟動 OpenClaw Gateway:
# 檢查網(wǎng)關狀態(tài) openclaw gateway status # 手動前臺運行 openclaw gateway --port 18789 --verbose
Gateway 啟動后,可以通過以下地址訪問 Dashboard:http://127.0.0.1:18789/
三、全局選項
OpenClaw CLI 提供以下全局選項:
| 選項 | 說明 |
|---|---|
--dev | 在 ~/.openclaw-dev 下隔離狀態(tài),并轉移默認端口 |
--profile <name> | 在 ~/.openclaw-<name> 下隔離狀態(tài) |
--no-color | 禁用 ANSI 顏色輸出 |
--update | 執(zhí)行 openclaw update 更新程序 |
-V, --version | 打印版本信息并退出 |
四、核心指令系統(tǒng)
4.1 設置與入門命令
| 命令 | 說明 | 使用場景 |
|---|---|---|
openclaw setup | 初始化配置和工作區(qū) | 首次安裝時設置基礎配置 |
openclaw onboard | 交互式向?qū)гO置 | 完整引導配置過程 |
openclaw configure | 交互式配置向?qū)?/td> | 配置模型、頻道、技能、網(wǎng)關 |
openclaw config | 非交互式配置 | get/set/unset 操作 |
openclaw doctor | 健康檢查和快速修復 | 診斷和修復問題 |
setup 常用選項:
openclaw setup --workspace <path> # 指定工作區(qū)路徑(默認 ~/.openclaw/workspace) openclaw setup --wizard # 運行入門向?qū)? openclaw setup --non-interactive # 無提示運行 openclaw setup --mode <mode> # 向?qū)J? openclaw setup --remote-url <url> # 遠程 Gateway URL openclaw setup --remote-token <token> # 遠程 Gateway token
config 子命令使用方法:
# 查看配置值 openclaw config get <key> # 設置配置值 openclaw config set <key> <value> # 移除配置 openclaw config unset <key>
4.2 消息與代理命令
| 命令 | 說明 |
|---|---|
openclaw message | 統(tǒng)一出站消息和頻道操作 |
openclaw agent | 通過 Gateway 運行單個 agent 回合 |
openclaw agents | 管理隔離的 agents |
openclaw status | 顯示鏈接會話健康狀況和最近收件人 |
openclaw health | 從運行中的 Gateway 獲取健康狀態(tài) |
openclaw sessions | 列出存儲的對話會話 |
openclaw acp | 運行連接 IDEs 到 Gateway 的 ACP 橋接 |
message 子命令包括:
# 發(fā)送消息 openclaw message send --target +15555550123 --message "Hello from OpenClaw" # 讀取消息 openclaw message read # 搜索消息 openclaw message search <query> # 消息反應 openclaw message react <message-id> <emoji> # 編輯消息 openclaw message edit <message-id> <new-content> # 刪除消息 openclaw message delete <message-id> # 置頂消息 openclaw message pin <message-id> openclaw message unpin <message-id> # 消息超時設置 openclaw message timeout <channel> <seconds> # 踢出成員 openclaw message kick <member-id> # 封禁成員 openclaw message ban <member-id> # 線程操作 openclaw message thread <threadId> # Emoji 操作 openclaw message emoji <emojiId> # 貼紙操作 openclaw message sticker <stickerId> # 角色操作 openclaw message role <roleId> # 頻道操作 openclaw message channel <channelId> # 成員信息 openclaw message member info # 語音狀態(tài) openclaw message voice status # 事件操作 openclaw message event <eventId>
agent 命令使用:
# 基本用法 openclaw agent --message <text> --to <recipient> # 完整選項 openclaw agent --message <text> --to <recipient> \ --session-id <id> \ --thinking <text> \ # GPT-5.2 + Codex 模型專用 --verbose \ --channel <channel> \ --local \ # 嵌入式本地運行 --deliver \ --json \ --timeout <seconds>
status 命令選項:
openclaw status --json # JSON 格式輸出 openclaw status --all # 完整診斷 openclaw status --deep # 探測頻道 openclaw status --usage # 顯示模型使用量 openclaw status --timeout <seconds> openclaw status --verbose openclaw status --debug
agents 子命令:
# 列出 agents openclaw agents list [--json] [--bindings] # 添加新 agent openclaw agents add [name] # 刪除 agent openclaw agents delete <id> [--force]
4.3 Gateway 管理命令
| 命令 | 說明 |
|---|---|
openclaw gateway | 運行 WebSocket Gateway |
openclaw logs | 通過 RPC 尾隨 Gateway 文件日志 |
gateway 常用選項:
# 指定端口和地址 openclaw gateway --port 18789 --bind 0.0.0.0 # 指定認證令牌 openclaw gateway --token <your-token> # 啟用認證 openclaw gateway --auth --password <password> # 啟用 Tailscale openclaw gateway --tailscale # 重置配置 openclaw gateway --reset # 強制執(zhí)行 openclaw gateway --force # 詳細輸出 openclaw gateway --verbose # Claude CLI 日志 openclaw gateway --claude-cli-logs # WebSocket 日志 openclaw gateway --ws-log <path> # 緊湊輸出 openclaw gateway --compact # 原始流 openclaw gateway --raw-stream openclaw gateway --raw-stream-path <path>
gateway service 子命令:
openclaw gateway status # 查看狀態(tài) openclaw gateway install # 安裝服務 openclaw gateway uninstall # 卸載服務 openclaw gateway start # 啟動服務 openclaw gateway stop # 停止服務 openclaw gateway restart # 重啟服務
logs 命令使用:
openclaw logs --follow # 實時跟蹤日志 openclaw logs --limit 200 # 限制輸出行數(shù) openclaw logs --plain # 純文本格式 openclaw logs --json # JSON 格式輸出 openclaw logs --no-color # 禁用顏色
4.4 模型管理命令
| 命令 | 說明 |
|---|---|
openclaw models | 等同于 models status |
openclaw models list | 列出可用模型 |
openclaw models status | 顯示模型狀態(tài)和認證信息 |
openclaw models set <model> | 設置默認主模型 |
openclaw models set-image <model> | 設置默認圖像模型 |
openclaw models scan | 掃描可用模型 |
openclaw models auth | 管理模型認證 |
models 子命令:
# 列出所有模型 openclaw models list --all openclaw models list --local openclaw models list --provider <name> openclaw models list --json openclaw models list --plain # 查看模型狀態(tài) openclaw models status --json openclaw models status --plain openclaw models status --check openclaw models status --probe # 設置默認模型 openclaw models set claude-3-5-sonnet-20241022 openclaw models set-image claude-3-5-sonnet-20241022 # 模型別名管理 openclaw models aliases list openclaw models aliases add <alias> <model> openclaw models aliases remove <alias> # 回退模型管理 openclaw models fallbacks list openclaw models fallbacks add <model> openclaw models fallbacks remove <model> openclaw models fallbacks clear # 圖像回退模型管理 openclaw models image-fallbacks list openclaw models image-fallbacks add <model> openclaw models image-fallbacks remove <model> openclaw models image-fallbacks clear # 掃描可用模型 openclaw models scan --min-params <n> openclaw models scan --max-age-days <n> openclaw models scan --provider <name> openclaw models scan --set-default openclaw models scan --set-image # 認證管理 openclaw models auth add openclaw models auth setup-token openclaw models auth paste-token # 認證順序 openclaw models auth order get openclaw models auth order set <order> openclaw models auth order clear
4.5 頻道管理命令
OpenClaw 支持多種通信頻道,包括 WhatsApp、Telegram、Discord、Google Chat、Slack、Mattermost、Signal、iMessage、Microsoft Teams 等。
| 命令 | 說明 |
|---|---|
openclaw channels list | 列出所有配置的頻道 |
openclaw channels status | 查看頻道狀態(tài) |
openclaw channels logs | 查看頻道日志 |
openclaw channels add | 添加新頻道 |
openclaw channels remove | 移除頻道 |
openclaw channels login | 頻道登錄(QR 碼) |
openclaw channels logout | 頻道登出 |
添加頻道示例:
# 添加 Telegram 頻道 openclaw channels add --channel telegram --account alerts --name "Alerts Bot" --token $TELEGRAM_BOT_TOKEN # 添加 Discord 頻道 openclaw channels add --channel discord --account work --name "Work Bot" --token $DISCORD_BOT_TOKEN # 添加 WhatsApp openclaw channels add --channel whatsapp --account personal # 添加 Slack openclaw channels add --channel slack --account team --token $SLACK_BOT_TOKEN # 檢查頻道連接狀態(tài) openclaw channels status --probe
WhatsApp 登錄:
openclaw channels login # 然后掃描 QR 碼:設置 → 已關聯(lián)的設備
4.6 技能管理命令
Skills(技能)是賦予 OpenClaw 執(zhí)行特定任務能力的插件。
| 命令 | 說明 |
|---|---|
openclaw skills list | 列出可用技能 |
openclaw skills info <skill> | 查看技能詳情 |
openclaw skills check | 檢查技能狀態(tài) |
openclaw skills list openclaw skills info <skill-name> openclaw skills check [--eligible] [--json] [-v]
4.7 插件管理命令
| 命令 | 說明 |
|---|---|
openclaw plugins list | 列出已安裝插件 |
openclaw plugins info <plugin> | 查看插件詳情 |
openclaw plugins install <plugin> | 安裝插件 |
openclaw plugins enable <plugin> | 啟用插件 |
openclaw plugins disable <plugin> | 禁用插件 |
openclaw plugins doctor | 診斷插件問題 |
4.8 內(nèi)存管理命令
| 命令 | 說明 |
|---|---|
openclaw memory status | 顯示索引統(tǒng)計 |
openclaw memory index | 重新索引內(nèi)存文件 |
openclaw memory search <query> | 語義搜索內(nèi)存 |
4.9 定時任務命令
| 命令 | 說明 |
|---|---|
openclaw cron status | 查看定時任務狀態(tài) |
openclaw cron list | 列出所有定時任務 |
openclaw cron add | 添加新定時任務 |
openclaw cron edit <id> | 編輯定時任務 |
openclaw cron rm <id> | 刪除定時任務 |
openclaw cron enable <id> | 啟用定時任務 |
openclaw cron disable <id> | 禁用定時任務 |
openclaw cron runs --id <id> | 查看任務執(zhí)行記錄 |
openclaw cron run <id> | 手動執(zhí)行定時任務 |
添加定時任務示例:
# 使用 at 指定時間 openclaw cron add --name "daily-report" --at "0 9 * * *" --system-event "daily-report" # 使用 every 指定間隔 openclaw cron add --name "check-updates" --every 1h --message "check-updates" # 使用 cron 表達式 openclaw cron add --name "weekly-task" --cron "0 10 * * 1" --system-event "weekly-task"
4.10 節(jié)點管理命令
| 命令 | 說明 |
|---|---|
openclaw nodes status | 查看節(jié)點狀態(tài) |
openclaw nodes list | 列出所有節(jié)點 |
openclaw nodes describe --node <id> | 查看節(jié)點詳情 |
openclaw nodes pending | 查看待批準節(jié)點 |
openclaw nodes approve <id> | 批準節(jié)點 |
openclaw nodes reject <id> | 拒絕節(jié)點 |
openclaw nodes rename | 重命名節(jié)點 |
openclaw nodes invoke | 調(diào)用節(jié)點命令 |
openclaw nodes run | 在節(jié)點上運行命令 |
openclaw nodes notify | 通知節(jié)點 |
openclaw nodes camera | 節(jié)點相機控制 |
openclaw nodes canvas | 節(jié)點畫布控制 |
openclaw nodes screen | 節(jié)點屏幕控制 |
openclaw nodes location | 獲取節(jié)點位置 |
node 子命令:
openclaw node run --host <host> --port 18789 openclaw node status openclaw node install [--host <host>] [--port <port>] [--tls] openclaw node uninstall openclaw node stop openclaw node restart
4.11 瀏覽器控制命令
OpenClaw 提供強大的瀏覽器控制功能:
| 命令 | 說明 |
|---|---|
openclaw browser status | 查看瀏覽器狀態(tài) |
openclaw browser start | 啟動瀏覽器 |
openclaw browser stop | 停止瀏覽器 |
openclaw browser reset-profile | 重置瀏覽器配置 |
openclaw browser tabs | 查看標簽頁 |
openclaw browser open <url> | 打開網(wǎng)址 |
openclaw browser focus <targetId> | 聚焦標簽頁 |
openclaw browser close | 關閉標簽頁 |
openclaw browser profiles | 管理瀏覽器配置 |
openclaw browser create-profile | 創(chuàng)建配置 |
openclaw browser delete-profile | 刪除配置 |
瀏覽器檢查和操作命令:
# 截圖 openclaw browser screenshot [targetId] openclaw browser snapshot # 導航和操作 openclaw browser navigate <url> openclaw browser resize <width> <height> openclaw browser click <x> <y> openclaw browser type <text> openclaw browser press <key> openclaw browser hover <x> <y> openclaw browser drag <start> <end> openclaw browser select <select> openclaw browser upload <file> openclaw browser fill --fields <json> # 對話框處理 openclaw browser dialog --accept|--dismiss # 等待和執(zhí)行 openclaw browser wait openclaw browser evaluate --fn <function> openclaw browser console # 導出 openclaw browser pdf
4.12 系統(tǒng)命令
| 命令 | 說明 |
|---|---|
openclaw system event | 入隊系統(tǒng)事件并觸發(fā)心跳 |
openclaw system heartbeat | 心跳控制 |
openclaw system presence | 列出系統(tǒng)在線狀態(tài) |
openclaw system event --text <text> [--mode <mode>] [--json] openclaw system heartbeat last|enable|disable openclaw system presence
4.13 審批管理命令
| 命令 | 說明 |
|---|---|
openclaw approvals get | 獲取審批設置 |
openclaw approvals set | 設置審批配置 |
openclaw approvals allowlist add | 添加到允許列表 |
openclaw approvals allowlist remove | 從允許列表移除 |
4.14 沙箱命令
| 命令 | 說明 |
|---|---|
openclaw sandbox list | 列出沙箱 |
openclaw sandbox recreate | 重新創(chuàng)建沙箱 |
openclaw sandbox explain | 解釋沙箱 |
4.15 鉤子管理命令
| 命令 | 說明 |
|---|---|
openclaw hooks list | 列出鉤子 |
openclaw hooks info <hook> | 顯示鉤子詳情 |
openclaw hooks check | 檢查鉤子 |
openclaw hooks enable | 啟用鉤子 |
openclaw hooks disable | 禁用鉤子 |
openclaw hooks install | 安裝鉤子 |
openclaw hooks update | 更新鉤子 |
4.16 其他常用命令
| 命令 | 說明 |
|---|---|
openclaw docs [query] | 搜索實時文檔 |
openclaw tui | 打開終端 UI |
openclaw reset | 重置本地配置 |
openclaw uninstall | 卸載程序 |
openclaw update | 更新 OpenClaw |
openclaw security audit | 安全審計 |
openclaw pairing | 管理跨頻道 DM 配對 |
openclaw webhooks gmail | Gmail Webhook 設置 |
tui 命令選項:
openclaw tui --url <url> openclaw tui --token <token> openclaw tui --password <password> openclaw tui --session <session> openclaw tui --deliver openclaw tui --thinking <text> openclaw tui --message <text> openclaw tui --timeout-ms <ms> openclaw tui --history-limit <n>
reset 命令選項:
openclaw reset --scope <scope> openclaw reset --yes openclaw reset --non-interactive openclaw reset --dry-run
uninstall 命令選項:
openclaw uninstall --service openclaw uninstall --state openclaw uninstall --workspace openclaw uninstall --app openclaw uninstall --all openclaw uninstall --yes openclaw uninstall --non-interactive openclaw uninstall --dry-run
安全審計:
openclaw security audit # 基本審計 openclaw security audit --deep # 深度審計
配對管理:
openclaw pairing list whatsapp openclaw pairing approve whatsapp <message-id>
五、快速驗證步驟
安裝配置完成后,可以通過以下命令驗證系統(tǒng)狀態(tài):
# 檢查整體狀態(tài) openclaw status # 檢查健康狀態(tài) openclaw health # 安全審計 openclaw security audit --deep # 發(fā)送測試消息 openclaw message send --target +15555550123 --message "Hello from OpenClaw" # 查看模型狀態(tài) openclaw models status # 檢查頻道連接 openclaw channels status --probe
六、命令樹匯總
openclaw [--dev] [--profile <name>]
├── setup
├── onboard
├── configure
├── config
│ ├── get <key>
│ ├── set <key> <value>
│ └── unset <key>
├── doctor
├── security
│ └── audit
├── reset
├── uninstall
├── update
├── channels
│ ├── list
│ ├── status
│ ├── logs
│ ├── add
│ ├── remove
│ ├── login
│ └── logout
├── skills
│ ├── list
│ ├── info
│ └── check
├── plugins
│ ├── list
│ ├── info
│ ├── install
│ ├── enable
│ ├── disable
│ └── doctor
├── memory
│ ├── status
│ ├── index
│ └── search
├── message
│ ├── send
│ ├── poll
│ ├── react
│ ├── read
│ ├── edit
│ ├── delete
│ ├── pin/unpin
│ ├── search
│ ├── timeout
│ ├── kick
│ ├── ban
│ ├── thread
│ ├── emoji
│ ├── sticker
│ ├── role
│ ├── channel
│ ├── member
│ └── voice
├── agent
├── agents
│ ├── list
│ ├── add
│ └── delete
├── acp
├── status
├── health
├── sessions
├── gateway
│ ├── call
│ ├── health
│ ├── status
│ ├── probe
│ ├── discover
│ ├── install/uninstall/start/stop/restart/run
│ └── logs
├── system
│ ├── event
│ ├── heartbeat
│ └── presence
├── models
│ ├── list
│ ├── status
│ ├── set
│ ├── set-image
│ ├── aliases
│ ├── fallbacks
│ ├── image-fallbacks
│ ├── scan
│ └── auth
├── sandbox
│ ├── list
│ ├── recreate
│ └── explain
├── cron
│ ├── status
│ ├── list
│ ├── add/edit/rm
│ ├── enable/disable
│ └── runs/run
├── nodes
│ ├── status
│ ├── describe
│ ├── list
│ ├── pending
│ ├── approve/reject
│ ├── rename
│ ├── invoke
│ ├── run
│ ├── notify
│ ├── camera
│ ├── canvas
│ ├── screen
│ └── location
├── node
│ ├── run
│ ├── status
│ ├── install/uninstall/start/stop/restart
├── browser
│ ├── status/start/stop/reset-profile
│ ├── tabs/open/focus/close
│ ├── profiles
│ ├── screenshot/snapshot
│ └── navigate/click/type/press/hover/drag/select...
├── approvals
│ ├── get/set
│ └── allowlist
├── docs
├── dns
│ └── setup
├── tui
├── hooks
│ ├── list/info/check/enable/disable/install/update
├── webhooks
│ └── gmail setup/run
└── pairing
├── list
└── approve
七、常見問題處理
7.1 配置問題
如果遇到配置文件問題,可以運行診斷:
openclaw doctor
7.2 頻道連接問題
檢查頻道狀態(tài)并重新探測:
openclaw channels status openclaw channels status --probe
7.3 模型認證問題
檢查模型認證狀態(tài):
openclaw models status --check openclaw models auth add
7.4 環(huán)境變量說明
| 環(huán)境變量 | 說明 |
|---|---|
OPENCLAW_HOME | 配置根目錄 |
OPENCLAW_STATE_DIR | 狀態(tài)目錄 |
OPENCLAW_CONFIG_PATH | 配置文件路徑 |
八、參考鏈接
- OpenClaw 官網(wǎng):https://openclaw.ai/
- 官方文檔:https://docs.openclaw.ai/
- CLI 參考:https://docs.openclaw.ai/cli
- 入門指南:https://docs.openclaw.ai/start/getting-started
- ClawHub 技能市場:https://clawhub.com
九、輸出樣式說明
- ANSI 顏色和進度指示器僅在 TTY 會話中渲染
- OSC-8 超鏈接在支持的終端中可點擊
--json和--plain禁用樣式--no-color禁用 ANSI 樣式NO_COLOR=1環(huán)境變量也被支持
顏色調(diào)色板
| 名稱 | 顏色值 | 用途 |
|---|---|---|
| accent | #FF5A2D | 標題、標簽、主要高亮 |
| accentBright | #FF7A3D | 命令名稱、強調(diào) |
| accentDim | #D14A22 | 次要高亮文本 |
| info | #FF8A5B | 信息值 |
| success | #2FBF71 | 成功狀態(tài) |
| warn | #FFB020 | 警告、回退、注意力 |
| error | #E23D2D | 錯誤、失敗 |
| muted | #8B7F77 | 降強調(diào)、元數(shù)據(jù) |
到此這篇關于OpenClaw的核心指令使用方法詳解的文章就介紹到這了,更多相關OpenClaw指令使用內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章,希望大家以后多多支持腳本之家!
相關文章
OpenClaw是一個自主通信網(wǎng)關,它將WhatsApp、Telegram、Discord和iMessage等主流即時通訊應用與可編程人工智能代理連接起來,這篇文章主要為大家整理了一些openclaw常用指令2026-03-23
OpenClaw 是一個強大的 AI 助手框架,但有 40+ 核心命令,本文就來介紹一下OpenClaw 指令大全,文中通過示例代碼介紹的非常詳細,需要的朋友們下面隨著小編來一起學習學習吧2026-03-23
本文檔詳細介紹了Windows系統(tǒng)下OpenClaw的操作指令,包括基礎操作、Gateway網(wǎng)關管理、模型管理、技能管理、通道管理、Agent管理、瀏覽器自動化、定時任務、系統(tǒng)與日志以及配2026-03-16
OpenClaw常用操作命令完整速查手冊:從入門到精通的終端 CLI & 聊天指令全解析
作為 OpenClaw 生態(tài)(包括 PicoClaw、ZeroClaw、losterAI、EasyClaw 等系列開源應用)的核心用戶,我根據(jù)開源資料和個人使用體驗整理了這份全網(wǎng)最全的命令速查手冊2026-03-09
OpenClaw 是一款功能強大的開源 AI 助手框架,支持對接多種大模型和通訊平臺,下面就來介紹一下openclaw常用指令,需要的朋友們下面隨著小編來一起學習學習吧2026-03-04






