Skip to content

How to set up OpenCode

Open in ChatGPT ↗
Ask ChatGPT about this page
Open in Claude ↗
Ask Claude about this page
Copied!

Set up OpenCode in Warp, configure it for your project, and learn productivity tips for faster AI-assisted coding workflows.

OpenCode is an open-source coding agent that runs in your terminal. It supports 75+ LLM providers, features a built-in terminal UI (TUI), and lets you edit code, execute commands, and manage sessions from natural language prompts. This guide takes you from installation to a working OpenCode session in Warp in about 5 minutes, then shows you how to get the most out of it.

  • An LLM provider account — OpenCode connects to any supported provider (Anthropic, OpenAI, Google, and others) via API key, or use OpenCode Zen for a curated model list. See OpenCode configuration for details.
  • macOS, Linux, or Windows (via WSL) — WSL is recommended for the best experience on Windows. See OpenCode docs for full platform details.

Follow the official OpenCode installation guide to install OpenCode. The install script is the fastest method:

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

You can also install via npm or Homebrew:

Terminal window
npm install -g opencode-ai
Terminal window
brew install anomalyco/tap/opencode

See the OpenCode docs for additional installation methods including Homebrew taps, platform-specific binaries, and Docker.

When you launch OpenCode inside Warp, Warp auto-detects the agent session and surfaces integrated controls, including rich input, code review, vertical tab metadata, and more.

OpenCode supports multiple LLM providers. Run the /connect command inside OpenCode’s TUI to configure a provider, or set API keys as environment variables:

Terminal window
# For Anthropic models
export ANTHROPIC_API_KEY=YOUR_API_KEY
# For OpenAI models
export OPENAI_API_KEY=YOUR_API_KEY
# For Google Gemini models
export GEMINI_API_KEY=YOUR_API_KEY

Outside the TUI, run opencode auth login from the command line for interactive provider setup. Credentials are stored locally in ~/.local/share/opencode/auth.json.

Navigate to any project directory and launch OpenCode:

Terminal window
cd ~/your-project
opencode

OpenCode starts its TUI. Try giving it a task, for example:

Explain the architecture of this project

Or something more hands-on:

Add input validation to the user registration endpoint

OpenCode reads the relevant files, proposes changes, and asks for confirmation before modifying anything. Use the Tab key to switch between Plan mode (read-only suggestions) and Build mode (applies changes).

Initialize OpenCode for your project by running /init inside the TUI. This analyzes your codebase and creates an AGENTS.md file at your project root:

/init

The AGENTS.md file teaches OpenCode your project’s structure and conventions. You can also create or edit it manually:

# My Project
## Stack
- Backend: Python 3.12, FastAPI, SQLAlchemy
- Frontend: React, TypeScript, Vite
- Database: PostgreSQL 16
## Commands
- `npm run dev` starts the dev server
- `pytest -v` runs the test suite
- `npm run lint` checks code style
## Conventions
- Use async/await for all database operations
- Type hints on all function signatures
- ESM imports only (no require())

Commit the AGENTS.md file to Git so your team shares the same project context.

Warp supports agent notifications for OpenCode through a plugin. If the plugin isn’t installed, Warp displays an installation chip in the terminal when you run OpenCode, with setup steps you can follow directly.

For manual installation and configuration, see OpenCode in Warp (docs).

  • Use voice to prompt OpenCode — Dictate complex instructions instead of typing them. Warp supports voice transcription that works with any CLI agent, including OpenCode.
  • Attach images as context — Paste screenshots of bugs, designs, or error messages into your prompt. Warp’s images as context feature lets OpenCode see what you see.
  • Review diffs visually — After OpenCode makes changes, open Warp’s Code Review panel (⌘+Shift++) to see a visual diff. You can leave inline comments and send them back to OpenCode for corrections.
  • Run OpenCode alongside other agents — Use vertical tabs to run OpenCode and Claude Code or Codex side by side on the same task. Compare their approaches and pick the best output.
  • Compose richer prompts — Press Ctrl+G to open Warp’s rich input editor for OpenCode, giving you a full text editor experience instead of raw CLI input.

You installed OpenCode, authenticated with a provider, started your first session, and configured it for your project. OpenCode is now set up as a working coding agent in Warp.

Explore related guides and features: