14 KiB
name, description
| name | description |
|---|---|
| Creating and Editing Claude Plugins | Use before creating or editing plugin.json manifests, organizing .claude-plugin directories, or when user asks about plugin structure, versioning, or distribution. Provides expert guidance on manifest configuration, component organization, semantic versioning, and shareable plugin best practices. Invoke when working with any plugin files or discussing plugin architecture to ensure correct structure and discoverability. |
Building Claude Code Plugins
This skill provides comprehensive guidance for creating Claude Code plugins that extend Claude with shareable, discoverable functionality.
What Are Claude Code Plugins?
Plugins are packages of functionality that can be shared across projects and teams. They can contain:
- Custom slash commands: User-invoked commands
- Custom agents: Specialized agent behaviors
- Agent skills: Reusable capabilities agents can invoke
- Event hooks: Handlers that trigger on specific events
- MCP servers: External tool integrations
Plugins are discoverable through plugin marketplaces and easy to install with /plugin install.
Core Requirements
Every plugin requires exactly one file: .claude-plugin/plugin.json
Minimum valid plugin:
{
"name": "my-plugin",
"version": "1.0.0"
}
All other components (commands, agents, skills, hooks, MCP servers) are optional.
Quick Start
- Create plugin directory:
mkdir my-plugin - Create manifest:
mkdir my-plugin/.claude-plugin - Create plugin.json with name and version
- Add components (skills, commands, etc.) as needed
- Test locally:
/plugin install /path/to/my-plugin
For complete templates, see templates/plugin.json and templates/README.md.
Plugin Manifest
The plugin.json file defines your plugin's metadata and component locations.
Required Fields
name: Unique identifier in kebab-caseversion: Semantic versioning (MAJOR.MINOR.PATCH)
Optional Metadata
description: Brief plugin purposeauthor: Object withname(required) andemail(optional)homepage: Documentation URLrepository: Source code linklicense: Open source license identifierkeywords: Array of discovery tags
Component Paths
Specify where Claude should find each component type:
{
"name": "my-plugin",
"version": "1.0.0",
"commands": ["./commands"],
"agents": ["./agents"],
"skills": ["./skills"],
"hooks": "./hooks/hooks.json",
"mcpServers": "./.mcp.json"
}
Path rules:
- Must be relative to plugin root
- Should start with
./ - Can be arrays for multiple directories
- Use
${CLAUDE_PLUGIN_ROOT}variable for flexible resolution
See reference/plugin-structure.md for detailed structure information.
Component Types
Commands
Custom slash commands users invoke directly.
- Location: Specified in
commandsfield - Format: Markdown files with frontmatter
- Example:
/my-command
Agents
Specialized agent behaviors with custom capabilities.
- Location: Specified in
agentsfield - Format: Markdown files describing agent
Skills
Reusable capabilities agents can invoke autonomously.
- Location: Specified in
skillsfield - Format: Directories containing
SKILL.md - Most common component type
Hooks
Event handlers triggered by specific events.
- Location: Specified in
hooksfield (points to hooks.json) - Events: PreToolUse, PostToolUse, UserPromptSubmit
- Format: JSON configuration file
MCP Servers
External tool integrations via Model Context Protocol.
- Location: Specified in
mcpServersfield (points to .mcp.json) - Purpose: Connect external data sources and tools
Ensuring Consistency Between Commands and Skills
CRITICAL: When a plugin contains both slash commands and skills that work together, they must provide consistent instructions. Inconsistencies cause Claude to follow the wrong workflow.
The Problem
Slash commands execute first and provide initial instructions. If the command has different instructions than a skill it invokes, Claude will follow the command's approach instead of the skill's approach.
Example issue:
- Slash command says: "Clone the repository with
gh repo clone" - Skill says: "Create a git worktree with
git worktree add" - Result: Claude clones instead of using worktrees (following the command's instructions)
The Solution
- Align workflows: Ensure slash commands and skills describe the same approach
- Avoid duplication: Have the command reference the skill rather than duplicating instructions
- Provide complete context: When handing off to another Claude session, include all necessary details (what, where, what to skip)
Example: Correct Pattern
Slash command approach:
## 1. Setup
Create git worktree following the standard workflow:
[Include essential setup instructions]
## 2. Launch New Session
Provide user with complete context to continue:
- What PR/task they're working on
- Where the code is located
- Which skill to invoke
- What steps to skip (already completed)
Skill approach:
## 1. Setup (if needed)
[Same setup instructions as command]
## 2. Continue workflow
[Rest of the process]
Portability Considerations
DON'T hardcode machine-specific paths:
# Bad: Assumes all users organize code the same way
cd ~/src/<repo_name>
DO use adaptable instructions:
# Good: Adapts to any user's setup
First, check if the repository exists locally.
Ask the user where they keep repositories if not found.
This keeps plugins portable across different users and environments.
Validation Checklist
When creating or reviewing plugins with both commands and skills:
- Commands and skills describe the same workflow approach
- No hardcoded machine-specific paths
- Handoffs between sessions include complete context
- Instructions clearly state what steps to skip when already completed
- Examples use generic paths, not specific to one developer
Creating Your Plugin
Choose Your Pattern
Single-purpose plugin (one component type):
my-command-plugin/
├── .claude-plugin/
│ └── plugin.json
└── commands/
└── my-command.md
Skills-focused plugin (most common):
my-skills-plugin/
├── .claude-plugin/
│ └── plugin.json
└── skills/
├── skill-one/
│ └── SKILL.md
└── skill-two/
└── SKILL.md
Full-featured plugin:
enterprise-plugin/
├── .claude-plugin/
│ └── plugin.json
├── commands/
├── agents/
├── skills/
├── hooks/
│ └── hooks.json
└── .mcp.json
See reference/plugin-structure.md for more patterns and examples.
Writing plugin.json
Start minimal, add metadata as needed:
{
"name": "data-processor",
"version": "1.0.0",
"description": "Tools for processing and analyzing data files",
"author": {
"name": "Your Name"
},
"keywords": ["data", "analysis", "processing"],
"skills": ["./skills"]
}
Key points:
- Name must be unique and descriptive
- Version must follow semantic versioning
- Description helps with discoverability
- Only specify component paths you're using
Best Practices
For comprehensive best practices, see reference/best-practices.md. Key highlights:
Organization
- Keep related functionality together
- Use clear, descriptive naming
- One plugin = one cohesive purpose
- Don't create mega-plugins that do everything
Versioning
- Follow semantic versioning strictly
- MAJOR: Breaking changes
- MINOR: New features (backward compatible)
- PATCH: Bug fixes
Documentation
- Write clear descriptions for discoverability
- Document each component's purpose
- Include usage examples
- Specify any requirements or dependencies
Testing
- Test plugin installation:
/plugin install /path/to/plugin - Verify components load: Use
claude --debug - Test in clean environment before sharing
- Validate all paths are relative and correct
Path Management
- Always use relative paths starting with
./ - Verify paths are correct relative to plugin root
- Test that components are found after installation
Reviewing Plugins
When reviewing plugins (your own or others') before sharing or adding to marketplaces, use this systematic approach to ensure quality and adherence to best practices.
Review Process
Follow these five steps for thorough plugin review:
Step 1: Initial Inspection
- Check plugin.json exists at
.claude-plugin/plugin.json - Validate JSON syntax
- Verify required fields (name, version)
- Review overall directory structure
Step 2: Component Verification
- Test each component path references valid location
- Check component files exist and are properly formatted
- Verify component-specific requirements (SKILL.md, frontmatter, etc.)
Step 3: Local Testing
- Install plugin locally:
/plugin install /path/to/plugin - Verify installation:
/pluginshows plugin - Check for errors:
claude --debug - Test each component works as documented
- Uninstall and reinstall to verify clean installation
Step 4: Quality Assessment
- Evaluate documentation completeness
- Check if plugin has single, clear purpose
- Assess naming quality and discoverability
- Review for best practices adherence
Step 5: Final Validation
- Confirm no security issues
- Verify version is appropriate
- Check all documentation is accurate
- Ensure plugin is ready for intended audience
Review Checklist
For a comprehensive checklist covering all aspects of plugin review, see reference/review-checklist.md. Key areas to review:
- Manifest Validation: plugin.json structure, required fields, JSON syntax
- Path Validation: Relative paths, correct references, no external dependencies
- Structure and Organization: Clear patterns, cohesive purpose
- Component Quality: Skills, commands, agents, hooks, MCP servers
- Documentation: README, installation, usage examples
- Naming Conventions: Descriptive, non-generic names
- Versioning: Semantic versioning, appropriate version number
- Security and Safety: No credentials, safe operations, no malicious code
The detailed checklist in reference/review-checklist.md provides specific items to verify for each category, common issues to flag (critical, important, minor), and decision criteria for determining if a plugin is ready to share.
Quick Review Tips
- Test in clean environment: Install plugin fresh to catch missing dependencies
- Read documentation first: Verify docs match actual functionality
- Check debug output:
claude --debugreveals loading issues - Try all components: Don't assume untested components work
- Think like a user: Is it easy to understand and use?
- Verify paths manually: Walk through directory structure to confirm paths
- Check version history: If updating, ensure version change is appropriate
Testing and Debugging
Local Testing
# Install locally
/plugin install /path/to/my-plugin
# Check installation
/plugin
# Verify components loaded
/help # Check for new commands
claude --debug # See plugin loading details
# Update plugin after making changes
/plugin # Select plugin to update (easiest)
# OR manually uninstall/reinstall:
/plugin uninstall my-plugin@local
/plugin install /path/to/my-plugin
Validation steps:
- Plugin appears in
/pluginlist - No errors in
claude --debugoutput - Commands appear in
/help(if plugin has commands) - Skills are discoverable in conversation
- All component paths resolve correctly
Common Issues
- Plugin not found: Check plugin.json exists at
.claude-plugin/plugin.json - Components not loaded: Verify paths in plugin.json are relative and correct
- Version conflicts: Ensure version follows semantic versioning format
- Invalid JSON: Validate plugin.json syntax
Use claude --debug to see detailed plugin loading information.
Sharing Your Plugin
Via Marketplace
- Create or add to a marketplace (see marketplace-builder skill)
- Add plugin entry to marketplace.json
- Share marketplace URL or path
- Users add marketplace:
/plugin marketplace add <url> - Users install:
/plugin install my-plugin@marketplace-name
Direct Installation
Users can install directly without a marketplace:
/plugin install /path/to/plugin
# or
/plugin install https://github.com/user/repo
Key Principles
1. Single Responsibility
Each plugin should have one clear purpose. Don't create catch-all plugins.
2. Clear Naming
Use descriptive kebab-case names that indicate purpose:
- Good:
git-workflow,data-analyzer,react-toolkit - Avoid:
helpers,utils,misc
3. Minimal Manifest
Only include what you need. Start with name and version, add components as needed.
4. Relative Paths
All paths must be relative to plugin root and start with ./
5. Semantic Versioning
Version strictly: breaking changes = MAJOR, features = MINOR, fixes = PATCH
Progressive Development
Start Simple
- Create minimal plugin.json
- Add one component type
- Test locally
- Iterate and refine
Add Complexity Gradually
- Start with core functionality
- Test thoroughly
- Add additional components
- Document as you go
- Share when stable
Iterate Based on Usage
- Release early version
- Gather feedback
- Add features based on real needs
- Maintain backward compatibility when possible
References
reference/plugin-structure.md: Complete structure details and patternsreference/best-practices.md: Comprehensive development guidetemplates/plugin.json: Starting template for plugin manifesttemplates/README.md: Starting template for plugin documentation
Quick Decision Guide
Creating a plugin? Ask:
- What's the core purpose? One clear goal per plugin
- What components do I need? Start minimal, add as needed
- Is the name descriptive? Clear, kebab-case, indicates purpose
- Are paths relative? All paths start with
./from plugin root - Is it versioned correctly? Semantic versioning (x.y.z)
- Have I tested locally? Install and verify before sharing
Remember: Plugins package related functionality for easy sharing. Start simple, test thoroughly, and iterate based on real usage.