協助設計和開發 Claude Code Skills,提供 skill 設計的思考邏輯和最佳實踐
Provides design guidance and best practices for creating reusable Claude Code Skills. Use this when deciding whether to extract logic into a skill or when designing new skills to ensure they follow proper modularity and DRY principles.
/plugin marketplace add MilesChou/claude-marketplace/plugin install plugin-dev@mileschou-marketplaceThis skill inherits all available tools. When active, it can use any tool Claude has access to.
best-practices.mdexamples.mdimplementation.mdofficial-reference.md本指南遵循 Claude Code Skills 官方規範 並整合此 marketplace 專案的最佳實踐。
協助你設計和開發 Claude Code Skills,提供清晰的判斷標準、設計原則和實際案例,確保 skill 的設計符合「可重複使用的工作流程」的核心定位。
本 skill 包含以下文件:
建議閱讀順序:
Skill 是 可重複使用的工作流程,定義在 SKILL.md 檔案中,可以在多個 commands、agents 或其他 skills 中被引用和重複使用。
詳細的官方定義請參閱:official-reference.md
使用以下檢查清單來判斷:
多處重複使用
邏輯複雜度高
使用者可能單獨呼叫
需要獨立維護和版本控制
單一使用場景
邏輯簡單
與特定 command 緊密耦合
過度工程化
詳細的案例分析請參閱:examples.md
不要過度設計
❌ 錯誤思維:
「雖然現在只有一個地方用到,但未來可能會用到,所以我先獨立成 skill 好了。」
✅ 正確做法:
「目前只有一個地方使用,先保持簡單。等到第二個地方需要時,再考慮重構成 skill。」
避免重複邏輯
時機點:
一個 Skill 只做一件事
✅ 好的設計:
analyze-atomicity: 只負責分析提交的原子性generate-commit-message: 只負責產生提交訊息resolve-conflict: 只負責解決 Git 衝突❌ 不好的設計:
commit-helper: 包含原子性分析、訊息產生、推送等多個功能(職責不清晰,難以重複使用)明確的輸入和輸出
每個 skill 應該清楚定義:
## 輸入條件
- 需要哪些前置資訊?
- 依賴哪些工具或環境?
## 執行步驟
1. 步驟 1
2. 步驟 2
3. 步驟 3
## 輸出結果
- 返回什麼資訊?
- 如何被其他 commands/skills 使用?
詳細的實施指南請參閱:implementation.md
使用這個決策樹快速判斷:
flowchart TD
Start([開始]) --> Q1{是否有 2+ 個<br/>地方使用?}
Q1 -->|是| Q2{邏輯是否複雜<br/>5+ 步驟?}
Q1 -->|否| Q3{邏輯是否非常複雜<br/>10+ 步驟?}
Q2 -->|是| A1[✅ 強烈建議獨立成 Skill]
Q2 -->|否| A2[✅ 建議獨立成 Skill<br/>便於維護]
Q3 -->|是| Q4{使用者是否<br/>可能單獨呼叫?}
Q3 -->|否| A3[❌ 不需要獨立<br/>遵循 YAGNI 原則]
Q4 -->|是| A4[✅ 建議獨立<br/>便於測試和使用]
Q4 -->|否| A5[❌ 暫不獨立<br/>保留重構空間]
style A1 fill:#90EE90
style A2 fill:#90EE90
style A4 fill:#90EE90
style A3 fill:#FFB6C1
style A5 fill:#FFB6C1
style Start fill:#87CEEB
當使用者詢問「是否需要將某個功能獨立成 skill」時,按照以下步驟進行分析:
收集以下資訊(使用 AskUserQuestion 或直接分析):
目前使用情況
未來使用預期
邏輯複雜度
獨立使用價值
根據「判斷標準」章節的檢查清單進行評估:
檢查清單:
- [ ] 多處使用?
- [ ] 邏輯複雜?
- [ ] 可獨立呼叫?
- [ ] 需要獨立維護?
評分:勾選 3+ 項 → ✅ 建議獨立
勾選 1-2 項 → ❓ 視情況決定
勾選 0 項 → ❌ 不建議獨立
根據評估結果,提供清晰的建議:
✅ 建議獨立成 Skill
理由:
1. [列出符合的條件]
2. [說明獨立後的好處]
3. [未來的擴展可能性]
建議的 Skill 設計:
- 名稱:{plugin-name}:{skill-name}
- 位置:plugins/{plugin-name}/skills/{skill-name}/SKILL.md
- 核心功能:[簡述]
- 預期使用者:[列出會使用這個 skill 的 commands/agents]
❌ 目前不建議獨立成 Skill
理由:
1. [列出不符合的條件]
2. [說明保持現狀的好處]
3. [遵循的設計原則]
建議:
- 保持在 {current-location} 中
- 等到出現第二個使用場景時再考慮重構
未來觸發條件:
[列出什麼情況下應該重新評估]
如果決定要獨立成 skill,引導使用者查看詳細的實施計畫:
詳細的實施步驟請參閱:implementation.md
主要步驟:
| 問題 | 答案 | 參考文件 |
|---|---|---|
| 第一次使用這個邏輯,要獨立嗎? | ❌ 不要,遵循 YAGNI 原則 | best-practices.md |
| 第二次使用,要獨立嗎? | ✅ 強烈建議獨立 | examples.md |
| 邏輯很複雜但只用一次? | 視情況,看是否有獨立價值 | SKILL.md |
| 如何命名 skill? | 使用 kebab-case,動詞開頭 | implementation.md |
| SKILL.md 必須包含什麼? | YAML Front Matter、核心功能、執行步驟 | implementation.md |
| 可以在 skill 中引用其他 skills 嗎? | 可以,但要避免循環依賴 | best-practices.md |
創建 skill 前快速檢查:
設計 Skill 的核心原則:
記住:保持簡單永遠是最好的設計。
專案相關:
This skill should be used when the user asks to "create a slash command", "add a command", "write a custom command", "define command arguments", "use command frontmatter", "organize commands", "create command with file references", "interactive command", "use AskUserQuestion in command", or needs guidance on slash command structure, YAML frontmatter fields, dynamic arguments, bash execution in commands, user interaction patterns, or command development best practices for Claude Code.
This skill should be used when the user asks to "create an agent", "add an agent", "write a subagent", "agent frontmatter", "when to use description", "agent examples", "agent tools", "agent colors", "autonomous agent", or needs guidance on agent structure, system prompts, triggering conditions, or agent development best practices for Claude Code plugins.
This skill should be used when the user asks to "create a hook", "add a PreToolUse/PostToolUse/Stop hook", "validate tool use", "implement prompt-based hooks", "use ${CLAUDE_PLUGIN_ROOT}", "set up event-driven automation", "block dangerous commands", or mentions hook events (PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart, SessionEnd, UserPromptSubmit, PreCompact, Notification). Provides comprehensive guidance for creating and implementing Claude Code plugin hooks with focus on advanced prompt-based hooks API.