What Is OpenCode?
OpenCode is an open-source coding agent. You describe a change in plain language, and it reads your code, edits files and runs shell commands to make that change, using whichever language model you connect to it. It is for developers who want the agentic workflow popularized by Claude Code without tying themselves to one model vendor or one closed client.
It comes in several forms that share one engine: a full-screen terminal UI (the original and still the main one), a desktop app for macOS, Windows and Linux, a browser UI that opencode pair serves from your own machine through a one-time link that expires after five minutes, and Docker images on ghcr.io/anomalyco/opencode. A VS Code extension and an opencode acp mode for editors such as Zed connect it to an editor, with limits covered below.
The project is written in TypeScript, MIT licensed and maintained by Anomaly. The repository had 229,497 stars when we checked on November 27, 2026, up from about 216,000 when this page first went up in October, and its website claims more than 22 million developers use it each month, a figure that comes from the company and is not independently verifiable.
OpenCode 1 and OpenCode 2 Share a Command Name but Not a Feature Set
As of November 27, 2026, GitHub's Latest release badge on the repository still points at v1.19.6, published on November 17. But v2.4.2 shipped on November 26, the README's install commands now fetch version 2, and the current docs describe version 2. Old tutorials, including the README's own agent section, often describe version 1.
The two lines no longer install side by side. Both use the opencode command, so the migration guide says to remove a package-managed V1 install first; the V2 curl script replaces the V1 binary. The current install options are:
curl -fsSL https://opencode.ai/v2/install | bash # installs to $HOME/.opencode/bin
brew install anomalyco/tap/opencode-v2 # macOS and Linux
npm install -g @opencode/cli # also bun, pnpm, yarn
mise use -g opencode # needs mise 2026.10.9 or laterTwo traps hide in that list. An older mise installs OpenCode 1 instead. And Windows package managers are not supported for V2, so the Scoop and Chocolatey commands in older guides are out of date; on Windows, download the standalone x64 or ARM64 binary or the desktop installer. On Linux, the desktop app also comes as an AppImage, which arrives from a browser download without the execute bit; run chmod +x on it (mode 755 in the Chmod Calculator) before launching it.
The case for upgrading is that version 1 now gets only critical fixes and no longer serves OpenCode's free models. The pinned free-tier issue (#59387) lists the errors people hit, such as "This version of OpenCode Desktop no longer supports free models", and warns that the V1 desktop app's built-in updater keeps you on 1.x, so V2 Desktop has to be downloaded manually.
Version 2 has three intentional breaking changes: plugins use a new API and V1 plugins do not run, the server API and its clients have new contracts, and terminal settings move from layered tui.json files to one global cli.json, which is migrated automatically. Your opencode.json or opencode.jsonc files, agent and command definitions, and skills are read from the same places and normalized in memory, so they should keep working unchanged.
The docs suggest asking OpenCode itself to convert the config to the native V2 shape. If you do, keep a copy of the old file and compare the two in a Text Diff before you delete it: an agent has just rewritten the file that controls what the agent is allowed to do, and the global config in ~/.config/opencode/ is usually not under Git, so git diff will not show you the change.
One gap is still open. Version 1 fed language-server diagnostics back to the model; porting the LSP service to V2 is an open issue (#38528), and the LSP docs page exists only in the V1 docs. Formatters are back in V2, but they stay off until you set "formatter": true.
Build and Plan Are Permission Profiles, and the Defaults Are Permissive
OpenCode ships two primary agents, build and plan, plus subagents that a primary agent launches into a child session. In V2 you cycle the primary agents with Shift+Tab (V1 used Tab, which is what the README still says), and <leader>a, Ctrl+X then A by default, lists them all.
The differences between agents are not separate programs; they are permission rules layered on one base policy. Every agent, including any you define, starts from this list:
[
{ "action": "*", "resource": "*", "effect": "allow" },
{ "action": "read", "resource": "*.env", "effect": "ask" },
{ "action": "read", "resource": "*.env.*", "effect": "ask" },
{ "action": "read", "resource": "*.env.example", "effect": "allow" }
]The first line is the one to notice: by default everything is allowed, and only reading environment files triggers a prompt. The shipped agents then add their own rules:
| Agent | Type | What it adds to the base policy |
|---|---|---|
| build | primary, the default | Allows it to ask you questions |
| plan | primary | Denies file edits, except plan files under ~/.opencode/plan |
| general | subagent | Cannot ask questions or launch further subagents |
| explore | subagent | Denies everything except shell, reads, glob, grep, web fetch and web search |
Three practical consequences follow.
- Build runs shell commands without asking. Installing packages, deleting files and running migrations all go through unless you add a rule.
- Plan is not fully read-only. The README says plan asks permission before running bash commands, but neither V2's source nor the later V1 docs bear that out. The plan agent adds only the edit rules above, so shell commands fall through to the base
allow. The edit deny covers OpenCode's edit, write and patch tools, not ased -ior a>redirect run through the shell. - Paths outside the project are open. V1 asked before reading or editing files outside the project directory. V2 allows
external_directoryby default.
If you want plan to behave the way the README describes, override the built-in by its ID:
{
"$schema": "https://opencode.ai/config.json",
"agents": {
"plan": {
"permissions": [
{ "action": "shell", "resource": "*", "effect": "ask" }
]
}
}
}Permission Rules Read Top to Bottom, and the Last Match Wins
V2 replaced V1's per-tool permission map with one ordered permissions array. Each rule has an action, a resource and an effect of allow, deny or ask, and when several rules match, the last one wins. That means you write the broad rule first and the exceptions after it. This is the docs' recommended starting point for shell access:
{
"$schema": "https://opencode.ai/config.json",
"permissions": [
{ "action": "shell", "resource": "*", "effect": "ask" },
{ "action": "shell", "resource": "git status *", "effect": "allow" },
{ "action": "shell", "resource": "git diff *", "effect": "allow" },
{ "action": "shell", "resource": "git push *", "effect": "deny" },
{ "action": "external_directory", "resource": "*", "effect": "ask" }
]
}The matching rules are short enough to learn in one sitting:
- Patterns match the whole value.
*matches any characters including/,?matches exactly one, and matching is case-insensitive on Windows. - A shell pattern ending in a space and
*also matches the bare command, sogit status *coversgit statustoo. - When one operation touches several resources, such as a patch across three files, any
denyblocks it, otherwise anyaskprompts. - If no rule matches at all, the answer is
ask. - Rules are concatenated in load order: lower-priority config first, then global rules, then the agent's own rules, so an agent can always refine the global list.
Action names changed between versions, and old names are a common reason a migrated rule silently stops matching: bash is now shell, task is now subagent, and write and patch are folded into edit.
Shell rules are checked against what OpenCode's built-in scanner extracts from the command. It parses Bash, Zsh, POSIX sh and PowerShell and checks each subcommand of a compound command separately. Commands it cannot analyze, such as anything using eval, fail outright if any shell deny rule applies, and otherwise need approval as a whole. The docs are direct about the limit: shell runs with your user's full file, process and network authority, and directory detection from command text is best effort, so a short allowlist is safer than a long list of dangerous commands to deny.
For teams there is one more layer. Plain permissions rules can be refined by any later rule, including a user's own agent rules, so the docs say restrictions an administrator must enforce belong in policies, set in the system config directory, where they outrank global and project policies (/etc/opencode on Linux, /Library/Application Support/opencode on macOS, %ProgramData%\opencode on Windows).
Connecting a Model: API Keys, ChatGPT, Copilot, a Claude Plan or Ollama
Inside the terminal UI, /connect adds a provider and /models picks a model. The provider and model catalog comes from models.dev; the V1 docs put it at more than 75 providers. A few connection types deserve a closer look because they change what you pay:
| Connection | What you need | How it is billed |
|---|---|---|
| Any API provider | An API key | The provider's per-token prices |
| ChatGPT | A Plus or Pro plan; choose "Sign in with ChatGPT" under OpenAI | Counts against your ChatGPT plan |
| GitHub Copilot | Device login, with Copilot Chat access on the account | Your Copilot plan; Copilot Free qualifies |
| Claude Agent | Claude Code 2.1.248 or later, signed in with claude auth login | Your Claude plan, or your API account if Claude Code uses a key |
| Ollama | ollama serve running locally | Free; your own hardware |
| OpenCode Go | A subscription from OpenCode | $10, $40, or $20 per member a month |
Claude Agent works differently from the rest. OpenCode starts the Claude Code you already have installed, Claude Code calls the model, and OpenCode supplies its own tools, permissions, subagents and compaction. Your Claude Code settings, CLAUDE.md files, hooks, MCP servers and memory are not loaded, so this route keeps your Claude subscription but not your Claude Code setup.
Ollama needs no account at all: OpenCode probes http://127.0.0.1:11434 and lists the models it finds. Expect a small local model such as qwen3:8b to handle long, multi-step agent tasks less reliably than a large hosted model.
OpenCode Go is the vendor's own subscription for a curated set of open coding models. Its limits are worth reading before you buy: a rolling 5-hour window allows 20% of the monthly allowance and a weekly window allows 50%, resetting Mondays at 00:00 UTC. The Console also lists a few models as free "for a limited time", available in V2 only.
Undo Is a Private Git Snapshot, and It Does Not Cover Everything
/undo (or <leader>u) rolls back the last exchange: it restores the files the agent changed and puts your prompt back in the composer so you can rephrase it. /redo cancels the rollback until you submit again. It works because OpenCode attempts a snapshot before and after every model step and records which paths changed in between.
Those snapshots live in a separate Git object database under OpenCode's data directory. They do not create commits, move branches or touch your index, but they depend on Git being there, and their scope is narrower than many people expect:
| Content | Restored by /undo |
|---|---|
| Tracked files under the session's directory | Yes |
| Untracked, non-ignored files up to 2 MiB each | Yes |
Git-ignored files, such as dist/ | No |
| Files outside the directory the session was opened in | No |
| Commits, branches, database changes, running processes | No |
Outside a Git repository, /undo rolls back the conversation but cannot restore files. A session opened in packages/app will not undo the agent's edits to packages/server. And a migration the agent ran against your development database stays run. The docs' own advice is to treat snapshots as a convenience and keep real commits for anything that matters.
The same storage bears on privacy. OpenCode's enterprise docs state that it "does not store your code or context data": requests go from your machine straight to the provider you chose. That holds for the open-source client, with two caveats. Snapshot objects hold complete copies of your files, so the data directory deserves the same care as the repository. And the enterprise docs, written for V1, recommend that teams disable share pages, which publish a session at a link OpenCode hosts, if code must stay in-house.
Who Should Use OpenCode, and Who Should Stay With Claude Code
OpenCode makes the most sense if you want to choose the model per task or per budget, already pay for ChatGPT, Copilot or a Claude plan and want one client for all of them, need local models through Ollama, or want an agent whose permission rules live in a JSON file you can review and commit. Being able to read the source of the tool that runs commands on your machine is a real advantage over a closed client.
Claude Code remains the better fit in three situations:
- You depend on Claude Code's own setup.
CLAUDE.mdfiles, hooks and Claude Code plugins do not carry over, even through the Claude Agent provider. - You want cautious defaults without configuring anything. Claude Code asks before edits and shell commands out of the box. OpenCode's build agent asks only before reading
.envfiles until you add rules. - You rely on language-server feedback. V2 has not yet regained V1's LSP diagnostics.
Editor integration is thinner than "works in your editor" suggests. The VS Code extension, which also installs in Cursor, Windsurf and VSCodium, opens the terminal UI in a split terminal with Cmd+Esc or Ctrl+Esc, shares your current selection, and inserts file references such as @File#L37-42. It is not a native chat panel, and an official panel-style extension is the most upvoted open issue in the repository (#11176). Zed users get a closer fit through opencode acp, which runs OpenCode as an Agent Client Protocol server.
The practical recommendation: install V2, add an ask rule for shell and external_directory before your first real session, and work inside a Git repository so /undo can actually restore your files.



