跳轉到主要內容

Documentation Index

Fetch the complete documentation index at: https://docs2.openclaw.ai/llms.txt

Use this file to discover all available pages before exploring further.

Skills 會教導代理如何以及何時使用工具。每個技能都是一個目錄, 其中包含一個 SKILL.md 檔案,內含 YAML frontmatter 與 Markdown 指示。 若要了解 Skills 如何載入與排定優先順序,請參閱 Skills

建立你的第一個技能

1

建立技能目錄

Skills 位於你的工作區中。建立新資料夾:
mkdir -p ~/.openclaw/workspace/skills/hello-world
2

撰寫 SKILL.md

在該目錄中建立 SKILL.md。frontmatter 會定義中繼資料, Markdown 主體則包含給代理的指示。
---
name: hello-world
description: A simple skill that says hello.
---

# Hello World Skill

When the user asks for a greeting, use the `echo` tool to say
"Hello from your custom skill!".
技能 name 請使用由小寫字母、數字與連字號組成的 hyphen-case。 請讓資料夾名稱與 frontmatter name 保持一致。
3

新增工具(選用)

你可以在 frontmatter 中定義自訂工具結構描述,或指示代理 使用現有的系統工具(例如 execbrowser)。Skills 也可以 隨 Plugin 一起發佈,與其所記錄的工具並列。
4

載入技能

啟動新的工作階段,讓 OpenClaw 偵測到該技能:
# From chat
/new

# Or restart the gateway
openclaw gateway restart
確認技能已載入:
openclaw skills list
5

測試它

傳送一則應該觸發該技能的訊息:
openclaw agent --message "give me a greeting"
或者直接與代理聊天並要求問候語。

技能中繼資料參考

YAML frontmatter 支援下列欄位:
欄位必填說明
name使用小寫字母、數字與連字號的唯一識別碼
description顯示給代理的一行描述
metadata.openclaw.os作業系統篩選器(["darwin"]["linux"] 等)
metadata.openclaw.requires.binsPATH 上所需的二進位檔
metadata.openclaw.requires.config必要的設定鍵

最佳實務

  • 保持精簡 — 指示模型要做 什麼,而不是如何當 AI
  • 安全優先 — 如果你的技能使用 exec,請確保提示不會允許來自不受信任輸入的任意命令注入
  • 在本機測試 — 分享前先使用 openclaw agent --message "..." 測試
  • 使用 ClawHub — 在 ClawHub 瀏覽並貢獻 Skills

Skills 的位置

位置優先順序範圍
\<workspace\>/skills/最高每個代理
\<workspace\>/.agents/skills/每個工作區代理
~/.agents/skills/共用代理設定檔
~/.openclaw/skills/共用(所有代理)
Bundled(隨 OpenClaw 發佈)全域
skills.load.extraDirs最低自訂共用資料夾

相關