OpenCode field reference
OpenCode Code Cheatsheet and Command Guide
Move from “what was that command?” to the exact syntax, shortcut, flag, path, or configuration you need—without losing the thread of your work.
Updated July 28, 2026 · Fast-changing items are marked “Check locally”.
01
02
03
04
05
01 / Start with intent
What do you need OpenCode to do?
Select an outcome to open a focused set of matching commands.02 / Find anything
OpenCode command atlas
Search syntax, descriptions, examples, aliases, and keywords.03 / Compose a run
Headless command builder
Choose the session, model, output, file, and server options you need, then copy a ready-to-edit command.
04 / Reuse good prompts
Custom command workshop
Generate a project command file. OpenCode uses the Markdown file name as the slash command name.
Run it as /review-tests <arguments>. A project command can override a built-in command with the same name, so choose names deliberately.
05 / Know what wins
Configuration priority
OpenCode merges configuration layers. Later layers override only conflicting keys..well-known/opencodeLowest priority~/.config/opencode/opencode.jsonPersonal defaults$OPENCODE_CONFIGExplicit file override./opencode.jsonRepository settings.opencode/Agents, commands, skills, pluginsOPENCODE_CONFIG_CONTENTHighest priority06 / Put files in scope
Path map
Use global locations for personal defaults and project locations for repository behavior.Global configuration~/.config/opencode/opencode.json
Models, providers, permissions, sharing, compaction, and server defaults for the current user.
Global TUI settings~/.config/opencode/tui.json
Theme, scrolling, diff style, and keybindings.
Global instructions~/.config/opencode/AGENTS.md
Instructions that apply across projects.
Global commands~/.config/opencode/commands/
Custom slash commands available across projects.
Global skills~/.config/opencode/skills/
Reusable skills available across projects.
Global plugins~/.config/opencode/plugins/
User-level plugins.
Project instructions<project>/AGENTS.md
Repository-specific context and working rules.
Project configuration<project>/opencode.json
Project settings that override conflicting global values.
Project workspace<project>/.opencode/
Project agents, commands, skills, and plugins.
07 / Follow a reliable route
Four practical workflows
Select a workflow, then copy any step you need.First project
Connect a provider, teach OpenCode the repository, and start with useful context.
- 01
Launch in the intended repository.
- 02
Add the provider and credentials you want to use.
- 03
Create or update AGENTS.md after reviewing the project.
- 04
Confirm the instructions are concise and accurate.
Recover a session
Inspect history, restore snapshot-backed edits, and verify the result.
- 01
Return to the correct saved session.
- 02
Undo the latest message and associated snapshot.
- 03
Inspect what changed after restoration.
- 04
Reapply the undone state only when it is the better version.
Headless automation
Run a bounded request and return structured output for another tool.
- 01
Start with machine-readable output.
- 02
Continue the latest session when the next step depends on prior context.
- 03
Record the session ID for repeatable continuation.
Protected remote use
Start an authenticated local server and attach a TUI client.
- 01
Start with authentication enabled.
- 02
Attach locally first and verify the connection.
- 03
Review connected tools before exposing the server beyond the machine.
08 / Use the leader layer
Ctrl+X shortcut map
The default leader is Ctrl+X. Change it intui.json and use local help when a mapping differs.
09 / Keep the vocabulary close
OpenCode glossary
Short definitions for the concepts behind the commands.The interactive terminal interface launched by opencode.
A non-interactive task launched with opencode run, useful in scripts and CI.
Saved conversation history that can be reopened, continued, forked, exported, or shared.
Project or user instructions that give OpenCode durable context.
Git-backed state used by undo and redo for file changes.
A summary of older conversation context that frees room for continued work.
A task-focused behavior and tool configuration.
Model Context Protocol, used to connect external tools and services.
Agent Client Protocol support over JSON-RPC for compatible clients and editors.
10 / Install and launch
Choose your installation route
After installation, runopencode --version and opencode --help to confirm the local command surface.
11 / Before you run it
Small checks prevent large surprises
- Sharing: inspect the entire session before using
/shareor--share. - Remote servers: add authentication before binding beyond localhost; confirm firewall and network exposure.
- Shell injection: both prompt
!commandand custom-command!`command`run with your user permissions. - Undo and redo: inspect
git diffafter snapshot restoration; unrelated manual changes may need separate care. - Credentials: use environment or protected file substitution instead of committing API keys into configuration.
- Fast-changing features: confirm experimental variables, keybindings, flags, and model names locally.