Claude Code vs Codex vs OpenCode: which one should you run?

laptop screen displaying colorful code

On March 15, 2026, Claude Code authored roughly 326,000 GitHub commits in a single day. That is not a projection. By February 2026 it was already responsible for approximately 4% of all public GitHub commits, around 135,000 per day. SemiAnalysis projects that number will exceed 20% of all daily commits by end of 2026.

The question for working engineers is no longer whether to use AI coding tools. It is which ones to use, for which tasks, and how to wire them together. This guide covers the full setup for Claude Code, Codex, and OpenCode, plus the honest task-by-task breakdown of where each one wins.

What These Three Tools Actually Are

Before comparing them, you need to understand they are not the same category of thing.

  • Claude Code is a terminal-first AI coding agent built by Anthropic. It runs in your terminal, reads your codebase, edits files, runs commands, and executes multi-step tasks autonomously. Powered by Anthropic’s own models.
  • OpenAI Codex is OpenAI’s coding agent, available across ChatGPT plans and as a CLI. It runs in the cloud in sandboxes, or locally in your terminal. Powered by GPT-5.5 and related models.
  • OpenCode is neither. It is a model-agnostic, open source terminal UI for AI coding agents. Point it at Claude Opus and you get Claude Code scores. Point it at GPT-5.5 and you get Codex scores. Point it at a local Ollama model and your code never leaves your machine.

Claude Code and Codex compete on model quality. OpenCode competes on flexibility, privacy, and cost. A mature workflow uses all three.

What the Benchmarks Actually Tell You

Claude Code (Opus 4.7) leads on SWE-bench Pro with 64.3% against Codex’s 58.6%. SWE-bench Pro tests harder real-world multi-file problems. Codex (GPT-5.5) leads on SWE-bench Verified with 88.7% against 87.6%, and on Terminal-Bench 2.0 with 82.7% against Claude Code’s 69.4%. Terminal-Bench tests shell and system tasks.

Translated into practical terms: Claude Code wins on architectural changes, holistic codebase understanding, and multi-file refactors. Codex wins on shell tasks, scripting, and DevOps automation. That split should drive your tool selection on each task.

️ Installing Claude Code

Prerequisites

You need Node.js 18+ installed. Run node --version to check. You also need an Anthropic account at console.anthropic.com.

npm install -g @anthropic-ai/claude-code
claude --version
claude

To use your own API key instead of the subscription:

export ANTHROPIC_API_KEY="sk-ant-your-key-here"
echo 'export ANTHROPIC_API_KEY="sk-ant-your-key-here"' >> ~/.zshrc
source ~/.zshrc

Your First Session

Open your project directory and launch Claude Code. Here are five tasks you can run immediately:

cd my-fullstack-app
claude
# Understand an unfamiliar codebase
> Explain what this codebase does, how it is structured, and
  what the main data flow is

# Add a feature
> Add a password reset endpoint to the auth module.
  It should send an email with a reset token that expires in 1 hour.
  Use the existing email service. Add tests.

# Fix a bug
> The /api/users endpoint is returning 500 errors for users
  with null email addresses. Find the cause and fix it.

# Refactor
> Refactor the database connection logic. Currently it is
  duplicated across 6 files. Extract it to a shared module
  and update all imports.

# Write tests
> Write comprehensive tests for the payment service.
  Cover the happy path, failed payments, and edge cases.

Claude Code reads relevant files, shows you a plan, asks for confirmation, then executes. You stay in control at every step. That transparency is deliberate and valuable when you are working with production code.

CLAUDE.md: The 10-Minute Investment That Pays Every Session

Create a CLAUDE.md file in your project root. Claude Code reads it at the start of every session. Without it, you re-explain your conventions every time.

touch CLAUDE.md

Fill it with your tech stack, code conventions (error handling patterns, naming rules, which libraries to use), how to run tests, and where things live in the directory. A well-written CLAUDE.md also onboards new engineers instantly because the AI already knows the project and can guide them through it.

Claude Code Pricing

PlanCostNotes
Claude.ai Pro$20/monthRate limits hit quickly with heavy agentic use
Claude.ai Max 5x$100/monthPractical for daily AI coding work
Claude.ai Max 20x$200/monthHeavy agentic workloads
API (BYOK)Pay per tokenMost flexible; use with OpenCode for $30–80/month

The honest note: the $20/month Pro plan hits rate limits within a few hours of real agentic work. A $20 ChatGPT Plus subscription absorbs daily coding-agent work that on Claude would require Max 5x at $100. Start with Pro to evaluate. If you hit limits regularly and the quality justifies it, upgrade. If cost is a concern, run OpenCode with Claude’s API and get the same model quality for roughly $30–80/month.

lines of HTML codes

Installing Codex CLI

npm install -g @openai/codex
export OPENAI_API_KEY="sk-your-openai-key-here"
echo 'export OPENAI_API_KEY="sk-your-openai-key-here"' >> ~/.zshrc
source ~/.zshrc
codex --version

As of July 2026, Codex is included across ChatGPT’s Free, Go, Plus, Pro, Business, and Enterprise plans. If you have a ChatGPT Plus subscription, you already have access through the ChatGPT web app. No installation required for that entry point.

Codex Safety Modes

Understand these before running Codex on a real codebase:

codex --approval-mode suggest      # shows suggestions only
codex --approval-mode auto-edit    # edits files, asks before commands
codex --approval-mode full-auto    # fully autonomous

Where Codex Wins in Practice

The Terminal-Bench 2.0 edge (82.7% vs 69.4%) is visible on exactly this kind of work:

codex "write a script that:
1. Checks all our microservices are healthy
2. Runs database migration if schema is outdated
3. Rotates logs older than 30 days
4. Sends a Slack summary of what it did"

codex "write a production-ready Dockerfile for this Node.js app
with multi-stage build and non-root user"

codex "create a GitHub Actions workflow that runs tests,
checks code coverage, and deploys to AWS on merge to main"

Codex’s GitHub integration also goes deeper than Claude Code’s currently. You can connect your repository at platform.openai.com, then have Codex review open PRs, create issues from bug descriptions, suggest fixes for failing CI checks, and generate pull requests from task descriptions.

‍ Installing OpenCode

npm install -g opencode-ai
# or on Mac:
brew install opencode
opencode --version

Configure Model Profiles

This is OpenCode’s core feature. You route each task type to the right model:

mkdir -p ~/.config/opencode
// ~/.config/opencode/config.json
{
  "providers": {
    "anthropic": {
      "apiKey": "sk-ant-your-key-here",
      "defaultModel": "claude-opus-4-7-20250514"
    },
    "openai": {
      "apiKey": "sk-your-openai-key",
      "defaultModel": "gpt-5.5-turbo"
    },
    "ollama": {
      "baseUrl": "http://localhost:11434",
      "defaultModel": "llama3.1:70b"
    }
  },
  "default": "anthropic",
  "profiles": {
    "complex": {
      "provider": "anthropic",
      "model": "claude-opus-4-7-20250514",
      "description": "Complex multi-file tasks, architecture"
    },
    "fast": {
      "provider": "anthropic",
      "model": "claude-haiku-4-5",
      "description": "Quick edits, simple questions"
    },
    "shell": {
      "provider": "openai",
      "model": "gpt-5.5-turbo",
      "description": "Terminal tasks, scripts, DevOps"
    },
    "private": {
      "provider": "ollama",
      "model": "llama3.1:70b",
      "description": "Sensitive code — runs 100% locally, no API calls"
    },
    "free": {
      "provider": "ollama",
      "model": "codestral:22b",
      "description": "Cost-free coding — good for routine tasks"
    }
  }
}
opencode --profile complex "refactor the payment service"
opencode --profile shell "write a log rotation script"
opencode --profile private "review this client NDA code"
opencode --profile free "add JSDoc comments to all functions"

Running Completely Local with Ollama

This is the use case no other tool matches. Your code stays on your machine. No API keys. No monthly subscription. No data leaving your network.

curl -fsSL https://ollama.ai/install.sh | sh
ollama pull codestral:22b
ollama pull deepseek-coder:6.7b
ollama pull llama3.1:8b
ollama serve
opencode --profile free "explain how the authentication middleware works"

Local models are good for understanding code, explaining concepts, writing simple functions, and routine refactoring. They are not as capable as Claude Opus or GPT-5.5 for complex multi-file architectural changes. But they are completely free and completely private.

A smartphone displaying music on a desk with computer monitors showing code

Task-by-Task Decision Framework

Understanding an unfamiliar codebase

Use Claude Code. Its ability to read across an entire codebase and synthesize a coherent understanding is its strongest single feature. Run it every time you open an unfamiliar repo.

Multi-file feature implementation

Use Claude Code. The SWE-bench Pro lead (64.3% vs 58.6%) is visible on tasks like adding multi-tenancy support, planning cross-cutting migrations, and keeping changes consistent across many files simultaneously.

Shell scripts and DevOps automation

Use Codex CLI. Terminal-Bench 2.0: Codex 82.7% vs Claude Code 69.4%. For writing deployment scripts, log rotation, service health checks, and GitHub Actions workflows, Codex has a meaningful and practical edge.

Quick questions and simple edits

Use OpenCode with the fast profile (Claude Haiku). Sending every quick question to Claude Opus or GPT-5.5 is expensive and unnecessary. Configure a fast, cheap model for simple tasks and save the expensive models for work that needs them.

Sensitive or confidential code

Use OpenCode with Ollama (local). For anything under an NDA or with legal and compliance constraints on data handling, OpenCode with a local model is the only safe choice. The desktop and iOS apps are MIT licensed with source on GitHub.

Writing tests

Claude Code or Codex, depending on the goal. Claude Code writes tests that fit your existing test structure naturally. Codex writes more comprehensive edge case coverage. Use Claude Code when style consistency matters. Use Codex when coverage breadth matters.

Code review and PR automation

Use Codex. Codex’s GitHub integration is currently deeper. For automated PR review workflows at scale, Codex wins.

Cost-conscious daily coding

Use OpenCode with Ollama. For developers who want AI assistance on a limited budget, OpenCode with local models provides real capability at zero API cost. For roughly 70% of daily coding work (explaining code, simple refactoring, adding documentation, writing straightforward functions), a good local model is genuinely sufficient.

Prompting Patterns That Work Across All Three

The tool matters less than how you use it. Three patterns consistently produce better results:

Give context, not just instructions

# Weak
"Fix the bug"

# Strong
"The /api/orders endpoint is returning 422 errors
for orders with more than 10 items. The error started
appearing after yesterday's database migration.
Find the cause and fix it without breaking existing
orders with fewer than 10 items."

Specify constraints explicitly

# Weak
"Add user authentication"

# Strong
"Add JWT authentication to the API.
Requirements:
- Use the existing User model in /src/models/user.js
- Tokens should expire after 24 hours
- Refresh tokens should last 30 days
- Do not install new libraries — use jsonwebtoken
  which is already in package.json
- Add middleware to /src/middleware/ directory
- Apply auth middleware to all routes except POST /auth/login
  and POST /auth/register
- Add tests in /tests/integration/"

Ask for a plan first on complex tasks

"Before making any changes, describe your plan for adding
multi-tenancy support to this application. What files will
you modify? What migrations are needed? What are the risks?

I will review and approve the plan before you start."

This saves you from discovering halfway through a large change that the agent took a wrong architectural direction.

⚠️ Common Mistakes to Avoid

  • Accepting every suggestion without reading it. AI coding agents generate bugs, security vulnerabilities, and solutions to the wrong problem, quickly. Read every change before committing. The judgment on whether something is correct and safe stays yours.
  • Using the expensive model for everything. Claude Opus 4.7 for “add a comment to this function” is wasteful. Configure model profiles in OpenCode. Use fast, cheap models for simple tasks.
  • Skipping CLAUDE.md. The single highest-leverage 10-minute investment you can make is documenting your project’s conventions in a file the AI reads every session. Every session without it costs you time re-explaining context.
  • Trusting AI with security-sensitive code without human review. Authentication, authorization, cryptography, payment processing: any code where a subtle bug has serious consequences needs human review regardless of how confident the agent sounds.
  • Not committing before large autonomous tasks. Before handing an agent a multi-file task, run git commit -am "before AI session". Five seconds of prep has saved hours of manual rollback.

⏱️ 30-Minute Setup Path

  1. Minutes 0–10: Install Claude Code (npm install -g @anthropic-ai/claude-code), open your project, run claude "explain how this codebase is structured".
  2. Minutes 10–20: Create your CLAUDE.md with tech stack, conventions, test commands, and directory structure. This file pays dividends every session.
  3. Minutes 20–30: Install OpenCode (npm install -g opencode-ai), configure your model profiles, test with a quick question.
  4. Add Codex when you need it: npm install -g @openai/codex. Reach for it the next time you have a scripting or DevOps task.
a computer screen with a bunch of code on it

The Verdict

Use Claude Code if you spend most of your time on complex, multi-file feature work and want deep architectural understanding of your codebase. You value transparency: knowing what the AI plans before it acts.

Use Codex if you do significant DevOps, scripting, and shell work. You are already paying for ChatGPT Plus and want coding agents without additional cost. You want GitHub PR review automation.

Use OpenCode if you work with sensitive code that cannot leave your machine. You want to control costs by mixing models. You want an open source tool you can audit and fork.

Use all three if you are a professional full-stack engineer who wants the right tool for each task type. The setup overhead is low. The combined value is higher than any single subscription.

These tools accelerate the work. The architecture decisions, security reviews, and correctness calls stay yours. That combination, speed from AI and judgment from experience, is what produces solid software in 2026.

Quick Reference Commands

# Claude Code
npm install -g @anthropic-ai/claude-code
claude
claude "your task here"
claude --help

# Codex
npm install -g @openai/codex
codex
codex "your task here"
codex --approval-mode suggest
codex --approval-mode auto-edit
codex --approval-mode full-auto

# OpenCode
npm install -g opencode-ai
opencode
opencode --profile fast "task"
opencode --profile private "task"
opencode --profile shell "task"

# Ollama (local models)
curl -fsSL https://ollama.ai/install.sh | sh
ollama pull codestral:22b
ollama pull llama3.1:8b
ollama serve
Stay on top of AI & Automation with BizStack Newsletter
BizStack  —  Entrepreneur’s Business Stack
Logo