Can you run Claude Code locally?
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.
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.
Why the model can't come to you.
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.
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.
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.
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? +
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? +
claude --version answered in 247 ms with the API unreachable. Only prompts fail, which is unfortunately the part you opened it for.