Coding agents compared
OpenCode vs Claude Code: open-source flexibility against a vendor-built agent
You get a dated comparison of OpenCode and Claude Code on licence, model choice, permissions and cost, including what each does and does not support for self-hosted models.
OpenCode is an MIT-licensed open-source coding agent that you can point at many model providers, including local models served over an OpenAI-compatible URL. Claude Code is Anthropic's proprietary agent and runs Claude models. The choice usually turns on whether you need to pick or host the model yourself. Facts below come from each project's own site, documentation and repository, read on 2026-10-07, and gaps are marked not verified.
Last verified 2026-10-07. Sources are listed at the end of the page.
What is OpenCode, and who makes it?
OpenCode describes itself as an open source AI coding agent, available as a terminal interface, a desktop app or an IDE extension. Its repository is github.com/anomalyco/opencode, and the older github.com/sst/opencode address showed the same repository on 2026-10-07. The repository page and its LICENSE read MIT. The home page says it supports 75+ providers including local models. That is the project's own claim, and we did not count them.
OpenCode ships a build agent, a plan agent for read-only analysis, and subagents (general, explore and scout). It is a separate project from Anthropic and from Swfte. Swfte sells neither tool and does not rank them.
OpenCode and Claude Code at a glance
Each cell comes from the project's own documentation or repository, read on 2026-10-07.
| Topic | OpenCode | Claude Code |
|---|---|---|
| Licence | MIT (repository page and LICENSE). | Proprietary. The LICENSE.md reads 'All rights reserved. Use is subject to Anthropic's Commercial Terms of Service.' |
| Surfaces | Terminal, desktop app (beta, per the repository) and IDE extension. Non-interactive run, headless serve, web and GitHub Actions commands exist. | Terminal, IDE extensions, desktop app and web, plus GitHub, GitLab CI/CD and Slack integrations. |
| Models | Any provider you configure with API keys, including local models and custom OpenAI-compatible endpoints. | Claude models. Anthropic says it does not support routing Claude Code to non-Claude models through any gateway. |
| Project instructions | AGENTS.md in the project, ~/.config/opencode/AGENTS.md globally, and CLAUDE.md as a fallback if no AGENTS.md exists. A /init command creates AGENTS.md. | CLAUDE.md, and AGENTS.md when no CLAUDE.md exists in the working folder or above. |
| MCP | Local and remote servers set under the mcp key in opencode.jsonc, with automatic OAuth for protected servers. | MCP servers at several scopes, including a project .mcp.json, with managed MCP configuration for organisations. |
| Extensions | Plugins from .opencode/plugins or npm, custom agents, commands, LSP servers and formatters. | Hooks, skills, subagents and plugins. |
| Configuration | JSON or JSONC files that merge in layers: remote organisation config, global, project, managed files and macOS managed preferences at the highest precedence. | Settings files with managed settings for organisations, including an allowedProviders option to pin a gateway. |
Can OpenCode or Claude Code run against a self-hosted model?
OpenCode can. Its provider docs describe a custom provider that uses the @ai-sdk/openai-compatible package with a baseURL. They show the Ollama URL http://localhost:11434/v1, the LM Studio URL http://127.0.0.1:1234/v1 and the llama.cpp llama-server URL http://127.0.0.1:8080/v1, and say you can use any OpenAI-compatible provider. Credentials added with /connect are stored in a local auth.json file.
What the docs do not tell you is how well a small local model handles tool calls and long edits. That depends on the model and the server, and neither page measures it. See best LLM for coding for cited model results and deploy models for hosting.
Claude Code cannot use a self-hosted open-weight model. Anthropic's gateway page says any gateway that exposes a supported API format works, and also says it does not support routing Claude Code to non-Claude models through any gateway. The supported formats are Anthropic Messages, Amazon Bedrock and Google Agent Platform, with Microsoft Foundry through its own variables. A gateway can still give you central credentials, usage tracking, budgets and audit logs for Claude traffic.
On data flow, the OpenCode enterprise page says OpenCode does not store your code or context data, and that processing happens locally or through direct API calls to your provider. Its /share feature sends conversations to opencode.ai when used, the share setting defaults to manual, and the docs advise disabling it for enterprise trials. We did not verify what other network calls OpenCode makes at start-up, so check that with a network monitor before a regulated rollout.
How do permissions and safety defaults compare?
| Area | OpenCode | Claude Code |
|---|---|---|
| Default posture | Permissive. Most permissions default to allow. doom_loop and external_directory default to ask, and reads of .env files are denied by default. | Manual mode starts read-only and asks before edits, tests and commands. The security page also names Auto mode, where a classifier reviews actions, as the starting mode for interactive terminal and VS Code sessions. |
| Rule model | Each permission resolves to allow, ask or deny, with wildcard patterns, global and per-agent settings. Agent rules take precedence over global ones. | Permission modes (default, acceptEdits, plan, auto, dontAsk, bypassPermissions) plus allow, ask and deny rules. The docs say rules are enforced by Claude Code, not by the model. |
| OS sandbox | The permissions page we read does not describe an OS-level sandbox. That is not proof that none exists, so verify before you rely on one. | An opt-in Bash sandbox on macOS, Linux and WSL2. It covers shell commands only. Native Windows runs commands unsandboxed. |
| Blocking a call in code | The tool.execute.before plugin hook can intercept a tool call, for example to stop reads of .env files. | A PreToolUse hook can block an action regardless of what the model decides. |
| Organisation control | Managed config files and MDM preferences override user config. A central config can restrict requests to an internal gateway and disable other providers. | Managed settings, managed MCP configuration and allowedProviders set to a custom endpoint. |
How is each tool paid for?
Prices are as shown on the vendors' own pages on 2026-10-07, in US dollars.
| Item | OpenCode | Claude Code |
|---|---|---|
| The tool | Free software under the MIT licence. | Included in all paid Claude plans, per claude.com/pricing, or used with an Anthropic Console account. |
| Model usage | You pay the provider you connect, or run a local model on your own hardware. Hardware and electricity costs are yours. | Plan usage limits are shared with chat on a subscription. Console use is billed per token. |
| Optional vendor service | Zen is an optional pay-as-you-go gateway of tested models, with credits and an auto-reload of $20 when the balance falls below $5. The Go page shows $10 a month, and $40 a month for Go Plus. | Pro $17 a month billed annually or $20 monthly. Max from $100. Team Standard seat $20 billed annually or $25 monthly. |
| Data terms on the paid service | The Zen page says most providers follow a zero-retention policy and do not train on your data. It names exceptions: OpenAI and Anthropic retain requests for 30 days, and some free models may use data for improvement. | Commercial plans: no training on Claude Code prompts or code under commercial terms unless you opt in, and standard 30-day retention, per the data usage page. |
When should you pick OpenCode, and when Claude Code?
These are decision rules from documented differences, not a ranking.
| Your situation | Lean towards | Reason |
|---|---|---|
| You must run the agent against a model on your own infrastructure | OpenCode | Documented custom OpenAI-compatible providers, including Ollama, LM Studio and llama.cpp. Claude Code does not support non-Claude models behind a gateway. |
| You want an open-source agent you can read and modify | OpenCode | MIT licence. Claude Code is proprietary. |
| You want to change model provider without changing tools | OpenCode | Provider and model are configuration, per the config docs. |
| You already pay for a Claude plan and want one bill | Claude Code | Claude Code is included in all paid Claude plans. |
| You need Claude models in your own Bedrock, Google or Foundry account | Claude Code | Those providers are documented for Claude Code. |
| You want a safer default posture without writing rules | Claude Code, or tighten OpenCode | OpenCode defaults to allow for most actions. Set ask rules for bash and edit before first use. |
| Your repositories use CLAUDE.md today | Either | OpenCode reads CLAUDE.md as a fallback. Set OPENCODE_DISABLE_CLAUDE_CODE=1 to turn that off. |
How do you point OpenCode at a self-hosted model?
Serve the model over an OpenAI-compatible API
Use Ollama, LM Studio, llama.cpp or another server. Note its base URL, such as http://localhost:11434/v1 for Ollama.
Add a custom provider
In opencode.json, add a provider entry that uses the @ai-sdk/openai-compatible package, a display name, a baseURL and a models list, as the provider docs show.
Select the model
Set the default model in the config as provider/model, the format the config docs show for their anthropic example.
Tighten permissions
Set bash and edit to ask, or use per-agent rules. Defaults are permissive, so do this before the first run on a real repository.
Turn off sharing
Set share to disabled in config. For a team, deploy a central config that allows only your internal endpoint.
Test on your own tasks
Run a bug fix and a refactor. Check tool calls complete and watch outbound connections with a network monitor.
Where Swfte fits
Swfte Connect (Built) is an OpenAI-compatible model API with bring-your-own-key, routing and fallback, budgets and usage caps, secret and PII detectors with a redact action, and an audit event stream. OpenCode accepts a custom OpenAI-compatible baseURL, so Connect can sit between OpenCode and your models. Swfte has not published a tested OpenCode configuration. The fit is inferred from two documented interfaces, so test it on your own tasks.
Claude Code is different. Anthropic documents gateway formats (Anthropic Messages, Bedrock, Agent Platform) and we have not verified that Connect serves any of them, so do not plan on pointing Claude Code at Connect. See AI gateways compared for the wider gateway question.
Swfte Nexus wraps Claude Code and Codex only. It does not wrap OpenCode, so a governed audit trail of OpenCode sessions is not a Nexus feature. Use OpenCode's own permissions and plugins, and read Claude Code security for the approach. For Codex, see Codex vs Claude Code.
You do not need Swfte to use OpenCode with one provider key, or Claude Code on a subscription. Connect matters when you want one endpoint, budgets and audit in front of several models.
Sources and last verified
Every dated or technical fact on this page was read from the pages below on 2026-10-07. Anything that could not be confirmed is left out or marked as not verified.
- OpenCode home page. What OpenCode is, surfaces, provider claim and the optional Zen and Go services.
- OpenCode docs. Install methods, /connect and /init.
- OpenCode repository. Licence, agents and desktop beta. The sst/opencode address showed the same repository.
- OpenCode LICENSE. Confirmed MIT licence text.
- OpenCode providers. Local models and custom OpenAI-compatible providers.
- OpenCode permissions. Allow, ask and deny rules and defaults.
- OpenCode MCP servers. Local and remote MCP and OAuth.
- OpenCode rules. AGENTS.md and the CLAUDE.md fallback.
- OpenCode config. Config formats, precedence and sharing setting.
- OpenCode agents. Primary agents and subagents.
- OpenCode plugins. The tool.execute.before hook.
- OpenCode CLI. Non-interactive run, serve, web and GitHub commands.
- OpenCode enterprise. Data and privacy statements, central config.
- OpenCode Zen. Pay-as-you-go model service and its retention statements.
- OpenCode Go. Go and Go Plus monthly prices as shown 2026-10-07.
- Claude Code LICENSE.md. The exact licence wording.
- Claude Code overview. Surfaces, third-party providers and instructions files.
- Claude Code LLM gateways. Gateway support and the statement on non-Claude models.
- Claude Code gateway compatibility. Supported API formats.
- Claude Code permissions. Permission modes.
- Claude Code sandboxing. Scope of the Bash sandbox.
- Claude Code security. Default posture and managed settings.
- Claude Code data usage. Training and retention terms.
- Claude pricing. Plan prices and Claude Code inclusion.
Frequently asked questions
Is OpenCode free?
The software is free: the repository carries the MIT licence. You still pay for models. That means your provider's per-token price, an optional OpenCode plan such as Zen (pay as you go) or Go ($10 a month as shown on 2026-10-07), or your own hardware if you run a local model. Zen is described as completely optional.
Can OpenCode use local models?
Yes. The provider docs show Ollama, LM Studio and llama.cpp through a custom provider that uses the @ai-sdk/openai-compatible package and a baseURL, and say any OpenAI-compatible provider works. The docs do not state how reliable tool calling is on small models, so test your model on your own tasks.
Can Claude Code use a local or non-Claude model?
Not as a supported setup. Anthropic's gateway page says it does not support routing Claude Code to non-Claude models through any gateway. Claude Code does work with Claude models through Anthropic, Amazon Bedrock, Google Agent Platform and Microsoft Foundry, which can matter for where your data is processed.
Does OpenCode read CLAUDE.md?
Yes, as a fallback. OpenCode reads AGENTS.md first, then a global AGENTS.md, then the Claude Code file at ~/.claude/CLAUDE.md unless you disable it. The docs say this supports users migrating from Claude Code. Setting OPENCODE_DISABLE_CLAUDE_CODE=1 turns the fallback off, which matters if you do not want a personal Claude Code file to shape another tool's behaviour.
Does Swfte Nexus wrap OpenCode?
No. Nexus wraps Claude Code and Codex, with an allow, deny or ask gate, audit records, approval learning and completion gates. It does not wrap OpenCode. For OpenCode, use its own permission rules, the tool.execute.before plugin hook and managed configuration.
Does OpenCode have an OS-level sandbox?
The permissions page we read describes allow, ask and deny rules and does not describe an OS-level sandbox. We did not check every other page, so treat that as not verified in either direction. Claude Code documents an opt-in Bash sandbox on macOS, Linux and WSL2 that covers shell commands only.