Introduction
OpenCode is an open source AI coding agent available as a terminal interface, desktop application, or IDE extension. It enables developers to interact with AI for code-related tasks.
Prerequisites
Before using OpenCode in your terminal, you'll need:
-
Modern Terminal Emulator - Options include:
- WezTerm (cross-platform)
- Alacritty (cross-platform)
- Ghostty (Linux and macOS)
- Kitty (Linux and macOS)
-
API Keys - Credentials for your chosen LLM providers
Installation
Universal Installation
curl -fsSL https://opencode.ai/install | bashNode.js Package Managers
# npm
npm install -g opencode-ai
# Bun
bun install -g opencode-ai
# pnpm
pnpm install -g opencode-ai
# Yarn
yarn global add opencode-aiSystem Package Managers
# Homebrew (macOS/Linux)
brew install anomalyco/tap/opencode
# Paru (Arch Linux)
paru -S opencode-bin
# Chocolatey (Windows)
choco install opencode
# Scoop (Windows)
scoop bucket add extras && scoop install extras/opencode
# Docker
docker run -it --rm ghcr.io/anomalyco/opencodeConfiguration
- Execute the
/connectcommand within the terminal interface - Select your preferred provider
- Authenticate at opencode.ai/auth
- Configure billing information
- Retrieve and input your API key
We recommend OpenCode Zen as a curated, tested model collection for newcomers.
Project Initialization
Navigate to your project directory and launch:
cd /path/to/project
opencodeInitialize the project with:
/initThis generates an AGENTS.md file in your project root, which should be committed to version control.
Core Usage Patterns
Questioning the Codebase
Use @ to search project files:
How is authentication handled in @packages/functions/src/api/index.tsFeature Development
- Plan Mode (Tab key) - AI suggests implementation approaches without making changes
- Iteration - Refine plans with feedback and visual references
- Build Mode (Tab key) - Execute the approved changes
Reverting Changes
- Undo command:
/undo - Redo command:
/redo - Multiple undos are supported
Collaboration
Share conversations via:
/shareThis generates a shareable link copied to the clipboard.
Personalization
Customize your experience:
- Theme selection
- Keyboard bindings
- Code formatters
- Custom commands
- Configuration settings