Mục tiêu học tập
Sau bài này, bạn sẽ có thể:- ✅ Liệt kê đầy đủ 4 metadata field (
name,description,allowed-tools,model) và biết khi nào dùng field nào - ✅ Viết description trigger đúng 95%+ request relevant, bằng công thức “2 câu hỏi + trigger phrases”
- ✅ Dùng
allowed-toolsđể tạo read-only skill / security-sensitive skill an toàn - ✅ Cấu trúc multi-file skill với
references/,scripts/,assets/theo progressive disclosure - ✅ Viết script executable trong skill — Claude run, không read — tiết kiệm context
Mở đầu: Từ skill 20 dòng sang skill 2000 dòng
Skillsimple-page-builder bạn vừa làm ở Bài 15.2 có khoảng 100 dòng. Đơn giản, đủ dùng. Nhưng hãy xem case sau:
Tình huống của Linh — Content Marketer
Linh build skillblog-post-writer cho team. Version đầu, cô gom tất cả vào 1 file:
- Mỗi lần skill trigger → ăn 30% context window chỉ riêng skill này
- Khi Linh cần làm việc khác sau khi viết blog, context đã bị skill blog chiếm, Claude “lú”
- Team muốn update brand voice (1 dòng): phải mở file 1800 dòng tìm đoạn → sửa → rất dễ sai
4 metadata field — full spec
Bài 15.1 và 15.2 bạn đã biết 2 field bắt buộc. Bài này complete bức tranh.| Field | Bắt buộc? | Mục đích |
|---|---|---|
name | ✅ Có | Identify skill, match với folder |
description | ✅ Có | Match criteria (Claude dùng để trigger) |
allowed-tools | ❌ Optional | Restrict tool Claude được dùng khi skill active |
model | ❌ Optional | Chọn Claude model cho skill |
Field 1: name
- Lowercase, số, dấu gạch ngang (
-) only - Max 64 chars
- Phải khớp tên folder
- Không underscore, không space, không uppercase
Field 2: description — Quan trọng nhất
Max 1024 chars. Nhưng bạn không nên dùng hết. 150-300 chars là sweet spot. Tại sao quan trọng nhất? Vì Claude dùng chỉ description để quyết định có trigger skill hay không. Code bạn viết, tool bạn config — không matter nếu description không match. Chi tiết cách viết ở phần “Writing effective descriptions” dưới đây.Field 3: allowed-tools — Guardrail bảo mật
Khi skill active, Claude chỉ được dùng tools liệt kê trong field này. Không cóEdit, không có Write, không Bash → skill không thể modify gì cả.
Format: comma-separated list tên tool.
Read,Write,Edit— file operationsGrep,Glob— searchBash— shell commandWebFetch,WebSearch— internet access- … xem docs Claude Code cho full list
Field 4: model — Chọn Claude model
Specify model chạy skill:- haiku cho skill lặp đi lặp lại, simple (format commit, extract field từ text)
- sonnet cho hầu hết case (default, good balance)
- opus cho skill cần reasoning sâu (code review complex, architectural decision)
opus cho task format đơn giản.
Writing effective descriptions — Công thức
Nguyên tắc: Description phải trả lời 2 câu hỏi
- Skill này làm gì? (action cụ thể)
- Khi nào Claude nên dùng? (trigger phrases)
Công thức 3 phần
Ví dụ tiến hóa của 1 description
V1 — ❌ Quá chung:- Action: “Creates landing pages and simple signup pages”
- Use case nuanced: “for campaigns”
- 4 trigger phrases: cover cách diễn đạt khác nhau user thực tế dùng
Test trigger phrases
Trước khi finalize description, viết 5 câu user có thể gõ để trigger skill:| Variation | Match hay không? |
|---|---|
| ”Tạo landing page cho khóa học yoga” | ✅ có “landing page" |
| "Làm sales page cho dịch vụ spa” | ✅ có “sales page" |
| "Viết page cho campaign Tết” | ✅ có “campaign page" |
| "Tạo trang đăng ký học thử” | ✅ có “register/signup page" |
| "Thiết kế màn hình login” | ❌ skill này chưa cover login |
login-page-checklist.
Litton’s tip (AI University)
“In order to trigger a specific task related to that skill you need to provide a concrete trigger word or magic word. In my case my trigger word would be ‘email personalization’.”Cách reliable nhất: có 1 trigger phrase “magic” user memorize, đồng thời cover các variation khác. Ví dụ:
- Magic: “landing page brief”
- Variations: “sales page”, “campaign page”, “register page”, “signup page”
allowed-tools — Deep dive
Tại sao cần tool restriction?
3 scenario thực tế:Scenario 1: Read-only audit skill
Bạn build skillsecurity-audit — Claude scan code tìm lỗ hổng. Không được sửa gì để team review manual. Nếu skill không restrict, Claude có thể “chủ động” sửa — risky.
Edit, Write, Bash → Claude chỉ đọc, không thể touch file.
Scenario 2: Compliance workflow
Finance team có skillmonthly-reconcile. Output phải là Excel file mới, không được sửa source files (bank statement, invoice log).
Write để tạo file mới, nhưng không có Edit để modify file hiện có.
Scenario 3: Onboarding skill cho new hire
Skillcodebase-tour giúp intern hiểu project. Không cho intern vô tình run bash làm hư repo:
Bash hoàn toàn.
Skill codebase-onboarding — complete example
Omit allowed-tools — nghĩa là gì?
Write, Edit, Bash), nhưng Claude không bị restrict về loại tool.
→ Phù hợp cho skill “general-purpose”. Không nên dùng allowed-tools nếu không có lý do cụ thể, vì nó cản Claude dùng tool hữu ích.
Progressive disclosure — Cốt lõi của multi-file skill
Vấn đề: context window hữu hạn
Mỗi conversation Claude có context window hữu hạn (ví dụ 200K token, 1M token tùy model). Tất cả — system prompt + skill metadata + user messages + tool results + skill content khi active — share cùng 1 ngân sách. Nếu skill của bạn = 2000 dòng ~50K token, mỗi lần active → 25% context đi tong cho content có thể bạn chỉ cần 10%.Solution: chia SKILL.md thành core + reference
SKILL.md, link tới file phụ với rõ context khi nào load:
Claude decision flow
Kết quả: Mỗi conversation chỉ load subset skill cần thiết. Phần còn lại “ngủ” trên disk, không ăn context.Quy tắc vàng: SKILL.md < 500 dòng
Otto set con số cụ thể. NếuSKILL.md > 500 dòng → nghĩ lại:
- Có phần nào thành reference riêng được?
- Có instruction nào chỉ cần đôi khi?
- Có example có thể move sang
references/past-examples.md?
3 subfolder chuẩn: references/, scripts/, assets/
Agent skills open standard (agentskills.io) define 3 subfolder với vai trò rõ.references/ — documentation phụ
File.md chứa chi tiết Claude đọc khi cần. Ví dụ:
SKILL.md:
Read tool để đọc file đó chỉ khi task của nó cần brand voice.
scripts/ — executable code
File code (.py, .sh, .js…) Claude run thay vì read. Đây là điểm đột phá cho skill.
Ví dụ: scripts/check-grammar.py — 200 dòng Python check ngữ pháp.
Trong SKILL.md:
- Không đọc content của
check-grammar.py(tiết kiệm context) - Run script qua
Bashtool - Chỉ output (
stdout) consume tokens
- Environment validation: check Node version, env variable có đủ
- Data transformation consistent: parse CSV, generate report
- Operations reliability hơn khi là code: regex phức tạp, API call, file processing
- Calculations chính xác: generate số, không để LLM tự tính
assets/ — static files
Files không phải instruction, không executable — mà là material:Full example: skill gamma-present (từ DBS tutorial)
Đây là skill thật DBS build trong tutorial, minimal nhưng đầy đủ cấu trúc.scripts/ vì “everything is taking place within the Gamma connector” (tất cả output qua MCP connector, không cần script). Không có assets/ vì skill không cần static file.
Nguyên tắc: Chỉ thêm subfolder khi thực sự cần. Đừng tạo scripts/ chỉ vì “standard có”. Litton (DBS): “Direction only. The skill doesn’t need blueprints because there’s no proprietary business knowledge Claude needs, and it doesn’t need solution scripts because the output is text in chat.”
Case studies theo ngành
Legal — contract-review với allowed-tools security
allowed-tools: Read, Grep, Glob— Claude không thể edit contractmodel: opus— nghiệp vụ legal cần reasoning sâu, trade costreferences/tách 3 topic → chỉ loadjurisdiction-noteskhi contract là EU
Finance — monthly-close với scripts
- 3 script Python handle heavy lifting — Claude không “imagine” logic
- Template Excel có sẵn trong
assets/→ consistent format allowed-toolskhông cóEdit→ không sửa source bank statement
Marketing — campaign-brief-generator
scripts/: Claude tự viết content, không cần script. Không có allowed-tools restriction: Claude cần tạo file brief mới.
Engineering — deploy-checklist multi-env
rollback-procedure.md và incident-playbook.md chỉ load khi bước kiểm tra fail. Không fail → không consume context.
Anti-patterns
❌ Nhồi tất cả vào SKILL.md
Triệu chứng:SKILL.md 1500+ dòng, nửa là example/reference material.
Tại sao tệ: Mỗi lần skill active → ăn toàn bộ. Không tận dụng progressive disclosure. Maintain khổ.
Cách đúng: SKILL.md < 500 dòng, split còn lại vào references/.
❌ allowed-tools quá strict
Triệu chứng:allowed-tools: Read → skill không tạo được output file.
Tại sao tệ: Skill không complete được task, user frustrated.
Cách đúng: List tối thiểu đủ tool. Audit skill → chỉ có Read. Skill tạo file → cần Write. Skill run script → cần Bash.
❌ model: opus cho mọi skill
Triệu chứng: Mọi skill setmodel: opus “cho chắc”.
Tại sao tệ: Opus chậm + đắt. Task đơn giản (format commit, extract field) chạy Haiku đủ.
Cách đúng:
- Simple repetitive →
haiku - General →
sonnethoặc omit, default - Complex reasoning →
opus
❌ Đặt executable script trong references/
Triệu chứng:references/do-thing.py với expectation Claude read content để “learn”.
Tại sao tệ: Claude sẽ đọc file vì nằm trong references/, load vào context. Nếu script 500 dòng → ăn context. Đồng thời, Claude có thể cố “simulate” logic thay vì chạy thực.
Cách đúng: Script = scripts/. SKILL.md explicit nói “run this script” (không “read”). Otto: “Tell Claude to run the script, not read it.”
❌ Description phình to liệt kê mọi use case
Triệu chứng:description 900 chars mô tả skill có thể làm 15 việc.
Tại sao tệ: Overhead startup. Matching bớt chính xác vì quá rộng.
Cách đúng: 1 skill = 1 chức năng rõ. Nếu skill đang làm 15 việc → split thành 3-5 skill.
Áp dụng ngay
Bài tập 1: Nâng cấp skill của bạn lên multi-file (~15 phút)
Lấy skill bạn viết ở Bài 15.2 (Bài tập 2). Làm tiếp: Bước 1: Identify điều gì trongSKILL.md có thể tách ra:
- Example/past cases →
references/examples.md - Checklist dài > 10 items →
references/checklist.md - Template format →
assets/template.md
SKILL.md, link tới file phụ:
SKILL.md trước/sau:
- Trước: _____ dòng
- Sau: _____ dòng
- Giảm bao nhiêu %: _____
Bài tập 2: Thêm allowed-tools cho 1 skill (~5 phút)
Tự quyết định: skill nào nên read-only cho security/consistency? Candidate:- Bất kỳ skill review/audit (code review, contract review, security audit)
- Skill explanation/tutorial (không được modify code của learner)
- Skill documentation extraction
allowed-tools: Read, Grep, Glob vào frontmatter của skill đó. Test → Claude có complete task không? Nếu cần Write (ví dụ tạo report), thêm Write vào list.
Tóm tắt bài học
🎯 4 metadata field:name, description (bắt buộc), allowed-tools, model (optional). model: opus/sonnet/haiku trade-off speed ↔ capability.
🎯 Description công thức: Action verb + object + use case + 3-5 trigger phrases. Giữ 150-300 chars. Test với variation user thực tế nói.
🎯 allowed-tools là guardrail bảo mật. Read-only skill → Read, Grep, Glob. Skill tạo report → thêm Write. Omit field = dùng permission bình thường.
🎯 Progressive disclosure: SKILL.md < 500 dòng, chi tiết vào references/, script vào scripts/, static file vào assets/. Claude chỉ load khi cần.
🎯 Script: Claude RUN, không READ. Lệnh trong SKILL.md phải explicit “run scripts/xyz.py”. Output consume tokens, content script không. Dùng script cho validation, data transform, API call, calculation.
Bài tiếp theo
Bạn đã biết cách build skill mạnh. Nhưng Claude Code còn 4 cơ chế khác —CLAUDE.md, subagents, hooks, MCP server — và chúng hay overlap với skill. Chọn sai = build sai thứ.
Bài 15.4 là decision tree giúp bạn chọn đúng công cụ. Bonus: cách combine 5 cơ chế thành setup hoàn chỉnh.
➡️ Bài tiếp theo: Bài 15.4: Skill vs CLAUDE.md / subagent / hook / MCP
Tài liệu tham khảo
- Anthropic Academy — “Configuration and multi-file skills”
- Video — “Advanced skill configuration”
- agentskills.io — full field spec
- DBS Tutorial — “Direction / Blueprints / Solutions” framework (YouTube)