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:

ApproachCommand NamesBest For
Standalone .claude//helloPersonal workflows, project-specific customizations, quick experiments
Plugins .claude-plugin//plugin-name:helloSharing 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            # Documentation

Important: 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"
  }
}
FieldPurpose
nameUnique identifier and slash command namespace (e.g., /my-plugin:hello)
descriptionShown in the plugin manager when browsing or installing
versionTrack releases using semantic versioning
authorOptional attribution information

Quick Start

1

Create the plugin directory

Create your plugin folder with mkdir -p my-plugin/.claude-plugin

2

Create the manifest

Add plugin.json with name, description, and version fields

3

Add your components

Create commands/, skills/, agents/, or hooks/ directories at the plugin root

4

Test locally

Run claude --plugin-dir ./my-plugin to test your plugin

5

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.

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

1

Discovery

At startup, the agent loads only the name and description of each available Skill for fast startup.

2

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.

3

Execution

The agent follows the Skill's instructions, loading referenced files or running bundled scripts as needed.

Where Skills Live

LocationPathScope
Personal~/.claude/skills/You, across all projects
Project.claude/skills/Anyone working in this repository
Pluginskills/Anyone with the plugin installed

Skill Frontmatter Fields

FieldRequiredDescription
nameRequiredSkill name (lowercase letters, numbers, hyphens only)
descriptionRequiredWhat the Skill does and when to use it (max 1024 chars)
allowed-toolsOptionalTools the agent can use without asking permission
modelOptionalModel to use when this Skill is active
contextOptionalSet to fork to run in a separate subagent context
hooksOptionalHooks scoped to this Skill's lifecycle
user-invocableOptionalWhether 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

LocationPathScope
Project.claude/agents/Current project only
User~/.claude/agents/All your projects
Pluginagents/Anyone with the plugin installed

Subagent Frontmatter Fields

FieldRequiredDescription
nameRequiredUnique identifier using lowercase letters and hyphens
descriptionRequiredWhen the agent should delegate to this subagent
toolsOptionalTools the subagent can use (inherits all if omitted)
disallowedToolsOptionalTools to deny, removed from inherited list
modelOptionalModel: sonnet, opus, haiku, or inherit
permissionModeOptionalPermission level: inherit, default, bypassPermissions
skillsOptionalSkills 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 considerations

Commands (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

AspectSkillsCommands
InvocationAgent chooses automatically based on contextUser types /command explicitly
Best forSpecialized knowledge, domain expertiseCommon workflows, quick actions
ExamplesPR review standards, database schema docs/commit, /deploy, /test

Where Commands Live

LocationPathScope
Personal~/.claude/commands/You, across all projects
Project.claude/commands/Anyone working in this repository
Plugincommands/Anyone with the plugin installed

Command Arguments

Commands can accept user input through special placeholders:

PlaceholderDescription
$ARGUMENTSCaptures 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

EventWhen it runsCan block?
PreToolUseBefore tool callsYes
PostToolUseAfter tool calls completeNo
PermissionRequestWhen permission dialog is shownYes
UserPromptSubmitWhen user submits a promptNo
NotificationWhen agent sends notificationsNo
StopWhen agent finishes respondingNo
SubagentStopWhen subagent tasks completeNo
SessionStartWhen a session starts or resumesNo
SessionEndWhen a session endsNo

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 calls
  • Edit|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 proceed
  • 2 - 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 thisWhen you want to...When it runs
SkillsGive the agent specialized knowledge (e.g., "review PRs using our standards")Agent chooses when relevant
SubagentsDelegate tasks to a separate context with its own toolsAgent delegates, or you invoke explicitly
CommandsCreate reusable prompts (e.g., /deploy staging)You type /command to run it
HooksRun 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.