By the middle of 2026, the most-starred AI coding agent on GitHub was not Claude Code. It was OpenCode, the open-source terminal agent from the team behind SST — roughly 170–180K stars against Claude Code's ~135K, a lead built in under a year of mostly organic adoption. Naturally, the internet did what it does: it lined the two up and benchmarked them against each other, post after post asking which terminal agent writes better code.

That framing has a bug in it. OpenCode and Claude Code are not two entries in the same category. One is a product; the other is a harness. And the difference is the most useful thing you can know before choosing.

The category error#

Claude Code is a product in the strict sense: Anthropic ships the agent and the model as a co-designed pair, tuned together and closed. When you measure Claude Code on Terminal-Bench, you're measuring a specific model — Opus 4.8, say, which lands as the strongest usable Claude pairing at 78.9% — inside a scaffold built for it.

OpenCode is the scaffold without the model. It's a client that connects to 75+ providers; you bring the key, it drives whatever you point it at. Which means OpenCode has no coding score of its own. Its Terminal-Bench number is entirely the model you plug in. Run Anthropic's Opus 4.8 through OpenCode and you get roughly Claude Code's numbers. Run GPT-5.5 and you get roughly Codex CLI's numbers (the current leader at 83.4%). Change nothing about OpenCode and its score swings fifteen points depending on the key in your environment.

OpenCode has no coding score of its own. Its benchmark number is whatever model you plug into it — which is exactly why "OpenCode vs Claude Code, which codes better" is a question with no answer.

So the popular head-to-head — which one writes better code — is asking a harness to have an opinion the harness doesn't have. Quality is a property of the model. OpenCode's job is everything around the model.

Where they actually differ#

Once you stop comparing quality, the real distinctions get sharp, and they're architectural.

Claude Code runs as a CLI process. Close the terminal and the process ends; you resume by replaying a stored transcript. OpenCode makes the opposite structural choice: it runs a persistent background server that holds session state in a local SQLite database, and the interface you look at — a terminal TUI, a desktop app, an IDE extension — is just a client attached to it. The consequence is that a session is a live thing that outlives your terminal. Your SSH connection drops, your laptop sleeps, you close the window; you reconnect and the session is still running, mid-thought, where you left it. Because sessions live in SQLite and not in a single process, multiple frontends can attach to the same session at once.

That's a genuinely different shape for a coding agent, and it's invisible to any benchmark that only scores the diff at the end. It's also the part you can't get by swapping models into Claude Code, because it isn't about the model at all.

The second axis is ownership. OpenCode is MIT-licensed; you can read the harness, fork it, and — the load-bearing part — you are never stranded on one vendor's model roadmap, because the piece you run is yours and the model is a swappable dependency. Claude Code's bet is the inverse: give up that portability in exchange for a scaffold co-tuned with the model that Anthropic controls end to end. Neither is wrong. They're different trades, and the star count suggests a lot of developers now want to own the wrapper.

How to actually choose#

Ignore the benchmark drag races between these two specifically; they're comparing a model to a socket. Ask instead:

Do you want a managed, quality-first experience where the agent and the model are designed together and you assemble nothing? That's Claude Code, and it's a real advantage — the co-design is the product.

Do you want to keep your model choice open, run sessions that survive disconnects, or drive one long-running session from more than one frontend? That's OpenCode, and none of it depends on which model you end up using.

The tell that the usual comparison is broken: the single most-cited fact about OpenCode — that it passed Claude Code on GitHub stars — is a fact about interest in a harness, not about code quality, because a harness doesn't have code quality. Get that distinction right and the choice stops being a benchmark fight and becomes what it actually is: do you want to own the wrapper, or have the wrapper owned for you.