OpenClaw提供豐富命令行工具,分為CLI和聊天斜杠命令兩大類,涵蓋系統(tǒng)、配置管理、網(wǎng)關(guān)服務(wù)、模型管理、渠道管理、技能管理、消息與對話管理等多方面功能,本文總結(jié)了OpenClaw的命令使用頻率統(tǒng)計(jì)、實(shí)用技巧及最佳實(shí)踐,并提供配置管理、定時(shí)任務(wù)等高級功能介紹
OpenClaw 提供了豐富的命令行工具,分為終端CLI命令和聊天斜杠命令兩大類。以下是基于2026年5月最新資料的完整分類介紹。

一、基礎(chǔ)與安裝命令
1.1 版本與環(huán)境
| 命令 | 功能 | 示例 |
|---|
openclaw --version / -V | 查看當(dāng)前版本 | openclaw --version |
openclaw --help / -h | 顯示所有命令幫助 | openclaw --help |
openclaw tui | 啟動(dòng)終端交互界面 | openclaw tui |
openclaw dashboard | 打開網(wǎng)頁管理控制臺 | openclaw dashboard |
1.2 安裝與初始化
| 命令 | 功能 | 說明 |
|---|
openclaw setup | 初始化配置和工作區(qū) | 首次安裝后必須執(zhí)行 |
openclaw onboard | 交互式引導(dǎo)流程 | 依次配置Gateway、工作區(qū)、Skills |
openclaw configure | 交互式配置向?qū)?/td> | 修改模型、頻道、技能等核心配置 |
openclaw update | 更新CLI到最新版本 | openclaw update --channel stable |
openclaw uninstall | 卸載Gateway服務(wù)和相關(guān)數(shù)據(jù) | openclaw uninstall --all --yes |
1.3 全局選項(xiàng)
| 選項(xiàng) | 功能 | 說明 |
|---|
--dev | 開發(fā)模式 | 獨(dú)立配置+端口18790 |
--profile <name> | 多配置文件隔離 | 工作/個(gè)人環(huán)境分開 |
--log-level <level> | 設(shè)置日志級別 | silent/fatal/error/warn/info/debug/trace |
--no-color | 禁用彩色輸出 | 腳本中使用 |
--json | JSON格式輸出 | 機(jī)器可讀格式 |
二、配置管理命令
2.1 配置讀寫
| 命令 | 功能 | 示例 |
|---|
openclaw config get <path> | 讀取指定配置值 | openclaw config get gateway.port |
openclaw config set <path> <value> | 設(shè)置配置值 | openclaw config set gateway.port 18789 |
openclaw config unset <path> | 刪除配置項(xiàng) | openclaw config unset channels.telegram |
openclaw config file | 顯示配置文件路徑 | openclaw config file |
openclaw config validate | 校驗(yàn)配置文件有效性 | openclaw config validate |
2.2 常用配置路徑
# 設(shè)置網(wǎng)關(guān)模式
openclaw config set gateway.mode local
# 設(shè)置綁定模式
openclaw config set gateway.bind loopback
# 設(shè)置API密鑰
openclaw config set providers.anthropic.apiKey "sk-ant-xxxxx"
# 禁用記憶搜索
openclaw config set agents.defaults.memorySearch.enabled false
三、網(wǎng)關(guān)服務(wù)命令
3.1 生命周期管理
| 命令 | 功能 | 說明 |
|---|
openclaw gateway / openclaw gateway run | 前臺運(yùn)行Gateway | 常搭配screen或tmux使用 |
openclaw gateway start | 后臺啟動(dòng)Gateway服務(wù) | 系統(tǒng)服務(wù)方式運(yùn)行 |
openclaw gateway stop | 停止Gateway服務(wù) | 臨時(shí)暫停或維護(hù) |
openclaw gateway restart | 重啟Gateway服務(wù) | 修改配置后最常用 |
openclaw gateway status | 探測Gateway RPC狀態(tài) | 檢查服務(wù)是否存活 |
3.2 服務(wù)安裝
| 命令 | 功能 | 說明 |
|---|
openclaw gateway install | 安裝為系統(tǒng)服務(wù) | systemd/launchd等 |
openclaw gateway uninstall | 卸載系統(tǒng)服務(wù) | 徹底移除服務(wù) |
3.3 調(diào)試與發(fā)現(xiàn)
| 命令 | 功能 | 示例 |
|---|
openclaw gateway call <method> | 調(diào)用指定RPC方法 | openclaw gateway call health |
openclaw gateway probe | 探測Gateway | 調(diào)試連接問題時(shí)使用 |
openclaw gateway discover | 發(fā)現(xiàn)局域網(wǎng)中的Gateway實(shí)例 | 多實(shí)例環(huán)境使用 |
3.4 網(wǎng)關(guān)選項(xiàng)
# 指定端口啟動(dòng)
openclaw gateway --port 18789
# 強(qiáng)制殺掉占用端口并啟動(dòng)
openclaw gateway --force
# 詳細(xì)日志輸出
openclaw gateway --verbose
# 設(shè)置命令超時(shí)時(shí)間
openclaw gateway --timeout 30000
# 綁定模式設(shè)置
openclaw gateway --bind loopback # 僅本地
openclaw gateway --bind lan # 局域網(wǎng)
openclaw gateway --bind tailnet # Tailscale網(wǎng)絡(luò)
四、模型管理命令
4.1 基本操作
| 命令 | 功能 | 示例 |
|---|
openclaw models list | 列出所有可用模型 | openclaw models list |
openclaw models status | 模型狀態(tài)概覽 | openclaw models status |
openclaw models status --probe | 帶探測的模型狀態(tài)檢查 | 深度檢查模型可用性 |
openclaw models set <name> | 設(shè)置默認(rèn)模型 | openclaw models set glm-4.7-flash |
openclaw models set-image <name> | 設(shè)置圖片生成模型 | openclaw models set-image dalle-3 |
4.2 別名管理
| 命令 | 功能 | 示例 |
|---|
openclaw models aliases list | 列出模型別名 | openclaw models aliases list |
openclaw models aliases add <alias> <model> | 添加模型別名 | openclaw models aliases add gpt gpt-4 |
openclaw models aliases remove <alias> | 移除模型別名 | openclaw models aliases remove gpt |
4.3 回退模型
| 命令 | 功能 | 說明 |
|---|
openclaw models fallbacks list | 列出回退模型列表 | 主模型不可用時(shí)使用 |
openclaw models fallbacks add <model> | 添加回退模型 | openclaw models fallbacks add glm-4.7 |
openclaw models fallbacks remove <model> | 移除回退模型 | 清理不需要的回退模型 |
openclaw models fallbacks clear | 清空回退模型列表 | 重置回退配置 |
4.4 認(rèn)證管理
| 命令 | 功能 | 說明 |
|---|
openclaw models auth add | 添加模型認(rèn)證 | 配置API密鑰 |
openclaw models auth setup-token | 交互式設(shè)置API token | 推薦使用OAuth流程 |
openclaw models auth paste-token | 直接粘貼API token | 快速配置 |
openclaw models auth order get | 查看認(rèn)證提供商順序 | 優(yōu)先級排序 |
openclaw models auth order set | 設(shè)置認(rèn)證提供商順序 | 調(diào)整認(rèn)證優(yōu)先級 |
五、渠道管理命令
5.1 渠道操作
| 命令 | 功能 | 示例 |
|---|
openclaw channels list | 顯示所有已配置頻道 | openclaw channels list |
openclaw channels status | 檢查頻道健康狀態(tài) | openclaw channels status |
openclaw channels status --probe | 帶深度探測的頻道狀態(tài)檢查 | 詳細(xì)診斷 |
openclaw channels add | 向?qū)教砑有骂l道 | openclaw channels add |
openclaw channels login | 交互式登錄 | WhatsApp掃碼登錄 |
openclaw channels login --channel <name> | 登錄指定頻道 | openclaw channels login --channel whatsapp |
openclaw channels logout | 登出頻道 | 斷開連接 |
openclaw channels remove | 禁用并移除頻道 | openclaw channels remove --channel telegram |
5.2 渠道添加示例
# Telegram
openclaw channels add --channel telegram --token "BOT_TOKEN"
# Discord
openclaw channels add --channel discord --token "BOT_TOKEN"
# WhatsApp(掃碼登錄)
openclaw channels login --channel whatsapp
# 飛書
openclaw channels add --channel feishu --app-id "APP_ID" --app-secret "APP_SECRET"
六、技能與插件命令
6.1 技能管理
| 命令 | 功能 | 示例 |
|---|
openclaw skills list | 列出所有已加載技能 | openclaw skills list |
openclaw skills info <name> | 查看指定技能詳細(xì)信息 | openclaw skills info browser |
openclaw skills check | 就緒/缺失狀態(tài)摘要 | 檢查技能依賴 |
openclaw skills install <name> | 安裝新技能 | openclaw skills install browser |
openclaw skills enable <name> | 啟用技能 | openclaw skills enable browser |
openclaw skills disable <name> | 禁用技能 | openclaw skills disable browser |
6.2 插件管理
| 命令 | 功能 | 示例 |
|---|
openclaw plugins list | 發(fā)現(xiàn)并列出所有插件 | openclaw plugins list |
openclaw plugins info <name> | 查看插件詳細(xì)信息 | openclaw plugins info feishu |
openclaw plugins install <name> | 安裝插件 | 支持本地路徑、tgz或npm包名 |
openclaw plugins enable <name> | 啟用插件 | openclaw plugins enable feishu |
openclaw plugins disable <name> | 禁用插件 | openclaw plugins disable feishu |
openclaw plugins doctor | 插件加載錯(cuò)誤診斷報(bào)告 | 排查插件問題 |
6.3 ClawHub社區(qū)技能
# 搜索技能
clawhub search "weather"
# 安裝技能
clawhub install weather
# 同步所有技能
clawhub sync --all
# 列出已安裝技能
clawhub list
七、消息與會(huì)話命令
7.1 消息操作
| 命令 | 功能 | 示例 |
|---|
openclaw message send | 發(fā)送消息 | openclaw message send --target +15555550123 --message "Hi" |
openclaw message edit | 編輯已發(fā)送的消息 | openclaw message edit --message-id 123 --message "Updated" |
openclaw message delete | 刪除消息 | openclaw message delete --message-id 123 |
openclaw message poll | 創(chuàng)建投票 | openclaw message poll --question "Snack?" --option Pizza --option Sushi |
openclaw message react | 添加/移除反應(yīng) | openclaw message react --emoji "?" |
openclaw message broadcast | 廣播消息到多個(gè)目標(biāo) | 群發(fā)消息 |
7.2 會(huì)話管理
| 命令 | 功能 | 示例 |
|---|
openclaw sessions list | 列出所有會(huì)話 | openclaw sessions list |
openclaw sessions history | 查看會(huì)話歷史 | openclaw sessions history <session-key> |
openclaw memory | 管理記憶 | openclaw memory search "會(huì)議記錄" |
openclaw memory index | 重建向量索引 | 修復(fù)記憶索引錯(cuò)誤 |
7.3 Agent管理
| 命令 | 功能 | 示例 |
|---|
openclaw agents list | 列出所有已配置的agents | openclaw agents list |
openclaw agents add [name] | 通過向?qū)砑有耡gent | openclaw agents add assistant |
openclaw agents delete <name> | 刪除指定agent | openclaw agents delete old-assistant |
openclaw agents bindings | 列出所有路由綁定 | 查看agent與渠道的綁定關(guān)系 |
openclaw agents bind | 添加路由綁定 | 將agent綁定到頻道/群組 |
openclaw agents unbind | 移除路由綁定 | 解除綁定關(guān)系 |
八、診斷與維護(hù)命令
8.1 健康檢查
| 命令 | 功能 | 說明 |
|---|
openclaw doctor | 最有用的單條命令 | 全面健康檢查并提供快速修復(fù)建議 |
openclaw doctor --fix | 自動(dòng)修復(fù)常見問題 | 自動(dòng)修正配置文件權(quán)限等 |
openclaw doctor --deep | 深度診斷 | 復(fù)雜故障排查 |
openclaw health | 獲取運(yùn)行中Gateway的健康狀態(tài) | 快速確認(rèn)核心組件狀態(tài) |
openclaw status | 顯示會(huì)話健康狀態(tài)和最近接收者 | 整體運(yùn)行狀態(tài)概覽 |
8.2 日志管理
| 命令 | 功能 | 示例 |
|---|
openclaw logs | 查看Gateway日志 | openclaw logs |
openclaw logs --follow | 實(shí)時(shí)查看運(yùn)行日志 | 類似 tail -f |
openclaw logs --filter error | 僅查看錯(cuò)誤日志 | 快速定位故障 |
openclaw logs --start "2026-03-13" | 指定開始時(shí)間 | 時(shí)間范圍查詢 |
openclaw logs --search "error" | 關(guān)鍵詞過濾 | 搜索特定內(nèi)容 |
8.3 系統(tǒng)管理
| 命令 | 功能 | 示例 |
|---|
openclaw system event --text <msg> | 向系統(tǒng)事件隊(duì)列入隊(duì)一條事件 | 測試事件系統(tǒng) |
openclaw system heartbeat last | 查看上次心跳時(shí)間 | 檢查定時(shí)任務(wù) |
openclaw system heartbeat enable | 啟用心跳 | 開啟定時(shí)任務(wù) |
openclaw system heartbeat disable | 禁用心跳 | 關(guān)閉定時(shí)任務(wù) |
openclaw system presence | 列出系統(tǒng)在線狀態(tài) | 查看連接狀態(tài) |
8.4 安全與備份
| 命令 | 功能 | 說明 |
|---|
openclaw security audit | 安全審計(jì) | 檢查安全配置 |
openclaw security audit --deep | 深度安全審計(jì) | 全面安全檢查 |
openclaw secrets reload | 刷新敏感密鑰 | 重新加載密鑰 |
openclaw backup create | 創(chuàng)建系統(tǒng)備份 | 備份配置和數(shù)據(jù) |
openclaw reset | 重置系統(tǒng)狀態(tài) | 謹(jǐn)慎使用,保留CLI |
openclaw uninstall --all --yes | 徹底卸載 | 清理所有數(shù)據(jù) |
九、聊天斜杠命令(Slash Commands)
9.1 會(huì)話管理
| 命令 | 功能 | 說明 |
|---|
/new | 開啟新會(huì)話線程 | 清空上下文,節(jié)省token |
/new <描述> | 帶目標(biāo)啟動(dòng)新會(huì)話 | 指定會(huì)話目標(biāo) |
/reset | 重置當(dāng)前會(huì)話 | 同 /new |
/status | 查看當(dāng)前會(huì)話狀態(tài) | 包括模型、上下文、隊(duì)列等信息 |
/compact | 壓縮上下文 | 釋放上下文窗口空間 |
/history | 查看會(huì)話歷史記錄 | 瀏覽對話歷史 |
/pause | 暫停當(dāng)前任務(wù) | 臨時(shí)停止AI執(zhí)行 |
9.2 模型控制
| 命令 | 功能 | 示例 |
|---|
/model <名稱> | 切換模型 | /model glm-4.7-flash |
/reasoning | 開啟/關(guān)閉深度推理模式 | /reasoning on |
/reasoning <級別> | 調(diào)整推理級別 | /reasoning high |
/think <級別> | 設(shè)置思考級別 | /think medium |
/verbose on/off | 開啟/關(guān)閉詳細(xì)輸出 | /verbose on |
9.3 技能與工具
| 命令 | 功能 | 示例 |
|---|
/skills | 查看已安裝技能 | 列出所有可用技能 |
/skill <name> [input] | 直接運(yùn)行技能 | /skill weather 北京 |
/agents | 查看可用Agent | 列出所有Agent |
/memory | 查看或管理AI的記憶 | 查詢AI記住的信息 |
/forget | 忘記特定信息 | 清除記憶 |
9.4 操作控制
| 命令 | 功能 | 說明 |
|---|
/stop | 中止當(dāng)前正在運(yùn)行的任務(wù) | 緊急停止 |
/approve | 批準(zhǔn)配對請求 | 允許新聯(lián)系人 |
/deny | 拒絕配對請求 | 拒絕新聯(lián)系人 |
/cancel | 取消當(dāng)前操作 | 取消正在執(zhí)行的任務(wù) |
/undo | 撤銷上一步操作 | 回退操作 |
9.5 信息查詢
| 命令 | 功能 | 說明 |
|---|
/help | 顯示幫助信息 | 列出可用命令列表 |
/commands | 查看所有命令 | 同 /help |
/cost | 查看使用費(fèi)用 | 查詢API調(diào)用成本 |
/version | 查看版本信息 | 顯示OpenClaw版本 |
/ping | 測試連接狀態(tài) | 檢查服務(wù)是否正常 |
/deliver | 交付當(dāng)前任務(wù)結(jié)果 | 完成并輸出結(jié)果 |
十、高級與擴(kuò)展命令
10.1 定時(shí)任務(wù)
| 命令 | 功能 | 示例 |
|---|
openclaw cron list | 查看定時(shí)任務(wù) | openclaw cron list |
openclaw cron add | 添加定時(shí)任務(wù) | openclaw cron add "0 9 * * *" "check_disk" |
openclaw cron edit <id> | 編輯定時(shí)任務(wù) | 修改任務(wù)配置 |
openclaw cron rm <id> | 刪除定時(shí)任務(wù) | 移除指定任務(wù) |
openclaw cron run <id> | 立即執(zhí)行定時(shí)任務(wù) | 手動(dòng)觸發(fā)任務(wù) |
10.2 瀏覽器控制
| 命令 | 功能 | 示例 |
|---|
openclaw browser start | 啟動(dòng)瀏覽器 | 開啟瀏覽器實(shí)例 |
openclaw browser open <url> | 打開網(wǎng)頁 | openclaw browser open https://example.com |
openclaw browser click <selector> | 點(diǎn)擊元素 | openclaw browser click "#login" |
openclaw browser type <selector> <text> | 輸入文本 | openclaw browser type "#username" "admin" |
openclaw browser screenshot | 截圖 | 保存當(dāng)前頁面截圖 |
10.3 節(jié)點(diǎn)管理
| 命令 | 功能 | 說明 |
|---|
openclaw node run | 前臺運(yùn)行headless node host | 調(diào)試模式 |
openclaw node start | 啟動(dòng)node host服務(wù) | 后臺運(yùn)行 |
openclaw node stop | 停止node host服務(wù) | 關(guān)閉節(jié)點(diǎn) |
openclaw node restart | 重啟node host服務(wù) | 重新啟動(dòng) |
openclaw node status | 顯示node host狀態(tài) | 檢查節(jié)點(diǎn)狀態(tài) |
openclaw nodes | 管理移動(dòng)節(jié)點(diǎn) | 查看所有節(jié)點(diǎn) |
10.4 配對管理
| 命令 | 功能 | 說明 |
|---|
openclaw pairing list | 查看待處理的配對請求 | 審批新聯(lián)系人 |
openclaw pairing approve | 批準(zhǔn)配對請求 | 允許新聯(lián)系人 |
openclaw pairing deny | 拒絕配對請求 | 拒絕新聯(lián)系人 |
十一、故障排查流程
11.1 標(biāo)準(zhǔn)排查步驟
# 1. 檢查狀態(tài)
openclaw gateway status
# 2. 查看日志
openclaw logs --follow
# 3. 健康檢查
openclaw doctor
# 4. 自動(dòng)修復(fù)
openclaw doctor --fix
# 5. 重啟服務(wù)
openclaw gateway restart
11.2 常見問題解決
| 問題 | 解決方案 |
|---|
| 配置修改不生效 | openclaw gateway restart |
| JSON語法錯(cuò)誤 | openclaw doctor --fix |
| 網(wǎng)關(guān)宕機(jī) | openclaw doctor --deep |
| 記憶索引錯(cuò)誤 | openclaw memory index |
| 授權(quán)過期 | openclaw models auth setup-token |
| 不回復(fù)私聊 | 進(jìn)入Pairing List手動(dòng)批準(zhǔn) |
| 群聊靜默 | 檢查MentionPatterns配置 |
十二、命令使用頻率統(tǒng)計(jì)
高頻命令(每日使用)
openclaw gateway restart - 修改配置后必用openclaw doctor - 出問題先跑這個(gè)openclaw status - 快速檢查狀態(tài)openclaw logs --follow - 實(shí)時(shí)查看日志/new - 開啟新會(huì)話
中頻命令(每周使用)
openclaw models set - 切換模型openclaw skills install - 安裝新技能openclaw channels status - 檢查渠道連接openclaw config set - 修改配置clawhub search - 搜索技能
低頻命令(每月使用)
openclaw update - 更新版本openclaw backup create - 創(chuàng)建備份openclaw security audit - 安全審計(jì)openclaw reset - 重置配置openclaw uninstall - 卸載系統(tǒng)
十三、實(shí)用技巧與最佳實(shí)踐
13.1 多環(huán)境管理
# 工作環(huán)境
openclaw --profile work gateway start
# 個(gè)人環(huán)境
openclaw --profile personal gateway start
# 開發(fā)環(huán)境
openclaw --dev gateway start
13.2 腳本自動(dòng)化
# 批量執(zhí)行命令
openclaw run --batch commands.txt
# 管道輸入
echo "分析這段代碼" | openclaw run
# JSON輸出處理
openclaw models list --json | jq '.models[] | select(.provider=="openai")'
13.3 快捷鍵與別名
# 創(chuàng)建別名(在~/.bashrc或~/.zshrc中)
alias claw='openclaw'
alias claw-status='openclaw gateway status'
alias claw-restart='openclaw gateway restart'
alias claw-logs='openclaw logs --follow'
alias claw-doctor='openclaw doctor --fix'
13.4 配置文件位置
- 主配置:
~/.openclaw/openclaw.json - 工作區(qū):
~/.openclaw/workspace/ - 技能目錄:
~/.openclaw/skills/ - Agent數(shù)據(jù):
~/.openclaw/agents/ - 日志文件:
~/.openclaw/logs/
十四、總結(jié)
OpenClaw的命令體系設(shè)計(jì)清晰,分為CLI命令和斜杠命令兩大類別,覆蓋了從系統(tǒng)管理到日常使用的所有場景。掌握這些命令,您就能充分發(fā)揮OpenClaw作為個(gè)人AI助手的強(qiáng)大能力。
核心要點(diǎn):
- 配置修改后必須重啟網(wǎng)關(guān):
openclaw gateway restart - 出問題先跑診斷:
openclaw doctor - 實(shí)時(shí)查看日志:
openclaw logs --follow - 多環(huán)境隔離:使用
--profile參數(shù) - 技能擴(kuò)展:通過ClawHub社區(qū)安裝
這份命令大全基于2026年5月的最新資料整理,涵蓋了OpenClaw的所有核心功能。建議收藏本文,使用時(shí)通過Ctrl+F快速查找所需命令。
以上就是OpenClaw指令分類詳解與使用指南的詳細(xì)內(nèi)容,更多關(guān)于OpenClaw指令分類與使用的資料請關(guān)注腳本之家其它相關(guān)文章!