尚未安裝 OpenClaw?點此查看一鍵安裝指令
curl -fsSL https://openclaw.ai/install.sh | bash
iwr -useb https://openclaw.ai/install.ps1 | iex
curl -fsSL https://openclaw.ai/install.cmd -o install.cmd && install.cmd && del install.cmd
擔心影響電腦?ClawTank 免安裝雲端運行,免除誤刪風險
Key Findings
  • OpenClaw CLI 採用 openclaw <noun> [subcommand] 的一致命名結構——名詞一律用複數形式(modelschannelsskillshooksagents),所有操作皆可透過終端機完成
  • openclaw doctor 是最重要的日常維護指令——自動偵測 Gateway、Channels、Skills、Plugins、Memory 狀態;加上 --fix 可自動修復,--deep 可掃描系統服務
  • Gateway 預設在 ws://127.0.0.1:18789 啟動——透過 openclaw gateway(前台)或 openclaw gateway install(服務註冊)管理,所有 Channels、Skills 均透過此 WebSocket 端點通訊
  • 模型管理採用 OAuth / Auth Profiles 機制——透過 openclaw models auth login 完成 OAuth 授權,支援 Qwen、GitHub Copilot 等免費模型,Token 自動刷新
  • 設定檔為 JSON 格式(~/.openclaw/openclaw.json)——透過 openclaw config get/set/unset 以 dot-path 操作,或 openclaw configure 啟動互動式設定精靈。需要 Docker 部署?見《Docker 部署完全指南》

OpenClaw 自 2026 年初正式開源以來,迅速成為最受矚目的 AI 代理框架之一。[3] 相比於其他依賴網頁介面或桌面應用程式的同類工具,OpenClaw 從設計之初便以命令列介面(CLI)作為主要操作入口,這使得它天然適合與現有的 DevOps 工具鏈、Shell 腳本及自動化排程整合。

然而,許多初次接觸 OpenClaw 的使用者面臨同一個困境:官方文件雖然完整,但指令數量龐大(40+ 頂層指令),不同版本之間的旗標也略有差異。[1] 本文基於 OpenClaw 2026.2.25 版本的實機測試結果,系統性整理所有常用指令,從安裝到診斷,從模型管理到 Agents,提供一份經過驗證的完整參考。

一、命令列介面概覽

1.1 OpenClaw CLI 的設計哲學

OpenClaw 的 CLI 基於 Node.js 建構(非 Go),設計上遵循 openclaw <noun> [subcommand] [flags] 的格式。[4] 重要命名慣例:頂層名詞一律使用複數形式——modelschannelsskillshooksagentspluginssessions。少數核心指令使用單數(gatewaydoctorconfig)。

1.2 全域說明與版本資訊

在任何子指令後加上 --help-h 旗標,都可取得該指令的說明文字:

# 顯示所有可用的頂層指令與簡要說明
openclaw --help

# 顯示特定子指令的說明
openclaw gateway --help
openclaw models --help
openclaw channels add --help

執行 openclaw --help 後,實際輸出結構如下(2026.2.25):

Usage: openclaw [options] [command]

Options:
  --dev                Dev profile: isolate state under ~/.openclaw-dev
  -h, --help           Display help for command
  --log-level <level>  Global log level override (silent|fatal|error|warn|info|debug|trace)
  --no-color           Disable ANSI colors
  --profile <name>     Use a named profile (isolates state/config)
  -V, --version        output the version number

Core Commands:
  gateway *      Run, inspect, and query the WebSocket Gateway
  models *       Discover, scan, and configure models
  channels *     Manage connected chat channels (Telegram, Discord, etc.)
  skills *       List and inspect available skills
  hooks *        Manage internal agent hooks
  plugins *      Manage OpenClaw plugins and extensions
  agents *       Manage isolated agents (workspaces, auth, routing)
  doctor         Health checks + quick fixes
  config *       Non-interactive config helpers (get/set/unset)
  configure      Interactive setup wizard

Utility Commands:
  update *       Update OpenClaw and inspect update channel status
  logs           Tail gateway file logs via RPC
  sessions *     List stored conversation sessions
  browser *      Manage OpenClaw's dedicated browser (Chrome/Chromium)
  cron *         Manage cron jobs via the Gateway scheduler
  security *     Security tools and local config audits
  memory *       Search, inspect, and reindex memory files
  tui            Open a terminal UI connected to the Gateway
  dashboard      Open the Control UI with your current token
  onboard        Interactive onboarding wizard
  status         Show channel health and recent session recipients
  uninstall      Uninstall the gateway service + local data (CLI remains)
  reset          Reset local config/state (keeps the CLI installed)

Docs: https://docs.openclaw.ai/cli

查詢版本資訊:

# 顯示版本號
openclaw --version
# 輸出:2026.2.25

注意:openclaw version 指令不存在,版本資訊透過 --version-V 旗標取得。

1.3 全域旗標說明

以下旗標可套用於主 CLI:

--log-level <level>  日誌等級(silent|fatal|error|warn|info|debug|trace)
--no-color           停用 ANSI 彩色輸出(適合管道輸出與 CI 環境)
--dev                使用開發設定檔,隔離狀態至 ~/.openclaw-dev
--profile <name>     使用命名設定檔,隔離狀態至 ~/.openclaw-<name>
-V, --version        輸出版本號
-h, --help           顯示說明

二、安裝與環境管理

2.1 初次安裝

OpenClaw 提供三種安裝方式,底層均透過 npm install -g openclaw@latest 完成全域安裝:[2](Windows 用戶可參考 Windows 安裝教學

# macOS / Linux
curl -fsSL https://openclaw.ai/install.sh | bash

# Windows PowerShell
iwr -useb https://openclaw.ai/install.ps1 | iex

# Windows CMD(繞過 ExecutionPolicy 限制)
curl -fsSL https://openclaw.ai/install.cmd -o install.cmd && install.cmd && del install.cmd

安裝完成後,執行 Doctor 確認環境就緒:

openclaw doctor

Doctor 會檢查 Gateway 狀態、Skills、Plugins、Channels、Memory search 等並報告問題。

2.2 更新

# 更新至最新穩定版
openclaw update

# 切換更新頻道(stable/beta/dev)
openclaw update --channel beta

# 一次性更新至指定版本或 dist-tag
openclaw update --tag 2026.2.20

# 預覽更新內容(不實際執行)
openclaw update --dry-run

# 更新後不自動重啟 Gateway 服務
openclaw update --no-restart

# 非互動模式(CI 環境適用)
openclaw update --yes --json

# 查看當前更新頻道與版本狀態
openclaw update status

# 互動式更新精靈
openclaw update wizard

2.3 解除安裝與重設

# 解除安裝 Gateway 服務 + 本地資料(CLI 保留)
openclaw uninstall

# 解除安裝並清除所有設定、狀態、工作區
openclaw uninstall --all --yes

# 預覽解除安裝動作
openclaw uninstall --dry-run

# 僅移除服務/狀態/工作區
openclaw uninstall --service
openclaw uninstall --state
openclaw uninstall --workspace

# 重設本地設定(保留 CLI)
openclaw reset
openclaw reset --scope config          # 僅重設設定
openclaw reset --scope full --yes      # 完整重設(非互動)

2.4 全域設定管理

設定檔位於 ~/.openclaw/openclaw.json(JSON5 格式,支援註解與尾逗號):

# 取得特定設定值(dot-path 語法)
openclaw config get gateway.port
# 輸出:18789

openclaw config get gateway.mode
# 輸出:local

# 設定特定值
openclaw config set gateway.port 18790
openclaw config set gateway.bind loopback

# 移除設定值
openclaw config unset gateway.tailscale

# 啟動互動式設定精靈
openclaw configure

# 設定精靈指定區段
openclaw configure --section model
openclaw configure --section web

三、Gateway 管理指令

3.1 Gateway 概念說明

Gateway 是 OpenClaw 的核心 WebSocket 伺服器,負責在 ws://127.0.0.1:18789 上接收來自 Channels 的訊息,管理 Agent sessions,並協調 Skills 執行。[7] 所有 Channel、Dashboard、Browser 控制均透過 Gateway 通訊。

3.2 啟動與運行

# 前台模式運行(按 Ctrl+C 停止)
openclaw gateway

# 等同於
openclaw gateway run

# 指定埠號與綁定模式
openclaw gateway --port 18790
openclaw gateway --bind lan        # loopback|lan|tailnet|auto|custom

# 強制啟動(殺掉占用埠號的程序)
openclaw gateway --force

# Gateway auth 模式
openclaw gateway --auth token --token "your-secret-token"
openclaw gateway --auth password --password "your-password"

# Tailscale 暴露模式
openclaw gateway --tailscale serve   # off|serve|funnel

# 詳細日誌模式
openclaw gateway --verbose
openclaw gateway --ws-log compact    # 精簡 WebSocket 日誌(auto|full|compact)

# 開發模式(隔離狀態)
openclaw gateway --dev

3.3 Gateway 服務管理(持久化)

# 安裝為系統服務(launchd/systemd/schtasks)
openclaw gateway install

# 啟動已安裝的服務
openclaw gateway start

# 停止服務
openclaw gateway stop

# 重啟服務
openclaw gateway restart

# 解除安裝服務
openclaw gateway uninstall

# 查看服務狀態 + 探測 Gateway
openclaw gateway status

Windows 注意事項:openclaw gateway install 底層依賴 schtasks,需要系統管理員權限。非管理員環境建議使用前台模式 openclaw gateway

3.4 Gateway 狀態查詢

# 查看完整狀態(服務 + 探測)
openclaw gateway status

# 實際輸出範例(2026.2.25):
# Service: Scheduled Task (missing)
# Config (cli): ~\.openclaw\openclaw.json
# Gateway: bind=loopback (127.0.0.1), port=18789
# Probe target: ws://127.0.0.1:18789
# Dashboard: http://127.0.0.1:18789/
# Listening: 127.0.0.1:18789

# 取得 Gateway 健康狀態
openclaw gateway health
# 輸出:Gateway Health OK (1693ms)
# Telegram: ok (@your_bot) (1693ms)

# 探測 Gateway 可達性
openclaw gateway probe

# 發現本地及廣域網路上的 Gateway
openclaw gateway discover

# 直接呼叫 Gateway RPC 方法
openclaw gateway call health

# 查看使用量費用摘要
openclaw gateway usage-cost

3.5 日誌查看

# 查看 Gateway 日誌(透過 RPC)
openclaw logs

# 即時追蹤日誌
openclaw logs --follow

# 限制行數
openclaw logs --limit 100

# JSON 格式輸出
openclaw logs --json

# 本地時間顯示
openclaw logs --local-time

# 純文字輸出(無 ANSI 樣式)
openclaw logs --plain

四、模型設定指令

4.1 列出與查看模型

# 列出已設定的模型
openclaw models list

# 實際輸出範例:
# Model                       Input      Ctx    Local Auth  Tags
# qwen-portal/coder-model     text       125k   no    yes   default,configured
# qwen-portal/vision-model    text+image 125k   no    yes   configured

# 查看模型狀態摘要
openclaw models status

# 實際輸出範例:
# Config        : ~\.openclaw\openclaw.json
# Default       : qwen-portal/coder-model
# Aliases (1)   : qwen -> qwen-portal/coder-model
# Configured models (2): qwen-portal/coder-model, qwen-portal/vision-model

# JSON 輸出
openclaw models status --json

# 純文字輸出
openclaw models status --plain

4.2 設定預設模型

# 設定預設模型(使用模型 ID 或別名)
openclaw models set qwen-portal/coder-model
openclaw models set qwen

# 設定圖片模型
openclaw models set-image qwen-portal/vision-model

4.3 模型 Auth 管理

# 互動式新增 Auth(引導選擇供應商與授權方式)
openclaw models auth add

# 手動貼上 Token
openclaw models auth paste-token
openclaw models auth paste-token --profile-id qwen --expires-in 30d

# 透過供應商 CLI 設定 Token
openclaw models auth setup-token
openclaw models auth setup-token --provider anthropic --yes

# 管理 Auth 順序
openclaw models auth order get
openclaw models auth order set

4.4 模型別名與 Fallback

# 管理模型別名
openclaw models aliases

# 管理模型 Fallback 清單
openclaw models fallbacks

# 管理圖片模型 Fallback 清單
openclaw models image-fallbacks

# 掃描 OpenRouter 免費模型
openclaw models scan

五、Channel 管理指令

5.1 Channel 支援清單

OpenClaw 2026.2.25 支援 20+ 通訊渠道:Telegram、WhatsApp、Discord、Slack、Signal、iMessage、IRC、Google Chat、LINE、Zalo、Matrix、Nostr、Microsoft Teams、Mattermost、Nextcloud Talk、BlueBubbles、Synology Chat、Tlon、Feishu 等。

5.2 新增 Channel

# 新增 Telegram Bot(非互動式)
openclaw channels add --channel telegram --token "123456:ABC..."

# 新增 Discord Bot
openclaw channels add --channel discord --token "MTIz..."

# 新增 Slack App
openclaw channels add --channel slack --bot-token "xoxb-..." --app-token "xapp-..."

# 新增 WhatsApp(需互動式 QR 登入)
openclaw channels login --channel whatsapp

# 新增 Matrix
openclaw channels add --channel matrix --homeserver "https://matrix.org" --user-id "@user:matrix.org" --access-token "..."

# 新增 Signal
openclaw channels add --channel signal --signal-number "+886..."

# 新增多帳號(指定 account ID)
openclaw channels add --channel telegram --account work --token "..."

5.3 列出與管理 Channel

# 列出所有已設定的 Channel
openclaw channels list

# 實際輸出範例:
# Chat channels:
# - Telegram default: configured, token=config, enabled
#
# Auth providers (OAuth + API keys):
# - qwen-portal:default (oauth)

# 查看 Channel 狀態(含 Gateway 探測)
openclaw channels status
openclaw channels status --probe     # 主動探測

# 查看 Channel 日誌
openclaw channels logs

# 查看供應商能力(支援的功能)
openclaw channels capabilities

# 移除 Channel
openclaw channels remove --channel telegram

# 登出 Channel Session
openclaw channels logout --channel whatsapp

# 解析 Channel/User 名稱到 ID
openclaw channels resolve

5.4 DM Pairing 配對

# 查看待核准的配對請求
openclaw pairing

# 核准 Telegram 配對
openclaw pairing approve telegram WR8XRQQA

# Pairing 管理
openclaw pairing --help

六、Skills 管理指令

6.1 Skills 概念說明

Skills 是 OpenClaw 的功能擴充機制——每個 Skill 定義了 AI 代理可以執行的特定能力。Skills 為 bundled(內建)或 plugin 安裝。[5] 完整的 Skill 開發與推薦清單請參考 OpenClaw Skills 完全指南

6.2 列出與檢查 Skills

# 列出所有可用 Skills
openclaw skills list

# 實際輸出範例(部分):
# Skills (13/52 ready)
# ┌───────────┬──────────────────┬─────────────────────────────────┬────────────────┐
# │ Status    │ Skill            │ Description                     │ Source         │
# ├───────────┼──────────────────┼─────────────────────────────────┼────────────────┤
# │ ✓ ready   │ 🧩 coding-agent   │ ...                             │ openclaw-bundled│
# │ ✗ missing │ 🔐 1password      │ ...                             │ openclaw-bundled│

# 檢查 Skills 就緒狀態
openclaw skills check

# 實際輸出範例:
# Skills Status Check
# Total: 52
# ✓ Eligible: 13
# ✗ Missing requirements: 39
#
# Ready to use:
#   🧩 coding-agent
#   ♊️ gemini
#   📦 gh-issues
#   🐙 github
#   ...
#
# Missing requirements:
#   🔐 1password (bins: op)
#   📝 apple-notes (bins: memo; os: darwin)
#   ...

# 查看特定 Skill 的詳細資訊
openclaw skills info coding-agent
企業部署諮詢

需要在企業環境中大規模部署 OpenClaw?我們的教授級團隊提供從架構設計、安全合規到自訂 Skills 開發的完整技術支援。

聯繫技術團隊 →

七、Hooks 相關指令

7.1 Hooks 概念說明

Hooks 是 OpenClaw 的事件驅動自動化機制——在特定事件觸發時自動執行預定義動作。[6] 例如 session-memory/new/reset 時自動儲存 Session 上下文。

7.2 列出與管理 Hooks

# 列出所有 Hooks
openclaw hooks list

# 實際輸出範例:
# Hooks (4/4 ready)
# ┌──────────┬──────────────────────┬──────────────────────────────────────────┬─────────────┐
# │ Status   │ Hook                 │ Description                              │ Source       │
# ├──────────┼──────────────────────┼──────────────────────────────────────────┼─────────────┤
# │ ✓ ready  │ 🚀 boot-md            │ Run BOOT.md on gateway startup           │ openclaw-bundled│
# │ ✓ ready  │ 📎 bootstrap-extra-files│ Inject additional workspace bootstrap files│ openclaw-bundled│
# │ ✓ ready  │ 📝 command-logger     │ Log all command events to audit file     │ openclaw-bundled│
# │ ✓ ready  │ 💾 session-memory     │ Save session context on /new or /reset   │ openclaw-bundled│

# 查看特定 Hook 詳細資訊
openclaw hooks info session-memory

# 檢查 Hooks 資格狀態
openclaw hooks check

# 啟用 Hook
openclaw hooks enable session-memory

# 停用 Hook
openclaw hooks disable command-logger

# 安裝 Hook pack(路徑、壓縮檔、或 npm 套件)
openclaw hooks install ./my-hook-pack
openclaw hooks install some-npm-hook-package

# 更新已安裝的 Hooks(僅 npm 安裝)
openclaw hooks update

八、Plugins 管理指令

8.1 列出與管理 Plugins

# 列出所有已發現的 Plugins
openclaw plugins list

# 查看 Plugin 詳細資訊
openclaw plugins info some-plugin

# 安裝 Plugin(路徑、壓縮檔、或 npm 套件)
openclaw plugins install ./my-plugin
openclaw plugins install some-npm-plugin

# 啟用/停用 Plugin
openclaw plugins enable some-plugin
openclaw plugins disable some-plugin

# 診斷 Plugin 載入問題
openclaw plugins doctor

九、Agents 管理指令

9.1 Agents 概念說明

Agents 是 OpenClaw 的隔離執行單元——每個 Agent 擁有獨立的工作區(workspace)、Auth 設定與路由規則。預設有一個 main Agent。多 Agent 協作架構請參考 OpenClaw 多 Agent 協作指南

9.2 管理 Agents

# 列出已設定的 Agents
openclaw agents list

# 新增隔離 Agent
openclaw agents add work

# 設定 Agent 身份(名稱/主題/表情/頭像)
openclaw agents set-identity work --name "Work Bot"

# 刪除 Agent 並清除工作區
openclaw agents delete work

十、診斷與除錯指令

10.1 openclaw doctor

openclaw doctor 是最重要的診斷工具——檢查 Gateway、Channels、Skills、Plugins、Memory search 狀態:

# 執行環境診斷
openclaw doctor

# 嘗試自動修復
openclaw doctor --fix

# 深度掃描(含系統服務)
openclaw doctor --deep

# 生成並設定 Gateway Token
openclaw doctor --generate-gateway-token

# 非互動模式(僅安全修復)
openclaw doctor --non-interactive

# 跳過確認提示
openclaw doctor --yes

10.2 安全性審計

# 本地安全性審計
openclaw security audit

# 深度審計(含 Gateway 探測)
openclaw security audit --deep

# 自動修復安全問題
openclaw security audit --fix

# JSON 輸出
openclaw security audit --json

10.3 其他實用指令

# 查看 Channel 健康狀態與最近 Session
openclaw status

# 開啟 Dashboard(瀏覽器)
openclaw dashboard

# 開啟終端機 TUI
openclaw tui

# 查看 Memory 索引狀態
openclaw memory status

# 重新索引 Memory 檔案
openclaw memory index --force

# 搜尋 Memory
openclaw memory search --query "deployment notes"

# 管理 Cron 排程
openclaw cron list
openclaw cron add
openclaw cron status

# 查看 Sessions
openclaw sessions
openclaw sessions --active 120    # 最近 2 小時活躍的
openclaw sessions --all-agents    # 跨 Agent 聚合
openclaw sessions --json          # JSON 輸出

# 瀏覽器控制
openclaw browser status
openclaw browser tabs
openclaw browser open https://example.com
openclaw browser screenshot
openclaw browser snapshot

十一、常見問題與疑難排解

11.1 指令名稱常見錯誤

問題:執行 openclaw versionopenclaw modelopenclaw channel 等指令出現 unknown command

# 錯誤:
openclaw version        # ✗ unknown command
openclaw model list     # ✗ unknown command (Did you mean models?)
openclaw channel list   # ✗ unknown command (Did you mean channels?)
openclaw skill list     # ✗ unknown command (Did you mean skills?)
openclaw hook list      # ✗ unknown command (Did you mean hooks?)

# 正確:
openclaw --version      # ✓ 使用旗標,非子指令
openclaw models list    # ✓ 複數形式
openclaw channels list  # ✓ 複數形式
openclaw skills list    # ✓ 複數形式
openclaw hooks list     # ✓ 複數形式

11.2 Gateway 無法啟動

問題:openclaw gateway 出現 bind: address already in use

# 方案一:強制啟動(殺掉占用程序)
openclaw gateway --force

# 方案二:更換埠號
openclaw gateway --port 18790
openclaw config set gateway.port 18790

# 方案三:查看占用程序
netstat -ano | findstr :18789   # Windows
lsof -i :18789                  # macOS/Linux

問題:openclaw gateway install 在 Windows 上失敗(Access denied)。

# Gateway 服務安裝需管理員權限(schtasks)
# 方案一:以管理員身份執行 PowerShell
# 方案二:使用前台模式
openclaw gateway

11.3 設定檔位置

# OpenClaw 設定檔(JSON 格式)
~/.openclaw/openclaw.json

# Windows 完整路徑
C:\Users\<USERNAME>\.openclaw\openclaw.json

# Agent 工作區
~/.openclaw/agents/main/

# Auth Profiles
~/.openclaw/agents/main/agent/auth-profiles.json

# Gateway 日誌
/tmp/openclaw/openclaw-YYYY-MM-DD.log     # macOS/Linux
\tmp\openclaw\openclaw-YYYY-MM-DD.log     # Windows

11.4 取得技術支援

# 執行完整診斷
openclaw doctor --deep

# 查看版本資訊
openclaw --version

# 查看 Gateway 狀態
openclaw gateway status

# 查看完整健康狀態
openclaw gateway health

# 搜尋官方文件
openclaw docs

結語

OpenClaw 2026.2.25 的 CLI 提供了 40+ 頂層指令,涵蓋 Gateway 管理、模型設定、Channel 串接、Skills/Hooks/Plugins 管理、安全性審計、Cron 排程、瀏覽器控制等完整功能。[8] 掌握幾個核心指令——openclaw doctoropenclaw gatewayopenclaw models statusopenclaw channels list——就足以應對日常操作需求。

本文所有指令均經過 OpenClaw 2026.2.25 在 Windows 11 環境的實機驗證。隨著版本演進,部分指令的旗標或輸出格式可能變更,建議善用 --help 旗標查閱最新用法,並定期執行 openclaw doctor 確保環境健康。[1]