Claude Code does not care where the model lives. Point it at a local model and it works with no network. I tested that at 35,000 feet, picked the wrong model first, and swapped mid-flight.
TL;DR
- Claude Code reads two environment variables to decide where its model lives. Point them at Ollama and it runs fully offline.
- I tested this on a real flight. Berlin, May 13, wifi off, cabin door closed.
- I started on
qwen2.5-coder:14b. It was too slow for anything agentic. One tool call sat for 25 seconds, the next for 52. - I switched to
gemma4:26b. That one carried the session. - Local is for offline work, privacy-sensitive code, and cheap drafting. Cloud is still better for heavy reasoning and large-context tasks.
- The install takes 20 minutes once. After that, switching models is one command.
The setup, in one paragraph
Ollama runs an open-weights model on your laptop. Claude Code points at Ollama instead of Anthropic's servers. No network call leaves the machine. The cloud account is irrelevant for that session. The only real decision is which local model you run, and that decision is where I got it wrong the first time.
Why offline beats "just use a smaller cloud model"
Before the setup, the three objections I get every time:
"Just don't code on a plane." A flight is six uninterrupted hours. No social media, no notifications, nothing that pulls focus. That is rare now. Throwing it away because your LLM needs wifi, when the wifi problem is fixable, is a planning failure.
"Just use Copilot offline." Copilot's local mode does completions. Anything context-heavy still hits the network. The moment you ask for the work that justifies an AI assistant, you are back online.
"Just use a smaller cloud model." Haiku and GPT-4o-mini still live in the cloud. Smaller is not local. No network, no inference. Same failure, smaller bill.
Local is the only setup that runs at 35,000 feet. It also runs on a train through a tunnel, in a cafe with broken wifi, and on the morning the OpenAI status page goes red. The flight is just the stress test.
What you need
- A Mac on Apple Silicon (M1 or newer). Linux and Windows via WSL2 work with minor changes.
- Claude Code installed and already authenticated against your cloud account.
- About 16 GB of unified memory. 32 GB if you want the larger models comfortable.
- Homebrew, for the Ollama install.
- 20 minutes the first time. Roughly 90 seconds every time after.
Step 1 — Pull the model before you fly
Install Ollama and pull a model:
brew install ollama
ollama pull qwen2.5-coder:14b
Do this on home wifi the night before. The pull is around 9 GB. Airport wifi and hotspots will not cooperate, and finding that out at the gate is its own small tragedy.
Confirm it landed:
ollama list
This was my mistake, so I will be blunt about it: I prepped qwen2.5-coder:14b because it is the model every "local LLM for coding" post recommends. Pull more than one. You will see why in Step 4.
Step 2 — Point Claude Code at Ollama
Start the Ollama server in one terminal:
ollama serve
Then in a new terminal, launch Claude Code against your local model:
ollama launch claude --model qwen2.5-coder:14b
Wrap that in two shell aliases so the rest of your workflow has named modes. Add these to ~/.zshrc:
alias claude-local='ollama launch claude --model gemma4:26b'
alias claude-cloud='claude'
Then source ~/.zshrc. That is the entire switching layer.
claude-local runs offline against Ollama. claude-cloud runs against the real Anthropic API. Two commands, one decision per session.
Step 3 — Verify on the ground
Prove the setup works in airplane mode before you board anything. This is non-negotiable. Discovering a missing step at altitude is bad theater with no exits.
- Make sure
ollama serveis running. - Turn wifi off. Actually off, not "disconnected from this network."
- Run
claude-localand point it at a real file. - Confirm a real answer comes back.
One tool call crunched for 25 seconds. An earlier step had sat at 52. For a single step in a loop that needs five or six of them, that is not a workflow. That is staring at a terminal while the person next to you finishes a movie.
qwen2.5-coder:14b is a fine model for single-shot edits. For the multi-step tool loop that Claude Code actually runs, on this hardware, it could not keep up. The model every post recommends was the wrong call for the job I had.
Step 5 — The swap: gemma4:26b carried the session
I had pulled a second model before the flight, exactly because I did not fully trust the first one. So I switched to gemma4:26b.
Honest scorecard for the flight: roughly 70 percent of my normal Claude Code workflow worked on gemma4:26b. The 30 percent that did not was the heavy "go reason across the whole repo" pattern, which is cloud territory anyway. For six hours of focus on a known task, it was a real working setup, not a downgrade.
Because I already had a tight context-engineering setup with optimised token consumption, it ran smoothly. The Mac started lagging briefly when I had Xcode and Antigravity open alongside, but closing those and cleaning up Chrome tabs sorted it. If you want the context-engineering side, the U-AMOS write-up is here: .
Which local model should you actually run?
The lesson from the flight changed my default. Here is the short list I keep now:
AI Pro tier, so you are not assembling this from scratch.
I packaged the rest of this into the Local LLM with Claude Code bundle: the paste-ready zshrc aliases plus a claude-status helper, the Ollama config tuned for Apple Silicon, the model-picker matrix, and a pre-flight checklist so the setup is never a surprise at altitude. Reply to the , .
SOCIAL SHARE CARD GENERATOR