TL;DR

Claude Code có hơn 60 slash command tích hợp sẵn. Phần lớn dev chỉ biết 5-6 cái. Điều ít người biết hơn: bạn có thể tự tạo lệnh riêng. Một file markdown trong .claude/skills/ là một slash command bạn gọi bằng /tên-file. Viết prompt một lần, dùng mãi mãi. Bài này gồm 10 skills copy-paste sẵn, bao phủ toàn bộ vòng lặp phát triển từ debug cho tới deploy.

Vấn đề bạn đang bỏ qua

Mỗi ngày, bao nhiêu lần bạn gõ đại loại: "Review code này cho tôi, kiểm tra bug, security issue và style"? Hay "Viết commit message theo conventional commits từ diff này"?

Mỗi lần đó là bạn đang viết lại cùng một prompt, chấp nhận output không nhất quán. Khi một đoạn instruction lặp đi lặp lại trong chat - đó là dấu hiệu để biến nó thành một skill.

Anatomy của một skill

Tạo một thư mục trong .claude/skills/ hoặc ~/.claude/skills/. Bên trong đặt file SKILL.md. Tên thư mục trở thành slash command:

.claude/skills/review/SKILL.md   →   /review
~/.claude/skills/commit/SKILL.md  →  /commit

File gồm hai phần: YAML frontmatter kiểm soát hành vi và markdown content là prompt Claude thực thi:

---
name: review
description: Review current diff for bugs, security, and style
allowed-tools: Read, Grep, Glob, Bash(git diff *)
---

Review the diff for:
1. Bugs: logic errors, null handling, race conditions
2. Security: OWASP Top 10, hardcoded secrets, XSS
3. Performance: N+1 queries, blocking calls
Group by severity: CRITICAL / WARNING / INFO

Các frontmatter field quan trọng:

  • allowed-tools - giới hạn tool skill được dùng
  • disable-model-invocation: true - chỉ bạn trigger được, Claude không tự chạy (dùng cho /deploy, /commit)
  • user-invocable: false - chỉ Claude tự invoke, dùng cho background knowledge skill
  • context: fork - chạy trong isolated subagent, không làm ô nhiễm context chính

Skills còn hỗ trợ argument passing ($ARGUMENTS, $1, $2) và dynamic context injection qua cú pháp ! - chạy shell command trước khi Claude đọc skill, inject output thực vào prompt:

! git diff HEAD   →  replaced by actual diff output

10 skills cho toàn bộ vòng lặp

Dưới đây là cấu trúc folder cần tạo:

.claude/skills/
- review/SKILL.md
- test/SKILL.md
- commit/SKILL.md
- pr/SKILL.md
- debug/SKILL.md
- refactor/SKILL.md
- docs/SKILL.md
- migrate/SKILL.md
- deploy-check/SKILL.md
- security/SKILL.md

Ba skills thường dùng nhất - đây là template đầy đủ:

/debug - điều tra lỗi:

---
name: debug
description: Debug an error. Use when user mentions "bug", "error",
  "broken", or pastes an error message.
allowed-tools: Read, Grep, Glob, Bash(npm test *)
---
1. Identify error from message, stack trace, or description
2. Find source: search codebase with grep/glob
3. Form a hypothesis for root cause
4. Verify by reading related code and recent git log
5. Propose fix with explanation

Output: Root cause / Location [file:line] / Fix / Prevention
Do NOT make changes unless explicitly asked.

/commit - structured commits:

---
name: commit
description: Create structured git commits. Use when user says "commit".
allowed-tools: Read, Bash(git *)
---
1. Run git status and git diff
2. Group related changes into logical units
3. Format: type(scope): description under 50 chars
   Types: feat, fix, refactor, docs, test, chore
4. Stage and commit each unit separately
Rules: lowercase, present tense, no period at end.

/deploy-check - chặn bug trước khi ship:

---
name: deploy-check
description: Pre-deployment verification.
disable-model-invocation: true
allowed-tools: Read, Bash(npm *), Bash(npx tsc *), Bash(git *), Grep
---
Run in order, stop at first failure:
1. npx tsc --noEmit
2. npm test
3. npm run lint
4. npm run build
5. grep -r "console.log" src/
6. git status - no uncommitted changes
Output checkmark or X. Summary: "Ready" or "N issues".

7 skills còn lại - cùng cấu trúc, khác instruction body:

SkillDùng khiOutput
/reviewTrước khi mở PRFindings grouped by severity
/testSau khi viết featureTests khớp framework hiện tại
/prSau khi commit xongPR description What/Why/Changes/Testing
/refactorClean up sau implementationIncremental changes, tests pass sau mỗi step
/docsJSDoc, README, inline commentsMatch project style
/migrateSchema change mớiUP + DOWN migration theo ORM project
/securityTrước khi deploy productionCRITICAL/HIGH/MEDIUM/LOW + OWASP ref

Skills vs commands cu vs CLAUDE.md

Từ tháng 4/2026, Anthropic merge .claude/commands/ vào .claude/skills/. File commands cũ vẫn chạy được, nhưng skills mới bổ sung: auto-invoke theo description, dynamic context injection, allowed-tools, subagent execution.

So với CLAUDE.md: CLAUDE.md load mọi lúc, tốn token mỗi session, dễ bị context drift khi conversation dài. Skills thì full body chỉ load khi invoke - reference material dài bao nhiêu cũng không tốn gì cho đến khi bạn thực sự dùng.

Lưu ý kỹ thuật: sau auto-compaction, Claude Code giữ lại tối đa 5.000 token đầu của mỗi skill, với tổng budget 25.000 token cho tất cả re-attached skills. Nếu skill ngừng ảnh hưởng sau lần đầu, invoke lại sau khi compaction.

Bắt đầu ngay hôm nay

Commit folder .claude/skills/ lên git. Cả team nhận được ngay, không cần setup thêm gì. Đó là điểm mạnh thực sự của project-level skills.

Vòng lặp feature điển hình sau khi có đủ skills:

  1. /debug - điều tra issue
  2. Viết code
  3. /test - generate tests
  4. /refactor - clean up
  5. /review - self-review trước PR
  6. /security - quick scan
  7. /commit - structured commits
  8. /pr - generate PR description
  9. /deploy-check - verify trước khi ship

Mỗi step từng là 50 từ phải gõ lại. Giờ còn 7-15 ký tự. Sau một tháng, con số đó cộng dồn thành hàng giờ tiết kiệm.

Nguon: Claude Code Skills Docs, Essential Claude Code Skills, The Prompt Shelf.