← Back to blog

explainx / blog

OpenCode: The Open Source AI Coding Agent for Terminal, Desktop, and IDE (2026)

OpenCode is an open source coding agent with 160K GitHub stars — terminal TUI, desktop app, 75+ LLM providers, LSP, multi-session agents, and privacy-first design. Complete setup guide and harness comparison.

·6 min read·Yash Thakker
OpenCodeAgent HarnessAI CodingTerminal AgentsOpen Source
OpenCode: The Open Source AI Coding Agent for Terminal, Desktop, and IDE (2026)

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.

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.

TL;DR

OpenCodeClaude CodePi
LicenseOpen sourceProprietaryOpen source (MIT)
SurfacesTerminal, desktop, IDETerminal, IDETerminal (+ SDK)
Models75+ via Models.devAnthropic-first15+ providers
LSPAuto-loaded for LLMVia IDE / toolsExtension-dependent
Sub-agentsBuilt-in (subtask: true)Built-inDIY (tmux / packages)
Memory fileAGENTS.md (/init)CLAUDE.mdAGENTS.md
PrivacyNo code/context stored by OpenCodeAnthropic policiesLocal sessions
Best forOSS + any provider + team share linksAnthropic ecosystemMinimal 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:

  1. Task intake — natural language, @file references, custom slash commands
  2. Context manager/compact, @ fuzzy file attach, AGENTS.md project memory
  3. Tool execution — file edits, shell (!command), MCP servers
  4. Loop controller — Plan mode (read-only planning) vs Build mode (Tab to toggle)
  5. Verification — Git-backed /undo and /redo (requires Git repo)
  6. 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:

StepCommandWhat it does
1/connectAdd provider — Zen, Anthropic, OpenAI, Z.AI Coding Plan, Ollama, Copilot OAuth, etc.
2/modelsPick model (e.g. GLM-4.7, GLM-5.2 when available on your provider)
3/initAnalyze repo → create AGENTS.md (same filename as Codex)
4TabToggle 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 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.

Live Bootcamp6 weeks

Complete AI Builder Bootcamp

Claude, Python automation & full-stack — 12 live sessions with Yash Thakker.

View bootcamp

The Complete AI Builder Bootcamp is the best AI development course for learning Claude AI, prompt engineering, Python automation, and full-stack web development. This intensive 6-week live bootcamp teaches you how to build AI-powered applications using Claude Projects, Claude Artifacts, Claude Code, and the complete Claude ecosystem. You'll master prompt engineering techniques, learn to create custom Claude connectors and MCP integrations, build Python automation workflows, develop full-stack websites with AI assistance, and create AI marketing agents.

The bootcamp includes 12 live Zoom sessions with Yash Thakker, founder of AISOLO Technologies and instructor to 350,000+ students. You'll build 8+ portfolio projects including AI playbooks, full-stack note-taking applications, Python automation scripts, marketing agents, and personal portfolio websites. The curriculum covers AI fundamentals, Claude Projects and Artifacts, Claude Co-work, Claude plugins and skills, Claude Code for Python development, full-stack development, AI marketing, and capstone projects.

Students receive 1-year access to all recordings, permanent Discord community access, a certificate of completion, and personalized career guidance. All enrollments include a 7-day money-back guarantee. This is the most comprehensive Claude AI bootcamp available, taking students from zero AI knowledge to expert AI builder in 6 weeks.


Running GLM-5.2 on OpenCode

OpenCode is on Z.ai's official Coding Plan tool list. Setup:

  1. /connect → search Z.AI → select Z.AI Coding Plan if subscribed
  2. Enter Coding Plan API key (z.ai/manage-apikey)
  3. /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 reference
  • subtask: 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-green command + 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:

  1. curl -fsSL https://opencode.ai/install | bash
  2. opencode/connectOpenCode Zen (easiest) or existing API key
  3. /init → ask a question about your repo with @ file refs

Already on GLM Coding Plan:

  1. /connectZ.AI Coding Plan
  2. /modelsGLM-5.2 for hard tasks, GLM-4.7 for routine
  3. Read GLM harness guide for quota rules

Building team workflows:

  1. Commit .opencode/commands/ for /review, /test, /ship
  2. Standardize on AGENTS.md via /init
  3. Use /share for 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-provider baseURL, 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:


Related Reading

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.

Related posts