(Run it locally with open-source models — no Anthropic API spend)

By Basant

Published: 2026-01-22

URL: https://theautomator.substack.com/p/claude-code-just-got-a-free-mode


You can now run Claude Code using open-source models on your own machine by pointing it to an Anthropic-compatible endpoint like Ollama. You keep the Claude Code CLI experience (repo awareness, diffs, agentic flow) while avoiding Anthropic API costs and keeping your code local.

Thanks for reading The Systems Notebook! Subscribe for free to receive new posts and support my work.


Why this matters (quick context)

Claude Code is one of the best agentic coding CLIs right now. But until recently, it was tightly coupled to Anthropic’s paid API.

What changed is simple but important:

  • Ollama added compatibility with the Anthropic Messages API
  • Claude Code already speaks that API
  • Result: Claude Code can talk to local open-weight models

No hacks. No forks. Just configuration.

This unlocks:

  • Zero API cost for experimentation
  • Local-only code execution
  • Private repos without cloud leakage
  • A realistic path to self-hosted AI dev tooling


What you need (minimal)

  • macOS / Linux (Windows via WSL works)
  • 16 GB RAM recommended (CPU is fine to start)
  • Git installed
  • 10 minutes

Step 1 — Install Ollama (local LLM runtime)

Ollama runs models locally and exposes a simple HTTP API.

curl -fsSL https://ollama.com/install.sh | sh

Start the server:

ollama serve

By default it runs at:

http://localhost:11434

Step 2 — Pull a small model (fast to test)

Start with something lightweight so the first run is smooth.

ollama pull llama3.2

This downloads the model once and stores it locally.

You can list installed models anytime:

ollama list

Step 3 — Install Claude Code

Claude Code is Anthropic’s official coding CLI.

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

Verify:

claude --version

Step 4 — Point Claude Code to Ollama (this is the key)

Claude Code uses environment variables. We override Anthropic’s API endpoint.

export ANTHROPIC_BASE_URL="http://localhost:11434/api" export ANTHROPIC_API_KEY=""

Why this works:

  • Ollama exposes an Anthropic-compatible /messages endpoint
  • Claude Code doesn’t require a key if the backend doesn’t

Step 5 — Test locally in a real repo (2-minute test)

Create a tiny test repo:

mkdir claude-free-test && cd claude-free-test git init echo "console.log('hello');" > index.js git add . git commit -m "initial commit"

Start Claude Code:

claude code

Now type:

Add a README explaining what this project does

If everything is wired correctly, Claude Code will:

  • Read your repo
  • Create a README.md
  • Show a diff
  • Ask before applying changes

🎉 Congratulations ! You are running Claude Code without Anthropic.


Current limitations (important to know)

Be aware of these trade-offs:

  • Some open models don’t fully support tool-use
  • You may see errors when Claude Code tries to run shell commands
  • Quality depends on the model
  • Smaller models reason less deeply than Claude Opus / Sonnet
  • Performance is hardware-bound
  • Bigger models need GPU or patience

This is not a drop-in replacement for production-grade Claude — but it is a powerful local alternative.

Thanks for reading The Systems Notebook! This post is public so feel free to share it.