|
| 1 | +--- |
| 2 | +name: create-skill |
| 3 | +description: Guide for creating new Claude Code skills. Use when you need to create a new skill to package expertise or workflow into a reusable capability that Claude can automatically invoke. |
| 4 | +--- |
| 5 | + |
| 6 | +# Create Skill |
| 7 | + |
| 8 | +Use this skill when creating new Claude Code skills that package expertise, workflows, or domain knowledge into reusable capabilities. |
| 9 | + |
| 10 | +## Overview |
| 11 | + |
| 12 | +Skills are autonomous capabilities that Claude Code can invoke automatically based on the user's request. Each skill consists of a SKILL.md file with YAML frontmatter and markdown instructions, plus optional supporting files. |
| 13 | + |
| 14 | +## Skill structure |
| 15 | + |
| 16 | +### Directory layout |
| 17 | + |
| 18 | +``` |
| 19 | +.claude/skills/ |
| 20 | +└── your-skill-name/ |
| 21 | + ├── SKILL.md # Required: Main skill definition |
| 22 | + ├── reference.md # Optional: Additional documentation |
| 23 | + ├── examples.md # Optional: Example usage |
| 24 | + ├── templates/ # Optional: Template files |
| 25 | + │ └── template.txt |
| 26 | + └── scripts/ # Optional: Helper scripts |
| 27 | + └── helper.py |
| 28 | +``` |
| 29 | + |
| 30 | +### SKILL.md format |
| 31 | + |
| 32 | +Every SKILL.md file must have: |
| 33 | + |
| 34 | +1. **YAML frontmatter** (required) |
| 35 | +2. **Markdown content** with instructions |
| 36 | + |
| 37 | +#### YAML frontmatter |
| 38 | + |
| 39 | +```yaml |
| 40 | +--- |
| 41 | +name: skill-name |
| 42 | +description: Brief description of what the skill does and when to use it (max 1024 chars) |
| 43 | +--- |
| 44 | +``` |
| 45 | + |
| 46 | +**Requirements:** |
| 47 | +- `name`: lowercase letters, numbers, and hyphens only (max 64 characters) |
| 48 | +- `description`: Clear description for Claude to understand when to invoke this skill |
| 49 | + - Should explain WHAT the skill does |
| 50 | + - Should explain WHEN to use it |
| 51 | + - The description is critical for discoverability |
| 52 | + |
| 53 | +#### Markdown content |
| 54 | + |
| 55 | +Structure your skill instructions clearly: |
| 56 | + |
| 57 | +```markdown |
| 58 | +# Skill Name |
| 59 | + |
| 60 | +Brief introduction of when to use this skill. |
| 61 | + |
| 62 | +## Overview |
| 63 | + |
| 64 | +High-level explanation of what this skill does. |
| 65 | + |
| 66 | +## Workflow |
| 67 | + |
| 68 | +### Step 1: First step |
| 69 | +- Details |
| 70 | +- Instructions |
| 71 | + |
| 72 | +### Step 2: Second step |
| 73 | +- More details |
| 74 | + |
| 75 | +## Key concepts |
| 76 | + |
| 77 | +Important concepts the user needs to understand. |
| 78 | + |
| 79 | +## Examples |
| 80 | + |
| 81 | +Concrete examples showing how to use the skill. |
| 82 | + |
| 83 | +## Checklist |
| 84 | + |
| 85 | +- [ ] Verification steps |
| 86 | +- [ ] Required actions |
| 87 | +``` |
| 88 | + |
| 89 | +## Creating a new skill |
| 90 | + |
| 91 | +### 1. Identify the need |
| 92 | + |
| 93 | +Create a skill when: |
| 94 | +- You have a repeating workflow that requires multiple steps |
| 95 | +- You want to package domain expertise (like SQL translation, code review patterns) |
| 96 | +- You need to ensure consistent processes are followed |
| 97 | +- You want to make complex tasks accessible |
| 98 | + |
| 99 | +### 2. Design the skill |
| 100 | + |
| 101 | +Plan your skill by answering: |
| 102 | +- **What**: What does this skill do? |
| 103 | +- **When**: When should Claude invoke it? |
| 104 | +- **How**: What are the step-by-step instructions? |
| 105 | +- **Why**: What expertise or knowledge does it encode? |
| 106 | + |
| 107 | +### 3. Write the SKILL.md |
| 108 | + |
| 109 | +**YAML frontmatter:** |
| 110 | +- Choose a descriptive `name` (kebab-case) |
| 111 | +- Write a clear `description` that helps Claude understand when to use it |
| 112 | +- The description should be specific enough to avoid false positives |
| 113 | + |
| 114 | +**Content structure:** |
| 115 | +- Start with a brief introduction |
| 116 | +- Break down the workflow into clear, numbered steps |
| 117 | +- Include examples from the actual codebase when relevant |
| 118 | +- Provide a checklist for verification |
| 119 | +- Keep instructions concise but complete |
| 120 | + |
| 121 | +### 4. Add supporting files (optional) |
| 122 | + |
| 123 | +If your skill needs: |
| 124 | +- **Templates**: Add to `templates/` directory |
| 125 | +- **Scripts**: Add to `scripts/` directory |
| 126 | +- **Reference docs**: Create `reference.md` |
| 127 | +- **Examples**: Create `examples.md` |
| 128 | + |
| 129 | +### 5. Test the skill |
| 130 | + |
| 131 | +Test that Claude invokes your skill by: |
| 132 | +1. Asking a question that should trigger the skill |
| 133 | +2. Verifying Claude loads and follows the skill instructions |
| 134 | +3. Checking that the workflow produces correct results |
| 135 | + |
| 136 | +Iterate on the description if Claude doesn't invoke it at the right times. |
| 137 | + |
| 138 | +## Best practices |
| 139 | + |
| 140 | +### Description writing |
| 141 | + |
| 142 | +✅ **Good descriptions:** |
| 143 | +- "Guide for adding SQL function translations to dbplyr backends. Use when implementing new database-specific R-to-SQL translations." |
| 144 | +- "Code review checklist for security vulnerabilities. Use after writing authentication, database, or API code." |
| 145 | + |
| 146 | +❌ **Bad descriptions:** |
| 147 | +- "SQL stuff" (too vague) |
| 148 | +- "Use this for everything related to databases" (too broad) |
| 149 | + |
| 150 | +### Instruction writing |
| 151 | + |
| 152 | +- **Be specific**: Provide concrete steps, not vague guidance |
| 153 | +- **Be concise**: Remove unnecessary words |
| 154 | +- **Use examples**: Show, don't just tell |
| 155 | +- **Reference real files**: Point to actual codebase examples |
| 156 | +- **Include verification**: Add checklists to ensure completeness |
| 157 | + |
| 158 | +### Naming conventions |
| 159 | + |
| 160 | +- Use kebab-case for skill names |
| 161 | +- Choose names that describe the action or domain |
| 162 | +- Examples: `sql-translation`, `create-skill`, `review-security`, `deploy-production` |
| 163 | + |
| 164 | +## Skill invocation |
| 165 | + |
| 166 | +### How skills work |
| 167 | + |
| 168 | +1. **Discovery**: Claude reads the skill's description |
| 169 | +2. **Decision**: Claude decides if the skill matches the user's request |
| 170 | +3. **Loading**: The SKILL.md file is loaded into the conversation context |
| 171 | +4. **Execution**: Claude follows the skill's instructions |
| 172 | +5. **Context**: Supporting files are available if referenced |
| 173 | + |
| 174 | +### Automatic vs manual invocation |
| 175 | + |
| 176 | +- **Automatic** (preferred): Claude invokes based on description match |
| 177 | +- **Manual**: User explicitly requests the skill (not common) |
| 178 | + |
| 179 | +Most skills should be designed for automatic invocation. |
| 180 | + |
| 181 | +## Examples |
| 182 | + |
| 183 | +### Minimal skill |
| 184 | + |
| 185 | +```yaml |
| 186 | +--- |
| 187 | +name: format-code |
| 188 | +description: Format code using air format. Use after writing or modifying R code files. |
| 189 | +--- |
| 190 | + |
| 191 | +# Format Code |
| 192 | + |
| 193 | +Run `air format .` to format all R code in the project. |
| 194 | + |
| 195 | +## Checklist |
| 196 | + |
| 197 | +- [ ] Run `air format .` |
| 198 | +- [ ] Verify no formatting errors |
| 199 | +``` |
| 200 | +
|
| 201 | +### Workflow skill |
| 202 | +
|
| 203 | +```yaml |
| 204 | +--- |
| 205 | +name: add-test |
| 206 | +description: Add tests for new R functions. Use when creating new functions in R/ directory. |
| 207 | +--- |
| 208 | + |
| 209 | +# Add Test |
| 210 | + |
| 211 | +Add tests for new R functions following dbplyr conventions. |
| 212 | + |
| 213 | +## Workflow |
| 214 | + |
| 215 | +### 1. Identify test file |
| 216 | +- Tests for `R/{name}.R` go in `tests/testthat/test-{name}.R` |
| 217 | + |
| 218 | +### 2. Write tests |
| 219 | +- Place new tests next to similar existing tests |
| 220 | +- Keep tests minimal with few comments |
| 221 | +- Use `expect_snapshot()` for SQL translation tests |
| 222 | + |
| 223 | +### 3. Run tests |
| 224 | +```bash |
| 225 | +Rscript -e "devtools::test(filter = '{name}', reporter = 'llm')" |
| 226 | +``` |
| 227 | + |
| 228 | +## Checklist |
| 229 | + |
| 230 | +- [ ] Created/updated test file |
| 231 | +- [ ] Tests are minimal and focused |
| 232 | +- [ ] All tests pass |
| 233 | + |
| 234 | +## Common patterns |
| 235 | + |
| 236 | +### Research workflows |
| 237 | + |
| 238 | +For skills that require research before implementation: |
| 239 | +1. Specify search steps with WebSearch |
| 240 | +2. Require documentation with citations |
| 241 | +3. Only implement after research is complete |
| 242 | + |
| 243 | +See `sql-translation` skill for an example. |
| 244 | + |
| 245 | +### Multi-step processes |
| 246 | + |
| 247 | +For complex workflows: |
| 248 | +1. Break into numbered steps |
| 249 | +2. Use subsections for each step |
| 250 | +3. Include verification at each stage |
| 251 | +4. Provide a final checklist |
| 252 | + |
| 253 | +### Domain expertise |
| 254 | + |
| 255 | +For packaging specialized knowledge: |
| 256 | +1. Explain key concepts upfront |
| 257 | +2. Provide reference information |
| 258 | +3. Include decision trees or flowcharts |
| 259 | +4. Link to external documentation |
| 260 | + |
| 261 | +## Troubleshooting |
| 262 | + |
| 263 | +**Skill not being invoked:** |
| 264 | +- Check description clarity |
| 265 | +- Make description more specific |
| 266 | +- Verify YAML syntax |
| 267 | + |
| 268 | +**Skill invoked at wrong times:** |
| 269 | +- Description too broad |
| 270 | +- Add specifics about when NOT to use it |
| 271 | + |
| 272 | +**Instructions unclear:** |
| 273 | +- Add more concrete examples |
| 274 | +- Break down complex steps |
| 275 | +- Reference actual files from the codebase |
| 276 | + |
| 277 | +## Checklist |
| 278 | + |
| 279 | +Before completing a new skill: |
| 280 | + |
| 281 | +- [ ] Created `.claude/skills/{skill-name}/` directory |
| 282 | +- [ ] Created `SKILL.md` with YAML frontmatter |
| 283 | +- [ ] `name` field uses kebab-case (lowercase, hyphens only) |
| 284 | +- [ ] `description` clearly explains what and when (max 1024 chars) |
| 285 | +- [ ] Content has clear structure with sections |
| 286 | +- [ ] Workflow broken into numbered steps |
| 287 | +- [ ] Examples included where helpful |
| 288 | +- [ ] Checklist provided for verification |
| 289 | +- [ ] Tested that Claude invokes the skill correctly |
| 290 | +- [ ] Supporting files added if needed |
0 commit comments