</> CodeAgents

Cheat Sheet

OpenCode

Open-source AI coding agent, terminal-native

Learn More

Installation

curl -fsSL https://opencode.ai/install | shInstall OpenCode (Linux/macOS)
brew install opencodeInstall via Homebrew (macOS)
opencodeLaunch the TUI
opencode upgradeUpgrade to the latest version
opencode --versionShow installed version

TUI Keybindings

EnterSend message to agent
Ctrl+EnterInsert new line in input
EscapeCancel current operation / go back
Ctrl+CCopy selected text / quit
Ctrl+ZUndo last file change
Ctrl+YRedo last undone change
/Focus command input / search
TabCycle focus between panels

Session Commands

/mode planSwitch to Plan mode (read-only analysis)
/mode buildSwitch to Build mode (write file changes)
@filenameAttach a file to the prompt
/undoRevert last AI file changes
/sharePublish session as a shareable URL
/clearClear conversation history
/modelSwitch AI model mid-session
/compressCompress conversation to save context

Context & Memory

AGENTS.mdProject instructions (cross-agent standard)
opencode.jsonProject configuration file
~/.config/opencode/config.jsonGlobal user configuration
Plan modeAnalyze codebase without writing files
Build modeApply AI-generated changes to codebase
$rules in configDefine custom instruction rules

Provider Configuration

ANTHROPIC_API_KEY=...Set Claude (Anthropic) API key
OPENAI_API_KEY=...Set OpenAI API key
GOOGLE_API_KEY=...Set Google Gemini API key
provider: "anthropic"Set default provider in config
model: "claude-sonnet-4-6"Set default model in config
OpenCode ZenManaged model subscription (no API keys)
providers: [...]Multi-provider config in opencode.json

MCP

mcp.servers in opencode.jsonConfigure MCP server list
type: "local"Subprocess (stdio) MCP transport
type: "remote"HTTP/SSE remote MCP transport
mcp auth <server>OAuth flow for remote MCP server
args: [...]MCP server command arguments
env: {...}MCP server environment variables
opencode mcp listList all active MCP servers

code-agents.oday-bakkour.com · OpenCode · Last verified: April 2026