TL;DR: The Quick Answer
The One-Sentence Verdict
OpenCode = Open source + 75 providers + rough edges.
Claude Code = Proprietary + Anthropic-only + production polish.
The GitHub star battle is neck-and-neck (48K vs 47K as of January 2025), but the architectures couldn't be more different. Claude Code is a vertical integration masterpiece. OpenCode is a horizontal flexibility play. Choose based on whether you value polish or freedom.
GitHub Stars: The 48K vs 47K Battle
In just five days this January, OpenCode surged from 44,714 to 48,324 stars—a growth rate that suggests massive community momentum. Claude Code hovers around 47K, growing steadily but less explosively.
Repository Statistics
| Metric | OpenCode | Claude Code |
|---|---|---|
| GitHub Stars | 48,324+ | ~47,000 |
| Contributors | 450+ | Anthropic team |
| License | MIT (open source) | Proprietary |
| Primary Language | TypeScript (84%) | TypeScript/Node.js |
| Release Cadence | Rapid (weekly) | Regular (versioned) |
"OpenCode ships fast, which means you might hit the occasional bug. But if you're willing to tolerate a few rough edges for the flexibility to run any model, it's a compelling option."
System Prompt Deep Dive
We extracted Claude Code's system prompts from the compiled source code. Here's what powers each tool's "brain."
Claude Code System Prompt Architecture
Claude Code v2.1.12 uses a modular prompt system with 40+ components totaling thousands of tokens:
Claude Code Prompt Structure (Extracted)
// Claude Code System Prompt Components
├── Core System Prompt (2,896 tokens)
│ ├── Identity & capabilities
│ ├── Tool usage instructions
│ └── Response formatting rules
│
├── Subagent Prompts
│ ├── Plan Mode Enhanced (633 tokens)
│ ├── Explore Agent (516 tokens)
│ └── Task Tool (294 tokens)
│
├── Tool Descriptions (20 built-in tools)
│ ├── Write, Read, Edit, Bash
│ ├── Task, TodoWrite, Glob, Grep
│ ├── WebFetch, WebSearch
│ └── NotebookEdit, KillShell, etc.
│
├── Utility Prompts
│ ├── Conversation summarization
│ ├── Session management
│ ├── CLAUDE.md creation (384 tokens)
│ ├── Security review (2,610 tokens)
│ └── Agent creation architect (1,110 tokens)
│
└── Slash Command Prompts
├── /pr-comments (402 tokens)
├── /review-pr (243 tokens)
└── /security-review (2,610 tokens)OpenCode System Prompt Architecture
OpenCode uses a file-based prompt system with YAML frontmatter:
OpenCode Agent Configuration
# .opencode/agents/build.md (Primary Agent)
---
name: build
description: Default agent for development work
mode: primary
model: anthropic/claude-sonnet-4 # Or any provider
temperature: 0.7
tools:
write: true
edit: true
bash: true
webfetch: true
task: true
todo: true
permission:
edit: allow
bash: ask
webfetch: allow
maxSteps: 50
---
You are a coding assistant focused on software development.
[Custom instructions follow...]
# .opencode/agents/plan.md (Read-only Agent)
---
name: plan
description: Analysis and exploration agent
mode: primary
permission:
edit: deny
bash: ask
---
You are an analyst. Read code, explain patterns,
but do not modify files unless explicitly asked.The Customization Gap
Claude Code: Core prompts are baked in. You can add instructions via CLAUDE.md but cannot modify the 2,896-token core prompt without third-party tools like tweakcc.
OpenCode: Everything is a markdown file. Drop new agents in .opencode/agents/ and they're instantly available. Complete system prompt replacement is a configuration change.
Tool Definitions: 20+ Tools Compared
Claude Code ships with 20 built-in tools. OpenCode has a similar core set but approaches extensibility differently.
Claude Code Built-in Tools (Extracted)
Claude Code Tool Inventory
// Claude Code v2.1.12 Built-in Tools
const CLAUDE_CODE_TOOLS = [
// File Operations
"Read", // Read files with line ranges
"Write", // Create/overwrite files
"Edit", // Search-replace edits
"Glob", // Find files by pattern
"Grep", // Search file contents
// Execution
"Bash", // Execute shell commands
"KillShell", // Terminate running shells
"NotebookEdit", // Edit Jupyter notebooks
// Agent System
"Task", // Spawn subagents
"TodoWrite", // Track task progress
// Web & External
"WebFetch", // Fetch web content
"WebSearch", // Search the web
// IDE Integration
"AskUserQuestion", // Request user input
"EnterPlanMode", // Switch to planning
"ExitPlanMode", // Exit planning
// MCP Tools
"mcp__*", // Dynamically loaded MCP tools
];OpenCode Built-in Tools
OpenCode Tool Inventory
// OpenCode Built-in Tools
const OPENCODE_TOOLS = [
// File Operations
"read", // Read files with line ranges
"write", // Create/overwrite files
"edit", // Search-replace edits
"glob", // Find files by pattern
"grep", // Search with ripgrep
// Execution
"bash", // Execute shell commands
// Agent System
"task", // Spawn subagents
"todo", // Track task progress
"skill", // Load reusable instruction sets
// Web
"webfetch", // Fetch and process web content
// MCP Tools
"mcp_*", // Declaratively configured MCP tools
];Tool Feature Comparison
| Tool Category | Claude Code | OpenCode |
|---|---|---|
| File editing | Edit (search-replace) | edit (search-replace) |
| Web search | WebSearch (built-in) | Via MCP |
| Notebook support | NotebookEdit (native) | Via MCP |
| Skill system | Skills folder | skill tool (native) |
| LSP integration | Limited | Out-of-the-box |
| MCP loading | Eager (all at once) | Declarative (per-agent) |
The MCP Tool Search Revolution
Anthropic recently released MCP Tool Search for Claude Code, introducing "lazy loading" for tools. This reduced token usage from ~134K to ~5K in their testing. OpenCode has always used declarative tool loading:
MCP Tool Configuration Comparison
// Claude Code: MCP tools via mcp.json
{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/path"]
}
}
}
// All tools loaded into context at startup
// New: Tool Search enables lazy loading
// OpenCode: Declarative per-agent control
// opencode.json
{
"tools": {
"mymcp_*": true, // Enable for all agents
"dangerous_tool": false // Disable globally
},
"agent": {
"build": {
"tools": {
"mymcp_write": true,
"mymcp_delete": false // Disable for this agent
}
}
}
}Subagent Architecture Analysis
This is where the tools diverge most dramatically. Claude Code ships with native, production-grade subagents (Plan, Explore, Task) tuned for Anthropic models. OpenCode treats agents as user-configurable YAML files with superior interactivity but less out-of-box polish.
The Key Trade-off
Claude Code: Native Explore subagent that "just works" for codebase navigation. No configuration needed.
OpenCode: Tab to switch agents, @mention to invoke subagents, HTTP API for remote control. More interactive, but you configure the agents yourself.
Claude Code Subagent System (Native)
Claude Code Agent Hierarchy
// Claude Code Subagent Architecture
Primary Context
│
├── Plan Mode (633 tokens prompt)
│ ├── Triggered via /plan or EnterPlanMode tool
│ ├── Read-only by default
│ ├── Outputs plan to file for approval
│ └── Exits with ExitPlanMode tool
│
├── Explore Agent (516 tokens prompt)
│ ├── Fast codebase navigation
│ ├── Read-only access
│ └── Returns findings to parent
│
├── Task Agent (294 tokens prompt)
│ ├── Complex multi-step workflows
│ ├── Own context window
│ ├── Can run in background
│ └── Results summarized to parent
│
└── Custom Agents (user-defined)
├── Defined in .claude/agents/
└── Inherit tool access from config
// Key Feature: Checkpoint System
// Esc twice = instant rewind to last checkpoint
// Unique to Claude Code, not available in OpenCodeOpenCode Subagent System (User-Configurable)
OpenCode Agent Hierarchy + Interactivity
// OpenCode Agent Architecture
// KEY ADVANTAGE: Superior interactivity
Primary Agents (Tab to switch instantly)
├── Build Agent (default)
│ ├── All tools enabled
│ ├── Full filesystem access
│ └── For development work
│
└── Plan Agent
├── Read-only by default
├── Asks permission for bash
└── For analysis/exploration
// INTERACTIVITY FEATURES:
// 1. Tab - instant agent switching
// 2. @agent_name - invoke any subagent inline
// 3. HTTP API - control from mobile/remote
// 4. Persistent sessions - survives terminal close
Subagents (via Task tool or @mention)
├── @general - Complex multi-step tasks
├── @explore - Read-only codebase navigation
└── @custom - Your own agents from .opencode/agents/
// Example: Mobile workflow
$ curl http://localhost:7860/api/message \
-d '{"message": "@explore find auth handlers"}'
// Review results on phone, continue on laptopClaude Code's Killer Features
Native Explore subagent: Claude Code's Explore agent (516-token prompt) is production-tuned for codebase navigation. It "just works" without configuration—crucial for quickly understanding unfamiliar codebases.
Instant rewind: Esc twice to restore to the last checkpoint. When an agent goes off-track, you instantly recover. OpenCode has no equivalent—you're stuck with manual git operations.
OpenCode's Killer Feature: Interactivity
Tab switching: Instantly swap between Build and Plan agents without commands.
@mentions: Invoke any subagent inline with @explore, @general, or custom agents.
HTTP API: Control sessions from mobile, tablets, or remote machines. Start a task at your desk, review on your phone.
Context Management & Compaction
Long coding sessions require sophisticated context management. Both tools handle this differently.
Claude Code Context Strategy
Claude Code Context Management
// Claude Code uses automatic compaction
// Triggered near context limit
// Compaction process:
1. Detect approaching context limit
2. Summarize previous messages (utility prompt)
3. Preserve critical context (file contents, etc.)
4. Continue with reduced token count
// Manual compaction:
$ /compact # Slash command to force compaction
// Context advice from Anthropic:
// "If using Claude in an agent harness that compacts context,
// add this to your prompt so Claude can behave accordingly.
// Otherwise Claude may try to wrap up work as it
// approaches the context limit."OpenCode Context Strategy
OpenCode Context Management
// OpenCode uses Vercel AI SDK's context handling
// Provider-dependent behavior
// Session persistence:
// - Server-side state via Hono HTTP API
// - Sessions survive terminal closure
// - Can reconnect from mobile app
// Manual summarization:
// No built-in /compact equivalent
// Rely on starting new sessions for clean context
// LSP Integration:
// - Automatic symbol awareness
// - Language-specific context enrichment
// - Better code navigation than text-based approachesContext Management Comparison
| Feature | Claude Code | OpenCode |
|---|---|---|
| Auto-compaction | Yes (built-in) | Provider-dependent |
| Manual compaction | /compact command | Not available |
| Session persistence | In-session only | Server-side (survives close) |
| LSP awareness | Limited | Native integration |
Permission & Security Models
How each tool handles dangerous operations reveals their security philosophies.
Claude Code Permission System
Claude Code Permission Configuration
// claude.permissions in settings.json
{
"claude.permissions": {
"edit": "ask", // ask | allow | deny
"bash": "ask",
"bash.rm": "deny", // Specific command patterns
"bash.git": "allow",
"webfetch": "allow"
}
}
// Permission flow:
1. Tool call requested
2. Check permission config
3. If "ask": Show confirmation dialog
4. If "allow": Execute immediately
5. If "deny": Block with error
// Dangerous operation detection:
// Built-in heuristics for destructive commands
// Even with "allow", warns on rm -rf /, etc.OpenCode Permission System
OpenCode Permission Configuration
// opencode.json permission configuration
{
"permission": {
"edit": "allow",
"bash": {
"*": "ask", // Default: ask for all
"git *": "allow", // Allow git commands
"npm test": "allow",
"npm install": "ask",
"rm -rf *": "deny", // Block dangerous patterns
"sudo *": "deny"
},
"webfetch": "allow",
"task": {
"general": "allow",
"explore": "allow",
"custom-*": "ask"
},
"skill": {
"pr-review": "allow",
"dangerous-*": "deny"
}
}
}
// Permission inheritance:
// Agent-specific overrides in frontmatter
// Last matching glob pattern winsSecurity Philosophy Difference
Claude Code assumes you want protection by default, with explicit allows. Better for teams with mixed trust levels.
OpenCode assumes power users who want granular control via glob patterns. More flexible but requires careful configuration.
MCP Integration Patterns
Both tools support the Model Context Protocol, but with different loading strategies.
Claude Code MCP Approach
- Eager loading: All MCP tools loaded at startup (changing with Tool Search)
- Token cost: ~134K tokens with many MCPs (reduced to ~5K with Tool Search)
- Configuration:
mcp.jsonin project root - Server types: Supports stdio and HTTP MCP servers
OpenCode MCP Approach
- Declarative loading: Tools loaded per-agent based on config
- Glob patterns:
mymcp_*: trueenables all tools from an MCP - Configuration:
opencode.jsonoropencode.jsonc - Context efficiency: Only configured tools enter context
MCP Configuration Comparison
// Claude Code: mcp.json
{
"mcpServers": {
"postgres": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-postgres"],
"env": { "DATABASE_URL": "..." }
},
"github": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-github"]
}
}
}
// OpenCode: opencode.json
{
"mcp": {
"postgres": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-postgres"],
"env": { "DATABASE_URL": "..." }
}
},
"agent": {
"build": {
"tools": {
"postgres_query": true,
"postgres_execute": false // Read-only for this agent
}
}
}
}Performance Benchmarks
Real-world task benchmarks reveal practical differences.
Task Completion Benchmarks
| Task | OpenCode | Claude Code |
|---|---|---|
| Cross-file refactor | ✓ Correct, 4m 20s | ✓ Correct, 2m 15s |
| Bug fix from error | ✓ Correct, 3m 10s | ✓ Correct, 1m 45s |
| Test generation | 94 tests, 8m 50s | 73 tests, 5m 9s |
| Total time | 16m 20s | 9m 9s |
| Code reformatting bugs | Yes (all 3 models) | No |
Claude Code completes tasks ~45% faster, but OpenCode generates ~29% more tests. The reformatting bug ("All three models tested with OpenCode tried to reformat existing code") suggests a harness-level issue, not model quality.
Token Efficiency
Claude Code's model-specific optimization shows in token usage:
The Pricing Reality
This is where OpenCode has an unassailable advantage.
Pricing Comparison
| Aspect | OpenCode | Claude Code |
|---|---|---|
| Tool cost | Free (MIT license) | Free |
| Model access | BYOK (any provider) | $20-200/mo Anthropic |
| Total minimum cost | $0 (with free tiers) | $20/month |
| Enterprise option | Self-hosted | Anthropic Enterprise |
| Local model support | Yes (Ollama) | No |
The Cost Optimization Play
OpenCode users can leverage existing API subscriptions, free model tiers, or run local models for $0/month operational cost. Claude Code requires at minimum a $20/month Claude Pro subscription, with heavy users needing $100-200/month tiers.
Decision Framework
OpenCode
The open-source multi-provider rebel
"Best interactivity, bring your own everything."
Claude Code
Anthropic's polished ecosystem play
"Native Explore agent + instant undo = polish."
Choose Your Tool
| Your Priority | Best Choice | Why |
|---|---|---|
| Use multiple AI providers | OpenCode | 75+ providers vs Anthropic-only |
| Maximum polish & reliability | Claude Code | Production-grade UX |
| Local model support | OpenCode | Native Ollama integration |
| Instant undo/rewind | Claude Code | Checkpoint system (Esc×2) |
| Cost optimization | OpenCode | Free tool + BYOK |
| Deterministic outputs | Claude Code | Claude model consistency |
| Remote/mobile control | OpenCode | Client/server architecture |
| Enterprise compliance | Depends | Claude for support, OpenCode for self-host |
"TL;DR: if you have time to experiment, use OpenCode with sonnet-4. Otherwise, use Claude Code."
Frequently Asked Questions
Is OpenCode or Claude Code better for coding in 2025?
Claude Code is better for deterministic refactoring, niche languages, and teams wanting Anthropic's polish. OpenCode is better for multi-provider flexibility, local model support, and cost optimization. Claude Code completed benchmark tasks in 9m 9s vs OpenCode's 16m 20s, but OpenCode generated 94 tests vs Claude's 73.
What are the differences in system prompts?
Claude Code uses a 2,896-token core system prompt with 20 built-in tool descriptions and specialized subagent prompts (Plan: 633 tokens, Explore: 516 tokens, Task: 294 tokens). OpenCode uses modular markdown-based prompts stored in .opencode/agents/ with YAML frontmatter for configuration, allowing complete customization.
Which has better tool support?
Claude Code has 20 built-in tools including Write, Read, Edit, Bash, Task, TodoWrite, and more. OpenCode has similar core tools but treats MCP tools more declaratively. Both support MCP extensibility, but Claude Code's tools are more tightly integrated with its checkpoint system.
Can I use Claude models with OpenCode?
Yes, OpenCode supports Claude models through Anthropic's API. However, Anthropic is reportedly scoping OAuth credentials specifically to Claude Code, which may force OpenCode users to API key authentication rather than using existing Claude subscriptions.
Supercharge Any AI Coding Agent with Morph
Whether you use OpenCode, Claude Code, or Codex—Morph Fast Apply processes your code edits 100x faster with 98% first-pass accuracy. Works with any harness, any provider.