Cơ chế Skill — 4 Lớp cấu trúc
ClaudeKit được xây dựng từ 4 lớp (layers), mỗi lớp có vai trò riêng. Hiểu cơ chế này giúp bạn tùy chỉnh và mở rộng skills theo nhu cầu.Tổng quan 4 Lớp
Luồng hoạt động: Người dùng gõ command (Layer 2) → command gọi skill (Layer 1) → skill có thể delegate cho agent (Layer 3) → hooks (Layer 4) tự động chạy trước/sau events.
Luồng hoạt động chi tiết
Khi bạn gõ/cook "add auth", đây là những gì diễn ra qua 4 layers:
1
Layer 2 — Command nhận input
File
.claude/commands/cook.md nhận $ARGUMENTS = “add auth”.
Command chứa instructions gọi skill + workflow logic.2
Layer 1 — Skill xử lý logic chính
File
.claude/skills/cook/SKILL.md được kích hoạt.
Skill đọc instructions, detect mode, bắt đầu workflow 7 bước.
Skill có thể đọc thêm references/*.md (lazy-load khi cần).3
Layer 3 — Agents được delegate tasks
Skill spawn agents qua Task tool:
researcher→ tìm hiểu codebase (chạy song song)planner→ tạo plancoder→ viết codetester→ viết + chạy testscode-reviewer→ review code Mỗi agent có.claude/agents/ten-agent.mdđịnh nghĩa role + tools.
4
Layer 4 — Hooks chạy tự động
Trước khi Write file →
PreToolUse hook chạy (check rules).
Sau khi Bash → PostToolUse hook chạy (log, format).
Config trong .claude/settings.json.Layer 1: SKILL.md — Bộ não của skill
File chính định nghĩa logic của skill. Đường dẫn thực tế:Cấu trúc file SKILL.md
Đặc điểm quan trọng
Ví dụ cấu trúc thư mục skill
Layer 2: Commands — Giao diện người dùng
Định nghĩa slash commands mà người dùng gõ trực tiếp. Đường dẫn thực tế:Cập nhật bộ mới: Các subcommand
/fix:fast|:hard|:test|:ci|:types|:ui đã bỏ. Skill /fix (SKILL.md) tự route theo evidence trong description. Tương tự /plan:fast|:hard|:two, /cook:auto:*, /design:* cũng bỏ — dùng skill root thay vì subcommand. Xem dev/overview mapping đầy đủ.Quy tắc đặt tên — rất quan trọng
- Thư mục = nhóm lệnh (ví dụ:
qa-full/,fix/) - File = tên lệnh (ví dụ:
verify-issue.md,fast.md) - Slash command =
/{thư-mục}:{file}(ví dụ:/qa-full:verify-issue) - Thư mục lồng = sub-group (ví dụ:
ckm/seo/→/ckm:seo:*)
Layer 3: Agents — AI Workers chuyên biệt
Định nghĩa agents chuyên biệt. Đường dẫn thực tế:Cách agents phối hợp
Đặc điểm:- Agents có thể chạy song song (researchers) hoặc tuần tự (coder → tester)
- Mỗi agent có tool access riêng (coder có write, tester có bash)
- Agent có thể delegate cho agent khác (nesting)
- project-manager tổng hợp kết quả cuối cùng
Agents trong ClaudeKit Engineer
Layer 4: Hooks — Tự động hóa
Tự động chạy trước/sau các events. Đường dẫn thực tế:Cấu hình trong settings.json
Sơ đồ thời điểm Hook chạy
Các event phổ biến
Cách skill gọi skill (Skill Chaining)
Skill có thể gọi skills khác để tạo workflow phức tạp:Khi instruction nói “Invoke Skill” → PHẢI gọi skill bằng Skill tool. KHÔNG tự làm thay. Đây là quy tắc nghiêm ngặt.
Ví dụ skill chaining phức tạp
Ví dụ skill chaining trong QA
Tùy chỉnh & mở rộng
Thêm skill mới
Cập nhật skill hiện có
Tối ưu skill
Thêm reference files cho skill
Best practices khi tạo skill:
- Mỗi skill làm 1 việc rõ ràng (Single Responsibility)
- Viết instructions cụ thể, không mơ hồ
- Thêm ví dụ input/output trong SKILL.md
- Dùng skill chaining thay vì tạo skill quá lớn
- Luôn test skill trước khi share cho team
- Dùng
references/folder cho lazy-load content