Updated November 9, 2026 — Rewritten for OpenCode 2 (current release 2.2.6): new install URL, new npm package @opencode/cli, new Homebrew tap name, no Windows package managers, and the V2 config, permission and update changes.
Quick answer: install OpenCode in one command
OpenCode 2 is the current major version (2.0.0 shipped on September 11, 2026; 2.2.6 is the latest release as of November 9, 2026). Use the command for your system from the official install page:
| Your system | Install command |
|---|---|
| macOS or Linux (recommended) | curl -fsSL https://opencode.ai/v2/install | bash |
| macOS or Linux with Homebrew | brew install anomalyco/tap/opencode-v2 |
| Any OS with Node.js (incl. Windows) | npm install -g @opencode/cli |
| Windows without Node.js | Download the standalone x64 or ARM64 binary, or install the Linux build inside WSL |
| Arch Linux | sudo pacman -S opencode (extra repo, 2.2.6) or paru -S opencode-beta |
Then open a new terminal and check it:
opencode --version
cd your-project
opencode
Inside OpenCode, type /connect to sign in to a model provider and /models to pick a model. That is the whole install. The rest of this guide covers choosing a method, Windows, Docker, configuration, permissions, updates and fixes.
Old tutorials are now wrong in one important way.
curl -fsSL https://opencode.ai/install | bash,npm install -g opencode-aiandbrew install anomalyco/tap/opencodestill work, but they install OpenCode 1 (latest 1.19.5). The V1 installer refuses to install a 2.x version. If you want the current release, use the/v2/installURL,@opencode/cli, or theopencode-v2tap.
Key takeaways
- The current Unix installer is
curl -fsSL https://opencode.ai/v2/install | bash; it puts the binary in~/.opencode/binand adds it to your shell's PATH. - The OpenCode 2 npm package is
@opencode/cli. The olderopencode-aipackage is OpenCode 1. - OpenCode 1 and 2 both use the
opencodecommand and are no longer installed side by side. Remove a package-managed V1 install before installing V2; the V2 curl installer replaces a V1 binary. - On Windows, OpenCode 2 supports npm and standalone binaries. The V2 docs state that Windows package managers (Chocolatey, Scoop) are not supported.
- Configuration is still JSON or JSONC (
opencode.json/opencode.jsonc), and V1 files keep working. Permissions now use an orderedpermissionsarray. - OpenCode is a terminal coding agent. NxCode is a separate product for building a full app from an idea, so choose based on the job.
OpenCode is an open-source coding agent from Anomaly, available as a terminal interface, desktop app and web interface. This guide focuses on the command-line install because it is the most portable route and the easiest to verify. The maintained repository is anomalyco/opencode (MIT license), and releases are published on its GitHub releases page.
OpenCode terms to know before you install
- CLI means command-line interface.
opencodeis the executable you launch from a shell. - TUI means terminal user interface. Running
opencodeopens a full-screen interface in the terminal;opencode miniopens a minimal one, andopencode run "..."runs a single prompt for scripts and CI. - Background service. In OpenCode 2, local clients connect to one shared background server for your user account, which owns sessions, configuration, permissions and tool execution.
opencode --standaloneruns a private server instead. - Provider is the AI service or compatible endpoint that supplies models. Connecting a provider is separate from installing OpenCode.
- Global vs project configuration. Global settings apply to your account; project settings live with one repository and can be reviewed by a team.
- Permission rule tells OpenCode whether an action should be allowed, denied or require confirmation.
This helps when troubleshooting. command not found is an install or PATH problem. A rejected login is a provider problem. An unexpected file change is a permission problem.
Choose the right installation method
Use one installer and remember which one you chose. Mixing Homebrew, npm and the shell installer can leave several opencode binaries on PATH, and with V1 and V2 sharing one command name, you may end up running a different major version than you think.
| Environment | Recommended starting point | Command or channel | Why choose it |
|---|---|---|---|
| macOS or Linux | Official install script | curl -fsSL https://opencode.ai/v2/install | bash | Direct, documented, no Node.js needed |
| macOS or Linux with Homebrew | Official tap | brew install anomalyco/tap/opencode-v2 | Fits an existing brew upgrade routine |
| JavaScript toolchain | npm, Bun, pnpm, Yarn or Vite+ | Package @opencode/cli | Convenient when Node tooling is already managed |
| Windows | npm or standalone binary | npm install -g @opencode/cli or the .zip from the docs | Native Windows builds for x64 and ARM64 |
| Windows with WSL | Unix installer inside WSL | curl -fsSL https://opencode.ai/v2/install | bash in the WSL shell | Linux environment for repos that already live in WSL |
| Arch Linux | Official repo | sudo pacman -S opencode | Packaged in Arch extra |
| Tool version manager | mise | mise use -g opencode | Requires mise 2026.10.9 or later; older mise installs OpenCode 1 |
| Container | GitHub Container Registry | ghcr.io/anomalyco/opencode:<version> | Isolated, pinned version |
| Managed or offline machine | Standalone binary | Links on opencode.ai/docs | Inspect and distribute through your own tooling |
Pre-installation checklist
- Open a modern terminal. The docs suggest Ghostty, WezTerm, Alacritty or Kitty; truecolor support gives the most accurate theme colors.
- Check for an existing install with
command -v opencodeandopencode --version. A1.xresult means you have OpenCode 1. - If OpenCode 1 came from npm, Homebrew, Chocolatey or Scoop, remove it with that manager before installing V2.
- Decide which provider account or local endpoint you will use. Do not paste credentials into shell history or repository files.
- Use a clean test repository or a disposable branch before letting any coding agent edit important work.
- On a company-managed computer, confirm that downloading executables and connecting an external AI provider is allowed.
Prerequisites depend on the method: the script needs curl and tar, npm needs Node.js, Homebrew needs a working Brew install, Docker needs a Docker runtime. OpenCode itself does not need Go; Go-based install commands in older articles belong to a different, older project.
Install OpenCode on macOS or Linux with the official script
curl -fsSL https://opencode.ai/v2/install | bash
The script detects your OS and CPU (including musl Linux and older x64 CPUs that need a "baseline" build), installs the binary to ~/.opencode/bin, and adds that directory to your shell config (.zshrc, .bashrc and so on). Pass --no-modify-path if you manage PATH yourself, or --version <version> to install a specific release:
curl -fsSL https://opencode.ai/v2/install | bash -s -- --no-modify-path
Restart the terminal, then verify:
command -v opencode
opencode --version
opencode --help
command -v should print one path. If it prints nothing, read the installer's final message and add ~/.opencode/bin to PATH. Do not reach for sudo.
For a controlled rollout, review the installer before piping it to a shell (curl -fsSL https://opencode.ai/v2/install -o install.sh), or download a standalone binary and distribute it through your normal software-management tooling.
Install with npm, Bun, pnpm, Yarn or Vite+
The OpenCode 2 package is @opencode/cli:
npm install -g @opencode/cli
The official equivalents are:
bun install -g --trust @opencode/cli
pnpm add -g --allow-build=@opencode/cli @opencode/cli
yarn global add @opencode/cli
vp install -g @opencode/cli
The package uses a postinstall script to select the native binary for your platform. That is why the Bun and pnpm commands explicitly allow the script; if you drop those flags, the install can finish without a working binary.
If npm reports a global permission error, fix the global prefix or use a Node version manager instead of sudo. Check the package name: npm install -g opencode-ai installs OpenCode 1, and the unscoped opencode package is not the documented CLI.
Install with Homebrew, Arch or mise
Homebrew (macOS and Linux), as documented by OpenCode 2:
brew install anomalyco/tap/opencode-v2
brew info anomalyco/tap/opencode-v2
opencode --version
The Homebrew core formula, brew install opencode, is also on 2.2.6 as of November 9, 2026. The tap formula anomalyco/tap/opencode (no -v2) installs OpenCode 1, so do not follow older guides that use it unless you want V1.
Arch Linux: the official extra package installs OpenCode 2. The V2 docs also list the AUR opencode-beta package; opencode-bin on the AUR is OpenCode 1.
sudo pacman -S opencode
mise: mise use -g opencode installs OpenCode 2 only with mise 2026.10.9 or later.
Install OpenCode on Windows
OpenCode 2 has native Windows builds, and the V2 install page lists two ways to get them:
npm install -g @opencode/cli
or download the standalone CLI from the official page: Windows x64, x64 baseline for older CPUs, or ARM64. Unzip it into a folder on your PATH. Then open a new PowerShell window:
Get-Command opencode
opencode --version
The V2 docs state plainly: Windows package managers are not supported. The choco install opencode and scoop install opencode commands you will see in older guides come from the OpenCode 1 docs.
WSL remains a good option if your repositories and tools already live in Linux. Open your WSL terminal and run the Unix installer there:
curl -fsSL https://opencode.ai/v2/install | bash
Windows and WSL have separate PATHs, home directories and credentials. Installing in WSL does not make opencode available in PowerShell. For best file performance, keep the repository inside the WSL filesystem (for example ~/code) rather than under /mnt/c.
Prefer a graphical app? The OpenCode Desktop installer is available for Windows x64 and ARM64 on the same docs page.
Run OpenCode with Docker or a standalone binary
Container images are published at ghcr.io/anomalyco/opencode with versioned tags. Pin one:
docker run -it --rm ghcr.io/anomalyco/opencode:2.2.6
For real project work, mount only the project directory you need and pass credentials through your container platform's secret mechanism, not a command stored in shell history. Docker is useful for isolated evaluation or a standard developer image, but Git identity, SSH agents and file ownership may need extra setup. It is not safer if you mount your whole home directory.
Standalone binaries for macOS (Apple silicon, Intel, Intel baseline), Windows (x64, x64 baseline, ARM64) and Linux (glibc and musl, x64 and ARM64) are linked from the official install page. Release notes and tags are on GitHub releases.
Older articles may show a Go install command, a repository under opencode-ai, or an image at ghcr.io/opencode-ai/opencode. Those point to older or different code.
Already on OpenCode 1? How to move to V2
According to the official migration guide, V1 and V2 both use the opencode command and are not installed side by side by default.
- Check what you have:
opencode --version. - If V1 came from npm (
opencode-ai), Homebrew (anomalyco/tap/opencode), Chocolatey or Scoop, uninstall it with that manager. - Install V2 with one of the commands above. The V2 curl installer replaces a V1 binary installed by the V1 script.
- Start V2 and confirm your models, credentials, agents, permissions and MCP servers. V2 reads V1 config from the same locations and imports saved credentials.
- Port plugins (V1 plugin code does not run in V2) and any integrations that call the server API.
Two changes worth knowing: terminal UI settings moved from tui.json files to one global ~/.config/opencode/cli.json (auto-migrated), and V2 no longer asks before touching paths outside the project by default. To keep V1's behavior, add { "action": "external_directory", "resource": "*", "effect": "ask" } to your permissions.
Verify the installation and start your first session
Run this sequence in a small Git repository:
command -v opencode
opencode --version
git status --short
opencode
Inside the TUI, run /connect to choose a provider and authenticate, then /models to choose a model. The provider docs cover API keys, OAuth, custom providers and local endpoints. Model names and access change more often than the install process, so this guide does not promise a specific model.
To give OpenCode lasting project context, add an AGENTS.md file with build commands, architecture notes and conventions (see the instructions docs). Review any generated guidance before committing it.
Start with a read-only request such as "Explain the test structure and tell me which command runs the unit tests." That confirms repository discovery works before you allow edits. Then try a narrow change in a disposable branch.
Configure OpenCode with JSON or JSONC
OpenCode supports JSON and JSONC (use JSONC for comments and trailing commas). Per the config docs:
~/.config/opencode/opencode.json(c) # global, all projects
<project>/opencode.json(c) # project
<project>/.opencode/opencode.json(c) # project, higher precedence
Machine-wide managed config can also live in /etc/opencode (Linux), /Library/Application Support/opencode (macOS) or %ProgramData%\opencode (Windows), and it overrides user and project files. A minimal project file:
{
"$schema": "https://opencode.ai/config.json",
// Show update notices instead of installing automatically
"update": "notify"
}
The update key (global config only) accepts "notify" (the default), "auto" or "disable"; it replaces V1's autoupdate. Do not commit access tokens. Theme and keybinding settings go in ~/.config/opencode/cli.json, not opencode.json.
The ~/.config/opencode/config.toml path in very old tutorials is not used. Recreate settings against the current schema rather than renaming a TOML file.
Connect providers without leaking credentials
/connect
/models
Or from the shell:
opencode auth login
opencode auth login anthropic --method key
OpenCode 2 supports API keys, OAuth, provider authentication commands and environment variables. Saved keys and OAuth tokens are stored in the local server's SQLite database. OpenCode also sells its own model access through OpenCode Console and the $10/month OpenCode Go plan, if you do not want to manage a separate provider account.
Safety rules:
- Never put a secret in
opencode.json, a committed transcript or a public screenshot. - Keep personal and production credentials separate. A coding session should not inherit cloud-admin rights.
- Treat local or OpenAI-compatible endpoints as network services: check the base URL, TLS and data handling.
- If a key lands in a tracked file or public issue, revoke it. Deleting the text later is not enough.
Set a safe permission baseline
OpenCode 2 uses an ordered permissions array in which the last matching rule wins, and anything without a matching rule defaults to ask (permissions docs). The docs' own starter example:
{
"$schema": "https://opencode.ai/config.json",
"permissions": [
{ "action": "shell", "resource": "*", "effect": "ask" },
{ "action": "shell", "resource": "git status *", "effect": "allow" },
{ "action": "shell", "resource": "git diff *", "effect": "allow" },
{ "action": "shell", "resource": "git push *", "effect": "deny" },
{ "action": "external_directory", "resource": "*", "effect": "ask" }
]
}
(The last line restores V1's prompt for paths outside the project.) V1 names changed: permission is now permissions, bash is shell, task is subagent.
A practical first-run playbook:
- Start in a clean Git working tree or new branch.
- Keep destructive and external actions on
askordeny. - Allow only routine read and test commands you understand.
- Review the diff after every meaningful edit.
- Run tests yourself; trust command output, not a claim that tests passed.
- Never grant deployment credentials to solve a local coding task.
- Commit only after a human checks the scope.
Admins who need hard restrictions should use policies in managed configuration, because ordinary settings cannot stop users from adding providers, MCP servers or plugins.
OpenCode and NxCode solve different jobs
OpenCode is for developers who want an agent inside an existing repository and are comfortable reviewing terminal commands, diffs, providers and permissions. NxCode is an AI app builder for people who want to turn an idea into a working app without setting up a repository. A free NxCode account can chat and get a build plan; building and publishing the app requires a subscription (Lite $5/month or Pro $20/month).
Choose OpenCode when the job is to inspect, change, test or explain code under version control. Choose NxCode when the job is to shape and ship the product itself. Installing OpenCode does not install NxCode, and an NxCode account is not an OpenCode provider credential.
Troubleshooting decision table
OpenCode 2 runs a shared background service, so the troubleshooting guide starts by checking it. Logs are written to ~/.local/share/opencode/log/opencode.log.
| Symptom | Likely layer | Evidence to collect | Next action |
|---|---|---|---|
opencode: command not found | Install or PATH | command -v opencode, shell profile, installer output | Restart shell; add ~/.opencode/bin (script installs) to PATH |
opencode --version shows 1.x | Wrong channel | which -a opencode, npm/brew inventory | Remove V1 (opencode-ai, anomalyco/tap/opencode), install V2 |
| Version does not change after update | Multiple installs | which -a opencode | Update or remove the binary that appears first on PATH |
| Installer refuses a 2.x version | Old installer URL | Command you ran | Use https://opencode.ai/v2/install |
npm install finishes but opencode fails | Postinstall blocked | Bun/pnpm flags | Re-run with --trust (Bun) or --allow-build=@opencode/cli (pnpm) |
| TUI hangs or sessions do not load | Background service | opencode service status | opencode service restart |
| Provider fails | Authentication | Redacted error, provider docs | Run /connect again; check account access |
| Model missing | Provider access | Provider account, /models list | Pick a model that account can use |
| Unexpected file changes | Instructions or permissions | Git diff, project config | Stop, revert reviewed changes, tighten permissions |
Follow the log while reproducing a problem:
opencode service status
tail -f ~/.local/share/opencode/log/opencode.log
When filing a GitHub issue, include opencode --version, opencode service status, the smallest reproduction and the relevant log lines, with keys, prompts and file contents removed. Do not delete service files or the database while troubleshooting.
Do not fix every error by reinstalling. A working opencode --version plus a login error means the binary is fine; changing API keys will not fix a PATH collision.
Update, pin, roll back or uninstall
From the CLI command reference:
opencode upgrade # latest version (alias: opencode update)
opencode upgrade 2.0.21 --method bun # specific version via a specific method
If Homebrew or npm owns the binary, updating through that same manager keeps its inventory consistent (brew upgrade, npm install -g @opencode/cli@latest). After an update, a running background server keeps the old version until you restart it (opencode service restart). Run opencode --version afterwards.
For a team, test a new release in a sample repository before broad rollout and keep the previous approved version so you can roll back.
Uninstall:
opencode uninstall --dry-run
opencode uninstall
This stops background services and removes the shared cache. Session data, configuration and state are never removed; delete those yourself if you are decommissioning a machine. Package-manager installs are removed through the detected manager; curl installs print the final command to remove the binary. Revoking provider credentials is a separate step.
Five practical setup scenarios
macOS solo developer. Use the /v2/install script or the opencode-v2 Homebrew tap, confirm a single binary path, connect a personal provider and test in a branch.
JavaScript team. Install @opencode/cli through the team's pinned Node environment, write the method in onboarding docs, and avoid a parallel Brew install. Put shared, non-secret settings in the project opencode.jsonc and review them like code.
Windows developer. Use npm install -g @opencode/cli or the standalone binary for native Windows; use WSL if your repos live there. Do not expect Chocolatey or Scoop to deliver V2.
Upgrading from OpenCode 1. Remove the V1 package, install V2, then check models, credentials, permissions and MCP servers before porting plugins.
Security-sensitive evaluation. Review the installer or binary, use a disposable repository with synthetic code, a restricted provider account, ask for external_directory, and deny for pushes and destructive commands.
Final verification checklist
command -v opencodeorGet-Command opencodepoints to the expected install.opencode --versionshows a2.xversion (unless you deliberately chose V1).- No older binary appears earlier on PATH.
/connectauthenticates only the intended provider account, and/modelsshows the model you plan to use.- Global config is valid JSON or JSONC at the documented path; project config contains no secrets.
permissionsprotect destructive commands, external directories and sensitive files.- A read-only first prompt works in a disposable repository, and a small edit gives an understandable Git diff.
- You know which manager owns updates and uninstalls, and where the log file is.
If all of these pass, OpenCode is not just installed: it is connected, observable and running inside a boundary you have reviewed. Next, follow the OpenCode tutorial for a first real project.
Sources and reference links
- OpenCode install page (V2)
- Migrate from V1
- OpenCode 1 docs (legacy install methods)
- Configuration reference
- Providers and TUI provider login
- Permissions
- Troubleshooting
- CLI commands
- OpenCode changelog
- Official GitHub repository and releases
- @opencode/cli on npm and opencode-ai on npm (V1)
- Homebrew formula: opencode
- Arch Linux package: opencode