跳轉到主要內容
Skills 會教導代理如何以及何時使用工具。每個 Skills 都是一個目錄, 其中包含一個帶有 YAML frontmatter 和 Markdown 指示的 SKILL.md 檔案。 OpenClaw 會依定義好的優先順序從多個根目錄載入 Skills。

建立你的第一個 Skills

1

建立 Skills 目錄

Skills 位於你工作區的 skills/ 資料夾中:
mkdir -p ~/.openclaw/workspace/skills/hello-world
你可以將 Skills 分組到子資料夾中以便整理,但 Skills 仍然 由 SKILL.md frontmatter 命名,而不是由資料夾路徑命名:
mkdir -p ~/.openclaw/workspace/skills/personal/hello-world
# skill name is still "hello-world", invoked as /hello-world
2

撰寫 SKILL.md

frontmatter 定義中繼資料;本文則提供代理指示。
---
name: hello-world
description: A simple skill that prints a greeting.
---

# Hello World

When the user asks for a greeting, use the `exec` tool to run:

```bash
echo "Hello from your custom skill!"

命名規則:
- `name` 使用小寫字母、數字和連字號。
- 讓目錄名稱與 frontmatter `name` 保持一致。
- `description` 會顯示給代理,並出現在斜線命令探索中,
  請保持單行且少於 160 個字元。

</Step>

<Step title="確認 Skills 已載入">
```bash
openclaw skills list
OpenClaw 預設會監看 Skills 根目錄下的 SKILL.md 檔案。如果 監看器已停用,或你正在延續現有工作階段,請啟動新的工作階段, 讓代理收到重新整理後的清單:
# From chat — archive current session and start fresh
/new

# Or restart the gateway
openclaw gateway restart
3

測試

openclaw agent --message "give me a greeting"
或開啟聊天並直接詢問代理。使用 /skill hello-world 可依名稱 明確叫用它。

SKILL.md 參考

必填欄位

欄位說明
name使用小寫字母、數字和連字號的唯一 slug
description顯示給代理並出現在探索輸出中的單行說明

選用 frontmatter 鍵

欄位預設值說明
user-invocabletrue將 Skills 作為使用者斜線命令公開
disable-model-invocationfalse讓 Skills 不出現在代理的系統提示中(仍可透過 /skill 執行)
command-dispatch設為 tool 可將斜線命令直接路由到工具,繞過模型
command-tool設定 command-dispatch: tool 時要叫用的工具名稱
command-arg-moderaw用於工具派送時,將原始 args 字串轉送給工具
homepage在 macOS Skills UI 中顯示為「網站」的 URL
關於閘道欄位(requires.binsrequires.env 等),請參閱 Skills — 閘道

使用 {baseDir}

引用 Skills 目錄中的檔案時無需硬編碼路徑,代理會根據 Skills 自身目錄解析 {baseDir}
Run the helper script at `{baseDir}/scripts/run.sh`.

新增條件式啟用

為你的 Skills 設定閘道,使其只在相依項目可用時載入:
---
name: gemini-search
description: Search using Gemini CLI.
metadata: { "openclaw": { "requires": { "bins": ["gemini"] }, "primaryEnv": "GEMINI_API_KEY" } }
---
說明
requires.bins所有二進位檔都必須存在於 PATH
requires.anyBins至少一個二進位檔必須存在於 PATH
requires.env每個環境變數都必須存在於程序或設定中
requires.config每個 openclaw.json 路徑都必須為 truthy
os平台篩選器:["darwin"]["linux"]["win32"]
always設為 true 可略過所有閘道,並一律包含 Skills
完整參考:Skills — 閘道
openclaw.json 中將 API 金鑰連接到 Skills 項目:
{
  skills: {
    entries: {
      "gemini-search": {
        enabled: true,
        apiKey: { source: "env", provider: "default", id: "GEMINI_API_KEY" },
      },
    },
  },
}
該金鑰只會在該代理回合中注入主機程序。 它不會進入沙箱,請參閱 沙箱化環境變數

透過 Skills Workshop 提案

若是由代理起草的 Skills,或你希望在 Skills 上線前先由操作員審查, 請使用 Skills Workshop 提案,而不是直接撰寫 SKILL.md
# Propose a brand-new skill
openclaw skills workshop propose-create \
  --name "hello-world" \
  --description "A simple skill that prints a greeting." \
  --proposal ./PROPOSAL.md

# Propose an update to an existing skill
openclaw skills workshop propose-update hello-world \
  --proposal ./PROPOSAL.md \
  --description "Updated greeting skill"
當提案包含支援檔案時,請使用 --proposal-dir
openclaw skills workshop propose-create \
  --name "hello-world" \
  --description "A simple skill that prints a greeting." \
  --proposal-dir ./hello-world-proposal/
該目錄根層必須包含 PROPOSAL.md。支援檔案放在 assets/examples/references/scripts/templates/ 下。 審查後:
openclaw skills workshop inspect <proposal-id>
openclaw skills workshop apply <proposal-id>
請參閱 Skills Workshop 了解完整提案生命週期。

發佈到 ClawHub

1

確認你的 SKILL.md 完整

確認已設定 namedescription,以及任何 metadata.openclaw 閘道欄位。如果你有專案頁面,請新增 homepage URL。
2

安裝獨立 ClawHub 命令列介面並登入

npm i -g clawhub
clawhub login
3

發佈

clawhub skill publish ./path/to/hello-world
新增 --version <version>--owner <owner> 可覆寫推斷出的 版本,或以特定擁有者身分發佈。完整流程、擁有者範圍和其他 維護命令(clawhub syncclawhub skill rename 等),請參閱 ClawHub — 發佈ClawHub 命令列介面

最佳實務

  • 保持精簡 — 指示模型要做什麼,而不是如何成為 AI。
  • 安全優先 — 如果你的 Skills 使用 exec,請確保提示不會允許 來自不受信任輸入的任意命令注入。
  • 在本機測試 — 分享前先使用 openclaw agent --message "..."
  • 使用 ClawHub — 從零開始建置前,先在 clawhub.ai 瀏覽社群 Skills。

相關

Skills 參考

載入順序、閘道、允許清單,以及 SKILL.md 格式。

Skills Workshop

由代理起草的 Skills 提案佇列。

Skills 設定

完整的 skills.* 設定結構描述。

ClawHub

在公開登錄檔瀏覽並發佈 Skills。

建置外掛

外掛可以隨附 Skills,與其記錄的工具一同發布。