agentleFS
rjstonerjstone/agent-skills/skills/opencode-build/SKILL.md

opencode-build

Skill0 starsChanged 6 days agoMITView on GitHub

Use when writing, changing or reviewing an opencode plugin (server, TUI, GUI or RPC part, Plugin.define, hooks, custom tools, package.json exports, loading from opencode.json), using @opencode/plugin, @opencode/sdk or @opencode/client, porting a v1 plugin (@opencode-ai/plugin), or unsure whether an opencode API is v1 or v2.

The file

We split this skill into the rules it gives an agent

3 rules. About 0 are common, 1 is distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    When they disagree, the higher source wins.

    line 34
  2. Very specific:

    Check that a plugin loads, without a model or your real config: python scripts/plugin_probe.py <plugin-dir> (needs the v2 CLI.

    line 56
  3. Very specific:

    No cached page for it? The live Markdown of any docs page is its URL with the trailing / replaced by .md.

    line 66

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 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 Build docs (v2)

Overview

opencode v2 replaced the v1 plugin API, and what you remember is probably v1 (v1 -> v2): @opencode-ai/plugin -> @opencode/plugin; exported async function returning hooks -> Plugin.define({ id, setup(ctx) }); tool() -> ctx.tool.transform; config "plugin" -> "plugins"; .opencode/plugin/ -> .opencode/plugins/. Do not write opencode plugin code from memory. Look it up first, in this order:

  1. Installed types (the authority for the version the project uses): dist/promise/<area>.d.ts (tool.d.ts, plugin.d.ts, command.d.ts, ...) in node_modules/@opencode/plugin/, or in bun's cache ~/.bun/install/cache/@opencode/plugin@<version>*/ (Windows: %USERPROFILE%\.bun\install\cache\...).
  2. ERRATA.md beside this file: known mistakes in the docs below.
  3. references/: the v2 Build docs cached as Markdown. A page X.md may have a X.local.md beside it: our additions to that page (Reference sections with the real type declarations, notes), written from the installed types. Read it with its page.

When they disagree, the higher source wins.

Which reference

TaskRead
Parts (server/TUI/GUI/RPC), package.json exports, loading, plugins config, publishreferences/plugins.md
How opencode finds parts and checks a plugin's default export; dependencies of a by-path plugin; lazy loading; checking a plugin loadedreferences/plugins.local.md
Server part: setup(ctx), tools, hooks, transforms, agents, commands, MCPreferences/plugins-server.md
Type of ctx (Plugin.Context) and of each ctx.<domain>, and how they derive from the clientreferences/plugins-server.local.md
TUI part: commands, keymaps, slash commands, toasts, dialogs, routes, slotsreferences/plugins-cli.md
GUI part (Desktop panels, settings, main process)references/plugins-gui.md
GUI limits: no agent switch, Desktop picker vs server switchAgent, hiding app controls, user-only outputreferences/plugins-gui.local.md
Typed methods/events between parts and clientsreferences/plugins-rpc.md
Porting v1 code, or supporting v1 and v2 from one packagereferences/plugins-migrate-v1.md
What a v1+v2 package did on real opencode 1.18.29 and 2.2.6; V1 config key, CLIs, sharing codereferences/plugins-migrate-v1.local.md
Effect API versionsreferences/plugins-effect.md, references/plugins-effect-rpc.md
Driving a running server from codereferences/client.md, references/client-effect.md
Type of the client object (OpenCodeClient): every group and methodreferences/client.local.md
Embedding opencode in your appreferences/sdk.md, references/sdk-effect.md, references/sdk-cloudflare.md
What the Build section coversreferences/intro.md

Check that a plugin loads, without a model or your real config: python scripts/plugin_probe.py <plugin-dir> (needs the v2 CLI; details in its docstring and references/plugins.local.md "Load").

plugins-server.md (~1800 lines) and plugins-gui.md (~3700 lines) are large: list their headings first (grep -n '^##' <file>), then read only the section you need.

Keeping it current

  • No cached page for it? The live Markdown of any docs page is its URL with the trailing / replaced by .md; the index is https://opencode.ai/docs/llms.txt.
  • Cite the page URL without .md (it is in references/manifest.json).
  • Found a doc mistake (the docs contradict the installed types or real behavior)? Add an entry to ERRATA.md with your evidence.
  • Refreshing the downloaded pages, or writing or updating a references/*.local.md (where it goes, its style, the scripts that print type declarations): read MAINTAINING.md first. Never edit the downloaded pages.

Common mistakes

MistakeFix
v1 imports or exported async functionimport { Plugin } from "@opencode/plugin"; export default Plugin.define({ id, setup(ctx) { ... } })
Guessing an exports keyplugins.md "Parts" lists them (., ./tui, ./gui-experimental, ./rpc)
editor.namespace() but no options.namespace on the tool (id stays un-prefixed; Code Mode shows tools.<name>())Pass options: { namespace } on every add; see ERRATA.md E01
Editing only event.result.content in execute.after (Code Mode returns output; MCP tools always set it)Edit output too; see ERRATA.md E03
Reading a whole 2000-line referenceSearch headings, read one section
Trusting a reference over the installed typesTypes win; record the conflict in ERRATA.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.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

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.