--- name: claude-code-plugin description: Configure and troubleshoot the opencode-claude-code-plugin, the opencode provider that runs Anthropic Claude models through the Claude Code CLI. Use when the user wants to install, set up, change or debug this plugin, meaning anything under provider.claude-code.options in opencode.json (accounts, proxyTools, cwd, permissions, MCP bridging, timeouts, logging), subagent model or effort, model ids and variants, /btw, the skill bridge, upgrades, or reading plugin.log. Not for opencode's own general configuration. --- # Configuring the Claude Code plugin This plugin is `@khalilgharbaoui/opencode-claude-code-plugin`. It registers one or more `claude-code*` providers and routes inference through the `claude` CLI, not opencode's native Anthropic provider. Headless `--print` is the default, which is the Agent SDK path. Never promise a user what subscription headless usage draws from: Anthropic's policy page is the only authority and it changes (read 2026-10-16: subscription usage limits by default, and since 2026-10-07 Max and Team plans also carry monthly API credits, Max 20x $200, spendable through `claude -p` by giving the CLI an API key from the linked Console organization; Pro has none). API-key/cloud billing depends on the CLI's authentication. Confirm the user's intended account and billing method. ## How this differs from the alternatives Three routes reach Claude from opencode, and they are not interchangeable: 1. **opencode's native `anthropic` provider**: an Anthropic Platform API key in opencode's auth store, pay as you go, everything running in opencode's own runtime. 2. **This plugin**: the official `claude` CLI authenticates, so opencode inherits whatever that CLI holds (subscription login, API key, Bedrock, Vertex). It never reads, stores or replays a token. Anthropic has not approved or endorsed it, so never describe it as approved or sanctioned. What it costs: a `claude` child per conversation, Claude Code's own context compaction and clearing happening behind opencode's back, a locally synthesised session title instead of a model-written one unless `titleModel` is set, `/compact` on its own short-lived spawn, no todo panel on opencode 2, and opencode's native reasoning features bypassed by design. 3. **Proxy or token-reuse plugins** (`opencode-with-claude`/Meridian, `opencode-claude-auth`, `opencode-claude-plan`): they reuse the Claude OAuth session outside the official client. Anthropic disallowed that for third-party use in February 2026, and each of those projects says so in its own README (a "community workaround", "no claims regarding compliance", "could be suspended or terminated"). A fourth route arrived in opencode 2.2.3: opencode's own **Claude Agent** provider (`claude-agent`), which also drives the user's own `claude` (2.1.248+) and never reads the login. It is opencode 2 only, runs every tool in opencode, leaves the `~/.claude` setup (CLAUDE.md, hooks, skills, MCP servers, memory, auto-compaction) out, and serves one login. It is a fair choice for a user on 2.2.3+ with one account who wants exactly that; this plugin is the one for opencode 1.x, several accounts, the user's own Claude Code setup, fast mode, the subagent dispatch form (model, effort and account per subagent, remembered) with per-agent `maxTurns`/`maxBudgetUsd` caps, a `/btw` answered by the running Claude session itself, the sidebar and the doctor. Never present `/btw` or naming a subagent's model as unique to it: opencode 2 has its own `/btw` for every provider, and its subagent tool takes a `model` per call for any provider, the built-in included. To hide Claude Agent, the user's opencode config is the switch (the plugin has no option for it): `"disabled_providers": ["claude-agent"]` keeps it out of the model list, and only a `policies` entry `{"action": "integration.connect", "resource": "claude-agent", "effect": "deny"}` removes it from `/connect`. Recommend both. Never recommend route 3, never help migrate a user onto it, and never enable `interactive: true` to dodge a billing or access restriction. If a user asks why this plugin is slower or heavier than a proxy, the answer is route 2's cost list above, plus the tool mediation: proxied `Bash`/`Edit`/`Write`/`WebFetch`/`Task` execute in opencode under its permissions instead of inside the CLI. This file ships with the package, so upgrading that package updates the bundled reference without a separate skill install. Do not copy it into a personal skill directory: a user override can shadow the bundled version. Match guidance to the version actually loaded, not a newer checkout. `test/configure-skill.test.ts` checks name coverage against source declarations; it does not verify defaults or runtime semantics or regenerate prose. For behavior, inspect the matching version's `src/types.ts`, consumers in `src/index.ts` / `src/claude-code-language-model.ts`, and the relevant module. Comments and prose can lag the implementation. The user-facing manual is the markdown under `docs/` (published at https://opencode-claude-code-plugin.dev/); `README.md` is a landing page and is not where an option is documented. ## Ground rules 1. **Config lives in opencode's config, not in a plugin file.** Start at `provider.claude-code.options`. Global defaults usually live in `~/.config/opencode/opencode.json[c]`; project `opencode.json[c]` and `.opencode/` files can override them. Check `OPENCODE_CONFIG`, `OPENCODE_CONFIG_DIR` and `XDG_CONFIG_HOME` before selecting a file. With `accounts`, the seed options are inherited; an existing `provider.claude-code-.options` can override them. 2. **Provider options are read once, at opencode startup.** After any change the user must fully quit and relaunch opencode. A plain `/new` session is not enough, and every other opencode window still open keeps running the old configuration and the old plugin code. Include serve/GUI processes. Say this every time you change something. Bridged MCP config has a limited next-turn hot reload, not general config reload. 3. **Edit minimally.** Keep the user's comments in `.jsonc`, keep key order, change only the keys asked for, and re-parse afterwards. Use surgical text edits or a JSONC-aware edit API. This package already depends on `jsonc-parser`: its `modify` and `applyEdits` preserve unrelated text; `parse` must be checked for errors (`allowTrailingComma: true` for JSONC). Never strip comments with regex or round-trip JSONC through `JSON.stringify`; that can corrupt URLs or erase comments. 4. **Never edit `dist/`, `node_modules/`, or `~/.cache/opencode/packages/`** to change behavior. Build output and installer caches are not configuration. 5. **No credentials exposure.** Never read or print auth files, tokens, keys, a full environment dump, or generated MCP configs. Check credential presence only, not values. Config, diffs and logs can contain secrets or private prompts; inspect only relevant fields and redact before displaying or sharing. Leave secret references such as `{env:NAME}` intact. Do not initiate login/account switching without approval. 6. **No paid probes or risky changes without explicit approval.** Do not run inference (`claude -p`, `opencode run`, `/btw`), enable extra usage, change billing, grant broad tool permissions, or enable experimental flags as a routine verification step. Explain consequences first, including `Question`, `planModeQuestion`, `Compress`, `interactive`, skill/MCP bridging and fast models. Ask in ordinary text if a decision is needed. Do not enable the `Question` proxy in order to ask one: it is opt-in precisely because it disables Claude's own `AskUserQuestion`. ## Procedure 1. Identify install source/version, config scope, account/provider and requested change. Inspect relevant config layers without exposing secrets. Preserve unrelated work. 2. If installation is requested, add the scoped package to the existing `plugin` array, not a replacement array. Preserve pins and `file://` installs unless upgrading was requested. A local checkout entry is `file:///abs/path/to/opencode-claude-code-plugin`. 3. Edit only the needed options/agent keys. Do not populate every default or invent plugin-level options, `apiKey`, model metadata, or derived account fields. 4. Validate syntax and the opencode schema (`https://opencode.ai/config.json` when needed). Schema validation alone does not validate this plugin's free-form options; check this reference and source for names, types, units and enums. 5. Review the minimal, redacted diff. Report what changed and any unverified behavior. 6. Tell the user to fully restart opencode. Prefer offline checks below; get approval before launching another opencode process, which may also start configured MCPs. ## Options reference Use `provider.claude-code.options` unless intentionally overriding an expanded account. That key is read by both opencode majors; opencode 2's own spelling is `providers.claude-code.settings`, and the full precedence is in the opencode 2 recipe. Defaults below describe normal headless opencode use when the key is absent. | Option | Type | Default | What it does | |---|---|---|---| | `cliPath` | string | `"claude"` | Executable, not a shell command with flags. Use an absolute path for a non-PATH install. The opencode config hook supplies this default; only direct `createClaudeCode()` use falls back to `CLAUDE_CLI_PATH`. Account providers wrap it; never select a generated wrapper yourself. | | `cliModelCatalog` | boolean | `true` | Register the models as the installed `claude` describes them. Once per CLI version a background probe (one `claude --print --bare --model ` per catalog id, about 16 spawns and 3 s on 2.1.314, sent `initialize` and `get_context_usage` and never a message, with no credential in its env: measured no API request) records which models the CLI knows, the context window it runs each in and the effort levels it accepts, in `$XDG_STATE_HOME/opencode-claude-code-plugin/cli-models.json` (`0600`, atomic, keyed on the real binary and its version). Registration reads that file and never waits for the probe: a fresh answer applies at once on opencode 2 (it reloads the providers) and from the next start on opencode 1. What changes: windows and effort variants follow the CLI, and a model the CLI's own picker offers that the catalog lacks is added at an unknown (zero) price, usable by `forceModel`/`defaultSubagentModel`. Costs and `(N×)` stay the catalog's. A deadline kill writes nothing; a refusal is remembered for a day. `false` registers the built-in catalog and runs no probe. Doctor section: **Model catalog from the Claude CLI**. Log: `read the model catalog from the claude cli` (INFO). | | `accounts` | string[] | unset | Unset keeps provider `claude-code`. Any array, including `[]`, expands to `claude-code-default` plus normalized, deduplicated names. Non-default accounts use `~/.claude-`; default uses the CLI's normal environment/auth. | | `accountFailover` | `"ask"` / `"auto"` / `"off"` | `"off"` | **Opt-in: only an explicit `"ask"` opens the switch form**, so unset and `"off"` behave identically. `"auto"`, also opt-in, makes the same switch without a form, moving the same request to the next eligible account in configured order inside the same turn (see "Automatic failover" below). `"ask"` ends a usage-limited turn on opencode's native `question` form listing the other configured accounts, and continues the task on the pick inside the same opencode turn. Only ever fires with more than one account configured. The pick is sticky for the LIMITED account until the limit's reset time (or until opencode restarts when the CLI reported none), so it covers every session on that account and subagents follow their parent; child sessions are never shown the form. Leaving it unanswered waits and costs nothing. `stop`, a dismissal, or text that is not one of the offered accounts ends the turn the way a limited turn ends without the form. Triggered only by a rejected `rate_limit_event`, one of the two known account-limit error texts, or one of the five account-level failure kinds the CLI names on its own error reply (`authentication_failed`, `oauth_org_not_allowed`, `account_on_hold`, `verification_required`, `billing_error`); never by a generic failure. Never on compaction turns; both transports (the TUI's limit reply carries the same `error: "rate_limit"` kind). A switch carries the Claude conversation to the target account's config dir and resumes it there (`crossAccountResume`, default on) and only replays the thread as text when that copy is refused; either way, MCP servers configured only in the limited account's Claude profile are gone. With the default `"off"`, a limited turn ends on one `▌ **usage limit:**` note instead (see "When an account runs out of usage"). | | `accountGroups` | object | – | **Off unless set**, and unset means every account behaves as one group, so nothing changes on an install that does not set it. A map from an account name in `accounts` to a group name, e.g. `{"work": "work"}`; every account not named, `default` included, is in one implicit group. With it set the plugin only moves a conversation between accounts in the SAME group, which covers every way one can move: the by-hand switch (picking a model under another account's provider in the same opencode session), the `accountFailover` form, the `"auto"` switch, the override either one sets, and `crossAccountResume`. A switch ACROSS groups sends the other account nothing at all, neither the Claude transcript nor a text replay of the thread (the replay is the same history by another route), starts fresh with only the current user message, and writes one `▌ **account group:**` note naming both accounts and both groups. The source account keeps the conversation and its transcript, so switching back continues it. The way BACK is guarded on the same lookup: that account still has its own Claude session, so the turn is an ordinary one, and the catch-up that would tell that session what it missed while the conversation ran elsewhere (``) is withheld, with nothing else about the turn changed; a thread that was edited or undone in between still drops its session but is not replayed either, and writes the same note. The switch form offers only same-group accounts, the `"auto"` switch moves only to one, and with none left either behaves as a single-account install; `describeOtherAccounts` in the usage-limit and account-block notes is filtered the same way. An account name that is not configured is ignored with one WARN, as is a non-object value or a non-string group. Compaction is exempt and a child session follows its parent (under `"auto"` a child can move itself, which moves the parent with it, within the group). Shown resolved (never echoed) in the startup block and `/claude-code-doctor` as `accountGroups`, names only. Log: `starting fresh on this account: it is in another account group` (NOTICE, reason `another-account-group`), or `not replaying what this claude session missed: the conversation continued on an account in another group` for a withheld catch-up (NOTICE, same reason). It guards what the plugin moves on its own; it is not a permission system. | | `failoverAccounts` | string[] | unset/derived | Account expansion supplies the resolved account list so a limited account can offer the others. Do not hand-wire it; set `accounts` instead. | | `baseCliPath` | string | unset/derived | The `cliPath` before the per-account wrapper substitution, so a failover can build another account's wrapper on the same binary. Supplied by the config hook. Do not hand-wire it. | | `accountInProcess` | boolean | unset/derived | Set by the config hook on Windows, where there is no per-account wrapper script: the spawn exports `CLAUDE_CONFIG_DIR` itself and strips the `@` marker off `--model`. Do not hand-wire it. | | `subagentDispatch` | `"ask"` / `"off"` | `"off"` | **Opt-in: only an explicit `"ask"` raises the form**, so unset and `"off"` are identical and a dispatch is handed to opencode exactly as it is today. With `"ask"`, a proxied `task` or `task_batch` call is held at the drain and the turn ends on opencode's native `question` form asking how the subagents should run; the real `task` calls are released, with the answer applied, on the next step of the SAME opencode turn. Always exactly one question first (`Same as last time` when this conversation has one, `Default`, four curated model/effort combos, `Customise…`), so the common answer is one click. `Customise…` opens a second form with one row per agent type plus one account row when more than one account is offered. That account row also offers `Per type…` when the dispatch has more than one agent type, and a type row with more than one task offers `Per task…`; either one opens a third form, and asking for both gives one third form carrying the per-type account rows followed by the per-task rows. Every row takes a typed answer too: a model (its id or the picker's name, `fable 5.2 max`), an effort level, an `@account`, or any combination (`claude-opus-5-5 max @worker`); anything unrecognised keeps that row's default with a NOTICE. **The account is choosable at three widths and the narrowest wins**: the dispatch (`Account` row), the agent type (`Per type…` or `@name` on the type's row) and one task (`@name` on its row in the third form). Every account answer, typed ones included, is checked against the same same-group candidate list. The answer applies to each child's own `claude` spawn (`--model`, `CLAUDE_CODE_EFFORT_LEVEL`, and the account's wrapper and `CLAUDE_CONFIG_DIR`) and beats `forceModel`, `defaultSubagentModel` and the inherited effort, because it is about this dispatch. A child is matched to its task by the dispatching session, the subagent type and the task prompt, verified against `parentID`. A dismissed or unanswered form dispatches with the defaults and writes one `▌ **subagent dispatch:**` note; the dispatch is never lost. Never on compaction turns, never inside a child session (a subagent follows the choice its own parent made for it), and only where opencode's registry has the `question` entry. `Same as last time` is per opencode session and per agent type and is kept in `$XDG_STATE_HOME/opencode-claude-code-plugin/subagent-dispatch.json` (`0600`, capped at 128 sessions and 32 agent types each, pruned at 30 days, merged rather than overwritten between opencode processes, deleted with the session), so it survives an opencode restart; only the model id, effort level and account name are stored. A remembered model this install no longer has, or an account no longer configured or no longer in the group, is dropped from the row and named in one note. Both transports, both opencode majors. | | `subagentDispatchCrossGroup` | boolean | `false` | Let `subagentDispatch`'s account row offer accounts outside the dispatching account's own `accountGroups` group, and on opencode 2 let a `task` call's own `model` name one. **Off by default and never implied by anything else**: a subagent is handed the task text the main agent writes, which can quote the conversation, and it reads the repository, so offering another group is offering that group the conversation by another route. Does nothing when `accountGroups` is unset, where every account is already one group, or when `subagentDispatch` is off. | | `defaultSubagentModel` | string | unset | Seed-config default for discovered `mode: subagent` agents without a full `provider/model` pin; `forceModel` takes precedence. Keeps the caller's account. Unknown ids warn and keep the inherited model. Not independently read per expanded account. | | `defaultSubagentCacheTtl` | string | unset | Prompt cache TTL (`5m` / `1h`) for discovered `mode: subagent` agents that declare no `cacheTtl`; the agent's own value takes precedence. Unset leaves the CLI's default (1 hour on a subscription). Unknown values warn and change nothing. Headless and interactive spawns, never compaction. | | `defaultSubagentMaxTurns` | number | unset | `--max-turns` for discovered `mode: subagent` agents that declare no `maxTurns`; the agent's own value wins. Counted by the CLI per user message, so safe on a reused process. CLI 2.1.280+; headless only (print-only flag, the interactive transport WARNs once). Part of the session key. | | `defaultSubagentMaxBudgetUsd` | number | unset | `--max-budget-usd` for discovered `mode: subagent` agents that declare no `maxBudgetUsd`. Counted by the CLI over the whole process's life and reset on `--resume`, hence subagents only; a main agent's `maxBudgetUsd` is refused with a WARN. Probe-gated on `claude --help`; headless only. | | `maxBudgetUsd` | number | unset | Dollar cap per opencode conversation (its turns plus every descendant subagent), from the CLI's `total_cost_usd` (cumulative per Claude session on headless, so the ledger takes deltas). Unset: no ledger at all. Warn notes at `budgetWarnAt`; at the cap the next fresh turn ends before any spawn with a `▌ **budget:**` note and `{unified:"error", raw:"budget_exceeded"}`. Not on a turn answering a parked proxy call, not on compaction; a child gets an `error` part instead of the note; `doGenerate` gets the finish only. In memory; raising it needs an opencode relaunch. | | `budgetWarnAt` | number[] | `[50, 80]` | Percent thresholds of `maxBudgetUsd`, one note each per conversation (only the highest when a turn jumps several). `[]` drops the notes, keeps the stop. Invalid values WARN and keep the default. | | `maxBackgroundSubagents` | number | unset | Ceiling on background subagents running at once (the doctor's running count, process-wide). A background `task`, or a `task_batch` with background items, that would exceed it is refused whole with an `isError` tool result naming the cap and the count; nothing reaches opencode. Foreground is never capped. On opencode 2.3.0+ every dispatch counts, because every one runs in the background. An unreadable count (2 s budget) refuses. | | `cacheKeepalive` | boolean \| number | unset (off) | After a served turn on a live idle headless process, send a `side_question` (opencode's own keep-alive prompt, never a user envelope, never a spawn) at 0.9 of the cache TTL the turn's last API call wrote, read off `usage.cache_creation` (1-hour caches only: 54 min), counted from that call's `requesting` frame; each ping restarts the clock, up to the cap per idle stretch. `true` = 2, an integer 1 to 4 = itself, larger = 4 with one WARN, anything else = off with one WARN. Skipped (kebab reason in the doctor): busy (turn in flight, parked proxy call, plan-mode question), `cache-expired` (a late fire after sleep with under a minute left), child session, compaction, `default` affinity, a 5-minute cache, a limited account, the interactive transport. Cancelled by a new turn, exit, eviction, a deleted session, an account or live model switch, a respawn and a compaction. An answered opencode 2 warming ping (`session.generate`) counts as a ping. A ping's cost lands in the next result's running total, so `maxBudgetUsd` and that turn's `turnStats` include it. One INFO per ping (`sent a cache keepalive ping`, tokens only); the doctor's `Cache keepalive` section lists pings sent, skipped by reason and each conversation's next ping. | | `leanGenerate` | boolean | `false` | A detached generate call (opencode 2 `experimental.generate.text`: affinity `default`, no agent, not compaction; OpenChamber's AI rename and walkthroughs; on 1.x only `opencode agent create`) gets one lean `claude -p` on the requested model: `--tools ""`, `--strict-mcp-config`, `--setting-sources ""` (no CLAUDE.md at all), `--disable-slash-commands`, `--no-session-persistence`, a `client_composed` stream-json envelope on stdin (no `@path` attachment), a fresh `0700` cwd under the plugin scratch dir. Skipped when `--help` lacks one of those four flags. Any failure or 180 s timeout runs the normal turn; an abort ends the call. `claude -p` on either transport. | | `titleModel` | string | unset | A CLI model (`haiku`) that names sessions through the same lean `claude -p` as `leanGenerate` (same flags, same `--help` gate, same account and `cliPath` as a turn of this provider, `@account`/`-fast` stripped), given the title agent's system prompt as `` and the conversation's last 12k characters. Unset keeps the synthetic title with zero spawns (first six non-stop words of the latest user text, read from inside V2's `` / `` element so its lead-in is skipped); any failure or 30 s timeout falls back to it, and a `model_not_found` refusal WARNs once per model. Both majors (V1 no-tools title, V2 `title` agent). | | `fallbackModels` | string[] | unset | Ordered models to try when the model a turn would run on is refused. Default for agents declaring no `fallbackModels`; a per-agent list replaces it rather than extending it. Same account throughout, never a switch. Armed only by the CLI refusing the model (`model_not_found`) or by a usage limit when the `accountFailover` form is not taking the turn, which is the case whenever it is `"off"` (its default) or has no other account to offer; with `"ask"` and another account the switch form wins. Entries must be registered model ids, unknown ones warn and are skipped, the current model is dropped from its own chain, each entry is tried at most once per turn, and an exhausted chain surfaces the original error. Never on compaction or title stubs; both transports. Writes a `▌ **model fallback:**` note that transcript rebuilds strip. Not independently read per expanded account. | | `cwd` | string | automatic | Pin an absolute existing directory. Otherwise: session directory from SDK, usable `process.cwd()`, captured project directory, final `process.cwd()` fallback. Startup diagnostics cannot show the per-call session tier. | | `skipPermissions` | boolean | `true` | Pass `--dangerously-skip-permissions` to Claude on both transports (the TUI also gets Claude Code's own `skipDangerousModePermissionPrompt` so it does not stop on that mode's confirmation; CLI 2.1.263+), even with proxies enabled. Proxied calls still use opencode permissions, but unproxied CLI tools do not. `false` removes the bypass flag; it does not by itself create human approval prompts. Ignored when `permissionMode` is `"plan"`, which always drops the flag. | | `permissionMode` | `acceptEdits` / `auto` / `bypassPermissions` / `default` / `dontAsk` / `plan` | unset | Headless `--permission-mode`, not version-gated: verify the installed CLI supports the value. `plan` is enforced: it overrides `skipPermissions: true` and the plugin drops `--dangerously-skip-permissions` for it, so claude cannot edit or run commands. Every other value governs prompting and still passes the skip flag, so `plan` is the only one that makes a run read-only. Headless: nothing releases plan mode mid-session (no headless `ExitPlanMode`), so leaving it means a config change and an opencode restart; the plugin warns once at startup. Interactive transport: forwarded (not `bypassPermissions`), and plan mode CAN be left: the TUI's `ExitPlanMode` dialog is parked and the operator's next message (bare yes approves, anything else is "what to change") or the `planModeQuestion` form answers it; in plan mode there the proxy drops `write`/`edit` so Claude's own Write can write the plan file. | | `permissionPreset` | `"read-only"` | unset | One named posture instead of hand-combining the options around it. Unset changes nothing. An applied preset replaces `permissionMode`, `skipPermissions`, `controlRequestBehavior` and `controlRequestToolBehaviors` outright, filters `proxyTools`, and unions its own names into `extraDisallowedTools`. `read-only` forces `skipPermissions: false` (the CLI exits with `bypassPermissions not supported in restricted mode` if both are passed), replaces any `permissionMode` with `--restricted` (CLI 2.1.258+: no Bash, REPL or other code runners, no WebFetch, file tools confined to the working directories, bypass refused), adds `--permission-prompts none` (CLI 2.1.263+), disallows `Bash`, `Write`, `Edit`, `NotebookEdit`, `REPL`, `JavaScript` and `WebFetch` via `--disallowedTools`, drops `bash`/`write`/`edit`/`webfetch`/`task`/`task_batch` from `proxyTools`, forces `controlRequestBehavior: "deny"` and ignores `controlRequestToolBehaviors` entirely. Every override is logged at NOTICE. An unknown preset name applies nothing and WARNs rather than guessing. On a CLI below either flag gate the preset still holds through `--disallowedTools` plus the plugin's own deny, with a WARN naming what is lost. Reads (`Read`, `Grep`, `Glob`, `WebSearch`) still work; anything else that would prompt, including bridged MCP tools and the `question` proxy, is denied. | | `controlRequestBehavior` | `allow` / `deny` | `allow` | Automatically answer CLI `can_use_tool` requests if emitted. Forced to `deny` by `permissionPreset: "read-only"`. Not an opencode permission prompt or a sandbox; bypass/pre-allowed tools may never ask. `AskUserQuestion` defaults to deny. | | `controlRequestToolBehaviors` | object of tool name to `allow`/`deny` | unset | Case-insensitive per-tool override of the above (`Bash`, `Read`, `mcp__github__list_prs`). Do not allow `AskUserQuestion`: that can let headless Claude self-answer. | | `controlRequestDenyMessage` | string | built-in text | Override ordinary deny text. `AskUserQuestion` always uses its own stop-and-wait message. | | `proxyTools` | string[] | `["Bash", "Edit", "Write", "WebFetch", "Task"]` | Case-insensitive replacement list, not additive and not a capability allowlist. Known entries expose `mcp__opencode_proxy__`; omitted/unknown tools are not disabled. `Task` also brings `task_batch`; `[]` disables this list, not MCP proxying. See the proxy table for exceptions. | | `extraDisallowedTools` | string[] | unset | Claude built-ins to switch off outright with `--disallowedTools`, for tools that have no proxy (`["NotebookEdit"]`). Removes the capability rather than routing it. | | `mapReadRules` | boolean | `true` | Carry opencode's own `read` permission **deny** rules onto the Read the CLI runs itself, as `--disallowedTools "Read()"`. `Read`, `Glob` and `Grep` are CLI-native by default, so without this a file opencode would refuse to read is read by Claude with no prompt (measured 2026-10-16: "read .env with your Read tool" returned a planted secret). Only `deny` is carried: an `ask` cannot be honoured on a spawn that has nobody to ask, and **opencode's own `*.env` default is an `ask`, not a deny**, so a default install maps nothing. Write `permission: { read: { "*.env": "deny" } }` to close that, or add `Read` to `proxyTools` so the read runs in opencode and its prompt applies. `glob`, `grep`, `list` and `external_directory` rules are not mapped (Claude's deny beats its allow, so "outside the working directory" cannot be said without denying the working directory); nor are agent-level `permission.read` overrides. `/claude-code-doctor` lists what was mapped, what was not, and the asks it cannot enforce. Compaction spawns get no rules. Set `false` to send nothing. | | `proxyToolTimeoutMs` | object of proxy tool name to ms | unset | Optional wall-clock backstop per tool, in ms, case-insensitive keys. A proxied call normally ends on an event the plugin listens for, not on a timer: opencode's result, an abort (the CLI is interrupted), the next user message (calls the previous turn left pending are rejected as orphaned), the `claude` process exiting, the chat being deleted, or opencode exiting. Fallback 10 min (including dynamic MCP tools); `task` and `task_batch` have no deadline, so a subagent runs to completion and a chat parked in one holds its worker until one of those events; `question` 30 min. Set both task keys to cover both. A positive value replaces the default, `0` removes that tool's deadline, negative or non-numeric values are ignored, and values above 2147483647 are clamped. Bash `input.timeout` raises the resolved deadline (and restores one after `bash: 0`); executor ceilings still apply. The generated MCP client timeout is the largest effective deadline, or the CLI's maximum while any tool has none. `compress` is intercepted without a deadline. | | `planModeQuestion` | boolean | `false` | Bridge `ExitPlanMode` approval to opencode's `question` and return a real CLI tool result. Requires a live question registry entry; otherwise keeps text fallback. Cannot fire on the headless transport: CLI 2.1.258 does not offer `ExitPlanMode` under `--print`, measured directly and through a full plugin probe, so the text path is what runs. On the interactive transport it fires and is verified live (1.18.34): the form's answer is pressed into the TUI's approval dialog. Headless prose yes/no is not a plan-mode unlock; interactive typed yes is. | | `webSearch` | `"claude"` / `"disabled"` / `""` | `"claude"` | Default: CLI search with the query rendered as text. Custom target forwards a tool call to an existing opencode tool accepting `query`; this is mapping, not the authenticated proxy replacement, so do not assume CLI search is suppressed. `"disabled"` disallows headless `WebSearch`. | | `bridgeOpencodeMcp` | boolean | `true` | Discover/translate disk MCP config plus runtime enabled status. False stops this bridge, not explicit `mcpConfig`, the built-in-tool proxy, or Claude's own MCP settings. Only bridge trusted servers. | | `bridgeMcpOauthTokens` | boolean | `false` | Give a bridged **remote** MCP server the OAuth bearer token opencode already holds for it, so the Claude CLI can use a server the user authenticated through opencode's own flow instead of reporting it `needs-auth` for the whole session (`MCP server "" is needs-auth in Claude Code`). **Off by default and never a silent recommendation**: it copies a credential out of opencode's own store (`$XDG_DATA_HOME/opencode/mcp-auth.json`, usually `~/.local/share/opencode/`) into the `0600` bridged config the plugin writes for a second program, which then lets a model drive calls with it. Say that before suggesting it. opencode **1 only**: opencode 2 keeps MCP credentials in its database behind a typed plugin API and has no such file, so the option finds nothing there. Purely additive when on: a token is matched by opencode's own key for it (the server's **name**) and only when the stored `serverUrl` still equals the configured URL, a server with no usable token is bridged unchanged rather than dropped, an `Authorization` header the user wrote wins in any casing, and a local (stdio) server is never touched. An expired token (30 s margin) is not used and WARNs once per server per process; the plugin never runs an OAuth flow and never refreshes. A rotation forces a respawn through `hotReloadMcp` because the token's **expiry** is folded into the bridge hash (never anything derived from the token). No token ever reaches a log line, the doctor report or `/claude-code-doctor bundle`. | | `mcpConfig` | string or string[] | unset | Extra `--mcp-config` paths or inline JSON passed alongside the bridged config. | | `strictMcpConfig` | boolean | `false` | Headless `--strict-mcp-config`: use only explicitly supplied MCP configs, ignoring other MCP sources, not all settings/credentials/hooks. The interactive wrapper adds it whenever it passes MCP paths, independently of this option. | | `hotReloadMcp` | boolean | `true` | With bridging on, compare merged MCP config/status at turn start and respawn on drift, so a server enabled, disabled or finished connecting since the spawn reaches the model. Keeps the session via `--resume` on both transports. Acts only at a safe boundary: never during compaction, and never while a proxied call is pending, a turn is in flight or a plan-mode approval is outstanding. Logs the joined and left server names at INFO. One respawn per conversation per `CLAUDE_CODE_MCP_HOT_RELOAD_COOLDOWN_MS` (default 60000) so a flapping server cannot respawn every turn. Does not reload arbitrary provider options or watch explicit `mcpConfig` contents. | | `mcpConnectWaitMs` | number | `3000` | How long the first turn waits for MCP servers the host reports as still connecting before planning the spawn without them. Only opencode 2 reports that state (`pending`); opencode 1's status call blocks until every server decides, so this is a no-op there and costs one status call as before. `0` disables the wait; negative or non-numeric values fall back to the default. Aborting the turn ends the wait at once, and the turn then spawns nothing. A server slower than the budget is still bridged (pending is not read as disabled) and `hotReloadMcp` brings a later one in on the next turn. | | `proxyOpencodeMcpTools` | boolean | `false` | Route opencode's MCP-backed tools through opencode's executor instead of Claude's own `--mcp-config` child, so each call is permission-prompted and rendered as an opencode tool row. Default changed `true` to `false` here, with no behaviour change: at `true` it routed nothing, because discovery read opencode's tool registry, which never contains MCP tools. Discovery now reads the model tool set opencode passes the provider, verified live on opencode 1.18.31 / Claude Code 2.1.263. **Tell the user to set `strictMcpConfig: true` alongside it**: a server also present in Claude Code's own config is reached directly and the proxy is bypassed, which looks exactly like the option doing nothing. A routed call runs with the calling agent's permissions. Per server: a tool in the agent's tool set means proxied; `connected` in opencode with none of its tools in the agent's set means left out of that spawn entirely (this is what keeps an `explore` subagent from starting its own copy of every MCP server and being handed servers opencode withheld from it); anything else keeps the direct bridge. One INFO line, `proxyOpencodeMcpTools: MCP servers outside this agent's tool set`, names the `withheld` and `bridged` lists. With the option off every enabled server is bridged into every spawn, subagents included: suggest turning it on when subagents start slowly or get MCP servers they should not have. Inert with `bridgeOpencodeMcp: false`, which leaves no bridged server list to match names against. Do not promise exactly-once side effects across failures, retries or opencode versions; verify routing before using write-capable tools. | | `proxyOpencodeTools` | string[] | `[]` | Forward explicitly named opencode tools (case-insensitive): V1 resolves registry ids; V2 resolves the current model tool snapshot and its actual JSON Schema, including synthesized Code Mode `execute`, without re-exposing tools absent from that snapshot. Covers plugin-declared tools such as DCP's `compress` and V2 Code Mode. Same broker as other proxies; collisions and unknown names warn. Explicit allowlist only, because calls run in opencode with the agent's permissions. `execute` grants access to the session's whole Code Mode catalog, not just MCP, and is refused by the read-only preset. | | `stripContextReminders` | boolean | `false` | Strip opencode-dcp `` blocks from user/assistant message text, including the fresh-session rebuild. Only when no `compress` is proxied via `proxyTools` or `proxyOpencodeTools`; reachable compress makes it inert. Resolved from config, so a configured-but-unregistered name still counts as reachable. Leaves opencode's own `` blocks alone. | | `alwaysLoadProxyTools` | boolean or string[] | `["bash", "edit", "write"]` | Proxy tools served with `_meta["anthropic/alwaysLoad"]`, so Claude Code puts them in every request instead of behind `ToolSearch` and the first proxied call of a process skips one API request. Measured on 2.1.314 (h #g276): a proxied `echo` took 2 calls instead of 3, 32% fewer prompt tokens, 41% lower cost; a turn with no tool call carried 531 more prompt tokens. `true` loads every proxy tool, `proxyOpencodeMcpTools` tools included (warn the user: many schemas in every prompt is what `ENABLE_TOOL_SEARCH=0` cost, 2.5 to 4 times); `false` defers them all (the behaviour before h #g276); a list names proxy tools, case-insensitive. `task` and `task_batch` are left deferred together on purpose. An older CLI ignores the field. | | `parallelWebfetch` | boolean | `true` | Proxy serves `webfetch` with MCP `readOnlyHint: true`, so Claude Code sends one reply's fetches together, and the drain waits for that reply's `message_stop` (cap 2 s) while it holds only read-only calls, so they run in one opencode step. Measured on 2.1.314 (h #g289): three 1-second fetches, 2 steps instead of 4, 2.2 to 2.4 s from first call to answer instead of 5.1 to 5.8 s, same API requests. Also lets plan mode run the proxied `webfetch` (refused there without it), matching Claude's native WebFetch; opencode's `webfetch` permission, hooks, `--disallowedTools` and deny rules still apply, and `bash`/`edit`/`write` still run alone and in order. `false` serves no annotation. | | `claudeCommands` | boolean | `true` | List Claude Code's own commands and skills in opencode's `/` menu and send a typed one the way Claude Code accepts it (h #g322). The list is the CLI's own: per configured account (its config dir) and per folder, a background `claude --print --input-format stream-json --strict-mcp-config --no-session-persistence --settings '{"disableAllHooks":true}'` is sent `initialize` and never a message (measured on 2.1.322: about 1 s, no API request; without `disableAllHooks`, `initialize` alone runs SessionStart hooks; NOT `--bare`, which skips plugins), once per opencode start, and its `commands` rows (name, description, built-in flag; never the account block) are kept in `$XDG_STATE_HOME/opencode-claude-code-plugin/claude-commands.json` (`0600`, atomic, 32 entries). Menu: every non-built-in command, under its short name when that is unique (`/test-cards` for `stripe:test-cards`), else `plugin:name`, described `Claude Code: `, running `/ `; never a Claude Code built-in and never a name opencode already has (its built-ins `init`/`review`/`goal`, its TUI's own entries, the user's opencode commands, `/btw`, `/claude-code-doctor`: a plugin command with a built-in's name replaces it on both majors). Messages: a listed command goes out without `client_composed` from the first message; a typed short name that exactly one listed plugin command ends in, with nothing listed or defined under that name itself, is rewritten to the full name (headless Claude Code does not resolve short names: `/test-cards` answered "not available in this session" on 2.1.322). Both majors pass an unknown `/name` through as text (measured on 1.19.4 and 2.3.2). The TUIs read their `/` menu at startup, so a skill installed while opencode runs is listed from the next start (opencode 2: a second `/reload`). `false` adds nothing, runs no probe and leaves messages as typed. Log: `read claude code's own commands from the cli`, `listed claude code's own commands in opencode's / menu`, `sending a claude code command under the full name it was listed with` (INFO). | | `verbatimPrompts` | boolean | `true` | Stamp `client_composed: true` on every text envelope the headless transport writes (user messages, forwarded messages, late proxy results, the auto-continue nudge; never a `tool_result` envelope), so Claude Code delivers the text as written: no slash-command dispatch and no `@path` expansion on the message's last text block. Measured on 2.1.314: without it `/model claude-sonnet-5-5` switched the process to Sonnet with no model call and `/cost` returned the CLI's usage screen. Hooks, `CLAUDE.md` and the skill listing still arrive; the `ultrathink` keyword reminder does not, so suggest an effort variant. `/btw` and `/claude-code-doctor` are unaffected. Exception: a message whose only text block starts with `/name` for the user's own command or skill goes out unstamped and runs as typed, from the first message in a cwd, decided by the definition file: a plain name needs `commands/.md`, `commands//SKILL.md` or `skills//SKILL.md` under the Claude config dir or a `.claude` from the cwd up to its git root (never the home dir's, nothing above it), a nested `/ns:name` needs `commands/ns/name.md`. A plugin's `/plugin:cmd` has no file the plugin reads, so it goes out unstamped once `claudeCommands`' list names it (from the first message), or, with that option off, once a `claude` in that cwd has reported the name in its init frame. A typed short name a single listed plugin command ends in is sent under its full name (see `claudeCommands`). A command file added after a conversation's `claude` started is unknown to that process: the model answers that it is not installed, and it runs from the next process. Built-ins stay stamped. Interactive transport not covered. Set `false` only when the user wants Claude Code's own `/` commands or `@` mentions typed through opencode. | | `multiStepContinuation` | boolean | `true` | Append a system-prompt hint to chain tool calls in one turn instead of stopping between subtasks. | | `autoContinueIncompleteTurns` | boolean or `"smart"` | `"smart"` | `true`/`"smart"` continue a turn truncated at `max_tokens`, bounded by 8 attempts and 10 minutes, and otherwise run the keyword heuristic only when stop reason is missing. Every other stop reason, plus error, abort or latched question, stops it. Current measured CLIs always report a reason, so truncation is the only case that resumes in practice. Also gates the `▌ **no reply:**` note written when a turn finishes cleanly with no text and no tool call; `false` turns off the note as well as the continuation. | | `compactionModel` | string | `"claude-haiku-4-5"` | `/compact` uses a fresh short-lived process on the selected transport without the usual bridge/proxy/skill wiring. On the PTY it disables built-in tools, uses an empty strict MCP config, submits summary instructions with the transcript as text, and closes the TUI after its answer. Nonblank `CLAUDE_CODE_COMPACTION_MODEL` wins. This is inference and can be billed. | | `ignoreAnthropicApiKey` | boolean | `false` | Strip `ANTHROPIC_API_KEY` and `ANTHROPIC_AUTH_TOKEN` from headless/interactive spawn env, allowing stored auth to be used. Does not log in, change the parent env, or guarantee subscription billing if other CLI/cloud auth is configured. Warns at startup when either nonempty variable is present, regardless of the flag. | | `idleProcessTimeoutMs` | number | unset | Kill a conversation's idle `claude` worker this many ms after a finished turn. The timer starts when a turn completes, reuse cancels it, and a worker found mid-turn when it fires is re-timed rather than killed. The session id is kept, so the next message resumes transparently. Unset or `0` keeps workers until LRU eviction (16 processes, oldest idle first). Values above `2147483647` are ignored. Applies to the interactive transport too (the TUI is closed; the next message resumes it). Deleting a chat in opencode releases its workers and session ids immediately regardless. | | `enableTodoTools` | boolean | `false` | Set `CLAUDE_CODE_ENABLE_TODO_TOOLS=1` on every `claude` spawn (both transports, never compaction), so the CLI offers `TaskCreate`/`TaskUpdate`/`TaskGet`/`TaskList` on every model. Claude Code 2.1.280 to 2.1.293 offers them on its own only to Claude 3.x, Opus 4.0-4.7, Sonnet 4.0-4.6 and Haiku 4.5; on Opus 4.8, Opus 5/5.5, Sonnet 5/5.5, Fable and Haiku 5.5 no todos reach opencode's `todowrite` (or the sidebar's todo fraction) without it. Fills a gap only: a `CLAUDE_CODE_ENABLE_TODO_TOOLS` already in opencode's environment, `0` included, is passed through and decides. Off by default because the CLI turned the tools off for those models deliberately. Doctor row: `enableTodoTools`, with a note when the environment overrides it. Spawn log: `enableTodoTools: true` on `spawning new claude process`. Subagents still need `permission.todowrite: "allow"`. | | `turnStats` | boolean | `false` | Append one `▌ **stats:**` line to each finished turn: cost, wall duration, CLI turn count, input/output/cache-read/cache-write tokens, and a permission-denial count when the turn had any, taken from the CLI's own `result`. Never on a compaction turn or a turn that ended in error. Its own text part, stripped from transcripts rebuilt for the CLI, so the model never sees it. The same numbers are logged at INFO regardless, and `modelUsage` plus `permission_denials` always reach `providerMetadata`. The cost is THIS turn's: the CLI reports the Claude session's running total, and the footer prints the difference from that session's previous total (the INFO line carries both, `costUsd` and `turnCostUsd`). The first turn of a session resumed after an opencode restart, or of a fork, prints no cost, because `--resume` restores the running total and there is nothing to subtract; the next turn has it again. Not a billing guarantee. | | `forkSessions` | boolean | `false` | When a new opencode session turns out to be a fork of one this provider already served, branch the parent's Claude conversation with `claude --resume --fork-session` instead of re-rendering the whole thread as text into the first message. Measured on CLI 2.1.280 with haiku 4.5 over a ~13k-token thread: 814 cache tokens written and 39,710 read, against 22,355 written and 17,385 read for the replay, so $0.0058 against $0.0467 for that turn; the parent's transcript is byte-identical afterwards. Neither opencode major tells a provider that a session is a fork, so the parent is found by matching this prompt's history against what each sibling session key was last asked to continue. Off by default because a resumed Claude conversation reuses the system prompt recorded on its FIRST request (`--system-prompt-snapshot`, default `on`), so a forked session answers under the parent's appended system prompt rather than this turn's; measured directly, a parent seeded with codename ZEBRA and forked while passing QUAIL answered ZEBRA. Falls back to the replay, unchanged, for: another account, an unknown or released parent session id, a busy parent (live process, proxied call in flight, unanswered plan-mode question), a fork cut mid-conversation, a fork taken mid tool round trip, a different cwd / model / agent / effort / prompt-cache TTL, compaction, an account-failover switch, and a `claude` whose `--help` does not advertise `--fork-session`. Recording costs nothing while the option is off. | | `forkCompaction` | boolean | `false` | Headless `/compact` on a fork of the conversation's own Claude session: `--resume --fork-session` with the conversation's spawn args minus every MCP server, the skip flag (replaced by `--permission-mode dontAsk`, a read-only spawn keeps `--restricted`), its prompt file, caps and effort, on the conversation's own model. The fork reads that model's prompt cache, which keys on the model and the built-in tool set (h #g284). `compactionModel` is ignored when it fires. Measured on 2.1.314: 136k-token Haiku 5.5 thread $0.013 / 10 of 10 facts against $0.122 / 4 of 10 for the Haiku 4.5 transcript; 81k-token Opus 5.5 thread $0.054 against $0.055, same facts. Not strictly cheaper (chat-model prices, cold-cache rewrite), hence off. Falls back to the transcript, with one INFO `compacting from a transcript instead of a fork` and a `reason` token, on: interactive transport, `default` affinity, no matching served conversation in this cwd and session, no Claude session or no live process for it, a turn or proxied call in flight, another binary, transcript gone, CLI without `--fork-session` or `dontAsk`. The fork's transcript copy is deleted afterwards; the conversation's own is never touched. | | `forkOnRewind` | boolean | `true` | After an opencode `/undo`, an edited message or a regenerated reply (the `rewound` verdict), continue a copy of the conversation's Claude session cut at the last turn both versions of the thread share, `claude --resume --resume-session-at --fork-session`, instead of ending the session and replaying the shorter thread as text. Every served headless turn records a checkpoint (the uuid of its reply's last transcript entry, read off the `assistant` frames, against the conversation up to the turn's last user message); the fork is a NEW Claude session holding exactly the turns that are left, the old transcript byte-identical. Measured on 2.1.288 / 2.1.293 / 2.1.314 on a four-turn thread cut after its second turn: 99 / 121 / 38 tokens written to the prompt cache against the replay's 11,152 / 20,659 / 19,924 to 20,484, 6.9 to 9.7 times cheaper, faster in every run, and correct where the replay's clipping lost a document line and a tool result. Falls back to the replay, with a `forkRefused` token in the NOTICE, on: `option-off`, `interactive-transport` (`--resume-session-at` is print-mode only), `no-checkpoint` (the thread ends on a turn another agent or model answered, a failed turn, a turn from before the CLI's own `compact_boundary`, or more than 64 turns back), `cli-too-old` (below 2.1.288; hidden flag, so a version gate), `transcript-gone`, `entry-gone`. A cross-group account (`accountGroups`) keeps its fresh start with nothing replayed and no fork; compaction is never classified. The fork keeps the system prompt the conversation started with, like any `--resume`. A fork's first `total_cost_usd` carries its parent's running total, so the budget ledger and the `turnStats` footer take the parent's last total as its baseline. Log: `forking the claude session at the last turn the edited thread still has` (NOTICE). | | `forkFromCheckpoint` | boolean | `true` | When a new opencode session is a fork of a turn another session served ("Fork from here", `/fork`, a `session.fork` with a `before` boundary), continue a copy of that session's Claude conversation cut at the turn, `claude --resume --resume-session-at --fork-session`, instead of replaying the inherited thread as text. Uses `forkOnRewind`'s checkpoints, matched STRICTLY across sessions (h #g305): a sibling key only (same cwd, model, scope, provider, agent, spawn settings and effort), the checkpoint's own `cliPath`, a parent not busy (`claudeSessionIsWriting`), no tool result past the last reply, the history up to the turn's user message equal with assistant content included, and the reply the thread ends on equal to the last text block Claude wrote for that turn. The parent's checkpoints up to the cut are carried onto the fork, so an undo there to before the fork point cuts the parent's session. Only where the turn was about to replay: the key's own session, `resumeAfterRestart`, a model-or-effort sibling and `forkSessions` come first. Measured through opencode 2.2.6 + Claude Code 2.1.322 on Haiku 5.5: 30 to 39 written / about 64,100 read and $0.00075 to $0.00081 against the replay's 25,024 to 25,077 written and $0.00554 to $0.00559 (7.3x); opencode 1.19.4: $0.00103 against $0.00560 (5.4x); the fork quoted a document line the replay's clipping dropped, every run. The copy answers under the system prompt the parent started with (measured on 2.1.322: a cut under a different appended prompt answered with the parent's); for a sibling the forwarded prompt was byte-identical, so the residual is the date line and instruction edits, as for `resumeAfterRestart`. Falls back to the replay with the replay NOTICE's usual `reason`, typically `no-sibling-recorded`, when nothing matched (an opencode restart, unless the fork took the WHOLE conversation: then it starts from the parent's resume record, `--resume --fork-session`, NOTICE `forking the claude session of the conversation this one was forked from, saved before the restart`, needs `resumeAfterRestart`, h #g319; a turn that ended on a tool call or failed, another model, agent or effort, the parent busy) or `fork-` (`fork-interactive-transport`, `fork-cli-too-old`, `fork-transcript-gone`, `fork-entry-gone`). Log: `found the turn this forked conversation was cut from` (INFO), `forking the claude session of the turn this conversation was forked from instead of replaying it` (NOTICE). | | `resumeAfterRestart` | boolean | `true` | After an opencode restart, resume the conversation's Claude session (`--resume`) instead of replaying the thread as text. Persists session id + conversation digest per session key in `$XDG_STATE_HOME/opencode-claude-code-plugin/claude-sessions.json` (0600, 256 entries, 30 days) after each successful turn, and after one that failed on a usage limit or an account block, whose message Claude Code keeps in the session (h #g315). Resumes only on the same session key and binary, with the transcript on disk and the history equal to the recorded conversation plus Claude's reply; anything else (edit, revert, compaction, account switch, open tool round trip) replays. opencode-dcp's `` references (and its `@12@` compact form) are not part of the digest: dcp renumbers them on every opencode restart, so after an undo the same message came back under another number and the conversation was refused as `conversation-changed`. Records carry a digest `version`; one without it (written by an older plugin) is compared the old way. Not on compaction. Log: `resuming the claude session from before the restart` (NOTICE) or `not resuming ...` with a reason (INFO). `false` disables reading and writing. | | `liveModelSwitch` | boolean | `true` | Apply a model or reasoning effort change to the conversation's RUNNING `claude` with the CLI's own control requests (`set_model`, `apply_flag_settings {effortLevel}`) instead of stopping it and spawning another with `--resume`. Measured on 2.1.288 and 2.1.314 (h #g278): the conversation is kept, the next request goes out under the new model or effort, and prompt cache reads and writes match the respawn's; what it saves is the respawn, 4.6 to 6.6 s to `system`/`init` on a real install, against 0.5 to 0.7 s for `set_model` and about 25 to 140 ms for an effort change. So that an effort change can apply, a headless spawn on a CLI that can switch (2.1.288+) passes `--effort ` and drops `CLAUDE_CODE_EFFORT_LEVEL` from the child's env: the variable beats `apply_flag_settings` silently (a `success` answer and an unchanged request). Only on an IDLE headless child of the same conversation whose key differs in nothing but the model name (same `@account`, same fast mode) and the effort; an effort changes live only between two explicit levels. A change that lands mid-turn still finishes that turn on the old settings (h #g271) and applies at the next turn. Never across accounts, never on the interactive transport (no control channel; it keeps respawning), never on compaction. A refused or unanswered request (`CLAUDE_CODE_LIVE_SWITCH_TIMEOUT_MS`, default 10000) stops the child and falls back to the respawn. Needs `resumeAcrossModelChanges`. `false` restores the respawn and the env-var effort exactly. Log: `switched the live claude process to the new model or effort instead of respawning it` (NOTICE), `could not switch the live claude process; respawning it instead` (NOTICE, with `step` and `reason`). | | `resumeAcrossModelChanges` | boolean | `true` | When the operator changes a conversation's model or reasoning effort mid-conversation, continue the same Claude session (`--resume --model `) instead of replaying the thread as text. Both are in the session key, so changing either used to start a fresh Claude conversation (issue #91); neither needs one, because `--model` and `CLAUDE_CODE_EFFORT_LEVEL` are spawn-time and the CLI applies either to a resumed transcript (measured on 2.1.288). The session is MOVED off the old key, so one Claude conversation has exactly one owner. Refused on every term `resumeAfterRestart` is refused on (another account, a transcript that is gone, a conversation that changed) plus two more: a sibling whose transcript may still be written to (that turn is served on the sibling instead and the change applies at the next turn that finds it idle, h #g271), and anything that is not the same request scope, opencode session and agent. A session opencode MOVED to another working directory (`session_move`, a lane's worktree) is carried too (h #g317): the transcript is copied from the old directory's project folder into the new one's (the CLI would otherwise keep appending where it found it, which neither the restart lookup nor the interactive transport reads), the old key's child is stopped, and a step that answers a call parked in the old directory finishes there first. The shared `default` affinity never moves. An agent's prompt-cache TTL, `maxTurns` and `maxBudgetUsd` are spawn settings like the effort, so a change to one carries the conversation too, after a restart as well (h #g275); `--max-budget-usd` counts per process, so the carried process starts the new cap from zero, as any `--resume` does. Not on compaction, not on an account-failover switch. It reads the record `resumeAfterRestart` writes, which is also what carries the first change after an opencode restart (h #g274), so `resumeAfterRestart: false` turns it off too. Log: `continuing this conversation's claude session under the new model or effort` (NOTICE), or `... in the session's new directory` for a move. | | `crossAccountResume` | boolean | `true` | On any account switch (a by-hand pick of another account's model in the same session, the switch form, and the switch back when the override expires), and only between accounts in the same `accountGroups` group, continue the same Claude conversation on the other account instead of replaying the thread as text. An account is a `CLAUDE_CONFIG_DIR` and a conversation is one `projects//.jsonl` inside it, so the switch copies that file into the target account's own projects dir (0600, dir 0700) and keeps the session id for the `--resume` both transports already build. Measured on CLI 2.1.288: a copied transcript resumes under another config dir with its context intact, the CLI resolves a session by FILENAME (not the `sessionId` in the records), it appends to the copy it found rather than to the cwd's path, the source comes out byte-identical, and no record holds a user, org or account id. Never overwrites: an older copy already at the target path (what a switch back finds) makes the carry take a fresh session id, and the live copy is the longest one. Refuses on nothing to carry, a non-file at the target path, or a failed copy, and each refusal falls back to the replay. Not on compaction, and inert with one account. Log: `carried this conversation's claude transcript to the other account` or `replaying this conversation as text on the other account` with a reason (both NOTICE). What is NOT verified live is a different Anthropic login answering another's conversation; `false` keeps the replay. | | `usageWarnThresholds` | number[] | `[50, 75, 90, 95]` | Percent levels of a usage window at which a SERVED turn ends with one `▌ **usage:**` note (its own text part, stripped from rebuilt transcripts): account, window, utilization, reset in local time. Read from every headless `rate_limit_event` (not only a rejected one), whose `utilization` is a FRACTION (`0.9` is 90%) and is ABSENT on an `allowed` event with headroom, which is unknown, never zero, and crosses nothing. The same event's `unifiedWindows` carries every window's own utilization and reset (measured on CLI 2.1.293), and each listed window is recorded, so the 7-day window has readings and notes while the 5-hour one limits. Readings persist per account per window in `$XDG_STATE_HOME/opencode-claude-code-plugin/account-usage.json` (`0600`, names, numbers and times only), and so does the dedup: each threshold is said once per account per window across reused processes, sessions and restarts, again only after the window's reset. A crossing in a `/compact` turn or a child session is not said there and is said by the next ordinary turn on the account. Never on `doGenerate`, never turns a served turn into a failure. `[]` turns the notes off but keeps the readings. The single-account name is `default`. Interactive transport: no event, so only a limit reply is recorded (`limited`). Log: `claude account usage crossed a warning threshold` (NOTICE). | | `usageSwitchAt` | number / `false` | `90` | Percent at which work leaves an account BEFORE the wall, when another `failoverCandidates` account (same `accountGroups` group) exists and is not itself at that level per the store. `accountFailover: "auto"`: sets the existing account override (keyed on the account, until the window's reset; in memory, lost on restart) so the NEXT turn spawns on the other account, carried like a limit switch; the note says `New turns move to the "" account until HH:MM`. `"ask"` / `"off"`: nothing moves and no form (the form only ends a FAILED turn); the note names the other account to pick a model from. The turn that crossed finishes as served. Also a threshold in its own right, so the switch is said exactly once per window. `false` or `0` never. Log: `claude account is near its usage limit; new turns move to another account until the window resets` (WARN). | | `loginExpiryWarnDays` | number / `false` | `10` | Days before an account's stored claude.ai login ends at which a SERVED turn ends with one `▌ **login:**` note (its own text part, stripped from rebuilt transcripts) naming the account, the date in local time and `loginCommandFor(configDir)` (`claude auth login`, or `CLAUDE_CONFIG_DIR=~/.claude- claude auth login`). Read from `credential_expires_at` on every `result` (CLI 2.1.318+; measured on 2.1.322: an ISO 8601 string on every numbered result, a free `/cost` included, never on `system`/`init`; the end of the login's REFRESH chain, which the CLI's own token refresh does not move; the server's date or a 30-day estimate, up to 3 days late; absent for an API key, an env token, other providers). Kept per account under `logins` in `account-usage.json` (a date, never a token). Said once per login (per date) across processes, sessions and restarts; a re-login is a new date. Not on compaction, `doGenerate`, a child session or a failed turn; the next ordinary turn says it. The sidebar adds `login ends by 11-19 09:39` (warning colour) or `login may have ended` (error colour) under the account from the same day. `false` or `0` turns both off; at most `30`. Interactive transport: no `result` field, nothing. Log: `claude account login ends soon` (NOTICE, `daysLeft`). | | `bridgeOpencodeSkills` | boolean | `false` | Stage the user's opencode skills for Claude's native Skill tool as `opencode-skills:`, on the headless and interactive spawns (never compaction). Covers every root opencode reads: project `.opencode/`, `.claude/`, `.agents/` walking up, the opencode config dirs (`skill/` and `skills/`), and global `~/.claude/skills` and `~/.agents/skills` under opencode's own `OPENCODE_DISABLE_EXTERNAL_SKILLS` / `OPENCODE_DISABLE_CLAUDE_CODE_SKILLS` switches. Requires the CLI's `--help` to advertise `--plugin-dir`; otherwise no-op. Bridged skills are also listed in opencode's forwarded system prompt, so a large skill set costs prompt tokens twice, which is why it is off by default; `true` opts the user's skills in. Bundled skill staging ignores this option, but still requires flag support and successful discovery/staging. | | `bridgeSkipNativeSkills` | boolean | `true` | Leave a skill unbridged when the Claude session already loads it: from `/skills`, the project's `.claude/skills`, or an installed plugin's `skills/`. Matched by resolved directory, by byte-identical SKILL.md, or (user/project scope only, since plugin skills are namespaced `:`) by name. A name match means `Skill("")` answers from Claude's copy, not opencode's, so it is logged at WARN with both paths. The plugin scan reads `installed_plugins.json` and does not check whether the plugin is enabled. `false` bridges everything and reinstates the duplicates. | | `transport` | `"auto"` / `"headless"` / `"interactive"` | unset (headless) | Explicit choice wins over `interactive` and its env var. `auto` prefers headless and probes required headless flags with free help/argument parsing and no prompt. Only definitive unsupported flags select the PTY; timeout, auth failure, missing binary and unknown output stay headless. Never retries a submitted request. Explicit or automatic PTY selection requires `Bun.Terminal`, otherwise errors. Title stubs do not probe. `/compact` follows the selected transport. On the PTY, `read-only` is `--restricted` plus `dontAsk` (CLI 2.1.263+, refused below rather than weakened) and plan mode parks `ExitPlanMode`'s dialog for the operator. `/claude-code-doctor usage` reports the free headless check unavailable when those flags are absent; it does not run a PTY inference prompt. | | `interactive` | boolean | unset (headless) | Legacy experimental PTY opt-in when `transport` is unset; explicit boolean wins over `CLAUDE_CODE_INTERACTIVE_TRANSPORT`. Needs `Bun.Terminal`; this legacy setting retains headless fallback without it. Wires the same proxy MCP server, `proxyTools` and `--disallowedTools` as headless (proxied tools, subagent dispatch and `question` run in opencode with its permission prompts); tools the TUI runs itself are pre-allowed by `interactiveAllowTools`. `permissionMode` is forwarded (not `bypassPermissions`); `read-only` and plan mode hold as described under `transport`; MCP hot reload, idle eviction, images and `/btw` (answered by a short-lived `--fork-session` TUI) work. The skill bridge, effort, prompt cache TTL and CLI hygiene env do apply. Stopping a reply sends Esc and keeps the session; a dead or evicted TUI is replaced with `--resume`; folder trust is accepted (moving off the default "No, exit"), Claude Code 2.1.314's "Resume this conversation?" dialog is answered Resume (never "Start a new conversation"), a login or first-run screen fails the start with the fix, the usage-limit auto-continue is cancelled. Claude Code's own idle compaction (2.1.299+: a conversation of 200K tokens or more, idle 54 minutes, 1-hour cache) runs in the TUI and the next reply starts with a `▌ **context compacted:**` note; `"idleCompaction": false` in Claude Code's `settings.json` turns it off (headless spawns never run it). Never enable to bypass a billing/access restriction. | | `interactiveBypass` | boolean | `false` | Deprecated no-op: `skipPermissions` governs the interactive transport too. | | `interactiveAllowTools` | string[] | `["Bash", "Edit", "Write", "Read", "WebFetch"]` | With the interactive transport when it does not run `--dangerously-skip-permissions` (plan mode, `skipPermissions: false` with `controlRequestBehavior: "deny"`, or a CLI older than 2.1.263): replaces the built-in pre-allow list. MCP wildcards from discovered bridge names plus `mcp__opencode_proxy__*` are added even with `[]`. Not a capability denylist; review permissions before enabling. A tool outside the list raises the TUI's permission dialog, which the transport denies with Esc (nobody is there to answer): the turn ends interrupted and the result's `permission_denials` names the tool. | | `interactiveSystemPrompt` | boolean | `true` | With the interactive transport: append the plugin's own prompt. opencode's forwarded system prompt is deliberately not sent on this transport (it can trip Claude's third-party usage gate). `false` is for diagnostics only. | | `interactiveUserInstructions` | boolean | `false` | With the interactive transport: also append, verbatim, the operator's own instruction files that opencode forwarded (each `Instructions from: ` block whose local file still matches, trailing whitespace aside; not `CLAUDE.md`, not an `AGENTS.md` already appended) and the active agent's own prompt. Never opencode's generated prompt or environment block. Headless unaffected. If a turn is billed as a third-party app, turn it off. | | `logging` | object | see below | File logging plus how much reaches the operator. | | `name` | string | unset | Low-level `createClaudeCode()` provider identity fallback after `providerID`, not the opencode display-name setting. Display name lives at `provider..name`; account expansion supplies its own label. Leave this option unset. | | `providerID` | string | derived | Config hook writes the actual provider id (`claude-code` or `claude-code-work`). Do not override manually. | | `hostApi` | `"v1"` \| `"v2"` | derived | Which opencode major created the model, which decides the tool names its stream uses (`bash` on 1.x, `shell` on 2.x). Set only by the opencode 2 entrypoint. Do not set it: forcing `"v2"` under opencode 1.x makes every proxied tool call fail as an unavailable tool. | | `hostVersion` | string | derived | The opencode version that created the model (opencode 2's `app.version`), which decides whether every subagent runs in the background (2.3.0 and later). Set only by the opencode 2 entrypoint; when it is missing the plugin asks `opencode --version`. Do not set it. | | `account` | string | unset/derived | Account expansion supplies this to generate its runtime wrapper. Prefer `accounts` over hand-wiring it. | | `configDir` | string | unset/derived | Generated account directory, also used for interactive env/transcript lookup. Not a standalone headless auth switch: headless account selection comes from the wrapper's env. Do not hand-wire it. | ### `logging` object | Key | Values | Default | Effect | |---|---|---|---| | `file` | boolean | `false` | Persist entries that pass `level`. Logs can contain prompts/tool data/CLI arguments; enable temporarily with consent, not as a credential dump. | | `dir` | path | `~/.local/share/opencode-claude-code/` | Where `plugin.log` goes. | | `mode` | `"silent"` / `"debug"` | `"silent"` | After level filtering: silent routes lower levels only to the file if enabled; WARN/ERROR are surfaced to the operator too. Debug surfaces all emitted levels, but does not lower the threshold. | | `level` | `debug` / `info` / `notice` / `warn` / `error` | `"info"` | Minimum level emitted anywhere. | Where a surfaced line goes depends on whether a full-screen TUI owns the terminal, and the plugin detects that itself (`isTuiHost`, true when the plugin is running off the main thread, which is how opencode 1.x's TUI runs a plugin). Outside a TUI (`opencode run`, `opencode serve`, tests, and opencode 2, which runs plugins in a separate `serve --stdio` process) it is stderr, prefixed `[opencode-claude-code] WARN:`, unchanged. Inside the TUI **nothing is written to stderr at any level**, because stderr there is the terminal the TUI is drawing on and a raw line sits on top of the interface until a redraw. Instead the line goes to opencode's own log (`client.app.log`, service `opencode-claude-code`, so it lands in `~/.local/share/opencode/log/`), and WARN/ERROR also raise a toast titled `claude-code`. The toast carries the message only, never the JSON data; the same message text toasts at most once per process, and a burst raises at most three toasts plus one line naming how many were held back. Nothing is held back from either log. So when a user reports "the plugin printed garbage over my opencode UI", the answer is to upgrade, not to turn logging off; and when they ask where a WARN went in the TUI, point them at opencode's own log or the toast rather than at stderr. On opencode 2 the plugin runs in a separate process whose stderr nobody sees, so WARN and ERROR also go to the plugin's own sidebar half over the RPC channel opencode 2 gives a plugin between its two halves, and the sidebar half raises the same `claude-code` toast under the same limits, in the window the warning came from (measured on 2.0.31). When a 2.x user asks where a warning went, it is that toast and the plugin log file; stderr is a pipe. ## Environment variables Set variables in the environment that launches opencode, then fully restart it. Precedence is per variable, not a blanket env-over-config rule. CLI-owned variables are passed through; their final effect depends on the installed CLI. Never print their secret values. Arbitrary MCP `{env:NAME}` placeholders are outside this list. | Variable | Effect | |---|---| | `CLAUDE_CLI_PATH` | Direct factory fallback for absent `cliPath`. Normal opencode registration supplies `"claude"`; set the option explicitly there. | | `CLAUDE_CONFIG_DIR` | CLI auth/settings/session directory. Non-default account wrappers override it; the default account inherits it if set, on both transports. Never set it to the default `~/.claude` by hand: on CLI 2.1.288 an explicit value, even that one, makes `claude` report itself logged out. Login is a user-approved interactive action, never a diagnostic probe. | | `CLAUDE_CODE_EFFORT_LEVEL` | Shell-level CLI effort. Request variant/agent effort wins on a normal spawn. Compaction omits request/agent effort, but still inherits the shell env. A headless spawn that can switch live (`liveModelSwitch`, CLI 2.1.288+) with an effort requested passes `--effort` and removes this variable from the child, because it would silently beat a live effort change (h #g278). | | `CLAUDE_CODE_PROMPT_CACHE_TTL` | Shell-level CLI prompt cache TTL for the main conversation. An agent's `cacheTtl` (or `defaultSubagentCacheTtl`) wins on that agent's spawn; with neither set the plugin writes nothing and the shell value, or the CLI's own default, stands. | | `CLAUDE_CODE_DISABLE_THINKING` | CLI-owned, conventionally `1` to disable thinking. Plugin leaves it intact and suppresses its own thinking flags/summary defaults if enabled. | | `CLAUDE_CODE_DISABLE_ADAPTIVE_THINKING` | CLI-owned adaptive-thinking control. Either disable variable suppresses the plugin's own thinking flags/summary defaults, not just adaptive flags. Empty/`0`/`false`/`no`/`off` are false, case-insensitive. | | `CLAUDE_CODE_SHOW_THINKING_SUMMARIES` | Headless spawn fills in `1` only if unset and neither disable flag is enabled. Any explicit value is preserved and suppresses the plugin's `--thinking-display` override; `0` requests suppression from the CLI. | | `CLAUDE_CODE_COMPACTION_MODEL` | Nonblank, trimmed value wins over `compactionModel`. | | `CLAUDE_CODE_DISABLE_FAST_MODE` | CLI-owned kill switch, conventionally `1`; plugin does not interpret it or change picker prices. Use the non-fast id if fast mode is disabled. | | `CLAUDE_CODE_INTERACTIVE_TRANSPORT` | Fallback when both `transport` and `interactive` are absent: `1` enables; empty/`0`/`false`/`no`/`off` disable (case-insensitive). Explicit `transport` or `interactive: false` wins. | | `CLAUDE_CODE_INTERACTIVE_BYPASS` | Deprecated no-op, like `interactiveBypass`. | | `CLAUDE_CODE_MCP_AUTO_BACKGROUND_MS` | Set to `0` for the interactive TUI unless the operator set it, so a proxied call past 120 s stays in the foreground as on headless. `CLAUDE_CODE_DISABLE_MCP_TASK_BACKGROUND` is not set: it covers MCP-task servers only, which the proxy never is, and at `0` the CLI asks no server for a task. | | `CLAUDE_CODE_START_WATCHDOG_MS` | Positive integer ms before a headless start or proxy-result continuation is considered silent; default 90000 for missing/invalid/nonpositive values. First expiry respawns, second errors. A respawn mid-turn re-sends only the proxied tool results the model had not answered yet. Bookkeeping-only output is not progress. A process that has not sent its first `system`/`init` yet gets at least its `MCP_TIMEOUT` plus 30 s (150 s by default), since the CLI sends `init` only after its MCP servers connect or time out; the log's `beforeInit` says which delay fired. Keep within timer range; do not lower for routine config checks. | | `CLAUDE_CODE_LIVE_SWITCH_TIMEOUT_MS` | Positive integer ms one `set_model` or `apply_flag_settings` may take before a live model or effort switch gives up, stops the child and falls back to the respawn; default 10000 for missing/invalid/nonpositive values. Measured answers: 0.5 to 0.7 s and 20 to 140 ms. | | `CLAUDE_CODE_RESULT_FALLBACK_MS` | Positive integer ms of stdout silence, after the CLI has produced output, before the turn is closed with no `result`; default 90000 for missing/invalid/nonpositive values (60000 before v0.73.6: a turn whose model streamed a large tool input with no output for about 72 s was cut off; most other closes were the Mac asleep, which v0.73.4 handles). The close is announced in the reply as a `▌ **stream timeout:**` note, which is stripped from any rebuilt transcript, and interrupts the CLI's turn so it does not run on unattended. The note and the turn's error are worded from the stream: no answer came from the API (a `system`/`status` `requesting` frame with no `message_start` after it), the reply had finished (its `stop_reason` was `end_turn` or `stop_sequence`; the turn then ends as a stop with no error), or it stopped partway; never the CLI crash text, which stays for a child that really exited. A request that got no answer is instead interrupted and sent once more on the same process, once per turn, marked by a `▌ **request resent:**` note (h #g323); never on a reply that had started, a compaction, an aborted turn or the interactive transport. An aborted turn gets no note, and a compaction turn gets no note (its text is the summary). A fire more than 5 s past its deadline (the machine slept, or the event loop stalled) waits a fresh full delay instead, because that silence was never observed, and an `api_retry` frame adds the `retry_delay_ms` the CLI announces (h #g316). The start watchdog (`CLAUDE_CODE_START_WATCHDOG_MS`) follows the same two rules. | | `CLAUDE_CODE_CACHE_KEEPALIVE_TTL_MS` | Test seam: the length in ms the `cacheKeepalive` scheduler takes a 1-hour cache to be (ping at 0.9 of it, nothing past it). Changes only when the plugin pings, never what Claude Code or the API does. Positive number, else an hour. Leave unset outside tests. | | `OPENCODE_CLAUDE_CODE_LOG_FILE` | Overrides `logging.file`: trimmed `0/false/no/off` are false; any other nonempty value is true; empty falls back to config. Prefer `1` or `0`. | | `OPENCODE_CLAUDE_CODE_LOG_DIR` | Overrides `logging.dir`. | | `OPENCODE_CLAUDE_CODE_COMMAND_PROBE` | `0` or `false` stops the background probe that lists Claude Code's own commands and skills for this environment (the `npm test` script sets it); a stored list is still offered. `claudeCommands: false` is the config switch for the whole feature. | | `OPENCODE_CLAUDE_CODE_MODEL_PROBE` | `0` or `false` stops the background model probe for this environment (the `npm test` script sets it); the stored answer is still registered. `cliModelCatalog: false` is the config switch and also ignores the stored answer. | | `OPENCODE_CLAUDE_CODE_LOG_LEVEL` | Overrides `logging.level`. Invalid values fall through to config. | | `DEBUG` | A value containing `opencode-claude-code` promotes `logging.mode` to debug, not `logging.level`. Preserve other debug namespaces. | | `OPENCODE_CLAUDE_CODE_PLUGIN_NO_CLEANUP=1` | Skip the removal of a stale unscoped `opencode-claude-code-plugin` install from opencode's package cache. | | `OPENCODE_CLAUDE_CODE_PLUGIN_FORCE_CLEANUP=1` | Run that cleanup even when the marker at `$XDG_STATE_HOME/opencode-claude-code-plugin/cleanup-stale.json` says this plugin version already swept. Without it the sweep happens once per installed version, not once per opencode launch. | | `OPENCODE_CLAUDE_CODE_NO_TMP_SWEEP=1` | Skip the startup sweep of `/opencode-claude-code-` scratch directories whose pid is dead and which the current user owns. The sweep exists because `SIGKILL` skips the exit hook, leaving the `0600` bridged MCP config (which can hold `{env:VAR}`-substituted secrets) behind. | | `ANTHROPIC_API_KEY` | CLI API authentication input, stripped when `ignoreAnthropicApiKey` is true; otherwise may change billing away from stored subscription auth. Never display it. | | `ANTHROPIC_AUTH_TOKEN` | CLI auth-token input; same strip/warning rule. Never display it. | | `DISABLE_AUTOUPDATER` | Set to `1` on every spawned `claude`, and only when the user has not set it. Keeps the CLI from updating mid-session, which would invalidate the cached version that gates `--thinking-display summarized`, `--plugin-dir` and fast mode. Not a provider option: a user-set value (including `0`, meaning keep updating) is never overwritten, which is the intended escape hatch. Tell a user who wants CLI autoupdates to export `DISABLE_AUTOUPDATER=0`, not to look for a config key. | | `CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC` | Set to `1` on every spawned `claude` under the same never-overwrite rule. Suppresses non-essential CLI network traffic and independently blocks auto-update. An empty string counts as user-set and is left alone; the CLI reads it as off. | | `CLAUDE_CODE_DISABLE_REFUSAL_FALLBACK` | Set to `1` on every spawned `claude` (both transports) under the same never-overwrite rule, so a reply a safety classifier stops twice ends the turn as an error instead of Claude Code silently answering on another model and keeping it for the process. `0`, `false` or an empty string keeps Claude Code's fallback (measured on 2.1.322); the plugin then writes a `▌ **refusal fallback:**` note naming both models and the sidebar and turn history name the model that answered. A user who wants the fallback exports `CLAUDE_CODE_DISABLE_REFUSAL_FALLBACK=0`; there is no config key. The non-streaming fallback is not turned off: its reply is rendered. | | `MCP_TIMEOUT` | Set to `120000` on every spawned `claude` (both transports), only when the user has not set it. Claude Code's 30 s default let a subagent give up on the plugin's in-process proxy while opencode was busy, and run with no tools ("no shell tool"). A subagent that reports no tools, or a slow first reply in a very long session, points here. | | `OPENCODE_CONFIG` | Explicit config file, also read by the disk MCP bridge before project layers. | | `OPENCODE_CONFIG_DIR` | Additional `.opencode`-style config/skill root. The plugin's direct agent-file fallback does not use it; agents must reach the config hook or a supported agent directory. | | `OPENCODE_WORKTREE` | Overrides the disk MCP bridge's project walk-up boundary. opencode 1.x layering only: the opencode 2 layering walks to the filesystem root and applies no worktree boundary at all. | | `CLAUDE_CODE_MCP_HOT_RELOAD_COOLDOWN_MS` | Minimum gap in ms between two `hotReloadMcp` respawns of one conversation; default 60000 for missing, non-numeric or negative values. A server flapping between connected and failed would otherwise cost a kill and a `--resume` spawn every turn. `0` disables the guard. A real second change is not lost, it lands on the first turn after the gap. | | `XDG_CONFIG_HOME` | Global MCP/skill/AGENTS discovery root (`/opencode`); defaults to the home `.config`. Direct agent-file fallback still uses `~/.config/opencode/agent(s)`. | | `XDG_CACHE_HOME` | Account wrapper/cache-cleanup root override; do not assume the default cache path when upgrading. | | `HOME` | Home expansion and direct agent-file discovery (other paths also use OS homedir). Do not change it to switch accounts. | | `USERPROFILE` | Home fallback where `HOME` is absent. | | `OPENCODE_VERSION` | Startup diagnostics version fallback, not a capability override. | | `OPENCODE_EXPERIMENTAL_BACKGROUND_SUBAGENTS` | opencode's own flag, read by opencode and never by this plugin. On opencode 1.x it is what makes opencode advertise `background` on its `task` tool, and that advertised schema is the only thing the plugin reads. `OPENCODE_EXPERIMENTAL` turns it on as a blanket. It must be in the environment that launches opencode. Unconditional on opencode 2.0 to 2.2; on 2.3.0+ every subagent runs in the background. | | `OPENCODE_DISABLE_EXTERNAL_SKILLS` | opencode's own switch, honoured by the skill bridge: any value other than empty / `0` / `false` drops both `~/.claude/skills` and `~/.agents/skills` from discovery. | | `OPENCODE_DISABLE_CLAUDE_CODE_SKILLS` | The same switch for `~/.claude/skills` alone; `~/.agents/skills` is unaffected by it. | ## Recipes **Which major each recipe is for.** Every options fragment below is written in the opencode 1.x spelling, `provider.claude-code.options`, which opencode 2 also reads. On a config that only ever serves opencode 2, put the same fragment under `providers.claude-code.settings` instead. Fragments belong inside that options object, never at the config root. The opencode 2 recipe has the full precedence list. ### Minimum install ```json { "plugin": ["@khalilgharbaoui/opencode-claude-code-plugin"] } ``` Everything else is optional. Models appear in the picker without extra config. The `plugin` key is read by both opencode majors, so this block needs no edit after an opencode 2 upgrade. On opencode 1.x, the sidebar's **Subagents** section (below) also needs the same spec in `~/.config/opencode/tui.json`, because 1.x loads TUI plugins only from that file's `plugin` array, never from `opencode.json`'s: ```json { "plugin": ["@khalilgharbaoui/opencode-claude-code-plugin"] } ``` Same spec as in `opencode.json`, a `file://` checkout path included (1.x reads the package's `exports["./tui"]`). opencode 2 needs nothing: it finds `/tui` through the `plugins` entry it already has. ### opencode 2 Same package, same config. 2.x's native key is `plugins` (plural), but it still reads 1.x's `plugin` key, so an existing install needs no edit: ```json { "plugins": ["@khalilgharbaoui/opencode-claude-code-plugin"] } ``` - Check the major first with `opencode --version`. `plugin` is read by both majors (recorded in `docs/agents-history.md` #g39); `plugins` is read by 2.x only. On 2.x, `opencode plugin add @khalilgharbaoui/opencode-claude-code-plugin` writes the `plugins` entry and installs the package. - With no `accounts`, 2.x names the provider `Claude Code` (id `claude-code`); 1.x gives it no name and shows the id. Either way a model's full id is `claude-code/`, and `opencode run -m claude-code/claude-haiku-5-5 "reply with ok"` is a one-line check from a terminal. - On 2.1.4, `opencode plugin list` prints `No plugins found` even while this plugin is loaded. Never read that as "not installed": check with `/claude-code-doctor` or `opencode models | grep claude-code`. - Provider settings, lowest precedence first: `provider.claude-code.options` (1.x's spelling, still read on 2.x), `provider.claude-code.settings`, `providers.claude-code.settings` (2.x's own), and the plugin entry's own `options`, which wins over all three. Any option of this plugin can sit in any of them; the plugin entry is the usual home for `accounts`: `{"package": "@khalilgharbaoui/opencode-claude-code-plugin", "options": {"accounts": ["work"]}}`. - A local checkout is loaded by pointing `plugins` at its **`dist`** directory, never the repository root: 2.x resolves a configured plugin path as `/server` or `/index`. - Known 2.x differences: a `task` call can carry its own `model` (2.x's `subagent` tool takes one; 1.x's `task` does not), there is no todo panel (2.x has no `todowrite` tool, so the sidebar's progress bar is always the time estimate), `bridgeMcpOauthTokens` finds nothing (2.x's plugin API can activate a stored credential but not read one), and Claude's `EnterPlanMode`, `ExitPlanMode` and `NotebookEdit` calls get no tool row (2.x rejects an unknown tool name). From opencode 2.3.0 every subagent runs in the background and `task` has no `background` field (see Background subagents). Everything else behaves as on 1.x, including `/btw` answered inside the running turn, a permission prompt not counting against a proxied call's deadline, a stopped turn releasing its parked proxied calls, and warnings shown as toasts: the plugin reads busy and idle off opencode 2's event stream (`session.execution.*`) and sends warnings over its plugin RPC channel (measured on 2.0.22 and 2.0.31). Do not set `hostApi`; the 2.x entrypoint sets it, and forcing it on 1.x breaks every proxied tool call. - `/connect` on 2.x lists each provider (`Claude Code`, or one per account) under its own name with one method, *Claude Code login (checked with claude auth status)*. Connecting stores no token: the plugin runs `claude auth status` through that provider's own binary or account wrapper, toasts the login method (subscription, API key, Bedrock, Vertex, ...) or the one command that fixes it (`claude auth login`, or `CLAUDE_CONFIG_DIR=~/.claude- claude auth login`), and marks the connection *Sign in required* when the CLI is missing or logged out. It is optional (models work without it) and has no option. Before this, the entry was the raw id with a "Manually enter API Key" method whose key nothing reads; never tell a user to store a key there. Needs CLI 2.1.288 or later for the check; an older CLI gets a "could not check" toast and the connection is left as it was. - 2.x would run a failed turn again up to ten times (each retry a new `claude` resuming the conversation and resending the prompt). The plugin declines every retry for its providers, with no option: the CLI retries API errors itself, and usage limits, max turns and refused models were never retried. An error shows once; resend after fixing the cause. - Every form the plugin raises is answered through 2.x's own `Form` surface rather than a question tool, which changes nothing the operator does. The account-switch form and the plan-mode approval were measured live on 2.0.22, and the `subagentDispatch` form (including `Customise…`, `Per type…` accounts and `Same as last time` across a restart) on 2026-10-08. The by-hand account carry and the `accountGroups` guard were measured live there the same day: both behave exactly as on 1.x. #### V2 MCP and Code Mode V2 MCP config is `mcp.servers.`, with `disabled` rather than `enabled`. The disk bridge accepts both shapes. V2 discovery includes ancestors above the repo, and nearest `.opencode` config wins after all direct configs. Higher precedence server entries replace the entire spec; repeat required fields. Doctor must report actual names, never the container name `servers`. V2 defaults to Code Mode, where MCP functions are behind `execute` rather than individual tools. `proxyOpencodeMcpTools` cannot prefix-match that tool and warns before leaving servers on the direct bridge. Two deliberate choices: - Individual proxies: set `codemode: false` on selected MCP servers and pair `proxyOpencodeMcpTools: true` with `strictMcpConfig: true`. - Preserve Code Mode: after explaining that `execute` can invoke **all tools in the session catalog**, add it to `proxyOpencodeTools`, set `bridgeOpencodeMcp: false` and `strictMcpConfig: true`. In native V2 config these belong under `providers.claude-code.settings`; preserve other allowlisted entries. Do not also pass those servers through `mcpConfig`. The headless proxy exposes `mcp__opencode_proxy__execute` using the actual per-turn schema and catalog. Claude uses ToolSearch to discover that full name, then the original `search(...)` and `tools[...]` signatures inside its code. No execute proxy is automatic; the read-only preset refuses this code runner. With the bridge off, OpenCode still owns MCP connections and catalog updates, but the plugin's disk-MCP hot-reload mechanism does not apply. This path is verified offline with a fake CLI, not a paid live Claude probe. Fully restart all opencode processes after provider/plugin changes; ask before live probes. ### Transport selection To opt into fallback when the CLI removes headless flags, put this in the provider options on opencode 1. On opencode 2 put it in the plugin's own options instead (`"plugin": [["", { "transport": "auto" }]]`), or use `"interactive": true` or `CLAUDE_CODE_INTERACTIVE_TRANSPORT=1`: `transport` is opencode 2's own provider setting (`http` / `websocket`), so it fails opencode's config load under `provider.claude-code.options` (a 500 on every command, 2.1.4 to 2.2.5) and is dropped as malformed under `providers.claude-code.settings`: ```json { "transport": "auto" } ``` Unset keeps headless as the default. `"headless"` forces that path; `"interactive"` requires the PTY directly. An explicit `transport` wins over the legacy `interactive` boolean and `CLAUDE_CODE_INTERACTIVE_TRANSPORT`. Fully quit and relaunch opencode. `"auto"` probes the required headless flags with `--help` before submitting work. Only a definite missing flag selects PTY; timeout, authentication failure, a missing binary or inconclusive output stays headless. Nothing retries a submitted request on another transport. Explicit PTY and an automatic PTY selection require `Bun.Terminal`; without it they fail clearly. This changes transport, not account access or billing. Interactive transport takes text, images and PDFs (staged as 0600 files, deleted after the turn: an image path the TUI attaches, a PDF as an `@` mention Claude reads with its Read tool; headless sends a PDF as a `document` block; other blocks are dropped with a warning). A message sent while a proxied tool runs reaches the same turn through the TUI's own input queue, as on headless. A turn ends on its stop reason or `turn_duration`, or, as a safeguard for a CLI that writes neither, after 20 s of total silence once it has its reply (reported as ended without a stop reason). It reads completed transcript blocks, not token deltas. A poll reads only the bytes appended since the last one, so a poll that finds nothing new costs one `stat` and no read at all, however long the conversation is. Normal interactive turns do not forward opencode's system prompt (on the TUI, Claude Code bills a request carrying it as a third-party app's from extra usage; headless does not). The account-switch form, the fallback chain, `forkSessions`, the usage-limit and account notes and `turnStats` cost and duration all work as on headless, while `forkOnRewind` and `forkFromCheckpoint` do not (the CLI takes `--resume-session-at` in print mode only), so an undo, an edit or a forked chat replays the thread into a fresh TUI session as before; tool permissions follow `skipPermissions` and `controlRequestBehavior` as on headless; proxied calls stay in the foreground (`CLAUDE_CODE_MCP_AUTO_BACKGROUND_MS=0`). `/btw` is answered by a short-lived fork of the conversation (`--resume --fork-session`, same spawn arguments so the prompt cache is shared, `dontAsk` with nothing pre-approved so it runs no tool), closed and its transcript copy deleted once it answers; the main conversation is never written. MCP hot reload and `idleProcessTimeoutMs` work as on headless (the TUI is replaced and resumed). `read-only` is `--restricted` plus `--permission-mode dontAsk` and a read-only allow list (CLI 2.1.263+, refused below); `plan` is forwarded and its `ExitPlanMode` approval is parked for the operator's next message or the `planModeQuestion` form; other `permissionMode` values are forwarded except `bypassPermissions`. Proxy tools use opencode's permissions, while CLI permission dialogs are denied with Esc. `/compact` uses a fresh tool-free PTY with an empty strict MCP config, explicit summary instructions and no session resume, proxy or skills. The doctor remains available even if a PTY cannot start. Its optional usage lookup reports unavailable when headless output is demonstrably unsupported; it does not send `/cost` as an interactive model prompt. ### Two accounts ```json { "provider": { "claude-code": { "options": { "accounts": ["personal", "work"] } } } } ``` Creates `claude-code-default`, `claude-code-personal`, `claude-code-work`; default models have no suffix, other accounts have `@` (`claude-opus-5@work`). Names normalize to lowercase hyphen-separated ids, so choose distinct simple names. After the user approves login, they authenticate each non-default account interactively, for example `CLAUDE_CONFIG_DIR="$HOME/.claude-work" claude auth login`, using the chosen binary. Never copy credentials between accounts. The model suffix is stripped and the config dir set by the generated bash wrapper on macOS and Linux; on **Windows there is no wrapper at all** and the plugin does both itself on the spawn (`accountInProcess`), because a `.cmd` forwarding `%*` would re-parse every argument a third time. Existing `CLAUDE.md`, `settings.json`, `skills/`, `agents/`, `commands/`, `plugins/` in `~/.claude` are linked only when targets are missing; existing targets stay untouched. Directories become junctions on Windows; a file there falls back symlink -> hard link -> copy, and a copy warns because it does not follow later edits. This shares capabilities/settings, not an isolation boundary. Auth/session files are not part of the shared list. Each provider's display name carries the account's plan tier when it can be read: `Claude Code (Work, Max 20x)`, also `Max 5x`, `Max`, `Pro`, `Team`, `Enterprise`. It comes from `organizationType` plus `organizationRateLimitTier` in `/.claude.json` (the default account also falls back to the legacy `~/.claude.json`), read-only, no token and no spawn, and nothing else in that file is ever displayed or logged. Unreadable or unrecognised means no suffix. There is no option for it. ### Usage before the limit Every headless `rate_limit_event` is kept as a reading per account per window, so the operator hears about a window filling up before it runs out (`usageWarnThresholds`, `usageSwitchAt` in the table above): ```text ▌ **usage:** the Claude account "work" has used 76% of the 5-hour window, which resets at 2026-10-17 18:00. ``` - One note per served turn whose account has an unannounced crossing, each threshold once per account per window, persisted, so neither a reused process nor a restart repeats it. Not on compaction, `doGenerate` or a child session. - At `usageSwitchAt` with `"auto"` and an eligible other account, new turns move there until the reset and the note says so; with `"ask"`/`"off"` the note names the account to pick a model from. No form after a served turn. - The CLI reports whenever a window's rounded percent moves, and only on turns this machine runs: use on claude.ai or another machine shows on the next local turn. The last reading stands until a newer one or its reset. - Where to look: the TUI sidebar's `Accounts` lines, one per configured account from the first draw, about what is LEFT of the 5-hour window (`work · 5h 24% left · resets 18:00`, `work · 5h 24% left · 2026-10-18 01:20` for a reset on another day, `5h 100% left` once that window has reset, `ok` for a reading without a number, `limited` for a refusal, `home · Max 20x · no reading yet` before an account's first turn reports, the reset time in its own colour apart from the level). Under an account, one line per window: the weekly window whenever its reading is current, at any level (`7d 56% left · 10-30 12:00`); the weekly window of the model the viewed session last really spawned, on that spawn's account only (`7d opus` for Opus, `7d sonnet` for Sonnet; Claude Code 2.1.322 reports none for Fable or Haiku, so those add no line); and any other window refused or 75% used or more (`7d extra limited`). No window twice; a missing or expired reading is hidden, never assumed full; a line gives up its indentation before its level or reset date is cut. A reset today keeps the word `resets` unless its own line has no room (`default · 5h 100% left · 18:00`). The sidebar re-reads every 1.5 s. Also the doctor's `Account usage` table, which also shows which thresholds were already noted. "No reading yet" with a recent turn usually means the interactive transport. ### Before a login ends Every headless `result` from Claude Code 2.1.318+ carries `credential_expires_at`, when the account's stored claude.ai login ends for good (`loginExpiryWarnDays` in the table above): ```text ▌ **login:** the Claude account "work" stays signed in until about 2026-11-19 09:39, in 9 days, and the login can end up to 3 days sooner. Log in again with `CLAUDE_CONFIG_DIR=~/.claude-work claude auth login` before then, so no turn fails on it. ``` - Once per login, persisted. Within 3 days it says "any day now"; past the date, "the next one may be refused". A turn that already failed gets the `▌ **claude account:**` note (`authentication_failed`) instead, as before. - Where to look: the sidebar's login line under the account, and the doctor's `Account logins` table (date, days left, `said` / `due` / `off`). "No date yet" means an API key, an env token, an older CLI or the interactive transport. ### When an account runs out of usage By default (`accountFailover` unset or `"off"`) a usage-limited turn ends with one `▌ **usage limit:**` note and nothing else, on every limited turn rather than once per process: ```text ▌ **usage limit:** the Claude account "work" is out of usage in the 5-hour window, which resets at 2026-09-20 20:00. Pick a model from the "personal" or "default" account and resend your message, or wait for the window to reset. ``` - The reset time is **local** to the operator, to the minute, and is omitted when the CLI reported none. The window name comes from the CLI's `rateLimitType`. - With no other account configured the advice is "Wait for the window to reset, or enable extra usage on the account." instead. - It replaces the CLI's own error text for that turn: the raw sentence names no account, and the `▌ **rate limit:**` paragraph the plugin used to write is log-only now, so a limited turn carries exactly one block. - Written on a child session too (a subagent that died on a limit is what the parent's `task` result should say), but never on a compaction turn, which fails outright instead (see "A failed compaction turn" below). - The turn **finishes as an error** (`finishReason` `{unified:"error", raw:"usage_limit"}`), the way the account-block note's turn always has: nothing was served, so filing it as a reply hid the failure from opencode. There is no `error` stream part outside compaction, so the note stays the single account of what happened. - `permission_denials` and `turnStats` are untouched; `turnStats` was already suppressed on a failed turn, so a limited turn never carried a stats line anyway. ### A failed compaction turn A compaction turn's text is what opencode stores as the summary, so a compaction whose `result` is `is_error: true` (or carries a failing subtype) writes **no text at all**: no note, no CLI prose, nothing. It ends on an `error` stream part naming the cause and the CLI's own sentence, plus a finish of `{unified:"error", raw:}` where the cause is `usage_limit`, an account-block kind such as `authentication_failed`, or the failing subtype. opencode then marks the compaction failed and keeps the conversation it already had. Before this, a usage-limited compaction returned the CLI's sentence as a normal answer and opencode stored it as the summary, so every later session that could not resume its Claude transcript began from that sentence with the earlier messages gone (issue #90). There is no option for this and nothing to turn off; the operator retries the compaction once the account can serve. When a user says the limit message is unhelpful, check the plugin version before anything else: this note is recent and a long-lived opencode window may predate it. ### Account failover **Opt-in.** `{ "accountFailover": "ask" }` and more than one account configured makes a usage-rejected turn end on opencode's `question` form instead of that note: one option per other configured account in the limited account's `accountGroups` group (every other account when no groups are set), plus `stop`. Picking an account applies it inside the same opencode turn, with no new user message, and the task carries on. Leaving the form unanswered waits and costs nothing. It is opt-in rather than on by default because of what was measured against a real five-hour limit on 2026-10-03. One finding is not the plugin's to fix: typing a message instead of picking **dismisses** the form in opencode, and that message then runs on the still-limited account and raises a second form (the "I had to send two messages before anything ran" report). The other two are fixed: every pick was refused as `unrecognised answer` because another plugin appends a routing tag to tool results, and a switch was always a full replay (since 0.47.0 it carries the conversation over, see below). Tell the user what a pick actually does before recommending one: - It is sticky for the **limited account** until that limit's reset time, or until opencode restarts when the CLI reported no reset time. Every session on the limited account follows the same pick, and subagents follow their parent. Child sessions are never shown the form themselves. - A switch **carries the Claude conversation over** (`crossAccountResume`, on by default): a transcript is one file under an account's own `CLAUDE_CONFIG_DIR`, and a copy of it placed under the target's resumes there with its context intact. Only when the copy is refused does the conversation get replayed into a fresh session on the target account, which costs input tokens there and loses anything the CLI held but opencode did not. - The turn on the picked account starts with one `▌ **account failover:**` line that says which way the conversation arrived: "continues where it stopped" (carried) or "replayed into a fresh Claude session there" (not), and names an account block's reason instead of "is out of usage". - After an earlier pick already moved the conversation (`work` to `personal`), a limit on `personal` makes the form name `personal`, not `work`, and offer neither; the remembered limit, the usage-limit note and an account-block note's login command are `personal`'s too. A pick is still stored under the provider's own account, which is where every turn resolves its account from, so the conversation moves on from there. - MCP servers configured only in the limited account's Claude profile will be **missing** on the target account. - `stop`, dismissing the form, or answering with anything that is not one of the offered accounts ends the turn the way a limited turn ends without the form. The limit is unchanged either way; failover moves the work, it does not create usage. - Only a rejected `rate_limit_event`, one of the two known account-limit error texts, or an account-level failure the CLI reports on its own error reply opens the form. The account-level kinds are `authentication_failed`, `oauth_org_not_allowed`, `account_on_hold`, `verification_required` and `billing_error`. A generic 4xx, a timeout or a bad flag never does. - An expired login also writes a `▌ **claude account:**` note naming the account and the command to fix it: `claude auth login` for the default account, or `CLAUDE_CONFIG_DIR= claude auth login` for a named one. When a user reports "Failed to authenticate: OAuth session expired", that command is the fix; a switch made from that form lasts until opencode restarts. With the form off and another account configured the note ends with "Or pick a model from the `""` account and resend." instead of offering the form. - Works on both transports; not available on compaction turns. `{ "accountFailover": "off" }`, which is also the default, keeps the note. ### Automatic failover **Opt-in.** `{ "accountFailover": "auto" }` and more than one account configured makes the switch a pick would make, without the form: the failed attempt is dropped and the **same request** runs on the next eligible account **inside the same opencode turn**. The user sees one turn with the other account's answer under one note: ```text ▌ **account failover:** "work" is out of usage, so this turn moved to "personal" automatically and stays there until 2026-09-20T18:00:00.000Z. The conversation continues where it stopped. ``` What to tell a user who asks for it, or asks why billing moved: - **Triggers** are exactly the form's, and only on a turn that **failed** (`is_error: true`): a usage limit (rejected `rate_limit_event`, the CLI's `rate_limit` reply, the two known limit texts) or one of the five account-block kinds. A served turn with a rejected event, a generic error, a server error or a timeout never switches, and healthy turns never rotate between accounts. - **Order** is configured order: `default` first, then `accounts` as written. It skips the account that just failed, every account already tried for this request, every account outside the limited account's `accountGroups` group, and every account known to be out: one with an unexpired override moving its own work elsewhere, or one whose remembered limit has a reset time still ahead. Both expire on their own. The choice is made when the failure arrives, so a limit another session learned meanwhile counts. An account whose runtime cannot be prepared (config dir or wrapper not writable) is skipped and the walk moves on; an account already tried is never run again. - **Bounded.** Each account is tried at most once per request. With none left the turn finishes as an error: the `▌ **usage limit:**` note naming the last account tried and offering no other (or the `▌ **claude account:**` note for a block), below one `▌ **account failover:**` line per switch made on the way. A `doGenerate` caller gets the error finish (`usage_limit` or the block's kind), never an answer, and no usage-limit or failover line; its text is at most the CLI's own error text plus, for a block, the `▌ **claude account:**` note with the login command. - **Sticky** like a pick: the override is keyed on the account the conversation was on, so every session on it, subagents included, follows until the limit's reset time, or until opencode restarts when none was reported (always the case for a block). - **Billing** moves to the target account for the rest of the turn and every later turn on the limited account until the override expires. Opting in is the consent. - **The conversation** is carried (`crossAccountResume`) and resumed, or replayed into a fresh session when the carry is refused, exactly as for a pick; the note's last sentence says which. Work the failed account did in that turn is not re-run by the plugin, but a replay only has what opencode has. - **Scope.** Both transports, `doGenerate` callers (no failover note in the returned text), and child sessions, which switch themselves because nothing is asked; the parent follows through the same override. Never compaction (it fails outright) and never a title request (no spawn). An available account beats the `fallbackModels` chain, as the form does. Stopping the turn, or cancelling the stream it returned, stops the attempt in flight and starts no further account. (A cancel is a stop in every mode, `"off"` and `"ask"` included.) - Verified with a scripted `claude` only; the switch path itself is the one measured live for the form. ### Switching account by hand, and keeping two accounts apart Picking a model under another account's provider in the **same** opencode session continues the conversation on that account rather than starting over: the Claude transcript is copied into the other account's `CLAUDE_CONFIG_DIR` and resumed with `--resume`. Both transports, either direction, and it composes with a model or effort change in the same step. It refuses (and replays as text, saying which in one NOTICE) when the thread is no longer the conversation that account was last asked to continue, when the transcript is gone or still being written, or with `"crossAccountResume": false`. When two accounts must NOT see each other's work, name them into groups: ```json { "provider": { "claude-code": { "options": { "accounts": ["work", "hobby"], "accountGroups": { "work": "work" } } } } } ``` `work` is alone in the group `work`; `hobby` and `default` share the implicit `default` group. Moving a conversation from `work` to `hobby` now sends `hobby` nothing: no transcript copy and no text replay, one `▌ **account group:**` note, and the conversation left intact on `work` to switch back to. Recommend one group name per real-world boundary (employer, client, personal), and name only the accounts that have to stay apart, since everything unnamed is already together. ### Subagents on one model, on the caller's account opencode's agent config cannot say "inherit the account, change the model", because the account is the provider and the model is only a `--model` flag. The plugin closes that gap. Per agent, in `~/.config/opencode/agents/.md` or `.opencode/agents/.md` (`agent/` singular also works; subfolders are not read by the plugin). From opencode 2.4.3 a `name:` in the frontmatter names the agent instead of the file, and the plugin applies the file's keys under both names. No `model:` key: ```yaml --- description: Designs and builds UI work mode: subagent forceModel: claude-haiku-4-5 reasoningEffort: high cacheTtl: 5m --- ``` Or once for every discovered subagent without a full provider/model pin: ```json { "provider": { "claude-code": { "options": { "defaultSubagentModel": "claude-opus-5", "defaultSubagentCacheTtl": "5m" } } } } ``` Rules, in order: on opencode 2 a model named for that dispatch in the conversation (the `task` call's `model`, recipe "One subagent on a model the user names") wins over everything here; else `forceModel` wins; else `mode: subagent` with `defaultSubagentModel` set; else untouched. An agent with `model: /` is left exactly as written, account and all (`model: claude-code-work/claude-opus-5@work` pins the account too). Undeclared built-ins are not discovered; a user definition with a built-in name can enter the registry and is subject to these rules. This is not a built-in-name denylist. `reasoningEffort` in the agent file beats the effort the call arrived with; compaction is exempt. Effort, model and cache TTL are part of the CLI session key, so a changed agent respawns rather than sharing a process. `cacheTtl` sets the prompt cache TTL of that agent's own `claude` process, as `CLAUDE_CODE_PROMPT_CACHE_TTL` at spawn. Unset (the default) leaves the CLI deciding, which is 1 hour on a subscription. Claude Code also has a per-agent `experimental.cacheTtl` and a `CLAUDE_CODE_SUBAGENT_PROMPT_CACHE_TTL`: neither does anything here, because both apply only to subagents the CLI runs through its own `Task` tool, and this plugin disallows that tool by default so opencode runs the subagent instead. An opencode subagent is a separate `claude` process using the selected transport, which the CLI counts as a main conversation. Use `cacheTtl: 5m` on short-lived workers that never re-read the cache they wrote, since a 1-hour write is billed above a 5-minute one and both come out of the same usage limit; leave a long-lived main session at the default. Only grant `permission.task` for approved target agents if delegation is wanted. `permission.todowrite: "allow"` is needed for subagent todos; opencode otherwise denies them by default. On models newer than the 4.x line the CLI offers no todo tool at all unless `enableTodoTools` is on. Ask before broadening permissions. Use the singular `agent` config object for inline definitions, with `forceModel`/`reasoningEffort` under `options` if the opencode schema requires it. Markdown fallback reads top-level scalar fields only. ### Agent keys | Key | Behavior | |---|---| | `mode` | Only exactly `subagent` qualifies for `defaultSubagentModel`; `primary`/`all` do not. | | `model` | Full `provider/model` pins bypass plugin model overrides, not the separate effort override. | | `forceModel` | Registered bare model id, preserving the caller's account even if an account suffix is supplied. Works for any discovered agent mode. | | `reasoningEffort` | `minimal`, `low`, `medium`, `high`, `xhigh`, `max`; invalid declarations warn and keep inherited effort. `minimal` maps to CLI `low`. Compaction skips this override. | | `cacheTtl` | `5m` or `1h`; anything else warns and leaves the CLI's default alone. Exported as `CLAUDE_CODE_PROMPT_CACHE_TTL`, beating a shell export of the same name. Works for any discovered agent mode; compaction skips it. | | `maxTurns` | Positive whole number, passed as `--max-turns` (per user message, CLI 2.1.280+). Any agent mode; headless only; part of the session key. | | `maxBudgetUsd` | Positive dollars, passed as `--max-budget-usd` (per process life, reset on resume). Discovered `mode: subagent` agents only; on a main agent it is refused with a WARN. Headless only. | | `fallbackModels` | Ordered registered bare model ids to try when this agent's model is refused. Both YAML spellings (`[a, b]` or a `- ` block). Replaces the provider-level `fallbackModels` rather than extending it. Keeps the caller's account; an entry carrying `@account` has it stripped. Unknown ids warn and are skipped. | **Editing an agent file needs no restart for the plugin's own keys** (h #g313): `forceModel`, `reasoningEffort`, `cacheTtl`, `maxTurns`, `maxBudgetUsd` and `fallbackModels` are re-read at the start of the next turn (a `stat` per agent file, at most every 2 s), with one NOTICE naming the agent, key, old and new value. `mode`, `model` and the prompt are opencode's keys, read by opencode at set-up, so they stay as they were until opencode sets the plugin up again (a full restart on 1.x). A value the `agent` block of `opencode.json` sets itself still wins (one NOTICE says the file's value is not used); a value opencode 1 merely copied out of the file follows the file. A `forceModel` the install does not have WARNs as soon as the file is read. Before this, an edit waited for a restart and nothing said so. ### One subagent on a model the user names (opencode 2) On opencode 2 the user can choose a subagent's model in the message itself, with no configuration: the proxied `task` (and each `task_batch.tasks` item) takes an optional `model`, forwarded to opencode's own `subagent` tool, which resolves it by exact id against the models opencode has. opencode 1's `task` has no such field, so the plugin leaves it out there; on 1.x point the user at `forceModel`, `defaultSubagentModel` or `subagentDispatch: "ask"` instead. (PR #123, h #g254, h #g255.) opencode's form is `providerID/modelID`, plus `#low`, `#medium`, `#high`, `#xhigh` or `#max` for a reasoning variant (every model has them except `claude-haiku-4-5`): | Install | Reference | |---|---| | No `accounts` | `claude-code/claude-sonnet-5-5` | | `accounts`, the default account | `claude-code-default/claude-sonnet-5-5` | | `accounts`, another account | `claude-code-/claude-sonnet-5-5@` | A bare model id (`claude-sonnet-5-5`, `claude-sonnet-5-5#high`) is completed to the reference this conversation's own provider serves (the first column's provider and marker) before opencode sees it, so the subagent stays on the conversation's account. Only an id the plugin registers is completed, and only with no `@` marker or the provider's own; a full reference, another account's marker and an unknown id reach opencode as written. Use the full reference only for another account or provider. Tell the user to name the model by id: "Run the reviewer subagent on `claude-sonnet-5-5#high`." Two ids in one request ("review it on `claude-opus-5-5` and on `claude-sonnet-5-5`, in parallel") become one `task_batch` with a model per task. A model named in words is a guess, and it depends on the model doing the dispatching. Measured on opencode 2.0.31 with "a general subagent on Sonnet 5.5" and "on claude-sonnet-5-5": Opus 5.5 passed `claude-code/claude-sonnet-5-5` first time; Haiku 4.5 passed a bare `claude-sonnet-5-5` first both times, and before bare ids were completed went on to `anthropic/claude-sonnet-5-5` and `claude-sonnet-5.5`, each refused by opencode (`Invalid model "…"`, `Model "…" is not available`) with no subagent started. With the completion both of Haiku's requests ran on the first call. A guessed provider that IS in the user's opencode config would be accepted, though: an `anthropic` provider serving that id would run the subagent there, outside this plugin and billed to that provider. That is the reason to have the user name the model. What the plugin adds on top of forwarding: - The named model beats the agent's `forceModel` and `defaultSubagentModel`, and a named `#variant` beats its `reasoningEffort`, which is opencode's own order. With no variant the agent's effort still applies. A child resumed by `task_id` with a model runs on it. - A task that names a model is left out of the `subagentDispatch` form, and a dispatch whose every task names one raises no form. - A model on a plugin account outside the dispatching account's `accountGroups` group is refused before any task of the call starts; `subagentDispatchCrossGroup: true` lifts that. A model on any other provider is opencode's routing and is not checked. - On 1.x a `model` set anyway is refused before dispatch, for the whole batch. Claude is told to set `model` only when the user asked for one. If it ever sets one unasked, that subagent runs on it, under the same rules. Verify: the subagent's sidebar row shows the model it really spawned with, its tool row shows the `model` opencode received (none there means opencode picked the model as usual), and `plugin.log` has `bare task model completed to this conversation's own provider` for a completion and `explicit task model claimed by its child session`. Every spawn logs `task model gate` with `supported`, which is false on a 1.x host. ### Ask before each subagent dispatch Opt-in; off by default. Turns a fan-out into one question instead of a static agent file. ```json { "provider": { "claude-code": { "options": { "proxyTools": ["Bash", "Write", "Edit", "WebFetch", "Task"], "subagentDispatch": "ask" } } } } ``` What happens, in order: 1. The model calls `mcp__opencode_proxy__task` or `mcp__opencode_proxy__task_batch`. 2. The plugin holds the call and ends the step on opencode's `question` form with ONE question: `Same as last time` (when this conversation has one), `Default`, five curated model/effort combos (Haiku `low`, Sonnet `medium`, Opus `high`, `xhigh` and `max`), and `Customise…`. 3. Answering anything but `Customise…` releases the subagents immediately, with that answer applied, on the next step of the SAME opencode turn. 4. `Customise…` opens one row per agent type, plus an `Account` row when more than one account is offered. A type with more than one task also offers `Per task…`, and the account row offers `Per type…` when the dispatch has more than one agent type. 5. Either of those opens one third form, carrying the per-type account rows first and the per-task rows after them. Asking for neither never builds it. 6. Each subagent opencode starts spawns its own `claude` with the chosen `--model`, `CLAUDE_CODE_EFFORT_LEVEL` and account wrapper. Rules worth stating to a user: - A dispatch answer beats `forceModel`, `defaultSubagentModel` and the inherited effort. - A task whose `task` call names its own `model` (opencode 2) is not asked about, and a dispatch whose every task names one raises no form: the user already chose. - Any row takes a typed answer: a registered model (its id or the picker's name, so `fable 5.2 max` and `opus 5.5 / high` work), an effort level, an `@account`, or any combination (`claude-opus-5-5 max @worker`). Unrecognised text keeps that row's default with a NOTICE. - With opencode-dcp on opencode 2, plugin versions before the h #g312 fix read EVERY answer to this form (and to the account-switch form and the plan-mode approval) as a dismissal, logging `subagent dispatch form was dismissed`: dcp appends `\n@@` to the tool output and only its XML tag was stripped. Upgrade rather than work around it. - The account has three widths and the narrowest wins: the dispatch's `Account` row, the agent type (`Per type…` or `@name` on the type's row), and one task (`@name` on its row in the third form, which is how a single task gets its own account). - Dismissing or ignoring the form dispatches with the defaults and writes one `▌ **subagent dispatch:**` note. The dispatch is never lost. - Every account answer, offered or typed, is checked against the accounts in the dispatching account's own `accountGroups` group. `subagentDispatchCrossGroup: true` is the explicit, default-off opt-in for the rest; it does nothing when `accountGroups` is unset. - Never on compaction, never inside a child session, and only where opencode's registry has the `question` entry. - `Same as last time` is per opencode session and per agent type, kept in `$XDG_STATE_HOME/opencode-claude-code-plugin/subagent-dispatch.json`, so it survives an opencode restart and is deleted with the session. A remembered model or account that is no longer available is dropped and named in one note. ### Degrade to another model instead of failing ```yaml forceModel: claude-opus-5 fallbackModels: [claude-sonnet-5, claude-haiku-4-5] ``` Or as the default for every agent that declares none: ```json { "provider": { "claude-code": { "options": { "fallbackModels": ["claude-sonnet-5"] } } } } ``` Per-agent replaces provider-level; it never merges. Unset means no chain, which is the default. Two triggers only, never a generic error: the CLI refusing the model (assistant `error: "model_not_found"`, or a failed result whose text is *"There's an issue with the selected model"*, measured on CLI 2.1.280, where the result `subtype` is misleadingly `success`), and a usage limit **only when no `accountFailover` switch is taking the turn**, meaning it is `"off"` (its default) or has no other account to offer. With `"ask"` or `"auto"` and another eligible account configured the switch wins and the chain stays out of it: model is a capability choice, account is a billing choice. An expired login, a billing hold and every other error kind are excluded because they fail the same way on the next model. On a trigger the failed process is killed, its session id dropped, a fresh process spawns on the next model with the same account, effort and cwd, the conversation replays, and a `▌ **model fallback:**` note names the failed model, the reason and the serving model. The failed attempt's output is discarded entirely. Each model is tried at most once per turn; an exhausted chain surfaces the original error unchanged. Never on compaction turns, title stubs, or the interactive transport. Claude Code's own two fallbacks are separate (h #g300). A safety refusal never arms the chain, and Claude Code's refusal fallback (answer on another model, Opus 5.5 to Opus 4.8, and keep it for the process) is off through `CLAUDE_CODE_DISABLE_REFUSAL_FALLBACK=1`, filled in unless the user set it: the turn ends as an error with Claude Code's sentence. With the user's `0` it runs, a `▌ **refusal fallback:**` note names both models, and the spawn record (sidebar) and turn history name the model that answered until the process restarts or a model change is applied live. A reply Claude Code resent without streaming (404 on the streaming endpoint, or a stream cut before output) arrives as an `assistant` frame with no stream events of its own and is rendered; `CLAUDE_CODE_DISABLE_NONSTREAMING_FALLBACK` is not set, because it turns that answer into an error and does not cover the 404 case. ### Route a tool through opencode, or switch one off ```json { "proxyTools": ["Bash", "Edit", "Write", "WebFetch", "Task"], "extraDisallowedTools": ["NotebookEdit"] } ``` Preserve other wanted proxies when changing this replacement list. `Read`, `Glob` and `Grep` have tool mappings/disallowed-name entries but no selectable proxy definitions in this version, just like `NotebookEdit` has no proxy. Adding them to `proxyTools` warns and leaves the built-ins unproxied. Use `extraDisallowedTools` only to deliberately remove a capability; omission from `proxyTools` is not denial. The proxy's loopback endpoint has bearer, Host, Origin and Content-Type guards. Never weaken them, publish its token or relax the generated MCP file's `0600` mode. Restart all old processes after a security upgrade; changing files cannot patch them. Proxying a tool that is not always loaded costs **one extra Claude Code API call per `claude` process**: a proxied tool is an MCP tool, Claude Code 2.1.280 defers MCP tools behind `ToolSearch`, so the model spends a request finding it before the first proxied call. `bash`, `edit` and `write` are always loaded by default (`alwaysLoadProxyTools`) and skip it. Built-ins are never deferred. Measured on 2.1.280 (`docs/agents-history.md`, `#g166`): 3 API calls with `Bash` proxied against 2 without, and it is paid once per process, not per call (two commands measured 4 against 3, one `ToolSearch` either way). It is not caused by a large tool list. Never suggest `ENABLE_TOOL_SEARCH=0` to avoid it: that inlines every tool definition into each prompt and measured 2.5 to 4 times the cost. For a hot tool the user proxies beyond the default three, add it to `alwaysLoadProxyTools`; otherwise weigh the one call against the permission prompts and audit log proxying buys. ### Make a provider read-only ```json { "permissionPreset": "read-only" } ``` That one line is the whole posture. Do not also set `skipPermissions`, `permissionMode`, `controlRequestBehavior` or `controlRequestToolBehaviors` alongside it: the preset replaces all four and logs each value it dropped. `proxyTools` is filtered rather than replaced, so a list naming `Question` keeps it while `Bash`, `Edit`, `Write`, `WebFetch` and `Task` go, and `extraDisallowedTools` is added to rather than replaced, so names already listed there survive. Read-only is enforced at three layers because no single one covers the plugin: `--restricted` removes the CLI's own command and code-running tools, the `--disallowedTools` list covers CLIs older than 2.1.258, and the proxy defs are dropped before the MCP server is built because a proxied `bash` executes in opencode where no CLI flag reaches it. Anything left that would prompt is denied, so bridged MCP tools and the `question` proxy do not work under the preset; Claude's own `AskUserQuestion` still renders its stop-and-wait markdown. Pair it with a second provider entry when only some sessions should be read-only: `accounts` or `providerID` gives each its own model list. ### Let the model satisfy an opencode-dcp compress nudge DCP injects "MAX CONTEXT LIMIT REACHED ... You MUST use the `compress` tool now" reminders. DCP declares `compress` directly rather than through an MCP server, so automatic MCP routing never offers it and the model cannot obey. Two choices, and they are different tools, so choose one rather than both: ```json { "proxyOpencodeTools": ["compress"] } ``` forwards DCP's real tool, which compresses opencode's transcript with DCP's strategies. The live `claude` process keeps its own context until it restarts. ```json { "proxyTools": ["Bash", "Edit", "Write", "WebFetch", "Task", "Compress"] } ``` uses this plugin's tool instead, which resets the Claude session and carries a summary forward. Setting both leaves this one holding the `compress` name and logs `proxyOpencodeTools entry dropped`. If neither is wanted, `stripContextReminders: true` removes the reminders the model cannot act on. ### Proxy tool names Names below become `mcp__opencode_proxy__`; input config is case-insensitive. | Tool | Selection and behavior | |---|---| | `bash` | `"Bash"`, default; replaces CLI Bash with opencode execution. On opencode 2 only it also takes `background: true` (opencode 2's `shell` has it in every 2.x release; 1.x's `bash` has none, so the field is not offered there and the def is unchanged): the call returns at once with `Command moved to the background (shell ID: sh_...)` and the output file's path, and when the command ends opencode adds `` with its output to the session and starts a turn on it. No option. A proxy deadline covers only the starting call; opencode gives the command no timeout unless one is passed. The sidebar lists it as a `bg` row. | | `edit` | `"Edit"`, default; replaces CLI Edit. | | `write` | `"Write"`, default; replaces CLI Write. | | `webfetch` | `"WebFetch"`, default; replaces CLI WebFetch. | | `task` | `"Task"`, default; disables CLI Agent and dispatches opencode subagents under its permissions. No proxy deadline by default; a positive `proxyToolTimeoutMs` entry adds one. Takes `background: true` only on a host that runs background subagents and lets the model choose (1.x with the flag, opencode 2.0 to 2.2; on 2.3.0+ every dispatch is a background one and the field is gone, see below), and `model` only on opencode 2 (recipe "One subagent on a model the user names"). | | `task_batch` | Included with Task; one MCP call fans out two or more independent task inputs concurrently. Separate task calls were measured serial (2026-09-06, two 8-second calls: the second MCP request left the CLI 7 ms after the first resolved). The input must be a `tasks` array of at least two items, each with `description`, `prompt` and `subagent_type`; anything else is refused before the calls are queued. | | `task_status` | Included with Task, and only on a host that runs background subagents. Reads a background subagent's state by `task_id` and collects its result. A recovery path for a completion notification that never arrived, not a progress poll; a result is handed over once. Answered in-process (opencode has no such tool) and refuses any session that is not this conversation's subagent. Not nameable in `proxyTools`. | | `task_cancel` | Included with Task, same host gate as `task_status`. Aborts a background subagent's child session; a cancelled subagent sends no completion notification. | | `question` | `"Question"`, opt-in; replaces AskUserQuestion only if the live opencode registry has question. Round-trip verified on plugin 0.18.0 / CLI 2.1.258 / opencode 1.18.29, headless and as a real TUI form, with no `permission` block; grant `permission.question` only if a subagent's form is refused. Opt-in because it disables Claude's own AskUserQuestion. | | `compress` | `"Compress"`, opt-in; in-process summary/reset interceptor, no opencode permission prompt and no built-in replacement. Discards prior CLI detail on a later eligible turn, retaining the summary, not the full transcript. Keep off unless explicitly requested. Reset round-trip verified live on CLI 2.1.263 / opencode 1.18.31. Not the same tool as a forwarded opencode `compress` (see `proxyOpencodeTools`): this one resets the Claude session, that one compresses opencode's transcript. Enabling both leaves this one holding the name. | ### How a proxied call ends A proxied call is held open until an event ends it, and the plugin listens to the `claude` process, the stream and the control protocol for those events rather than inferring failure from elapsed time. opencode's result resolves the call. An abort interrupts the CLI and rejects the turn's pending calls, unless opencode still reports the session busy (opencode 1.18 aborts the signal of every tool step while it runs the tool, so busy means the call is being served, not refused). The next user message rejects what the previous turn left pending and tells the CLI. The process exiting, the chat being deleted, or opencode exiting rejects the rest. That is why `task` and `task_batch` carry no default deadline and a subagent runs to completion. Three timers remain and are distinct from that: the optional per-tool deadlines (`proxyToolTimeoutMs`, a backstop the user chooses), the start and inactivity watchdogs (for a process that is alive but silent, which emits nothing to listen to; a CLI parked in a proxied call is exempt), and the connection keepalives (SSE comments or JSON whitespace every 15 s, so the CLI's HTTP client does not give up on a long call; they never extend a deadline). A deadline that passes while opencode still reports the session busy (a permission prompt the user has not answered, or the tool still running) does not end the call: it logs `proxy call past its deadline, but opencode is still serving it; waiting` at WARN once and rechecks every minute. So an unanswered permission prompt is not a reason to raise `proxyToolTimeoutMs`, and a raised deadline is never the fix for a long subagent, because the default already waits for it. Two log lines report a call that is simply taking a while, and neither is a failure or ends a call: - `proxy call still waiting, no deadline`, WARN, after five minutes and every five minutes after, with tool, call id and elapsed time. Only a call whose resolved deadline is `0` reaches it, which by default means `task` and `task_batch`, and also any tool the user set to `0` in `proxyToolTimeoutMs`. - `proxy call still waiting, deadline approaching`, WARN, once, at 60% of that call's deadline, carrying `remainingMs` and naming `proxyToolTimeoutMs`. Deadlines under a minute are not announced, because there the notice and the rejection would arrive together. Use them, or `/claude-code-doctor`, to tell a working subagent from a wedged one before suggesting any timeout change. ### Background subagents (fire-and-collect) Off unless the **opencode process** has `OPENCODE_EXPERIMENTAL_BACKGROUND_SUBAGENTS=true` (or `OPENCODE_EXPERIMENTAL=true`) in its environment on opencode 1.x; unconditional on opencode 2.0 to 2.2; and from **opencode 2.3.0 every subagent runs in the background** (see "opencode 2.3.0 and later" below). It is opencode's feature, not this plugin's: the plugin only surfaces it. There is no provider option, and nothing in `opencode.json` can turn it on, because the flag is read by opencode itself at startup. ```sh OPENCODE_EXPERIMENTAL_BACKGROUND_SUBAGENTS=true opencode ``` With it set, `task` takes `background: true` and returns at once with `` instead of the subagent's answer. The model keeps working and ends its turn; when the child finishes, opencode prompts the same conversation with `...` as a new message. Delivery is automatic, so polling is wrong and the tool descriptions say so. `task_status` and `task_cancel` join the tool list, keyed on the `id` from that envelope (the child's opencode session id). opencode 2 uses different envelopes and the plugin's tool descriptions follow the host: there a background dispatch answers in prose, `The subagent is working in the background (sessionID: ses_...)`, and the completion arrives as ``. The `sessionID` is the `task_id`, and a cancel pushes the same envelope with `state="cancelled"`. Both extra tools work on both majors (on opencode 2 over `session.context` and `session.interrupt`, the session routes a plugin is given there); verified live on 2.0.22, and before that on 2.0.16. With `subagentDispatch: "ask"` a background dispatch is held for the same form a foreground one is and the answer reaches the background child's own spawn, with the dispatch itself unchanged. Without it, opencode rejects a `background: true` call outright (`Background subagents require OPENCODE_EXPERIMENTAL_BACKGROUND_SUBAGENTS=true`), losing the dispatch, so the plugin strips `background` from the `task` and `task_batch` schemas on such a host and registers neither extra tool. The plugin never reads that variable itself: it reads whether opencode's own advertised `task` schema carries a `background` property, which is how a 1.x host publishes the flag, and on opencode 2 it does not ask at all. Which way it went is in `plugin.log`: ``` background subagent gate {"supported":false,"registryResolved":true,"hostApi":"v1","note":"`background` stripped ..."} ``` **opencode 2.3.0 and later** removed the `subagent` tool's `background` input: every dispatch returns at once with the prose above, and the parent gets a `` message each time the child goes idle (again after a follow-up by its `sessionID`, and `state="running"` while the child's own background work is still going). The plugin reads opencode's version (the V2 plugin context's `app.version`, else `opencode --version`) and on 2.3.0+ strips `background` from `task` and every `task_batch` item, replaces "calls block until the subagent finishes" and "returns every result together" with what 2.3 does, sends a system hint with no "foreground is still the default", keeps `task_status` / `task_cancel` (which hand over each newer round of a child that ran again, once each) and counts every dispatch against `maxBackgroundSubagents`. 1.x and 2.0 to 2.2 are told what they were before. The log line says which: `background subagent gate {"mode":"always", "hostVersion":"2.3.2",...}`; the doctor adds an `every subagent runs in the background` row. A `background` field still reaching a 2.3 host (an older plugin) is dropped by opencode and changes nothing. **opencode 2.4.0 and later** write that report as `` (one tag for every kind of background work: `kind="shell"` reaches the session that ran the shell, and there are `image`, `video` and `codemode` kinds), with 2.3's states and the same dispatch prose (now ending `You will receive a message`). On 2.4.0+ the hint and the `task` / `task_batch` notes name that tag; the log line carries `"reports":"background-result"` (`"subagent"` before). Nothing else about the tools changes. Troubleshooting: `background` missing from the tool schema, or a refusal naming the env var, means the flag is not set on the opencode process (setting it in a shell after opencode started does nothing, and a plugin upgrade cannot change it). A `task_status` that answers `not a subagent of this conversation` means the id came from a different conversation. `/claude-code-doctor` has a **Background subagents** section answering the same question without reading the log: whether `background` was offered and the two tools registered, the opencode major, what decided it (the live `task` schema, a registry that did not answer, or opencode 2 offering it unconditionally), and the background tasks this process has collected or cancelled. The gate is read while a turn plans its proxy tools, so a fresh process reports `Not read yet this process` until one message has been sent. It opens with `running now: N (of M started by this process)`: the answer to "how many subagents are working at once" when a user worries about overloading the machine or the usage window. It counts only background dispatches Claude made through this opencode process, uses `task_status`'s own running test, and never collects a result. Claude is told the same number: an accepted background dispatch's result gets one trailing line, `Background subagents running now: N (including this one).` (one line per `task_batch`, `(including the 2 just started)`, also when one of its subagents failed and the batch is reported as an error). Foreground results and every other tool are unchanged. The lookup is bounded (four at a time, 500 ms in all) and the line is simply left out when it runs over or a child cannot be read, so a missing line is not a fault. There is no option for it. ### Subagents in the sidebar Always on, no option. While the viewed session has subagents, the sidebar ends with a `Subagents` section: one row each, running first (spinner in the theme accent), then up to three finished ones (✓ or ✗, greyed out, gone after ten minutes), with the agent type, the task description, a dim `bg` for background dispatches (every dispatch on opencode 2.3.0+, spinning until the child's own `` report, `` from 2.4.0, and again whenever opencode says the child is working or work it started still runs), and a muted second line `model · effort · account` (account only on a multi-account install; the effort alone in the theme's warning colour, faded on a finished row). That line is what the plugin really spawned, read from `$XDG_STATE_HOME/opencode-claude-code-plugin/session-spawns.json`, so `forceModel`, an agent's `reasoningEffort`, a dispatch-form answer, the fallback chain and a failover all show there, while opencode's own footer shows the model it asked for. The model line ends with the subagent's spend so far (`· $0.42`, opencode's own session cost, kept after it finishes; on a tight line the dot goes before the number does), and a running row gets a third line: the same progress line the viewed session gets above the section under a `Main Progress` heading while its turn runs (and 15 s after). That line is a ten-cell `▰▱` bar, two spaces, then the todo list's completed fraction with `2/4` when the session has one (opencode 1 only; opencode 2 exposes no todo list to a TUI plugin), else the turn's elapsed over its estimated total (`1m02s/~2m30s`), else no bar until three turns of that agent and model (or of that agent across its other models) are on record; plus the call count (when neither is shown) and the running tool. The estimate is a log-normal fitted to this agent and model's recorded turns in `$XDG_STATE_HOME/opencode-claude-code-plugin/turn-history.json` (written at every served result), weighted toward a prompt of about this length, this effort (another effort's turns at half weight, scaled by the measured duration ratio) and recent turns, borrowing the agent's other models for a new model and pulled toward this session's own earlier turns. It is conditioned on the turn's elapsed time, its tool calls and the output tokens it has generated, which the provider half writes per API call to `turn-progress.json` beside it. The bar's shades are the band (where the turn likely ends, calibrated on the estimate's own past misses), a turn waiting on a foreground subagent is floored at what that subagent has left, and past every recorded turn the bar is full in the warning colour. A turn that ended on a failed tool is never read. How far to trust it: `/claude-code-doctor`'s `Progress estimate` section (per agent and model: turns, typical, `off by`, `outran`, `in band`). No model call, no option, nothing read from the prompt but its length. Clicking a row opens the subagent's session; `up` returns to the parent. More than two rows fold behind a `▼` heading. Setup: nothing on opencode 2; on opencode 1 the `tui.json` line under Minimum install. If the section never appears on 1.x, that line is missing or opencode was not fully restarted. On opencode 2.2.6+ the same section also lists the session's **background shells**: a command moved to the background with `ctrl+b` while it ran, and a `!command` typed in the prompt. Row: `shell` (info colour), the command, `bg`; second line the elapsed time, then `exit 0` (✓), `exit N` / `timed out` / `killed` (✗) or `ended` (✓, no exit code seen) and how long it ran. A foreground call the model makes never gets a row (it is the running tool on the progress line); the rule is a running shell whose command matches no running `shell` tool part. No option, nothing written. On opencode 2.4 a click on a running shell row opens opencode's own shell output view (its composer's Shell tab, then the shell's output: live, `c`/`o` copy, `esc` closes); an ended shell's row opens nothing. On opencode 2 the proxied `bash` tool also takes `background: true`, so Claude can start one too. opencode's footer `↓ N shell` counts foreground ones too. **Work under a subagent** (opencode 2): a subagent's row keeps spinning while its own background shells or its own subagents run, even after the subagent itself went idle (the case that used to show no row at all while a director's renders ran), and that work is listed under the row as a tree: one line each (` ├ ⠋ shell ffmpeg … 12m03s bg`, ` └ ⠋ writer Write the … 2m10s bg`), a subagent's own work one level further in, a finished line kept for a minute while the row still runs, three lines then ` └ ▾ +N more`, two cells per level and at most three levels. A click on `▾ +N more` lists everything under that row in place (up to twenty lines, then ` ├ ▸ +N more · open session`, which opens the subagent) and ` └ ▴ show less` folds it back; the choice is per viewed session, in memory, and dropped once the row stops running with work under it. A finished row folds back to its single row; a row running only for its work has no progress line and never counts toward the three finished rows. A click on a nested line shows what it is doing: a nested subagent opens its session; a nested running shell opens the subagent that started it on its Shell tab with that shell's output view on top (opencode 2.4; measured on 2.4.2 and 2.4.3); an ended nested shell opens that subagent. opencode 2.4's session tabs (`tabs.mode`, `auto` is off inside herdr) change nothing: a subagent opens inside its top-level session's tab, and 2.4.3 draws the sidebar only on top-level sessions. On opencode 2.4.0+ it reads opencode's own running background jobs (`data.job.list`, owner `sessionID` on each) for the viewed session and every session below it, in any directory; on 2.2.6 to 2.3 each subagent's shells come from its own directory's shell list, listed once the subagent is idle (or earlier when its messages tell foreground calls apart). The 2.4 report form and every older one are read. opencode 1.x: unchanged. ### Let Claude load the user's opencode skills ```json { "bridgeOpencodeSkills": true } ``` The bridge is off by default. With it on, `Skill("")` works for any skill opencode advertises. Bridged names are `opencode-skills:`, including this bundled skill as `opencode-skills:claude-code-plugin`. The package also makes opencode itself list the bundled skill: on opencode 1.x by adding its directory to `skills.paths` in the config hook, on opencode 2 by registering it through the `skill` domain (a skill opencode already found under the same id is left alone). Older opencode versions may not support either surface. The native Claude bridge needs `--plugin-dir` support and is wired into the headless streaming and interactive spawns, never compaction. Set `true` only when the user asks for it, since a large skill set costs prompt tokens twice; the bundled skill is staged either way. Reusing a process does not load a new skill catalog. User roots, in precedence order: walking from cwd to filesystem root, `.opencode/skills` then `.claude/skills` then `.agents/skills` at each level; home `.opencode/skills`; `OPENCODE_CONFIG_DIR/{skills,skill}`; `XDG_CONFIG_HOME/opencode/{skills,skill}` (home `.config` fallback); then `~/.claude/skills` and `~/.agents/skills`. Those last two are opencode's external scans: `OPENCODE_DISABLE_EXTERNAL_SKILLS` drops both and `OPENCODE_DISABLE_CLAUDE_CODE_SKILLS` drops `~/.claude/skills` alone. Neither is ever reached through the walk-up, and a workspace that happens to BE the home directory does not smuggle them in early. First name wins, so a project shadows a global and an opencode-managed copy shadows an external one; enabled user bridging can shadow bundled names. A skill is known by the `name:` its SKILL.md frontmatter declares (directory basename when it declares none or an unusable one), which is the name opencode advertises. Only immediate `/SKILL.md` directories are collected; arbitrary `skills.paths` and `skills.urls` are not scanned. Those roots overlap Claude's own, so `bridgeSkipNativeSkills` (on by default) drops anything the session already loads rather than advertising it twice. If the user reports a skill that went missing, grep `plugin.log` for `skills claude code already loads` (one line naming both paths and the reason) or the `claude already registers a different skill under this name` warning, and only then consider `bridgeSkipNativeSkills: false`. Broad bridging can duplicate advertised skill context and exposes every discovered skill, not just one. ### Change when idle workers are freed ```json { "idleProcessTimeoutMs": 900000 } ``` Idle eviction is **off by default**. With the option unset, or set to `0`, a conversation's `claude` process is kept until the LRU cap evicts it, which is why many open chats cost memory: an idle `claude --print` holds roughly 250 MB. This example frees a worker fifteen minutes after its last turn ends; the session id is retained, so the next message resumes the same conversation through `--resume` and only pays for the spawn. The cap is 16 live processes, oldest idle first. Neither the timer nor the cap ever takes a worker mid-turn: a process found in flight when the timer fires is re-timed instead of killed, and a round where all 16 are busy evicts nothing and warns. ### Different `/compact` model ```json { "compactionModel": "claude-sonnet-5" } ``` This is more expensive per token than the Haiku default, not a cost-saving recipe. ### Debug logging ```json { "logging": { "file": true } } ``` Default destination: `~/.local/share/opencode-claude-code/plugin.log` (respect the configured/env directory). INFO is enough for startup diagnostics. Add `"level": "debug"` only if needed for lower-level events; `mode: "debug"` alone does not do that. Capture a bounded, redacted excerpt, then disable temporary logging and restart. Logs rotate above 5 MB to `plugin.log.1`, which can also contain private data. Never hand either file to anyone: for anything shared, use `/claude-code-doctor bundle`, which is redacted by allowlist (see "Filing an issue" below). ### Upgrade the plugin A published version does not reach a running opencode. First distinguish an npm pin, npm latest resolution, and a local `file://` install. Preserve a pin unless the user requested changing it. An `@latest` install is frozen in opencode's package cache, and a plain restart never re-resolves it: removing that one directory and then fully relaunching is what picks a new version up. The directory differs per major: `~/.cache/opencode/packages/@khalilgharbaoui/opencode-claude-code-plugin@latest/` on opencode 1.x, `~/.cache/opencode/npm/@khalilgharbaoui/opencode-claude-code-plugin@latest/` on opencode 2.x. On opencode 2.1.4 `opencode plugin check` and `opencode plugin update` do not see this plugin, so they cannot refresh it. A registry proxy or security agent with a minimum package age can hide a new release for hours; opencode then caches the older version it resolved, so remove the entry again once the release is visible. Inspect the actual cache location and package identity and get approval before removing only that stale package directory, never the whole cache or auth/session directories. Respect platform/XDG paths (`XDG_CACHE_HOME` moves it). Then fully relaunch every opencode window, including serve and GUI processes. A `file://` install uses the checkout's `dist/`: rebuild with `npm run build`, not cache deletion. On opencode 2, from plugin 0.63.0, the rebuild applies by itself: opencode re-imports the changed build within a second, and the first turn that finds no older build with work in flight switches to it, each conversation resuming its Claude session there (`switched to the newest plugin build` in `plugin.log`). That needs the FIRST build the process loaded to be 0.63.0 or later, so one restart after upgrading to it. On opencode 1, restart after approval. No manual skill copy/update is needed. Do not publish or release as part of configuring. ## Models and variants ### Registered model ids Registered ids: `claude-haiku-4-5`, `claude-haiku-5-5`, `claude-sonnet-4-6`, `claude-sonnet-5`, `claude-sonnet-5-5`, `claude-opus-4-5`, `claude-opus-4-6`, `claude-opus-4-7`, `claude-opus-4-8`, `claude-opus-5`, `claude-opus-5-fast`, `claude-opus-5-5`, `claude-opus-5-5-fast`, `claude-fable-5`, `claude-fable-5-1`, `claude-fable-5-2`, `claude-fable-5-2-fast`, `claude-mythos-5`, `claude-mythos-5-1`, `claude-mythos-5-2`, `claude-mythos-5-2-fast`. With `cliModelCatalog` on (the default), a model the installed CLI's own picker offers that this list lacks is registered too, named from the CLI, at an unknown (zero) price. ### Variants and costs - Display names end in a `(N×)` list-price multiplier anchored on Haiku 4.5: 0.1× haiku 5.5, 1× haiku 4.5, 2× sonnet 5 and 5.5, 3× sonnet 4.6, 4× opus 5.5, 5× other opus, 8× fast-mode opus 5.5 and fable/mythos 5.2, 10× fable, mythos 5 / 5.1 and fast-mode opus 5, 16× fast-mode fable/mythos 5.2. It is display only. - Reasoning variants are the effort levels Claude Code accepts for that model, because the CLI silently runs a level a model lacks as `high` (read out of 2.1.314): none for Haiku 4.5, `low`/`medium`/`high` for Opus 4.5, `low`/`medium`/`high`/`max` for Sonnet 4.6 and Opus 4.6, and all five (`low`, `medium`, `high`, `xhigh`, `max`) for everything newer. With `cliModelCatalog` on they follow the installed CLI's own list. They are picked in opencode's model selector. A variant becomes `CLAUDE_CODE_EFFORT_LEVEL` on the spawned CLI unless an agent effort wins. For direct AI-SDK calls, `ClaudeCodeCallOptions.reasoningEffort` supports the same levels plus `minimal` (mapped to `low`); it is not a provider startup option. - The `-fast` ids are this plugin's own markers. They spawn the base model with `--settings '{"fastMode":true}'` (Claude Code 2.1.220+). Fast mode fails soft: an ineligible account runs at standard speed and the plugin logs a warning naming the reason, read off the terminal `result` rather than the `system`/`init` frame, which is optimistic (2.1.288 says `"on"` at init and `"off" / extra_usage_disabled` at the end for an account with usage credits off). Switch to a non-fast id rather than silently enabling paid usage credits. Review eligibility/billing with the user; the enabled state needs live verification on their account. CLI floors are gates, not proof of model access. - `claude-opus-4-8-fast` is retired and no longer registered: Anthropic removes Opus 4.8's fast mode on 2026-11-30, after which a fast request on it is an API error with no fallback (Claude Code 2.1.316's changelog), and the CLI still sends it. Named in `forceModel`, `defaultSubagentModel`, `fallbackModels` or a user-registered model entry, it runs `claude-opus-4-8` at standard speed and price with one WARN (`this fast-mode model id is retired`) naming `claude-opus-5-5-fast`. opencode refuses it in an agent's `model:` or the top-level `model`: change those to `claude-opus-5-5-fast` or `claude-opus-4-8`. - `claude-sonnet-4-5` (and its dated `claude-sonnet-4-5-20250929`) is retired and no longer registered: Anthropic retires Sonnet 4.5 on the Claude API on 2026-11-30, after which a request to it fails, and Claude Code's own remap of retired ids covers Opus 4 and 4.1 only. Named in `forceModel`, `defaultSubagentModel`, `fallbackModels`, `compactionModel`, `titleModel` or a user-registered model entry, it runs `claude-sonnet-5-5` with one WARN (`claude-sonnet-4-5 is retired on the Claude API`) naming the replacement and both prices ($2/$10 against $3/$15). opencode refuses it in an agent's `model:` or the top-level `model`: change those to `claude-sonnet-5-5`. - `claude-sonnet-5-5` is $2/$10 like Sonnet 5, but its cache reads are $0.10 (0.05x input, like Opus 5.5) where Sonnet 5's are $0.20; both have 5-minute writes at $2.50 and 1-hour writes at $4. - `claude-sonnet-5-5` needs Claude Code 2.1.284+ to run on its real limits. An older CLI still serves it on fallback limits (200k context, an estimated cost), and the plugin logs a WARN naming the model and the floor: the fix is `claude update`. - `claude-haiku-5-5` needs Claude Code 2.1.293+ for the same reason, the release that added it and made it the default Haiku. It is a tenth of Haiku 4.5 ($0.10/$0.50), has a 1M context, 128k output and adaptive thinking, so it carries reasoning variants where Haiku 4.5 does not, and it has no `-fast` id (the CLI's catalog gives it no fast-mode capability). It is the only model Anthropic prices by prompt length: over **100,000 prompt tokens** (input plus cache read plus cache write) the whole call bills at 5× ($0.50/$2.50). The registered cost is the base rate, because opencode's only tier field is fixed at 200,000 tokens; the interactive transport's own per-turn cost does apply the tier. Tell the user to budget for up to 5× on long prompts. - `claude-fable-5-2` and `claude-mythos-5-2` ($8/$40, 1-hour cache writes $16, cache reads $0.20) need Claude Code 2.1.321+, the release that added them; an older CLI serves them on fallback limits (200k). Their `-fast` ids ($16/$80) need the same release: below it the CLI refuses them fast mode and the plugin warns. Claude Code 2.1.314 names `claude-fable-5-2` "Fable" in its model list although it does not know it, so the model probe goes by the CHANGELOG release, not that name. - `claude-mythos-5` and `claude-mythos-5-1` are limited availability (Project Glasswing), `claude-mythos-5-2` to organizations verified through Anthropic's verification programs. Without access `claude --model` errors; use the corresponding `claude-fable-*`. - Ordinary calls can pass through unregistered ids; availability and opencode model registration still need checking. `forceModel`/`defaultSubagentModel` reject those ids. - Registry costs are USD per million tokens, not subscription quota or a billing guarantee. Fast entries have fast pricing; other entries use standard rates. There is no above-200K tier in this registry; do not invent `cost.tiers` or `cost.experimentalOver200K`. 4.5 models have 200K context/64K output; Sonnet 4.6 and Opus 4.6 have 200K/128K, because Claude Code runs them in a 200K window (their 1M window is the `[1m]` id, which is not registered); later models have 1M/128K. With `cliModelCatalog` on the window is the one the installed CLI reports. Recheck vendor pricing/access separately when changing models. ## Verify and diagnose Offline first: validate edited JSON/JSONC without starting opencode; inspect installed package metadata. `claude --version` / `claude --help` on the trusted configured binary and `opencode --version` do not request model inference. Do not invoke a model merely to test configuration. A paid smoke test requires explicit approval and a bounded task. If diagnostic logging was approved, find the newest matching `NOTICE: claude-code plugin ready` entry for the restarted process (INFO threshold includes NOTICE). Do not paste the entire log or raw spawn arguments. Fields: `plugin` (version actually loaded), `opencode`, `cwd.resolved` and `cwd.source` (`configured`, `process`, `captured`, `unresolved`), `providers`, `accounts`, `proxyTools`, `mcpServers`, `permissionPresets` (one row per provider: `{provider, preset, applied, overrides}`, `preset: "none"` where unset, `applied: false` for `none` and for an unrecognised name, `overrides` naming the options an applied preset replaced), `interactiveTransport`, `planModeQuestion`, `anthropicApiKeyInEnv`, `claudeCli.path` and `.version` (`not detected` means the binary did not answer `--version`, which also disables version-gated flags). Cwd is a startup fallback snapshot, not the per-session spawn directory. MCP names are disk discovery, not proof of live connectivity. The startup `transport` field is the requested mode (`auto` / `headless` / `interactive` / `invalid`, resolved as the provider resolves it) and `interactiveTransport` is true when `interactive` was requested by either spelling; neither proves the PTY ran (`auto` stays headless until the CLI refuses `--print`). `/claude-code-doctor`'s live-process rows carry a per-process transport column, which is the proof; the spawn log line is the other. The PTY was measured on Claude Code 2.1.293: a newer CLI logs one WARN per version ("has not been measured") and the doctor flags it, but nothing is refused. Useful log lines to search for (redact payloads): `spawning new claude process`, `bridged opencode skills into claude`, `interrupt sent for aborted turn`, `btw:`, `rendering opencode-side tool result as text`, `proxy-mcp tool call received`, `evicting idle claude process`, `evicting LRU claude process`, `background subagent gate`, `task model gate`, `bare task model completed`, `explicit task model claimed by its child session`, `task model refused`, `proxy call still waiting`, `fast mode` warnings. Version requirements. The first four are flag gates in `src/cli-version.ts`; the last two are model floors enforced outside the plugin. Check with `claude --version`; a binary that does not answer it disables every gated flag. | Claude Code CLI | What it gates | |---|---| | 2.1.142+ | `--thinking-display summarized`, so Opus 4.7 thinking summaries | | 2.1.220+ | fast mode, which is `--settings '{"fastMode":true}'` | | 2.1.258+ | `--restricted` (the first layer of `permissionPreset: "read-only"`) and the `side_question` control request behind `/btw` | | 2.1.263+ | `--permission-prompts none` (the second read-only layer) | | 2.1.280+ | `claude-opus-5-5`; the API rejects it from an older CLI with a 400 naming that floor | | 2.1.284+ | `claude-sonnet-5-5` on its real limits; an older CLI still runs it, on fallback limits, and the plugin warns | | 2.1.293+ | `claude-haiku-5-5` on its real limits, same fallback and warning | Below a flag gate the plugin drops the flag rather than failing the spawn, and says so at WARN. `--plugin-dir` (the skill bridge) has no published version marker, so it is probed through the binary's own `--help` instead of a semver threshold. Only if a proxy security check is specifically requested: identify the exact local proxy port first, not every opencode listener. An unauthenticated `initialize` with the correct `127.0.0.1:` Host, no Origin and JSON Content-Type should get `401`. `200` on a confirmed proxy endpoint is unsafe; restart/upgrade. Other status codes alone do not prove it patched. Never call `tools/call` or obtain the bearer to probe. `/claude-code-doctor` prints the same fields as the startup block plus live runtime state, in the chat, with no model inference and at zero tokens: plugin/opencode/CLI versions, cwd and its resolution tier, providers, accounts, `proxyTools`, disk MCP servers, the `permissionPreset` in force per provider (`provider: preset`, `none` where unset, an unknown name marked `(unknown, nothing applied)`, plus a **Permission preset overrides** block listing what an applied preset replaced), transport, `planModeQuestion`, `turnStats`, whether an `ANTHROPIC_API_KEY` is present (never its value), the live `claude` processes (opencode session, model, pid, in flight, age, effort), pending proxy calls with their deadlines (`none` for a deadline-free `task`), one unauthenticated `initialize` against each proxy URL (`401, good`; anything else is flagged unsafe), and the last stderr of any child that produced some. Prefer it over asking for `plugin.log` for a first look. It carries no bearer token, no key value and no system prompt. A user-defined `claude-code-doctor` command is never overwritten. The name has no space in it: opencode would read the second word as an argument. Diagnostics remain accessible when Bun PTY support is missing or an interactive permission posture is refused. The transport row is not evidence that a child started; for `auto`, check an actual spawn entry after an approved normal turn. The `plugin build` row, directly under `plugin`, is the one field that says whether the version above it is the code actually answering. It compares the build this opencode process loaded at startup with the one on disk right now and reads `current`, `on disk . Restart opencode to run it`, `the same version was rebuilt on disk at