Skip to content

Latest commit

 

History

History
135 lines (99 loc) · 3.14 KB

File metadata and controls

135 lines (99 loc) · 3.14 KB
marp true
theme tessl-cheatsheet
paginate false
size 1400px 1200px
style section { columns: 4; }

OpenCode Cheat Sheet

Installation

curl -fsSL https://opencode.ai/install | bash
opencode

Also: brew install sst/tap/opencode or npm i -g opencode-ai. Built by SST. Update with opencode upgrade.

CLI Commands

Command Description
opencode Start interactive TUI
opencode run "prompt" Non-interactive run
opencode run --format json Machine-readable output
opencode auth login Add a provider
opencode models List available models
opencode serve Headless API server
opencode upgrade Update to latest

run flags: -c continue, -s session, -m model, --agent, --share.

Agent Commands

opencode agent create  # Create custom agent
opencode agent list    # List all agents
opencode mcp add       # Add MCP server
opencode mcp list      # List MCP servers

Custom agents: markdown in .opencode/agents/ with frontmatter (description, mode, permission).

Built-in Agents

Agent Description
build Primary dev agent (all tools)
plan Read-only; edits/bash ask first
@explore Read-only codebase search
@scout Read-only dependency research
@general Complex multi-step subagent

Switch primary agents with Tab in TUI.

Keyboard Shortcuts

Key Action
Tab Switch agent
Enter Send message
Ctrl+C Cancel/interrupt
Esc Exit menu
Ctrl+L Clear screen

Configuration

Global: ~/.config/opencode/opencode.json Project: opencode.json in project root Context file: AGENTS.md (run /init to generate)

{
  "$schema": "https://opencode.ai/config.json",
  "model": "anthropic/claude-sonnet-4-6"
}

Provider Setup

opencode auth login    # interactive, OAuth or API key
opencode auth list

In-TUI: /connect. Anthropic & OpenAI support OAuth (Claude Pro/Max, ChatGPT). Env vars also work:

export ANTHROPIC_API_KEY="sk-ant-..."
export OPENAI_API_KEY="sk-..."

Supports 75+ providers via Models.dev (Anthropic, OpenAI, Google, Bedrock, Azure, Groq, OpenRouter).

Models

Select with /models in TUI or -m provider/model:

  • anthropic/claude-sonnet-4-6
  • openai/gpt-5.1-codex
  • google/gemini-3-pro

GitHub Actions

opencode github install  # scaffold workflow
opencode github run      # run agent in CI

For automated PR reviews and issue triage.

Slash Commands (TUI)

/init generate AGENTS.md · /connect add provider · /models switch model · /share link · /undo · /redo

Features

  • Interactive terminal UI
  • Multi-provider (75+ via Models.dev)
  • Subagents (explore, scout, general)
  • Headless serve + web modes
  • LSP integration · MCP support

Tips

  • Use plan agent for exploration first
  • Switch to build agent to implement
  • Use opencode run --format json for scripting
  • Use @explore / @scout for read-only research
Tessl · OpenCode Cheat Sheet · __VERSION__