agentleFS
afaraha8403afaraha8403/mental/.claude/skills/opencode-plugins/SKILL.md

opencode-plugins

Skill5 starsChanged yesterdayMITView on GitHub

Build OpenCode plugins and terminal UI extensions without MCP: v1 hook plugins (@opencode-ai/plugin, config key plugin), v2 Plugin.define server plugins (@opencode/plugin, config key plugins), v2 TUI/CLI plugins (@opencode/plugin/tui, dialogs, keymap, routes, toasts), discovery paths, the V1 to V2 migration, and npm distribution. Use when the user wants an OpenCode plugin, mod, TUI customization, or asks whether OpenCode has a UI extension mechanism.

  • Reads credentials

We split this skill into the rules it gives an agent

6 rules. About 0 are common, 0 are distinctive, and 6 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 6

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Default export from Plugin.define.

    line 47
  2. Very specific:

    No Bun $ shell helper; v2 removed it.

    line 50
  3. Very specific:

    Write .opencode/plugins/<name>/index.ts (or tui.ts).

    line 61
  4. Very specific:

    Do not bind ctrl+n or ctrl+p in dialogs.

    line 69
  5. Very specific:

    Keep keymap.layer factories pure.

    line 70
  6. Very specific:

    Do not npm publish or open an upstream PR without the user's explicit go-ahead this turn.

    line 71

≈ “Common” is an estimate: at least 1 in 5 of the 308,232 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

OpenCode plugins and TUI extensions

Not a desktop mod target. OpenCode's docs say plugins change behavior, and "to change the terminal UI, build a CLI plugin" (opencode.ai/v2/docs/build/plugins). No documented plugin API changes the UI of the OpenCode desktop app or web UI. Do not treat this skill as the OpenCode equivalent of Claude Desktop mods; it covers server plugins (hooks, tools) and TUI plugins only. Both need no MCP. Re-check the docs for a desktop UI extension API before stating otherwise.

First: which generation?

v1v2
Docsopencode.ai/docs/plugins/opencode.ai/v2/docs/build/plugins
Package@opencode-ai/plugin@opencode/plugin (TUI: @opencode/plugin/tui)
Shapeexport const X: Plugin = async (ctx) => hooksexport default Plugin.define({ id, async setup(ctx) { return cleanup } })
Config keypluginplugins

V1 implementations do not run in V2. Ask or check the user's version, then follow one generation only. Details: references/v1-hooks.md, references/v2-server.md, references/v2-tui.md, references/migrate-and-publish.md.

Requirements (v2)

  1. A stable id on every plugin. Storage is scoped by it.
  2. Default export from Plugin.define.
  3. Return a cleanup function from setup instead of a dispose hook.
  4. Published plugins depend on a compatible @opencode/plugin range.
  5. No Bun $ shell helper; v2 removed it.

Where plugins load

  • Local server plugins: .opencode/plugins/<name>/index.ts (v2 also reads .opencode/plugin/); v1 also reads ~/.config/opencode/plugins/.
  • TUI plugins: <global-config>/plugins/<name>/{index.ts,tui.ts} and <project>/.opencode/plugins/<name>/.
  • Config: opencode.json(c) for server plugins, cli.json for TUI plugins. Entries are a package name (optionally @version), a path, a file:// URL, or { package, options }. A -id or -wildcard prefix disables a TUI plugin. The docs do not give the global cli.json path; do not assert one.

Workflow

  1. Pick the generation and the surface (server or TUI).
  2. Write .opencode/plugins/<name>/index.ts (or tui.ts).
  3. Restart OpenCode and exercise the feature.
  4. For distribution, publish an npm package and list it in the user's config by name.

Safety

  • Plugins run with the user's privileges. Never read or log environment secrets; do not forward prompts, tool inputs or files to remote servers without disclosure.
  • shell.env and permission hooks can change what the agent may do. Keep them narrow and explainable.
  • Do not bind ctrl+n or ctrl+p in dialogs; they are reserved for navigation.
  • Keep keymap.layer factories pure.
  • Do not npm publish or open an upstream PR without the user's explicit go-ahead this turn.

Checklist

  • Generation confirmed; config key matches (plugin vs plugins).
  • Stable id; cleanup returned; every subscription unsubscribed.
  • Dependency range on @opencode/plugin (v2) or @opencode-ai/plugin (v1).
  • Tested in a project-local .opencode/plugins/ before publishing.

Anti-patterns

  • Copying a V1 example into a V2 project.
  • Building an MCP server to add a keybinding or dialog.
  • Importing the plugin SDK by absolute path (TUI imports resolve at runtime).
  • Leaving listeners registered without returning cleanup.

Pointers

NeedWhere
V1 hooks, events, custom toolsreferences/v1-hooks.md
V2 server ctx APIreferences/v2-server.md
V2 TUI context, dialogs, keymap, routesreferences/v2-tui.md
Migration table and publishingreferences/migrate-and-publish.md

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

Reviews can't be read right now.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.