
TL;DR
The Short Answer
Pick Claude Code if Claude is the model you want and you pay for a Claude plan. It's Anthropic's own agent, built for Claude models, with the most built-in automation, and it's included in the Pro, Max, Ultra, Team, and Enterprise plans.
Pick OpenCode if you want an open-source (MIT) agent that runs any model, from 75+ cloud providers to local models, or if you'd rather use a ChatGPT or GitHub Copilot subscription you already have.
Day to day, the two work alike: terminal-first agents with a read-only plan mode, subagents, MCP, skills, and allow, ask, and deny permission rules. What actually decides it is model choice, licensing, and how you want to pay.
| Claude Code | OpenCode | |
|---|---|---|
| Made by | Anthropic | Anomaly (anomalyco on GitHub) |
| License | Proprietary, used under Anthropic's terms | Open source, MIT |
| Models | Claude only | 75+ providers through Models.dev, including local models |
| How you pay | Claude Pro, Max, Ultra, Team, or Enterprise plan, or pay-as-you-go API | Tool is free; pay your provider, sign in with ChatGPT or Copilot, use free models, or subscribe to OpenCode Go |
| Interfaces | Terminal, VS Code and Cursor, JetBrains, desktop app, web, mobile | Terminal (TUI), desktop app (beta), web via opencode pair |
| Non-interactive mode | claude -p "..." | opencode run "..." |
| Instruction file | CLAUDE.md; reads AGENTS.md when there is no CLAUDE.md | AGENTS.md only; no CLAUDE.md fallback in OpenCode 2 |
| Config file | .claude/settings.json (project), ~/.claude/settings.json (user) | opencode.json or opencode.jsonc (project or ~/.config/opencode/) |
| MCP | claude mcp add; team servers in .mcp.json | mcp.servers in opencode.json(c); OAuth on by default for remote servers |
| Agents | Explore, Plan, and general-purpose subagents; custom ones in .claude/agents/ | build and plan primary agents; general and explore subagents; custom ones in .opencode/agents/ |
| Permissions | Modes (Manual, acceptEdits, plan, auto, and more) plus allow, ask, and deny rules; deny always wins | Ordered allow, ask, and deny rules; last match wins; default policy allows almost everything |
| Best for | People who want Claude and already pay for a Claude plan | People who want open source, any model, or to reuse a ChatGPT or Copilot plan |
Open Source vs Closed: What Each Tool Is
Claude Code is Anthropic's agentic coding tool. It reads your codebase, edits files, and runs commands. It's not open source: the anthropics/claude-code repo holds the changelog, plugins, and examples, and its license reads "© Anthropic PBC. All rights reserved." Use is governed by Anthropic's commercial or consumer terms.
It runs in more places than OpenCode does: the terminal CLI, a VS Code extension (which also installs in Cursor), a JetBrains plugin, a desktop app, the web at claude.ai/code, and the Claude mobile app.
OpenCode calls itself "the open source AI coding agent". The code is MIT-licensed at anomalyco/opencode, so you can read it, fork it, and change it. It runs as a terminal app (TUI), a desktop app (beta, for macOS, Windows, and Linux), and a web app you open with opencode pair. Pairing links work once and expire after 5 minutes.
Both run headless for scripts and CI. Claude Code uses claude -p "your prompt" and also has official GitHub Actions and GitLab CI/CD integrations. OpenCode uses opencode run "your prompt".
A note on OpenCode versions: OpenCode currently has two major versions, and they can't be installed side by side under the default opencode command. This article covers OpenCode 2, documented at opencode.ai/v2/docs. Older tutorials that use npm install -g opencode-ai install OpenCode 1.
Install and First Run
Both install with a one-line script or a package manager, then start from your project folder.
- Claude Code asks you to log in on first use, with a Claude account or an Anthropic Console account. Native installs update themselves in the background. Homebrew and WinGet installs don't. On Windows, use
irm https://claude.ai/install.ps1 | iexin PowerShell orwinget install Anthropic.ClaudeCode. - OpenCode needs no account to start, and its free models work without one. Inside the app,
/connectpicks a provider and takes its credentials, and/modelspicks a model. OpenCode 2 doesn't support Windows package managers. Windows users download a standalone binary instead.
The commands below are copied from each tool's official docs.
# Claude Code (macOS, Linux, WSL)
curl -fsSL https://claude.ai/install.sh | bash
# or: brew install --cask claude-code
cd your-project
claude
# OpenCode 2
curl -fsSL https://opencode.ai/v2/install | bash
# or: brew install anomalyco/tap/opencode-v2
# or: npm install -g @opencode/cli
opencode
# then inside the app: /connect, then /modelsModels, Providers, and Pricing
This is the biggest difference between the two.
Claude Code runs Claude models only. You can reach them in several ways:
- A Claude subscription: Pro, Max, Ultra, Team, or Enterprise. The Free plan doesn't include Claude Code.
- An Anthropic Console account, billed pay-as-you-go.
- A cloud provider: Amazon Bedrock, Claude Platform on AWS, Google Cloud's Agent Platform (formerly Vertex AI), or Microsoft Foundry.
See Claude pricing for current plan prices.
OpenCode is provider-agnostic. The tool itself is free. It covers 75+ providers through the Models.dev catalog, including Anthropic, OpenAI, and xAI, plus local models through Ollama, LM Studio, and vLLM. Ways to pay:
- Your own API keys. You pay each provider directly.
- A ChatGPT Plus or Pro plan through "Sign in with ChatGPT". Usage counts against your plan.
- A GitHub Copilot subscription, connected through GitHub's device sign-in.
- The free models that ship with OpenCode.
- OpenCode Go, an optional subscription that starts at $10/month for a curated set of coding models. See OpenCode Go.
The Claude subscription catch. Anthropic's terms say Claude.ai subscription login is for Claude Code and Anthropic's own apps. Third-party developers may not offer it in their tools. So to use Claude models in OpenCode, you connect an Anthropic API key (pay per token) or go through another provider. If Claude is your main model and you already pay for Pro or Max, Claude Code is usually the cheaper way to use it.
Instructions and Config: CLAUDE.md vs AGENTS.md
Claude Code reads CLAUDE.md. It looks for a project file at ./CLAUDE.md or ./.claude/CLAUDE.md, a personal one at ~/.claude/CLAUDE.md, and a gitignored CLAUDE.local.md. /init generates a starting CLAUDE.md from your codebase. Since v2.1.277, Claude Code also reads AGENTS.md, but by default only when the repo has no CLAUDE.md or CLAUDE.local.md. Settings and permissions live in .claude/settings.json (shared), .claude/settings.local.json (personal), and ~/.claude/settings.json (all projects).
OpenCode reads AGENTS.md. Its docs say OpenCode 2 "recognizes AGENTS.md only. It does not use CLAUDE.md as a fallback." The global file is ~/.config/opencode/AGENTS.md. Config goes in opencode.json or opencode.jsonc, in the project root, in .opencode/, or globally in ~/.config/opencode/.
Skills carry over. OpenCode also loads skills from .claude/skills and ~/.claude/skills (and .agents/skills), so Claude Code skills work in both.
One file for both tools. Keep your instructions in AGENTS.md. If the repo also needs a CLAUDE.md for Claude-specific notes, import AGENTS.md at the top of it, as Claude Code's docs show:
@AGENTS.md
## Claude Code
Use plan mode for changes under `src/billing/`.Agents, Subagents, and MCP
Plan mode. In Claude Code, plan mode is a permission mode. Press Shift+Tab to cycle into it, or start a prompt with /plan. Claude explores without editing source files, then asks you to approve the plan before it starts making changes. In OpenCode, plan is a separate read-only primary agent, and Tab switches between it and build, the full-access default agent.
Subagents. Claude Code ships with Explore, Plan, and general-purpose subagents. OpenCode ships with general (mention it with @general) and explore. In both tools, a custom agent is a Markdown file with YAML frontmatter, and the body becomes the system prompt:
- Claude Code:
.claude/agents/or~/.claude/agents/, withname,description,tools, andmodelfields. - OpenCode:
.opencode/agents/or~/.config/opencode/agents/, withdescription,mode(primary,subagent, orall),model, andpermissionsfields.
MCP. Both connect to local (stdio) and remote MCP servers, with OAuth for remote ones.
- Claude Code: add a server with
claude mcp add --transport http sentry https://mcp.sentry.dev/mcp, then run/mcpto log in. Servers shared with the team go in.mcp.json. - OpenCode: servers go under
mcp.serversin your config. Sign in with/mcpsoropencode mcp auth sentry.
Extras. Claude Code has more built in: hooks that run shell commands before or after actions, cloud sessions, scheduled tasks, and the Agent SDK. OpenCode's extension point is plugins.
The same Sentry server in OpenCode, from its docs:
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"servers": {
"sentry": {
"type": "remote",
"url": "https://mcp.sentry.dev/mcp",
},
},
},
}Permissions: Cautious vs Permissive Defaults
The two tools start from opposite defaults.
Claude Code asks first. In the default Manual mode, file edits and most shell commands need your approval. Other modes change that:
acceptEditsauto-accepts file edits.planexplores without editing.autolets a background classifier review actions instead of you.dontAskdenies anything that would prompt.bypassPermissionsskips prompts. The docs say to use it only in containers or VMs.
You can also write allow, ask, and deny rules in settings.json, such as "deny": ["Bash(git push *)"]. They're evaluated deny first, then ask, then allow, so a narrower allow rule can never override a deny.
OpenCode allows by default. Every agent starts from a base policy that allows everything, except that reading .env files asks. The plan, general, and explore agents add their own restrictions on top. Your rules are an ordered list of action, resource, and effect entries, the last matching rule wins, and anything no rule matches asks. Put broad rules first and exceptions after them.
To make OpenCode ask before shell commands, the way Claude Code does, add rules like this example from the docs:
{
"$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" },
],
}Who Should Pick Which
Choose Claude Code if:
- Claude is your main model and you already pay for Pro, Max, Ultra, Team, or Enterprise.
- You want an IDE extension (VS Code, Cursor, JetBrains), a desktop app, cloud sessions, or mobile access to the same agent.
- You rely on hooks, scheduled tasks, GitHub Actions, or the Agent SDK.
- You want cautious defaults, with approvals or a classifier-reviewed auto mode.
Choose OpenCode if:
- You want to switch models per task, or use models from OpenAI, xAI, or open-weight providers.
- You already pay for ChatGPT Plus or Pro, or GitHub Copilot, and want to use that plan.
- You need local models through Ollama, LM Studio, or vLLM.
- Open source matters to you or your company: you want to read, audit, or modify the agent.
Using both works well. Keep instructions in AGENTS.md, import it from CLAUDE.md if you need one, and keep skills in .claude/skills so both tools load them.
New to Claude Code? Start with our Claude Code tutorial and keep the Claude Code cheat sheet open. Weighing other options too? See Claude Code alternatives for Codex CLI, Cursor, Copilot, Cline, Aider, and Gemini CLI.
FAQ
- Is OpenCode free?
- The tool is free and MIT-licensed, and it ships with some free models. Beyond those, you pay your model provider, sign in with a ChatGPT Plus or Pro plan or a GitHub Copilot subscription, or subscribe to the optional OpenCode Go plan.
- Can I use my Claude Pro or Max subscription in OpenCode?
- No. Anthropic's terms reserve Claude.ai subscription login for Claude Code and Anthropic's own apps, and third-party developers may not offer it. In OpenCode you use Claude models through an Anthropic API key or another provider, billed separately.
- Is Claude Code open source?
- No. The anthropics/claude-code GitHub repo holds the changelog, plugins, and examples, but Claude Code itself is proprietary and used under Anthropic's terms. OpenCode is open source under the MIT license.
- Does OpenCode read CLAUDE.md?
- Not in OpenCode 2. It reads AGENTS.md only and does not fall back to CLAUDE.md. It does load skills from .claude/skills and ~/.claude/skills. To share instructions, keep them in AGENTS.md: Claude Code reads AGENTS.md when there is no CLAUDE.md, or you can import it with @AGENTS.md.
- Is OpenCode better than Claude Code?
- It is a different trade-off, not a straight upgrade. OpenCode wins on model choice, open source, and reusing ChatGPT or Copilot plans. Claude Code wins on surfaces (IDE, desktop, web, mobile), built-in automation like hooks and cloud sessions, and value if you already pay for a Claude plan.
- Which one is safer to run on my machine?
- Claude Code starts more cautiously: its default mode asks before file edits and most shell commands. OpenCode's default policy allows almost everything except reading .env files, so add ask or deny rules in opencode.json if you want approvals. Both let you deny specific commands such as git push.


