Skip to content

opencode.json Configuration Reference

This document is the complete reference manual for the OpenCode configuration file, explaining every field available in opencode.json.

📝 Course Notes

Key takeaways from this lesson:

Configuration Options Reference Notes


Configuration File Location and Priority

OpenCode loads configuration in the following order (priority from low to high, later overrides earlier):

PriorityLocationDescription
1 (lowest)Remote .well-known/opencodeRemote organization default config (obtained via Auth mechanism)
2~/.config/opencode/opencode.jsonGlobal user configuration
3OPENCODE_CONFIG environment variableCustom configuration file path
4./opencode.jsonProject root directory configuration
5./.opencode/opencode.jsonProject .opencode directory configuration
6OPENCODE_CONFIG_CONTENT environment variableInline configuration content (JSON string)
7 (highest)Managed configuration directoryEnterprise deployment, administrator controlled

Managed Configuration Directory (enterprise deployment, highest priority):

PlatformPath
macOS/Library/Application Support/opencode
Windows%ProgramData%\opencode
Linux/etc/opencode

Top Level Configuration

Fields contained in the root object of the configuration file.

Basic Settings

FieldTypeDescriptionDefault
usernamestringUsername displayed in conversations. If not set, uses system username.System user
themestringInterface theme name. See Theme List.-
autoupdateboolean | "notify"Auto-update behavior. true=auto update, false=disabled, "notify"=notify only.-
logLevelenumLog level. Options: "DEBUG", "INFO", "WARN", "ERROR".-
snapshotbooleanWhether to enable Git snapshot backup mechanism. Set to false to disable.Enabled when not set

Model and Agent

FieldTypeDescription
modelstringPrimary model ID (format: provider/model), used for complex tasks.
small_modelstringSmall model ID, used for simple tasks like title generation, summaries, etc.
default_agentstringDefault Primary Agent name to start. Defaults to build.

Behavior Control

FieldTypeDescriptionDefault
shareenumSession sharing behavior. "manual", "auto", "disabled"."manual"
disabled_providersstring[]List of disabled providers. Won't load even with API key.[]
enabled_providersstring[]List of only enabled providers. When set, providers not in list are ignored.-

Interface Configuration (tui)

Controls Terminal User Interface (TUI) display behavior.

json
"tui": {
  "scroll_speed": 3,
  "diff_style": "auto"
}
FieldTypeDescriptionDefault
scroll_speednumberMouse wheel scroll speed multiplier (minimum 0.001).3
scroll_accelerationobjectScroll acceleration configuration.-
scroll_acceleration.enabledbooleanWhether to enable macOS-style inertial scrolling acceleration.false
diff_styleenumDiff display style. "auto"(adaptive), "stacked"(always single column)."auto"

Provider Configuration (provider)

Configure model provider API keys, endpoints, and model parameters.

Key name: provider (singular)
Type: Record<string, ProviderConfig>

json
"provider": {
  "anthropic": {
    "options": {
      "apiKey": "sk-...",
      "timeout": 600000
    }
  }
}

Common Options (options)

options fields supported by all providers:

FieldTypeDescription
apiKeystringAPI key. Recommend using {env:VAR} to reference environment variables.
baseURLstringCustom API endpoint address (for proxies or compatible services).
timeoutnumber | falseRequest timeout (milliseconds). Default 300000 (5 minutes). false disables timeout.
setCacheKeybooleanWhether to enable Prompt Cache key (for Anthropic/DeepSeek etc.). Default false.
enterpriseUrlstringGitHub Enterprise URL (Copilot Provider only).

Provider-level Fields

The Provider object itself also supports the following fields:

FieldTypeDescription
namestringProvider display name.
envstring[]Environment variable names list (for auto-detecting API key).
whiteliststring[]List of only allowed models.
blackliststring[]List of prohibited models.

Model-specific Configuration (models)

Fine-tune specific models:

json
"provider": {
  "anthropic": {
    "models": {
      "claude-3-7-sonnet": {
        "variants": {
          "thinking": { "disabled": true }
        }
      }
    }
  }
}

Agent Configuration (agent)

Define or override Agent behavior.

Key name: agent (singular)
Type: Record<string, AgentConfig>

json
"agent": {
  "code-reviewer": {
    "mode": "subagent",
    "prompt": "You are a code reviewer...",
    "permission": { "edit": "deny" }
  }
}
FieldTypeDescription
descriptionstringBrief description of the Agent, shown in /agent list.
modeenumAgent type. "primary"(standalone), "subagent", "all".
modelstringModel ID specific to this Agent.
variantstringDefault model variant (only effective when using the model configured for this Agent).
promptstringSystem Prompt (persona instructions).
temperaturenumberTemperature coefficient (0.0 - 1.0).
top_pnumberNucleus sampling parameter (0.0 - 1.0).
stepsnumberMaximum automatic iteration steps.
colorstringDisplay color in interface (Hex format, e.g. #FF0000), or theme color name (e.g. primary).
hiddenbooleanWhether to hide this Agent in @ autocomplete menu.
permissionobjectAgent-specific permission configuration (overrides global permissions).
disablebooleanWhether to disable this Agent.

Permission Configuration (permission)

Control OpenCode's access to system resources.

Key name: permission (singular)
Type: Record<string, Rule | Action>

Value can be one of the following strings (Action):

  • "allow": Auto-allow
  • "ask": Ask each time
  • "deny": Deny

Can also be an object (Rule) for finer control.

json
"permission": {
  "edit": "ask",
  "bash": {
    "*": "ask",
    "git *": "allow",
    "rm *": "deny"
  }
}

Available Permissions:

  • read: Read files
  • edit: Edit/write files
  • bash: Execute commands
  • glob: File search
  • grep: Content search
  • list: List directory
  • task: Call sub-Agent
  • external_directory: Access external directories
  • todowrite: TODO write
  • todoread: TODO read
  • question: Question tool
  • webfetch: Access web pages
  • websearch: Search engine
  • codesearch: Code search
  • lsp: LSP operations
  • doom_loop: Infinite loop detection
  • skill: Skill invocation

Command Configuration (command)

Define custom slash commands.

Key name: command (singular)
Type: Record<string, CommandConfig>

json
"command": {
  "commit": {
    "template": "Generate a commit message for these changes:\n$DIFF",
    "agent": "build"
  }
}
FieldTypeDescription
templatestringPrompt template. Supports variables like $ARGUMENTS.
descriptionstringCommand description.
agentstringAgent to execute this command.
modelstringModel to execute this command.
subtaskbooleanWhether to run as a subtask.

Keybinds Configuration (keybinds)

Customize keyboard shortcuts.

Key name: keybinds (plural)

json
"keybinds": {
  "leader": "ctrl+x",
  "session_new": "<leader>n"
}

Common options (see Keybinds Reference for complete list):

  • leader: Prefix key (default ctrl+x)
  • app_exit: Exit application
  • session_new: New session
  • session_list: Session list
  • model_list: Switch model
  • agent_list: Switch Agent
  • input_submit: Send message
  • input_newline: New line

Server Configuration (server)

Configure opencode serve or opencode web behavior.

json
"server": {
  "port": 4096,
  "hostname": "0.0.0.0",
  "mdns": true,
  "mdnsDomain": "opencode.local"
}
FieldTypeDescriptionDefault
portnumberListen port.4096
hostnamestringListen address. Defaults to 0.0.0.0 when mdns is enabled.127.0.0.1
mdnsbooleanWhether to enable mDNS local network discovery.false
mdnsDomainstringCustom domain for mDNS service.opencode.local
corsstring[]List of origins allowed for CORS requests.-

Experimental Features (experimental)

Enable experimental features in development. Note: These features are unstable and may change at any time.

json
"experimental": {
  "batch_tool": true,
  "openTelemetry": true
}
FieldTypeDescription
batch_toolbooleanEnable batch operation tools.
openTelemetrybooleanEnable OpenTelemetry tracing.
disable_paste_summarybooleanDisable auto-summary when pasting large text.
continue_loop_on_denybooleanWhether to let Agent continue thinking when tool call is denied (instead of interrupting).
primary_toolsstring[]Specify list of tools only available to Primary Agent.
mcp_timeoutnumberGlobal timeout for MCP requests (milliseconds).

Hook functionality is implemented through the plugin system, not experimental configuration. See Hooks Mechanism.


Other Configuration

compaction

Control context compression behavior.

json
"compaction": {
  "auto": true,
  "prune": true,
  "reserved": 10000
}
FieldTypeDescriptionDefault
autobooleanAuto-trigger compression when context is full.true
prunebooleanRemove old tool outputs during compression.true
reservednumberToken buffer during compression, reserved window to avoid overflow.-

watcher

Control file system watching.

json
"watcher": {
  "ignore": ["node_modules/**", ".git/**"]
}
  • ignore: List of file glob patterns to ignore watching.

instructions

json
"instructions": ["docs/rules.md", ".cursor/rules/*.md"]

List of additional global instruction files.

plugin

json
"plugin": ["opencode-helicone-session", "./my-plugin.js"]

List of plugins to load. Supports npm package names or local file paths.

skills

json
"skills": {
  "paths": ["./skills", "~/shared-skills"],
  "urls": ["https://example.com/.well-known/skills/"]
}
FieldTypeDescription
pathsstring[]Additional Skill folder paths.
urlsstring[]Remote Skill fetch URLs.

mcp

Configure Model Context Protocol servers. See MCP Documentation.

formatter

Configure code formatting tools. See Formatter Documentation.

lsp

Configure LSP servers. See LSP Documentation.

enterprise

json
"enterprise": {
  "url": "https://github.example.com"
}

Configure GitHub Enterprise instance URL.


Appendix: Source Code Reference

Click to expand source code locations

Last updated: 2026-02-14

All configuration schemas are defined in packages/opencode/src/config/config.ts.

ConfigurationSchemaLine Range
Top Level InfoInfoL1004-L1197
ProviderProviderL951-L1001
AgentAgentL672-L758
PermissionPermissionL621-L652
KeybindsKeybindsL761-L917
TUITUIL919-L931
ServerServerL933-L944
CommandCommandL654-L661
SkillsSkillsL663-L670
MCPMcpL523-L584
ExperimentalexperimentalL1172-L1192