Bridge the gap between your favorite editor and your favorite AI assistant.
OpenCode is fantastic as a standalone TUI (Terminal User Interface). It's powerful, agentic, and works with any editor. But if you spend your day in VS Code, constantly switching contexts or copy-pasting code snippets breaks your flow.
This extension integrates the OpenCode TUI directly into your VS Code workflow.
You shouldn't have to choose between a great editor (VS Code) and a great AI agent (OpenCode). This connector gives you the best of both worlds:
-
Context Awareness: When you use commands like "Add to Prompt", the extension sends your active file, selection, and diagnostics to OpenCode.
- No more copy-pasting code blocks.
- No more manually typing file paths.
-
Seamless Process Management:
- Auto-Discovery: The extension automatically finds running OpenCode instances serving your current workspace.
- Auto-Spawn: If no instance is running, it spawns one for you in the integrated terminal.
- One command to rule them all.
| Command | Description | Keyboard Shortcut |
|---|---|---|
OpenCode: Add to Prompt |
Send the current file reference (e.g., @src/main.ts#L10-L20) to the TUI |
Ctrl+Shift+A / Cmd+Shift+A |
OpenCode: Select Files to Add |
Open a file picker to select multiple files to add to the prompt | Ctrl+Shift+Alt+A / Cmd+Shift+Alt+A |
OpenCode: Check Instance |
Check if an OpenCode instance is running and connected | |
OpenCode: Show Workspace |
Display workspace information detected by the extension | |
OpenCode: Show Menu |
Quick access menu from the status bar |
Right-click files or folders in the Explorer to quickly send them to OpenCode:
- Add to Opencode → Send Path: Send absolute file/folder paths (e.g.,
@/home/user/project/src/file.ts) - Add to Opencode → Send Relative Path: Send relative paths (e.g.,
@src/file.ts)
Multiple files/folders can be selected. Directories include a trailing slash.
- Explain and Fix (OpenCode): Click on any diagnostic (error, warning, info) and select this quick fix to send the error details to OpenCode for explanation and automatic fixing.
- Connection Status: Shows whether OpenCode is connected (
● OpenCode) or disconnected (○ OpenCode). - Click to Manage: Click the status bar item to access connection management options.
- Runs the OpenCode TUI directly within VS Code's terminal panel
- Auto-focuses the terminal after sending prompts (configurable)
- Open your project in VS Code.
- The extension will find or spawn an OpenCode TUI session.
- Use
OpenCode: Add to Prompt(orCtrl+Shift+A) to reference your current code in the TUI. - Use
OpenCode: Select Files to Add(orCtrl+Shift+Alt+A) to pick multiple files to add to the prompt. - Use
Explain and Fix (OpenCode)to quickly fix errors - hover over any error or click the lightbulb.
You can customize the extension behavior through the following VS Code settings:
| Setting | Type | Default | Description |
|---|---|---|---|
opencode.port |
number | 4096 |
Port for OpenCode server connection |
opencode.binaryPath |
string | "" |
Absolute path to OpenCode binary (leave empty to use PATH) |
opencode.codeAction.severityLevels |
array | ["error", "warning", "information", "hint"] |
Diagnostic severity levels that trigger the "Explain and Fix" code action |
opencode.autoFocusTerminal |
boolean | true |
Automatically focus OpenCode terminal after sending prompts |
- VS Code 1.94.0 or higher
- OpenCode installed and available in your PATH (or configured via
opencode.binaryPath)
For the extension to detect your OpenCode instance, it must be running in server mode with a port specified:
opencode --port 4096The extension will automatically:
- Discover running OpenCode instances by scanning for processes with
--port - Match instances to your current workspace directory
- Connect to the correct instance automatically
If no running instance is found for your workspace, the extension will spawn one automatically in the integrated terminal.
If you want to start OpenCode manually:
# Terminal 1
opencode --port 4096Then use VS Code as normal - the extension will detect and connect to it.
This extension is inspired by:
