extension-authoring
Comprehensive guide for authoring Claude Code extensions including skills (SKILL.md), hooks, slash commands, and subagents. Use when: creating skills, writing hooks, making slash commands, building subagents, learning Claude Code extensions.
What this skill does
<objective>
This skill is the definitive guide for authoring Claude Code extensions. It covers four extension types:
1. **Skills** - Modular capabilities in SKILL.md files that provide domain expertise
2. **Hooks** - Event-driven automation that executes on tool use and session events
3. **Slash Commands** - Reusable prompts triggered with `/command-name` syntax
4. **Subagents** - Specialized Claude instances for delegated tasks
All four extension types share core principles: pure XML structure, YAML frontmatter, and clear success criteria. This skill teaches you to create effective extensions following best practices.
</objective>
<intake>
What would you like to create or learn about?
1. **Skill** - SKILL.md file for domain expertise
2. **Hook** - Event-driven automation (PreToolUse, PostToolUse, Stop, etc.)
3. **Slash Command** - Reusable prompt with `/command-name`
4. **Subagent** - Specialized agent for delegated tasks
5. **Guidance** - Help deciding which extension type to use
**Respond with a number or describe what you want to build.**
</intake>
<routing>
| Response | Action |
|----------|--------|
| 1, "skill", "SKILL.md" | Read [reference/skills.md](reference/skills.md) |
| 2, "hook", "hooks" | Read [reference/hooks.md](reference/hooks.md) |
| 3, "command", "slash" | Read [reference/commands.md](reference/commands.md) |
| 4, "subagent", "agent" | Read [reference/subagents.md](reference/subagents.md) |
| 5, "guidance", "help" | Use decision tree below |
**After reading the reference, follow its workflow exactly.**
</routing>
<decision_tree>
**Which extension type should I use?**
```
Is it triggered by specific Claude Code events?
(tool use, session start/end, user prompt submit)
YES --> Hook
Is it a reusable prompt the user invokes with /command-name?
YES --> Slash Command
Is it an isolated task that runs autonomously without user interaction?
YES --> Subagent
Is it domain knowledge or workflow guidance Claude loads on demand?
YES --> Skill
```
**Quick decision matrix:**
| Need | Extension Type |
|------|---------------|
| Validate commands before execution | Hook (PreToolUse) |
| Auto-format code after edits | Hook (PostToolUse) |
| Desktop notification when input needed | Hook (Notification) |
| Reusable git commit workflow | Slash Command |
| Code review checklist | Slash Command |
| Delegated research task | Subagent |
| Autonomous test writing | Subagent |
| API integration knowledge | Skill |
| Multi-step workflow guidance | Skill |
</decision_tree>
<shared_principles>
These principles apply to ALL Claude Code extension types:
<xml_structure>
**Use pure XML structure. Remove ALL markdown headings from body content.**
```xml
<objective>What it does</objective>
<workflow>How to do it</workflow>
<success_criteria>How to know it worked</success_criteria>
```
Keep markdown formatting WITHIN content (bold, lists, code blocks).
**Why XML?**
- Semantic meaning for Claude (not just visual formatting)
- Unambiguous section boundaries
- Token efficient (~15 tokens vs ~20 for markdown headings)
- Reliable parsing and progressive disclosure
</xml_structure>
<yaml_frontmatter>
All extensions require YAML frontmatter:
```yaml
---
name: extension-name # lowercase-with-hyphens
description: What it does and when to use it (third person)
---
```
**Name conventions:** `create-*`, `manage-*`, `setup-*`, `generate-*`
**Description rules:**
- Third person (never "I" or "you")
- Include WHAT it does AND WHEN to use it
- Maximum 1024 characters
</yaml_frontmatter>
<conciseness>
Context window is shared. Only add what Claude doesn't already know.
- Assume Claude is smart
- Challenge every piece of content: "Does this justify its token cost?"
- Provide default approach with escape hatch, not a list of options
- Keep main files under 500 lines, split to reference files
</conciseness>
<success_criteria>
Every extension should define clear completion criteria:
```xml
<success_criteria>
- Specific measurable outcome 1
- Specific measurable outcome 2
- How to verify it worked
</success_criteria>
```
</success_criteria>
</shared_principles>
<quick_reference>
**File locations:**
| Extension | Project Location | User Location |
|-----------|-----------------|---------------|
| Skill | `.claude/skills/` | `~/.claude/skills/` |
| Hook | `.claude/hooks.json` | `~/.claude/hooks.json` |
| Slash Command | `.claude/commands/` | `~/.claude/commands/` |
| Subagent | `.claude/agents/` | `~/.claude/agents/` |
**Minimal examples:**
<skill_example>
```markdown
---
name: process-pdfs
description: Extract text from PDF files. Use when working with PDFs.
---
<objective>Extract text from PDF files using pdfplumber.</objective>
<quick_start>
```python
import pdfplumber
with pdfplumber.open("file.pdf") as pdf:
text = pdf.pages[0].extract_text()
```
</quick_start>
<success_criteria>Text extracted without errors.</success_criteria>
```
</skill_example>
<hook_example>
```json
{
"hooks": {
"Notification": [
{
"hooks": [
{
"type": "command",
"command": "osascript -e 'display notification \"Claude needs input\" with title \"Claude Code\"'"
}
]
}
]
}
}
```
</hook_example>
<command_example>
```markdown
---
description: Create a git commit
allowed-tools: Bash(git add:*), Bash(git status:*), Bash(git commit:*)
---
<objective>Create a git commit for current changes.</objective>
<context>
Current status: ! `git status`
Changes: ! `git diff HEAD`
</context>
<process>
1. Review changes
2. Stage relevant files
3. Create commit following repository conventions
</process>
<success_criteria>Commit created successfully.</success_criteria>
```
</command_example>
<subagent_example>
```markdown
---
name: code-reviewer
description: Reviews code for quality and security. Use after code changes.
tools: Read, Grep, Glob, Bash
model: sonnet
---
<role>
You are a senior code reviewer focused on quality and security.
</role>
<workflow>
1. Read modified files
2. Identify issues
3. Provide specific feedback with file:line references
</workflow>
<constraints>
- NEVER modify code, only review
- ALWAYS provide actionable feedback
</constraints>
```
</subagent_example>
</quick_reference>
<reference_index>
**Detailed guides:**
| Reference | Content |
|-----------|---------|
| [reference/skills.md](reference/skills.md) | SKILL.md structure, router pattern, progressive disclosure |
| [reference/hooks.md](reference/hooks.md) | Hook types, matchers, input/output schemas, examples |
| [reference/commands.md](reference/commands.md) | Slash command YAML, arguments, dynamic context |
| [reference/subagents.md](reference/subagents.md) | Agent configuration, execution model, orchestration |
</reference_index>
<anti_patterns>
**Common mistakes across all extension types:**
<pitfall name="markdown_headings">
```markdown
## Bad - Using markdown headings
```
```xml
<good>Using XML tags instead</good>
```
</pitfall>
<pitfall name="vague_descriptions">
```yaml
description: Helps with stuff # Bad
description: Extract text from PDF files. Use when processing documents. # Good
```
</pitfall>
<pitfall name="first_person">
```yaml
description: I help you process files # Bad - first person
description: Processes files for analysis # Good - third person
```
</pitfall>
<pitfall name="too_many_options">
Provide ONE default approach with escape hatch, not a menu of alternatives.
</pitfall>
</anti_patterns>
<success_criteria>
A well-authored Claude Code extension has:
- Valid YAML frontmatter with descriptive name and description
- Pure XML structure (no markdown headings in body)
- Clear objective/purpose statement
- Defined success criteria or completion verification
- Appropriate level of detail (not over-engineered)
- Real-world testing and iteration
- Documentation in third person
</success_criteria>
## Emit Outcome Sidecar
As the final step, write to `~/.claude/skill-analytiRelated in AI Agents
skill-development
IncludedComprehensive meta-skill for creating, managing, validating, auditing, and distributing Claude Code skills and slash commands (unified in v2.1.3+). Provides skill templates, creation workflows, validation patterns, audit checklists, naming conventions, YAML frontmatter guidance, progressive disclosure examples, and best practices lookup. Use when creating new skills, validating existing skills, auditing skill quality, understanding skill architecture, needing skill templates, learning about YAML frontmatter requirements, progressive disclosure patterns, tool restrictions (allowed-tools), skill composition, skill naming conventions, troubleshooting skill activation issues, creating custom slash commands, configuring command frontmatter, using command arguments ($ARGUMENTS, $1, $2), bash execution in commands, file references in commands, command namespacing, plugin commands, MCP slash commands, Skill tool configuration, or deciding between skills vs slash commands. Delegates to docs-management skill for official documentation.
reprompter
IncludedTransform messy prompts into well-structured, effective prompts — single or multi-agent. Use when: "reprompt", "reprompt this", "clean up this prompt", "structure my prompt", rough text needing XML tags and best practices, "reprompter teams", "repromptception", "run with quality", "smart run", "smart agents", multi-agent tasks, audits, parallel work, anything going to agent teams. Don't use when: simple Q&A, pure chat, immediate execution-only tasks. See "Don't Use When" section for details. Outputs: Structured XML/Markdown prompt, quality score (before/after), optional team brief + per-agent sub-prompts, agent team output files. Success criteria: Single mode quality score ≥ 7/10; Repromptception per-agent prompt quality score 8+/10; all required sections present, actionable and specific.
adaptive-compaction
IncludedAdaptive add-on policy and recovery layer that decides WHEN to compact, prune, snapshot, or fork -- replacing fixed-percent auto-compaction across Claude Code, Codex, and MCP-capable hosts. Trigger on auto-compact timing or damage: "when should I compact", "is it safe to compact now or start a fresh session", "auto-compact fires too early/mid-task", "switching to an unrelated task but the window still has space", "context rot", "answers get worse the longer the session runs", "the agent forgot the plan or my decisions after it summarized", "add a layer on top that manages context without changing the agent", raising autoCompactWindow to give the policy room, or installing/tuning a cross-tool compaction policy or PreCompact hook -- even when "compaction" is never said but the problem is context-window pressure or post-summarization memory loss. Do NOT use to summarize a conversation, build RAG, write a summarization prompt (decides WHEN not HOW), or answer max-context-length trivia.
agent-skill-creator
IncludedCreate cross-platform agent skills from workflow descriptions. Activates when users ask to create an agent, automate a repetitive workflow, create a custom skill, or need advanced agent creation. Triggers on phrases like create agent for, automate workflow, create skill for, every day I have to, daily I need to, turn process into agent, need to automate, create a cross-platform skill, validate this skill, export this skill, migrate this skill. Supports single skills, multi-agent suites, transcript processing, template-based creation, interactive configuration, cross-platform export, and spec validation.
llm-wiki
IncludedUse when building or maintaining a persistent personal knowledge base (second brain) in Obsidian where an LLM incrementally ingests sources, updates entity/concept pages, maintains cross-references, and keeps a synthesis current. Triggers include "second brain", "Obsidian wiki", "personal knowledge management", "ingest this paper/article/book", "build a research wiki", "compound knowledge", "Memex", or whenever the user wants knowledge to accumulate across sessions instead of being re-derived by RAG on every query.
skill-master
IncludedAgent Skills authoring, evaluation, and optimization. Create, edit, validate, benchmark, and improve skills following the agentskills.io specification. Use when designing SKILL.md files, structuring skill folders (references, scripts, assets), ingesting external documentation into skills, running trigger evals, benchmarking skill quality, optimizing descriptions, or performing blind A/B comparisons. Keywords: agentskills.io, SKILL.md, skill authoring, eval, benchmark, trigger optimization.