Plugin lifecycle
Lifecycle flow
Section titled “Lifecycle flow”Installation:
- User runs
claude plugin install <name> - Claude Code fetches the plugin from the marketplace or seed directory
- Manifest is validated — if invalid, installation fails with an error
- Plugin downloaded to
~/.claude/plugins/cache/ - Plugin ID added to
enabledPluginsinsettings.json
Activation (on session start or /reload-plugins):
- Manifest is parsed and re-validated
- Components registered: commands, skills, agents, hooks
- MCP servers started as subprocesses
- LSP servers started (if configured)
- Background monitors launched
- Plugin is now active
Uninstall:
claude plugin uninstall <name>removes the plugin fromenabledPlugins- Subprocesses stop on the next session start
Discovery
Section titled “Discovery”Plugins are discovered from:
- Configured marketplaces: Loaded from Git repositories, the official Anthropic marketplace (if enabled), or custom sources added via
extraKnownMarketplacessetting. - Seed directories: The
CLAUDE_CODE_PLUGIN_SEED_DIRenvironment variable can point to a local directory for pre-seeding plugins at startup. - CLI: The
claude plugin installcommand searches configured marketplaces. - In-session UI: The
/plugincommand opens the marketplace browser.
Installation
Section titled “Installation”- User runs
claude plugin install <name>[@marketplace](CLI) or/plugin→ “Discover” (UI). - Claude Code fetches the plugin from the specified marketplace (or searches all configured marketplaces).
- Plugin is downloaded to the local plugin cache:
~/.claude/plugins/cache/<plugin-id>/<version>/. - Plugin is added to the user’s
enabledPluginsin the target scope’ssettings.json(user, project, or local).
Validation
Section titled “Validation”validatePlugin.tschecks manifest syntax (JSON, required fields, semantic version format).- Schema validation via Zod: paths are relative and start with
./, component directories exist, manifest fields match expected types. - Component files (skills, agents, commands) are checked for frontmatter syntax.
- Path traversal checks prevent plugins from referencing files outside their directory.
Loading
Section titled “Loading”When a session starts or /reload-plugins is invoked:
- Manifest loading: The manifest is parsed and validated.
- Component registration: Commands, skills, agents, hooks, MCP servers, and LSP servers are registered with the runtime. Plugin skills use namespaced names (
/plugin-name:skill-name). - Hook registration: Hooks are merged across all sources (user, project, plugin, managed) and attached to their event handlers.
- MCP server startup: Enabled MCP servers are spawned as subprocesses.
- LSP server startup: Enabled LSP servers are started (users must have binaries installed).
- Monitor startup: Background monitors are launched as long-running processes.
Enable/disable
Section titled “Enable/disable”- Enabled plugins load at session start. Settings key:
enabledPlugins[<plugin-id>] = true/false. - Toggling is done via
/pluginUI orclaude plugin enable/disableCLI commands. - Per-scope (user, project, local, managed): each scope has its own
settings.jsonor managed config. - Managed-only plugins (from managed settings) cannot be disabled by users.
Reload
Section titled “Reload”/reload-pluginscommand reloads all plugins without restarting the session.- Re-parses manifests, re-registers components, restarts MCP/LSP servers.
- Useful for development or applying updates during an active session.
Auto-update
Section titled “Auto-update”- Controlled by
FORCE_AUTOUPDATE_PLUGINSenvironment variable (global) or per-pluginautoUpdatefield. - Claude Code periodically checks for new versions and updates automatically if enabled.
- Users can manually update via
claude plugin update <name>or/plugin→ “Update”.
Uninstall
Section titled “Uninstall”claude plugin uninstall <name>removes the plugin from the scope’ssettings.json.- By default, the plugin’s data directory (
${CLAUDE_PLUGIN_DATA}) is deleted when uninstalling from the last scope. --keep-dataflag preserves the data directory for reinstallation later.