|
| 1 | +--- |
| 2 | +title: Manage AI-tool plugins |
| 3 | +sidebar_label: AI-tool plugins |
| 4 | +description: |
| 5 | + How to install, distribute, and manage plugins for AI coding tools such as |
| 6 | + Claude Code and Codex with the ToolHive CLI. |
| 7 | +--- |
| 8 | + |
| 9 | +An **AI-tool plugin** is a bundle of commands, agents, skills, hooks, and MCP or |
| 10 | +LSP server declarations that extends an AI coding tool. ToolHive builds these |
| 11 | +plugins into portable OCI artifacts, publishes them to any OCI registry, and |
| 12 | +installs them into the target client's plugins directory. |
| 13 | + |
| 14 | +Plugins are for the AI tool itself, not for ToolHive. A plugin ships everything |
| 15 | +that lives inside the AI tool's own extension surface (commands, agents, skills, |
| 16 | +and so on); ToolHive is the delivery mechanism. |
| 17 | + |
| 18 | +:::note[Supported clients] |
| 19 | + |
| 20 | +The `thv ai-plugin` commands install into two clients today: |
| 21 | + |
| 22 | +- **Claude Code**: `~/.claude/plugins/<name>` for user scope, |
| 23 | + `<PROJECT_ROOT>/.claude/plugins/<name>` for project scope |
| 24 | +- **Codex**: `~/.agents/plugins/toolhive/<name>` for user scope, |
| 25 | + `<PROJECT_ROOT>/.agents/plugins/toolhive/<name>` for project scope |
| 26 | + |
| 27 | +Other supported clients may install skills, MCP servers, or both; only these two |
| 28 | +currently accept plugins. See the |
| 29 | +[client compatibility reference](../reference/client-compatibility.mdx). |
| 30 | + |
| 31 | +::: |
| 32 | + |
| 33 | +## Prerequisites |
| 34 | + |
| 35 | +- The [ToolHive API server](./api-server.mdx) must be running. Start it in a |
| 36 | + separate terminal window (the command blocks while running): |
| 37 | + |
| 38 | + ```bash |
| 39 | + thv serve |
| 40 | + ``` |
| 41 | + |
| 42 | + The server must remain running while you use `thv ai-plugin` commands. |
| 43 | + |
| 44 | + :::tip[Using the ToolHive desktop app?] |
| 45 | + |
| 46 | + If the ToolHive desktop app is already running, the API server is available |
| 47 | + automatically. You can skip the `thv serve` step and use `thv ai-plugin` |
| 48 | + commands directly. |
| 49 | + |
| 50 | + ::: |
| 51 | + |
| 52 | +- Claude Code or Codex installed on your machine. |
| 53 | + |
| 54 | +## Install a plugin |
| 55 | + |
| 56 | +You can install plugins by plain name (resolved through the configured |
| 57 | +registry), by OCI reference, by Git URL, or from a local build: |
| 58 | + |
| 59 | +```bash |
| 60 | +thv ai-plugin install my-plugin |
| 61 | +thv ai-plugin install ghcr.io/my-org/plugins/my-plugin:v1.0.0 |
| 62 | +thv ai-plugin install git://github.com/my-org/plugins@main#packages/my-plugin |
| 63 | +``` |
| 64 | + |
| 65 | +If the plain name matches an artifact you built locally with |
| 66 | +`thv ai-plugin build`, ToolHive resolves it from the local OCI store; otherwise |
| 67 | +it looks up the name in the configured Registry Server. |
| 68 | + |
| 69 | +### Target a specific client |
| 70 | + |
| 71 | +If both Claude Code and Codex are installed, ToolHive installs the plugin for |
| 72 | +the first supported client it detects. To pick explicitly, use the `--clients` |
| 73 | +flag: |
| 74 | + |
| 75 | +```bash |
| 76 | +thv ai-plugin install my-plugin --clients claude-code |
| 77 | +thv ai-plugin install my-plugin --clients claude-code,codex |
| 78 | +thv ai-plugin install my-plugin --clients all |
| 79 | +``` |
| 80 | + |
| 81 | +Valid values are `claude-code`, `codex`, or `all`. |
| 82 | + |
| 83 | +### Choose a scope |
| 84 | + |
| 85 | +Plugins support two installation scopes, matching skills: |
| 86 | + |
| 87 | +- **User scope** (default) - installs the plugin into your home directory, so it |
| 88 | + is available across all projects. |
| 89 | +- **Project scope** - installs the plugin into the project directory. The |
| 90 | + project root must be a Git repository. |
| 91 | + |
| 92 | +```bash |
| 93 | +# User scope (default) |
| 94 | +thv ai-plugin install my-plugin |
| 95 | + |
| 96 | +# Project scope |
| 97 | +thv ai-plugin install my-plugin --scope project \ |
| 98 | + --project-root /path/to/project |
| 99 | +``` |
| 100 | + |
| 101 | +### Overwrite or group |
| 102 | + |
| 103 | +Pass `--force` to replace an existing installation of the same plugin, or |
| 104 | +`--group` to add the plugin to a named group for later batch operations: |
| 105 | + |
| 106 | +```bash |
| 107 | +thv ai-plugin install my-plugin --force |
| 108 | +thv ai-plugin install my-plugin --group development |
| 109 | +``` |
| 110 | + |
| 111 | +## List installed plugins |
| 112 | + |
| 113 | +```bash |
| 114 | +thv ai-plugin list |
| 115 | +``` |
| 116 | + |
| 117 | +Filter by client, scope, or group: |
| 118 | + |
| 119 | +```bash |
| 120 | +thv ai-plugin list --client claude-code |
| 121 | +thv ai-plugin list --scope project --project-root /path/to/project |
| 122 | +thv ai-plugin list --group development |
| 123 | +``` |
| 124 | + |
| 125 | +For JSON output: |
| 126 | + |
| 127 | +```bash |
| 128 | +thv ai-plugin list --format json |
| 129 | +``` |
| 130 | + |
| 131 | +## Inspect a plugin |
| 132 | + |
| 133 | +To see metadata, version, source, and declared contents for an installed plugin: |
| 134 | + |
| 135 | +```bash |
| 136 | +thv ai-plugin info my-plugin |
| 137 | +``` |
| 138 | + |
| 139 | +For project-scoped plugins, pass `--scope project --project-root`. |
| 140 | + |
| 141 | +## Uninstall a plugin |
| 142 | + |
| 143 | +```bash |
| 144 | +thv ai-plugin uninstall my-plugin |
| 145 | +``` |
| 146 | + |
| 147 | +For a project-scoped install: |
| 148 | + |
| 149 | +```bash |
| 150 | +thv ai-plugin uninstall my-plugin --scope project \ |
| 151 | + --project-root /path/to/project |
| 152 | +``` |
| 153 | + |
| 154 | +## Author a plugin |
| 155 | + |
| 156 | +A plugin is a directory with a manifest at `.claude-plugin/plugin.json`. At a |
| 157 | +minimum, the manifest needs a `name`; a `version` is recommended and becomes the |
| 158 | +default OCI tag at build time. |
| 159 | + |
| 160 | +```json title="my-plugin/.claude-plugin/plugin.json" |
| 161 | +{ |
| 162 | + "name": "my-plugin", |
| 163 | + "version": "1.0.0", |
| 164 | + "description": "What this plugin does and when to use it.", |
| 165 | + "author": { |
| 166 | + "name": "Your Team", |
| 167 | + "email": "team@example.com" |
| 168 | + }, |
| 169 | + "license": "Apache-2.0", |
| 170 | + "keywords": ["review", "python"], |
| 171 | + "commands": ["./commands/review.md"], |
| 172 | + "agents": ["./agents/reviewer.md"], |
| 173 | + "skills": ["./skills/code-review"], |
| 174 | + "hooks": ["./hooks/post-tool-use.js"] |
| 175 | +} |
| 176 | +``` |
| 177 | + |
| 178 | +Content-path fields (`commands`, `agents`, `skills`, `hooks`) must be relative |
| 179 | +paths beginning with `./`. Path traversal (`..`) is rejected, each group is |
| 180 | +capped at 100 entries, and the manifest itself is capped at 64 KB. The |
| 181 | +`keywords` field must be a JSON array of strings. |
| 182 | + |
| 183 | +MCP and LSP server declarations (`mcpServers`, `lspServers`) are recorded in the |
| 184 | +manifest for the AI tool to consume; ToolHive does not lifecycle-manage them |
| 185 | +from the plugin. `thv ai-plugin info` reports declared servers as "Declared (not |
| 186 | +managed by ToolHive)". |
| 187 | + |
| 188 | +### Naming conventions |
| 189 | + |
| 190 | +Use kebab-case for the plugin name - lowercase letters, numbers, and hyphens. |
| 191 | +The name must match the directory the plugin ships in and appears in the default |
| 192 | +OCI tag. |
| 193 | + |
| 194 | +### Validate |
| 195 | + |
| 196 | +Before building, check the manifest and directory structure: |
| 197 | + |
| 198 | +```bash |
| 199 | +thv ai-plugin validate ./my-plugin |
| 200 | +``` |
| 201 | + |
| 202 | +For JSON output: |
| 203 | + |
| 204 | +```bash |
| 205 | +thv ai-plugin validate ./my-plugin --format json |
| 206 | +``` |
| 207 | + |
| 208 | +### Build an OCI artifact |
| 209 | + |
| 210 | +Package the plugin into an OCI artifact stored in the local OCI store: |
| 211 | + |
| 212 | +```bash |
| 213 | +thv ai-plugin build ./my-plugin |
| 214 | +``` |
| 215 | + |
| 216 | +The command prints the OCI reference of the built artifact to stdout. Pass |
| 217 | +`--tag` to override the tag (default: `<name>:<version>` from the manifest, or |
| 218 | +the raw digest if `version` is omitted): |
| 219 | + |
| 220 | +```bash |
| 221 | +thv ai-plugin build ./my-plugin --tag ghcr.io/my-org/plugins/my-plugin:v1.0.0 |
| 222 | +``` |
| 223 | + |
| 224 | +### Push to a registry |
| 225 | + |
| 226 | +After building, push to a remote OCI registry: |
| 227 | + |
| 228 | +```bash |
| 229 | +thv ai-plugin push ghcr.io/my-org/plugins/my-plugin:v1.0.0 |
| 230 | +``` |
| 231 | + |
| 232 | +Push uses your existing container registry credentials (for example, from |
| 233 | +`docker login` or `podman login`). Authenticate before pushing. |
| 234 | + |
| 235 | +## Manage local builds |
| 236 | + |
| 237 | +The `builds` subcommand exposes the local OCI store where `thv ai-plugin build` |
| 238 | +writes artifacts. |
| 239 | + |
| 240 | +### List locally-built artifacts |
| 241 | + |
| 242 | +```bash |
| 243 | +thv ai-plugin builds |
| 244 | +``` |
| 245 | + |
| 246 | +Output shows the tag, digest, name, and version for each artifact. Add |
| 247 | +`--format json` for machine-readable output. |
| 248 | + |
| 249 | +### Remove a locally-built artifact |
| 250 | + |
| 251 | +```bash |
| 252 | +thv ai-plugin builds remove ghcr.io/my-org/plugins/my-plugin:v1.0.0 |
| 253 | +``` |
| 254 | + |
| 255 | +Blobs are retained on disk until every tag pointing to their digest is removed. |
| 256 | + |
| 257 | +## Next steps |
| 258 | + |
| 259 | +- [Configure your AI client](./client-configuration.mdx) to register clients |
| 260 | + with ToolHive so plugins install to the right location automatically |
| 261 | +- [Manage agent skills](./skills-management.mdx) - the sibling workflow for |
| 262 | + distributing skill bundles across a wider set of clients |
| 263 | + |
| 264 | +## Related information |
| 265 | + |
| 266 | +- [`thv ai-plugin` command reference](../reference/cli/thv_ai-plugin.md) |
| 267 | +- [Client compatibility](../reference/client-compatibility.mdx) |
| 268 | +- [ToolHive API reference](../reference/api.mdx) - the `/api/v1beta/plugins` |
| 269 | + routes expose the same operations for scripting and integration |
| 270 | + |
| 271 | +## Troubleshooting |
| 272 | + |
| 273 | +<details> |
| 274 | +<summary>`thv ai-plugin install` reports "plugin not found in local store or registry"</summary> |
| 275 | + |
| 276 | +ToolHive looks up plain names first in the local OCI store (populated by |
| 277 | +`thv ai-plugin build`) and then in the configured Registry Server. If both miss, |
| 278 | +install the plugin directly by OCI reference: |
| 279 | + |
| 280 | +```bash |
| 281 | +thv ai-plugin install ghcr.io/<namespace>/<name>:<version> |
| 282 | +``` |
| 283 | + |
| 284 | +Confirm the Registry Server is configured (see |
| 285 | +[Registry configuration](./registry.mdx)) and that the plugin has been published |
| 286 | +to it. |
| 287 | + |
| 288 | +</details> |
| 289 | + |
| 290 | +<details> |
| 291 | +<summary>Installed plugin isn't visible to the AI tool</summary> |
| 292 | + |
| 293 | +1. Verify the install landed: |
| 294 | + |
| 295 | + ```bash |
| 296 | + thv ai-plugin list |
| 297 | + thv ai-plugin info <PLUGIN_NAME> |
| 298 | + ``` |
| 299 | + |
| 300 | +2. Confirm the plugin files exist in the expected directory: |
| 301 | + - **Claude Code**: `~/.claude/plugins/<PLUGIN_NAME>/` (user) or |
| 302 | + `<PROJECT_ROOT>/.claude/plugins/<PLUGIN_NAME>/` (project) |
| 303 | + - **Codex**: `~/.agents/plugins/toolhive/<PLUGIN_NAME>/` (user) or |
| 304 | + `<PROJECT_ROOT>/.agents/plugins/toolhive/<PLUGIN_NAME>/` (project) |
| 305 | + |
| 306 | +3. Restart the AI tool to trigger plugin discovery. |
| 307 | + |
| 308 | +</details> |
| 309 | + |
| 310 | +<details> |
| 311 | +<summary>Manifest validation fails</summary> |
| 312 | + |
| 313 | +Run `thv ai-plugin validate ./my-plugin` to see the specific error. Common |
| 314 | +issues: |
| 315 | + |
| 316 | +- Missing `.claude-plugin/plugin.json` or missing `name` field |
| 317 | +- `keywords` is a string instead of a JSON array |
| 318 | +- A content-path entry (in `commands`, `agents`, `skills`, or `hooks`) does not |
| 319 | + start with `./` or contains `..` |
| 320 | +- More than 100 entries in one content-path group |
| 321 | +- The manifest file exceeds 64 KB |
| 322 | + |
| 323 | +</details> |
| 324 | + |
| 325 | +<details> |
| 326 | +<summary>Push to registry fails with authentication error</summary> |
| 327 | + |
| 328 | +`thv ai-plugin push` uses your existing container registry credentials. Log in |
| 329 | +first: |
| 330 | + |
| 331 | +```bash |
| 332 | +# For GitHub Container Registry |
| 333 | +echo $GITHUB_TOKEN | docker login ghcr.io -u USERNAME --password-stdin |
| 334 | + |
| 335 | +# For Docker Hub |
| 336 | +docker login |
| 337 | +``` |
| 338 | + |
| 339 | +Then retry the push. |
| 340 | + |
| 341 | +</details> |
0 commit comments