Guide for creating effective skills...
This skill provides guidance for creating effective Claude Code skills following the official documentation.
A Skill is a markdown file that teaches Claude how to do something specific. Skills transform Claude from a general-purpose agent into a specialized agent with procedural knowledge, domain expertise, and bundled resources.
skill-name/
├── SKILL.md # Required: frontmatter + instructions
├── reference.md # Optional: detailed documentation
├── examples.md # Optional: usage examples
├── templates/ # Optional: template files
└── scripts/ # Optional: utility scripts
├── helper.py
└── validate.sh
| Location | Path | Scope | Priority |
|---|---|---|---|
| Managed | See admin settings | All org users | 1 (highest) |
| Personal | ~/.claude/skills/ |
You, all projects | 2 |
| Project | .claude/skills/ |
Team in repo | 3 |
| Plugin | skills/ in plugin dir |
Plugin users | 4 (lowest) |
Higher priority locations override lower ones when names conflict.
---
name: skill-name
description: What this skill does and when to use it
allowed-tools:
- Read
- Grep
- Glob
model: claude-sonnet-4-20250514
context: fork
agent: Plan
hooks:
PreToolUse:
- matcher: "Bash"
hooks:
- type: command
command: "./scripts/validate.sh"
once: true
user-invocable: true
disable-model-invocation: false
---
| Field | Required | Description |
|---|---|---|
name |
Yes | Lowercase, numbers, hyphens. Must match directory name. Max 64 chars |
description |
Yes | What skill does + when to use. Include trigger keywords. Max 1024 chars |
allowed-tools |
No | Tools Claude can use without permission when skill is active |
model |
No | Specific model to use (e.g., claude-sonnet-4-20250514) |
context |
No | Set to fork to run in isolated sub-agent context |
agent |
No | Agent type when context: fork: Explore, Plan, general-purpose, or custom |
hooks |
No | Lifecycle hooks: PreToolUse, PostToolUse, Stop |
user-invocable |
No | Show in slash menu (default: true) |
disable-model-invocation |
No | Block programmatic invocation via Skill tool |
skills |
No | (Subagents only) Skills to inject into subagent context |
Comma-separated:
allowed-tools: Read, Grep, Glob
YAML array:
allowed-tools:
- Read
- Grep
- Glob
With command filtering:
allowed-tools: Bash(git add:*), Bash(git status:*), Bash(git commit:*)
Read, Write, Edit, Bash, Glob, Grep, WebFetch, WebSearch, Skill, Task
Run skills in separate sub-agent context with own conversation history:
---
name: data-analysis
description: Analyze data and generate reports
context: fork
agent: Plan
---
| Aspect | Normal Skill | Forked Skill |
|---|---|---|
| Context | Shares conversation | Isolated history |
| Visibility | In main conversation | Runs in background |
| When to use | Simple guidance | Complex multi-step workflows |
Only PreToolUse, PostToolUse, and Stop are supported in skill frontmatter.
hooks:
PreToolUse:
- matcher: "Bash"
hooks:
- type: command
command: "./scripts/security-check.sh"
once: true
PostToolUse:
- matcher: "Edit|Write"
hooks:
- type: command
command: "./scripts/run-linter.sh"
Stop:
- hooks:
- type: command
command: "./scripts/cleanup.sh"
| Option | Type | Description |
|---|---|---|
type |
string | command for bash or prompt for LLM evaluation |
command |
string | Bash command to execute |
prompt |
string | LLM prompt for evaluation |
matcher |
string | Tool pattern to match (regex) |
timeout |
number | Timeout in seconds (default: 60) |
once |
boolean | Run only once per session |
| Setting | Slash Menu | Skill Tool | Auto-Discovery |
|---|---|---|---|
| Default | Visible | Allowed | Yes |
user-invocable: false |
Hidden | Allowed | Yes |
disable-model-invocation: true |
Visible | Blocked | Yes |
Use user-invocable: false for skills Claude should use but users shouldn't invoke manually.
Use disable-model-invocation: true for skills users invoke manually but Claude shouldn't.
Subagents don't automatically inherit skills. To give a custom subagent access:
File: .claude/agents/code-reviewer.md
---
name: code-reviewer
description: Review code for quality
skills: pr-review, security-check, style-guide
---
Review this code thoroughly...
The context window is a public good. Skills share it with system prompt, conversation history, other skills' metadata, and user requests.
Default assumption: Claude is already smart. Only add context Claude doesn't have.
| Freedom Level | When to Use | Example |
|---|---|---|
| High (text instructions) | Multiple valid approaches | General guidelines |
| Medium (pseudocode) | Preferred pattern exists | Configurable workflows |
| Low (specific scripts) | Operations are fragile | Critical sequences |
Skills use three-level loading:
Keep SKILL.md under 500 lines. Split content when approaching this limit.
A good description answers:
Poor:
description: Helps with documents
Good:
description: Extracts text and tables from PDF files, fills forms, merges documents. Use when working with PDF files or when user mentions PDFs, forms, or document extraction.
# PDF Processing
## Quick start
[code example]
## Advanced features
- **Form filling**: See [FORMS.md](FORMS.md)
- **API reference**: See [REFERENCE.md](REFERENCE.md)
bigquery-skill/
├── SKILL.md
└── reference/
├── finance.md
├── sales.md
└── product.md
cloud-deploy/
├── SKILL.md
└── references/
├── aws.md
├── gcp.md
└── azure.md
Important: Keep references one level deep. Avoid chains (A -> B -> C).
The skill should only contain information needed for Claude to do the job.
mkdir -p .claude/skills/skill-name---
name: commit-helper
description: Generate clear commit messages from git diffs. Use when writing commit messages or reviewing staged changes.
allowed-tools: Bash(git diff:*), Bash(git status:*)
---
# Commit Message Generator
## Instructions
1. Run `git diff --staged` to see changes
2. Suggest commit message with:
- Summary under 50 characters
- Detailed description
- Affected components
## Best Practices
- Use present tense imperative
- Explain what and why, not how
---
name: pdf-processor
description: Extract text, fill forms, merge PDFs. Use when working with PDF files.
allowed-tools: Read, Bash(python:*)
---
# PDF Processing
## Quick Start
```python
import pdfplumber
with pdfplumber.open("doc.pdf") as pdf:
text = pdf.pages[0].extract_text()
python scripts/validate.py input.pdf
### Example 3: Security-Focused with Hooks
```yaml
---
name: secure-db-ops
description: Execute database queries with validation and audit logging.
allowed-tools: Bash(psql:*), Bash(mysql:*)
hooks:
PreToolUse:
- matcher: "Bash"
hooks:
- type: command
command: "./scripts/validate-query.sh"
PostToolUse:
- matcher: "Bash"
hooks:
- type: command
command: "./scripts/audit-log.sh"
---
# Secure Database Operations
All queries are validated before execution and logged for audit.
---
name: code-analysis
description: Analyze code quality and generate detailed reports
context: fork
agent: Plan
---
# Code Analysis
Run comprehensive analysis in isolated context...
Make description more specific with trigger keywords.
SKILL.md (case-sensitive)--- on line 1 (no blank lines)claude --debug to see errorschmod +x scripts/*.py scripts/*.sh
Make descriptions distinct with specific trigger terms.
| Variable | Description |
|---|---|
CLAUDE_PROJECT_DIR |
Absolute path to project root |
CLAUDE_PLUGIN_ROOT |
Absolute path to plugin directory |
CLAUDE_CODE_REMOTE |
"true" if remote environment |