# Plugins

A plugin is a manifest naming skills, slash commands, agents, hooks, MCP servers and model provider directories, in the format Claude Code, Codex, OpenCode or Hermes already use. OpenProgram mounts the contents; no plugin code runs inside it. Code that adds tools or a screen is an [application](https://fzkuji.github.io/OpenProgram/docs/capabilities/applications.html).

## Commands

| Command | Effect |
| --- | --- |
| `openprogram plugins list` | Installed plugins |
| `openprogram plugins search <query>` | Search the configured marketplaces |
| `openprogram plugins install git <url> --ref v1.2` | Clone into `~/.openprogram/plugins/` |
| `openprogram plugins install npm <package>` | Into its `node_modules/` |
| `openprogram plugins install path /abs/path` | Link there, so edits apply on `reload` |
| `openprogram plugins update --all` | Reinstall npm plugins, or pass one name |
| `openprogram plugins enable <name>`, `disable <name>` | Toggle |
| `openprogram plugins reload <name>` | Re-read its manifest and files |
| `openprogram plugins uninstall <name>` | For a linked plugin, removes only the link |
| `openprogram plugins inspect` | What a plugin may contain, every hook event, what is refused, each entry's exposure tier; `--json` |

| Trust | In `~/.openprogram/plugin-trust.json` |
| --- | --- |
| `verified`, `community` | Can be enabled. A local `path` install is `community`. |
| `untrusted` | Default for unlisted plugins. Not enabled, because hooks and MCP servers run commands. |

The Web UI uses the same management API through the plugin routes.

## Contents

Manifests are tried in this order:

1. `.claude-plugin/plugin.json` (Claude Code), `.codex-plugin/plugin.json` (Codex), or `plugin.json` at the root
2. `[tool.openprogram.plugin]` in `pyproject.toml`
3. the `openprogram`, `opencode` or `hermes` field of `package.json`
4. `plugin.yaml` or `plugin.yml` (Hermes)

Fields: `name`, `version`, `description`, `trust`, `entrypoints`, `options`, `requires`. Contribution keys may sit at the top level, as Claude Code writes them. `requires` orders loading topologically and reports `missing dependencies: ...`.

| Key | Contents |
| --- | --- |
| `skills` | A directory of `SKILL.md` skills |
| `commands` | `{name: {description, prompt}}`, or a directory of `.md` files with front matter |
| `agents` | `{name, description, prompt, tools}` list, or a directory of `.md` agents. Created as `<plugin>-<name>`; kept on disable, because deleting an agent would delete its sessions. |
| `hooks` | Shell commands on events, inline or a `.json` path |
| `mcpServers` | `{name: {command, args, env} \| {url}}` inline, or a `.mcp.json` path. Running while enabled. |
| `providers` | A directory whose children each hold a `provider.json` |

Everything mounts through one context owned by `plugin:<name>`; `disable` and `reload` remove all of it.

### Hooks

OpenProgram's shape (same as `hooks` in `config.json`), then Claude Code's `hooks/hooks.json`:

```
{"tool.before": [{"command": "${CLAUDE_PLUGIN_ROOT}/check.sh", "timeout": 30}]}
```

```
{"hooks": {"PreToolUse": [{"matcher": "bash|write", "hooks": [
  {"type": "command", "command": "${CLAUDE_PLUGIN_ROOT}/check.sh"}]}]}}
```

| Claude Code | OpenProgram |
| --- | --- |
| `PreToolUse` | `tool.before` |
| `PostToolUse` | `tool.after` |
| `UserPromptSubmit` | `chat.before_send` |
| `Stop` | `turn.stop` |
| `SessionStart` | `session.start` |

- `matcher` is a regular expression over the tool name.
- `${CLAUDE_PLUGIN_ROOT}` becomes the plugin directory. Commands run in the worker's working directory and receive the event as JSON on stdin.
- On a gate event (`tool.before`, `turn.stop`), exit code 2 denies with stderr as the reason; any other code allows.

### Refused

`install` refuses a manifest that names code and removes the git clone or npm package; one placed by hand is listed with the error and never loads. The refusal names the keys and says to add an `application.json` and run `openprogram programs install <dir>`.

- `python`, `module`, `setup`, `main`, `tools`: Python or JavaScript code
- `client`, `web`, `sidebar`: a screen of its own
- `hooks` written as `module:name`: a Python handler mapping
- A Hermes `plugin.yaml` beside an `__init__.py`
- pip as a source

## Write one

```
house-style/
  .claude-plugin/plugin.json
  skills/review/SKILL.md
  commands/summarize.md
  hooks/hooks.json
```

```
{"name": "house-style", "version": "0.1.0", "skills": "./skills",
 "commands": "./commands", "hooks": "./hooks/hooks.json"}
```

```
openprogram plugins install path /abs/path/to/house-style   # links the directory
openprogram plugins enable house-style
openprogram plugins reload house-style                      # after editing its files
```

Agents have a `plugin` tool (approval required; not offered on chat channels or in plan mode). `guide` returns the authoring guide from the running build; `install` with the directory's absolute path links, trusts and enables in one step; `reload` applies edits. A plugin naming code is refused with the CLI's message.

[Applications](https://fzkuji.github.io/OpenProgram/docs/capabilities/applications.html)
