opencode Cheat Sheet — the open terminal agent
The philosophy is in the name: open. opencode gives you the full terminal-agent experience — slick TUI, tools, sessions — and you pick the model underneath. Claude, GPT, Gemini, a local model on your box… all work. If vendor lock-in gives you allergies, this is your playground.
Install & setup
| Command | What it does |
|---|---|
npm install -g opencode-ai |
Install (or curl -fsSL https://opencode.ai/install | bash) |
opencode auth login |
Connect a provider — dozens supported |
opencode |
Open the TUI in the current directory |
opencode run "your prompt" |
Non-interactive mode for scripts |
opencode upgrade |
Update |
Inside the TUI
| Command | What it does |
|---|---|
/help |
All commands |
/init |
Generate AGENTS.md — the project memory file |
/models |
Pick a model from any connected provider |
/sessions |
Switch between sessions |
/share |
Share the conversation via link |
/undo |
Revert the last edit — your safety valve |
/compact |
Summarize conversation to free context |
/exit |
Quit |
The nice move: modes
opencode ships with modes you cycle via Tab: build mode (normal work — edit & run) and plan mode (read & plan only — touches nothing). You can define custom modes with their own prompts and tools in opencode.json.
The verdict
Its killer use: experimentation and comparison. One task — how does Claude solve it vs GPT vs a cheap open-weight model? Same harness, swap with /models, compare with your own eyes. There's no cleaner way to understand real model differences at work — beyond benchmark tables.