
Printable single-page A4 JPEG reference for developers
Last updated: 13/05/2026
Concise reference for OpenCode CLI across macOS, Linux, Windows, and WSL: TUI, run, config, agents/subagents, MCP, skills, tools, providers, and workflows.
I regularly write about agentic coding tools and workflows. If you want updates like these in your inbox, subscribe below. Thanks!
🚀 Start Here
Command | Use |
|---|---|
| Open the interactive TUI in the current directory |
| Open the TUI for a specific project |
| Start TUI with an initial prompt |
| Continue the last session |
| Continue a specific session |
| Fork while continuing a previous session |
| Run once without the full TUI |
| Add provider credentials |
| List configured provider models |
| Upgrade OpenCode |
| Create/update project |
Install: curl -fsSL https://opencode.ai/install | bash, npm install -g opencode-ai, brew install anomalyco/tap/opencode, choco install opencode, scoop install opencode, or Docker ghcr.io/anomalyco/opencode.
🖥️ TUI Essentials
Input / Command | Action |
|---|---|
| Fuzzy search files and attach selected file content |
| Add configured reference roots or autocomplete under them |
| Run shell command and add output as tool result |
| Show available commands |
| Add/authenticate an LLM provider |
| Select/list models |
| Toggle display of model reasoning blocks |
| Toggle tool execution details |
| Compose prompt in |
| Export current conversation to Markdown |
| Exit |
Slash Command | Use |
|---|---|
| Generate or update |
| Start a new session |
| List and switch sessions |
| Compact current context |
| Undo last message and file changes; requires Git |
| Redo an undone message; requires Git |
| Share or unshare current session |
| Select/list themes |
⌨️ Keybinds
Key | Action |
|---|---|
| Default leader key |
| Compact session |
| Open editor |
| Exit |
| Export session |
| Model list |
| New session |
| Session list |
| Theme list |
| Undo / redo |
| Cycle primary agents |
| Cycle model variants |
| Enter first child subagent session |
| Next child / previous child / parent session |
| Newline in prompt |
Customize in tui.json under keybinds; use "none" or false to disable a binding.
CLI Commands & Flags
Command | Use |
|---|---|
| Create or list agents |
| Attach TUI to running |
| Manage provider credentials |
| Install or run GitHub agent automation |
| Manage MCP servers and OAuth |
| List models; optional provider filter |
| Start headless HTTP server |
| Start server with web UI |
| Manage sessions |
| Show token and cost stats |
| Export session JSON |
| Import session JSON or share URL |
| Start Agent Client Protocol server |
| Install plugin and update config |
| Fetch/check out GitHub PR and run OpenCode |
| Query DB or print DB path |
| Debugging tools |
| Remove OpenCode files |
Flag | Use |
|---|---|
| Help / version |
| Log output and level |
| Run without external plugins |
| Choose model |
| Choose agent |
| Continue last/specific session |
| Fork continued session |
| Server/TUI networking |
opencode run
Command / Flag | Use |
|---|---|
| Non-interactive single run |
| Run a configured command; message becomes args |
| Attach files to message |
| Emit raw JSON events |
| Share resulting session |
| Set session title |
| Reuse running |
| Use model variant |
| Show thinking blocks |
| Auto-approve anything not explicitly denied ⚠️ |
Start opencode serve first for repeated scripted runs to avoid repeated MCP/server cold starts.
⚙️ Config
Path / Source | Use |
|---|---|
| Global runtime config |
| Global TUI config |
| Project runtime config |
| Project TUI config |
| Project extensions |
| Remote organization defaults |
| Custom config file/dir |
| Inline JSON override |
| Managed config |
Precedence, low to high: remote, global, OPENCODE_CONFIG, project, .opencode dirs, OPENCODE_CONFIG_CONTENT, managed config, macOS MDM. Configs are merged; later sources override conflicting keys.
Key | Use |
|---|---|
|
|
| Main model and cheaper small-task model |
| Provider definitions/options |
| Default and custom agents |
| Custom slash commands |
| Tool/action policy |
| MCP servers, plugins, extra rule files/globs/URLs |
|
|
| Enable/disable undo snapshots |
|
|
| Enable/configure formatters and LSP |
| Context compaction behavior |
| File watcher ignore globs |
| Provider allow/deny lists |
Use {env:VAR} for env substitution and {file:path} for file contents. Paths can be relative to config, absolute, or ~.
| Use |
|---|---|
| UI theme |
| Shortcut overrides |
| Default |
| Scroll behavior |
|
|
| Capture mouse; set |
🔐 Permissions & Tools
Permission | Gates |
|---|---|
| File reads; |
|
|
| Shell commands |
| File and content search |
| Subagent launches |
| Skill loading |
| LSP queries |
| Todo tracking |
| URL fetch and web search |
| Ask user questions during execution |
| Paths outside project; asks by default |
| Repeated identical tool calls; asks by default |
Actions: allow, ask, deny. Pattern rules use * and ?; last match wins.
Example Rule | Meaning |
|---|---|
| Allow all except safety defaults |
| Ask by default |
| Block file changes |
| Granular shell policy |
| Allow outside project path |
| Agent-specific override |
| Control all tools from an MCP server |
Built-in Tool | Use |
|---|---|
| Command/file operations |
| Search via ripgrep; respects |
| Experimental definitions/references/hover/symbols/calls |
| Skill loading, task tracking, user prompts |
| URL retrieval and Exa search |
Custom tools: add JS/TS files to .opencode/tools/ or ~/.config/opencode/tools/. Default export name is filename; named exports become <file>_<export>. Use tool() from @opencode-ai/plugin; JS/TS wrappers can call scripts in any language.
🤖 Agents & Subagents
Agent | Mode | Use |
|---|---|---|
| Primary | Default development agent |
| Primary | Planning/review; edits and bash ask by default |
| Subagent | General multi-step or parallel work |
| Subagent | Fast read-only codebase exploration |
| Subagent | Read-only external docs/dependency research |
| Hidden primary | Automatic system agents |
Task | How |
|---|---|
Switch primary agent |
|
Invoke subagent |
|
Create/list agents |
|
Define agents |
|
Set default |
|
Control subagent calls |
|
Agent Option | Use |
|---|---|
| Required usage hint |
|
|
| Agent model, system prompt, and policy |
| Max agentic iterations |
| Randomness/diversity |
| Availability and UI |
Extra keys | Provider-specific options, e.g. |
Skills & MCP
Skill Path | Scope |
|---|---|
| Project OpenCode skill |
| Global OpenCode skill |
| Claude-compatible skills |
| Agent-compatible skills |
SKILL.md requires YAML name and description; optional license, compatibility, metadata. Name must match the directory and ^[a-z0-9]+(-[a-z0-9]+)*$. Control access with permission.skill.
MCP Command / Config | Use |
|---|---|
| Add local or remote server |
| List servers/status |
| OAuth login |
| OAuth status |
| Remove OAuth credentials |
| Debug connection/OAuth |
| Disable without deleting |
MCP Type | Required | Options |
|---|---|---|
Local |
|
|
Remote |
|
|
OAuth | Remote server with optional |
|
MCP tools are automatically exposed and add to context. For high-token servers, disable globally and enable per agent/prompt. OAuth tokens live in ~/.local/share/opencode/mcp-auth.json.
Models & Providers
Task | How |
|---|---|
Add provider |
|
Credential file |
|
List auth/models |
|
Refresh models |
|
Verbose metadata |
|
Select in TUI |
|
Set default |
|
Override run |
|
Cycle variants |
|
Restrict providers |
|
Loading priority: CLI --model, config model, last used model, internal priority. Docs list strong coding/tool-use models such as GPT 5.2, GPT 5.1 Codex, Claude Opus 4.5, Claude Sonnet 4.5, Minimax M2.1, and Gemini 3 Pro.
Provider Config | Use |
|---|---|
| Proxy/custom endpoint |
| Request/stream timeouts |
| Model-specific options |
| Named reasoning/provider variants |
| Hide variant |
Custom provider flow: /connect -> Other, enter provider ID and key, then configure provider.<id> with npm, name, options.baseURL, and models. Use @ai-sdk/openai-compatible for /v1/chat/completions, @ai-sdk/openai for /v1/responses.
Commands, Rules & Plugins
Custom Command Feature | How |
|---|---|
Project/global file |
|
Config command |
|
Arguments |
|
Shell output |
|
File context |
|
Overrides |
|
Rules / Instructions | Use |
|---|---|
| Project rules; commit to Git |
| Global personal rules |
| Fallback compatibility |
| Extra files/globs/remote URLs; combined with rules |
| Disable Claude compatibility pieces |
Rule precedence: local AGENTS.md/CLAUDE.md while walking up from CWD, then global OpenCode rules, then Claude global fallback. If both exist at a level, AGENTS.md wins.
Plugin Surface | Use |
|---|---|
| Project plugin |
| Global plugin |
| Load npm plugins |
| Dependencies for local plugins/tools |
| Inspect or alter tool calls |
| Common hook areas |
Plugin | Add tools; name collision overrides built-in |
Plugin load order: global config, project config, global plugin dir, project plugin dir. Npm plugin dependencies cache under ~/.cache/opencode/node_modules/.
Formatters, LSP & Themes
Feature | Config |
|---|---|
Enable formatters |
|
Disable formatters | Omit |
Custom formatter |
|
Enable LSP |
|
Disable LSP | Omit |
Custom LSP |
|
Disable LSP downloads |
|
Enable LSP tool |
|
Formatters cover tools like prettier, biome, gofmt, rustfmt, ruff, uv, shfmt, terraform, clang-format, rubocop, and more. LSP built-ins cover TypeScript, ESLint, Go, Rust, Python, Ruby, PHP, Java, C/C++, Swift, Vue, Svelte, YAML, Terraform, Bash, Lua, and more.
Theme | Use |
|---|---|
| Select/list themes |
| Persist theme |
| Match terminal background/ANSI palette |
Built-ins |
|
Custom themes |
|
Truecolor | Set |
Environment & Sharing
Variable | Use |
|---|---|
| Config overrides |
| TUI config path |
| Inline permissions JSON |
| Basic auth for |
| Auto-share sessions |
| Disable update/compaction behavior |
| Disable default loading/fetching |
| Disable TUI mouse capture |
| Git Bash path on Windows |
| Enable Exa web search tools |
| Experimental features |
Sharing | Use |
|---|---|
| Public |
| Remove public link/data |
| Default |
| Share new conversations automatically |
| Disable sharing |
Shared sessions are public to anyone with the link and include conversation history, messages/responses, and metadata.
Windows / WSL
Task | Command / Note |
|---|---|
Recommended Windows setup | Use WSL for better file performance and terminal compatibility |
Install in WSL | `curl -fsSL https://opencode.ai/install |
Access Windows files |
|
Best performance | Clone repos into WSL filesystem, e.g. |
Serve from WSL |
|
Secure WSL server |
|
Web from WSL |
|
If localhost fails from Windows, run hostname -I in WSL and connect to http://<wsl-ip>:4096.
Troubleshooting
Symptom / Task | Check |
|---|---|
Logs | macOS/Linux |
App data | macOS/Linux |
Debug logs |
|
Won't start | Check logs, use |
Auth issues | Re-run |
Model missing | Check exact |
| Fix provider config; last resort clear |
API/provider package errors | Clear |
Desktop crash/hang | Disable |
Desktop connection failed | Clear default server URL; remove |
Linux blank desktop window | Try |
Windows blank desktop window | Install/update Edge WebView2 Runtime |
Linux copy/paste | Install |
Workflow Patterns
Goal | Pattern |
|---|---|
Ask about code |
|
Plan first | Switch to |
Build after plan | Switch back to |
Include command output |
|
Fix by example | Reference target and known-good file: |
Recover bad change |
|
Restore undone work |
|
Share context |
|
Prompt template: goal + relevant files + constraints + done-when checks. Put durable project facts in AGENTS.md, repeatable prompts in custom commands, reusable methods in skills, and live external context in MCP.




