DevPik Logo
open sourceai agentscoding agentclaude codedeveloper toolsterminal

OpenCode: The Open-Source AI Coding Agent With 216,000 GitHub Stars

OpenCode is an open-source coding agent that works with almost any model, including your ChatGPT, Copilot or Claude plan. Version 2 changed its install, its keybinds and its permission rules, and the defaults are loose: the build agent runs shell commands without asking, and plan mode does not ask either. Here is how to set it up safely.

ByMuhammad Tayyab10 min read
All open source picks
anomalyco/opencode
The official repository — this write-up is not affiliated with the project.
229.5kTypeScriptMIT

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:

bash
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 later

Two 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:

jsonc
[
  { "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:

AgentTypeWhat it adds to the base policy
buildprimary, the defaultAllows it to ask you questions
planprimaryDenies file edits, except plan files under ~/.opencode/plan
generalsubagentCannot ask questions or launch further subagents
exploresubagentDenies 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 a sed -i or 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_directory by default.

If you want plan to behave the way the README describes, override the built-in by its ID:

jsonc
{
  "$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:

jsonc
{
  "$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, so git status * covers git status too.
  • When one operation touches several resources, such as a patch across three files, any deny blocks it, otherwise any ask prompts.
  • 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:

ConnectionWhat you needHow it is billed
Any API providerAn API keyThe provider's per-token prices
ChatGPTA Plus or Pro plan; choose "Sign in with ChatGPT" under OpenAICounts against your ChatGPT plan
GitHub CopilotDevice login, with Copilot Chat access on the accountYour Copilot plan; Copilot Free qualifies
Claude AgentClaude Code 2.1.248 or later, signed in with claude auth loginYour Claude plan, or your API account if Claude Code uses a key
Ollamaollama serve running locallyFree; your own hardware
OpenCode GoA 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:

ContentRestored by /undo
Tracked files under the session's directoryYes
Untracked, non-ignored files up to 2 MiB eachYes
Git-ignored files, such as dist/No
Files outside the directory the session was opened inNo
Commits, branches, database changes, running processesNo

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.md files, 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 .env files 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.

Frequently Asked Questions

Is OpenCode free?

The software is free and MIT licensed. You pay whichever model provider you connect, or use a ChatGPT, Copilot or Claude plan you already have; OpenCode Go is an optional $10 a month subscription, and a few models are offered free for a limited time in version 2 only.

Should I install OpenCode 1 or OpenCode 2?

Version 2. Version 1 receives only critical fixes and no longer serves OpenCode's free models. Stay on 1.x only if you depend on a V1 plugin or on language-server diagnostics, which V2 has not ported yet.

Does OpenCode ask before running shell commands?

Not by default. The base policy allows every action except reading .env files, so add a rule such as { "action": "shell", "resource": "*", "effect": "ask" } to the permissions array in opencode.jsonc.

Can I use my Claude subscription with OpenCode?

Yes, through the Claude Agent provider, which runs your installed Claude Code (2.1.248 or later) as the model backend. OpenCode supplies the tools and permissions, and your CLAUDE.md files, hooks and Claude Code settings are not loaded.

Does OpenCode run on Windows?

Yes, as a standalone x64 or ARM64 binary or the desktop app. The version 2 docs state that Windows package managers are not supported, so Scoop and Chocolatey instructions in older guides no longer apply.

Can OpenCode use local models?

Yes. Start Ollama, pull a model, and OpenCode finds it at 127.0.0.1:11434 without any account setup. Small local models are much weaker at multi-step agent work than hosted frontier models.

Does OpenCode upload my code?

The project says it does not store your code: requests go directly to the model provider you chose. Share pages publish a session on a link OpenCode hosts, and local undo snapshots keep full copies of your files in OpenCode's data directory.

Related DevPik tools

Muhammad Tayyab

Written by

Muhammad Tayyab

Founder of DevPik

Muhammad Tayyab founded DevPik and builds its free developer tools. He writes about developer tools, AI and web technology.

More open source picks