Tabby: Self-Hosted AI Coding Assistant with 33K+ StarsPersistent Memory for AI Coding Agents in 2026 {</* resource-info */>}

TL;DR: OpenCode is a free, MIT-licensed terminal AI coding agent with 160K+ GitHub stars. It supports 75+ LLM providers, integrates LSP for ~50ms codebase navigation, and costs $0 in software fees. This guide walks you from installation to production-grade workflows.

Why OpenCode Became the Fastest-Growing AI Dev Tool of 2026The AI coding tool landscape in 2026 is defined by a single tension: convenience versus freedom. Closed-source tools like Claude Code and Cursor offer polished out-of-the-box experiences, but they lock you into proprietary models, fixed pricing tiers, and opaque data handling. OpenCode took the opposite bet—and won.By May 2026, OpenCode had accumulated over 160,000 GitHub stars, overtaking Claude Code (122K) to become the most-starred open-source coding agent in history. Its growth wasn’t driven by marketing; it was driven by three structural advantages that matter to professional developers:1. Provider Agnosticism: Switch between GPT-5.5, Gemini 3.1 Pro, Claude Sonnet 4.6, DeepSeek-V4, local Ollama models, and 70+ other providers without rewriting your workflow. #

  1. Zero Software Cost: MIT-licensed, no subscription. You pay only for the API tokens you consume—or nothing at all if you run local models.
  2. Terminal-Native Speed: Built on OpenTUI (TypeScript API + Zig backend) with native LSP integration, delivering symbol navigation in ~50 milliseconds instead of the 45-second text searches common in other agents.—## What OpenCode Actually Is (And Isn’t)OpenCode is not a code completion plugin like GitHub Copilot. It is an autonomous coding agent that operates inside your terminal, reads your entire codebase, executes shell commands, manages Git operations, and orchestrates external tools via the Model Context Protocol (MCP).Think of it as a senior engineer who lives in your terminal, understands your project conventions via AGENTS.md, and can implement features end-to-end while keeping you in the approval loop.### Architecture at a Glance┌─────────────────────────────────────────┐ │ User Input (Natural Language) │ ├─────────────────────────────────────────┤ │ OpenTUI Frontend (Zig + TypeScript) │ ├─────────────────────────────────────────┤ │ LSP Integration │ Models.dev Router │ │ (~50ms symbols) │ (75+ providers) │ ├─────────────────────────────────────────┤ │ Sandbox Shell │ Git Native │ MCP Bus │ └─────────────────────────────────────────┘The LSP integration is the architectural differentiator. Most AI coding agents parse code as raw text, which collapses at scale. OpenCode hooks into Language Server Protocol servers, giving it structured understanding of types, imports, and call graphs—critical for refactoring across large monorepos.—## Installation: Choose Your Path### Universal Installer (macOS & Linux)bash curl -fsSL https://opencode.ai/install | bash This detects your OS, installs dependencies, and sets up the opencode binary globally. Typical install time: under 60 seconds.### Package Managers| Platform | Command | |———-|———| | npm / bun / pnpm | npm install -g opencode-ai | | Homebrew | brew install anomalyco/tap/opencode | | Arch Linux | sudo pacman -S opencode | | Windows (Scoop) | scoop in```bash curl -fsSL https://opencode.ai/install | bash ``` opencode | | Docker | docker run -it --rm ghcr.io/anomalyco/opencode |Windows recommendation: Use WSL2 for the TUI, or install the Desktop App for a native GUI experience.—## Connecting Your First AI ProviderLaunch OpenCode with opencode, then type /connect.### Option A: Bring Your Own Key (BYOK)Ideal if you already have API subscriptions. Supported providers include:
  • Anthropic (Claude Sonnet 4.6, Opus 4.7)
  • OpenAI (GPT-5.4, GPT-5.5, o3)
  • Google (Gemini 3.1 Pro, Gemini 2.0 Flash)
  • AWS Bedrock, Azure OpenAI, Groq
  • OpenRouter (aggregates dozens of frontier and open-weight models)### Option B: OpenCode ZenA curated model service managed by the OpenCode team. Pre-tested for coding tasks, hosted in the US with zero data retention. Prepaid from $20; zero markup on token pricing.### Option C: Local Models via Ollama```bash
Install Ollama, then pull a coding-optimized model #

ollama pull gemma4:9b ollama pull qwen3:14b In OpenCode, select `ollama://gemma4:9b`. **Zero API cost. Zero data leaving your machine.** This is the preferred setup for defense contractors, healthcare orgs under HIPAA, and anyone working with sensitive IP.---## Project Initialization: The AGENTS.md ContractBefore OpenCode can work effectively, it needs to understand your project. The `/init` command generates an bash

Install Ollama, then pull a coding-optimized model #

ollama pull gemma4:9b ollama pull qwen3:14b TS.md Templatemarkdown

Project: E-Commerce Microservices Platform## Stack #

  • Go 1.24 + Fiber web framework
  • PostgreSQL 16 (via sqlc for type-safe queries)
  • Redis 7 for caching and sessions
  • gRPC for inter-service communication
  • Docker Compose for local dev## Conventions
  • All HTTP handlers live in internal/handlers/{domain}/
  • Database migrations are in db/migrations/, never edit manually
  • Use slog for structured logging; no fmt.Println in production code
  • Errors wrap with github.com/pkg/errors to preserve stack traces
  • Tests must achieve >80% coverage; use testify asse```markdown

Project: E-Commerce Microservices Platform #

Stack #

  • Go 1.24 + Fiber web framework
  • PostgreSQL 16 (via sqlc for type-safe queries)
  • Redis 7 for caching and sessions
  • gRPC for inter-service communication
  • Docker Compose for local dev

Conventions #

  • All HTTP handlers live in internal/handlers/{domain}/
  • Database migrations are in db/migrations/, never edit manually
  • Use slog for structured logging; no fmt.Println in production code
  • Errors wrap with github.com/pkg/errors to preserve stack traces
  • Tests must achieve >80% coverage; use testify assertions
1. Affected files and line ranges
2. Proposed idempotency key schema
3. Database migration requirements
4. Test cases that need updating
5. A rollback strategyReview, iterate, then proceed.### Build Mode (Execution)OpenCode writes code, runs tests, fixes failures iteratively, and commits changes. Experimental **background subagents** allow parallel task execution—e.g., one agent refactoring while another writes tests and a third updates API documentation.---## Real-World Workflow: Building a Feature End-to-End**Scenario**: Add OAuth 2.0 login with Google and GitHub to an existing Express + Prisma application.**Step 1**: Initialize and select model
```bash
cd my-app
opencode
/init
/connect  # Select Gemini 3.1 Pro for 1M-token context window
```**Step 2**: Plan mode prompt

Add Google and GitHub OAuth 2.0 login. Use Passport.js with JWT session strategy. Update Prisma schema with User and Account models following NextAuth conventions. Add protected route middleware. Write integration tests with supertest.

- `src/auth/` directory needs creation
- `prisma/schema.prisma` needs User/Account/Session models
- `.env.example` needs GOOGLE_CLIENT_ID, GITHUB_CLIENT_ID
- `src/middleware/requireAuth.ts` for route protection
- `tests/auth/oauth.test.ts` for coverage**Step 3**: Switch to Build mode and execute
OpenCode creates the files, runs `prisma migrate dev`, executes `npm test`, and fixes a missing `passport.serializeUser` configuration it detected during test failures.**Step 4**: Review and share

/share

Generates a read-only link. Send it to your team for async review of the AI's reasoning before merging.---## Multi-Model Strategy: Optimize Cost and QualityThe killer feature of OpenCode is **task-appropriate model selection**. A monolithic approach—using C```bash
cd my-app
opencode
/init
/connect  # Select Gemini 3.1 Pro for 1M-token context window
``` Cost |
|-----------|-------------------|----------------|
| Linting, formatting, simple refactors | Gemma 4 (local/Ollama```
> Add Google and GitHub OAuth 2.0 login. Use Passport.js with JWT session
> strategy. Update Prisma schema with User and Account models following
> NextAuth conventions. Add protected route middleware. Write integration
> tests with supertest.
```ask |
| Legacy code migration (COBOL→Go) | Claude Opus 4.7 (xhigh effort) | ~$5.00-10.00/task |Teams report **60-80% cost reductions** compared to single-model subscriptions by routing each task to the cheapest capable model.---## Extending OpenCode with MCP ServersThe Model Context Protocol (MCP) transforms OpenCode from a coding agent into a general-purpose automation engine.### Example: PostgreSQL MCPAdd to `~/.config/opencode/opencode.json`:
```json
{
  "mcpServers": {
    "db": {
      "command": ["npx", "-y", "@modelcontextprotocol/server-postgres"],
      "env": { "DATABASE_URL": "postgresql://localhost/devdb" }
    }
  }
}
```Now you can prompt:
> "Show me the schema of the orders table and suggest indexes for the slow query in `src/```
> /share
```y.ts`."OpenCode queries the live database, reads the query code, and proposes `CREATE INDEX` statements with EXPLAIN ANALYZE verification.### Popular MCP Integrations| Server | Capability |
|--------|-----------|
| `@modelcontextprotocol/server-postgres` | Schema inspection, query optimization |
| `@modelcontextprotocol/server-browser` | Web scraping, visual regression testing |
| `@modelcontextprotocol/server-github` | Issue creation, PR review, automated releases |
| `@modelcontextprotocol/server-slack` | Notify channels on build status |---## Head-to-Head: OpenCode vs. The Competition| Capability | OpenCode | Claude Code | Cursor | GitHub Copilot |
|-----------|----------|-------------|--------|----------------|
| License | MIT (open source) | Proprietary | Proprietary | Proprietary |
| Monthly software fee | $0 | $20-$200 | $20 | $10-$39 |
| Model flexibility | 75+ providers | Anthropic only | Limited | Limited |
| Local/offline mode | ✅ Ollama/vLLM | ❌ | ❌ | ❌ |
| Terminal-native | ✅ | ✅ | ❌ | ❌ |
| IDE extensions | VS Code, Cursor, Zed | ❌ | Built-in IDE | VS Code, JetBrains |
| LSP integration | ✅ ~50ms | ❌ Text search | Via VS Code | Via VS Code |
| MCP support | ✅ | ```json
{
  "mcpServers": {
    "db": {
      "command": ["npx", "-y", "@modelcontextprotocol/server-postgres"],
      "env": { "DATABASE_URL": "postgresql://localhost/devdb" }
    }
  }
}
```s
- **Claude Code**: Deep Anthropic integration, enterprise compliance (SOC2), Agent Teams for large orgs
- **Cursor**: Visual designers, non-terminal users, all-in-one IDE preference
- **Copilot**: Microsoft ecosystem lock-in, simplest setup for individual developers---## Advanced Configuration and Performance Tuning### Custom Model Routing RulesCreate `~/.config/opencode/model-routes.json`:
```json
{
  "routes": [
    { "pattern": "refactor|lint|format", "model": "ollama://gemma4:9b" },
    { "pattern": "security|audit|vulnerability", "model": "anthropic://claude-sonnet-4.6" },
    { "pattern": "architecture|design|microservice", "model": "google://gemini-3.1-pro" }
  ]
}
```OpenCode automatically selects the cheapest appropriate model based on your prompt keywords.### Workspace PersistenceOpenCode's experimental **Workspaces** feature saves full session context—including file states, conversation history, and LSP caches—so you can resume a complex refactoring task days later without losing context.---## Troubleshooting Common Issues**"Context too large" errors**
- Disable unused MCP servers in `opencode.json`
- Use per-agent tool configuration to limit active MCPs
- Switch to Gemini 3.1 Pro for its 1M+ token window**Slow responses on large codebases**
- Ensure LSP server is running (`/lsp status` in OpenCode)
- Exclude `node_modules/`, `.git/`, and build artifacts from indexing
- Use `.opencodeignore` syntax identical to `.gitignore`**Model provider timeouts**
- Increase timeout in provider config (default: 30s)
- For local models, verify Ollama is responsive: `curl http://localhost:11434/api/tags`---







## Recommended Hosting & InfrastructureBefore deploying these tools into production, you'll need solid infrastructure. Two options dibi8 actually uses and recommends:- **DigitalOcean
** — $200 free credit for 60 days across 14+ global regions. The default option for indie devs running open-source AI tools.
- **HTStack
** — Hong Kong VPS with low-latency ac```json
{
  "routes": [
    { "pattern": "refactor|lint|format", "model": "ollama://gemma4:9b" },
    { "pattern": "security|audit|vulnerability", "model": "anthropic://claude-sonnet-4.6" },
    { "pattern": "architecture|design|microservice", "model": "google://gemini-3.1-pro" }
  ]
}
``` as frontier models converge in capability (GPT-5.5, Claude Sonnet 4.6, Gemini 3.1 Pro now score within 5% of each other on SWE-bench), **the differentiation shifts to the orchestration layer**. OpenCode's bet is that developers want to own this layer—to mix, match, and migrate models as the market evolves.160,000 stars later, that bet appears to be paying off. OpenCode won't replace senior engineers, but it eliminates the boilerplate tax that consumes 30-40% of a developer's week. The remaining time is for architecture, for taste, for the decisions that only humans can make.Install it today. Your terminal is already open.```bash
curl -fsSL https://opencode.ai/install | bash

References

References & Sources- OpenCode #

curl -fsSL https://opencode.ai/install | bash

💬 Discussion