ai/courses

Vibe coding/Tool comparison

Claude Code vs OpenCode: Which AI Coding Agent Should You Use?

Two terminal coding agents with a similar workflow and very different trade-offs. Models, pricing, licensing, config files, MCP, subagents, and permissions, side by side, checked against the official docs.

Updated
Reading time
8 min
Checked against
22 sources
Two terminal windows on a balance scale with an arrow between them

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 CodeOpenCode
Made byAnthropicAnomaly (anomalyco on GitHub)
LicenseProprietary, used under Anthropic's termsOpen source, MIT
ModelsClaude only75+ providers through Models.dev, including local models
How you payClaude Pro, Max, Ultra, Team, or Enterprise plan, or pay-as-you-go APITool is free; pay your provider, sign in with ChatGPT or Copilot, use free models, or subscribe to OpenCode Go
InterfacesTerminal, VS Code and Cursor, JetBrains, desktop app, web, mobileTerminal (TUI), desktop app (beta), web via opencode pair
Non-interactive modeclaude -p "..."opencode run "..."
Instruction fileCLAUDE.md; reads AGENTS.md when there is no CLAUDE.mdAGENTS.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/)
MCPclaude mcp add; team servers in .mcp.jsonmcp.servers in opencode.json(c); OAuth on by default for remote servers
AgentsExplore, Plan, and general-purpose subagents; custom ones in .claude/agents/build and plan primary agents; general and explore subagents; custom ones in .opencode/agents/
PermissionsModes (Manual, acceptEdits, plan, auto, and more) plus allow, ask, and deny rules; deny always winsOrdered allow, ask, and deny rules; last match wins; default policy allows almost everything
Best forPeople who want Claude and already pay for a Claude planPeople 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 | iex in PowerShell or winget install Anthropic.ClaudeCode.
  • OpenCode needs no account to start, and its free models work without one. Inside the app, /connect picks a provider and takes its credentials, and /models picks 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.

install.sh
# 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 /models

Models, 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:

CLAUDE.md
@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/, with name, description, tools, and model fields.
  • OpenCode: .opencode/agents/ or ~/.config/opencode/agents/, with description, mode (primary, subagent, or all), model, and permissions fields.

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 /mcp to log in. Servers shared with the team go in .mcp.json.
  • OpenCode: servers go under mcp.servers in your config. Sign in with /mcps or opencode 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:

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

  • acceptEdits auto-accepts file edits.
  • plan explores without editing.
  • auto lets a background classifier review actions instead of you.
  • dontAsk denies anything that would prompt.
  • bypassPermissions skips 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:

opencode.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" },
  ],
}

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.

Read next

  1. 01Claude Code Alternatives: 7 AI Coding Agents ComparedWhat each tool actually is, whether it's open source, which models it runs, how you pay for it, and when it beats Claude Code. Plus a dedicated Claude Code vs OpenCode breakdown.Comparison
  2. 02Claude Code Tutorial: Build Your First App, Step by StepInstall Claude Code, learn how a session works on a real codebase, then build a small tested web app from an empty folder. Every prompt you type is in this guide, and every command was checked against Anthropic's docs.Guide
  3. 03Claude Code Cheat Sheet: Commands, Shortcuts, and PromptsEvery command, flag, and shortcut checked against Anthropic's docs, copy-paste templates for CLAUDE.md, subagents, skills, and hooks, and the prompting habits that actually make a difference.Guide

Sources: Claude Code overview, Claude Code memory, CLAUDE.md, and AGENTS.md, Claude Code permissions, Claude Code permission modes, Claude Code subagents, Claude Code MCP, Claude Code enterprise deployment and cloud providers, Claude Code legal and compliance (credential use), Claude pricing, Claude Code on GitHub, OpenCode homepage, OpenCode on GitHub, OpenCode 2 docs: install, OpenCode providers, OpenCode agents, OpenCode permissions, OpenCode config, OpenCode instructions (AGENTS.md), OpenCode skills, OpenCode MCP servers, OpenCode CLI, OpenCode Go.