1. Plugin Structure Is Sacred
my-plugin/
├── .claude-plugin/
│ └── plugin.json # ONLY manifest here (required)
├── commands/ # Slash commands (plugin root)
├── agents/ # Subagent definitions (plugin root)
├── skills/ # Agent Skills (plugin root)
├── hooks/
│ └── hooks.json # Event handlers (plugin root)
├── .mcp.json # MCP server configs (plugin root)
└── .lsp.json # LSP server configs (plugin root)
CRITICAL: Never put commands/, agents/, skills/, or hooks/ inside .claude-plugin/. Only plugin.json goes there.
2. Namespacing Prevents Conflicts
Plugin commands use format /plugin-name:command-name. The name field in plugin.json becomes the namespace prefix. Choose names carefully - they're public-facing.
3. Use ${CLAUDE_PLUGIN_ROOT} for Paths
All paths in hooks, MCP servers, and scripts must use ${CLAUDE_PLUGIN_ROOT} to reference plugin files. Plugins are copied to a cache directory, so relative paths like ../ won't work.
4. Test with --plugin-dir During Development
claude --plugin-dir ./my-plugin
This loads your plugin without installation. Restart Claude Code after changes.
- Create a new plugin
- Add a component (command, agent, skill, hook, MCP, LSP)
- Test or debug a plugin
- Create a marketplace for distribution
- Something else
Wait for response before proceeding.
After reading the workflow, follow it exactly.
- Validate plugin structure:
claude plugin validate ./my-plugin
- Test plugin loads:
claude --plugin-dir ./my-plugin
- Verify components appear:
- Commands:
/help shows plugin commands
- Agents:
/agents lists plugin agents
- MCP:
/mcp shows server status
Report to user:
- "Plugin validates: ✓"
- "Commands registered: X"
- "Ready for testing"
Structure: plugin-structure.md
Components: commands.md, agents.md, skills.md, hooks.md, mcp-lsp.md
Distribution: marketplace.md
Issues: troubleshooting.md
| Workflow |
Purpose |
| create-plugin.md |
Create new plugin from scratch |
| add-component.md |
Add command, agent, skill, hook, MCP, or LSP |
| test-debug-plugin.md |
Test locally and fix issues |
| create-marketplace.md |
Create and host plugin marketplace |
|
|
1---2name: developing-claude-code-plugins3description: Build, test, and distribute Claude Code plugins with slash commands, agents, skills, hooks, MCP servers, and LSP servers. MUST be loaded when creating, reviewing, debugging, or distributing plugins. Use PROACTIVELY when user mentions plugins, extensions, marketplaces, or wants to add custom commands/agents to Claude Code.4---56<essential_principles>7Plugins extend Claude Code with reusable functionality: custom slash commands, agents, skills, hooks, MCP servers, and LSP servers. Unlike standalone `.claude/` configurations, plugins are namespaced, versioned, and distributable through marketplaces.89**1. Plugin Structure Is Sacred**1011```12my-plugin/13├── .claude-plugin/14│ └── plugin.json # ONLY manifest here (required)15├── commands/ # Slash commands (plugin root)16├── agents/ # Subagent definitions (plugin root)17├── skills/ # Agent Skills (plugin root)18├── hooks/19│ └── hooks.json # Event handlers (plugin root)20├── .mcp.json # MCP server configs (plugin root)21└── .lsp.json # LSP server configs (plugin root)22```2324**CRITICAL**: Never put commands/, agents/, skills/, or hooks/ inside `.claude-plugin/`. Only `plugin.json` goes there.2526**2. Namespacing Prevents Conflicts**2728Plugin commands use format `/plugin-name:command-name`. The `name` field in plugin.json becomes the namespace prefix. Choose names carefully - they're public-facing.2930**3. Use `${CLAUDE_PLUGIN_ROOT}` for Paths**3132All paths in hooks, MCP servers, and scripts must use `${CLAUDE_PLUGIN_ROOT}` to reference plugin files. Plugins are copied to a cache directory, so relative paths like `../` won't work.3334**4. Test with `--plugin-dir` During Development**3536```bash37claude --plugin-dir ./my-plugin38```3940This loads your plugin without installation. Restart Claude Code after changes.4142</essential_principles>4344<intake>45**What would you like to do?**46471. Create a new plugin482. Add a component (command, agent, skill, hook, MCP, LSP)493. Test or debug a plugin504. Create a marketplace for distribution515. Something else5253**Wait for response before proceeding.**54</intake>5556<routing>57| Response | Workflow |58|----------|----------|59| 1, "new", "create", "build", "start", "plugin" | `workflows/create-plugin.md` |60| 2, "add", "component", "command", "agent", "skill", "hook", "mcp", "lsp" | `workflows/add-component.md` |61| 3, "test", "debug", "fix", "error", "not working", "broken" | `workflows/test-debug-plugin.md` |62| 4, "marketplace", "distribute", "share", "publish" | `workflows/create-marketplace.md` |63| 5, other | Clarify intent, then route to appropriate workflow |6465**After reading the workflow, follow it exactly.**66</routing>6768<verification_loop>69**After Every Change:**70711. Validate plugin structure:72```bash73claude plugin validate ./my-plugin74```75762. Test plugin loads:77```bash78claude --plugin-dir ./my-plugin79```80813. Verify components appear:82- Commands: `/help` shows plugin commands83- Agents: `/agents` lists plugin agents84- MCP: `/mcp` shows server status8586Report to user:87- "Plugin validates: ✓"88- "Commands registered: X"89- "Ready for testing"90</verification_loop>9192<reference_index>93All in `references/`:9495**Structure:** plugin-structure.md96**Components:** commands.md, agents.md, skills.md, hooks.md, mcp-lsp.md97**Distribution:** marketplace.md98**Issues:** troubleshooting.md99</reference_index>100101<workflows_index>102All in `workflows/`:103104| Workflow | Purpose |105|----------|---------|106| create-plugin.md | Create new plugin from scratch |107| add-component.md | Add command, agent, skill, hook, MCP, or LSP |108| test-debug-plugin.md | Test locally and fix issues |109| create-marketplace.md | Create and host plugin marketplace |110</workflows_index>111112<success_criteria>113A well-built plugin:114- Has valid plugin.json manifest in `.claude-plugin/`115- Components are in correct directories (commands/, agents/, skills/, hooks/)116- All paths use `${CLAUDE_PLUGIN_ROOT}` variable117- Passes `claude plugin validate`118- Loads correctly with `--plugin-dir`119- Commands appear in `/help` output120</success_criteria>