Minh là tech lead của team 8 người, làm sản phẩm SaaS trên Next.js + TypeScript. Anh dùng Claude Code mỗi ngày để review PR.
- Định nghĩa một Claude Code skill là gì và cấu trúc tối giản của nó
- Phân biệt personal skill (~/.claude/skills) và project skill (.claude/skills)
- Giải thích sự khác nhau giữa skill, CLAUDE.md, và slash command — dưới góc độ thời điểm load
- Nhận diện tình huống nào là "a skill waiting to be written"
- Hiểu tại sao skill là open standard — không khóa chặt vào một nền tảng
Skill là gì — Định nghĩa kỹ thuật
Có 3 từ khóa quan trọng trong định nghĩa trên:
1. "Folder" — không phải file đơn lẻ
Otto, engineer ở Anthropic, nhấn mạnh: "Skills as organized folders that package expertise." Skill không phải 1 file .md. Nó là 1 thư mục mà trong đó, SKILL.md là entry point, và có thể có:
Folder cho phép progressive disclosure — Claude chỉ đọc SKILL.md trước, rồi mới đọc file phụ nếu cần. Chi tiết ở Bài 15.3.
2. "Frontmatter" với name và description
Frontmatter là phần metadata ở đầu file SKILL.md, ngăn bởi ---:
Hai field bắt buộc:
Phần còn lại sau frontmatter là instructions — hướng dẫn Claude sẽ đọc khi skill được kích hoạt.
3. "Tự động kích hoạt qua semantic matching"
Đây là điểm khác biệt quan trọng nhất với slash command. Slash command bạn phải gõ /tên-command. Skill thì không cần.
Khi Claude Code khởi động, nó quét 4 location (chi tiết Bài 15.2), load chỉ name + description (chưa load full content). Rồi mỗi khi bạn gõ request:
- name: tên skill (lowercase, dấu gạch ngang, max 64 chars, khớp với tên folder)
- description: mô tả khi nào nên dùng skill (max 1024 chars, quan trọng nhất)
pr-review/ ← tên skill = tên folder
├── SKILL.md ← entry point (luôn có, bắt buộc)
├── references/ ← (optional) chi tiết deep dive
│ └── owasp-checklist.md
├── scripts/ ← (optional) script executable
│ └── count-test-coverage.sh
└── assets/ ← (optional) template, image
└── review-template.md
name: pr-review
description: Reviews pull requests for code quality. Use when reviewing PRs or checking code changes.
When reviewing a PR, follow this checklist:
1. Run `git diff main...HEAD`
2. Check: ...3. "Tự động kích hoạt qua semantic matching"
Đây gọi là semantic matching — không cần keyword exact, Claude hiểu ý định của bạn.
Bạn: "Review this PR for me"
↓
Claude so sánh "Review this PR" với description
của tất cả skill đã biết
↓
Match với skill pr-review (description: "Reviews pull requests...")
↓
Claude hỏi bạn xác nhận (confirmation prompt)
↓
Bạn OK → Claude load full SKILL.md → làm theo instructionsCấu trúc một skill tối giản
Đây là skill đơn giản nhất có thể (2 field bắt buộc + vài dòng instructions):
Một file duy nhất. Không dependencies. Không config gì thêm. Đây là mức tối thiểu để skill hoạt động.
Khi bạn tiến xa hơn, sẽ thêm field allowed-tools, model, folder references/, scripts/... — Bài 15.3.
name: pr-review
description: Reviews pull requests for code quality. Use when reviewing PRs or checking code changes.
When reviewing a pull request:
1. Run `git diff main...HEAD` to see the changes
2. Check for:
- TypeScript typing issues
- Missing tests for new code paths
- Security concerns (SQL injection, XSS, secrets in code)
3. Write feedback with this structure:
- **What works well:** (2-3 points)
- **Issues to fix:** (critical/major/minor)
- **Suggestions:** (optional improvements)
4. Tone: constructive, specific, avoid personal criticismSkill sống ở đâu?
Personal skills — ~/.claude/skills/
Nơi sống của skill của riêng bạn, đi theo bạn qua mọi project.
Windows path: C:\Users\<username>\.claude\skills\.
Phù hợp cho:
Project skills — .claude/skills/ trong repo
Nơi sống của skill team bạn chia sẻ, commit vào repository.
Ai clone repo về đều có những skill này. Không cần cài thêm. Push update → team pull về là có bản mới. Đây là cách chia sẻ chuẩn nhất cho team coding standards — chi tiết ở Bài 15.5.
Thứ tự ưu tiên (khi trùng tên)
Nếu bạn có pr-review ở cả personal và project, cái nào thắng? Có 4 tầng priority:
Chi tiết về enterprise ở Bài 15.5. Debug conflict ở Bài 15.6.
- Style cá nhân của bạn khi viết PR description
- Format commit message bạn ưa thích
- Cách bạn muốn Claude giải thích code (với diagram, analogy...)
- Checklist debug cho framework bạn chuyên sâu
┌────────────────────────────────────────┐ │ 1. Enterprise (managed settings) │ ← cao nhất ├────────────────────────────────────────┤ │ 2. Personal (~/.claude/skills) │ ├────────────────────────────────────────┤ │ 3. Project (.claude/skills) │ ├────────────────────────────────────────┤ │ 4. Plugins (installed plugins) │ ← thấp nhất └────────────────────────────────────────┘
Claude match skill với request như thế nào?
Cơ chế matching là điểm dễ gây hiểu lầm nhất. Hãy đi chậm.
Bước 1: Startup — load metadata only
Khi Claude Code khởi động, nó scan 4 location và load chỉ name + description của mỗi skill vào system prompt. Không load full content.
Bước 2: Request matching
Bạn gõ: "Giải thích function này cho tôi".
Claude so sánh câu này với description của tất cả skill đã biết. Giả sử có skill mô tả "Explains code using visual diagrams and analogies" — semantic matching nhận ra "explain" + "function" overlap với "explain code".
Bước 3: Confirmation
Claude hỏi bạn:
Bước này không tự ý bỏ qua. Nó bảo đảm bạn biết context nào Claude đang đưa vào conversation của mình. Quan trọng cho security và transparency.
Bước 4: Load full + execute
Bạn xác nhận → Claude đọc toàn bộ SKILL.md (bây giờ mới load chi tiết) → làm theo instructions.
Biểu đồ tổng quan
Mô hình này là progressive disclosure — bạn chỉ "trả tiền" context window cho những skill thực sự được dùng.
STARTUP RUNTIME (mỗi lần bạn gõ request)
───────── ────────────────────────────────
Scan 4 locations You: "Review this PR"
↓ ↓
Load name+desc Claude semantic match
của từng skill ↓
(30-50 tok/skill) Found: skill pr-review
↓ ↓
System prompt Show confirmation
cache ready ↓
You confirm
↓
Claude loads full SKILL.md
↓
Claude follows instructionsI'd like to use the "explain-code-visually" skill for this.
It matches your request about explaining code. Proceed?
[y/n]Skill vs CLAUDE.md vs Slash Command
Đây là câu hỏi thường gặp nhất: "Tôi đã có CLAUDE.md / slash command rồi, skill thêm gì nữa?"
Sự khác biệt nằm ở khi nào load và ai trigger:
Câu hỏi quyết định: "Nó luôn luôn áp dụng, hay đôi khi áp dụng?"
Ví dụ cụ thể
| Tình huống | Dùng cái gì? Tại sao |
|---|---|
| "Project này dùng Next.js 14 App Router" | CLAUDE.md — luôn áp dụng |
| "Review PR theo checklist của team" | Skill — chỉ đôi khi, tự nhận |
| "Format diff của tôi thành markdown bảng đẹp" | Slash command — bạn gõ lúc cần |
| "Viết commit message theo Conventional Commits" | Skill — tự kích hoạt khi bạn nói "commit" |
| "Không bao giờ modify schema database trực tiếp" | CLAUDE.md — constraint luôn luôn |
| "Prep brief cho meeting sáng mai" | Skill — tự nhận khi bạn nói "prep meeting" |
┌──────────────────────────────────────────────────┐ │ │ │ Instruction này có áp dụng │ │ mọi conversation của project này? │ │ │ │ ┌─── CÓ ──→ CLAUDE.md │ │ │ │ │ └─── KHÔNG ──→ Hỏi tiếp: │ │ │ │ Bạn muốn trigger tay, │ │ hay muốn Claude tự nhận? │ │ │ │ ┌─── Trigger tay ──→ Slash command │ │ │ │ │ └─── Tự nhận ──→ SKILL │ │ │ └──────────────────────────────────────────────────┘
Ví dụ theo ngành — Khi nào là skill?
💼 Sales Operations
Pain: Tối nào Bảo — sales ops — cũng tổng hợp deal week-over-week. Paste lại format bảng, nhắc lại KPI quan trọng, yêu cầu Claude check CRM + Slack channel #sales. 15 phút mỗi ngày chỉ để "prompt lại".
Thành skill:
Kết quả: 15 phút/ngày → 1 phút (chỉ cần nói "tổng hợp sales tuần này").
📣 Content Marketing
Pain: Linh viết 5 blog post/tuần. Mỗi post, cô phải paste lại brand guideline (tone, từ cấm, emoji policy), SEO checklist, CTA template. Tổng 200 dòng prompt prefix cho mỗi bài.
Thành skill:
name: weekly-sales-digest
description: Generates weekly sales digest from CRM and Slack data. Use when asked for weekly sales update, sales summary, or end-of-week report.
Sources to pull: CRM deals closed this week, Slack #sales messages tagged
[win], emails with "Proposal" in subject...
Output format: ...📣 Content Marketing
Kết quả: 200 dòng prompt → 0 dòng. Tone nhất quán 100% các bài.
💰 Finance Analyst
Pain: Hằng reconcile báo cáo tháng. Mỗi lần cần instruct Claude: chạy match_transactions.py, flag variance > $5000, xuất Excel 3 sheet (matched, unmatched, flagged). Paste 3 sheet template mỗi lần.
Thành skill với multi-file:
Kết quả: Claude gọi script thay vì generate từ đầu (chính xác hơn), template auto-applied. 45 phút → 10 phút.
⚖️ Legal Operations
Pain: Review NDA, mỗi lần phải nhắc Claude check 12 điều khoản chuẩn (jurisdiction, term, confidentiality scope, carve-outs, liability cap...). Claude thỉnh thoảng miss 1-2 điều khoản.
Thành skill:
monthly-close/
├── SKILL.md ← instructions chính
├── scripts/
│ └── match_transactions.py ← script executable
└── assets/
└── excel-template.xlsx ← template 3 sheet
name: blog-post-writer
description: Writes blog posts following company brand guidelines and SEO best practices. Use when writing a blog post, article, or web content.
[Instructions ngắn gọn]
[Link tới references/brand-tone.md cho chi tiết]
[Link tới references/seo-checklist.md]⚖️ Legal Operations
allowed-tools restrict Claude chỉ có thể đọc, không edit file contract → đảm bảo Claude không vô tình modify NDA.
Kết quả: 0 điều khoản bị miss, peace of mind cho legal team.
🏥 Healthcare Operations
Pain: Clinical research coordinator consolidate patient records hàng tuần. Pull lab results, imaging, notes vào unified timeline. Mỗi lần cần instruct: "theo thứ tự time, flag giá trị bất thường, list current medications...".
Thành skill:
name: nda-review
description: Reviews NDA contracts against company standard terms. Use when reviewing NDA, confidentiality agreement, or legal document starting with "Non-Disclosure".
allowed-tools: Read, Grep, Glob
[12-point checklist]
[Red flag patterns]🏥 Healthcare Operations
Kết quả: 30 phút/patient → 5 phút. Zero inconsistency.
name: patient-record-consolidation
description: Consolidates patient records into unified timeline. Use when processing patient data, creating medical summary, or preparing case review.
Process:
1. Timeline-based aggregation
2. Flag lab values outside normal range
3. Extract current medications
4. Privacy: never log patient names outside processingSkill là open standard — không vendor lock-in
Một điểm mà DBS tutorial nhấn mạnh: skill format là open standard (agentskills.io). Không chỉ hoạt động với Claude.
Skill pr-review bạn viết hôm nay có thể dùng ở:
Đây là điểm rất khác với "một prompt template riêng cho mỗi tool". Bạn đầu tư viết skill 1 lần, dùng nhiều chỗ.
- Claude Code (terminal + IDE)
- Claude.ai (web, paid plan)
- Claude API (programmatic)
- Các agentic tool khác implement cùng standard
Anti-patterns — Những sai lầm cần tránh
❌ Biến CLAUDE.md constraint thành skill
Sai lầm: Tạo skill use-typescript-strict với description "Always use TypeScript strict mode".
Tại sao sai: Constraint này luôn luôn áp dụng. Nếu là skill, Claude phải "match" vào mỗi request — thừa thãi. Quan trọng hơn, nếu skill không trigger (do description mismatch), bạn mất constraint.
Cách đúng: Để trong CLAUDE.md của project.
❌ Description quá chung chung
Sai lầm:
Tại sao sai: Semantic matching cần overlap cụ thể. "Helps with code" match với mọi request liên quan code — Claude bối rối, trigger sai skill.
Cách đúng: Action cụ thể + trigger phrase:
description: Helps with code.❌ Description quá chung chung
❌ Một skill "làm tất cả"
Sai lầm: Skill dev-helper với description liệt kê 10 thứ: "review code, write tests, format commits, debug errors, explain code...".
Tại sao sai: Mơ hồ → match không chính xác. Hơn nữa, khi 10 thứ gộp, file SKILL.md bị phình to.
Cách đúng: 1 skill = 1 task. Có pr-review, test-generator, commit-format — 3 skill riêng, mỗi cái description rõ.
❌ Nhồi cả 40 trang PDF vào SKILL.md
Sai lầm: Copy toàn bộ brand book 40 trang vào SKILL.md.
Tại sao sai: Mỗi lần skill kích hoạt, ăn hết 30% context window. Duplicate trong mỗi conversation.
Cách đúng: Progressive disclosure — SKILL.md ngắn, link tới references/brand-book.md, Claude chỉ đọc khi cần. Chi tiết Bài 15.3.
description: Reviews pull requests for code quality issues. Use when asked to "review this PR", "check my changes", or "give me PR feedback".Áp dụng ngay
Bài tập: Xác định 3 skill candidate đầu tiên (~10 phút)
Bước 1: Mở lịch sử chat Claude Code gần nhất (7 ngày qua). Tìm ít nhất 3 lần bạn paste cùng 1 instruction nhiều lần.
Bước 2: Với mỗi lần paste, trả lời 3 câu:
Bước 3: Phân loại:
Bước 4: Chọn 1 skill để build ở Bài 15.2. Ưu tiên cái:
- Instruction nào luôn luôn áp dụng → để trong CLAUDE.md.
- Instruction nào chỉ áp dụng đôi khi, tự động → candidate cho skill.
- Instruction nào bạn muốn trigger tay (ví dụ: /format-diff) → candidate cho slash command.
- Bạn làm nhiều nhất (ít nhất 3 lần/tuần)
- Same format every time (không phải cái mỗi lần khác nhau)
- Dễ mô tả trigger phrase (không phải "help me with random stuff")
| Câu hỏi | Lần 1 | Lần 2 | Lần 3 |
|---|---|---|---|
| Instruction đó nội dung gì? | _______ | _______ | _______ |
| Bạn trigger nó bằng câu gì? ("review PR", "write commit", ...) | _______ | _______ | _______ |
| Tên skill bạn sẽ đặt? (lowercase-dash) | _______ | _______ | _______ |
Tóm tắt bài học
🎯 Skill = folder + SKILL.md + frontmatter name/description — không phải prompt đơn lẻ, không phải config đơn giản.
🎯 Semantic matching qua description — Claude tự nhận request có match skill nào không, rồi hỏi xác nhận trước khi load full content.
🎯 Personal (~/.claude/skills) đi theo bạn, Project (.claude/skills) đi theo repo — commit vào Git để team cùng dùng.
🎯 Priority 4 tầng: Enterprise > Personal > Project > Plugins. Trùng tên → tầng cao thắng.
🎯 Không phải mọi instruction đều nên là skill. Nếu nó "luôn luôn" áp dụng → CLAUDE.md. Nếu "đôi khi và tự động" → skill. Nếu "user trigger tay" → slash command.
🎯 Open standard — skill bạn viết cho Claude dùng được ở API, Claude.ai, và các tool khác implement agentskills.io. Không vendor lock.
- agentskills.io — open standard specification
- Claude Code documentation — Skills — official docs
- Otto (Anthropic), "Claude Agent Skills Explained" — video