3.4.0-beta.1). Features may change before the next stable release.Switch to stable →Guides
Using AgentKit with OpenCode
Install AgentKit Kits for OpenCode 1.x and 2.x, run Skills through OpenCode, and work around the current limits.
AgentKit installs Kits natively into OpenCode. The
opencode adapter is at the Production stage and ships on the beta channel:
use AgentKit v3.3.0-beta.15 or later with --channel beta until a stable
release includes it.
| OpenCode version | Status |
|---|---|
| 1.x | Certified on 1.18.18 (macOS, Apple silicon) |
| 2.x | Live-tested on 2.4.1 (macOS, Apple silicon) |
Windows and Linux are Assumed: expected to work, not yet measured. See support tiers.
Install a Kit
From your project root:
ak kit init engineer --target opencode --channel betaReplace engineer with any Kit you own (for example marketing). Add
--global to install into your OpenCode config root instead of the project.
The install writes:
- Skills, Agents, and commands below
.opencode/(project) or$XDG_CONFIG_HOME/opencode(global, default~/.config/opencode). - One marker-bounded Kit section in
AGENTS.md. Your own lines stay untouched, and uninstall removes only that section. A symlinkedAGENTS.mdis never written through; the install warns instead.
Agents are installed as subagents without a model, so the model from your
OpenCode session or opencode.json applies.
Refresh or remove the Kit with:
ak kit refresh engineer --target opencode --channel betaak kit uninstall engineerUninstall keeps your own skills and a backup of .opencode for manual
recovery. Files OpenCode writes itself, such as .opencode/node_modules, are
left alone.
Run a Skill through OpenCode
ak run engineer/ak-bro "Explain this repo" --target opencodeak run starts opencode run with your configured provider. OpenCode must be
signed in to a working provider first.
Hooks on OpenCode 2.x
From AgentKit CLI v3.3.0-beta.20, an install for OpenCode 2.x bridges the
Kit's Hooks into an AgentKit-owned plugin, plugins/agentkit-<kit>/ below
.opencode/ (project) or the OpenCode config root (global). OpenCode 2.x loads
that directory automatically. The plugin holds the bridge entrypoint
index.js, the Kit's hooks.json, and its Hook scripts. Refresh rewrites it
and uninstall removes it, so do not edit it.
The bridge runs command Hooks for PreToolUse, PostToolUse, SessionStart,
UserPromptSubmit, SubagentStart, SubagentStop, Stop, PreCompact, and
SessionEnd. The install warns about each other Hook event the Kit uses,
because OpenCode 2.x has no equivalent plugin hook. A Hook fails open on a
spawn error, timeout, or malformed output. Only an explicit block, exit code
2 or a deny decision, stops the tool call, rejects the prompt, or re-prompts
the session.
AgentKit reads the major version from opencode --version and assumes 2.x when
it cannot run the binary. Set AGENTKIT_OPENCODE_MAJOR=1 or 2 to pin it, for
example when opencode is not on PATH at install time. On OpenCode 1.x the
Hooks stay an inactive sidecar and are not run.
MCP servers in opencode.json
From AgentKit CLI v3.3.0-beta.17, the install merges the Kit's MCP servers
into OpenCode's own config file. For a project install that is the first
existing opencode.json, opencode.jsonc, .opencode/opencode.json, or
.opencode/opencode.jsonc in the project root, the same order
opencode mcp add uses, or a new opencode.json. A global install edits the
file in the OpenCode config root. Servers go under mcp.<name>, or under
mcp.servers.<name> when the file already uses the OpenCode 2.x layout.
AgentKit owns each server by name, recorded in the Kit's
opencode-mcp-ownership.json, never the whole file. Comments and every other
key stay yours. A server with the same name that you or opencode mcp add
added, one another Kit owns, or one you edited after install is preserved with
a warning. A config file that is a link or does not parse is left unchanged,
with a warning that names the fix. Refresh retires servers the Kit no longer
exports. Uninstall removes only the Kit's servers that still hold the value
AgentKit wrote, and removes the file only when AgentKit created it and nothing
else is left in it.
Known limits
- Output styles and the status line are kept, not run. OpenCode has no output-style or status-line surface, so they stay inactive sidecars, as do Hooks on OpenCode 1.x.
- OpenCode 2.x has no stable skill listing.
opencode debug skillexists only on 1.x; on 2.x, ask the model to list its skills. - Duplicate skills. OpenCode also loads
.claude/skillsand.agents/skills, so a Claude Code or Codex Skill with the same name appears twice. The install warns and touches neither copy.
Provider keys and ak secrets run
OpenCode prefers the credentials it stored with opencode auth login over
environment variables. A key passed through ak secrets run can therefore be
ignored when an older or expired stored credential exists.
-
OpenCode 1.x: point the provider at the environment variable in your project
opencode.json:{ "provider": { "<provider-id>": { "options": { "apiKey": "{env:YOUR_KEY_VAR}" } } } }Then run through
ak secrets runas usual. -
OpenCode 2.x: re-run
opencode auth loginto replace the stored credential.
Tracked in
bestagentkits/agentkit#3686.
See Secrets vault for ak secrets run.