跳轉到主要內容

Documentation Index

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

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

Skills 會教導代理程式如何以及何時使用工具。每個 skill 都是一個目錄, 其中包含帶有 YAML frontmatter 和 markdown 指示的 SKILL.md 檔案。 如需了解 skills 的載入與優先順序,請參閱 Skills

建立你的第一個 skill

1

建立 skill 目錄

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!".
skill name 請使用由小寫字母、數字和連字號組成的 hyphen-case。 保持資料夾名稱與 frontmatter name 一致。
3

新增工具(選用)

你可以在 frontmatter 中定義自訂工具 schema,或指示代理程式 使用現有的系統工具(例如 execbrowser)。Skills 也可以 與其記錄的工具一起封裝在 plugins 中。
4

載入 skill

啟動新的工作階段,讓 OpenClaw 載入該 skill:
# From chat
/new

# Or restart the gateway
openclaw gateway restart
驗證 skill 已載入:
openclaw skills list
5

測試它

傳送應該會觸發該 skill 的訊息:
openclaw agent --message "give me a greeting"
或直接與代理程式聊天並要求問候語。

Skill 中繼資料參考

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

最佳實務

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

Skills 的位置

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

相關