Home › Guides › Claude Code with a local model

Claude Code for free: running it on a local model, and how it compares

I pay for Claude Code every month, and the Max plan costs $200. So I wondered: can a free model running on my own Mac do the same job? No subscription, no internet, nothing sent anywhere. I spent a whole day finding out, broke it three times along the way, and then put it head to head with the real Claude on six coding tasks.

The setup: Ollama and a model that fits

Ollama is free and runs open-weights models locally. Pull a model once and Claude Code can talk to it instead of Anthropic. The catch on a Mac is memory: the graphics chip can only use about two thirds of your RAM. On 24 GB that is roughly 18 GB, and the context needs memory on top of the model, so the newest big models do not really fit. A model that does not fit spills onto the CPU and crawls.

Your RAMModelDownloadTested?
16 GBornith:9b5.6 GBRan on 24 GB, see results
24-32 GBgpt-oss:20b14 GBYes - best local result
48 GB+qwen3.8:27b18 GBNot tested

Three traps that break it

1. The context window

Ollama even has an official command for this, ollama launch claude. I tried it on a failing test suite and asked it to fix the bug. The answer had nothing to do with my task. Ollama sizes the default context by your memory, and on my Mac that was 4,096 tokens - while Claude Code sends about 10,000 tokens of instructions and tool definitions before your task even starts. The model loses the plot, and the worst part: Claude Code still reports the run as completed, no error. The fix is a copy of the model with a 64k context.

2. Claude Code assumes 200k tokens

It does not know a local model, so it assumes it can remember 200,000 tokens and never compacts the conversation in time. You have to tell it the real window.

3. Auto mode and the billing notice

In auto mode every action gets an extra check by a classifier model. On a local model that is an extra slow call each time, and halfway through a task a billing notice popped up and blocked everything - even though nothing is billed at all.

The fix: one command

I wrapped all three fixes into cc-local. It starts Ollama, picks a model for your RAM, makes the 64k copy, tells Claude Code the real window, routes every model slot (main, background, sub-agents) to the local model so nothing goes to Anthropic, and starts in accept-edits mode. Your normal claude command stays untouched.

cc-local --doctor     # checks your machine for every trap above
cc-local              # Claude Code on the local model, in the current folder

The doctor check tests it end to end on your own Mac: context window, whether the model fits the GPU, speed in tokens per second, and a real Claude Code request that proves only the local model was used. On my M5 Pro, gpt-oss:20b ran at about 66 tokens per second, 100% on the GPU.

The benchmark: local vs the real Claude

One task proves nothing, so I built a small benchmark: six tasks - four everyday ones (fix a bug, add a feature, build a CLI, build a Snake game) and two hard ones (a strict spec with lots of rules, and a bug from a vague user report). Every result is checked by hidden tests the model never sees, and every task runs three times, because local models can get lucky once.

Results table: Claude 18 of 18 in 5 minutes, gpt-oss 20b 14 of 18 in 41 minutes, ornith 9b 11 of 18 in 93 minutes, across six tasks run three times each.
Six tasks, three runs each, on an M5 Pro with 24 GB. Cell = passes out of 3.
TaskClaude (cloud)gpt-oss:20bornith:9b
Fix a bug3/3 · 9 s3/3 · 48 s3/3 · 52 s
Add a feature3/3 · 16 s3/3 · 115 s3/3 · 74 s
Build a CLI3/3 · 15 s3/3 · 45 s3/3 · 7.6 min
Build a Snake game3/3 · 21 s0/30/3
Follow a strict spec3/3 · 24 s2/3 · 195 s0/3
Bug from a user report3/3 · 13 s3/3 · 148 s2/3 · 60 s
Total18/18 · 5 min14/18 · 41 min11/18 · 93 min

The way they fail is interesting. gpt-oss sometimes wrote the whole Snake game into the chat and never saved the file. The small ornith model often did the work and then kept going - over 100 steps - until Claude Code stopped with "prompt is too long".

Three Snake games from the same prompt: Claude's polished version with a score, ornith 9b's working version, and gpt-oss 20b's version which ends at game over.
Same prompt, three Snake games. gpt-oss's one saved game looks fine, but its "no reversing" check also blocks every 90-degree turn, so the snake drives straight into the wall. My automatic check missed that, so I play-tested every game.

So, is free good enough?

For small, clear tasks, for private code that cannot leave your machine, or for working offline, a local model is honestly enough, and it costs nothing. When the task is vague, has lots of rules, or you need it right the first time, you pay for Claude. And time matters too: five minutes against forty-one.

On Patreon · $9 one-off

cc-local and the full benchmark

Run Claude Code on your own machine with all three fixes, and test any model yourself before you trust it.

  • cc-local - Claude Code on a local Ollama model, with the context, routing and permission fixes.
  • cc-local --doctor - tests your own Mac for every trap and tells you exactly what to fix.
  • cc-bench - the 6 tasks with the hidden checks; add your own tasks and compare any model with the real Claude.
  • The README with model picks per RAM size and my full results.
Get it on Patreon →

Patreon members ($5/month) get it with all my other tools, or buy just this one for $9.

Honest limitations

Watch the video

The three traps on screen, the fix, and every result, including the Snake games.

FAQ

Can you use Claude Code for free?

Claude Code itself is free to install. With Ollama and an open-weights model it runs entirely on your own computer, with no subscription or API key - after fixing the context window and two other settings.

Is a local model as good as Claude?

Not quite. In my 6-task benchmark Claude scored 18/18 in 5 minutes, gpt-oss:20b 14/18 in 41 minutes and ornith:9b 11/18 in 93 minutes. Simple, clear tasks were fine; vague and rule-heavy ones were not.

Which local model should I use with Claude Code?

On a 24-32 GB Mac, gpt-oss:20b had the best local result. On 16 GB, ornith:9b fits. The model has to fit the GPU (about two thirds of a Mac's RAM), or it becomes very slow.

Why does Claude Code give a random answer on Ollama?

Usually the context window: Ollama's default on a 24 GB Mac was 4,096 tokens, while Claude Code sends about 10,000 tokens before your task. Give the model a 64k context.

Related

Want AI tooling that stays on your own machines?

Private code, offline work or a team that cannot send anything to the cloud: setting up local models and tooling that actually works is the kind of thing I do at KorFlux.