How to Install and Setup OpenCode AI Assistant in VS Code
Photo by Afgprogrammer on Unsplash
I opened VS Code, searched for “OpenCode” in the extension marketplace, and found nothing. Then I tried running the install script in a regular terminal window - the extension didn’t show up in VS Code. After a few failed attempts and some documentation hunting, I figured out the right way to get OpenCode working inside VS Code.
The Problem: Multiple Wrong Paths
Here’s what tripped me up initially:
- OpenCode doesn’t have a traditional VS Code extension you download from the marketplace
- The extension installs automatically when you run OpenCode in the integrated terminal
- Running it in an external terminal doesn’t trigger the VS Code integration
- Different IDEs (VS Code, Cursor, Windsurf, VSCodium) need different CLI commands available
I wasted time trying to find a marketplace extension and running install commands in my regular terminal. Neither approach worked.
The Direct Answer
The simplest working method: open VS Code’s integrated terminal (Ctrl + ~), run opencode, and the extension installs automatically. But first you need OpenCode itself installed on your system.
Step 1: Install OpenCode on Your System
OpenCode has several installation options. I tried them all and here’s what works:
Method A: Official Script (Recommended)
curl -fsSL https://opencode.ai/install | bashThis script detects your operating system and installs the right binary. It’s what the documentation recommends and it worked on my Mac without issues.
Method B: Node.js Package Managers
If you already use npm, bun, pnpm, or yarn, you can install through those:
# npmnpm install -g opencode-ai
# bun (faster)bun install -g opencode-ai
# pnpmpnpm install -g opencode-ai
# yarnyarn global add opencode-aiI tested the npm method on a Linux machine and it worked fine. The bun method is noticeably faster if you have bun installed.
Method C: Homebrew (macOS/Linux)
# Use the official tap for latest versionbrew install anomalyco/tap/opencodeDon’t use brew install opencode without the tap - that gave me an outdated version on my first attempt.
Method D: Windows Options
On Windows, I had to use different tools:
# Chocolateychoco install opencode
# Scoopscoop install opencodeBut here’s what I found works better on Windows: use WSL (Windows Subsystem for Linux). OpenCode feels more natural in a Unix-like environment. Inside WSL, just use the official script.
# Inside WSLcurl -fsSL https://opencode.ai/install | bashStep 2: Verify the Installation
Before moving to VS Code integration, verify OpenCode is actually installed:
opencode --versionI got:
OpenCode v1.0.0If you see a version number, OpenCode is ready. If you get command not found, something went wrong with the installation.
Step 3: Install the VS Code Extension
This is where I made my mistake. I ran opencode in my regular terminal (outside VS Code) and expected the extension to appear. It didn’t.
Here’s the correct process:
1. Open VS Code
Start VS Code normally and open any project folder.
2. Open the Integrated Terminal
Press Ctrl + ~ (Windows/Linux) or Cmd + ~ (Mac) to open VS Code’s integrated terminal. Or use the menu: View > Terminal.
3. Run OpenCode
opencodeWhen you run this inside VS Code’s integrated terminal, OpenCode detects the IDE and installs its extension automatically.
4. Verify the Extension Installed
I checked by looking at VS Code’s extension panel (Ctrl+Shift+X) and searching “OpenCode”. The extension appeared with an “OpenCode” name after the automatic install.
What If the Extension Doesn’t Auto-Install?
This happened to me on one machine. Here’s the troubleshooting steps:
Check 1: Are You in the Integrated Terminal?
Running in: External terminal (Terminal.app, iTerm2, Windows Terminal) → No extension install VS Code integrated terminal (Ctrl + ~) → Extension auto-installsOpenCode only detects VS Code when running inside its integrated terminal. The detection relies on environment variables that VS Code sets for its terminal.
Check 2: Is the IDE CLI Installed?
OpenCode needs to call your IDE’s command-line tool to install the extension. Check if your IDE CLI is available:
# VS Codecode --version
# Cursorcursor --version
# Windsurfwindsurf --version
# VSCodiumcodium --versionIf any of these return a version, the CLI is installed. If you get command not found, install the CLI.
Check 3: Install the IDE CLI
In VS Code, install the code command:
- Press
Cmd+Shift+P(Mac) orCtrl+Shift+P(Windows/Linux) - Search for “Shell Command: Install ‘code’ command in PATH”
- Select it
Shell Command: Install 'code' command in PATHFor Cursor and Windsurf, check their documentation for CLI installation. Both have similar shell command install options.
Check 4: Permissions
On macOS, I hit a permission issue once. VS Code needed permission to install extensions. Check VS Code’s settings:
{ "extensions.autoUpdate": true, "extensions.allowedExtensions": ["*"]}If allowedExtensions is restricted, OpenCode’s extension might be blocked.
Supporting Multiple IDEs
OpenCode works with more than just VS Code. I tested it with Cursor and Windsurf too.
IDE | CLI Command | Works With OpenCode------------------|--------------|--------------------VS Code | code | YesCursor | cursor | YesWindsurf | windsurf | YesVSCodium | codium | YesAny terminal IDE | - | Terminal mode onlyThe process is identical for each: open the IDE’s integrated terminal, run opencode, and the extension installs automatically.
For Cursor:
# In Cursor's integrated terminalopencodeFor Windsurf:
# In Windsurf's integrated terminalopencodeUsing OpenCode After Installation
Once the extension is installed, here’s what I got:
Code generation - Ask OpenCode to write functions, classes, or entire files.
Code explanation - Select code and ask “what does this do?”
Refactoring - “Refactor this function to be more readable”
Debugging help - “Why is this null pointer exception happening?”
Terminal commands - OpenCode can run shell commands through its MCP integration
The key difference from running OpenCode standalone: the VS Code integration lets OpenCode see your current file, selection, and project context. Running in a separate terminal would require manually providing that context.
Why This Installation Method Matters
OpenCode has over 140,000 GitHub stars and 6.5 million users according to the official site. That popularity comes with different installation preferences - npm users want npm installs, Homebrew users want brew installs, Windows users want Chocolatey.
But the VS Code extension install is consistent: run opencode in the integrated terminal. No matter how you installed OpenCode itself, the extension mechanism is the same.
Common Mistakes I Made
Mistake 1: External Terminal
# In Terminal.app or iTerm2opencode# Extension doesn't installThe fix: always use VS Code’s integrated terminal (Ctrl + ~).
Mistake 2: Missing IDE CLI
OpenCode cannot find 'code' commandPlease install the VS Code shell commandThe fix: install the shell command via VS Code’s command palette.
Mistake 3: Old Homebrew Formula
brew install opencode# Installed outdated versionThe fix: use the official tap: brew install anomalyco/tap/opencode.
Summary
In this post, I walked through installing OpenCode and setting it up for VS Code. The key points:
- Install OpenCode first - Use the official script (
curl -fsSL https://opencode.ai/install | bash) or your preferred package manager - Open VS Code’s integrated terminal - Ctrl + ~ (not an external terminal)
- Run
opencode- The extension installs automatically when OpenCode detects VS Code - Verify the CLI - Make sure
code,cursor, orwindsurfcommands are available - Works with multiple IDEs - VS Code, Cursor, Windsurf, VSCodium all follow the same process
The whole process takes about 5 minutes once you know the right steps. Most of my wasted time came from running commands in the wrong terminal and expecting marketplace-style extension installation.
Final Words + More Resources
My intention with this article was to help others share my knowledge and experience. If you want to contact me, you can contact by email: Email me
Here are also the most important links from this article along with some further resources that will help you in this scope:
Oh, and if you found these resources useful, don’t forget to support me by starring the repo on GitHub!
Comments