Format
OpenCode supports both JSON and JSONC (JSON with Comments) configuration files.opencode.jsonc
Locations
OpenCode loads global configuration from:opencode.json(c) files
from the project root toward the current directory, then does the same for
files inside .opencode directories. A .opencode config therefore overrides
every direct config, even when the direct config is closer to the current
directory. Avoid mixing the two forms across one project hierarchy unless this
precedence is intentional.
For example, consider a monorepo with OpenCode started from
/home/user/projects/acme/packages/web:
~/.config/opencode/opencode.json/home/user/projects/acme/opencode.json/home/user/projects/acme/packages/web/opencode.json
Schema
The complete OpenCode configuration schema is available at opencode.ai/config.json. Add the$schema field to your configuration file to enable validation and
autocomplete in editors that support JSON Schema:
opencode.json
Shell
Set the shell used by the terminal and shell tools.Model
Set the default model inprovider/model format. The root default currently
does not retain a #variant; select variants in the TUI or on an agent or command.
Default agent
Choose the primary agent used when a session does not select one explicitly.Autoupdate
Control automatic updates from the global config. Set this tofalse to
disable updates. The current beta treats true and "notify" identically and
automatically installs compatible non-major updates; project-level values are
ignored.
Sharing
Set the intended session sharing policy. V2 accepts this field, but session sharing is not implemented yet.Username
Set a username for future display behavior. V2 accepts this field but does not currently display it in conversations.Permissions
Define ordered rules that allow, deny, or ask before an agent uses a tool on a matching resource.Agents
Override built-in agents or define specialized agents with their own model, instructions, mode, and permissions.Snapshots
Enable or disable filesystem snapshots used by undo and revert behavior.Watcher
Ignore files and directories that should not trigger filesystem updates.Formatter
Define formatter settings for compatibility and future use. V2 accepts this field, but it does not run formatters yet.LSP
Define language server settings for compatibility and future use. V2 accepts this field, but it does not start language servers yet.Attachments
Control how oversized images loaded by theread tool are resized or rejected
before they are sent to a model.
Tool output
Set the maximum number of lines and bytes retained from a tool result.MCP
Configure local and remote Model Context Protocol servers. Global timeouts can be overridden by an individual server.Compaction
Control automatic context compaction and how much recent context it preserves.Session warming
Keep recently active model sessions warm with periodic transient requests. Warming is disabled by default; set it totrue to use the four-minute idle
interval and 30-minute active window.
Skills
Add directories or URLs that OpenCode should search for agent skills..opencode/skills/.
Commands
Define reusable slash commands as named prompt templates.Instructions
Declare additional instruction files, globs, or URLs. V2 accepts this field, but does not load these entries yet; useAGENTS.md for active instructions.
AGENTS.md.