Benefits of Plugins
Extension Glossary
What is a Plugin?
A plugin is anAgentPlugin — an object that implements the SDK’s extension interface. It can register tools, hook into agent lifecycle events, and provide configuration defaults.
hooks object, not directly on the extension. The available lifecycle hooks are beforeRun, afterRun, beforeModel, afterModel, beforeTool, afterTool, and onEvent.
Next Steps
Register withClineCore:
File-Based Plugins
ClineCore supports plugin module paths via pluginPaths in session config:
AgentPlugin.
Installing Plugins via CLI
Plugins can also be installed from file URLs, npm, git, or local paths usingcline plugin install. See Plugins for install commands, the manifest format, and directory layout.
Hook Stages
Hook stages include:Hook Policies
Hook policies control execution behavior:
Use
fail_closed for policy-enforcement hooks where bypassing the hook is unsafe.
Build a Plugin
For a step-by-step plugin tutorial, see Writing Plugins.SDK Examples
The SDK repository includes ready-to-run plugin examples underexamples/plugins/, including tool registration, lifecycle metrics, notifications, custom compaction, policy guards, web search, background jobs, TypeScript LSP tools, and multi-agent teams.
See Plugin Examples for the full list and usage commands.
