$npx -y skills add anthropics/claude-code --skill plugin-structureplugin structure is an agent skill published from anthropics/claude-code, installable through the skills CLI.
| 1 | # Plugin Structure for Claude Code |
| 2 | |
| 3 | ## Overview |
| 4 | |
| 5 | Claude Code plugins follow a standardized directory structure with automatic component discovery. Understanding this structure enables creating well-organized, maintainable plugins that integrate seamlessly with Claude Code. |
| 6 | |
| 7 | **Key concepts:** |
| 8 | - Conventional directory layout for automatic discovery |
| 9 | - Manifest-driven configuration in `.claude-plugin/plugin.json` |
| 10 | - Component-based organization (commands, agents, skills, hooks) |
| 11 | - Portable path references using `${CLAUDE_PLUGIN_ROOT}` |
| 12 | - Explicit vs. auto-discovered component loading |
| 13 | |
| 14 | ## Directory Structure |
| 15 | |
| 16 | Every Claude Code plugin follows this organizational pattern: |
| 17 | |
| 18 | ``` |
| 19 | plugin-name/ |
| 20 | ├── .claude-plugin/ |
| 21 | │ └── plugin.json # Required: Plugin manifest |
| 22 | ├── commands/ # Slash commands (.md files) |
| 23 | ├── agents/ # Subagent definitions (.md files) |
| 24 | ├── skills/ # Agent skills (subdirectories) |
| 25 | │ └── skill-name/ |
| 26 | │ └── SKILL.md # Required for each skill |
| 27 | ├── hooks/ |
| 28 | │ └── hooks.json # Event handler configuration |
| 29 | ├── .mcp.json # MCP server definitions |
| 30 | └── scripts/ # Helper scripts and utilities |
| 31 | ``` |
| 32 | |
| 33 | **Critical rules:** |
| 34 | |
| 35 | 1. **Manifest location**: The `plugin.json` manifest MUST be in `.claude-plugin/` directory |
| 36 | 2. **Component locations**: All component directories (commands, agents, skills, hooks) MUST be at plugin root level, NOT nested inside `.claude-plugin/` |
| 37 | 3. **Optional components**: Only create directories for components the plugin actually uses |
| 38 | 4. **Naming convention**: Use kebab-case for all directory and file names |
| 39 | |
| 40 | ## Plugin Manifest (plugin.json) |
| 41 | |
| 42 | The manifest defines plugin metadata and configuration. Located at `.claude-plugin/plugin.json`: |
| 43 | |
| 44 | ### Required Fields |
| 45 | |
| 46 | ```json |
| 47 | { |
| 48 | "name": "plugin-name" |
| 49 | } |
| 50 | ``` |
| 51 | |
| 52 | **Name requirements:** |
| 53 | - Use kebab-case format (lowercase with hyphens) |
| 54 | - Must be unique across installed plugins |
| 55 | - No spaces or special characters |
| 56 | - Example: `code-review-assistant`, `test-runner`, `api-docs` |
| 57 | |
| 58 | ### Recommended Metadata |
| 59 | |
| 60 | ```json |
| 61 | { |
| 62 | "name": "plugin-name", |
| 63 | "version": "1.0.0", |
| 64 | "description": "Brief explanation of plugin purpose", |
| 65 | "author": { |
| 66 | "name": "Author Name", |
| 67 | "email": "author@example.com", |
| 68 | "url": "https://example.com" |
| 69 | }, |
| 70 | "homepage": "https://docs.example.com", |
| 71 | "repository": "https://github.com/user/plugin-name", |
| 72 | "license": "MIT", |
| 73 | "keywords": ["testing", "automation", "ci-cd"] |
| 74 | } |
| 75 | ``` |
| 76 | |
| 77 | **Version format**: Follow semantic versioning (MAJOR.MINOR.PATCH) |
| 78 | **Keywords**: Use for plugin discovery and categorization |
| 79 | |
| 80 | ### Component Path Configuration |
| 81 | |
| 82 | Specify custom paths for components (supplements default directories): |
| 83 | |
| 84 | ```json |
| 85 | { |
| 86 | "name": "plugin-name", |
| 87 | "commands": "./custom-commands", |
| 88 | "agents": ["./agents", "./specialized-agents"], |
| 89 | "hooks": "./config/hooks.json", |
| 90 | "mcpServers": "./.mcp.json" |
| 91 | } |
| 92 | ``` |
| 93 | |
| 94 | **Important**: Custom paths supplement defaults—they don't replace them. Components in both default directories and custom paths will load. |
| 95 | |
| 96 | **Path rules:** |
| 97 | - Must be relative to plugin root |
| 98 | - Must start with `./` |
| 99 | - Cannot use absolute paths |
| 100 | - Support arrays for multiple locations |
| 101 | |
| 102 | ## Component Organization |
| 103 | |
| 104 | ### Commands |
| 105 | |
| 106 | **Location**: `commands/` directory |
| 107 | **Format**: Markdown files with YAML frontmatter |
| 108 | **Auto-discovery**: All `.md` files in `commands/` load automatically |
| 109 | |
| 110 | **Example structure**: |
| 111 | ``` |
| 112 | commands/ |
| 113 | ├── review.md # /review command |
| 114 | ├── test.md # /test command |
| 115 | └── deploy.md # /deploy command |
| 116 | ``` |
| 117 | |
| 118 | **File format**: |
| 119 | ```markdown |
| 120 | --- |
| 121 | name: command-name |
| 122 | description: Command description |
| 123 | --- |
| 124 | |
| 125 | Command implementation instructions... |
| 126 | ``` |
| 127 | |
| 128 | **Usage**: Commands integrate as native slash commands in Claude Code |
| 129 | |
| 130 | ### Agents |
| 131 | |
| 132 | **Location**: `agents/` directory |
| 133 | **Format**: Markdown files with YAML frontmatter |
| 134 | **Auto-discovery**: All `.md` files in `agents/` load automatically |
| 135 | |
| 136 | **Example structure**: |
| 137 | ``` |
| 138 | agents/ |
| 139 | ├── code-reviewer.md |
| 140 | ├── test-generator.md |
| 141 | └── refactorer.md |
| 142 | ``` |
| 143 | |
| 144 | **File format**: |
| 145 | ```markdown |
| 146 | --- |
| 147 | description: Agent role and expertise |
| 148 | capabilities: |
| 149 | - Specific task 1 |
| 150 | - Specific task 2 |
| 151 | --- |
| 152 | |
| 153 | Detailed agent instructions and knowledge... |
| 154 | ``` |
| 155 | |
| 156 | **Usage**: Users can invoke agents manually, or Claude Code selects them automatically based on task context |
| 157 | |
| 158 | ### Skills |
| 159 | |
| 160 | **Location**: `skills/` directory with subdirectories per skill |
| 161 | **Format**: Each skill in its own directory with `SKILL.md` file |
| 162 | **Auto-discovery**: All `SKILL.md` files in skill subdirectories |