OpenCode — The Open-Source AI Coding Agent Framework
OpenCode is a terminal-first AI coding assistant with multi-model support, MCP integration, LSP diagnostics, and a powerful plugin system.
If you’ve used Claude Code or Cursor, you know how powerful an AI coding agent can be. But what if you want something open-source, provider-agnostic, and terminal-native — something that works with any LLM, in any environment, without being locked into a single ecosystem?
That’s exactly what OpenCode delivers.
What is OpenCode?#
OpenCode is an open-source AI coding assistant and agent framework that runs directly in your terminal. It started as a Go-based CLI and has evolved into a dual-layer architecture:
- Backend: A high-performance HTTP server (Bun + Hono + TypeScript)
- Frontend: A rich Terminal UI (Go + Bubble Tea)
OpenCode gives AI agents fine-grained access to your files, terminal shell, Language Server Protocol (LSP) diagnostics, and external services via the Model Context Protocol (MCP). It’s designed to be a fully open-source alternative to proprietary tools like Claude Code — with the freedom to use any model provider you choose.
Why OpenCode?#
1. Provider-Agnostic — 75+ LLM Providers#
Unlike Claude Code (tied to Anthropic) or GitHub Copilot (tied to OpenAI/Microsoft), OpenCode works with 75+ LLM providers through Vercel’s AI SDK and Models.dev. Use any model you want:
- Anthropic: Claude 3.5 Sonnet, Claude 4 Opus
- OpenAI: GPT-4o, o3, GPT-5
- Google: Gemini 2.5 Pro, Gemini 2.0 Flash
- Open-Source: Llama 3, DeepSeek-V3, Qwen 3
- Local: Ollama, LM Studio, vLLM
- Cloud: AWS Bedrock, Azure, Groq
You can even configure different models for different agents — use a cheap, fast model for planning and a powerful reasoning model for building.
2. Terminal-Native with a Rich TUI#
OpenCode runs in your terminal with a full-screen TUI built on Bubble Tea. It’s designed for keyboard-driven workflows:
| Shortcut | Action |
|---|---|
Tab | Switch between agents (Build ↔ Plan) |
@ | Fuzzy-search files and agents |
Ctrl+K | Command palette |
Ctrl+O | Model selector |
/undo / /redo | Revert or reapply AI changes |
/share | Generate a shareable session link |
3. Advanced Agent Architecture#
OpenCode uses a primary agent + subagent hierarchy:
Primary agents:
- Build: Full tool access — can read, write, edit files, run shell commands, access LSP diagnostics. This is your implementation agent.
- Plan: Read-only with ask-only permissions. Analyzes code and formulates strategies without changing anything.
Subagents (summonable via @):
- General: Multi-step task execution
- Explore: Fast codebase navigation
- Scout: External dependency research and documentation lookup
4. Model Context Protocol (MCP) Integration#
OpenCode acts as an MCP client, dynamically loading tools from external MCP servers — both Stdio-based and SSE-based. Every MCP tool inherits the same permission system as native tools, so you control exactly what the AI can access.
5. Language Server Protocol (LSP) Support#
OpenCode connects to LSP servers (like gopls, typescript-language-server, rust-analyzer) to feed real-time diagnostics to the LLM. The AI sees errors, warnings, and hints as it edits code — just like an IDE would.
6. Granular Permission Controls#
Security is built in at every level. OpenCode supports three permission modes:
- Allow: Auto-approve (safe for read-only commands like
git status) - Ask: Prompt for approval (default for write commands)
- Deny: Always block (dangerous operations)
Permissions can be set globally, per-tool, per-file, or per-command. This means you can auto-allow git status while requiring approval for git push — all configured in opencode.json.
7. Auto-Compact Context Management#
OpenCode automatically monitors token usage. When you approach 95% of the model’s context window, it summarizes the conversation history to avoid “out of context” errors. This means you can have long, productive sessions without hitting model limits.
8. Plugin System & Customization#
Custom Commands: Create Markdown files in ~/.config/opencode/commands/ or .opencode/commands/ to define reusable multi-step workflows with named parameters.
Custom Agents: Configure specialized agents with custom system prompts, temperature, step limits, and permission boundaries — all via opencode.json or Markdown files.
Middleware Hooks: Plugins can hook into tool execution lifecycles to audit logs, manage telemetry, or inject custom verification.
Plugin Ecosystem: Tools like opencode-scheduler ↗ extend OpenCode with scheduling, background execution, and more.
Installation#
OpenCode installs on all major platforms:
# Official install script
curl -fsSL https://opencode.ai/install | bash
# Or via npm
npm install -g opencode-ai
# Or via Homebrew (macOS/Linux)
brew install anomalyco/tap/opencode
# Or via Bun
bun install -g opencode-aibashGetting Started#
# Navigate to your project
cd /path/to/project
# Launch OpenCode
opencode
# Inside the TUI:
# 1. Run /connect to add your API provider
# 2. Run /init to generate AGENTS.md with project context
# 3. Start coding!bashOpenCode also supports non-interactive scripting mode for CI/CD:
# Run a single prompt and get JSON output
opencode -p "Find all TODO comments in this project" --jsonbashHow It Works#
OpenCode runs a client/server architecture:
- The Go TUI (client) connects to a Bun/Hono HTTP server (backend)
- The server orchestrates LLM calls through the AI SDK, managing tool calls, context windows, and agent hierarchy
- Client SDK code is generated via Stainless from an OpenAPI spec — any app (mobile, web, script) can interface with OpenCode programmatically
- The model is the brain — native tools (file read/write, bash, grep, glob, LSP diagnostics, webfetch) are its hands
OpenCode vs. Alternatives#
| Feature | OpenCode | Claude Code | Cursor |
|---|---|---|---|
| Open Source | ✅ MIT | ❌ Proprietary | ❌ Proprietary |
| Provider-Agnostic | ✅ 75+ providers | ❌ Anthropic only | ❌ Limited |
| Terminal-Native | ✅ TUI + headless | ✅ CLI | ❌ VS Code fork |
| MCP Support | ✅ Full | ✅ Full | ⚠️ Limited |
| LSP Diagnostics | ✅ Native | ❌ No | ✅ Yes |
| Plugin System | ✅ Commands + agents | ❌ No | ⚠️ Extensions |
| CI/CD Mode | ✅ JSON output | ✅ Text output | ❌ No |
| Local Models | ✅ Ollama, LM Studio | ❌ No | ⚠️ Limited |
The Ecosystem Grows#
OpenCode’s plugin architecture has spawned a growing ecosystem. The opencode-scheduler ↗ plugin, for example, lets you run AI agents on a schedule using your OS native scheduler — perfect for autonomous deal hunting, weekly code audits, or uptime monitoring.
With its open-source MIT license, provider flexibility, and powerful plugin system, OpenCode is becoming the go-to choice for developers who want an AI coding agent that works their way.