opencode - AI Coding Agent
opencode is an open source AI coding agent that operates in your terminal, desktop, IDE, or CI/CD pipeline. It connects to 75+ large language model providers -- including Anthropic, OpenAI, Google, Groq, Together AI, and local models -- to help you understand, write, review, and refactor code through natural language conversations.
opencode is built around a powerful agent system that can autonomously plan, execute, and verify multi-step software engineering tasks. It exposes a rich terminal user interface (TUI), a headless CLI for scripting, a web interface for browser-based access, and a plugin ecosystem for deep editor integration.
Key Features
Multi-Provider LLM Support
Connect to any major LLM provider through a unified interface. Switch between providers on the fly, compare model outputs, and use the best model for each task. Support includes Anthropic Claude, OpenAI GPT-4o / o3, Google Gemini, Groq, Together AI, OpenRouter, Azure OpenAI, AWS Bedrock, GCP Vertex AI, GitHub Models, Ollama (local), llama.cpp (local), and custom OpenAI-compatible endpoints.
Rich Terminal UI
The primary interface is a full-featured terminal application with themes, mouse support, a command palette, tab completion, file references via @, image drag-and-drop, slash commands, and configurable keybindings. The TUI supports multiple sessions with branching conversations, undo/redo via automatic git snapshots, and session sharing.
Agent System
opencode ships with a multi-agent architecture:
- Build primary agent -- executes tasks by reading files, writing code, running shell commands, and applying changes
- Plan primary agent -- analyzes requirements, researches codebases, and produces detailed plans before any code is written
- General subagent -- handles general Q&A, research, and exploration tasks
- Explore subagent -- navigates and inspects codebases to build understanding
- Scout subagent -- lightweight pre-agent for quick lookups and context gathering
- Custom agents -- define your own specialized agents with custom system prompts, tools, and model preferences
Tool Ecosystem
Agents use a growing set of built-in tools to interact with your system:
| Tool | Purpose |
|---|---|
bash | Execute shell commands |
edit | Apply targeted edits to files |
write | Create new files |
read | Read file contents |
grep | Search file contents with regex |
glob | Pattern-match file paths |
lsp | Query language server for code intelligence |
apply_patch | Apply unified diff patches |
skill | Load specialized skill instructions |
todowrite | Track multi-step task progress |
webfetch | Fetch web page content |
websearch | Search the web |
question | Ask the user for clarification |
You can also define custom tools and connect to MCP (Model Context Protocol) servers to extend agent capabilities.
Multi-Platform
opencode runs everywhere software is built:
| Platform | Method |
|---|---|
| Terminal TUI | opencode |
| Desktop app | Native GUI builds |
| IDE extension | VS Code, Cursor, Windsurf |
| Web interface | opencode web |
| Headless CLI | opencode run "prompt" |
| CI/CD | GitHub Action, shell scripts |
Session Management
Every conversation in opencode is a session. Sessions support:
- Undo / Redo: Automatic git snapshots at each agent step let you revert changes with
/undoor/redo - Branching: Child sessions fork from parent sessions, letting you explore alternative approaches
- Persistence: Sessions are saved automatically and listed with
/sessions - Continue: Resume any previous session
Sharing
Share full session transcripts with teammates via /share. Three modes:
- Manual (default): You choose when to share with
/share - Auto: Every session is automatically shared
- Disabled: Sharing is turned off
Shared sessions are accessible via a URL and include the full conversation, file diffs, and tool outputs.
Configuration System
opencode is configured through JSON or JSONC files. Multiple config locations are merged with clear precedence:
- Project-level
.opencode.jsonoropencode.json - User-level
~/.config/opencode/opencode.json - System-level
/etc/opencode.json - CLI flags (highest priority)
The TUI includes a built-in configuration editor accessible through the command palette.
Integration Ecosystem
- GitHub Copilot: Use GitHub Models as a provider
- GitLab Duo: Connect via GitLab AI Gateway
- LSP: Language Server Protocol for code intelligence
- MCP: Model Context Protocol for tool ecosystem
- ACP: Agent Communication Protocol for multi-agent coordination
Subscription Options
| Plan | Description |
|---|---|
| OpenCode Zen | Curated, tested models with consolidated billing |
| OpenCode Go | Mobile companion app |
| Enterprise | Self-hosted, SSO, audit logs, dedicated support |
Architecture Overview
opencode follows a client-server architecture:
┌─────────────────────────────────────────────────┐
│ User │
├─────────────────────────────────────────────────┤
│ TUI / CLI / Web / IDE / Desktop │
├─────────────────────────────────────────────────┤
│ opencode Core │
│ ┌──────────┐ ┌──────────┐ ┌───────────────┐ │
│ │ Agent │ │ Session │ │ Tool Executor │ │
│ │ System │ │ Manager │ │ │ │
│ ├──────────┤ ├──────────┤ ├───────────────┤ │
│ │ Planner │ │ History │ │ Bash / Edit │ │
│ │ Builder │ │ Snapshots│ │ Write / Read │ │
│ │ Scout │ │ Sharing │ │ Grep / Glob │ │
│ └──────────┘ └──────────┘ │ LSP / WebFetch │ │
│ │ Skills / MCP │ │
│ └───────────────┘ │
├─────────────────────────────────────────────────┤
│ Provider Abstraction Layer │
│ Anthropic OpenAI Google Groq Local Zen │
├─────────────────────────────────────────────────┤
│ LLM API / Local Models │
└─────────────────────────────────────────────────┘
Quick Start
# Install
curl -fsSL https://opencode.ai/install | bash
# Start the TUI
cd /path/to/your/project
opencode
# In the TUI, configure a provider
/connect
# Initialize project context
/init
# Start working -- ask questions, add features, fix bugs
For a detailed walkthrough, see the Quick Start guide.
Documentation
Getting Started
- Installation -- Install opencode on any platform
- Quick Start -- Get productive in 5 minutes
- Key Features -- Deep dive into capabilities
Usage
- CLI Usage -- Command-line reference and scripting
- Terminal UI -- TUI commands, keybinds, and customization
- Web Interface -- Browser-based access
- IDE Integration -- Editor workflows
- OpenCode Zen -- Curated model service
Configuration
- Configuration -- JSON/JSONC config reference
- Customization -- Themes, keybinds, providers
- Permissions & Safety -- Security model
Advanced
- Agents -- Agent system deep dive
- Integrations -- MCP, LSP, GitHub, GitLab
- Subscription -- Zen, Go, Enterprise
- Development -- Contributing and building
- Reference -- Full command and config reference
- Cheatsheet -- Quick reference cards