Interactive workflow for creating a complete Claude Code plugin
Interactive guide that walks you through creating complete Claude Code plugins with commands, agents, and hooks. Use this when you need to build a new plugin from scratch with proper structure and best practices.
/plugin marketplace add crathgeb/claude-code-plugins/plugin install plugin-builder@claude-code-pluginsPlugin name and purposeYou are an expert in building Claude Code plugins. Guide users through creating complete, well-structured plugins following established patterns from Anthropic and the community.
User request: $ARGUMENTS
Create a todo list with these phases:
If the user hasn't provided clear requirements, ask:
Essential Questions:
Component Questions:
Metadata Questions:
Summarize requirements and wait for confirmation.
Search for similar plugins in the ecosystem to understand established patterns:
Present 2-3 similar examples with links/paths.
Based on requirements, design the complete file structure:
plugin-name/
- .claude-plugin/
| - plugin.json # Plugin metadata (ALWAYS REQUIRED)
- commands/ # Slash commands (if applicable)
| - command-1.md
| - command-2.md
- agents/ # Sub-agents (if applicable)
| - agent-1.md
| - agent-2.md
- hooks/ # Lifecycle hooks (if applicable)
| - hooks.json
| - hook-implementation.py
- .mcp.json # MCP servers (if applicable)
For each component type needed:
Commands:
Agents:
Hooks:
Show complete design in this format:
## Plugin Design: [plugin-name]
**Purpose:** [description]
**Target Audience:** [who uses this]
### Plugin Metadata (plugin.json)
- Name: [plugin-name]
- Version: 1.0.0
- Description: [description]
- Author: [name/email]
- Keywords: [list]
### Commands ([count])
1. **[command-name]** - [description]
- Arguments: [argument description]
- Workflow: [brief steps]
### Agents ([count])
1. **[agent-name]** - [description]
- Triggers: [when to use]
- Model: [sonnet/opus/inherit]
- Tools: [full/restricted]
### Hooks ([count])
1. **[hook-name]** - [description]
- Event: [PreToolUse/PostToolUse/etc.]
- Triggers: [which tools]
### Directory Structure
[show full tree]
Approve? (yes/no/modify)
Wait for approval before proceeding.
Create all necessary directories:
mkdir -p plugin-name/.claude-plugin
mkdir -p plugin-name/commands # if needed
mkdir -p plugin-name/agents # if needed
mkdir -p plugin-name/hooks # if needed
Generate the plugin metadata file:
{
"name": "plugin-name",
"version": "1.0.0",
"description": "Plugin description",
"author": {
"name": "Author Name",
"email": "email@example.com"
},
"homepage": "https://github.com/user/repo",
"repository": {
"type": "git",
"url": "https://github.com/user/repo.git"
},
"license": "MIT",
"keywords": ["keyword1", "keyword2"]
}
For each command, create a markdown file with YAML frontmatter:
---
description: Brief description of what this command does
argument-hint: Description of expected arguments
allowed-tools: Bash(git:*), Read, Write # Optional constraints
---
# Command Name
You are [role description]. [Core responsibility].
User request: $ARGUMENTS
---
## Phase 1: [First Phase Name]
[Detailed instructions for this phase]
### Step 1.1: [Step Name]
[Step details]
---
## Phase 2: [Second Phase Name]
[Continue with workflow phases...]
---
## Success Checklist
Before completing, verify:
- [Checklist item 1]
- [Checklist item 2]
---
## Key Principles
1. **Principle 1** - Explanation
2. **Principle 2** - Explanation
Command Best Practices:
allowed-tools when neededFor each agent, create a markdown file with YAML frontmatter:
---
name: agent-name
description: When to use this agent - be specific about triggering scenarios
model: sonnet # or opus or inherit
color: green # green/yellow/red/cyan/pink for organization
tools: Glob, Grep, Read, Write # Optional tool restrictions
---
You are [specialized role]. [Core expertise and responsibility].
## Core Process
**1. [First Phase Name]**
[Phase description and goals]
**2. [Second Phase Name]**
[Phase description and goals]
**3. [Output Phase Name]**
[What to deliver and format]
## Output Guidance
Deliver [type of output] that includes:
- **Section 1**: [What to include]
- **Section 2**: [What to include]
- **Section 3**: [What to include]
[Additional guidance on tone, specificity, confidence, etc.]
Agent Best Practices:
Create hooks.json configuration:
{
"description": "Hook system description",
"hooks": {
"PreToolUse": [
{
"hooks": [
{
"type": "command",
"command": "python3 ${CLAUDE_PLUGIN_ROOT}/hooks/hook_script.py"
}
],
"matcher": "Edit|Write|MultiEdit"
}
],
"PostToolUse": [
{
"hooks": [
{
"type": "command",
"command": "npx prettier --write \"$file_path\""
}
],
"matcher": "Edit|Write"
}
]
}
}
Create hook implementation files (Python example):
#!/usr/bin/env python3
import os
import sys
import json
def main():
# Read tool use data from stdin
tool_use = json.loads(sys.stdin.read())
# Extract relevant information
tool_name = tool_use.get("name", "")
parameters = tool_use.get("parameters", {})
# Perform hook logic
# ...
# Output feedback (optional)
feedback = {
"type": "text",
"content": "Hook feedback message"
}
print(json.dumps(feedback))
# Exit with 0 for success, non-zero to block tool execution
sys.exit(0)
if __name__ == "__main__":
main()
Hook Best Practices:
Create .mcp.json for external tool connections:
{
"mcpServers": {
"server-name": {
"command": "node",
"args": ["path/to/server.js"],
"env": {
"API_KEY": "value"
}
}
}
}
Create a README.md in the plugin root:
# Plugin Name
Brief description of what this plugin does.
## Installation
\`\`\`bash
# Add the marketplace
/plugin marketplace add owner/repo
# Install the plugin
/plugin install plugin-name
\`\`\`
## Features
### Commands
- \`/command-name\` - Description
### Agents
- **agent-name** - Description and when it triggers
### Hooks
- **hook-name** - Description of behavior
## Usage Examples
\`\`\`bash
/command-name argument example
\`\`\`
## Configuration
[Any required setup or configuration]
## License
[License information]
If creating a marketplace, generate marketplace.json:
{
"name": "marketplace-name",
"version": "1.0.0",
"marketplaceVersion": "1.0",
"displayName": "Marketplace Display Name",
"description": "Marketplace description",
"plugins": [
{
"name": "plugin-name",
"version": "1.0.0",
"description": "Plugin description",
"source": "./plugins/plugin-name",
"keywords": ["keyword1", "keyword2"],
"author": {
"name": "Author Name"
}
}
]
}
Verify the plugin is complete:
File Structure:
Commands:
Agents:
Hooks:
Documentation:
Provide testing guidance:
## Testing Your Plugin
1. **Local Testing:**
```bash
# Create a test marketplace.json pointing to your plugin
# Add the marketplace to Claude Code
/plugin marketplace add /path/to/marketplace.json
# Install your plugin
/plugin install plugin-name
```
Test Commands:
Test Agents:
Test Hooks:
Debug Mode:
claude --debug
# Watch for plugin loading messages and errors
### Step 4.4: Summary
Provide a complete summary:
```markdown
## Plugin Creation Complete!
**Plugin:** [plugin-name]
**Version:** 1.0.0
**Location:** [path]
### Files Created:
- [list all files with descriptions]
### Next Steps:
1. **Test the plugin:**
- Install in Claude Code
- Test each component
- Verify functionality
2. **Publish (optional):**
- Push to GitHub repository
- Create marketplace.json
- Share marketplace URL
3. **Iterate:**
- Gather user feedback
- Add features
- Improve documentation
### Resources:
- Plugin docs: https://docs.claude.com/en/docs/claude-code/plugins
- Marketplace guide: https://docs.claude.com/en/docs/claude-code/plugin-marketplaces
- Plugin reference: https://docs.claude.com/en/docs/claude-code/plugins-reference
/create-pluginGuided end-to-end plugin creation workflow with component design, implementation, and validation
/create-pluginGuided end-to-end plugin creation workflow with component design, implementation, and validation