Skip to main content

ขยาย Claude ด้วย Skills

สร้าง จัดการ และแชร์ skills เพื่อขยายความสามารถของ Claude ใน Claude Code รวมถึง custom commands และ bundled skills

Skills ขยายสิ่งที่ Claude ทำได้ สร้างไฟล์ SKILL.md พร้อมคำสั่ง และ Claude จะเพิ่มเข้าใน toolkit ของมัน Claude ใช้ skills เมื่อเกี่ยวข้อง หรือคุณสามารถเรียกใช้โดยตรงด้วย /skill-name

Custom commands ถูก merge เข้าสู่ skills แล้ว ไฟล์ที่ .claude/commands/deploy.md และ skill ที่ .claude/skills/deploy/SKILL.md ทั้งสองสร้าง /deploy และทำงานเหมือนกัน ไฟล์ .claude/commands/ ที่มีอยู่ยังคงทำงาน

Claude Code skills ปฏิบัติตาม Agent Skills open standard

Bundled Skills

Claude Code มี bundled skills พร้อมใช้ในทุก session เว้นแต่ปิดใช้งานด้วย disableBundledSkills รวมถึง /code-review, /batch, /debug, /loop และ /claude-api

รันและยืนยัน App

Skillวัตถุประสงค์
/runเปิดและขับเคลื่อน app ของคุณเพื่อดูการเปลี่ยนแปลงที่ทำงาน
/verifyBuild และรัน app เพื่อยืนยัน code change
/run-skill-generatorสอน /run และ /verify วิธี build และเปิด project

เริ่มต้น

สร้าง Skill แรกของคุณ

ตัวอย่างนี้สร้าง skill ที่สรุปการเปลี่ยนแปลงที่ uncommitted ใน git repository:

ขั้นที่ 1: สร้าง skill directory

mkdir -p ~/.claude/skills/summarize-changes

ขั้นที่ 2: เขียน SKILL.md

บันทึกไปยัง ~/.claude/skills/summarize-changes/SKILL.md:

---
description: Summarizes uncommitted changes and flags anything risky. Use when the user asks what changed, wants a commit message, or asks to review their diff.
---

## Current changes

!`git diff HEAD`

## Instructions

Summarize the changes above in two or three bullet points, then list any risks you notice such as missing error handling, hardcoded values, or tests that need updating.

ขั้นที่ 3: ทดสอบ skill

เปิด git project แล้วรัน Claude Code คุณสามารถทดสอบ 2 วิธี:

ให้ Claude เรียกใช้อัตโนมัติ:

What did I change?

หรือเรียกใช้โดยตรง:

/summarize-changes

ตำแหน่ง Skills

ตำแหน่งPathใช้ได้กับ
Enterpriseดู managed settingsผู้ใช้ทั้งหมดในองค์กร
Personal~/.claude/skills/<skill-name>/SKILL.mdทุก projects ของคุณ
Project.claude/skills/<skill-name>/SKILL.mdProject นี้เท่านั้น
Plugin<plugin>/skills/<skill-name>/SKILL.mdที่ plugin เปิดใช้งาน

กำหนดค่า Skills

Frontmatter Reference

---
name: my-skill
description: What this skill does
disable-model-invocation: true
allowed-tools: Read Grep
---

Your skill instructions here...
FieldRequiredDescription
nameไม่Display name แสดงใน skill listings
descriptionแนะนำสิ่งที่ skill ทำและเมื่อใช้ Claude ใช้นี้เพื่อตัดสินใจเมื่อใช้ skill
when_to_useไม่Context เพิ่มเติมสำหรับเมื่อ Claude ควรเรียกใช้ skill
argument-hintไม่คำใบ้แสดงใน autocomplete
argumentsไม่Named positional arguments สำหรับ $name substitution
disable-model-invocationไม่ตั้งเป็น true เพื่อป้องกัน Claude จากการโหลด skill อัตโนมัติ
user-invocableไม่ตั้งเป็น false เพื่อซ่อนจาก / menu
allowed-toolsไม่Tools ที่ Claude ใช้โดยไม่ต้องขอ permission เมื่อ skill active
disallowed-toolsไม่Tools ที่ถูกถอดออกขณะ skill active
modelไม่Model ที่ใช้เมื่อ skill active
effortไม่Effort level เมื่อ skill active
contextไม่ตั้งเป็น fork เพื่อรันใน forked subagent context
agentไม่subagent type ที่ใช้เมื่อ context: fork ถูกตั้ง

String Substitutions

VariableDescription
$ARGUMENTSArguments ทั้งหมดที่ผ่านเมื่อเรียกใช้ skill
$ARGUMENTS[N]เข้าถึง argument เฉพาะตาม 0-based index
$NShorthand สำหรับ $ARGUMENTS[N]
${CLAUDE_SESSION_ID}Session ID ปัจจุบัน
${CLAUDE_EFFORT}Effort level ปัจจุบัน
${CLAUDE_SKILL_DIR}Directory ที่มี SKILL.md ของ skill

Advanced Patterns

Inject Dynamic Context

Syntax !`<command>` รันคำสั่ง shell ก่อนส่ง skill content ไปยัง Claude:

---
name: pr-summary
description: Summarize changes in a pull request
context: fork
agent: Explore
allowed-tools: Bash(gh *)
---

## Pull request context
- PR diff: !`gh pr diff`
- PR comments: !`gh pr view --comments`
- Changed files: !`gh pr diff --name-only`

## Your task
Summarize this pull request...

รัน Skills ใน Subagent

เพิ่ม context: fork ใน frontmatter เมื่อต้องการให้ skill รันแบบ isolated:

---
name: deep-research
description: Research a topic thoroughly
context: fork
agent: Explore
---

Research $ARGUMENTS thoroughly:

1. Find relevant files using Glob and Grep
2. Read and analyze the code
3. Summarize findings with specific file references

ควบคุมการเข้าถึง Skill ของ Claude

ปิดใช้งาน skills ทั้งหมด:

# เพิ่มใน deny rules:
Skill

อนุญาตหรือปฏิเสธ skills เฉพาะ:

# อนุญาตเฉพาะ skills บางอย่าง
Skill(commit)
Skill(review-pr *)

# ปฏิเสธ skills เฉพาะ
Skill(deploy *)

แชร์ Skills

Skills สามารถกระจายในขอบเขตต่าง ๆ:

  • Project skills: Commit .claude/skills/ ไปยัง version control
  • Plugins: สร้าง skills/ directory ใน plugin ของคุณ
  • Managed: Deploy organization-wide ผ่าน managed settings

การแก้ไขปัญหา

Skill ไม่ถูก Trigger

หาก Claude ไม่ใช้ skill ของคุณเมื่อคาดหวัง:

  1. ตรวจสอบว่า description มี keywords ที่ผู้ใช้จะพูดตามธรรมชาติ
  2. ยืนยันว่า skill ปรากฏใน What skills are available?
  3. ลอง rephrase คำขอให้ตรงกับ description มากขึ้น
  4. เรียกใช้โดยตรงด้วย /skill-name

Skill ถูก Trigger บ่อยเกินไป

หาก Claude ใช้ skill ของคุณเมื่อไม่ต้องการ:

  1. ทำให้ description เฉพาะเจาะจงมากขึ้น
  2. เพิ่ม disable-model-invocation: true หากต้องการ manual invocation เท่านั้น

แหล่งข้อมูลที่เกี่ยวข้อง

  • Debug your configuration: วินิจฉัยว่าทำไม skill ไม่ปรากฏหรือถูก trigger
  • Subagents: มอบหมายงานให้ specialized agents
  • Plugins: package และกระจาย skills พร้อม extensions อื่น ๆ
  • Hooks: automate workflows รอบ tool events
  • Commands: อ้างอิงสำหรับ built-in commands และ bundled skills