Config & CLI Reference
This chapter summarizes opencode.json, environment variables, and common CLI commands.
Config Files
Environment variables:
opencode.json Overview
model and provider
model: defaultprovider/model-idstringprovider: per-vendor endpoint, apiKey references, etc.- TUI
/connectavoids committing secrets to the repo
instructions
String array appended to system prompt (like global rules):
Common CLI
Install and update
Interactive TUI
Non-interactive run
Good for scripts and CI helpers—mind permissions and API cost.
Headless
Agent management
Other
Subcommands evolve quickly—trust local opencode --help.
TUI Slash Commands (common)
Custom commands live in .opencode/commands/*.md.
Custom Slash Commands
.opencode/commands/test-and-fix.md:
Type /test-and-fix in TUI to inject that prompt template.
OpenCode Zen
Zen is OpenCode’s curated model list (optimized routing). See the site or TUI /connect for current models and pricing.
75+ Providers
OpenCode supports Anthropic, OpenAI, Google, local Ollama, OpenRouter, and more:
- API key env vars
- Custom
baseURL(OpenAI-compatible gateways) - Local models without cloud
Team tip: Pin model in opencode.json so members do not accidentally use expensive models.
Git Workflow
- Commit
opencode.json(no secrets) andAGENTS.md - Do not commit API keys—use env vars or global config
- Optionally
.gitignore.opencode/cacheand local caches