OpenCode
TL;DR
OpenCode is an open-source, MIT-licensed AI coding agent for the terminal, with desktop and IDE clients, built by Anomaly. It works with many model providers, ships Build and Plan primary agents plus delegating subagents, and exposes an HTTP server and TypeScript SDK. It suits developers who want a provider-neutral coding agent they can script.
Key facts
| Type | Harness |
|---|---|
| Languages / SDKs | TypeScript |
| License | MIT |
| Pricing model | Open core |
| Orchestration pattern | Supervisor |
| GitHub stars | 211,058 (as of 2026-09-30) |
| GitHub forks | 27,957 |
| Last push | 2026-09-30 |
| Latest release | v1.18.33 |
| Repository | anomalyco/opencode |
| Website | opencode.ai |
| Documentation | opencode.ai |
| Last verified | 2026-09-30 |
Key features
- Two kinds of agents: primary agents (Build with full tools, Plan restricted to asking before edits and bash) that you switch with Tab, and subagents that primary agents call for focused tasks. (source)
- Built-in General, Explore and Scout subagents; the docs suggest General for running several units of work in parallel. (source)
- Custom agents in opencode.json or Markdown files with their own prompt, model, temperature, step limit and permissions; permission.task restricts which subagents an agent may call. (source)
- Permission rules per tool resolve to allow, ask or deny, with glob patterns for bash commands and an --auto mode that approves everything not explicitly denied. (source)
- Local (stdio) and remote MCP servers, including OAuth sign-in via opencode mcp auth. (source)
- opencode serve runs a headless HTTP server with an OpenAPI 3.1 spec; the TUI is one client of it and @opencode-ai/sdk is a typed JS/TS client. (source)
- opencode acp runs it as an Agent Client Protocol subprocess for editors such as Zed. (source)
- GitHub integration: mention /opencode in an issue or PR comment and it works in your GitHub Actions runner, opening a PR with changes. (source)
Architecture and orchestration pattern
Pattern: Supervisor
Running opencode starts both a server and a TUI client that talks to it; the server publishes an OpenAPI 3.1 spec, which is also used to generate the JS/TS SDK. opencode serve runs the server alone, so scripts, the desktop app, IDE extensions or opencode run --attach <url> can drive the same sessions.
Multi-agent work follows a supervisor model inside one session tree. A primary agent (Build, Plan or one you define) can call subagents through the Task tool, either on its own based on each subagent's description or when the user @-mentions one. Each subagent call creates a child session that the user can open, cycle through and return from. Subagents inherit the calling agent's model unless configured otherwise, and permission.task controls which subagents each agent may invoke.
Project instructions live in an AGENTS.md file (created with /init), which is loaded into context. Long sessions are shortened by a hidden compaction agent, configurable through the compaction option; there is no separate long-term memory store documented.
Human in the loop
Every tool call is checked against the permission config: allow runs it, ask prompts the user, deny blocks it. Rules can target patterns (for example "git *": "allow", "rm *": "deny") and differ per agent; the built-in Plan agent asks before any edit or bash command. --auto (or the TUI command palette) approves everything not explicitly denied. The question tool lets the model ask the user multiple-choice or free-text questions mid-task. Users can open any subagent's child session to watch it, and can @-mention a subagent directly even when an agent's task permissions deny it.
Protocols
| Protocol | Support | Note |
|---|---|---|
| MCP | Yes evidence | Client: local (command-based) and remote MCP servers are configured under mcp in opencode.json, with OAuth handled by opencode mcp auth. |
| A2A | Unknown | No A2A mention in the README or docs sources; repo code search hits were colour hex codes. A feature request to upstream a community A2A prototype (issue #18021) was auto-closed for inactivity, which is not a maintainer statement. |
| AG-UI | Unknown | No AG-UI mention in the README or docs sources and no code search hits; a community PR titled 'Add AG-UI support' (#10935) was closed without merging; not in the AG-UI README integration list. |
Best for
- Terminal-first coding with any of many model providers, including local ones, rather than one vendor's models. (shortlist)
- Teams that script a coding agent from TypeScript through the HTTP server and @opencode-ai/sdk. (shortlist)
- Splitting work between a read-only Plan agent, custom reviewer subagents and a full-access Build agent. (shortlist)
- Organisations that need code to stay on their own infrastructure, via OpenCode Enterprise's central config with SSO and an internal AI gateway. (shortlist)
Not for
- Cross-framework agent networks that need A2A; no A2A support is documented.
- Users who want every action gated by default; most permissions start as allow unless you configure them.
- Long-lived assistants with persistent memory across projects; OpenCode relies on AGENTS.md and session compaction.
Quickstart
npm install -g opencode-ai npm install -g opencode-ai
opencode auth login # store an API key for your provider
# a project-level review subagent that cannot edit files
mkdir -p .opencode/agents
cat > .opencode/agents/reviewer.md <<'EOF'
---
description: Reviews diffs for bugs and risky changes
mode: subagent
permission:
edit: deny
---
List concrete problems in the latest changes.
EOF
opencode run "Add input validation to src/api.ts, then ask @reviewer to check it"
opencode run --agent plan "Outline how to split src/api.ts into modules"
opencode serve --port 4096 # headless server for @opencode-ai/sdk
Common pitfalls
- Remove OpenCode versions older than 0.1.x before installing (README).
- The TUI needs a modern terminal emulator; the docs list recommended ones.
- Most permissions default to
allow(onlydoom_loopandexternal_directorydefault toask, and.envreads are denied); setpermissionrules before letting it run unattended. - Since v1.1.1 the old
toolsboolean config is deprecated in favour ofpermission; it still works for backwards compatibility. - Every enabled MCP server adds its tool definitions to the context; the docs warn that some, such as the GitHub MCP server, can exceed the context limit.
Pros
- Provider-neutral: API keys for any provider in the Models.dev list can be added with opencode auth login. (source)
- Client/server design with an OpenAPI 3.1 spec and a typed JS/TS SDK makes the agent scriptable from other programs. (source)
- Fine-grained allow/ask/deny rules per tool, per command pattern and per agent. (source)
- The paid Zen and Go model services are documented as completely optional. (source)
- Available in editors through ACP and in GitHub issues and PRs through the GitHub integration. (source)
Cons
- Permissive defaults: most permissions are allow unless configured, so edits and shell commands run without prompts in the Build agent. (source)
- MCP servers add their tools to the context; the docs warn heavy servers such as GitHub's can exceed the context limit. (source)
- No native A2A support; a request to upstream a community A2A prototype was closed as not planned after 60 days without activity. (source)
- Config churn: the legacy tools setting was deprecated in v1.1.1 and merged into permission. (source)
Alternatives
FAQ
Does OpenCode support MCP?
Yes, as a client: local and remote MCP servers are added under mcp in opencode.json, and opencode mcp auth handles OAuth. A2A and AG-UI support are not documented.
Is OpenCode free?
The agent is MIT-licensed and works with your own provider keys. The same team sells optional model services (OpenCode Zen pay-as-you-go, OpenCode Go at $10 or $40 a month) and an Enterprise offering priced on request.
How does OpenCode use multiple agents?
Primary agents such as Build and Plan handle the conversation and can call subagents (General, Explore, Scout or your own) through the Task tool; each call runs in a child session you can open.
How is OpenCode different from Claude Code?
OpenCode is MIT-licensed and works with many model providers; it also exposes an HTTP server and TypeScript SDK and runs as an ACP agent in editors.
What language is OpenCode written in?
TypeScript; its SDK is a JS/TS package, @opencode-ai/sdk.
Sources
- anomalyco/opencode repository (README)
- OpenCode homepage
- Intro and install
- Agents
- Permissions
- Tools
- MCP servers
- Server
- SDK
- ACP support
- CLI
- GitHub integration
- Rules (AGENTS.md)
- OpenCode Zen
- OpenCode Go docs
- OpenCode Go pricing
- Enterprise
- Issue #18021: native A2A support request
- PR #10935: Add AG-UI support (closed, not merged)
- AG-UI README integration list