Documentation
Everything you need to build, publish, and integrate Agent Skills.
Getting Started
Plugins extend AI agents with new capabilities. A plugin is a package that can contain skills, subagents, commands, and hooks - giving agents specialized knowledge, delegation capabilities, user-invocable actions, and lifecycle automation.
Standalone vs Plugins
There are two ways to add custom functionality:
| Approach | Command Names | Best For |
|---|---|---|
Standalone .claude/ | /hello | Personal workflows, project-specific customizations, quick experiments |
Plugins .claude-plugin/ | /plugin-name:hello | Sharing with teammates, distributing to community, reusable across projects |
Tip: Start with standalone configuration in .claude/ for quick iteration, then convert to a plugin when you're ready to share. Plugin commands are namespaced (like /my-plugin:hello) to prevent conflicts.
Plugin Structure
my-plugin/
├── .claude-plugin/
│ └── plugin.json # Required: Plugin manifest
├── commands/ # Slash commands as Markdown files
│ └── hello.md
├── agents/ # Custom agent definitions
│ └── code-reviewer.md
├── skills/ # Agent Skills with SKILL.md files
│ └── code-review/
│ └── SKILL.md
├── hooks/ # Event handlers
│ └── hooks.json
├── .mcp.json # MCP server configurations
└── README.md # DocumentationImportant: Don't put commands/, agents/, skills/, or hooks/ inside the .claude-plugin/ directory. Only plugin.json goes inside .claude-plugin/. All other directories must be at the plugin root level.
Plugin Manifest
Every plugin requires a .claude-plugin/plugin.json manifest:
{
"name": "my-plugin",
"description": "A helpful plugin for code workflows",
"version": "1.0.0",
"author": {
"name": "Your Name"
}
}| Field | Purpose |
|---|---|
| name | Unique identifier and slash command namespace (e.g., /my-plugin:hello) |
| description | Shown in the plugin manager when browsing or installing |
| version | Track releases using semantic versioning |
| author | Optional attribution information |
Quick Start
Create the plugin directory
Create your plugin folder with mkdir -p my-plugin/.claude-plugin
Create the manifest
Add plugin.json with name, description, and version fields
Add your components
Create commands/, skills/, agents/, or hooks/ directories at the plugin root
Test locally
Run claude --plugin-dir ./my-plugin to test your plugin
Publish to the marketplace
Share your plugin with the community or distribute through a team marketplace
Example: A Complete Plugin
Here's what a "GitHub Integration" plugin might include:
Skills
PR review standards, code quality guidelines
Subagents
Issue triage bot, security scanner
Commands
/github:pr, /github:issue, /github:release
Hooks
Auto-lint on commit, changelog update
Plugin Components
A plugin is a package that can contain one or more of the following components. When you publish to the marketplace, you're publishing a plugin.
Skills
Markdown files that teach agents how to do something specific. Agents automatically discover and apply relevant skills based on context.
Subagents
Specialized AI assistants with their own context window, tool restrictions, and permissions. Ideal for task delegation.
Commands
Slash commands that users invoke directly with /command. Great for common workflows like commits or deployments.
Hooks
Shell commands that execute automatically at specific lifecycle points. Ensure deterministic behavior for formatting, validation, and notifications.
Note: A plugin can contain any combination of these components. For example, a "GitHub Integration" plugin might include skills for repository management, commands like /pr, and hooks that run on commit.
Skills
A Skill is a markdown file that teaches the agent how to do something specific: reviewing PRs using your team's standards, generating commit messages in your preferred format, or querying your company's database schema. Skills are model-invoked - the agent decides which Skills to use based on your request.
How Skills Work
Discovery
At startup, the agent loads only the name and description of each available Skill for fast startup.
Activation
When your request matches a Skill's description, the agent asks to use it. The full SKILL.md is loaded into context after confirmation.
Execution
The agent follows the Skill's instructions, loading referenced files or running bundled scripts as needed.
Where Skills Live
| Location | Path | Scope |
|---|---|---|
| Personal | ~/.claude/skills/ | You, across all projects |
| Project | .claude/skills/ | Anyone working in this repository |
| Plugin | skills/ | Anyone with the plugin installed |
Skill Frontmatter Fields
| Field | Required | Description |
|---|---|---|
| name | Required | Skill name (lowercase letters, numbers, hyphens only) |
| description | Required | What the Skill does and when to use it (max 1024 chars) |
| allowed-tools | Optional | Tools the agent can use without asking permission |
| model | Optional | Model to use when this Skill is active |
| context | Optional | Set to fork to run in a separate subagent context |
| hooks | Optional | Hooks scoped to this Skill's lifecycle |
| user-invocable | Optional | Whether the Skill appears in slash command menu (default: true) |
Example Skill with Supporting Files
pdf-processing/
├── SKILL.md # Overview and quick start
├── FORMS.md # Form field mappings and filling instructions
├── REFERENCE.md # API details for pypdf and pdfplumber
└── scripts/
├── fill_form.py # Utility to populate form fields
└── validate.py # Checks PDFs for required fields---
name: pdf-processing
description: Extract text, fill forms, merge PDFs. Use when working with PDF files.
allowed-tools: Read, Bash(python:*)
---
# PDF Processing
## Quick start
Extract text:
```python
import pdfplumber
with pdfplumber.open("doc.pdf") as pdf:
text = pdf.pages[0].extract_text()
```
For form filling, see [FORMS.md](FORMS.md).
For detailed API reference, see [REFERENCE.md](REFERENCE.md).Subagents
Subagents are specialized AI assistants that handle specific types of tasks. Each subagent runs in its own context window with a custom system prompt, specific tool access, and independent permissions. When the agent encounters a task that matches a subagent's description, it delegates to that subagent.
Why Use Subagents?
Preserve Context
Keep exploration and implementation out of your main conversation
Enforce Constraints
Limit which tools a subagent can use for safety
Specialize Behavior
Focused system prompts for specific domains
Control Costs
Route tasks to faster, cheaper models like Haiku
Where Subagents Live
| Location | Path | Scope |
|---|---|---|
| Project | .claude/agents/ | Current project only |
| User | ~/.claude/agents/ | All your projects |
| Plugin | agents/ | Anyone with the plugin installed |
Subagent Frontmatter Fields
| Field | Required | Description |
|---|---|---|
| name | Required | Unique identifier using lowercase letters and hyphens |
| description | Required | When the agent should delegate to this subagent |
| tools | Optional | Tools the subagent can use (inherits all if omitted) |
| disallowedTools | Optional | Tools to deny, removed from inherited list |
| model | Optional | Model: sonnet, opus, haiku, or inherit |
| permissionMode | Optional | Permission level: inherit, default, bypassPermissions |
| skills | Optional | Skills to inject into subagent context at startup |
Example Subagent
---
name: code-reviewer
description: Reviews code for quality and best practices. Use proactively after code changes.
tools: Read, Grep, Glob, Bash
model: sonnet
---
You are a senior code reviewer. When invoked:
1. Analyze the code for quality, security, and best practices
2. Provide specific, actionable feedback
3. Highlight both issues and strengths
4. Suggest concrete improvements with code examples
Focus on:
- Code organization and readability
- Error handling and edge cases
- Security vulnerabilities
- Performance considerationsCommands (Slash Commands)
Commands are user-invocable actions triggered by typing /command-name. Unlike Skills (which the agent chooses automatically), Commands require explicit user invocation. They're ideal for common workflows users want quick access to.
Skills vs Commands
| Aspect | Skills | Commands |
|---|---|---|
| Invocation | Agent chooses automatically based on context | User types /command explicitly |
| Best for | Specialized knowledge, domain expertise | Common workflows, quick actions |
| Examples | PR review standards, database schema docs | /commit, /deploy, /test |
Where Commands Live
| Location | Path | Scope |
|---|---|---|
| Personal | ~/.claude/commands/ | You, across all projects |
| Project | .claude/commands/ | Anyone working in this repository |
| Plugin | commands/ | Anyone with the plugin installed |
Command Arguments
Commands can accept user input through special placeholders:
| Placeholder | Description |
|---|---|
| $ARGUMENTS | Captures all text after the command name |
| $1, $2, ... | Individual arguments by position |
Example Command
.claude/commands/deploy.md---
name: deploy
description: Deploy the current branch to staging or production
allowed-tools: Bash, Read
---
# Deploy Command
Deploy the current branch to the "$ARGUMENTS" environment using our deployment pipeline.
## Steps
1. Run tests to ensure everything passes
2. Build the production bundle
3. Deploy to the specified environment
## Usage
- `/deploy staging` - Deploy to staging environment
- `/deploy production` - Deploy to production (requires approval)Tip: Commands can accept arguments. When a user types /deploy production, the $ARGUMENTS placeholder is replaced with "production".
Namespacing: Plugin commands are namespaced with the plugin name. A command in deploy.md inside a plugin named "my-plugin" becomes /my-plugin:deploy. Standalone commands in .claude/commands/ have no namespace.
Hooks
Hooks are user-defined shell commands that execute at various points in the agent's lifecycle. They provide deterministic control over behavior, ensuring certain actions always happen rather than relying on the LLM to choose to run them.
Security Note: Hooks run automatically with your environment's credentials. Always review hook implementations before registering them to prevent data exfiltration or other security issues.
Hook Events
| Event | When it runs | Can block? |
|---|---|---|
| PreToolUse | Before tool calls | Yes |
| PostToolUse | After tool calls complete | No |
| PermissionRequest | When permission dialog is shown | Yes |
| UserPromptSubmit | When user submits a prompt | No |
| Notification | When agent sends notifications | No |
| Stop | When agent finishes responding | No |
| SubagentStop | When subagent tasks complete | No |
| SessionStart | When a session starts or resumes | No |
| SessionEnd | When a session ends | No |
Common Use Cases
Auto-formatting
Run prettier on .ts files, gofmt on .go files after every edit
Notifications
Custom desktop or Slack notifications when agent needs input
Logging
Track all executed commands for compliance or debugging
File Protection
Block modifications to production files or sensitive directories
Hook Configuration
Hooks are configured in ~/.claude/settings.json (user) or .claude/settings.json (project).
{
"hooks": {
"PostToolUse": [
{
"matcher": "Edit|Write",
"hooks": [
{
"type": "command",
"command": "jq -r '.tool_input.file_path' | { read file_path; if echo \"$file_path\" | grep -q '\\.ts$'; then npx prettier --write \"$file_path\"; fi; }"
}
]
}
],
"PreToolUse": [
{
"matcher": "Edit|Write",
"hooks": [
{
"type": "command",
"command": "python3 -c \"import json, sys; data=json.load(sys.stdin); path=data.get('tool_input',{}).get('file_path',''); sys.exit(2 if any(p in path for p in ['.env', 'package-lock.json', '.git/']) else 0)\""
}
]
}
]
}
}Matcher Patterns
Use matchers to run hooks only for specific tools:
Bash- Match only Bash tool callsEdit|Write- Match Edit or Write tool calls*- Match all tools""(empty) - Match all tools
Exit Codes
For PreToolUse hooks, exit codes control behavior:
0- Allow the tool call to proceed2- Block the tool call and provide feedback to the agent- Other non-zero - Hook error (tool call proceeds)
When to Use What
Choose the right extensibility mechanism for your use case:
| Use this | When you want to... | When it runs |
|---|---|---|
| Skills | Give the agent specialized knowledge (e.g., "review PRs using our standards") | Agent chooses when relevant |
| Subagents | Delegate tasks to a separate context with its own tools | Agent delegates, or you invoke explicitly |
| Commands | Create reusable prompts (e.g., /deploy staging) | You type /command to run it |
| Hooks | Run scripts on events (e.g., lint on file save) | Fires on specific tool events |
Skills vs. Subagents: Skills add knowledge to the current conversation. Subagents run in a separate context with their own tools. Use Skills for guidance and standards; use Subagents when you need isolation or different tool access.