Files
2026-07-13 12:52:40 +08:00

174 lines
5.2 KiB
Plaintext

---
title: "Installing Plugins"
sidebarTitle: "Installing Plugins"
description: "Install plugins from file URLs, npm, git, or local sources using the CLI or programmatically."
---
The Cline CLI provides a `plugin install` command to install plugins from various sources. You can also load plugins programmatically via session config.
## CLI Installation
Use the `cline plugin install` command to install plugins from file URLs, npm, git repositories, or local paths.
```sh
cline plugin install <source> [options]
```
The shorthand `cline plugin i` works as well.
### Install from a File URL
```sh
cline plugin install https://github.com/cline/cline/blob/main/sdk/examples/plugins/weather-metrics.ts
cline plugin install https://raw.githubusercontent.com/cline/cline/main/sdk/examples/plugins/weather-metrics.ts
```
Installs a single `.ts` or `.js` plugin file from an HTTPS URL. GitHub `blob` URLs are normalized to raw file downloads automatically.
### Install from npm
```sh
cline plugin install --npm @scope/plugin-name
```
Installs the package from the npm registry into the Cline plugin directory.
### Install from Git
```sh
cline plugin install --git https://github.com/owner/repo.git
cline plugin install --git github.com/owner/repo
```
Clones the repository (shallow, with blobless filter for speed) and installs its dependencies. The `.git` directory is excluded from the final install.
### Install from Local Source
```sh
cline plugin install ./path/to/plugin.ts # Single file
cline plugin install /absolute/path/to/dir # Directory with package.json
```
Supports both files and directories. Local installs copy the source, filter out `.git` and `node_modules`, and run `npm install` to resolve dependencies.
### Options
| Option | Description |
|--------|-------------|
| `--npm` | Treat the source as an npm package name |
| `--git` | Treat the source as a git repository URL |
| `--force` | Overwrite an existing plugin at the same path |
| `--json` | Output results as JSON (useful for scripting) |
| `--cwd` | Install to `<path>/.cline/plugins` and resolve relative local paths from `<path>` |
### Examples
```sh
# Install a local plugin directory
cline plugin install ./my-custom-plugin
# Install a single plugin file from GitHub
cline plugin install https://github.com/cline/cline/blob/main/sdk/examples/plugins/weather-metrics.ts
# Install an npm package as a plugin
cline plugin install --npm @cline/plugin-sql
# Install from a GitHub repo
cline plugin install --git https://github.com/my-org/my-plugin.git
# Force reinstall an existing plugin
cline plugin install --force --npm @scope/plugin-name
# Use shorthand
cline plugin i --git github.com/owner/repo
```
### Listing Installed Plugins
Installed plugins appear in the `plugins` section of your CLI config:
```sh
cline config
```
### Find All Your Plugins from your file system
Project-scoped plugins live in the `.cline/plugins/` folder at your workspace root. The CLI auto-discovers plugins from this folder when you run Cline in that project.
```text
your-project/
├── .cline/
│ └── plugins/
│ ├── my-plugin.ts
│ └── another-plugin/
└── ...
```
To add a single-file plugin to a project, install it with `--cwd`:
```sh
cline plugin install https://github.com/owner/repo/blob/main/plugins/my-plugin.ts --cwd .
```
Global plugins are discovered from `~/.cline/plugins/`, and Cline may also discover plugins from the system Plugins folder. Use `--cwd .` when you want plugins to stay with a specific project.
## Programmatic Installation
### Using `pluginPaths` (ClineCore)
In SDK code, load plugins from file paths using the `pluginPaths` session config option:
```typescript
import { ClineCore } from "@cline/sdk"
const cline = await ClineCore.create({ clientName: "my-app" })
await cline.start({
config: {
systemPrompt: "Analyze this project",
// ...model/runtime config
pluginPaths: ["/absolute/path/to/plugin.ts"],
},
})
```
Plugin files must export an `AgentPlugin` as the default export. `pluginPaths` also accepts a package directory -- the SDK reads `package.json` and follows the `cline.plugins` entries, so you can `npm install` once inside a package and iterate without re-running `cline plugin install` on every edit.
### Using `plugins` (Agent Runtime)
When using the `Agent` or `AgentRuntime` directly, pass plugin instances in the `plugins` array:
```typescript
import { Agent } from "@cline/sdk"
import { myPlugin } from "./my-plugin"
const agent = new Agent({
providerId: "anthropic",
modelId: "claude-sonnet-4-6",
plugins: [myPlugin],
})
```
### Using `extensions` (ClineCore)
With `ClineCore`, use the `extensions` config array instead:
```typescript
import { ClineCore } from "@cline/sdk"
const cline = await ClineCore.create({ clientName: "my-app" })
await cline.start({
config: {
systemPrompt: "Analyze customer records",
extensions: [myPlugin],
},
})
```
## Next Steps
- **Learn about [Plugins](/sdk/plugins)** — Understand what plugins are and their benefits.
- **Follow the [Writing Plugins](/sdk/guides/writing-plugins) guide** — Build and distribute your own plugin.
- Explore [Plugin Examples](/sdk/plugin-examples) to install ready-to-run plugin examples from the SDK repository.