Plugins are the primary way to package reusable agent capabilities. This guide walks through building a production-quality plugin from scratch.Documentation Index
Fetch the complete documentation index at: https://docs.cline.bot/llms.txt
Use this file to discover all available pages before exploring further.
What You’ll Build
A GitHub integration plugin that:- Registers tools for interacting with GitHub (list issues, create PRs, post comments)
- Logs all tool calls for auditing
- Tracks token usage per session
Step 1: Define the Plugin Structure
Step 2: Create the Tools
Step 3: Use the Plugin
Distributing as a File Plugin
To load this plugin from a file in ClineCore, pass its path inpluginPaths:
Distributing via CLI Install
To make your plugin installable withcline plugin install, add a cline field to your package.json that declares entry points and list @cline/ imports as peer dependencies (the host runtime provides them):
Plugin Design Guidelines
-
Use factory functions (like
createGitHubPlugin) when the plugin needs configuration. Export the plugin object directly when it doesn’t. -
Keep
setup()synchronous and fast. It runs before the first LLM call, so any async initialization delays the agent. -
Register all tools in
setup(), not in lifecycle hooks. Tools must be available before the first iteration. -
Use lifecycle hooks for observation (logging, metrics, auditing), not for modifying agent behavior. If you need to modify behavior, consider using the
beforeRunorbeforeModelhooks to adjust the system prompt or context. -
Handle errors gracefully in hooks. A thrown error in
beforeToolwill count as a tool failure. If your hook is purely observational, catch errors internally.

