All guides
MASTER CLASS · OPENCODE · INTERMEDIATE

OpenCode: the open-source Claude Code alternative.

OpenCode is a fully open-source agentic coding terminal — same workflow as Claude Code, runs against any model (Claude, GPT-5, local Llama, Hermes). Bring your own provider, no vendor lock-in.

▸ When you're done

OpenCode installed and configured against the model of your choice. You can switch between Claude, GPT-5, and a local model with one config flip.

18 min walkthrough
3 tools · all free tier
Copy-paste ready · no theory
The stack
◢ The build · 5 steps · 18 min

Follow these in order. Don't skip.

Step 01 / 05

Why OpenCode (and when to pick it over Claude Code)

  • Open-source — you can read every line, fork it, run it air-gapped
  • Provider-agnostic — Anthropic, OpenAI, Groq, Together, Ollama (local), all from one config
  • Same TUI vibe as Claude Code — slash commands, plan/execute mode, MCP support
  • Pick OpenCode when: you need on-prem, you want to A/B providers, you want to run a local model on a laptop with no API
  • Stick with Claude Code when: you're shipping fast and don't care about the abstraction layer
Step 02 / 05

Install OpenCode

Terminal
1# macOS / Linux — official installer
2curl -fsSL https://opencode.ai/install | bash
3
4# Or via npm
5npm install -g opencode-ai
6
7# Verify
8opencode --version
Step 03 / 05

Configure your provider — Anthropic, OpenAI, or local

~/.config/opencode/opencode.json
1{
2 "$schema": "https://opencode.ai/config.json",
3 "model": "anthropic/claude-sonnet-4-6",
4 "provider": {
5 "anthropic": {
6 "options": { "apiKey": "sk-ant-..." }
7 },
8 "openai": {
9 "options": { "apiKey": "sk-..." }
10 },
11 "ollama": {
12 "options": { "baseURL": "http://localhost:11434/v1" }
13 }
14 },
15 "permissions": {
16 "edit": "ask",
17 "bash": {
18 "git status": "allow",
19 "git diff *": "allow",
20 "npm run *": "allow",
21 "rm -rf *": "deny",
22 "*": "ask"
23 }
24 }
25}
Heads up
Switch models inline: opencode --model openai/gpt-5 — same session, different brain. Useful for A/B testing reliability across providers.
Step 04 / 05

Run a local model with Ollama

The whole point of OpenCode: $0 inference once you're on a local model.

Terminal
1# Install Ollama
2brew install ollama
3
4# Pull a coding-tuned model
5ollama pull qwen2.5-coder:32b
6
7# Or NousResearch's Hermes (agentic-tuned)
8ollama pull nous-hermes-2:34b
9
10# Start the Ollama server
11ollama serve
12
13# Now point OpenCode at it
14opencode --model "ollama/qwen2.5-coder:32b"
Watch out
Local models are 80% as good as Sonnet on routine code tasks and 30% as good on complex refactors. Use them for boilerplate. Use Claude/GPT-5 for the hard stuff.
Step 05 / 05

AGENTS.md works in OpenCode too

Same convention as Codex CLI — drop an AGENTS.md at your repo root. OpenCode reads it on every session. The format is identical, so a single file works for Codex AND OpenCode.

Ship-it checklist
6 CHECKS
  • OpenCode installed
  • At least one provider configured (Anthropic OR OpenAI)
  • Optional: Ollama + a local model wired in for free inference
  • Permissions config tuned (read-only auto-allow, destructive deny)
  • AGENTS.md at your repo root
  • You ran the same task on two providers and compared outputs