> opencode
the open-source terminal coding agent — bring any of 75+ providers, share sessions by URL, script it with opencode run, and switch between build and plan agents
// getting started
5 commands// sessions & tui
6 commands// headless & scripting
6 commandsRun a one-off prompt without the TUI
$ opencode run "explain how the auth module works"Continue or fork a session from the command line
$ opencode run -c "now add tests for that change"Pipe input or attach files to a headless run
$ cat error.log | opencode run "explain this error and suggest a fix"Get machine-readable JSON output
$ opencode run "list every TODO in the codebase" --format jsonPick the model or agent for a single run
$ opencode run -m anthropic/claude-sonnet-4-5 "refactor this function"Run opencode as a server and attach to it
$ opencode serve --port 4096// keyboard shortcuts
5 commands// configuration
5 commandsConfigure opencode with opencode.json
$ ~/.config/opencode/opencode.jsonControl which tools need approval
$ { "permission": { "edit": "ask", "bash": "ask" } }Inject secrets and env values into config
$ { "model": "{env:OPENCODE_MODEL}" }Configure opencode with environment variables
$ export OPENCODE_MODEL=anthropic/claude-sonnet-4-5Change the TUI theme
$ /themes// models & providers
4 commands// agents & rules
4 commands// mcp & integrations
5 commandsAdd a local MCP server
$ ~/.config/opencode/opencode.jsonAdd a remote MCP server
$ { "mcp": { "my-remote": { "type": "remote", "url": "https://mcp.example.com", "enabled": true, "headers": { "Authorization": "Bearer {env:MCP_TOKEN}" } } } }Run opencode on GitHub issues and PRs
$ opencode github installEnable LSP for better code awareness
$ { "lsp": true }Set the editor opencode opens for prompts
$ export EDITOR=nvim