Claude Code's extensibility is built on two complementary systems: Plugins (collections of commands, agents, and hooks) and Skills (single-purpose workflows defined in markdown). Both use a declarative, frontmatter-driven approach.
- Marketplace plugins: Resolved by name (e.g., plugin@official), downloaded from official registry
- Session plugins: Loaded from --plugin-dir CLI flag or SDK plugins option
- Built-in plugins: Hardcoded in the binary
my-plugin/
├── plugin.json # Metadata, version, dependencies
├── commands/ # Slash command .md files
│ └── my-command.md # Frontmatter + prompt body
├── agents/ # Agent definition .md files
│ └── my-agent.md # Frontmatter + agent prompt
└── hooks/
└── hooks.json # Hook definitions (pre-tool, post-tool)
- Discovery: Scan all plugin sources, resolve symlinks
- Deduplication: File identity checks prevent duplicate loading
- Manifest validation: plugin.json parsed and verified
- Component registration: Commands, agents, hooks merged into runtime
- Caching: Marketplace plugins cached locally with version checking
- Blocklist/allowlist enforcement by organization policy
- Version pinning support
- Install count tracking via public stats endpoint
A skill is a reusable workflow defined as a markdown file with YAML frontmatter:
---
name: my-skill
description: One-line description
whenToUse: When the user asks to...
---
Prompt content that defines the skill's behavior...- User config (~/.claude/skills/)
- Project settings (.claude/skills/)
- Plugin directories
- Bundled skills (shipped with Claude Code)
- Managed/policy skills (organization-level)
- Prompt skills: Fork a sub-agent with the skill's prompt (primary type)
- Shell scripts: Spawned in subprocess (deprecated, replaced by prompt skills)
- User invokes /skill-name or LLM calls SkillTool
- Skill resolved by name from registry
- Arguments substituted into prompt template
- Sub-agent forked with parent context + skill prompt
- Agent executes, results returned to parent
MCP server prompts automatically wrapped as skills. Registered in app state, available to both model and SkillTool. This means any MCP server that exposes prompts gets skill integration for free.
Hooks are shell commands triggered by tool lifecycle events:
- PreToolUse: Runs before a tool executes (can block execution)
- PostToolUse: Runs after a tool completes
- Configured in settings.json or plugin hooks.json
- Variable substitution for dynamic values (tool name, input, etc.)
- Plugin Architecture: Isolated component loading with manifest-driven discovery
- Composite: Skills compose messages + agent execution into reusable workflows
- Strategy: Different skill types (prompt vs. shell vs. MCP) use different execution strategies
- Template Method: Frontmatter defines structure, content defines behavior