OpenCode and Claude Code are two of the most-starred terminal coding agents on GitHub, with about 217,000 and 152,000 stars. OpenCode is an MIT-licensed agent from Anomaly that works with 75+ model providers and local models. Claude Code is Anthropic’s proprietary agent, built for Claude models and sold with Claude subscriptions. We compared them on features, models, pricing, permissions, telemetry and one thing most comparisons skip: where each tool keeps your API keys.
That last question became urgent this week. On October 17, 2026, OpenCode posted that it “had a security breach last night related to a large scale distillation attack that impacted 1.4% of OpenCode Console users” (via IBTimes, StepSecurity). The scope matters. The hosted Console, a web workspace that can store provider keys, was hit. The CLI on your machine was a separate case, and co-founder dax said so directly: “note this is the OpenCode Console, not OpenCode itself, those keys never come to us” (same IBTimes report).
We build Atomic Agent, a third option covered near the end with that disclosure. Everything about OpenCode and Claude Code was checked on October 19, 2026, against their docs, GitHub and npm, plus OpenCode’s source code.
Quick answer: OpenCode or Claude Code?
Pick Claude Code if you already pay for Claude Pro ($20 a month, $17 on annual billing) or Max (from $100) and want the top-ranked agent on Terminal-Bench 4.0: 64.85% with Opus 5.5 at max effort, where OpenCode has no entry. Pick OpenCode for a free MIT tool, 75+ providers, local models or a ChatGPT or Copilot login.
| If you | Pick | Why |
|---|---|---|
| Pay for Claude Pro or Max | Claude Code | The subscription covers it; Anthropic’s terms bar third-party tools from using it |
| Want to switch between GPT, Gemini, GLM, Kimi and Claude | OpenCode | 75+ providers through one config |
| Run models on your own GPU | OpenCode | Documented Ollama, LM Studio and llama.cpp setups |
| Want a sandbox around shell commands | Claude Code | OS sandbox on macOS, Linux and WSL2 |
| Want the strongest local key storage on a Mac | Claude Code | Its login sits in the encrypted macOS Keychain |
| Want an open-source tool you can audit and fork | OpenCode | MIT license, 217,412 GitHub stars |
OpenCode vs Claude Code at a glance
The biggest differences: OpenCode is MIT licensed with 217,412 stars and Claude Code is proprietary with 152,453; OpenCode starts from permissive defaults, looser still in v2, while Claude Code usually starts in auto mode with a classifier; Claude Code’s login uses the macOS Keychain while OpenCode writes plaintext. Values checked October 19, 2026.
| OpenCode | Claude Code | |
|---|---|---|
| License | MIT | Proprietary (Anthropic Commercial Terms) |
| GitHub stars | 217,412 | 152,453 (the repo holds issues and plugins only) |
| Latest version | v1.19.3 (Oct 16, 2026); v2 line @opencode/cli 2.0.32 (Oct 16, 2026) | v2.1.303 (Oct 18, 2026) |
| Models | 75+ providers via AI SDK and Models.dev | Claude models only |
| Subscription logins | ChatGPT Plus/Pro, GitHub Copilot, GitLab Duo | Claude Pro, Max, Team, Enterprise |
| Local models | Documented: Ollama, LM Studio, llama.cpp | Unofficial, through Ollama’s compatible API |
| Default permissions | Everything allow (v2); most tools allow (v1) | Auto mode (classifier reviews actions) since v2.1.283, where model and org allow |
| Sandbox | None documented | OS sandbox for shell on macOS, Linux, WSL2 |
| Key storage | Plaintext auth.json (v1) or SQLite (v2) | Login in macOS Keychain; ~/.claude/.credentials.json elsewhere |
| Telemetry | CLI: none found; desktop app: Sentry error reports (undocumented) | On by default, opt-out env vars |
| Share links | Public link via /share (v1) | None; /share sends transcript to Anthropic |
| Price | Free tool; Go $10 or $40/month; Zen pay-as-you-go | Pro $17-$20/month; Max $100 or $200; API per token |
Features: agents, plan mode, MCP, hooks and memory
Both tools cover the same core: a plan mode, subagents, MCP servers, skills, custom commands, memory files and automatic context compaction. Claude Code goes deeper on lifecycle hooks and permission modes. OpenCode adds built-in LSP with automatic server downloads, more interfaces, and a v1/v2 release split that changes its defaults and how it stores keys.
Plan and build. OpenCode ships two primary agents, Build with all tools and Plan with restricted ones, and Tab switches between them (agents docs). Claude Code treats planning as one of several permission modes: plan, Manual, acceptEdits, auto, dontAsk and bypass.
Subagents. OpenCode has three built-in subagents (General, Explore and Scout) plus custom agents you define in config or Markdown and call with an @-mention. Claude Code has subagents in .claude/agents, including background subagents.
MCP, LSP and hooks. Both support MCP servers. OpenCode has built-in LSP integration that downloads language servers on its own, switchable off with OPENCODE_DISABLE_LSP_DOWNLOAD. Claude Code loads LSP servers through plugins. For hooks, Claude Code has a dedicated system of lifecycle hooks; OpenCode’s JavaScript and TypeScript plugins can subscribe to events, with no separate hooks page.
Memory files and skills. Claude Code reads CLAUDE.md, can read a repo’s AGENTS.md instead, and has auto memory (memory docs). OpenCode creates AGENTS.md with /init and also reads ~/.claude/CLAUDE.md and .claude/skills unless you set the OPENCODE_DISABLE_CLAUDE_CODE* flags. So your existing CLAUDE.md and skills carry over without changes.
Interfaces. OpenCode runs as a TUI, a desktop app, IDE extensions for VS Code, Cursor, Zed, Windsurf and VSCodium, a web UI, a headless server, and GitHub and GitLab agents. Claude Code runs in the terminal, VS Code and JetBrains, a desktop app, the web at claude.ai/code, and GitHub Actions.
The v1/v2 split. OpenCode now ships two lines. GitHub releases and the npm package opencode-ai are at v1.19.3. The download page installs v2 instead, through opencode.ai/v2/install or npm install -g @opencode/cli (2.0.0 shipped September 11, 2026). Most published comparisons describe v1. The difference matters for permissions and key storage, covered below; run opencode --version to see which one you have.
Models and local models
OpenCode is model-agnostic: 75+ providers and documented local setups for Ollama, LM Studio and llama.cpp. Claude Code is built for Claude. Anthropic says it does not support routing it to non-Claude models, though Ollama documents a working path. On local hardware, OpenCode is the supported choice.
OpenCode’s provider docs cover cloud APIs, gateways and local servers through one config. Local models connect as OpenAI-compatible endpoints, for example Ollama at http://localhost:11434/v1. The docs advise raising Ollama’s num_ctx to 16k-32k if tool calls fail, and Ollama’s own docs add ollama launch opencode for automatic setup (Ollama).
Claude Code authenticates with a Claude subscription, the Claude Console, or cloud platforms such as Amazon Bedrock, Google Cloud and Microsoft Foundry (authentication docs). The LLM gateway docs are explicit that Anthropic “doesn’t support routing Claude Code to non-Claude models through any gateway.” Ollama’s own Claude Code integration still works: ollama launch claude, or ANTHROPIC_BASE_URL plus ANTHROPIC_AUTH_TOKEN set by hand, with 64k or more tokens of context recommended. Treat it as a path Ollama supports and Anthropic does not.
The Terminal-Bench leaderboard even lists Claude Code runs with GLM-5.3 and Qwen3.8-Max, so the harness can drive other models through compatible endpoints.
Pricing: Claude Pro, Max and API vs OpenCode Go and Zen
A Claude subscription with Claude Code starts at $17 a month (Pro, billed annually) or $20 billed monthly; Max costs $100 or $200. OpenCode is free, and you pay providers directly, nothing for local models, $10 or $40 a month for OpenCode Go, or per request on Zen. Anthropic’s terms bar using Claude Pro or Max inside OpenCode.
Claude Code (claude.com/pricing):
- Free: no Claude Code.
- Pro: $20 a month billed monthly, or $17 a month on annual billing ($200 up front).
- Max: $100 a month for Max 5x and $200 for Max 20x, billed monthly only (Max plan help page). Max includes $100-$200 a month in API credits for the Claude Platform.
- Team: Standard seats $25 a month ($20 annual), Premium seats $125 ($100 annual) with 5x the usage.
- Enterprise: $20 per seat per month billed annually, 20-seat minimum, plus usage at API rates.
- API: per million tokens, Opus 5.5 is $4 in and $20 out, Sonnet 5.5 $2 and $10, Haiku 5.5 $0.10 and $0.50, Fable 5.1 $10 and $50. Batch saves 50%.
If an API key or gateway credential is active, Claude Code bills per token in place of your subscription, so check which one you are using.
OpenCode:
- The tool: free, MIT. Bring a key from any provider, or run local models at no token cost.
- OpenCode Go: $10 a month (Go) or $40 (Go Plus), with monthly dollar limits per model; a 5-hour window can use 20% of the monthly amount and a week 50%. The roster includes GLM, Kimi, DeepSeek, Qwen, MiniMax, Grok, GPT 6 Luna and Claude Haiku 5.5. Go also works in validated third-party clients, Claude Code among them.
- OpenCode Zen: a pay-as-you-go gateway of curated models. Card fees pass through at cost (4.4% + $0.30), and auto-reload adds $20 when the balance drops below $5 unless you change it. Claude Opus 5.5 on Zen costs the same $4 and $20 per million tokens as Anthropic’s list price.
Can you use Claude Pro or Max in OpenCode? No. Anthropic’s legal and compliance page says it does not permit third-party developers “to route requests through Free, Pro, or Max plan credentials on behalf of their users.” OpenCode’s provider docs say the same, “Anthropic explicitly prohibits this,” and note that OpenCode stopped bundling such plugins as of 1.3.0. Community plugins exist but break those terms. In OpenCode, Claude models need an Anthropic API key or Zen. ChatGPT Plus and Pro, GitHub Copilot and GitLab Duo logins work with zero setup.
Permissions and sandboxing
Claude Code starts more cautiously. Since v2.1.283, terminal and VS Code sessions start in auto mode, where a classifier reviews each action, when the model and organization allow it, otherwise in Manual. An optional OS sandbox wraps shell commands. OpenCode starts permissive in v1 and more so in v2, with no sandbox documented.
OpenCode resolves each tool to allow, ask or deny, with glob patterns per command and path. In v1.19.3, per the permissions docs, “Most permissions default to allow”: doom_loop and external_directory ask first, and .env reads are denied. The v2 line that the download page installs is looser. Its permissions docs allow everything by default and make .env reads ask, and the v1 migration guide warns: “V1 asks before accessing paths outside the project. V2 does not.” In both lines the --auto flag approves anything not explicitly denied. You can tighten all of this in config, and Plan mode limits tools by design.
Claude Code’s auto mode sends actions past a classifier; Manual mode asks before edits, shell commands and network access, and deny rules apply in every mode. Its sandbox isolates Bash, PowerShell and Monitor on macOS, Linux and WSL2. It has limits: native Windows runs unsandboxed, and file tools, MCP servers and hooks run outside the sandbox.
Where your API keys live
Claude Code keeps its login in the encrypted macOS Keychain on a Mac and in a 0600 file elsewhere. OpenCode keeps provider keys in a plaintext file: auth.json in v1, a SQLite database in v2. Neither CLI uploads third-party provider keys to a vendor-hosted store. The October breach involved keys that users had saved in the hosted OpenCode Console.
| OpenCode v1.19.3 | OpenCode v2 (@opencode/cli) | Claude Code | |
|---|---|---|---|
| Login / stored credential | ~/.local/share/opencode/auth.json | credential table in ~/.local/share/opencode/opencode.db | macOS Keychain; Linux ~/.claude/.credentials.json; Windows %USERPROFILE%\.claude\.credentials.json |
| Protection | Plain JSON, mode 0600 | Plain text column, no encryption found | Keychain on macOS; 0600 file on Linux; profile permissions on Windows |
| Hosted copy | Only keys you add to a Console workspace | Same | No vault for third-party keys |
OpenCode v1. Keys you add with /connect go to auth.json. The source writes that file as JSON with 0600 permissions (auth/index.ts at v1.19.3). Sessions, messages and your OpenCode Console login tokens sit separately in opencode.db in the same folder; opencode db path prints its location, and OPENCODE_DB overrides it.
OpenCode v2. A database migration on the dev branch, which the v2 line builds from, import_legacy_credentials, reads auth.json and copies API keys and OAuth tokens into a credential table in opencode.db. OpenCode’s v2 provider docs confirm that v2 imports auth.json and stores new credentials only in SQLite. Neither the docs nor the migration code delete the old file, so after an upgrade your keys may sit in both places. Delete auth.json yourself once v2 works; opencode debug paths db prints the v2 database path. Searching the source for keychain or encryption code turned up nothing for credential storage in either line.
That explains the conflicting reports. Some news coverage said OpenCode stores keys in SQLite, while the v1 docs say auth.json. Both are right, for different versions.
Claude Code. Per its credential management docs, the login goes into the encrypted macOS Keychain. On Linux, and as a fallback, it is ~/.claude/.credentials.json with 0600 permissions. On Windows it is the same file under %USERPROFILE%, protected by user-profile permissions. That covers the login only. If you give Claude Code an API key through ANTHROPIC_API_KEY or a settings file, it lives wherever you put it, usually in plain text. So on a Mac with a normal login, Claude Code holds the stronger position; on Linux, both tools come down to a 0600 file.
Console vs CLI. OpenCode’s hosted Console is where the breach happened. Its docs say “Console stores the credential and serves each provider through its gateway” (Console providers), so workspace members can use models without seeing the key. That is also the copy that leaked: OpenCode’s customer email warned that third-party provider keys saved in workspaces may have been exposed. Anthropic’s Claude Console is a billing account; the API keys it issues are Anthropic’s own, and Claude Code has no comparable vault for other providers’ keys.
Why plaintext still matters. A 0600 file stops other users on the machine and nothing running as you. Gen Digital reported in September that infostealers now collect AI-agent data: Remus targets Claude, Cursor and OpenCode, Amatera targets Cline and Continue, and the macOS Djinn stealer adds Codex and OpenCode. OpenCode says CLI keys never reach its servers, so CLI-only users were outside the breach; rotating anyway is cheap insurance, and StepSecurity recommends it. For any key ever saved in a Console workspace, revoke it at the provider and confirm the old key returns 401. Our OpenCode alternatives guide covers the full checklist and nine other agents’ key files.
Privacy: telemetry, share links and retention
Claude Code sends usage metrics by default, plus error reports for Pro and Max users, with an opt-out variable for each. We found no product telemetry in the OpenCode CLI, but its desktop app ships Sentry error reporting without a documented opt-out. OpenCode’s v1 /share command publishes a session as a public link until you remove it.
Claude Code telemetry (data usage docs). Metrics on latency, reliability and usage patterns go to Anthropic and a third-party logging service, and the docs say they “never include your code, prompts, or file paths.” Turn them off with DISABLE_TELEMETRY=1. Error reports go to a third-party error tracker and are on for Pro and Max sign-ins from v2.1.198; turn them off with DISABLE_ERROR_REPORTING=1. CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC covers all nonessential traffic. On Bedrock, Google Cloud and Foundry these default to off. The WebFetch domain safety check calls api.anthropic.com unless you set skipWebFetchPreflight.
OpenCode telemetry. The docs have no telemetry page and no telemetry opt-out. In the CLI source on dev, the OpenTelemetry exporter only runs when you set OTEL_EXPORTER_OTLP_ENDPOINT, and we found no analytics SDK. The desktop app is different: its renderer starts Sentry when a DSN is set, and the release workflow sets one for desktop builds. The docs do not mention it or give an opt-out. Some CLI network calls also happen by default, judging by the disable flags: update checks, the models.dev catalog and LSP downloads. We did not trace every network path.
Share links. In OpenCode v1, /share creates a public link at opncd.ai/s/<share-id> and syncs the conversation to OpenCode’s servers. The default mode is manual. Setting auto shares every new conversation, and disabled turns sharing off. Shared sessions stay up until you run /unshare (share docs at v1.19.3). The v2 docs have no share page, so we could not confirm its status there. Claude Code has no public share link: /share, /bug and /feedback send the transcript to Anthropic through the feedback path, where it is kept for 5 years.
Retention. For Claude Free, Pro and Max, Anthropic keeps data for 5 years if you allow model-improvement use and 30 days if you do not. Team, Enterprise and API accounts get 30 days, with zero data retention for qualified Enterprise customers. Locally, Claude Code keeps transcripts in plaintext under ~/.claude/projects/ for 30 days by default (cleanupPeriodDays). OpenCode keeps sessions in its local SQLite database. On Zen, OpenCode says its providers follow zero retention, with stated exceptions: the OpenAI and Anthropic APIs keep data for 30 days, and some free models may use your data for training.
Security record in 2026
Both tools disclosed serious bugs this year. OpenCode published a critical web UI command execution flaw and a high-severity unauthenticated server bug in January, then had the Console breach in October. Claude Code published an API key leak through project settings in January, then accidentally shipped its own source in March, during an unrelated npm supply-chain attack.
OpenCode:
- CVE-2026-22812 (high, disclosed January 12, fixed in 1.0.216 in December 2025): an unauthenticated HTTP server allowed arbitrary command execution.
- CVE-2026-22813 (critical, disclosed January 12, fixed in 1.1.10): a malicious website could run commands on your machine through XSS in the OpenCode web UI.
- GHSA-632h-h47v-g4x4 (high, disclosed September 24): a cross-site upgrade request to the OpenCode server could install arbitrary packages on npm-based installs.
- Console breach (October 16-17): provider keys saved in Console workspaces may have been exposed for 1.4% of Console users. The Hacker News reported self-described losses up to $1,700. Anthropic’s Lydia Hallie said Anthropic had “revoked Claude API keys we believe were affected” (via Avneesh Kasture), and OpenCode’s follow-up email said it worked with OpenAI to revoke the exposed OpenAI keys and that OpenAI issued refunds (via Hacker News).
Claude Code:
- CVE-2026-21852 (medium, disclosed January 20, fixed in v2.0.65 in December 2025): a repository’s settings file could set
ANTHROPIC_BASE_URL, and Claude Code sent requests, API key included, before the trust prompt (advisory). - Source leak (March 31): version 2.1.88 on npm shipped a source map exposing about 512,000 lines of TypeScript. Anthropic said “No sensitive customer data or credentials were involved or exposed” (BleepingComputer).
- Trojanized axios (same day, separate issue): npm installs or updates between 00:21 and 03:29 UTC could pull a compromised axios carrying a remote access trojan, and the advice was to rotate all secrets (The Hacker News).
- GitHub lists 22 security advisories published in 2026 in the anthropics/claude-code repository (a few cover Claude Desktop), mostly sandbox escapes, trust-dialog bypasses and approval bypasses.
Advisory counts reflect attack surface and disclosure habits as much as code quality, so they do not rank the two tools. One structural difference does show up: OpenCode’s largest key exposure came from a hosted service holding customer keys, a component Claude Code does not have.
Benchmarks
On the official Terminal-Bench leaderboard, Claude Code with Opus 5.5 at max effort ranks first at 64.85%, and OpenCode has no current entry, so there is no head-to-head number. Much of that rank reflects the model. Field tests by LogRocket and Builder.io reached opposite conclusions on speed. Treat all of these as rough signals.
The Terminal-Bench leaderboard, which now renders Terminal-Bench 4.0, lists Claude Code with Opus 5.5 at max effort at 64.85% (September 22, 2026) and with Sonnet 5.5 at 61.82%. Agents on the board are Claude Code, Codex, Grok Build, mini-SWE-agent and Muse Code. OpenCode has no submission, which says nothing about how it would score.
Two single-task field tests disagree. LogRocket ran the same refactor with Opus 4.6 in both and reported OpenCode at 7 minutes with no code mistakes against Claude Code at 14 minutes with two. Builder.io reported Claude Code at 9 minutes 9 seconds against OpenCode at 16 minutes 20 seconds. One task per tool cannot settle it; run your own repo through both before you commit.
A third option: Atomic Agent
We build Atomic Agent, so weigh this section accordingly. It is an MIT-licensed, local-first agent whose default model runs on a local llama-server, so you can start with no API key at all. When you add a cloud key, it stays in a 0600 file on your machine, with no Atomic-hosted console or proxy in the path.
What matters for this comparison:
- No key by default. The default provider is a local llama-server on 127.0.0.1, and the Ollama and LM Studio presets need no key.
- Keys stay local, in plaintext. Cloud keys go into files under
~/.atomic-agent(.envfrom the terminal wizard,config.jsonfrom the desktop app), written with 0600 permissions; forconfig.jsonthat holds since v0.6.7, so re-save your settings once if you installed earlier. There is no OS keychain support, so on a Mac, Claude Code’s Keychain storage is stronger. - No hosted vault. No Atomic console, account or proxy holds or forwards model keys. Requests go from your machine straight to the provider.
- Imports from Claude Code. Skills, memory, MCP servers, sessions and, if you opt in, your Anthropic API key. There is no OpenCode importer.
- Telemetry is on by default. Events carry provider, model, token and cost data without message content. Turn it off with
analytics.enabled: falsein the config or the Privacy toggle in the desktop app.
If you are leaving Claude Code over model choice, our list of open-source Claude Code alternatives compares more options. To try Atomic Agent, download it here.
Frequently asked questions
OpenCode or Claude Code: which should you pick?
Choose Claude Code if Claude is your model and you already pay for Pro or Max. It holds the top Terminal-Bench 4.0 score with Opus 5.5 (OpenCode has no entry), can sandbox shell commands, and keeps its login in the Keychain on a Mac. You give up other model families and accept default telemetry.
Choose OpenCode if you want one free, open-source tool across many providers, a ChatGPT or Copilot login, or local models on your own hardware. Check whether you run v1 or v2, tighten the permissive defaults in config, skip the Console if you would rather no vendor hold your keys, and remember that its key store is plaintext.
You can also run both: Claude Code on a Claude subscription, OpenCode for everything else. Whichever you use, give each tool its own provider key with a spend limit, so one leak stays small.
Versions, release dates, star counts and licenses were checked against GitHub, npm and each tool’s documentation on October 19, 2026. OpenCode key storage, permissions and telemetry were checked in its source at tag v1.19.3 and on the dev branch (commit ce15cd8). Atomic Agent claims were checked against its source on main. Quotes about the breach reached us through the linked reports. We did not run either agent for this comparison; benchmark figures are third-party results.


