Configuring opencode: opencode.json in depth
IntermediateLast updated: Oct 21, 2026
opencode is configured by opencode.json or opencode.jsonc (JSON with comments). Add $schema and your editor gets validation and autocomplete:
{
"$schema": "https://opencode.ai/config.json",
"model": "anthropic/claude-sonnet-4-5",
"autoupdate": true,
"server": { "port": 4096 }
}
Locations and precedence
Configs are merged, not replaced. Later sources win only on conflicting keys. Load order (later overrides earlier):
- Remote config —
.well-known/opencodeon a domain, for org defaults - Global config —
~/.config/opencode/opencode.json - Custom path —
OPENCODE_CONFIGenv var - Project config —
opencode.jsonin the project root .opencodedirectories —agents/,commands/,modes/,plugins/,skills/,themes/,tools/(plural names; singular also works)- Custom directory —
OPENCODE_CONFIG_DIRenv var: a whole extra config directory, loaded after global +.opencodedirs - Inline config —
OPENCODE_CONFIG_CONTENTenv var - Managed config — admin-controlled files
- macOS managed preferences — MDM, highest priority
So: global defaults → project overrides → managed policies on top.
The keys that matter
model/small_model— default model and the cheap model for small tasks, inprovider/modelform.provider— provider-specific options (API keys can also come from env vars; see the providers doc).agent— define or override agents;default_agentpicks the primary one.mcp— MCP server definitions (localcommand-based orremoteURL-based).plugin— npm plugin packages loaded at startup (see the plugin guide).permission— granular tool permissions (edit, shell, webfetch, etc. — the shell tool was renamed frombash; see the permissions guide).formatter— code formatters per language.lsp— LSP server overrides.tools— enable/disable individual built-in tools.command— define or override slash commands inline (see the commands guide).snapshot— file snapshot/revert tracking.autoupdate— self-update on launch.theme,keybinds,tui— deprecated insideopencode.json; migrated automatically (see below).disabled_providers/enabled_providers— restrict the provider list.instructions— extra instruction files beyondAGENTS.md.
TUI config is a separate file
Interface settings live in tui.json / tui.jsonc — scroll speed, diff style, cursor style, mouse, and desktop attention notifications:
{
"$schema": "https://opencode.ai/tui.json",
"scroll_speed": 3,
"diff_style": "auto",
"cursor": { "style": "block", "blinking": true },
"attention": { "enabled": true, "notifications": true, "sound": true }
}
Point OPENCODE_TUI_CONFIG at a custom path to override. Legacy theme/keybinds/tui keys in opencode.json are auto-migrated where possible.
Team tips
- Commit project
opencode.jsonfor shared defaults; keep personal overrides in the global file. - A domain can publish org defaults at
/.well-known/opencode— merged under global config. - Environment variables can carry secrets so keys stay out of committed files.