Ad space · Your tool here
PluginStack
Tutorial

How to install and set up OpenCode (macOS, Linux and Windows)

Checked against the official docs:

[OpenCode](/plugins/opencode/) is an open-source coding agent with a terminal interface, a desktop app and a web interface. It works with many model providers, so you can bring the API key or account you already have. This guide covers installing OpenCode 2 (the current version), connecting a model, your first task, project instructions, MCP servers, updates and the most common problems. It was checked against the OpenCode docs on 27 November 2026, when the current npm release was 2.4.2.

Get new guides by email

New MCP servers and agent tools, checked by hand. Free, unsubscribe anytime.

The newsletter hasn't started sending yet. Join the list now and we'll email you when the first issue goes out. From PluginStack (pluginstackai@gmail.com). Privacy policy.

Paid prompt and rules packs are on the packs page.

Quick answer

  1. On macOS or Linux, run curl -fsSL https://opencode.ai/v2/install | bash (or use Homebrew or npm, below).
  2. Go to your project folder and run opencode.
  3. Type /connect, pick a provider and sign in or paste your API key. Then use /models to choose a model.
  4. Type your task. Press Shift+Tab to switch between the build agent (makes changes) and the plan agent (looks and plans only).

Free: MCP Starter Checklist

One page: Inspector smoke-test, Claude Code + Cursor connect steps, and the stdout gotcha. Join the list and download it free.

Markdown download + occasional PluginStack updates. No spam. Privacy policy.

What you need

  • macOS, Linux or Windows. On Windows, use the standalone download or the desktop app (see below).
  • Access to a model. OpenCode has built-in support for many LLM providers, so you can use an API key or account from a provider you already pay for. OpenCode also sells its own access: OpenCode Console, and OpenCode Go at $10 a month.
  • A terminal with truecolor support makes the themes look right. The docs suggest Ghostty, WezTerm, Alacritty or Kitty, but others work too.

1. Install OpenCode

macOS and Linux

macOS / Linux
bash
curl -fsSL https://opencode.ai/v2/install | bash

Or use a package manager:

bash
# Homebrew
brew install anomalyco/tap/opencode-v2

# npm
npm install -g @opencode/cli

# Bun or pnpm (these flags allow the install script OpenCode needs)
bun install -g --trust @opencode/cli
pnpm add -g --allow-build=@opencode/cli @opencode/cli

# mise (needs mise 2026.10.9 or later; older versions install OpenCode 1)
mise use -g opencode

# Arch Linux (AUR)
paru -S opencode-beta

Windows

OpenCode's docs say Windows package managers aren't supported. Download the standalone Windows CLI (x64, ARM64 or x64 baseline) from the install section of the OpenCode docs, or install the desktop app for Windows from the same page.

Desktop app

The desktop app runs several sessions in tabs, shows each change as a diff and has a built-in browser. Downloads for macOS, Windows and Linux (.deb, .rpm and AppImage) are on the docs intro page.

Coming from OpenCode 1?

Both versions use the opencode command and don't install side by side. Remove a V1 install that came from a package manager before installing V2. The V2 curl installer replaces the V1 program on its own. V2 reads your existing config files from the same places, but V1 plugins don't run in V2. The migration guide covers the rest.

Check the install with:

bash
opencode --version

2. Connect a model

Start OpenCode and run these in its message box:

text
/connect
/models

/connect lists the providers you can use. Pick one, choose how to sign in if it offers more than one way, and follow the prompts. For browser sign-ins, press o to open the link or c to copy it. /models then picks the model. Run /connect again to add another account.

You can do the same from your shell without opening OpenCode:

bash
opencode auth login
opencode auth login anthropic --method key
opencode auth list

OpenCode saves keys and tokens in its own database. Don't edit that file by hand; use /connect or the auth commands. To set a default model, add it to opencode.jsonc in your project in provider/model form:

opencode.jsonc
json
{
  "$schema": "https://opencode.ai/config.json",
  "model": "anthropic/claude-sonnet-5-5",
}

Your personal settings for every project go in ~/.config/opencode/opencode.json (or .jsonc).

3. Run your first task

bash
cd my-project
opencode

You can also pass a folder, as in opencode ~/code/my-project. Then describe what you want. OpenCode has two built-in agents:

  • build (the default) makes changes and runs tools. It asks before reading sensitive environment files.
  • plan looks around and plans without editing your project files. Shell commands still go through permissions.

Press Shift+Tab to cycle between agents, or run /agents. A good habit for bigger changes is to ask the plan agent first, then switch to build.

Other useful commands: /new starts a fresh session, /sessions lists old ones, and /undo takes back your last message and everything OpenCode did after it (/redo brings it back). Ctrl+P opens a list of every action. To run one prompt from a script instead of the full screen, use opencode run "Explain this repository".

4. Give OpenCode project instructions

Add an AGENTS.md file to your project with build commands, code conventions and anything else OpenCode should always know. It loads ~/.config/opencode/AGENTS.md first, then each AGENTS.md from your current folder up to the project root. In a folder without an AGENTS.md, it reads CLAUDE.md instead, so an existing Claude Code setup carries over. See Cursor rules vs AGENTS.md for what to put in the file.

5. Add an MCP server

Add a remote server from your project folder, then check it:

bash
opencode mcp add context7 --url https://mcp.context7.com/mcp
opencode mcp list

Add --global to make the server available in every project. Remote servers sign in with OAuth by default. If the list shows needs authentication, open OpenCode, run /mcps, pick the server and sign in. To add a local server by hand, put it under mcp.servers in your config:

opencode.jsonc
json
{
  "$schema": "https://opencode.ai/config.json",
  "mcp": {
    "servers": {
      "my-server": {
        "type": "local",
        "command": ["npx", "-y", "example-mcp-server"],
      },
    },
  },
}

V2 expects server names under mcp.servers, not straight under mcp. To keep a server configured but switched off, add "disabled": true.

6. Update OpenCode

bash
opencode upgrade

opencode update does the same thing. By default OpenCode tells you when an update is out before installing it. Set "update" in your global config to "auto" to install updates on their own, or "disable" to turn checks off. An automatic update doesn't restart OpenCode's background service, so restart it to use the new version.

Common problems and fixes

OpenCode seems stuck or won't respond

OpenCode runs a shared background service that your terminal, desktop and web sessions all connect to. Check it and restart it if needed:

bash
opencode service status
opencode service restart

Finding the logs

Logs are written to ~/.local/share/opencode/log/opencode.log. Watch them with tail -f ~/.local/share/opencode/log/opencode.log while you repeat the problem. Remove keys, prompts and file contents before sharing any log.

My plugins stopped working after updating

OpenCode 2 has a new plugin API, so V1 plugins don't run until they're ported. Your config, agents, commands and skills should keep working.

An MCP server says "needs authentication"

Run /mcps inside OpenCode, select the server and complete the sign-in.

Reporting a bug

Include the output of opencode --version and opencode service status, and the shortest steps that reproduce it, in an issue on the anomalyco/opencode GitHub repository.

FAQ

Is OpenCode free?

OpenCode itself is open source under the MIT license. You pay your model provider, or OpenCode if you use its Console or Go plan.

Does OpenCode read my CLAUDE.md?

Yes, in any folder that doesn't have an AGENTS.md. Without a global ~/.config/opencode/AGENTS.md, it also reads ~/.claude/CLAUDE.md.

Can I remove OpenCode?

Run opencode uninstall --dry-run to see what would be removed, then opencode uninstall. Your sessions, settings and saved state are kept.

Sources

Commands and config above come from these official docs. Tools change often, so check them for the latest steps.

PluginStack is independent and not affiliated with or endorsed by the companies mentioned. Spotted something out of date? Email pluginstackai@gmail.com.

Get new guides by email

New MCP servers and agent tools, checked by hand. Free, unsubscribe anytime.

The newsletter hasn't started sending yet. Join the list now and we'll email you when the first issue goes out. From PluginStack (pluginstackai@gmail.com). Privacy policy.

Paid prompt and rules packs are on the packs page.