Mục tiêu học tập
Sau bài này, bạn sẽ có thể:- ✅ So sánh skill với 4 cơ chế còn lại trong Claude Code:
CLAUDE.md, subagent, hook, MCP server - ✅ Chọn đúng công cụ cho mỗi use case qua decision tree rõ ràng
- ✅ Thiết kế setup kết hợp nhiều cơ chế — không force mọi thứ vào skill
- ✅ Nhận diện 3 anti-pattern phổ biến khi dev lẫn lộn các cơ chế
Mở đầu: “Tôi đã có CLAUDE.md, tôi cần skill làm gì?”
Đây là câu hỏi nhận được mỗi khi giới thiệu skill với team đã quen Claude Code. Họ cóCLAUDE.md, có slash command, một số team tiến xa hơn có subagent, hook, MCP server. Ôi thôi, thêm skill nữa à?
Câu trả lời ngắn: Không. Bạn không thêm skill. Bạn dùng đúng công cụ cho đúng việc. Skill không thay thế những cơ chế kia — nó fill in cái gap mà chúng không giải quyết tốt.
Otto (Anthropic) đưa ra công thức ngắn gọn nhất:
“Your CLAUDE.md file sets the foundation, MCP servers connect the data, subagents specialize in their roles, and Skills bring the expertise — making every piece smarter and more capable.”Foundation. Data. Roles. Expertise. Mỗi thứ có vai trò riêng, không overlap. Bài này sẽ:
- So sánh skill với từng cơ chế riêng biệt
- Đưa decision tree để bạn quyết định nhanh
- Cho case study setup đầy đủ kết hợp cả 5 cơ chế
5 cơ chế customize Claude Code — overview
| Cơ chế | Load khi nào | Ai trigger | Mục đích chính |
|---|---|---|---|
| CLAUDE.md | Mỗi conversation | Auto (luôn có mặt) | Project standards luôn áp dụng |
| Skill | Khi match request | Claude semantic match | Task-specific expertise on-demand |
| Subagent | Khi bạn delegate task | User hoặc Claude gọi | Task độc lập, isolated context |
| Hook | Khi có event (save file, tool call) | Event-driven | Side effect tự động |
| MCP server | Khi Claude cần external data | Claude qua tool call | Kết nối data/service bên ngoài |
Mental model: Claude Code như một layered system
Bạn không chọn 1 trong 5. Setup thực tế dùng nhiều cơ chế cùng lúc, mỗi cái một vai trò.Skill vs CLAUDE.md — Load khi nào?
CLAUDE.md: Always-on
Skill: On-demand
Skillpr-review chỉ load khi bạn nói “review PR này”. Còn lại, nó ngủ.
Khi nào dùng cái nào?
| Đặc điểm | CLAUDE.md | Skill |
|---|---|---|
| Luôn luôn áp dụng? | ✅ | ❌ |
| Đôi khi áp dụng (theo task)? | ❌ | ✅ |
| Cần trigger tự động semantic? | ❌ | ✅ |
| Scope: 1 project | ✅ | ✅ (project skill) |
| Scope: nhiều project | ❌ | ✅ (personal skill) |
| Token overhead mỗi conversation | 100% content | 30-50 tok/skill (metadata only) |
Ví dụ thực tế — quyết định 5 trường hợp
| Hướng dẫn | Để đâu? Tại sao |
|---|---|
| ”Project này dùng Next.js 14” | CLAUDE.md — luôn cần biết |
| ”Never modify /migrations/ directly” | CLAUDE.md — constraint luôn luôn |
| ”Review PR theo checklist 15 điểm” | Skill — chỉ khi review PR |
| ”Format commit theo Conventional Commits” | Skill — trigger khi commit |
| ”All API routes live in src/app/api/“ | CLAUDE.md — structural, always relevant |
Anti-pattern: CLAUDE.md phình to
Sai lầm: Nhồi mọi instruction vàoCLAUDE.md — review checklist, email template, report format, debug procedure…
Hậu quả: Mỗi conversation ăn 40% context cho content có thể chỉ cần 5%.
Cách đúng: CLAUDE.md chỉ giữ thứ luôn áp dụng. Còn lại → skill.
Otto hỏi ngược: “Look at your current CLAUDE.md file. Is there anything in it that would work better as a skill (loaded only when relevant)?” Answer cho hầu hết team: có.
Skill vs Subagent — Cùng context vs isolated
Skill: Join current context
Khi skillpr-review trigger, nó thêm instructions vào cuộc hội thoại đang chạy. Context hiện tại (code bạn đang xem, conversation history) vẫn ở đó. Skill làm Claude thông minh hơn trong context hiện tại.
Subagent: Separate context
Subagent là Claude khác chạy trong context riêng, isolated. Bạn delegate task cho nó, nó làm xong, trả result về bạn. Nó không thấy conversation history của bạn, không share context.Khi nào dùng cái nào?
Dùng Skill khi:- Bạn muốn cùng conversation smarter về task
- Expertise apply throughout remaining conversation
- Ví dụ: activate PR review skill → mọi review tiếp theo trong session vẫn có expertise đó
- Bạn muốn task độc lập — không pollute main context
- Cần tool access khác main conversation (ví dụ subagent có quyền
Bashmà main không có) - Parallelize: chạy 5 subagent concurrent cho 5 file khác nhau
- Ví dụ: delegate “phân tích 10 file log” cho subagent — kết quả về main, không bloat main context
Skill ↔ Subagent: Hoạt động cùng nhau
Đây là điểm quan trọng dễ miss: Subagent có thể dùng skill. Otto giải thích:“Your front-end developer subagent can use a component pattern skill. Your UI reviewer subagent can use a design system skill, but both can load and use the same accessibility standard skill.”Skill là portable expertise — share được giữa subagent. Bạn không build lại expertise cho mỗi subagent. Setup mẫu:
Skill vs Hook — Request-driven vs Event-driven
Hook: Fire on event
Hook là automation chạy khi có event xảy ra:- File save → run linter
- Before bash call → validate input
- After
Edittool → auto-format
Skill: Fire on request
Skill trigger khi user hỏi điều match với description. Claude làm trung gian.Khi nào dùng cái nào?
| Situation | Hook | Skill |
|---|---|---|
| Auto-format file sau save | ✅ | ❌ |
| Validate input trước khi run bash | ✅ | ❌ |
| Review PR theo standard | ❌ | ✅ |
| Write commit message | ❌ | ✅ |
| Log mỗi tool call ra file | ✅ | ❌ |
| Explain code when asked | ❌ | ✅ |
Rule of thumb
- Hook = “operation chạy không cần Claude suy nghĩ” — tự động, deterministic
- Skill = “knowledge để Claude dùng khi reasoning” — Claude vẫn là người quyết định
Case: Lint workflow
Cách tệ (dùng skill):git commit. Không dựa vào user.
Skill vs MCP Server — Expertise vs Data connection
Đây là phần gây confuse nhất. Vì cả skill và MCP đều “extend Claude”.MCP (Model Context Protocol): Connection tới external world
MCP là open protocol cho phép Claude truy cập data/service bên ngoài:- MCP server cho GitHub → Claude đọc/write issue, PR, code
- MCP server cho Postgres → Claude query database
- MCP server cho Slack → Claude đọc tin nhắn
Skill: Expertise về cách làm gì với data
Skill không fetch data. Skill chứa instructions.Otto’s killer one-liner
“MCP connects to data, Skills teach Claude what to do with it.”Clean nhất trong tất cả explanation. Memorize đi.
Ví dụ cụ thể — MCP + Skill hoạt động cùng nhau
Setup:- Match skill
pr-review→ load instructions - Instructions nói:
gh pr view 142hoặc dùng MCPgithub.get_pr(142)lấy diff - Instructions nói: check X, Y, Z theo checklist
- Instructions nói: comment review qua MCP
github.comment_pr(142, ...)
- Chỉ MCP không skill → Claude có thể đọc PR nhưng review không theo style team
- Chỉ skill không MCP → Claude biết cách review nhưng không access được PR
Setup cho team thực tế
Litton (AI University) cho workflow mẫu:“Skills can call MCP servers. That means Claude can connect with Gmail, Slack, Telegram and even your CRM.”Skill orchestrate. MCP cung cấp tool. 2 thứ complement, không compete.
Decision
| Câu hỏi | Trả lời | Dùng cái gì |
|---|---|---|
| Bạn cần Claude access data ở external system? | YES | MCP server |
| Bạn cần dạy Claude quy trình theo style của team? | YES | Skill |
| Cả 2 | YES | Skill + MCP cùng lúc |
Decision Tree — Chọn cơ chế nào?
Flowchart dạng checklist
- Cần fetch data từ GitHub/Slack/DB/API? → MCP server
- Cần side-effect tự động khi save/call tool? → Hook
- Instruction luôn luôn áp dụng trong mọi conversation của project? →
CLAUDE.md - Muốn task chạy isolated, không pollute main context? → Subagent
- Instruction chỉ áp dụng khi user hỏi về task đó, Claude tự nhận? → Skill
Setup hoàn chỉnh: Case study team engineering
Để thấy 5 cơ chế sống chung thế nào, hãy xem setup của 1 team engineering giả lập nhưng realistic: Team 12 người, làm SaaS trên Next.js 14 + TypeScript + Postgres. Ship code hàng tuần. Yêu cầu: code quality, security, consistency.Tầng 1: CLAUDE.md — Foundation
Tầng 2: MCP servers — Data connections
Tầng 3: Skills — Expertise
Tầng 4: Subagents — Specialized roles
Tầng 5: Hooks — Automation
Kết quả
Workflow điển hình của 1 dev:- Dev mở task “thêm API endpoint”.
CLAUDE.mdđã cho Claude biết stack + convention. - Dev gõ “tạo API route cho POST /api/users”. Skill
api-route-generatortrigger (đúng convention team). - Claude generate code qua MCP file system + pnpm tool.
- Dev edit code → Hook
prettier --writeauto format. - Dev commit. Skill
commit-formattrigger khi nói “viết commit message”. - Dev push → Hook
pnpm lint && pnpm testchạy. - Dev mở PR qua MCP GitHub. Skill
pr-reviewbảo subagentbackend-reviewerreview → subagent dùng skillspr-review,api-conventions,sql-perf-checkcho review toàn diện.
Anti-patterns — Khi dev lẫn lộn các cơ chế
❌ Anti-pattern 1: Nhồi review checklist vào CLAUDE.md
Triệu chứng:CLAUDE.md 800 dòng, nửa là review checklist không ai cần khi đang viết feature mới.
Tại sao tệ: Overhead mỗi conversation. Claude confused (quá nhiều context).
Cách đúng: Review checklist → skill pr-review. CLAUDE.md giữ foundation (stack, convention luôn áp dụng).
❌ Anti-pattern 2: Dùng skill thay cho hook
Triệu chứng: Skillauto-format-on-save description “Formats code after save. Use whenever editing.”
Tại sao tệ: Skill chỉ fire khi user nói gì đó match. Save file không phải là “user request” → skill không trigger. Format không happen.
Cách đúng: Hook PostToolUse fire on Edit tool. Skill dành cho “expertise Claude cần suy nghĩ để apply”, không phải automation mechanical.
❌ Anti-pattern 3: MCP cho mọi thứ
Triệu chứng: Build MCP server cho “team coding standards” — trả về rules. Tại sao tệ: MCP thiết kế cho data/service external. Coding standard là expertise, không phải data cần fetch. Overhead, slow, complex. Cách đúng: Coding standard → skill với instructions. Dùng MCP cho data thực sự ở external system.❌ Anti-pattern 4: Subagent thay vì skill
Triệu chứng: Tạo subagentpr-reviewer thay vì skill pr-review.
Tại sao tệ: Subagent chạy isolated context → mất context PR bạn đang xem. Phải pass lại toàn bộ context. Overhead.
Cách đúng: Skill pr-review join main context, review với full context sẵn có. Chỉ dùng subagent khi cần isolation thực sự (parallelization, different tool access, large delegated task).
Áp dụng ngay
Bài tập 1: Audit CLAUDE.md của bạn (~10 phút)
MởCLAUDE.md của project hiện tại. Đọc từng section, trả lời cho mỗi section:
| Section trong CLAUDE.md | Áp dụng LUÔN LUÔN? | Nếu không → chuyển sang… |
|---|---|---|
| Stack info | ✅ | Giữ |
| Naming convention | ✅ | Giữ |
| PR review checklist | ❌ | Skill pr-review |
| Incident runbook | ❌ | Skill incident-handler |
| Deploy procedure | ❌ | Skill deploy-checklist |
| Database no-touch rule | ✅ | Giữ |
- Section cần giữ ở
CLAUDE.md: _____ - Section cần move thành skill: _____
- Ước tính % giảm size
CLAUDE.md: _____
Bài tập 2: Thiết kế setup cho use case của bạn (~10 phút)
Pick 1 workflow bạn làm thường xuyên (ví dụ: “review PR”, “ship feature”, “on-call response”). Điền bảng:| Aspect của workflow | Dùng cơ chế nào | Giải thích |
|---|---|---|
| Luôn-luôn biết stack + convention | _____ | _____ |
| Fetch data (CRM, DB, Slack…) | _____ | _____ |
| Automation khi save / commit | _____ | _____ |
| Expertise theo task | _____ | _____ |
| Delegate task lớn isolated | _____ | _____ |
Tóm tắt bài học
🎯 5 cơ chế, 5 vai trò.CLAUDE.md = foundation. MCP = external data. Subagent = isolated roles. Skill = on-demand expertise. Hook = event automation.
🎯 Otto’s one-liner: “MCP connects to data, Skills teach Claude what to do with it.”
🎯 Decision tree quick check: Cần external data? → MCP. Event-driven? → Hook. Luôn áp dụng? → CLAUDE.md. Isolated? → Subagent. On-demand task expertise? → Skill.
🎯 Combine, không compete. Setup hoàn chỉnh dùng cả 5 cơ chế. Skill gọi MCP, subagent dùng skill, hook complement skill.
🎯 Skill là đúng khi: (1) task-specific, (2) Claude tự nhận qua semantic, (3) join current context, (4) portable qua project (personal) hoặc share team (project).
Bài tiếp theo
Bạn đã có skill cá nhân. Nhưng skill chỉ thực sự có giá trị khi share cho team/tổ chức — team standardize review, new hire onboard nhanh, compliance consistent. Bài 15.5 đi sâu 3 cách share: commit vào repo (đơn giản nhất), qua plugin marketplace (cross-org), và enterprise managed settings (deploy toàn tổ chức với priority cao nhất). Plus: gotcha lớn về subagent + skill. ➡️ Bài tiếp theo: Bài 15.5: Chia sẻ skill với team & tổ chứcTài liệu tham khảo
- Anthropic Academy — “Skills vs. other Claude Code features”
- Video — “Choosing the right feature”
- Model Context Protocol — MCP spec
- Otto, “Claude Agent Skills Explained” — quote sources