OpenCode is the open source AI coding agent Matt Pocock's GLM-5.2 thread kept naming alongside Pi and ZCode: "OpenCode is my preference. Honestly been having comparable results to Opus in my recent usage." With 160,000+ GitHub stars, 900 contributors, and marketing claiming 7.5M monthly developers, it has become the default model-agnostic harness for teams that refuse vendor lock-in.
Unlike a chat wrapper, OpenCode is a full agent harness — tool loop, LSP integration, session management, plan/build modes — shipped as terminal TUI, desktop app (beta on macOS, Windows, Linux), and IDE extension. You connect any model from any provider (Claude, GPT, Gemini, GLM-5.2, local Ollama) or use OpenCode Zen for a curated, benchmarked model list.
Update — July 20, 2026: Want to read the source behind product harnesses? Bojie Li's AI Agent Book chapter5/coding-agent — 17 pure-Python tools, multi-provider — is the pedagogical counterpart to OpenCode and Claude Code.
This guide covers what OpenCode is, how to install it, and when to choose it. For every slash command, see our OpenCode slash commands reference. For GLM-5.2 wiring across harnesses, see How to Run GLM 5.2. Update (July 1, 2026): Run open-source models locally in OpenCode — full stack: Ollama, llama.cpp, LM Studio → opencode.jsonc. Update (July 15, 2026): Desktop tabs — session-per-tab shell; worktrees not in new UI yet. Update (July 16, 2026): SpaceXAI open-sourced Grok Build — Apache 2.0, no external PRs; comparison and install: Grok Build open source.
TL;DR
| OpenCode | Claude Code | Pi | |
|---|---|---|---|
| License | Open source | Proprietary | Open source (MIT) |
| Surfaces | Terminal, desktop, IDE | Terminal, IDE | Terminal (+ SDK) |
| Models | 75+ via Models.dev | Anthropic-first | 15+ providers |
| LSP | Auto-loaded for LLM | Via IDE / tools | Extension-dependent |
| Sub-agents | Built-in (subtask: true) | Built-in | DIY (tmux / packages) |
| Memory file | AGENTS.md (/init) | CLAUDE.md | AGENTS.md |
| Privacy | No code/context stored by OpenCode | Anthropic policies | Local sessions |
| Best for | OSS + any provider + team share links | Anthropic ecosystem | Minimal ownable harness |
What OpenCode actually is
OpenCode's homepage frames it simply: the open source AI coding agent. In harness terms (our explainer), it implements:
- Task intake — natural language,
@filereferences, custom slash commands - Context manager —
/compact,@fuzzy file attach,AGENTS.mdproject memory - Tool execution — file edits, shell (
!command), MCP servers - Loop controller — Plan mode (read-only planning) vs Build mode (Tab to toggle)
- Verification — Git-backed
/undoand/redo(requires Git repo) - Multi-agent — parallel sessions on the same project; subagents via command frontmatter
What makes OpenCode distinct in 2026 is surface area + openness: one harness, three UIs, 75+ providers, and a privacy story — OpenCode does not store your code or context data, so it can run in regulated environments (provider APIs still apply their own retention rules).
By the numbers (from opencode.ai, June 2026): 160K+ GitHub stars, 900+ contributors, 13K+ commits, and marketing citing 7.5M monthly developers — scale that matters because OSS harnesses live or die on issue velocity, provider adapters, and community command libraries in .opencode/commands/.
Install
From opencode.ai/docs:
# Recommended
curl -fsSL https://opencode.ai/install | bash
# Node
npm install -g opencode-ai
# macOS / Linux
brew install anomalyco/tap/opencode
# Arch (AUR latest)
paru -S opencode-bin
Windows: Chocolatey, Scoop, or npm. Docker: docker run -it --rm ghcr.io/anomalyco/opencode.
Desktop app: opencode.ai/download — beta on macOS, Windows, Linux for developers who want GUI without giving up the same agent core.
First session: connect, init, build
cd /path/to/your/project
opencode
Inside the TUI:
| Step | Command | What it does |
|---|---|---|
| 1 | /connect | Add provider — Zen, Anthropic, OpenAI, Z.AI Coding Plan, Ollama, Copilot OAuth, etc. |
| 2 | /models | Pick model (e.g. GLM-4.7, GLM-5.2 when available on your provider) |
| 3 | /init | Analyze repo → create AGENTS.md (same filename as Codex) |
| 4 | Tab | Toggle Plan mode (suggest only) vs Build mode (edit files) |
Example workflow from official docs: describe a feature in Plan mode, iterate on the plan, Tab back to Build mode, say "Go ahead and make the changes." For surgical edits, skip planning and reference files directly:
We need auth on /settings — mirror @packages/functions/src/notes.ts in @packages/functions/src/settings.ts
Full command surface: slash commands guide.
Standout features
LSP enabled
OpenCode automatically loads the right LSPs for the language context the LLM is working in — diagnostics, symbols, and navigation without manual server wiring. That puts it closer to IDE-integrated agents than bare terminal chat. oh-my-pi goes further on LSP-as-tools; OpenCode bakes baseline LSP into the default harness.
Multi-session parallelism
Start multiple agents in parallel on the same project — useful for "fix tests in thread A, update docs in thread B" without context bleed. Pair with explainx.ai agent loops by giving each session a different kickoff prompt and verification target.
Share links
/share creates a link to the current conversation for debugging or handoffs. /export for offline artifacts. Team review of agent runs without screen recordings.
Bring your existing subscriptions
OpenCode supports OAuth flows many harnesses omit:
- GitHub Copilot —
/connect→ login with GitHub - ChatGPT Plus/Pro —
/connect→ OpenAI subscription auth
Plus standard API keys for Anthropic, Google, etc. Credentials land in ~/.local/share/opencode/auth.json per providers docs.
75+ providers and local models
OpenCode uses the AI SDK and Models.dev registry. Local paths documented include Ollama, LM Studio, llama.cpp, Atomic Chat, and NVIDIA NIM. Custom baseURL in opencode.json supports proxies and Z.ai-style endpoints.
OpenCode Zen
OpenCode Zen is a curated model list OpenCode benchmarks for coding agents — transparent pay-as-you-go ($20 balance, auto top-up), usable with any agent (not locked to OpenCode). Solves "which model/provider combo actually works?" without testing 40 combinations yourself. Zero markup on inference; spend limits available.
Running GLM-5.2 on OpenCode
OpenCode is on Z.ai's official Coding Plan tool list. Setup:
/connect→ search Z.AI → select Z.AI Coding Plan if subscribed- Enter Coding Plan API key (z.ai/manage-apikey)
/models→ select GLM-5.2 (or GLM-4.7 for quota-friendly routine work)
For endpoints, effort levels (high / max), 1M context variant, and comparison to Pi/ZCode/Claude Code, read How to Run GLM 5.2 with Every Harness — model context lives in GLM-5.2 explainer.
Custom commands and MCP
OpenCode's extensibility sweet spot is markdown slash commands in .opencode/commands/:
---
description: Run tests until green
agent: build
model: provider/model-id
subtask: false
---
Run the test suite. Fix failures. Stop when all tests pass.
Arguments: $ARGUMENTS
$ARGUMENTS,$1/$2,@path,!shell` — same patterns as our commands referencesubtask: true— force subagent isolation for heavy tasks- MCP servers — configure in OpenCode config for web search, docs, internal tools; browse explainx.ai/mcp-servers for ideas
Kilo Code rebuilt its VS Code extension on OpenCode as the portable server — evidence the harness is becoming shared infrastructure across CLIs and IDEs.
Privacy and data
OpenCode's pitch: privacy first — the product does not store code or context on OpenCode infrastructure. Your prompts still go to whichever model provider you connect (Anthropic, Z.ai, OpenCode Zen hosts in the US with zero-retention policies per their FAQ). For enterprise evals, that split matters: harness local, inference remote.
Contrast with cloud-only agents that sync sessions by default. OpenCode + local Ollama is the air-gapped path; OpenCode + Zen is the "we tested these models" path.
OpenCode vs other harnesses
vs Claude Code
Claude Code wins on Anthropic-native /loop, /background, and Opus integration out of the box. OpenCode wins when you need GLM-5.2 today, Copilot subscription reuse, or open-source auditability. Many teams run both — Claude Code for daily Anthropic work, OpenCode for multi-model experiments.
vs Pi
Pi is minimal — you add MCP, sub-agents, and plan mode yourself. OpenCode ships plan/build modes, subagents, LSP, and 75 providers as defaults. Choose Pi to own every line of harness behavior; choose OpenCode to start coding in ten minutes without sacrificing provider choice.
vs Codex
Codex is OpenAI's harness with /goal and OSS mode via Ollama. OpenCode is vendor-neutral with similar AGENTS.md memory and undo semantics. Codex OSS + GLM: Codex Ollama guide.
vs Cursor
Cursor optimizes IDE-native flow. OpenCode optimizes terminal-first + optional desktop with explicit share links and multi-session. Cursor CLI users: compare Cursor slash commands to OpenCode commands.
Loop engineering on OpenCode
OpenCode does not market "loop engineering" the way Pi and Claude Code do, but the same patterns apply:
- Deterministic exit — custom
/test-until-greencommand + CI script - Plan before build — Tab to Plan mode for spec-first work
/compact— context engineering when sessions run long- Parallel sessions — one loop per worktree or concern
Wire top agent loops as custom commands; add verification gates from loop engineering guide.
Recommended path (June 2026)
New to agent coding:
curl -fsSL https://opencode.ai/install | bashopencode→/connect→ OpenCode Zen (easiest) or existing API key/init→ ask a question about your repo with@file refs
Already on GLM Coding Plan:
/connect→ Z.AI Coding Plan/models→ GLM-5.2 for hard tasks, GLM-4.7 for routine- Read GLM harness guide for quota rules
Building team workflows:
- Commit
.opencode/commands/for/review,/test,/ship - Standardize on
AGENTS.mdvia/init - Use
/sharefor async review of agent sessions
Configuration: opencode.json
OpenCode behavior lives in project or global config (opencode.json with schema at opencode.ai/config.json):
provider— per-providerbaseURL, model lists, options (critical for Z.ai Coding Plan endpoints and corporate proxies)- Themes and keybinds — customize TUI without forking
- Formatters — wire Prettier, rustfmt, etc. so agent edits match team style
- MCP server definitions — attach tools once, reuse across sessions
Credentials from /connect stay in ~/.local/share/opencode/auth.json — separate from repo config so keys never land in Git. For teams, document which providers are approved (Zen only vs BYOK Anthropic vs GLM Coding Plan) in internal runbooks alongside AGENTS.md.
OpenCode Go and Enterprise tiers (listed on opencode.ai) target teams needing managed rollout — check current docs if you are standardizing across hundreds of developers. Individual developers rarely need more than /connect + /init on day one. Power users graduate to custom commands, MCP servers, and Zen spend limits once a single model/provider combo proves stable on real repos.
Summary
OpenCode is the open source, multi-surface coding agent that won 2026 mindshare by combining terminal + desktop + IDE, 75+ LLM providers, auto LSP, parallel sessions, Copilot/ChatGPT OAuth, optional Zen curated models, and a privacy-first local-harness story. It is a complete agent harness — not a thin client — and the harness Matt Pocock's audience keeps picking for GLM-5.2 and Opus-comparable daily driving.
Go deeper:
- OpenCode slash commands — complete reference
- How to Run GLM 5.2 with Pi, OpenCode, Claude Code & More
- What Is an Agent Harness?
- Official docs · GitHub
Related Reading
- Using an open model feels surprisingly good — OpenCode + Kimi on Modal
- Top 10 closed-source and open-source agent harnesses (2026)
- Grok Build open source — SpaceXAI harness vs OpenCode (Jul 2026)
- Inkling self-finetuning demo — Tinker + OpenCode (Jul 2026)
- Thoughtworks zero-cost fallacy — OSS in the agentic era (Jul 2026)
- Claude Code vs OpenCode token overhead — Systima July 2026
- OpenCode Slash Commands: Complete TUI Reference
- How to Run GLM 5.2 with Every Agent Harness
- Pi: Minimal Agent Harness by Mario Zechner
- Kilo Code: Built on OpenCode Server
- Claude Code Commands Reference
- Top 10 AI Agent Loops for Coding Workflows
Star counts, provider list, and Zen pricing are accurate as of June 19, 2026 per opencode.ai. Verify on GitHub and docs before production rollout.
