Skills
การสร้าง Skills
Skills สอนเอเจนต์ว่าจะใช้เครื่องมืออย่างไรและเมื่อใด แต่ละ skill เป็นไดเรกทอรี
ที่มีไฟล์ SKILL.md พร้อม YAML frontmatter และคำแนะนำแบบ markdown
OpenClaw โหลด skills จากหลาย root ตามลำดับความสำคัญที่กำหนดไว้
สร้าง skill แรกของคุณ
Create the skill directory
Skills อยู่ในโฟลเดอร์ skills/ ของ workspace ของคุณ สร้างไดเรกทอรีสำหรับ
skill ใหม่ของคุณ:
mkdir -p ~/.openclaw/workspace/skills/hello-worldคุณสามารถจัดกลุ่ม skills ในโฟลเดอร์ย่อยเพื่อจัดระเบียบได้ — skill ยังคง
ถูกตั้งชื่อตาม frontmatter ของ SKILL.md ไม่ใช่ path ของโฟลเดอร์:
mkdir -p ~/.openclaw/workspace/skills/personal/hello-world# skill name is still "hello-world", invoked as /hello-worldWrite SKILL.md
สร้าง SKILL.md ภายในไดเรกทอรี frontmatter กำหนด metadata;
body ให้คำแนะนำแก่เอเจนต์
---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`- รักษาชื่อไดเรกทอรีและ `name` ใน frontmatter ให้สอดคล้องกัน- `description` จะแสดงให้เอเจนต์เห็นและใน slash-command discovery — ให้เป็นบรรทัดเดียวและไม่เกิน 160 อักขระ OPENCLAW_DOCS_MARKER:stepClose: OPENCLAW_DOCS_MARKER:stepOpen:IHRpdGxlPSJWZXJpZnkgdGhlIHNraWxsIGxvYWRlZCI ```bashopenclaw skills listโดยค่าเริ่มต้น OpenClaw จะเฝ้าดูไฟล์ SKILL.md ใต้ skills roots หาก
watcher ถูกปิดใช้งานหรือคุณกำลังดำเนินการต่อใน session เดิม ให้เริ่ม
session ใหม่เพื่อให้เอเจนต์ได้รับรายการที่รีเฟรชแล้ว:
# From chat — archive current session and start fresh/new # Or restart the gatewayopenclaw gateway restartTest it
ส่งข้อความที่ควรกระตุ้น skill:
openclaw agent --message "give me a greeting"หรือเปิด chat แล้วถามเอเจนต์โดยตรง ใช้ /skill hello-world เพื่อ
เรียกใช้อย่างชัดเจนตามชื่อ
เอกสารอ้างอิง SKILL.md
ฟิลด์ที่จำเป็น
| ฟิลด์ | คำอธิบาย |
|---|---|
name |
slug ที่ไม่ซ้ำ โดยใช้ตัวอักษรพิมพ์เล็ก ตัวเลข และขีดกลาง |
description |
คำอธิบายบรรทัดเดียวที่แสดงให้เอเจนต์เห็นและในผลลัพธ์ discovery |
คีย์ frontmatter ที่ไม่บังคับ
| ฟิลด์ | ค่าเริ่มต้น | คำอธิบาย |
|---|---|---|
user-invocable |
true |
เปิดเผย skill เป็น slash command สำหรับผู้ใช้ |
disable-model-invocation |
false |
ไม่ใส่ skill ใน system prompt ของเอเจนต์ (ยังคงรันผ่าน /skill) |
command-dispatch |
— | ตั้งเป็น tool เพื่อ route slash command ไปยังเครื่องมือโดยตรง โดยข้ามโมเดล |
command-tool |
— | ชื่อเครื่องมือที่จะเรียกใช้เมื่อมีการตั้งค่า command-dispatch: tool |
command-arg-mode |
raw |
สำหรับ tool dispatch ส่งต่อสตริง args ดิบไปยังเครื่องมือ |
homepage |
— | URL ที่แสดงเป็น "เว็บไซต์" ใน macOS Skills UI |
สำหรับฟิลด์ gating (requires.bins, requires.env และอื่นๆ) โปรดดู
Skills — Gating
การใช้ {baseDir}
ใช้ {baseDir} ใน body ของ skill เพื่ออ้างอิงไฟล์ภายในไดเรกทอรีของ skill
โดยไม่ต้อง hardcode path:
Run the helper script at `{baseDir}/scripts/run.sh`.การเพิ่มการเปิดใช้งานแบบมีเงื่อนไข
ตั้ง gate ให้ skill ของคุณเพื่อให้โหลดเฉพาะเมื่อ dependencies พร้อมใช้งาน:
---name: gemini-searchdescription: Search using Gemini CLI.metadata: { "openclaw": { "requires": { "bins": ["gemini"] }, "primaryEnv": "GEMINI_API_KEY" } }---Gating options
| คีย์ | คำอธิบาย |
|---|---|
requires.bins |
binary ทั้งหมดต้องมีอยู่บน PATH |
requires.anyBins |
ต้องมี binary อย่างน้อยหนึ่งรายการบน PATH |
requires.env |
env var แต่ละตัวต้องมีอยู่ใน process หรือ config |
requires.config |
path ของ openclaw.json แต่ละรายการต้องเป็น truthy |
os |
ตัวกรอง platform: ["darwin"], ["linux"], ["win32"] |
always |
ตั้งเป็น true เพื่อข้าม gates ทั้งหมดและรวม skill ไว้เสมอ |
เอกสารอ้างอิงฉบับเต็ม: Skills — Gating
Environment and API keys
เชื่อม API key เข้ากับรายการ skill ใน openclaw.json:
{ skills: { entries: { "gemini-search": { enabled: true, apiKey: { source: "env", provider: "default", id: "GEMINI_API_KEY" }, }, }, },}key จะถูกฉีดเข้าไปใน host process สำหรับ agent turn นั้นเท่านั้น key จะไม่ไปถึง sandbox — โปรดดู sandboxed env vars
เสนอผ่าน Skill Workshop
สำหรับ skills ที่เอเจนต์ร่างขึ้น หรือเมื่อคุณต้องการให้ operator review ก่อนที่ skill จะ
ใช้งานจริง ให้ใช้ proposals ของ 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 เมื่อ proposal มีไฟล์สนับสนุน:
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/
หลัง review:
openclaw skills workshop inspect <proposal-id>openclaw skills workshop apply <proposal-id>ดู Skill Workshop สำหรับ lifecycle ของ proposal ฉบับเต็ม
การเผยแพร่ไปยัง ClawHub
Ensure your SKILL.md is complete
ตรวจสอบให้แน่ใจว่าได้ตั้งค่า name, description และฟิลด์ gating ของ metadata.openclaw
ทั้งหมดแล้ว เพิ่ม URL homepage หากคุณมีหน้าโปรเจกต์
Install the ClawHub skill
skill ของ ClawHub จัดทำเอกสารรูปแบบคำสั่ง publish ปัจจุบันและ metadata ที่จำเป็น:
openclaw skills install @openclaw/clawhub-publishPublish
clawhub publishดู ClawHub — Publishing สำหรับ flow ฉบับเต็ม
แนวปฏิบัติที่ดีที่สุด
ที่เกี่ยวข้อง
ลำดับการโหลด, gating, allowlists และรูปแบบ SKILL.md
คิว proposal สำหรับ skills ที่เอเจนต์ร่างขึ้น
schema config skills.* ฉบับเต็ม
เรียกดูและเผยแพร่ skills บน public registry
Plugins สามารถจัดส่ง skills ควบคู่กับเครื่องมือที่เอกสารอธิบายได้