OpenCode v2 is an open-source AI coding agent that explores codebases, changes files, and runs development commands in response to natural-language requests. You can use it in a terminal, a desktop app, or a browser, and select the AI model that handles each coding session.
A session can begin with a question about unfamiliar code and continue through debugging, editing, and testing. OpenCode records the conversation and tool activity alongside the project. In v2, a shared local service connects the different clients to project sessions, while specialized agents handle planning, implementation, and delegated research.
Key Features
- Searches, reads, creates, and edits files in your repository.
- Runs shell commands and project tests as part of a coding task.
- Switches between Build and Plan agents and delegates research to subagents.
- Opens project sessions in a full-screen terminal, desktop app, or browser.
- Connects provider APIs, OpenAI-compatible custom endpoints, and local AI models.
- Resumes sessions and supports conversation-aware undo and redo.
- Creates Git worktrees for isolated branches of development work.
- Loads project instructions, Agent Skills, custom commands, MCP servers, and plugins.
- Connects to ACP-compatible editors and supports scripted or embedded agent sessions.
How OpenCode Works in a Repository
OpenCode works with the files in the project directory you open. Suppose a login request returns the wrong error. Ask the agent to find the authentication handler and related tests. It can search for matching functions, read their implementations, and trace the error-handling logic. A follow-up request can ask it to change the handler and run the existing test suite. The session keeps the investigation, file edits, command output, and subsequent questions together.
In the terminal UI, type @ to find and reference a project file. For example, Review @src/auth.ts for missing error handling points the agent at a specific file. You can also enter shell mode by typing ! at the beginning of an empty prompt. Press Enter to redirect an active task, or press Ctrl+X followed by Enter to queue a follow-up.
Reopen saved sessions from the session list or paste a session ID into the command palette in the terminal or desktop app. OpenCode can undo and redo recent turns and associated file changes using project snapshots. These snapshots are best-effort recovery for agent activity. Git commits are the durable history for changes you intend to keep.
Build, Plan, and Subagents
Build is OpenCode’s default primary agent. Ask Build to implement a feature, fix a defect, refactor a module, or run tests. By default, Build can read and edit files and run commands, including outside the workspace. Reading sensitive .env files requires approval. The external_directory permission rule controls access beyond the workspace.
Plan is the other built-in primary agent. It can inspect a codebase, examine dependencies, and propose how to implement a change. It does not edit ordinary project files, although it can write OpenCode plan files when requested. Shell commands follow the current permission rules. Switch between primary agents from the terminal when you want to move from investigation to implementation.
Two built-in subagents handle delegated tasks. Explore searches and reads local or web sources and cannot edit files. General handles longer investigations and multistep research with wider tool access. General cannot launch another layer of subagents. A primary agent can delegate a focused question to either one and continue working with the returned findings.
You can create project-specific agents in .opencode/agents/. Each Markdown definition can assign a system instruction, preferred model, primary or subagent role, and tool permissions. For example, a reviewer agent can inspect changed code and existing test results with edit and shell permissions denied.
Terminal, Desktop, and Web Access
The terminal UI (TUI) is the keyboard-first client for repository work. It handles prompts, project file references, sessions, models, agents, and tool activity. For a smaller interactive terminal experience, run opencode mini. For a single prompt in a shell script or CI job, use opencode run.
The desktop app provides a graphical view of sessions and project work on macOS, Windows, and Linux. You can answer an agent’s questions with a click, a number key, or a typed response.
The built-in browser keeps your sign-ins and tabs across app restarts. Its tools can inspect a web page, click controls, enter form values, capture screenshots, examine console and network activity, and run Lighthouse audits. The agent can investigate a broken web interaction in the browser and examine the source code in the related project session.
The web UI opens sessions through the OpenCode service running on your computer or server. Run opencode pair to create a one-time browser sign-in link or QR code. Pairing on a local machine uses a localhost address by default. You can also forward a remote server’s local port over SSH or enable authenticated remote pairing with opencode pair --remote. Remote pairing asks for confirmation before exposing the service on a public address.
OpenCode runs one background service per local user account. The terminal, desktop, and browser clients access sessions and models through that service. You can also launch opencode serve as a dedicated foreground server for deployment under a process manager. A Console subscription is not required for local project sessions or the web UI.
OpenCode v2 Command Quick Reference
Read More: OpenCode Cheat Sheet: CLI Commands, Shortcuts & Config
| Task | Command |
|---|---|
| Open the terminal UI in a project | opencode /path/to/project |
| Send a one-off prompt | opencode run "Explain this repository" |
| Use the minimal terminal UI | opencode mini |
| List model options | opencode models |
| Pair the web UI or another client | opencode pair |
| List configured MCP servers | opencode mcp list |
| Start a foreground API server | opencode serve |
| Start the ACP editor agent | opencode acp |
| List saved sessions | opencode session list |
| Export a session as JSON | opencode session export SESSION_ID |
| Update the CLI | opencode upgrade |
How to Install and Start Using OpenCode v2
Install the CLI on macOS or Linux
curl -fsSL https://opencode.ai/v2/install | bash
# Alternative: Homebrew
brew install anomalyco/tap/opencode-v2
# Alternative: npm
npm install -g @opencode/cliInstall on Windows or download the desktop app
# CLI
winget install --id Anomaly.OpenCode -e
# Desktop app
winget install --id Anomaly.OpenCode.Desktop -eFor the newest Windows build, download the CLI ZIP or desktop installer from GitHub Releases. Extract the CLI ZIP and add the folder containing opencode.exe to your PATH, or run the desktop installer.
Run your first coding session
Open a repository in the terminal and launch OpenCode:
cd /path/to/your/project
opencodeInside the TUI, run /models to select a free model and start coding. In the desktop app, open the Free section of the model picker. To use a paid provider, run /connect, select the provider, and sign in or enter your API key before choosing a model.
Ask it to locate a function and explain its existing tests. Once the response identifies the relevant files, you can request an edit and ask Build to run the related tests.
File changes, tool output, and any permission prompts appear in the active session.
Models, Provider Access, and Pricing
You can connect OpenCode to model providers with an API key or the sign-in options they offer. The model catalog draws on models.dev and OpenCode’s provider definitions.
Models from providers defined in your configuration, such as a local Ollama endpoint, appear in /models even without a provider login. A project, custom agent, or individual opencode run command can use a specific model. If you have no default model configured, opencode run reuses the model from your most recent session unless you pass --model.
OpenCode works with providers including OpenAI, Anthropic, Google, and GitHub Copilot, as well as custom OpenAI-compatible endpoints. ChatGPT Plus and Pro subscribers can connect OpenAI through Sign in with ChatGPT and use models from their plan within its usage limits.
For local inference, connect a running Ollama, LM Studio, or vLLM server and select a model with tool-calling support. Choose a model that fits your available memory.
OpenCode Console
Console offers hosted coding models through an OpenCode account. Run /connect, choose OpenCode, and sign in. Select a model in /models.
Console’s pay-as-you-go inference deducts model usage from credits. There is no standard per-seat Console charge. A credit top-up carries a payment processing fee of 4.6% plus $0.31 per transaction.
For example, $50 of credits costs $52.61 at checkout. When you connect your own provider to a Console workspace, that provider bills its model usage directly.
OpenCode Go, Go Plus, and Go Teams
Go costs $10 per month, Go Plus costs $40 per month, and Go Teams costs $20 per member per month (two-member minimum). Go and Go Plus cover the subscriber and workspace API keys. Go Plus includes higher usage limits. With Go Teams, every member has an individual allowance, with a monthly limit $5 above Go for each model.
All paid models on a Go subscription draw from a shared allowance. The five-hour limit is 20% of your monthly allowance, and the weekly limit is 50%. The five-hour window starts with your first request against the allowance. Weekly limits reset on Mondays at 00:00 UTC, and monthly limits reset at the start of your next billing period.
The dollar value of your allowance varies by model. If you use only MiniMax M4 or only Kimi K3 for the month, your plan covers $15 in usage on Go, $60 on Go Plus, or $20 per member on Go Teams. On Go, $1.50 of usage on either model consumes 10% of your monthly allowance.
Track your Go usage in the desktop model picker. When you reach a limit, switch to a free model or enable Extra Usage on the Go page to draw from your prepaid Console balance. Extra Usage is on by default for Go Teams.
Read More: AI Coding Plan Comparison: Prices, Limits, and Features
Skills, MCP, Plugins, and Developer Integrations
Project instructions, Skills, and custom commands
Keep repository conventions in project instructions and use Agent Skills for recurring tasks that need more detailed procedures. A Skill lives in .opencode/skills/<skill-name>/SKILL.md and can have related scripts or reference files beside it.
OpenCode also discovers Agent Skills from .claude/skills/ and .agents/skills/. When the coding task needs a Skill, the agent loads its instructions into the current conversation.
For a repeatable prompt, create a Markdown command file in .opencode/commands/. For example, review.md with the instruction Review $ARGUMENTS for bugs and missing tests. becomes /review src/auth.ts in the terminal.
Read More: Most Popular Agent Skills on GitHub for Coding Agents
MCP servers and plugins
MCP servers connect the agent to external tools and information, such as current library documentation or a development service. OpenCode works with both local MCP processes and remote endpoints.
OpenCode saves each MCP server’s tool list, so new sessions can start before slow servers finish connecting. If a server temporarily disconnects, OpenCode reconnects on the next tool call.
Add a remote server from the project where you want to use it. If the list shows needs authentication, open /mcps in the TUI, select the server, and sign in.
opencode mcp add context7 --url https://mcp.context7.com/mcp
opencode mcp listPlugins and custom integrations
Plugins extend OpenCode with custom tools, event hooks, and other integrations. They can be loaded from JavaScript or TypeScript files or installed as packages.
Worktrees, editors, and automation
For an experimental feature or refactor, ask OpenCode to create a Git worktree and move its session into that checkout.
A worktree keeps changes for that task in a distinct working directory and branch. Deleting a worktree with uncommitted changes requires an explicit force option.
OpenCode can also act as an Agent Client Protocol (ACP) agent inside a compatible editor, including Zed.
Run opencode acp for the editor connection. Scripts and CI jobs can use opencode run, including JSON-formatted output and file attachments. For recurring tasks, use /automation to manage scheduled prompts or commands. From the desktop Automations view, check schedules, pause or resume tasks, and select Run now to launch an active timer automation immediately.
The server API and JavaScript client expose sessions and events to external programs. Developers embedding an agent into another app can use the @opencode/sdk host to run OpenCode components in-process.
Pros
- Free, MIT-licensed coding agent with model-provider choice.
- Terminal, desktop, and browser access to local project sessions.
- Built-in planning, subagents, session recovery, and Git worktree tools.
- Skills, MCP, plugins, ACP, API, and SDK integration options.
Cons
- Free hosted models have daily request limits. Paid models require provider billing, Console credits, or a subscription.
- Build allows many tool actions by default. Stricter approvals require permission configuration.
- Remote server access requires authentication and network settings.
FAQs
Is OpenCode v2 free to use?
Yes. The OpenCode agent and clients are free under the MIT License. Open /models and choose a free model, such as DeepSeek V4.1 Flash Free or MiMo-V2.6-Flash Free. These hosted models are free for a limited time, with daily request limits. For paid models, use provider billing, Console credits, or a Go subscription. Running a local model uses your own computing resources.
Can I export an OpenCode v2 session?
Yes. opencode session export SESSION_ID exports session data in JSON. Use --sanitize to redact sensitive transcript and file data. Import a saved session using opencode session import FILE.
Can I attach images and files to a prompt?
Yes. The desktop and web clients accept attachments. CLI runs accept file paths through --file, and the terminal UI can reference project files with @. Image interpretation depends on the selected model’s input capabilities.
Alternatives & Related Resources
- 10 Best CLI AI Coding Agents
- Kimi Code CLI: Open-Source AI Coding Agent with Skills & MCP Support
- MiMo Code: Free Open-Source AI Coding Agent with Persistent Memory
- bb: Free Open-Source Agentic IDE for AI Coding Agents
- The Ultimate Claude Code Resource List: Agents, Skills, Plugins & More
Last Updated: Dec 5, 2026 (v2.4.5)










