Format
OpenCode supports both JSON and JSONC (JSON with Comments) formats.opencode.jsonc
Locations
You can place your config in a couple of different locations and they have a different order of precedence.Configuration files are merged together, not replaced.
theme: "opencode" and autoupdate: true, and your project config sets model: "anthropic/claude-sonnet-4-5", the final configuration will include all three settings.
Precedence order
Config sources are loaded in this order (later sources override earlier ones):- Remote config (from
.well-known/opencode) - organizational defaults - Global config (
~/.config/opencode/opencode.json) - user preferences - Custom config (
OPENCODE_CONFIGenv var) - custom overrides - Project config (
opencode.jsonin project) - project-specific settings .opencodedirectories - agents, commands, plugins- Inline config (
OPENCODE_CONFIG_CONTENTenv var) - runtime overrides
The
.opencode and ~/.config/opencode directories use plural names for subdirectories: agents/, commands/, modes/, plugins/, skills/, tools/, and themes/. Singular names (e.g., agent/) are also supported for backwards compatibility.Remote
Organizations can provide default configuration via the.well-known/opencode endpoint. This is fetched automatically when you authenticate with a provider that supports it.
Remote config is loaded first, serving as the base layer. All other config sources (global, project) can override these defaults.
For example, if your organization provides MCP servers that are disabled by default:
Remote config from .well-known/opencode
opencode.json
Global
Place your global OpenCode config in~/.config/opencode/opencode.json. Use global config for user-wide preferences like themes, providers, or keybinds.
Global config overrides remote organizational defaults.
Per project
Addopencode.json in your project root. Project config has the highest precedence among standard config files - it overrides both global and remote configs.
When OpenCode starts up, it looks for a config file in the current directory or traverse up to the nearest Git directory.
This is also safe to be checked into Git and uses the same schema as the global one.
Custom path
Specify a custom config file path using theOPENCODE_CONFIG environment variable.
Custom directory
Specify a custom config directory using theOPENCODE_CONFIG_DIR environment variable. This directory will be searched for agents, commands, modes, and plugins just like the standard .opencode directory, and should follow the same structure.
.opencode directories, so it can override their settings.
Schema
The config file has a schema that’s defined inopencode.ai/config.json.
Your editor should be able to validate and autocomplete based on the schema.
Configuration Options
TUI
You can configure TUI-specific settings through thetui option.
opencode.json
Enable macOS-style scroll acceleration. Takes precedence over
scroll_speed.Custom scroll speed multiplier (minimum:
1). Ignored if scroll_acceleration.enabled is true.Control diff rendering.
"auto" adapts to terminal width, "stacked" always shows single column.Server
You can configure server settings for theopencode serve and opencode web commands through the server option.
opencode.json
Port to listen on.
Hostname to listen on. When
mdns is enabled and no hostname is set, defaults to 0.0.0.0.Enable mDNS service discovery. This allows other devices on the network to discover your OpenCode server.
Custom domain name for mDNS service. Useful for running multiple instances on the same network.
Additional origins to allow for CORS when using the HTTP server from a browser-based client. Values must be full origins (scheme + host + optional port), eg
https://app.example.com.Tools
You can manage the tools an LLM can use through thetools option.
opencode.json
Models
You can configure the providers and models you want to use in your OpenCode config through theprovider, model and small_model options.
opencode.json
small_model option configures a separate model for lightweight tasks like title generation. By default, OpenCode tries to use a cheaper model if one is available from your provider, otherwise it falls back to your main model.
Provider options can include timeout and setCacheKey:
opencode.json
Request timeout in milliseconds. Set to
false to disable.Ensure a cache key is always set for designated provider.
Provider-Specific Options
Some providers support additional configuration options beyond the generictimeout and apiKey settings.
Amazon Bedrock
Amazon Bedrock supports AWS-specific configuration:opencode.json
AWS region for Bedrock (defaults to
AWS_REGION env var or us-east-1).AWS named profile from
~/.aws/credentials (defaults to AWS_PROFILE env var).Custom endpoint URL for VPC endpoints. This is an alias for the generic
baseURL option using AWS-specific terminology. If both are specified, endpoint takes precedence.Bearer tokens (
AWS_BEARER_TOKEN_BEDROCK or /connect) take precedence over profile-based authentication.Themes
You can configure the theme you want to use in your OpenCode config through thetheme option.
opencode.json
Agents
You can configure specialized agents for specific tasks through theagent option.
opencode.jsonc
~/.config/opencode/agents/ or .opencode/agents/.
Default agent
You can set the default agent using thedefault_agent option. This determines which agent is used when none is explicitly specified.
opencode.json
"build" or "plan", or a custom agent you’ve defined. If the specified agent doesn’t exist or is a subagent, OpenCode will fall back to "build" with a warning.
This setting applies across all interfaces: TUI, CLI (opencode run), desktop app, and GitHub Action.
Sharing
You can configure the share feature through theshare option.
opencode.json
"manual"- Allow manual sharing via commands (default)"auto"- Automatically share new conversations"disabled"- Disable sharing entirely
/share command.
Commands
You can configure custom commands for repetitive tasks through thecommand option.
opencode.jsonc
~/.config/opencode/commands/ or .opencode/commands/.
Keybinds
You can customize your keybinds through thekeybinds option.
opencode.json
Autoupdate
OpenCode will automatically download any new updates when it starts up. You can disable this with theautoupdate option.
opencode.json
autoupdate to "notify".
This only works if it was not installed using a package manager such as Homebrew.
Formatters
You can configure code formatters through theformatter option.
opencode.json
Permissions
By default, opencode allows all operations without requiring explicit approval. You can change this using thepermission option.
For example, to ensure that the edit and bash tools require user approval:
opencode.json
Compaction
You can control context compaction behavior through thecompaction option.
opencode.json
Automatically compact the session when context is full.
Remove old tool outputs to save tokens.
Token buffer for compaction. Leaves enough window to avoid overflow during compaction.
Watcher
You can configure file watcher ignore patterns through thewatcher option.
opencode.json
MCP servers
You can configure MCP servers you want to use through themcp option.
opencode.json
Plugins
Plugins extend OpenCode with custom tools, hooks, and integrations. Place plugin files in.opencode/plugins/ or ~/.config/opencode/plugins/. You can also load plugins from npm through the plugin option.
opencode.json
Instructions
You can configure the instructions for the model you’re using through theinstructions option.
opencode.json
Disabled providers
You can disable providers that are loaded automatically through thedisabled_providers option. This is useful when you want to prevent certain providers from being loaded even if their credentials are available.
opencode.json
The
disabled_providers takes priority over enabled_providers.disabled_providers option accepts an array of provider IDs. When a provider is disabled:
- It won’t be loaded even if environment variables are set.
- It won’t be loaded even if API keys are configured through the
/connectcommand. - The provider’s models won’t appear in the model selection list.
Enabled providers
You can specify an allowlist of providers through theenabled_providers option. When set, only the specified providers will be enabled and all others will be ignored.
opencode.json
The
disabled_providers takes priority over enabled_providers.enabled_providers and disabled_providers, the disabled_providers takes priority for backwards compatibility.
Experimental
Theexperimental key contains options that are under active development.
opencode.json
Variables
You can use variable substitution in your config files to reference environment variables and file contents.Env vars
Use{env:VARIABLE_NAME} to substitute environment variables:
opencode.json
Files
Use{file:path/to/file} to substitute the contents of a file:
opencode.json
- Relative to the config file directory
- Or absolute paths starting with
/or~
- Keeping sensitive data like API keys in separate files.
- Including large instruction files without cluttering your config.
- Sharing common configuration snippets across multiple config files.