If you follow developer news, you have probably seen the name OpenCode everywhere this year. It is one of the most-starred developer tools on GitHub, and people keep calling it “the open-source Claude Code”. But what is OpenCode, exactly? Is it a model? A chat app? Another Copilot?
This guide answers that in plain words. You’ll learn what OpenCode is, what a coding agent actually does, the one idea that makes OpenCode different (the model is the brain, OpenCode is the hands), how it compares with Claude Code, GitHub Copilot and ChatGPT, whether it is free, and how to install it and run it with a free local model through Ollama.
OpenCode in one line
OpenCode is a free, open-source AI coding agent that works on your code from the terminal, a desktop app or the browser, with almost any AI model you choose.
It is made by Anomaly, the team behind the open-source SST framework, and released under the MIT license. That means anyone can read the code, use it at work, change it, or run their own copy. The project lives on GitHub at anomalyco/opencode.
What does a coding agent actually do?
Before OpenCode makes sense, you need to know the difference between a chatbot and an agent.
When you ask ChatGPT for code, it gives you text. You copy it into your editor, run it, see an error, copy the error back, and repeat. You are doing all the moving.
A coding agent does the moving for you. You give it a goal (“add a test for the discount logic and make it pass”), and it works in a loop:
- Read. It looks at your files: the code, the build file, the tests.
- Plan. It asks the AI model what to do next.
- Act. It edits files and runs commands, such as
mvn testornpm run build. - Check. It reads the result. Test failed? Back to step 1 with the error in hand.
It keeps looping until the job is done, or until it needs to ask you something.
New to the idea? Start with what an AI coding agent is, a plain-English guide with examples and a tour of the other agents.
| Chatbot (ChatGPT, Gemini app) | Coding agent (OpenCode, Claude Code) | |
|---|---|---|
| Sees your project | Only what you paste | Reads the files itself |
| Changes files | No, gives you text to copy | Yes, edits them directly |
| Runs commands and tests | No | Yes, with your permission |
| Fixes its own mistakes | Only if you paste the error back | Reads the error and tries again |
The big idea: the model is the brain, OpenCode is the hands
Here is the one idea that explains everything about OpenCode.
A language model, such as Claude, GPT or Qwen, is a brain. It is very good at reading text and writing text. But on its own, a model can’t open a file, can’t run your tests, can’t see your folder. It only predicts the next words (see what a large language model is if you want to know how).
OpenCode is the hands. It is the program that reads your files, edits them, runs commands, and shows the model what happened. At every step it asks the model “what should I do next?”, and the model answers with something like “open App.java” or “run the tests”.
“The model thinks. OpenCode does. And you can swap the brain without changing the hands.”
That last part is what makes OpenCode different. Most coding agents come from a model company and are built around that company’s models. Claude Code is from Anthropic and runs on Claude. Codex is from OpenAI and is built around GPT. OpenCode is not tied to any model company, so you plug in the brain you want:
- Claude from Anthropic
- GPT from OpenAI (you can even sign in with a ChatGPT Plus or Pro plan)
- Gemini from Google
- your GitHub Copilot subscription
- open models through services like OpenRouter
- a local model on your own laptop, through Ollama or LM Studio
Its list of providers and models comes from an open catalogue called models.dev, so new models show up without waiting for a big update.
What problem does OpenCode solve?
Copilot, Claude Code and ChatGPT already write code well. So why did a new tool become so popular? Because it solves four problems those tools don’t:
- Lock-in. With a vendor’s agent, you use that vendor’s models at that vendor’s price. With OpenCode, a better or cheaper model next month is one setting away.
- Privacy. Paired with a local model, your code never leaves your machine. For a bank, a hospital, or a company with strict rules, that can be the difference between “allowed” and “not allowed”.
- Cost. You can bring your own API key and pay only for what you use, mix an expensive model for hard problems with a cheap one for simple edits, or pay nothing at all with a local model.
- Control. Because it is open source, you can see exactly what it sends to the model, change how it behaves, and build on top of it.
OpenCode vs Claude Code vs GitHub Copilot vs ChatGPT
Here is where each one sits. All four are useful; they just make different trade-offs.
| OpenCode | Claude Code | GitHub Copilot | ChatGPT | |
|---|---|---|---|---|
| What it is | Coding agent | Coding agent | Coding assistant and agent | Chat app |
| Made by | Anomaly (open source) | Anthropic | GitHub (Microsoft) | OpenAI |
| Models | Almost any, including local | Claude | A set chosen by GitHub | OpenAI’s |
| Open source | Yes (MIT) | No | No | No |
| Where you use it | Terminal, desktop app, browser | Terminal, desktop, IDEs, web | IDEs, GitHub, terminal | Browser and apps |
| Cost to start | Free software; pay for the model, or use a local one | Claude plan or API | Free tier, then subscription | Free tier, then subscription |
The honest trade-off: a vendor’s own agent is tuned tightly to its own model, so Claude Code with Claude usually feels very polished. OpenCode gives up some of that tight fit in exchange for freedom. And because OpenCode is only the hands, it is only as smart as the brain you plug in. OpenCode with a top model is excellent; OpenCode with a tiny local model is fine for small jobs and struggles with big ones.
A simple way to remember it:
- Claude Code, Codex, Copilot: “Use our model, in our agent.”
- OpenCode: “Use our agent, with any model you like.”
Is OpenCode free?
The software is free. OpenCode itself costs nothing, for personal or company use. What can cost money is the model:
- Local model (Ollama, LM Studio): free. You pay only in hardware and patience.
- Your own API key (Anthropic, OpenAI, Google, OpenRouter): you pay that provider per use.
- A subscription you already have: sign in with ChatGPT Plus or Pro, or GitHub Copilot.
- OpenCode Go: an optional subscription from the OpenCode team, currently $10 a month, with coding models they have tested.
How to install OpenCode
On macOS, Linux or WSL, the official one-line installer is:
curl -fsSL https://opencode.ai/v2/install | bash
You can also install it with npm, Bun, pnpm or Yarn, download a standalone binary for Windows, macOS or Linux, or use the desktop app. Commands change between versions, so check the OpenCode docs for the latest.
Then open a terminal in your project folder and start it:
cd my-project
opencode
Inside OpenCode, three commands get you going:
| Command | What it does |
|---|---|
/connect |
Connect a provider: paste an API key or sign in |
/models |
Pick which model to use |
/init |
Scan your project and write an AGENTS.md file of project rules |
Now type what you want in plain English, for example: “Explain what this project does, then add a unit test for the PriceCalculator class.”
For the full walkthrough, from install to your first reviewed change, follow how to install and use OpenCode.
Use OpenCode free with a local model (Ollama)
If you already run models with Ollama, OpenCode can use them. Ollama runs the model; OpenCode is the agent that uses it. (New to Ollama? Start with what is Ollama. Confused about which does what? Read OpenCode vs Ollama.)
Start Ollama and pull a model that supports tools:
ollama serve
ollama pull qwen3.5:4b
OpenCode looks for Ollama at 127.0.0.1:11434 on its own, so local models appear in /models without any account. You can also let Ollama do the setup with ollama launch opencode, or by clicking OpenCode on the Apps screen of the Ollama desktop app.
Small local models are great for learning, explaining code and small edits. For big refactors across many files, a larger model (local or cloud) does much better.
Build and Plan: OpenCode’s two main agents
OpenCode comes with two main agents you switch between:
- Build is the default. It can edit files and run commands, and asks your permission for sensitive steps.
- Plan is read-only. It explores your code and writes a plan, but doesn’t change your project files. Use it when you want to think first and edit later.
Behind the scenes, these can hand work to subagents: General for multi-step research and Explore for quickly searching code without editing anything. You can also write your own agents as simple Markdown files in .opencode/agents/, for example a “reviewer” that only reads code and comments on it, using a model you choose.
AGENTS.md: teach OpenCode your project’s rules
Every project has rules a new teammate needs to know: how to build it, how to run the tests, which folders not to touch. OpenCode reads them from a file called AGENTS.md in your project root.
Run /init and OpenCode writes a first version for you by scanning the project. Then edit it like any other file:
# Project rules
- Build with `mvn package`. Run tests with `mvn test`.
- Java 21. Use records for data classes.
- Never edit files in `src/generated/`.
AGENTS.md is a shared convention, so the same file helps other coding agents too. If you are coming from Claude Code, OpenCode can also fall back to your existing CLAUDE.md.
MCP: give OpenCode more tools
OpenCode supports MCP (Model Context Protocol), the open standard for plugging tools into AI agents. With an MCP server, OpenCode can search docs, query a database, or talk to your issue tracker. Adding one is a single command:
opencode mcp add context7 --url https://mcp.context7.com/mcp
Honest limits
- It is only as good as the model. Choose the brain to match the job.
- Small local models have limits. They need a big context window and still struggle with large, multi-file changes.
- It moves fast. OpenCode ships new releases very often, and the move to version 2 changed some commands and settings. Check the docs when something doesn’t match a tutorial.
- More setup than an all-in-one tool. Picking providers and models is power, but also more choices to make.
Who should use OpenCode?
OpenCode is a great fit if you:
- want to try different models without learning a new tool each time,
- need code to stay on your machine and want to use local models,
- want to control cost with your own keys or a subscription you already pay for,
- like open-source tools you can inspect and customise.
If you just want the most polished experience with one top model and don’t mind the lock-in, a vendor’s own agent, such as Claude Code or Copilot, may be simpler.
OpenCode FAQ
Is OpenCode the same as Ollama? No. Ollama runs models on your computer. OpenCode is an agent that uses a model to work on your code. They work well together: Ollama provides the brain, OpenCode the hands. See OpenCode vs Ollama for the full comparison.
Does OpenCode work offline? The agent runs on your machine, and with a local model through Ollama the model does too, so your code doesn’t need to leave your computer. With a cloud model, you need the internet.
Does OpenCode work on Windows? Yes. There is a Windows binary and a Windows desktop app, and the installer also works in WSL.
Can I use OpenCode with my ChatGPT or Copilot subscription?
Yes. In /connect, choose OpenAI and sign in with ChatGPT (Plus or Pro), or choose GitHub Copilot and log in with GitHub.
Is OpenCode safe for company code? It is open source, it asks before risky actions, and you can set rules to allow, ask or deny each kind of action. With a local model, your code stays on your machine. Always check your company’s policy first.
Key takeaways
- OpenCode is a free, open-source AI coding agent. It reads your project, edits files and runs commands, from the terminal, a desktop app or the browser.
- The model is the brain, OpenCode is the hands. It works with Claude, GPT, Gemini, Copilot, OpenRouter, or local models through Ollama.
- It solves lock-in, privacy, cost and control. The trade-off: it is only as smart as the model you plug in.
- Start with
curl -fsSL https://opencode.ai/v2/install | bash, then/connect,/modelsand/init. - Build edits, Plan only reads, and AGENTS.md holds your project’s rules.
Want to go further? Learn how the brain side works in how to run an LLM on your own computer, then read what is Ollama to set up a free local model for OpenCode.
Comments