Back to home

OpenCode vs Claude Code: The Harness Battle for AI Coding Supremacy (2025)

48K vs 47K GitHub stars. Open source freedom vs Anthropic polish. We dissect the system prompts, 20+ tool definitions, and agent architectures that make each tool tick.

Morph Engineering Team

Posted by Morph Engineering Team

1 minute read


TL;DR: The Quick Answer

The One-Sentence Verdict

OpenCode = Open source + 75 providers + rough edges.
Claude Code = Proprietary + Anthropic-only + production polish.

48K+
OpenCode Stars
47K+
Claude Code Stars
2,896
CC Core Prompt Tokens
20+
CC Built-in Tools

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

MetricOpenCodeClaude Code
GitHub Stars48,324+~47,000
Contributors450+Anthropic team
LicenseMIT (open source)Proprietary
Primary LanguageTypeScript (84%)TypeScript/Node.js
Release CadenceRapid (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 CategoryClaude CodeOpenCode
File editingEdit (search-replace)edit (search-replace)
Web searchWebSearch (built-in)Via MCP
Notebook supportNotebookEdit (native)Via MCP
Skill systemSkills folderskill tool (native)
LSP integrationLimitedOut-of-the-box
MCP loadingEager (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 OpenCode

OpenCode 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 laptop
Native Explore subagent
OpenCode
Claude Code
Interactive agent switching
OpenCode
Claude Code
Checkpoint/Undo system
OpenCode
Claude Code
Remote/mobile control
OpenCode
Claude Code

Claude 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 approaches

Context Management Comparison

FeatureClaude CodeOpenCode
Auto-compactionYes (built-in)Provider-dependent
Manual compaction/compact commandNot available
Session persistenceIn-session onlyServer-side (survives close)
LSP awarenessLimitedNative 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 wins

Security 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.json in 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_*: true enables all tools from an MCP
  • Configuration: opencode.json or opencode.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

TaskOpenCodeClaude Code
Cross-file refactor✓ Correct, 4m 20s✓ Correct, 2m 15s
Bug fix from error✓ Correct, 3m 10s✓ Correct, 1m 45s
Test generation94 tests, 8m 50s73 tests, 5m 9s
Total time16m 20s9m 9s
Code reformatting bugsYes (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:

~30%
Claude Code token efficiency gain
~29%
OpenCode test coverage gain

The Pricing Reality

This is where OpenCode has an unassailable advantage.

Pricing Comparison

AspectOpenCodeClaude Code
Tool costFree (MIT license)Free
Model accessBYOK (any provider)$20-200/mo Anthropic
Total minimum cost$0 (with free tiers)$20/month
Enterprise optionSelf-hostedAnthropic Enterprise
Local model supportYes (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

Provider Freedom
Interactivity
Native Subagents
Checkpoint/Undo
Ecosystem Lock-in
Best For
Multi-provider setupsLocal modelsRemote/mobile controlCustom workflows

"Best interactivity, bring your own everything."

🎯

Claude Code

Anthropic's polished ecosystem play

Provider Freedom
Interactivity
Native Subagents
Checkpoint/Undo
Ecosystem Lock-in
Best For
Codebase explorationEnterprise teamsComplex refactoringNiche languages

"Native Explore agent + instant undo = polish."

Choose Your Tool

Your PriorityBest ChoiceWhy
Use multiple AI providersOpenCode75+ providers vs Anthropic-only
Maximum polish & reliabilityClaude CodeProduction-grade UX
Local model supportOpenCodeNative Ollama integration
Instant undo/rewindClaude CodeCheckpoint system (Esc×2)
Cost optimizationOpenCodeFree tool + BYOK
Deterministic outputsClaude CodeClaude model consistency
Remote/mobile controlOpenCodeClient/server architecture
Enterprise complianceDependsClaude 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.

Sources