OpenCode

The most popular open-source coding agent: it plans, writes, and tests code right inside your project.

Illustrative image, AI-generated
DifficultySome experience
Hardwareqwen3-coder:30b needs about 20 GB of (V)RAM · Cloud models work on any machine
LicenseMIT
LinksWebsite · GitHub

OpenCode works in your terminal like a teammate: it reads your project, runs commands, edits files, and explains what it's doing. With a local model via Ollama, it costs nothing and your code stays on your machine. You can also plug in cloud models. Requirement for running locally: Ollama is installed. If tool calls don't work, increase the context length in Ollama to 32k (Ollama app → Settings → Context length).

What is OpenCode?

OpenCode is a coding agent for the terminal. The terminal is the text window where you type commands. An agent is an AI that doesn't just answer questions but takes action itself. OpenCode works like a teammate: it reads your project, runs commands, edits files, and explains what it's doing as it goes.

The program is open source and released under the MIT license, so you can use it freely.

How does it work?

You start OpenCode in your project folder and describe what you want in plain language, in German or English. For example: "Find the bug in the login." OpenCode then looks through the files, suggests or makes changes, and runs commands when needed.

There are two built-in agents. You switch between them with the Tab key:

  • build: The default. It can work in your project and has full access.
  • plan: It's read-only. By default, it doesn't change files, and it asks for permission before running shell commands. This is a good fit for understanding unfamiliar code or planning changes.

There's also a helper agent called general. It searches and handles multi-step tasks. You can call on it with @general in a message.

Local or cloud

Here's the neat part: you decide which AI model powers it. With a local model via Ollama, it costs nothing. Your code stays on your machine. Ollama is a program that runs AI models on your own computer. You can also plug in cloud models. These run on someone else's servers and work on any machine.

What you need

To run it locally, Ollama must be installed. The description uses the model qwen3-coder:30b as an example. It needs about 20 GB of (V)RAM. That's the memory in your computer or graphics card. Cloud models don't have this requirement.

OpenCode is available for macOS, Linux, and Windows. Besides the terminal version, there's a desktop app, which is labeled as a beta.

Limits

An agent with full access can change your files. So review its changes before you accept them. Use the plan agent when you just want to take a look first. Local models need a lot of memory. On weaker machines, the cloud is your fallback. But then your code leaves your machine. If tool calls don't work in Ollama, a larger context length usually helps (see Pitfalls).

Ideas: What you can do with it

Understand unfamiliar code

You've inherited a project or downloaded one from the web, and you don't know where to start. Switch to the plan agent and ask: "How is this project structured?" You get an explanation without anything being changed.

Find and fix a bug

Describe the problem, such as "The form doesn't save anything." The build agent reads the relevant files, suggests a fix, and can apply it. Afterward, you can ask it to run the tests.

Plan a change first, then implement it

Have the plan agent first write down which files would need to change for a new feature. Once the plan looks good, press Tab to switch to build and let it implement the plan.

Hobby project with private code

You're tinkering with a smart-home controller or a bot and don't want to send the code to the cloud. With a local model via Ollama, everything stays on your machine and there are no costs.

Small scripts and cleanup chores

Ask OpenCode to rename files, write a script, or merge duplicate code. It runs the necessary commands itself and explains what it did.

Working on low-end hardware

Does your laptop have too little memory for a large local model? Plug in a cloud model. That way, you can use OpenCode on any machine.

How to try it

Commands from the official guides – just copy them.

Linux

curl -fsSL https://opencode.ai/install | bash
export PATH="$HOME/.opencode/bin:$PATH"    # applies automatically from the next terminal on
ollama pull qwen3-coder:30b
# Register Ollama as a provider (overwrites an existing global OpenCode configuration):
mkdir -p ~/.config/opencode && cat > ~/.config/opencode/opencode.json <<'EOF'
{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "ollama": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "Ollama (lokal)",
      "options": { "baseURL": "http://localhost:11434/v1" },
      "models": { "qwen3-coder:30b": { "name": "Qwen3 Coder 30B" } }
    }
  }
}
EOF
cd dein-projekt && opencode
# In OpenCode, type "/models" and pick "Qwen3 Coder 30B", then just start typing

macOS

curl -fsSL https://opencode.ai/install | bash
export PATH="$HOME/.opencode/bin:$PATH"    # applies automatically from the next terminal on
ollama pull qwen3-coder:30b
# Register Ollama as a provider (overwrites an existing global OpenCode configuration):
mkdir -p ~/.config/opencode && cat > ~/.config/opencode/opencode.json <<'EOF'
{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "ollama": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "Ollama (lokal)",
      "options": { "baseURL": "http://localhost:11434/v1" },
      "models": { "qwen3-coder:30b": { "name": "Qwen3 Coder 30B" } }
    }
  }
}
EOF
cd dein-projekt && opencode
# In OpenCode, type "/models" and pick "Qwen3 Coder 30B", then just start typing

Windows (PowerShell)

# Most reliable in WSL (Ubuntu) using the Linux instructions. Directly on Windows (requires Node.js):
npm install -g opencode-ai
ollama pull qwen3-coder:30b
# Create the configuration as on Linux at %USERPROFILE%\.config\opencode\opencode.json, then:
cd dein-projekt; opencode

Tips

  • Start with the plan agent when you don't know a project yet. It changes nothing and asks before running shell commands.
  • Give small, clear tasks instead of "Build me the whole app." That makes it easier to check each step.
  • Switch between plan and build with the Tab key. This keeps thinking and doing separate.
  • Use `@general` in your message when a search or task needs several steps.
  • Review the changes before you accept them. If you work in a version-control project like Git, it's easier to undo mistakes.

If something goes wrong

  • Tool calls don't work: This happens with local models when the context is too small. In the Ollama app, go to Settings → Context length and raise the value to 32k.
  • The local model runs slowly or not at all: qwen3-coder:30b needs about 20 GB of (V)RAM. If your machine can't handle that, use a cloud model.
  • An older version is still installed: The README advises removing versions older than 0.1.x before installing.
  • You mix up projects with similar names: Projects with "opencode" in their name aren't necessarily from the OpenCode team. Download the program from the official site, opencode.ai.

Ask the AI assistant

Questions about OpenCode, installation or background? Our assistant knows this page and runs on our own machine, not in someone else's cloud.

Connecting …

The Assistant is an AI (Gemma 4) and can make mistakes – please check important details against the source. Questions are used only to generate an answer and are deleted after one hour. Please don't enter any personal data.

Comments

What do you think? Already tried it? Write it here, no sign-up needed.

  1. Loading comments …

Comments are public. Links aren't allowed, and we delete abusive posts. You can delete your own comment at any time in this browser. Learn more in the Privacy Policy.