OpenCode vs Claude Code: Is the Open-Source Agent a Real Alternative?

claude-codeopencodeagentsopen-sourcesubscriptionsfleet-ops

Last verified:

Tested with Claude Code 2.1.322, Codex CLI 0.167.0 and OpenCode 1.18.29 — telemetry through .

On this page
  1. Which one fits you?#
  2. What was measured#
  3. How a turn runs in each#
  4. What the fleet record says#
  5. The hands-on trial#
  6. What you pay#
  7. Where OpenCode is the better fit#
  8. Where Claude Code is the better fit#
  9. When you want both, and when you want neither#
  10. Tested with#
For terminals & agents: curl -s https://jedarden.com/guides/opencode-vs-claude-code.md

OpenCode is a real alternative to Claude Code, and the two are not really competing for the same dollar. Claude Code is a harness sold with a set of models: you pay Anthropic $20, $100 or $200 a month and the agent is included. OpenCode is a harness with no models in the box: the program is free and open source, and you bring a provider, a subscription of theirs, a pay-per-token key, a local runtime, or one of a dozen free models that come and go. Both read the same instructions file and run the same shell-centred loop, and in September 2026 both ran unattended on this machine against the same backlog. The question behind the search is practical: what do I give up and gain if I leave the Anthropic box, and when is the answer to keep one foot in each? The installed binaries, two months of fleet telemetry, a small headless trial and the vendors’ price pages answer it better than another opinion would.

TL;DR — Yes, OpenCode is a real alternative, with two caveats: the version I ran is a major release behind its own documentation, and my hands-on use of it was headless, never interactive. Pick Claude Code first for Anthropic’s models on a flat monthly price, a terminal you steer, or guardrails a team can pin without writing code. Pick OpenCode first if the model is the thing you want to choose, open source is a requirement, you want a free lane for public work, or you want to hook the loop from inside in TypeScript. Run both when work is parallel or unattended and a second meter on a second provider is worth having; one AGENTS.md serves both. Stay on a free model or a metered key under five hours a week. Leaving Claude Code costs you the plan economics and a mature permission system; it buys you every other model and a bill that is only the model’s price.

Which one fits you?#

If the quiz does not load, the questions it asks are these, and the sections below answer each one:

  1. What do you want to spend on a coding agent each month: nothing, $10 to $20, $100 to $200, or whatever the meter says?
  2. Which models do you want behind it: Anthropic’s, several switched by task, the cheapest capable one, or local?
  3. Does the agent have to be open source?
  4. Do you steer every step, hand off and come back, run it headless in scripts, or run several at once?
  5. What do your guardrails need to do: nothing special, block a few commands, block or rewrite as a subprocess a team controls, or hook the loop in code?
  6. Who else uses it: just you, a small team sharing conventions, or a platform team setting rules?
  7. How do you feel about depending on one provider?

What was measured#

Everything here comes from one machine. Claude Code has run on it since March 2026, interactively on an Anthropic plan and, from July, unattended on GLM models through a gateway, the fleet the Codex guide and the GLM plan review measured. OpenCode 1.18.29 was installed in September 2026 for the same fleet, ran for two days on a free stealth model across nine public repositories, 170 attempts, and then sat idle, because the gateway it was meant to use for GLM never worked through it. Four kinds of evidence:

  • The fleet record. Every unattended attempt since September 12 leaves a trace with its adapter, outcome, duration and failure reason: 18,380 attempts across 85 repositories, 170 of them OpenCode’s, re-read with the same outcome classifier the Codex guide used.
  • The binaries and the docs. OpenCode’s CLI, config, agents, permissions and plugin contract, probed on the installed version and read on the vendor’s pages on 2026-11-12, next to Claude Code’s.
  • A hands-on trial. Three small tasks on one public Python repository, headless, in four harness-and-model lanes, each capped at fifteen minutes, each diff read.
  • The vendors’ price pages, captured the day this was written.

Two caveats before any number. The OpenCode fleet record is small: two days, one stealth model, nine repositories, against two months and thousands of attempts for the other harnesses. And I have never used OpenCode’s terminal interface; every sentence about its TUI, sharing and agents comes from the documentation and the CLI’s own help. The Claude Code side has four months of interactive use behind it, an asymmetry to keep in mind when I sound surer about one than the other.

How a turn runs in each#

Read an OpenCode run next to a Claude Code run and the skeleton is the one every agent of this generation has: load the instructions file, read, run shell commands, patch, run the tests, write a summary. OpenCode even reads Claude Code’s files. Its rules page says CLAUDE.md in the project is “used if no AGENTS.md exists” and ~/.claude/CLAUDE.md is used if there is no global OpenCode AGENTS.md, and it loads skills from ~/.claude/skills/. On this machine that meant both tools arrived at the trial with the same standing instructions. The differences are in what wraps the loop, and the first exhibit puts them side by side.

OpenCode 1.18.29Claude Code 2.1.322
The programOpen source (MIT), free; TUI, desktop and web from one binaryProprietary; free to install, needs an Anthropic plan, key or compatible endpoint
InstructionsAGENTS.md, falling back to CLAUDE.md; instructions globs and URLsCLAUDE.md from home, parents and repo, plus AGENTS.md
Toolsbash, read, write, edit, patch, glob, grep, webfetch, websearch, task, MCPBash, Read, Edit, Write, Glob, Grep, Agent, WebFetch, WebSearch, Monitor, MCP
PermissionsAllow all by default, ask on loops and outside the project; --auto headless. 2.x: ordered allow/ask/deny rules with a shell scannerSix modes from default to bypass; --allowedTools rules; managed settings
HooksIn-process plugin: rewrite tool args in place or throw to deny; 2.x adds permission.evaluate, session.context, shell hooksSubprocess hooks on some thirty events; PreToolUse returns allow, deny, ask or defer and can rewrite the input
Subagentsbuild, plan, general, explore; custom agents as Markdown, each with its own provider and modelAgent tool and .claude/agents; full standing context re-read per call
RecordsSQLite database, never pruned here; export and import; share links; opencode statsJSONL transcripts, deleted after 30 days; JSON result with usage and cost
ModelsAny provider in the models.dev catalog or any OpenAI-compatible endpoint; twelve free modelsAnthropic’s models, or a compatible endpoint via ANTHROPIC_BASE_URL
Price$0 software plus the model’s price; Go at $10 or $40Pro $20, Max $100, Ultra $200, or API tokens

Instructions. Both attach a repository AGENTS.md. Claude Code also attaches CLAUDE.md from your home directory and every directory above the checkout; OpenCode reads those files only as a fallback, and its instructions key takes globs and remote URLs. Keep one AGENTS.md, have CLAUDE.md point at it, and both read the same rules.

Tools. The two tool sets are near-identical in kind. OpenCode adds a patch tool and a question tool for asking the user; Claude Code adds Monitor for watching a long command. In the trial both spent most of their calls in the shell and the file reader.

Permissions and hooks. This is the largest real difference, and it cuts both ways. On the installed OpenCode the build agent’s permission table is one rule, allow everything, then ask on a detected loop and ask when leaving the project directory; --auto approves the rest for a headless run. The 2.x documentation describes something much richer, ordered allow/ask/deny rules per action with a shell scanner that applies them to every subcommand and organisation policies no saved approval can override, but I have not run that version. Claude Code’s permission modes and --allowedTools rules have been there for a year and the fleet leans on them daily.

Guardrails are where the architectures differ. OpenCode’s plugin runs in-process, in TypeScript, and its tool.execute.before hook gets the live arguments object: the house plugin rewrites a command by mutating that object in place and denies one by throwing, whose message the model sees as a failed tool call and routes around. The 2.x API goes further inward, with a permission.evaluate hook that sets allow, ask or deny and a session.context hook that edits the system prompt, the messages and the tool set before every model call. Claude Code’s hooks are subprocesses in any language on some thirty events; a PreToolUse hook returns allow, deny, ask or defer and can rewrite the input, and managed settings pin that for a team. The choice is between a hook system a platform team can write in Python and distribute as policy, and a plugin API that lets one person reach much deeper into the loop. On this machine the same rule engine runs under both, as a subprocess hook for Claude Code and as a plugin for OpenCode.

Delegation. OpenCode agents come in two kinds: the primary ones you talk to, build and plan, and subagents, general and explore, built in; a custom agent is a Markdown file whose header names a model, so a subagent can run on a different provider from its parent. Claude Code’s subagents can pick a different Anthropic model, not a different provider, and it matters for cost: in the Codex guide’s telemetry its subagents consumed 17% of interactive tokens for 4% of the output. I did not measure OpenCode subagents; the fleet’s headless runs never spawned one.

Records. OpenCode keeps every session in a local SQLite database; on this machine opencode session list still shows the fleet’s September sessions, and opencode stats sums tokens and cost per model from the same database. Claude Code’s transcript is richer, with its own running dollar estimate, but it is deleted thirty days after its last write unless you raise cleanupPeriodDays.

Headless use. Both run from a pipe: opencode run --format json --auto emits one JSON event per line with tokens and cost per step; claude -p --output-format json emits one result object with usage, a cost estimate and the turn count. The difference I hit was in what the provider returned through them, and the trial section has it.

Versions. The installed OpenCode is from September; the release page showed v2.2.7 on 2026-11-10 and the documentation describes that 2.x line, whose config keys, permission model and plugin API all differ from what is installed. Claude Code ships just as often. Anything here about how a turn runs is true of the versions in the “Tested with” line.

What the fleet record says#

The caveat first. These are unattended workers on a shared backlog, the harnesses ran different models on different repositories, and OpenCode’s row is two days against two months. What the record can say is that OpenCode on a free stealth model did the job the fleet gave it.

Harness, 90 days to 2026-11-12AttemptsVerifiedYieldExcluding splitsMedian attempt
Codex CLI (ChatGPT Pro)9,8794,93950.0%63.3%6.0 min
Claude Code on GLM8,1763,25239.8%53.1%27.9 min
Claude Code on Anthropic851416.5%22.6%3.4 min
OpenCode on a free Zen model17010260.0%71.8%7.5 min

OpenCode’s 170 attempts all ran on opencode/space-bunny-free on September 23 and 24 across nine public repositories.

What OpenCode did. On September 23 the fleet was pointed at OpenCode with a free stealth model, space-bunny-free, on a short allow-list of public repositories, because a free model’s data terms are not something to test on private code. In two days it made 170 attempts, 102 passed verification and 128 commits landed: a 60% yield, 72% excluding the attempts that split a task into smaller ones, a median of seven and a half minutes. Its failures were ordinary: 22 go build gate failures, 13 of them in one repository where it verified nothing, nine npm test failures, six infrastructure. The Codex guide’s deeper pass found the highest reopen rate of any harness for those closures, 27%, the pattern of a fast worker that closes before the paperwork is done. The model has since been retired from the free catalog; stealth models are loaned, not sold.

What OpenCode did not do. The fleet also had an OpenCode adapter for GLM-5.3-Flash through the Claude Code workers’ gateway, and not one attempt trace carries it. The trial explains why.

The context rows. Codex and Claude Code on GLM are the fleet’s workhorses and their numbers are the earlier guides’ numbers: Codex fast and inclined to close early, Claude Code on GLM slower and more often killed by its provider than by the task. Claude Code on Anthropic’s models barely appears because those models were spent where a person was watching. Read the rows as “each harness did the work it was given”, not as a ranking.

The hands-on trial#

The fleet record compares different work on different repositories, so I ran both harnesses on the same work: three small tasks on one public Python repository of mine, 727 tests in eighteen seconds, headless, one run per cell, fifteen-minute cap, every diff read afterwards. The tasks were to add unit tests for a function that had none, to find and fix a bug I had injected into the ledger key (five failing tests), and to write a README section from two source files with five facts it had to get right. Four lanes: OpenCode on a free Zen stealth model, OpenCode on GLM-5.3-Flash through the fleet’s gateway, Claude Code on the same GLM through the same gateway, and Claude Code on my Anthropic plan, which answered with Fable 5.2.

TaskOpenCode, free Zen modelOpenCode, GLM-5.3-FlashClaude Code, GLM-5.3-FlashClaude Code, Anthropic plan
Add tests48 s, 6 tool calls, 733 pass, acceptabletimed out at 15 min, no change133 s, 5 calls, 735 pass, acceptable38 s, 2 calls, 741 pass, acceptable
Fix the injected bug46 s, 7 calls, 727 pass, acceptabletimed out, bug still in place114 s, 5 calls, exact revert, acceptable30 s, 3 calls, exact revert, acceptable
Write a README section21 s, 5 calls, 171 words, acceptabletimed out, no change128 s, 5 calls, 168 words, acceptable15 s, 2 calls, 181 words, acceptable
Tokens per task, as reported19k to 34k input, 41k to 77k cache read, 0.5k to 0.7k output, cost $0none reported18k to 59k input, 45k to 68k cache read, 0.7k to 2k output6 input, 69k to 77k cache read, 0.7k to 1.3k output, $0.35 to $0.43 estimated

Nine of the nine cells where a lane worked were acceptable, and the three that were not belong to one pair. OpenCode on the fleet’s GLM gateway never produced a token: each run emitted empty steps, 125 to 974 of them, until the cap, with no error anywhere, while Claude Code on the same model through the same gateway did every task. That is the practical meaning of “any provider”: the provider package has to agree with the endpoint’s wire format, and nothing tells you when it does not. Speed ordered the same way in every task, Fable fastest, the free model close behind, GLM three to four times slower, which is the model and gateway rather than the harness. Claude Code on Fable did each task in two or three tool calls and wrote the longest diffs, thirteen test cases to OpenCode’s six; the free model fixed the bug with a line a shade weaker than the original, which both Claude lanes restored exactly; on the README all three got all five facts right.

The standing context dominates input on this machine, 69k to 77k cached tokens per Claude call and a comparable amount for OpenCode, which read the same home CLAUDE.md through its fallback; a clean machine would spend far less. And a free stealth model doing three small tasks acceptably for nothing is the most useful fact here for someone deciding whether to try OpenCode at all. One run per cell on one small repository shows which pairs work and roughly how fast; it does not rank quality.

What you pay#

OpenCode’s price is the model’s price: the program is free, and the vendor’s own paid surface is OpenCode Zen, its hosted model gateway, with a pay-as-you-go console, the free models, and a $10 Go subscription; anything else is between you and the provider you bring. Claude Code’s price is a Claude plan, models included, or an Anthropic API key at list rates.

RungHarnessMonthlyWhat you get
A free Zen modelOpenCode$0Twelve models on the read date, each with its own retention and training terms; free-tier chat models require OpenCode as the client
OpenCode GoOpenCode$10A basket of non-frontier models with per-model 5-hour (20%), weekly (50%) and monthly (100%) dollar caps; Go Plus $40
Claude ProClaude Code$20 ($17 annual)Anthropic’s models with a 5-hour window and a weekly cap
Claude MaxClaude Code$1005x Pro every 5 hours and every week; $100 of API credits
Claude UltraClaude Code$20010x Pro weekly, no 5-hour limit for verified accounts; $200 of API credits

Per-token list rates on the OpenCode console, per million tokens in and out: GLM 5.3 Flash $0.15 and $0.50; DeepSeek V4.1 Flash $0.30 and $1.20; GPT 6 Luna $0.10 and $0.50; GLM 5.3 $1.40 and $4.40; Claude Sonnet 5.5 $2 and $10; Claude Opus 5.5 $4 and $20; Claude Fable 5.2 $8 and $40. Credit purchases carry a 4.6% plus $0.31 fee.

Three things the ladder does not show. The free models are a rotating loan: the one the fleet ran in September was gone by November, and the twelve on the catalog today carry different data terms, from “zero retention, no training” for the GLM, DeepSeek and MiniMax entries to “data may be used to improve the model” for the stealth ones. Read the terms per model and keep free models to public code, as the fleet did. The cheapest way to keep either harness busy around the clock is still a GLM coding plan behind it, which has its own measured review and lists both tools as supported. And Claude Code on a plan is the only rung where the harness and the frontier models come in one price; put Anthropic’s models behind OpenCode and you pay per token, with no window and no cap.

Where OpenCode is the better fit#

  • The model is the decision. A cheap model for chores and a frontier model when it matters, a local model on private code, whatever is new this week: OpenCode’s catalog and per-agent model setting are the point. Claude Code can be pointed at one compatible endpoint; OpenCode is built around having many.
  • Open source is a requirement. The program is MIT-licensed and you can read the loop you are trusting with your shell; the guard plugin here was designed around exactly how the hook and the executor share an object.
  • A free lane for public work. Twelve free models on the day of writing; the fleet’s two days on one of them delivered a 60% yield for nothing but the data terms. For open-source maintenance or a first week of learning what an agent does, that is hard to argue with.
  • You want to hook the loop from inside. A plugin that edits the system prompt, the message list or the outgoing request before each model call has no equivalent in Claude Code’s subprocess hooks.
  • You already pay someone else. If you have a ChatGPT plan, a Copilot seat or a GLM coding plan, OpenCode runs on it; trying it costs an AGENTS.md.

You would switch, or add Claude Code, when you want Anthropic’s frontier models on a flat monthly price with a predictable weekly reset, or when a platform team needs to pin guardrails for many people without writing TypeScript.

Where Claude Code is the better fit#

  • You want Anthropic’s models and a flat bill. A plan buys the harness and the models together, with windows you can plan a week around. Behind OpenCode the same models are metered per token.
  • A team shares conventions, or a platform team sets rules. Hooks in any language, a PreToolUse hook that can allow, deny, ask or rewrite, and managed settings that pin them for everyone. On this machine that hook is why no agent has committed a workflow file or a floating image tag; the same engine gates OpenCode too, but it had to be written as a plugin first.
  • A mature permission system today. Six modes, allow rules by tool and prefix, a classifier mode. The installed OpenCode is allow-everything plus --auto; the richer model is in a version I have not run.
  • You steer from the terminal. Here my evidence is one-sided: four months of interactive Claude Code sessions and none in OpenCode’s TUI. I will not claim the comparison, only that Claude Code’s interactive loop, plan mode and named tools are what I reach for when something needs steering.
  • Usage accounting you can trust. Claude Code’s JSON result carried tokens and a cost estimate in every trial run, on both providers. OpenCode reported tokens on its own Zen model and nothing at all through the GLM gateway, so one lane of the trial has no usage figure.

You would switch, or add OpenCode, when you need a model Claude Code cannot reach, a free lane for a public repository, or an in-process hook that edits the prompt or the request itself.

When you want both, and when you want neither#

Both, each with a job. The fleet already runs this way: Claude Code where a person steers and Anthropic’s models earn their price, cheaper harness-and-model pairs for the unattended lane. OpenCode slots into the second role at no editorial cost, because one AGENTS.md serves both and the same rule engine can gate both. Give each harness a named class of work, run one shared acceptance check, and compare finished work rather than tokens. A second provider behind a second harness is also a second meter that does not fail with the first. Drop one when its lane sits idle for three weeks.

Neither, for now. Under five hours a week, with no plan in hand, run OpenCode on a free model against a public repository to learn the loop at no cost, then put a pay-per-token key behind whichever harness you preferred. Read the bill after a month and buy a plan when it crosses the plan price twice.

The $10 and $20 tiers. OpenCode Go buys a basket of non-frontier models with per-model caps and falls back to the free models at the limit; Claude Pro buys Anthropic’s models with a five-hour window a busy afternoon will hit. Either is the way to find out which loop you prefer, not the plan to run a long task on while you are away.

Tested with#

OpenCode 1.18.29 and Claude Code 2.1.322 were the installed versions when this was written; Codex CLI 0.167.0 appears only in the fleet table. The fleet record runs from 2026-09-12, the first day attempt traces exist, through 2026-11-12; OpenCode’s share of it is September 23 and 24. The trial, the CLI probes and the price captures were made on 2026-11-12. OpenCode’s documentation on that date described the 2.x line (v2.2.7 shipped on 2026-11-10); where the installed version and the docs disagree I have said which is which, and a refresh should re-run the trial on the current release before trusting any sentence about permissions or plugins. The prices are the vendors’ pages as they read on 2026-11-12; none carries a dated changelog. A weekly check compares the installed versions and the age of the telemetry against this page and flags it for a refresh when either tool moves by a minor version or the data passes ninety days. The “Tested with” line under the title is the one to trust.

— Jed