Skip to main content
OpenCode uses a JSON configuration file (.opencode.json) to customize its behavior. This page documents the complete schema and all available configuration options.

Configuration file locations

OpenCode searches for configuration files in the following order:
  1. $HOME/.opencode.json - Global configuration
  2. $XDG_CONFIG_HOME/opencode/.opencode.json - XDG-compliant location
  3. ./.opencode.json - Local directory (merged with global config)
Local configuration files are merged with global configuration. Local settings take precedence over global settings.

Root properties

data
object
Storage configuration for OpenCode’s database and files.
wd
string
Working directory for the application. If not specified, uses the current directory.
debug
boolean
default:"false"
Enable debug mode with verbose logging. When true, log level is set to debug automatically.
debugLSP
boolean
default:"false"
Enable Language Server Protocol debug mode for troubleshooting LSP integration issues.
autoCompact
boolean
default:"true"
Automatically summarize conversations when approaching the model’s context window limit. When enabled, OpenCode monitors token usage and creates a new session with a summary at 95% context usage.
contextPaths
array
List of file paths to automatically include in the AI context. These files are added to every conversation.Default paths:
  • .github/copilot-instructions.md
  • .cursorrules
  • .cursor/rules/
  • CLAUDE.md, CLAUDE.local.md
  • opencode.md, opencode.local.md
  • OpenCode.md, OpenCode.local.md
  • OPENCODE.md, OPENCODE.local.md

Agents configuration

agents
object
Configuration for different AI agents used by OpenCode. Each agent can use a different model and token limit.

Providers configuration

providers
object
LLM provider configurations. Each provider can be enabled/disabled and configured with API keys.

MCP servers configuration

mcpServers
object
Model Control Protocol server configurations. Define custom MCP servers to extend OpenCode’s capabilities.Each key is the server name, and the value is a server configuration object.

LSP configuration

lsp
object
Language Server Protocol configurations. Define LSP servers for different programming languages.Each key is a language identifier, and the value is an LSP configuration object.

Shell configuration

shell
object
Shell configuration for the bash tool.

TUI configuration

tui
object
Terminal User Interface configuration.

Example configuration

{
  "data": {
    "directory": ".opencode"
  },
  "debug": false,
  "autoCompact": true,
  "providers": {
    "anthropic": {
      "apiKey": "sk-ant-..."
    },
    "openai": {
      "apiKey": "sk-..."
    }
  },
  "agents": {
    "coder": {
      "model": "claude-3.7-sonnet",
      "maxTokens": 5000,
      "reasoningEffort": "medium"
    },
    "task": {
      "model": "gpt-4.1-mini",
      "maxTokens": 5000
    },
    "title": {
      "model": "gpt-4.1-mini"
    }
  },
  "shell": {
    "path": "/bin/zsh",
    "args": ["-l"]
  },
  "lsp": {
    "go": {
      "command": "gopls",
      "disabled": false
    },
    "typescript": {
      "command": "typescript-language-server",
      "args": ["--stdio"]
    }
  },
  "mcpServers": {
    "example": {
      "type": "stdio",
      "command": "uvx",
      "args": ["mcp-server-git"]
    }
  },
  "tui": {
    "theme": "tokyonight"
  }
}

JSON schema

The complete JSON schema is available in the OpenCode repository at opencode-schema.json. You can use it for validation and autocompletion in your editor:
{
  "$schema": "https://raw.githubusercontent.com/opencode-ai/opencode/main/opencode-schema.json"
}

Build docs developers (and LLMs) love