spacehub

surshar / claude-code

Claude Code is an agentic coding tool that lives in your terminal, understands your codebase, and helps you code faster by executing routine tasks, explaining complex code, and handling git workflows - all through natural language commands.

Built by Anthropic · github.com/anthropics

claude-code / plugins / plugin-dev / skills / skill-development / SKILL.md
637 lines · 22.3 KBPreviewCodeRaw
1---
2name: Skill Development
3description: This skill should be used when the user wants to "create a skill", "add a skill to plugin", "write a new skill", "improve skill description", "organize skill content", or needs guidance on skill structure, progressive disclosure, or skill development best practices for Claude Code plugins.
4version: 0.1.0
5---
6
7# Skill Development for Claude Code Plugins
8
9This skill provides guidance for creating effective skills for Claude Code plugins.
10
11## About Skills
12
13Skills are modular, self-contained packages that extend Claude's capabilities by providing
14specialized knowledge, workflows, and tools. Think of them as "onboarding guides" for specific
15domains or tasks—they transform Claude from a general-purpose agent into a specialized agent
16equipped with procedural knowledge that no model can fully possess.
17
18### What Skills Provide
19
201. Specialized workflows - Multi-step procedures for specific domains
212. Tool integrations - Instructions for working with specific file formats or APIs
223. Domain expertise - Company-specific knowledge, schemas, business logic
234. Bundled resources - Scripts, references, and assets for complex and repetitive tasks
24
25### Anatomy of a Skill
26
27Every skill consists of a required SKILL.md file and optional bundled resources:
28
29```
30skill-name/
31├── SKILL.md (required)
32│ ├── YAML frontmatter metadata (required)
33│ │ ├── name: (required)
34│ │ └── description: (required)
35│ └── Markdown instructions (required)
36└── Bundled Resources (optional)
37 ├── scripts/ - Executable code (Python/Bash/etc.)
38 ├── references/ - Documentation intended to be loaded into context as needed
39 └── assets/ - Files used in output (templates, icons, fonts, etc.)
40```
41
42#### SKILL.md (required)
43
44**Metadata Quality:** The `name` and `description` in YAML frontmatter determine when Claude will use the skill. Be specific about what the skill does and when to use it. Use the third-person (e.g. "This skill should be used when..." instead of "Use this skill when...").
45
46#### Bundled Resources (optional)
47
48##### Scripts (`scripts/`)
49
50Executable code (Python/Bash/etc.) for tasks that require deterministic reliability or are repeatedly rewritten.
51
52- **When to include**: When the same code is being rewritten repeatedly or deterministic reliability is needed
53- **Example**: `scripts/rotate_pdf.py` for PDF rotation tasks
54- **Benefits**: Token efficient, deterministic, may be executed without loading into context
55- **Note**: Scripts may still need to be read by Claude for patching or environment-specific adjustments
56
57##### References (`references/`)
58
59Documentation and reference material intended to be loaded as needed into context to inform Claude's process and thinking.
60
61- **When to include**: For documentation that Claude should reference while working
62- **Examples**: `references/finance.md` for financial schemas, `references/mnda.md` for company NDA template, `references/policies.md` for company policies, `references/api_docs.md` for API specifications
63- **Use cases**: Database schemas, API documentation, domain knowledge, company policies, detailed workflow guides
64- **Benefits**: Keeps SKILL.md lean, loaded only when Claude determines it's needed
65- **Best practice**: If files are large (>10k words), include grep search patterns in SKILL.md
66- **Avoid duplication**: Information should live in either SKILL.md or references files, not both. Prefer references files for detailed information unless it's truly core to the skill—this keeps SKILL.md lean while making information discoverable without hogging the context window. Keep only essential procedural instructions and workflow guidance in SKILL.md; move detailed reference material, schemas, and examples to references files.
67
68##### Assets (`assets/`)
69
70Files not intended to be loaded into context, but rather used within the output Claude produces.
71
72- **When to include**: When the skill needs files that will be used in the final output
73- **Examples**: `assets/logo.png` for brand assets, `assets/slides.pptx` for PowerPoint templates, `assets/frontend-template/` for HTML/React boilerplate, `assets/font.ttf` for typography
74- **Use cases**: Templates, images, icons, boilerplate code, fonts, sample documents that get copied or modified
75- **Benefits**: Separates output resources from documentation, enables Claude to use files without loading them into context
76
77### Progressive Disclosure Design Principle
78
79Skills use a three-level loading system to manage context efficiently:
80
811. **Metadata (name + description)** - Always in context (~100 words)
822. **SKILL.md body** - When skill triggers (<5k words)
833. **Bundled resources** - As needed by Claude (Unlimited*)
84
85*Unlimited because scripts can be executed without reading into context window.
86
87## Skill Creation Process
88
89To create a skill, follow the "Skill Creation Process" in order, skipping steps only if there is a clear reason why they are not applicable.
90
91### Step 1: Understanding the Skill with Concrete Examples
92
93Skip this step only when the skill's usage patterns are already clearly understood. It remains valuable even when working with an existing skill.
94
95To create an effective skill, clearly understand concrete examples of how the skill will be used. This understanding can come from either direct user examples or generated examples that are validated with user feedback.
96
97For example, when building an image-editor skill, relevant questions include:
98
99- "What functionality should the image-editor skill support? Editing, rotating, anything else?"
100- "Can you give some examples of how this skill would be used?"
101- "I can imagine users asking for things like 'Remove the red-eye from this image' or 'Rotate this image'. Are there other ways you imagine this skill being used?"
102- "What would a user say that should trigger this skill?"
103
104To avoid overwhelming users, avoid asking too many questions in a single message. Start with the most important questions and follow up as needed for better effectiveness.
105
106Conclude this step when there is a clear sense of the functionality the skill should support.
107
108### Step 2: Planning the Reusable Skill Contents
109
110To turn concrete examples into an effective skill, analyze each example by:
111
1121. Considering how to execute on the example from scratch
1132. Identifying what scripts, references, and assets would be helpful when executing these workflows repeatedly
114
115Example: When building a `pdf-editor` skill to handle queries like "Help me rotate this PDF," the analysis shows:
116
1171. Rotating a PDF requires re-writing the same code each time
1182. A `scripts/rotate_pdf.py` script would be helpful to store in the skill
119
120Example: When designing a `frontend-webapp-builder` skill for queries like "Build me a todo app" or "Build me a dashboard to track my steps," the analysis shows:
121
1221. Writing a frontend webapp requires the same boilerplate HTML/React each time
1232. An `assets/hello-world/` template containing the boilerplate HTML/React project files would be helpful to store in the skill
124
125Example: When building a `big-query` skill to handle queries like "How many users have logged in today?" the analysis shows:
126
1271. Querying BigQuery requires re-discovering the table schemas and relationships each time
1282. A `references/schema.md` file documenting the table schemas would be helpful to store in the skill
129
130**For Claude Code plugins:** When building a hooks skill, the analysis shows:
1311. Developers repeatedly need to validate hooks.json and test hook scripts
1322. `scripts/validate-hook-schema.sh` and `scripts/test-hook.sh` utilities would be helpful
1333. `references/patterns.md` for detailed hook patterns to avoid bloating SKILL.md
134
135To establish the skill's contents, analyze each concrete example to create a list of the reusable resources to include: scripts, references, and assets.
136
137### Step 3: Create Skill Structure
138
139For Claude Code plugins, create the skill directory structure:
140
141```bash
142mkdir -p plugin-name/skills/skill-name/{references,examples,scripts}
143touch plugin-name/skills/skill-name/SKILL.md
144```
145
146**Note:** Unlike the generic skill-creator which uses `init_skill.py`, plugin skills are created directly in the plugin's `skills/` directory with a simpler manual structure.
147
148### Step 4: Edit the Skill
149
150When editing the (newly-created or existing) skill, remember that the skill is being created for another instance of Claude to use. Focus on including information that would be beneficial and non-obvious to Claude. Consider what procedural knowledge, domain-specific details, or reusable assets would help another Claude instance execute these tasks more effectively.
151
152#### Start with Reusable Skill Contents
153
154To begin implementation, start with the reusable resources identified above: `scripts/`, `references/`, and `assets/` files. Note that this step may require user input. For example, when implementing a `brand-guidelines` skill, the user may need to provide brand assets or templates to store in `assets/`, or documentation to store in `references/`.
155
156Also, delete any example files and directories not needed for the skill. Create only the directories you actually need (references/, examples/, scripts/).
157
158#### Update SKILL.md
159
160**Writing Style:** Write the entire skill using **imperative/infinitive form** (verb-first instructions), not second person. Use objective, instructional language (e.g., "To accomplish X, do Y" rather than "You should do X" or "If you need to do X"). This maintains consistency and clarity for AI consumption.
161
162**Description (Frontmatter):** Use third-person format with specific trigger phrases:
163
164```yaml
165---
166name: Skill Name
167description: This skill should be used when the user asks to "specific phrase 1", "specific phrase 2", "specific phrase 3". Include exact phrases users would say that should trigger this skill. Be concrete and specific.
168version: 0.1.0
169---
170```
171
172**Good description examples:**
173```yaml
174description: This skill should be used when the user asks to "create a hook", "add a PreToolUse hook", "validate tool use", "implement prompt-based hooks", or mentions hook events (PreToolUse, PostToolUse, Stop).
175```
176
177**Bad description examples:**
178```yaml
179description: Use this skill when working with hooks. # Wrong person, vague
180description: Load when user needs hook help. # Not third person
181description: Provides hook guidance. # No trigger phrases
182```
183
184To complete SKILL.md body, answer the following questions:
185
1861. What is the purpose of the skill, in a few sentences?
1872. When should the skill be used? (Include this in frontmatter description with specific triggers)
1883. In practice, how should Claude use the skill? All reusable skill contents developed above should be referenced so that Claude knows how to use them.
189
190**Keep SKILL.md lean:** Target 1,500-2,000 words for the body. Move detailed content to references/:
191- Detailed patterns → `references/patterns.md`
192- Advanced techniques → `references/advanced.md`
193- Migration guides → `references/migration.md`
194- API references → `references/api-reference.md`
195
196**Reference resources in SKILL.md:**
197```markdown
198## Additional Resources
199
200### Reference Files
201
202For detailed patterns and techniques, consult:
203- **`references/patterns.md`** - Common patterns
204- **`references/advanced.md`** - Advanced use cases
205
206### Example Files
207
208Working examples in `examples/`:
209- **`example-script.sh`** - Working example
210```
211
212### Step 5: Validate and Test
213
214**For plugin skills, validation is different from generic skills:**
215
2161. **Check structure**: Skill directory in `plugin-name/skills/skill-name/`
2172. **Validate SKILL.md**: Has frontmatter with name and description
2183. **Check trigger phrases**: Description includes specific user queries
2194. **Verify writing style**: Body uses imperative/infinitive form, not second person
2205. **Test progressive disclosure**: SKILL.md is lean (~1,500-2,000 words), detailed content in references/
2216. **Check references**: All referenced files exist
2227. **Validate examples**: Examples are complete and correct
2238. **Test scripts**: Scripts are executable and work correctly
224
225**Use the skill-reviewer agent:**
226```
227Ask: "Review my skill and check if it follows best practices"
228```
229
230The skill-reviewer agent will check description quality, content organization, and progressive disclosure.
231
232### Step 6: Iterate
233
234After testing the skill, users may request improvements. Often this happens right after using the skill, with fresh context of how the skill performed.
235
236**Iteration workflow:**
2371. Use the skill on real tasks
2382. Notice struggles or inefficiencies
2393. Identify how SKILL.md or bundled resources should be updated
2404. Implement changes and test again
241
242**Common improvements:**
243- Strengthen trigger phrases in description
244- Move long sections from SKILL.md to references/
245- Add missing examples or scripts
246- Clarify ambiguous instructions
247- Add edge case handling
248
249## Plugin-Specific Considerations
250
251### Skill Location in Plugins
252
253Plugin skills live in the plugin's `skills/` directory:
254
255```
256my-plugin/
257├── .claude-plugin/
258│ └── plugin.json
259├── commands/
260├── agents/
261└── skills/
262 └── my-skill/
263 ├── SKILL.md
264 ├── references/
265 ├── examples/
266 └── scripts/
267```
268
269### Auto-Discovery
270
271Claude Code automatically discovers skills:
272- Scans `skills/` directory
273- Finds subdirectories containing `SKILL.md`
274- Loads skill metadata (name + description) always
275- Loads SKILL.md body when skill triggers
276- Loads references/examples when needed
277
278### No Packaging Needed
279
280Plugin skills are distributed as part of the plugin, not as separate ZIP files. Users get skills when they install the plugin.
281
282### Testing in Plugins
283
284Test skills by installing plugin locally:
285
286```bash
287# Test with --plugin-dir
288cc --plugin-dir /path/to/plugin
289
290# Ask questions that should trigger the skill
291# Verify skill loads correctly
292```
293
294## Examples from Plugin-Dev
295
296Study the skills in this plugin as examples of best practices:
297
298**hook-development skill:**
299- Excellent trigger phrases: "create a hook", "add a PreToolUse hook", etc.
300- Lean SKILL.md (1,651 words)
301- 3 references/ files for detailed content
302- 3 examples/ of working hooks
303- 3 scripts/ utilities
304
305**agent-development skill:**
306- Strong triggers: "create an agent", "agent frontmatter", etc.
307- Focused SKILL.md (1,438 words)
308- References include the AI generation prompt from Claude Code
309- Complete agent examples
310
311**plugin-settings skill:**
312- Specific triggers: "plugin settings", ".local.md files", "YAML frontmatter"
313- References show real implementations (multi-agent-swarm, ralph-wiggum)
314- Working parsing scripts
315
316Each demonstrates progressive disclosure and strong triggering.
317
318## Progressive Disclosure in Practice
319
320### What Goes in SKILL.md
321
322**Include (always loaded when skill triggers):**
323- Core concepts and overview
324- Essential procedures and workflows
325- Quick reference tables
326- Pointers to references/examples/scripts
327- Most common use cases
328
329**Keep under 3,000 words, ideally 1,500-2,000 words**
330
331### What Goes in references/
332
333**Move to references/ (loaded as needed):**
334- Detailed patterns and advanced techniques
335- Comprehensive API documentation
336- Migration guides
337- Edge cases and troubleshooting
338- Extensive examples and walkthroughs
339
340**Each reference file can be large (2,000-5,000+ words)**
341
342### What Goes in examples/
343
344**Working code examples:**
345- Complete, runnable scripts
346- Configuration files
347- Template files
348- Real-world usage examples
349
350**Users can copy and adapt these directly**
351
352### What Goes in scripts/
353
354**Utility scripts:**
355- Validation tools
356- Testing helpers
357- Parsing utilities
358- Automation scripts
359
360**Should be executable and documented**
361
362## Writing Style Requirements
363
364### Imperative/Infinitive Form
365
366Write using verb-first instructions, not second person:
367
368**Correct (imperative):**
369```
370To create a hook, define the event type.
371Configure the MCP server with authentication.
372Validate settings before use.
373```
374
375**Incorrect (second person):**
376```
377You should create a hook by defining the event type.
378You need to configure the MCP server.
379You must validate settings before use.
380```
381
382### Third-Person in Description
383
384The frontmatter description must use third person:
385
386**Correct:**
387```yaml
388description: This skill should be used when the user asks to "create X", "configure Y"...
389```
390
391**Incorrect:**
392```yaml
393description: Use this skill when you want to create X...
394description: Load this skill when user asks...
395```
396
397### Objective, Instructional Language
398
399Focus on what to do, not who should do it:
400
401**Correct:**
402```
403Parse the frontmatter using sed.
404Extract fields with grep.
405Validate values before use.
406```
407
408**Incorrect:**
409```
410You can parse the frontmatter...
411Claude should extract fields...
412The user might validate values...
413```
414
415## Validation Checklist
416
417Before finalizing a skill:
418
419**Structure:**
420- [ ] SKILL.md file exists with valid YAML frontmatter
421- [ ] Frontmatter has `name` and `description` fields
422- [ ] Markdown body is present and substantial
423- [ ] Referenced files actually exist
424
425**Description Quality:**
426- [ ] Uses third person ("This skill should be used when...")
427- [ ] Includes specific trigger phrases users would say
428- [ ] Lists concrete scenarios ("create X", "configure Y")
429- [ ] Not vague or generic
430
431**Content Quality:**
432- [ ] SKILL.md body uses imperative/infinitive form
433- [ ] Body is focused and lean (1,500-2,000 words ideal, <5k max)
434- [ ] Detailed content moved to references/
435- [ ] Examples are complete and working
436- [ ] Scripts are executable and documented
437
438**Progressive Disclosure:**
439- [ ] Core concepts in SKILL.md
440- [ ] Detailed docs in references/
441- [ ] Working code in examples/
442- [ ] Utilities in scripts/
443- [ ] SKILL.md references these resources
444
445**Testing:**
446- [ ] Skill triggers on expected user queries
447- [ ] Content is helpful for intended tasks
448- [ ] No duplicated information across files
449- [ ] References load when needed
450
451## Common Mistakes to Avoid
452
453### Mistake 1: Weak Trigger Description
454
455❌ **Bad:**
456```yaml
457description: Provides guidance for working with hooks.
458```
459
460**Why bad:** Vague, no specific trigger phrases, not third person
461
462✅ **Good:**
463```yaml
464description: This skill should be used when the user asks to "create a hook", "add a PreToolUse hook", "validate tool use", or mentions hook events. Provides comprehensive hooks API guidance.
465```
466
467**Why good:** Third person, specific phrases, concrete scenarios
468
469### Mistake 2: Too Much in SKILL.md
470
471❌ **Bad:**
472```
473skill-name/
474└── SKILL.md (8,000 words - everything in one file)
475```
476
477**Why bad:** Bloats context when skill loads, detailed content always loaded
478
479✅ **Good:**
480```
481skill-name/
482├── SKILL.md (1,800 words - core essentials)
483└── references/
484 ├── patterns.md (2,500 words)
485 └── advanced.md (3,700 words)
486```
487
488**Why good:** Progressive disclosure, detailed content loaded only when needed
489
490### Mistake 3: Second Person Writing
491
492❌ **Bad:**
493```markdown
494You should start by reading the configuration file.
495You need to validate the input.
496You can use the grep tool to search.
497```
498
499**Why bad:** Second person, not imperative form
500
501✅ **Good:**
502```markdown
503Start by reading the configuration file.
504Validate the input before processing.
505Use the grep tool to search for patterns.
506```
507
508**Why good:** Imperative form, direct instructions
509
510### Mistake 4: Missing Resource References
511
512❌ **Bad:**
513```markdown
514# SKILL.md
515
516[Core content]
517
518[No mention of references/ or examples/]
519```
520
521**Why bad:** Claude doesn't know references exist
522
523✅ **Good:**
524```markdown
525# SKILL.md
526
527[Core content]
528
529## Additional Resources
530
531### Reference Files
532- **`references/patterns.md`** - Detailed patterns
533- **`references/advanced.md`** - Advanced techniques
534
535### Examples
536- **`examples/script.sh`** - Working example
537```
538
539**Why good:** Claude knows where to find additional information
540
541## Quick Reference
542
543### Minimal Skill
544
545```
546skill-name/
547└── SKILL.md
548```
549
550Good for: Simple knowledge, no complex resources needed
551
552### Standard Skill (Recommended)
553
554```
555skill-name/
556├── SKILL.md
557├── references/
558│ └── detailed-guide.md
559└── examples/
560 └── working-example.sh
561```
562
563Good for: Most plugin skills with detailed documentation
564
565### Complete Skill
566
567```
568skill-name/
569├── SKILL.md
570├── references/
571│ ├── patterns.md
572│ └── advanced.md
573├── examples/
574│ ├── example1.sh
575│ └── example2.json
576└── scripts/
577 └── validate.sh
578```
579
580Good for: Complex domains with validation utilities
581
582## Best Practices Summary
583
584✅ **DO:**
585- Use third-person in description ("This skill should be used when...")
586- Include specific trigger phrases ("create X", "configure Y")
587- Keep SKILL.md lean (1,500-2,000 words)
588- Use progressive disclosure (move details to references/)
589- Write in imperative/infinitive form
590- Reference supporting files clearly
591- Provide working examples
592- Create utility scripts for common operations
593- Study plugin-dev's skills as templates
594
595❌ **DON'T:**
596- Use second person anywhere
597- Have vague trigger conditions
598- Put everything in SKILL.md (>3,000 words without references/)
599- Write in second person ("You should...")
600- Leave resources unreferenced
601- Include broken or incomplete examples
602- Skip validation
603
604## Additional Resources
605
606### Study These Skills
607
608Plugin-dev's skills demonstrate best practices:
609- `../hook-development/` - Progressive disclosure, utilities
610- `../agent-development/` - AI-assisted creation, references
611- `../mcp-integration/` - Comprehensive references
612- `../plugin-settings/` - Real-world examples
613- `../command-development/` - Clear critical concepts
614- `../plugin-structure/` - Good organization
615
616### Reference Files
617
618For complete skill-creator methodology:
619- **`references/skill-creator-original.md`** - Full original skill-creator content
620
621## Implementation Workflow
622
623To create a skill for your plugin:
624
6251. **Understand use cases**: Identify concrete examples of skill usage
6262. **Plan resources**: Determine what scripts/references/examples needed
6273. **Create structure**: `mkdir -p skills/skill-name/{references,examples,scripts}`
6284. **Write SKILL.md**:
629 - Frontmatter with third-person description and trigger phrases
630 - Lean body (1,500-2,000 words) in imperative form
631 - Reference supporting files
6325. **Add resources**: Create references/, examples/, scripts/ as needed
6336. **Validate**: Check description, writing style, organization
6347. **Test**: Verify skill loads on expected triggers
6358. **Iterate**: Improve based on usage
636
637Focus on strong trigger descriptions, progressive disclosure, and imperative writing style for effective skills that load when needed and provide targeted guidance.