Skip to main content

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:

ToolPurpose
bashExecute shell commands
editApply targeted edits to files
writeCreate new files
readRead file contents
grepSearch file contents with regex
globPattern-match file paths
lspQuery language server for code intelligence
apply_patchApply unified diff patches
skillLoad specialized skill instructions
todowriteTrack multi-step task progress
webfetchFetch web page content
websearchSearch the web
questionAsk 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:

PlatformMethod
Terminal TUIopencode
Desktop appNative GUI builds
IDE extensionVS Code, Cursor, Windsurf
Web interfaceopencode web
Headless CLIopencode run "prompt"
CI/CDGitHub 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 /undo or /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:

  1. Project-level .opencode.json or opencode.json
  2. User-level ~/.config/opencode/opencode.json
  3. System-level /etc/opencode.json
  4. 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

PlanDescription
OpenCode ZenCurated, tested models with consolidated billing
OpenCode GoMobile companion app
EnterpriseSelf-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

Usage

Configuration

Advanced