Last verified

Can you run Claude Code locally?

Half.
Client runs local · model never does

The agent runs on your machine; the model doesn't. Everything you can see locally — reading files, editing, executing commands — is local already. The reasoning is a call to a hosted model on every turn, and there is no local-model mode. We proved the dependency by pointing the CLI at an unreachable endpoint: it retried for about three minutes, then failed outright.

The client is local — file access, edits and commands run on your box No local-model mode — nothing ships that can answer a prompt alone Gateways don't count — routing elsewhere still needs a reachable server Measured — unreachable endpoint = ~3 min of retries, then exit 1 Fully local agents exist — Aider or Cline against your own model
§ 01 / PROOF

We actually ran it.

Methodology →
TEST RUN · AUG 01, 2026 · 3 RUNS

Cut off the model and the agent has nothing left to think with.

The test that settles it: we set ANTHROPIC_BASE_URL to a port with nothing listening, leaving everything else local and intact, then sent an ordinary prompt. Three consecutive runs took 172.5, 187.2 and 185.4 seconds of retries before exiting with status 1 and API Error: Unable to connect to API (ConnectionRefused). The local half — binary, file access, shell — was never the problem.

The same session showed the split cleanly: with the endpoint still unreachable, claude --version answered in 247 ms. Local commands are genuinely local. It's the thinking that lives elsewhere.

People usually ask this hoping for an Ollama-style setup. Anthropic documents routing through an LLM gateway, Amazon Bedrock, Google Cloud's Agent Platform or Microsoft Foundry — all of which move where the model runs, none of which put it on your laptop. A gateway on your own LAN is the closest you get, and even then you're serving Claude models from a server, not running one locally.

Local commands: work — 247 msPrompt, no endpoint: fails after ~3 minRuns: 172.5 / 187.2 / 185.4 sLocal-model mode: noneCLI version: 2.1.170
$ export ANTHROPIC_BASE_URL=http://127.0.0.1:9
$ claude --version
2.1.170 (Claude Code)
→ 247 ms — the local half is fine
$ claude -p "reply with the single word: pong"
API Error: Unable to connect to API
(ConnectionRefused)
→ exit 1 after 172.5 s
$
§ 02 / WHY

Why the model can't come to you.

2.1
The split, precisely

Claude Code is a thin client over a hosted model. The agent loop — deciding to open a file, running your test command, applying a diff — executes locally and quickly. Each decision inside that loop is a request to a model that Anthropic hosts.

That's why offline doesn't work and why this question has a two-part answer instead of a yes or no.

2.2
What ANTHROPIC_BASE_URL does and doesn't buy you

The variable is real and documented — it points the client at an LLM gateway instead of Anthropic's endpoint, which is how organisations route traffic through their own infrastructure. The proxy setups circulating online use the same hook to point it at entirely different models.

Two things follow. First, that's not "running locally" unless the gateway itself is on your machine, and then you're running the gateway's model, not Claude. Second, if you do point it at a non-Anthropic model, the answers you get are that model's — a distinction the "free Claude Code" videos tend to skip.

2.3
When local is a hard requirement

Air-gapped networks, regulated code that can't leave your infrastructure, or simply a policy against sending source to third parties — in those cases no amount of configuration makes this tool fit, and the honest answer is to use a different one.

The realistic local setup is an open-source agent plus a model you host. Quality tracks the model your hardware can run, which is the trade you're making.

→ GENUINELY LOCAL

Agents that run entirely on your machine.

Both are open source and speak to a locally hosted model, so no code and no prompt leaves your hardware. We have not benchmarked either against Claude Code — test on your own repository first.

Frequently asked.

Quick follow-ups people search after this question.

Q · 01 Can I point Claude Code at Ollama? +
Mechanically you can set ANTHROPIC_BASE_URL at a compatible local endpoint, and people do. What you get then is the Claude Code client driving a different model — useful, but it is no longer Claude answering, and quality follows whatever you're hosting.
Q · 02 Does any part of it run without the internet? +
Yes — the binary, file access and shell commands. claude --version answered in 247 ms with the API unreachable. Only prompts fail, which is unfortunately the part you opened it for.
Q · 03 Is Bedrock or Vertex a local option? +
No. They move the model into your cloud account, which helps with compliance and data residency, but it's still a network service you call. Local means on your machine, and none of these routes achieve that.
Q · 04 What's the closest thing to a local Claude Code? +
An open-source agent with a self-hosted model — Aider or Cline against Ollama or LM Studio. You keep the agentic workflow and lose the frontier model, which is the whole trade.