Featured image of post OpenCode In-Depth Guide: Installation, Configuration, and Advanced Techniques for the Open-Source Claude Code

OpenCode In-Depth Guide: Installation, Configuration, and Advanced Techniques for the Open-Source Claude Code

📋 Table of Contents


1. What is OpenCode?

OpenCode is currently the hottest AI programming tool, essentially an open-source version of Claude Code. It has replicated almost all core features of Claude Code while solving common pain points for Chinese users such as rate limiting and account bans.

Comparison with Claude Code

Dimension Claude Code OpenCode
Open Source ❌ Closed source ✅ Open source
Free models ❌ Paid API required ✅ Built-in free models
China-friendly ⚠️ Rate limit/ban risk ✅ No restrictions
Skills/MCP ✅ Supported ✅ Fully compatible
Session parallelism ❌ ✅ Core highlight

Core Positioning

  • Open-source Claude Code: Nearly all features, China-friendly, no rate limits or bans
  • Free models: Out-of-the-box GLM-4.7, MiniMax-2.1 and other free models, zero configuration needed
  • Top-tier model integration: Free access to Gemini 3 Pro and Claude 4.5 Opus via Antigravity plugin; GPT Codex via /connect
  • Killer features: Session parallelism, Timeline rollback, Share, Ultra Work multi-agent collaboration
  • Plugin ecosystem: Oh My Open Code (OMO) with seven programming agents + three MCP Servers + various tools

2. Four Installation Forms

⭐ 1. Command Line Version (Primary Recommendation)

The most stable and feature-complete way to use it.

1
2
3
4
5
# Install (Node.js required first)
npm i -g opencode-ai

# Launch
opencode

Prerequisite: Node.js must be installed (download from nodejs.org)

2. Desktop Client (Beta)

Download the client from the official website, install it, and select your project folder.

⚠️ Currently in Beta testing phase with more bugs — not recommended as your primary tool yet.

3. VS Code Plugin Version

Prerequisite: OpenCode CLI must be installed. The plugin’s core value lies in seamless IDE integration, letting AI directly perceive your code context.

  1. Search for OpenCode in the VS Code Extensions marketplace and install it
  2. Shortcut Ctrl + Shift + P → type open opencode and press Enter
  3. The plugin automatically associates with code files open in the left panel
  4. Select code and press Ctrl + Alt + K to quickly paste into the OpenCode chat window

4. Cloud Runtime Environment (GitHub Actions)

Perfect for automated Issue fixing in open-source projects:

  1. Upload your project to a public GitHub repository
  2. Configure API Key in the repository (Settings → Secrets and Variables → Actions)
  3. Type /opencode + requirement description in an Issue comment
  4. GitHub Actions automatically runs the OpenCode workflow
  5. Automatically creates a Pull Request upon completion

3. Free Model Configuration

View Available Models

1
/models    # View all available models (ones marked "free" can be used at no cost)
Model Features
GLM-4.7 Strong programming ability, zero configuration
MiniMax-2.1 Excellent programming skills, fast response

💡 These two free models are more than enough for beginners practicing AI programming.

Connect Top-tier Models

Method 1: Antigravity Plugin (Free Gemini + Claude Access)

Antigravity is Google’s AI programming IDE, generously providing Gemini 3 Pro and Claude 4.5 Opus for free.

  1. Paste the installation prompt in OpenCode (copy from the Antigravity GitHub homepage)
  2. Wait for AI to complete the installation automatically
  3. Open a new terminal and run the login command, select Google → Antigravity login
  4. Log in to your Google account, paste the generated URL
  5. Restart OpenCode — Gemini 3 Pro and Claude 4.5 Opus will appear in /models

Method 2: GPT Codex (Official OpenAI Partnership)

OpenAI has officially partnered with OpenCode, enabling direct ChatGPT Codex integration.

1
/connect    # Select OpenAI → GPT Pro → Browser login

Prerequisite: ChatGPT Plus subscription or higher required.

Method 3: OpenRouter (Universal Connector)

OpenRouter provides access to virtually every major model available, and Chinese users can easily obtain credits.

1
/connect    # Select OpenRouter → Enter API Key

OpenCode supports 75 AI integration methods, covering almost all model providers.


4. Core Feature Highlights

1. Clarifying Questions Before Coding

Before starting to code, OpenCode will ask you a series of questions:

  • Do you just need a code sample, or a complete runnable program?
  • Which features are must-haves?
  • Which model should be used?
  • How should environment variables be stored?

This “ask first, act later” mechanism significantly reduces rework.

2. Command Line Code Diff Interface

OpenCode’s command line diff display is considered the best among all command line programming tools, making code changes clear at a glance.

⭐ 3. Session Parallel Processing

This is OpenCode’s most distinctive feature — multiple Sessions running in parallel:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
# Start the first task (e.g., add a timer)
# While the task is running, create a new session
/new

# Start the second task (e.g., brush color)
# View all session statuses
/sessions

# Switch between sessions
/session <id>

The spinning symbol indicates a Session is running in the background. Two tasks can be developed in parallel without interfering with each other.

4. Timeline Checkpoint Rollback

1
/timeline    # View the complete conversation history of the current Session

Select any historical node:

  • Revert: Roll back both code and chat content to that point in time
  • View: See what modifications the AI made at that time

Like a “time machine” for programming, allowing you to boldly try different approaches.

5. Share

1
2
3
/share      # Share conversation history as a web page
/unshare    # Stop sharing
/export     # Export conversation history as a file

After sharing, a web link is generated displaying the complete conversation history and code modification process, convenient for collaboration or demonstration.


5. Skills Migration

OpenCode is fully compatible with Claude Code’s Skills directory structure, making migration extremely easy:

1
2
# Directory structure mapping
.claude/skills/<skill-name>/    →    .opencode/skills/<skill-name>/

Steps

  1. Create a new .opencode folder in the project root directory
  2. Create a skills folder inside .opencode
  3. Copy the skill folders from .claude/skills/ directly into it
  4. Restart OpenCode — the AI will recognize and call these Skills

Each Skill is essentially an instruction manual with its own directory, telling the AI how to complete tasks in a specific domain.


6. MCP Configuration

OpenCode supports two MCP (Model Context Protocol) modes:

Local MCP

Executed via local commands. Configure in ~/.config/opencode/opencode.json:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
{
  "mcpServers": {
    "shed-cn": {
      "type": "local",
      "command": "npx",
      "args": ["shed-cn"],
      "enabled": true
    }
  }
}

Remote MCP

Called remotely via URL. Using Context7 as an example:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
{
  "mcpServers": {
    "context7": {
      "type": "remote",
      "url": "https://context7-mcp-server-url",
      "headers": {
        "Authorization": "Bearer <your-api-key>"
      },
      "enabled": true
    }
  }
}

After configuration, restart OpenCode and enter /mcp to view configured MCP Servers.


7. Oh My Open Code (OMO) Super Plugin ⭐

OMO is the most popular programming plugin for OpenCode, essentially a bundled package of Tools + MCP + Programming Agents.

Seven Programming Agents

Agent Role Recommended Model
🧠 Sisyphus Main agent, planning & orchestration Claude 4.5 Opus / GPT 5.2
🔮 Prophet Architecture design, code review —
📚 Librarian Literature review, document retrieval —
🔍 Explorer Web search —
🎨 Frontend Engineer Frontend development Gemini 3 Pro
📝 Document Writer Document generation —
🖼️ Multimodal Image/PDF understanding —

Each agent is assigned the most suitable model for its work. The author reportedly spent $24,000 worth of Tokens to find the optimal combination.

Three MCP Servers

  • Web Search: Web search
  • Context7: Access latest technical documentation
  • Grep App: Fast code search across GitHub repositories

Integrated Tools

  • LSP Advanced: Helps AI quickly locate code through language syntax and semantics
  • AST Tool: Related search through code syntax trees
  • LOC Tool: Understand images and PDFs via multimodal vision
  • Delegate Task / Background Task: Agent task assignment and background scheduling

Installation and Usage

Configuration file location: C:\Users\<username>\.config\opencode\oh-my-opencode.json

  1. Copy the install prompt from the OMO GitHub homepage
  2. Paste it into OpenCode and answer configuration questions (subscription status, etc.)
  3. Installation completes automatically

Two Core Usage Patterns

① @ Designate Specific Agent

1
@Frontend Engineer Help me optimize the responsive layout of this page

② Ultra Work Mode (Magic Word ULW)

1
ULW Help me create a pet store application

In Ultra Work mode, Sisyphus as the main agent will:

  • Break down tasks into a Todo List
  • Launch multiple background tasks running in parallel
  • Orchestrate all agents from the center
  • Deliver the complete project

Ralph Loop Mode

Forces AI to work in continuous loops, suitable for extremely difficult tasks:

1
/ralph-loop

Example: “Refactor the entire project using the latest Spring Boot 4 standards until all test cases pass” — can run for hours until the task is complete.


8. Other Useful Features

/init — Project Knowledge Initialization

Let AI read through the entire project folder, generating an agents.md file as a system prompt to help AI quickly understand the project.

/compact — Context Compression

Refine previous conversations into a concise summary, freeing up the model’s context window to avoid Token overflow.

Custom Commands

Create .md files under ~/.config/opencode/commands/ to define custom commands:

1
2
3
4
# Run Tests
Mode: build
Command: npm test
Description: Run all test cases for the project

Usage: /Run Tests to trigger.

Custom Agents

Create .md files under ~/.config/opencode/agents/:

1
2
3
4
# Code Review Agent
Type: subagent
Model: claude-4.5-opus
Description: Specializes in code review, checking code quality, security vulnerabilities, and best practices.
  • Primary Agent: Switch with Tab key, use directly in conversation
  • Sub Agent: Automatically dispatched by the main agent in the background

9. Summary and Recommendations

Use Cases

Scenario Rating Notes
Beginner AI programming ⭐⭐⭐⭐⭐ Free models, zero-cost start
Daily development assistance ⭐⭐⭐⭐⭐ Session parallelism + Timeline rollback
Complex project development ⭐⭐⭐⭐⭐ OMO plugin multi-agent collaboration
Open-source project maintenance ⭐⭐⭐⭐ GitHub Actions cloud automation
Skills/MCP practice ⭐⭐⭐⭐⭐ Fully compatible with Claude Code ecosystem
1
2
3
4
5
6
7
Beginner → CLI installation + built-in free models
  ↓
Advanced → Configure Antigravity for Gemini/Claude access
  ↓
Efficient → Configure Skills + MCP
  ↓
Ultimate → Install OMO plugin, enable Ultra Work mode

OpenCode breaks down the high barriers of AI programming tools, allowing everyone to explore the infinite possibilities of AI-assisted programming at zero cost. Especially for Chinese users, there’s no longer any need to worry about rate limits and bans — you can “build freely, experiment freely.”


10. Hands-on Record: Installing Oh My OpenAgent

Below is the complete conversation record from personally installing Oh My OpenAgent (formerly Oh My Open Code), in a Windows + PowerShell environment.

Environment Check

1
2
opencode --version
# Output: 1.14.39

Installation Process

Tell AI directly in an OpenCode conversation:

“Install and configure oh-my-openagent by following the instructions here: https://raw.githubusercontent.com/code-yeongyu/oh-my-openagent/refs/heads/dev/docs/guide/installation.md"

AI will first ask about your model subscriptions:

Subscription My Status
Claude Pro/Max ❌ None
OpenAI / ChatGPT Plus ❌ None
Gemini ❌ None
GitHub Copilot ✅ Student certified
OpenCode Zen ✅ Free available
Z.ai Coding Plan ❌ None
OpenCode Go ❌ None
Kimi for Coding ❌ None
Vercel AI Gateway ❌ None

⚠️ AI will prompt “Without a Claude subscription, the Sisyphus agent might not work ideally” — but GitHub Copilot will automatically take over as a fallback model.

After confirming subscriptions, AI automatically executes the installation command:

1
2
3
4
5
bunx oh-my-openagent install --no-tui \
  --claude=no --openai=no --gemini=no \
  --copilot=yes --opencode-zen=yes \
  --zai-coding-plan=no --opencode-go=no \
  --kimi-for-coding=no --vercel-ai-gateway=no

Successful installation output:

1
2
3
4
[1/4] Checking OpenCode installation...
[OK] OpenCode 1.14.39 detected
[2/4] Adding oh-my-openagent plugin...
[OK] Plugin added -> C:\Users\<username>\.config\opencode\opencode.json

Post-Installation Configuration Files

Main configuration file ~/.config/opencode/opencode.json:

1
2
3
4
5
{
  "plugin": [
    "oh-my-openagent@latest"
  ]
}

Agent model configuration ~/.config/opencode/oh-my-openagent.json:

AI automatically assigned models based on GitHub Copilot subscription:

Agent Assigned Model
Sisyphus (Main agent) github-copilot/claude-opus-4.7
Oracle (Prophet) github-copilot/gpt-5.5 (medium)
Other Agents Auto-selected from Copilot available models

Authentication Configuration

After installation, you need to manually authenticate GitHub Copilot:

1
opencode auth login

Interactive steps:

  1. Use arrow keys to select GitHub Copilot
  2. Press Enter to confirm
  3. Browser opens automatically, log in to your GitHub student account
  4. Authorization complete, terminal shows successful authentication

How to Reconfigure Agent Models?

Method 1: Tell AI Directly

“Change Sisyphus’s model to claude-sonnet-4.6” “Oracle use gpt-5.5”

Method 2: Manually Edit Configuration File

Directly modify the model field for the corresponding agent in ~/.config/opencode/oh-my-openagent.json.

Additional Configuration: Add OpenCode Zen as Fallback

The free OpenCode Zen was missed during installation (--opencode-zen=no). In a new OpenCode conversation, ask AI to fix it:

“I also have your free OpenCode Zen, but I’ve already logged into GitHub Copilot — help me modify it”

AI’s first attempt set OpenCode Zen as primary (opencode/claude-opus-4-7), making GitHub Copilot the fallback. The actual need was the opposite:

“No, GitHub Copilot should be primary, and OpenCode Zen’s built-in free model as fallback”

After AI corrected it, the final configuration strategy:

1
2
Primary model: github-copilot/*     (paid, use first)
Fallback model: opencode/*          (free credits, auto-switch when Copilot unavailable)

Key configuration snippet (using Sisyphus as example):

1
2
3
4
5
6
7
8
9
{
  "sisyphus": {
    "model": "github-copilot/claude-opus-4-7",
    "fallback_models": [
      { "model": "opencode/claude-opus-4-7" },
      { "model": "opencode/gpt-5.5" }
    ]
  }
}

💡 Tip: When describing configuration needs, make the primary/secondary relationship clear — “XX as primary, YY as fallback” — to avoid AI getting it reversed.

Usage Tips

After installation, type opencode in the terminal to get started:

  • Include ultrawork or ulw in your prompt to trigger automatic parallel processing
  • Press Tab to enter Prometheus (planner) mode
  • Run /start-work to execute full orchestration

Appendix: Troubleshooting Notes

Issue Solution
doctor command timeout (30s) Some checks may hang; add --verbose to troubleshoot, or skip — it doesn’t affect usage
PowerShell if syntax errors OpenCode’s bash commands need syntax conversion under PowerShell
Sisyphus performance drops with non-Claude models This is a known limitation; experience is best with a Claude subscription
AI swaps primary/fallback models State the primary/secondary relationship clearly: “XX as primary, YY as fallback” — don’t just say “add YY for me”

📚 Sources: Tech Shrimp - OpenCode Detailed Guide, Oh My OpenAgent Installation Guide

comments powered by Disqus