Skills
建立 Skills
Skills 會教導代理如何以及何時使用工具。每個技能都是一個目錄,
其中包含一個具有 YAML frontmatter 和 Markdown 指示的 SKILL.md 檔案。
OpenClaw 會依照定義好的優先順序,從多個根目錄載入技能。
建立你的第一個技能
Create the skill directory
Skills 位於你工作區的 skills/ 資料夾中。為你的新技能建立一個目錄:
mkdir -p ~/.openclaw/workspace/skills/hello-world你可以將技能分組放在子資料夾中以便整理;技能仍然由
SKILL.md frontmatter 命名,而不是由資料夾路徑命名:
mkdir -p ~/.openclaw/workspace/skills/personal/hello-world# skill name is still "hello-world", invoked as /hello-worldWrite SKILL.md
在該目錄中建立 SKILL.md。frontmatter 會定義中繼資料;
內文則提供給代理的指示。
---name: hello-worlddescription: A simple skill that prints a greeting.--- # Hello World When the user asks for a greeting, use the `exec` tool to run: ```bashecho "Hello from your custom skill!" 命名規則:- `name` 使用小寫字母、數字和連字號。- 保持目錄名稱與 frontmatter 的 `name` 一致。- `description` 會顯示給代理,並出現在斜線命令探索中; 請保持為一行且少於 160 個字元。 OPENCLAW_DOCS_MARKER:stepClose: OPENCLAW_DOCS_MARKER:stepOpen:IHRpdGxlPSJWZXJpZnkgdGhlIHNraWxsIGxvYWRlZCI ```bashopenclaw skills listOpenClaw 預設會監看 Skills 根目錄下的 SKILL.md 檔案。如果監看器
已停用,或你正在延續現有工作階段,請啟動新的工作階段,
讓代理收到重新整理後的清單:
# From chat — archive current session and start fresh/new # Or restart the gatewayopenclaw gateway restartTest it
傳送一則應該觸發該技能的訊息:
openclaw agent --message "give me a greeting"或開啟聊天並直接詢問代理。使用 /skill hello-world
依名稱明確叫用它。
SKILL.md 參考
必填欄位
| 欄位 | 說明 |
|---|---|
name |
使用小寫字母、數字和連字號的唯一 slug |
description |
顯示給代理並出現在探索輸出中的單行描述 |
選用 frontmatter 鍵
| 欄位 | 預設值 | 說明 |
|---|---|---|
user-invocable |
true |
將技能公開為使用者斜線命令 |
disable-model-invocation |
false |
將技能排除在代理的系統提示之外(仍可透過 /skill 執行) |
command-dispatch |
— | 設為 tool 可將斜線命令直接路由至工具,繞過模型 |
command-tool |
— | 設定 command-dispatch: tool 時要叫用的工具名稱 |
command-arg-mode |
raw |
用於工具分派時,將原始引數字串轉送給工具 |
homepage |
— | 在 macOS Skills UI 中顯示為「網站」的 URL |
關於 gating 欄位(requires.bins、requires.env 等),請參閱
Skills — Gating。
使用 {baseDir}
在技能內文中使用 {baseDir},可參照技能目錄內的檔案,
而不需要硬編碼路徑:
Run the helper script at `{baseDir}/scripts/run.sh`.加入條件式啟用
為你的技能加上 gate,使其只在相依項可用時才載入:
---name: gemini-searchdescription: Search using Gemini CLI.metadata: { "openclaw": { "requires": { "bins": ["gemini"] }, "primaryEnv": "GEMINI_API_KEY" } }---Gating options
| 鍵 | 說明 |
|---|---|
requires.bins |
所有二進位檔都必須存在於 PATH |
requires.anyBins |
至少一個二進位檔必須存在於 PATH |
requires.env |
每個環境變數都必須存在於程序或設定中 |
requires.config |
每個 openclaw.json 路徑都必須為 truthy |
os |
平台篩選器:["darwin"]、["linux"]、["win32"] |
always |
設為 true 可略過所有 gate,並一律包含該技能 |
完整參考:Skills — Gating。
Environment and API keys
在 openclaw.json 中將 API 金鑰連接到技能項目:
{ skills: { entries: { "gemini-search": { enabled: true, apiKey: { source: "env", provider: "default", id: "GEMINI_API_KEY" }, }, }, },}該金鑰只會在該代理回合中注入主機程序。 它不會進入沙盒;請參閱 沙盒化環境變數。
透過 Skill Workshop 提案
若是代理草擬的技能,或你希望技能上線前先經由操作員審查,
請使用 Skill Workshop 提案,而不是直接撰寫
SKILL.md。
# Propose a brand-new skillopenclaw skills workshop propose-create \ --name "hello-world" \ --description "A simple skill that prints a greeting." \ --proposal ./PROPOSAL.md # Propose an update to an existing skillopenclaw 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>完整的提案生命週期請參閱 Skill Workshop。
發布到 ClawHub
Ensure your SKILL.md is complete
確認已設定 name、description,以及任何 metadata.openclaw
gating 欄位。如果你有專案頁面,請加入 homepage URL。
Install the ClawHub skill
ClawHub 技能會記錄目前發布命令的形式和必要中繼資料:
openclaw skills install @openclaw/clawhub-publishPublish
clawhub publish完整流程請參閱 ClawHub — Publishing。