OpenCode cheat sheet
Every command, flag and slash command for opencode — Open-source terminal agent with a slick TUI, 75+ providers via Models.dev, and a headless HTTP server. 13+ commands, verified July 2026.
The GitHub org was renamed sst → anomalyco — github.com/sst/opencode now redirects. Same project; only the brew tap and repo URL changed. This is *not* the unrelated opencode-ai/opencode fork.
curl -fsSL https://opencode.ai/install | bash # official installer
npm install -g opencode-ai # npm (also bun / pnpm / yarn)
brew install anomalyco/tap/opencode # Homebrew tap (most current)
opencode # launch the TUI in the current dir
opencode /path/to/project # TUI in a specific directory
opencode run "<message>" # headless: run one prompt, print the result
opencode auth login # add a provider + API key
opencode models [provider] # list available models
opencode serve # headless HTTP API server (no TUI)
`run` flags
| Flag | What it does |
|---|---|
-c, --continue | Continue the last session |
-s, --session <id> | Continue a specific session id |
-m, --model <p/m> | Model in provider/model form |
--agent <name> | Agent to use |
--format <default|json> | json emits raw JSON events (scripting) |
--auto | Auto-approve any permission not explicitly denied |
In-session (TUI · `ctrl+p` palette)
| Command | What it does |
|---|---|
/init | Create / update AGENTS.md for the project |
/models · /sessions | Browse models / past sessions |
/new (/clear) | Start a fresh session |
/compact (/summarize) | Compress the session to save context |
/undo · /redo | Revert / restore a message + its file changes |
/share · /export | Share the session / save to Markdown |
/editor | Compose the message in your external $EDITOR |
// opencode.json (project) · ~/.config/opencode/opencode.json (global)
{
"$schema": "https://opencode.ai/config.json",
"model": "anthropic/claude-sonnet-4-5"
}
// AGENTS.md = project rules (/init to generate)
// keys are added with `opencode auth login`, stored separately from config
opencode run "explain what this repo does and its entry points"
opencode run -c "now add unit tests for the change you just made"
opencode run -m anthropic/claude-sonnet-4-5 "refactor src/auth.ts"
opencode run --format json "list every TODO comment with its file and line"
More CLI cheat sheets
Stop memorizing flags
Run OpenCode — and every other agent — from one app
TheVibeFather orchestrates OpenCode alongside every other coding CLI in one native macOS app. Bring the models you already pay for; keep your keys.
Claude Code
Gemini CLI
Aider
Goose
Qwen Code
Crush
Grok CLI
OpenHands CLI
Cline CLI
Roo Code CLI
Continue CLI