OpenCode: The Complete Guide to the Open-Source AI Coding Agent (2026)

If you've spent any time in developer circles in 2026, you've heard the name. OpenCode went from a niche side project to the most-starred open-source coding agent on GitHub in under a year — and it did it without a marketing budget, a funding round, or a single model of its own.

The pitch is simple: a terminal-native AI coding agent that works with any model you want. No vendor lock-in, no subscription for the tool, MIT-licensed, and yours to fork. This guide walks through what it is, how to install and configure it, and the question everyone actually asks — how it stacks up against Claude Code.

As of June 2026, OpenCode has surpassed 180,000 GitHub stars and roughly 7.5 million monthly active developers, making it the most-adopted open-source coding agent ever built.

OpenCode is an open-source, terminal-based AI coding agent that reads your codebase, plans changes, writes and edits code, runs commands and tests, and iterates until a task is done — with your approval at each step. Unlike most agents, it isn't tied to one AI provider: you connect whatever model you prefer, from Claude to GPT to a local Llama.

TL;DR:
  • What it is: A free, MIT-licensed terminal AI coding agent from Anomaly Co. — 180K+ GitHub stars as of June 2026.
  • Model freedom: Bring your own key from 75+ providers, or use the curated OpenCode Zen gateway (50+ coding models, pay-as-you-go).
  • Two agents: Build (full access) and Plan (read-only) — toggle with Tab.
  • Real safety nets: /undo, /redo, and multiple concurrent sessions for parallel work.
  • OpenCode vs Claude Code: Pick OpenCode for open source + model flexibility; pick Claude Code for speed and the deepest Claude-native stack.

📋 What you'll need

Before you start, have these ready:

  • A terminal — macOS, Linux, or Windows (PowerShell or WSL).
  • Node.js 18+ if you install via npm (optional — the install script bundles everything).
  • An AI model connection — either an API key from a provider (Anthropic, OpenAI, Google, Groq, and others) or an OpenCode Zen account. You need at least one.
  • A code project to point it at. OpenCode works best inside a real git repository.

🚀 Why did OpenCode blow up in 2026?

Plenty of coding agents launched in the last two years. Most are tied to a single model vendor, a paid IDE, or a subscription. OpenCode took the opposite bet, and it paid off.

It's genuinely open source. MIT license, public repo, run by Anomaly Co. You can read every line, self-host the pieces, and fork it if you disagree with a decision. For teams nervous about sending their codebase through a black box, that transparency matters.

It's model-agnostic by design. OpenCode is a wrapper around your choice of model. The same tool runs Claude Opus today and GPT-5.5 tomorrow with a one-line config change. When a new model tops the benchmarks, you switch — you don't wait for your vendor to support it.

The terminal experience is the best in class. Fuzzy file search with @, a clean TUI, undo/redo, shareable session links, and multiple concurrent sessions. It feels built by people who live in the terminal, because it was.

The result: a community flywheel. More stars brought more contributors, more providers, and faster releases — the desktop app, background agents, and a VS Code extension all shipped in 2026 alone.

Tip: The "any model" design means OpenCode is also a great way to test whether a cheaper model is good enough for your day-to-day work. Switch the model, keep the workflow, compare the output.

💻 How to install OpenCode

The fastest path is the install script, which handles the binary and dependencies for you:

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

Prefer a package manager? Pick your platform:

Method Command
npm (cross-platform) npm i -g opencode-ai@latest
Homebrew (macOS/Linux) brew install anomalyco/tap/opencode
Arch Linux sudo pacman -S opencode
Chocolatey (Windows) choco install opencode
Scoop (Windows) scoop install opencode

Once installed, drop into a project and launch it:

cd your-project
opencode

That opens the TUI (terminal user interface). You'll be prompted to connect a model before you can do anything useful — which is the next step.


🔌 Connecting a model: OpenCode Zen vs Bring Your Own Key

OpenCode doesn't ship with a model. You connect one with the /connect command inside the TUI. There are two ways to do it.

Bring Your Own Key (BYOK)

Run /connect, pick a provider, and paste your API key. OpenCode supports 75+ providers — Anthropic, OpenAI, Google, AWS Bedrock, Azure OpenAI, Groq, and the long tail of open-model hosts. You pay the provider directly at their per-token rates. This is the path most professionals use because the model costs the same whether you call it through OpenCode or anything else — the wrapper is free.

OpenCode Zen

OpenCode Zen is an optional, curated gateway run by the OpenCode team. Instead of juggling provider accounts, you get one balance and 50+ models that have been benchmarked specifically for coding agents. It's pay-as-you-go.

BYOK OpenCode Zen
Setup One key per provider One account
Model choice 75+ providers 50+ curated coding models
Billing Pay each provider Single pay-as-you-go balance
Free options Provider free tiers 5 free trial models 🆓
Data retention Per provider policy Mostly zero-retention (US-hosted)
Best for You already have keys You want zero setup friction

Zen pricing is per million tokens and varies by model — for example, premium tiers like Claude Fable 5 ($10–$50/M) and GPT-5.5 ($5–$45/M), down to cheap Haiku-class models ($1–$5/M) and a handful of free trial models. Note Zen adds card-processing fees (4.4% + $0.30 per transaction) and auto-reloads your balance when it drops below a threshold.

Warning: Zen's free trial models (Big Pickle, DeepSeek Free, and similar) may use your data to improve the model. For private codebases, stick to the paid zero-retention models or your own provider key.

🤖 Build vs Plan: the two agents

OpenCode ships with two built-in agents, and switching between them is the single most useful habit to learn. Press Tab to toggle.

  • Build (default): Full access. It can read files, write code, run shell commands, and execute tests. This is where the actual work happens.
  • Plan (read-only): Analyzes your codebase and proposes an approach without touching a single file. Nothing gets written.

The workflow that works: start in Plan for anything non-trivial. Let the agent read the code and lay out its plan. Read it, correct it, then Tab into Build to execute. You catch bad assumptions before they become bad commits, which is far cheaper than reviewing a 20-file diff after the fact.

There's also a general subagent OpenCode can spin up for complex, multi-step searches across a large codebase — handy when "where is this even defined" is the real question.


📂 Project setup: /init and AGENTS.md

The first thing to run in any new project is /init. It analyzes your project structure and generates an AGENTS.md file in the root.

# inside the OpenCode TUI
/init

AGENTS.md is the agent's briefing document — your framework, conventions, important files, and the patterns you want followed. The agent reads it on every session, so a good one dramatically cuts repeated explanations.

Commit AGENTS.md to git. It's shared context: every teammate (and every CI run) gets the same instructions, so the agent behaves consistently across your whole team rather than relearning your conventions per machine.

If AGENTS.md sounds familiar, it should — it's the cross-tool successor to project instruction files like CLAUDE.md. We cover the whole standard and how the formats differ in our CLAUDE.md vs AGENTS.md guide.


🧩 Skills, MCP, and extending OpenCode

Out of the box OpenCode is capable, but the real power is in extending it. Two mechanisms matter.

MCP servers. OpenCode supports the Model Context Protocol, the open standard for giving agents access to external tools and data — databases, browsers, ticketing systems, your internal APIs. Add an MCP server in the config and the agent can call it like any other tool. If you're new to MCP, start with our MCP servers explained guide.

Agent Skills. Skills are reusable, packaged instructions for recurring tasks — "write a migration our way," "scaffold a new endpoint," "review this for our security rules." Define them once and invoke them anytime, instead of re-typing the same long prompt.

Together, skills and MCP turn OpenCode from a generic assistant into one that knows your stack. This is the same extensibility model the other major agents have converged on in 2026 — a good sign the patterns are stabilizing.


↩️ Undo, redo, and multiple sessions

Two features make OpenCode feel safe to actually use on real code.

Undo and redo without git gymnastics. The /undo command reverts the agent's last change and restores your previous message so you can refine it. /redo reapplies it. This is independent of git — a critical safety net when an agent confidently rewrites a file you liked. There's also /share to generate a link to a conversation for a teammate.

Multiple concurrent sessions. Each session keeps its own conversation history and context. You can run a long debugging session in one and a feature build in another, side by side, without them stepping on each other. With the 2026 desktop release, background agents push updates without you polling — a real shift toward always-on, parallel agentic work rather than one blocking conversation.

Session 1: debugging the failing auth test  ──►  (read-heavy, Plan mode)
Session 2: building the new export feature   ──►  (write-heavy, Build mode)

🖥️ The VS Code extension and desktop app

OpenCode isn't terminal-only anymore.

The VS Code extension brings the full agent into your editor. You interact with it the same way you would in the TUI, and it shares the exact same config, agents, and MCP servers — so you're not maintaining two setups. The win is direct editor integration: diffs, file navigation, and inline edits without leaving VS Code.

The desktop app (Desktop v2 shipped May 2026) adds a proper home screen, titlebar session controls, pinch zoom, and background agents. It's the most polished surface for people who want the agent running continuously rather than launched per task.

Pick the surface that fits: TUI for keyboard-driven flow, VS Code for editor integration, desktop for always-on background work.


⚖️ OpenCode vs Claude Code: which should you use?

This is the comparison everyone wants, so here's the straight answer up front. Pick OpenCode if open source, model flexibility, and terminal control matter most. Pick Claude Code if you want the fastest, deepest Claude-native experience with official surfaces everywhere. Both are excellent; they optimize for different things.

Dimension OpenCode Claude Code
License 🟢 Open source (MIT) 🔴 Proprietary
Models 🟢 Any provider (75+) 🟡 Claude only
Speed 🟡 Good, occasionally slower 🟢 Optimized for low latency
Cost of tool 🟢 Free (pay providers) 🟡 Subscription or API key
Instruction-following 🟢 Strong 🟢 Best-in-class (Claude-tuned)
Official surfaces 🟡 TUI, VS Code, desktop 🟢 Terminal, IDEs, desktop, web, CI
Vendor lock-in 🟢 None 🔴 Anthropic ecosystem

A few things the table doesn't capture:

Speed. Claude Code wins. Anthropic tuned it for minimal latency between your prompt and the agent acting. OpenCode can feel slower, especially when it decides to run a full test suite — though that thoroughness is often a feature, not a bug.

The January 2026 OAuth block. This caught a lot of people out. Early in 2026, Anthropic blocked third-party tools from authenticating with Claude subscription credentials. Overnight, routing a Claude Max plan through OpenCode stopped working. As of 2026, the only supported way to use Claude models in OpenCode is a pay-per-token API key — not your Pro or Max subscription. Budget accordingly, or run OpenCode with a different provider.

Cost in practice. The model costs the same through either tool; the difference is the wrapper. Claude Code's subscriptions ($20/mo entry, $100/mo Max for heavy users) can be more predictable for all-Claude shops. OpenCode's BYOK can be cheaper if you mix in cheaper models for routine work and save the expensive ones for hard problems.

For the full multi-tool picture including Codex and Gemini CLI, see our terminal AI agents comparison.


🧱 Rough edges (the honest part)

No tool is all upside. A few things to know before you commit:

  • Speed dips on big tasks. When it runs a full test suite or scans a large repo, you'll wait. Not a dealbreaker, but noticeable next to Claude Code.
  • The Claude subscription block stings. If you're paying for Claude Max already, you can't reuse it here — you'll pay API rates on top. This is Anthropic's decision, not OpenCode's, but it's your wallet either way.
  • More setup than a closed tool. Model freedom means you choose and configure the model. That's a feature for power users and a small hurdle for beginners.
  • Free Zen trial models and privacy. The free models may train on your data. Easy to avoid, but easy to miss.

None of these are reasons to skip it. They're the price of an open, flexible tool — and for most developers, a fair trade.


🔧 Troubleshooting

Problem Solution
/connect fails or model won't respond Re-check the API key and confirm the provider account has billing enabled and credits available.
Claude Max subscription rejected Expected since Jan 2026 — switch to a Claude API key, or use a different provider/Zen.
Agent edits the wrong files Start in Plan mode (Tab), review the plan, then switch to Build. Tighten your AGENTS.md.
Agent ignores your conventions Run /init and flesh out AGENTS.md with explicit rules; commit it so it loads every session.
Accidental bad edit /undo to revert instantly — no git reset needed.
Zen balance keeps reloading Lower the auto-reload threshold/amount in Zen workspace settings, or set spending limits.

You'll know it's working when you launch opencode in a repo, ask it to make a small change, watch it propose a plan, approve it, and see the diff applied — then /undo it cleanly. That round trip is the whole product in 30 seconds.


❓ Frequently Asked Questions

Is OpenCode free?
The OpenCode software is free and open source under the MIT license. You only pay for the AI models you use — either by bringing your own API key from a provider like Anthropic or OpenAI, or via OpenCode Zen's pay-as-you-go gateway. There is no subscription for the tool itself.

What is the difference between OpenCode and Claude Code?
OpenCode is open source and model-agnostic — it connects to 75+ providers including Claude, GPT, and Gemini. Claude Code is Anthropic's official CLI, tuned for Claude models, with faster responses and official integrations across IDEs, desktop, and CI. Pick OpenCode for model freedom; pick Claude Code for the deepest Claude-native experience.

Can I use my Claude Pro or Max subscription with OpenCode?
No. In January 2026 Anthropic blocked third-party tools from using Claude subscription credentials. As of 2026, the only supported way to use Claude models inside OpenCode is a pay-per-token API key, not a Pro or Max subscription.

Does OpenCode support MCP servers and skills?
Yes. OpenCode supports both Model Context Protocol (MCP) servers and Agent Skills, configured through its config file and the AGENTS.md project file. This lets you extend the agent with custom tools and reusable instructions.

What is OpenCode Zen?
OpenCode Zen is an optional, curated AI gateway run by the OpenCode team. It offers 50+ coding-benchmarked models on a pay-as-you-go basis with mostly zero data retention, so you can switch models without managing separate provider accounts.


🎯 What's Next


Deciding between OpenCode, Claude Code, and the rest of the field? Start with our AI coding agents compared guide — and if you want help choosing and rolling out an agentic coding workflow for your team, talk to us about AI engineering consulting.


Share Your Thoughts

Read More

AI Automation for Small Business: Where to Start in 2026
AI Coding Agents Compared: Cursor vs Copilot vs Claude Code vs Windsurf in 2026
AI Coding Agents and Security Risks: What You Need to Know
AI Pair Programming: The Productivity Guide for 2026
AI SRE Agents Explained: Platform Comparison and Pilot Guide for 2026
AI UI Testing with Vision Agents (2026): Catch Visual Bugs Before They Ship
Browse all AI-Assisted Engineering articles

Stay Ahead

Only insights that save you time or money. No fluff, ever.

Stay Ahead

Only insights that save you time or money. No fluff.