Best Local LLMs for Claude Code
Anthropic's terminal coding agent, driven by a local model
Claude Code is Anthropic's agentic terminal coder, and out of the box it talks only to Anthropic's API. But its Messages API can be translated by a local proxy (LiteLLM) onto any OpenAI-compatible server, and the fully open-source Open Claude Code reimplementation exposes an OpenAI-compatible base URL directly. That is how the "Claude Code locally" guides actually run: an open-weight model with reliable structured tool-calling, doing the same 25-tool agentic loop without any code leaving your machine. This page ranks the local models that hold up in Claude Code's tool-call-heavy loop, where tool-calling reliability comes first.
- Best pick
- Qwen3.6 35B-A3BAgent-tuned MoE with the strongest open-weight tool-calling here; 100K+ context, runs on a 24GB Mac.
- What Claude Code needs
- Claude Code chains many tool calls over a long, growing context, so it rewards models with strong agentic tool use and ample context. Tool-calling reliability is the first filter: models that drop or mangle tool_calls break the loop no matter how good their prose is.
Claude Code local LLM tier list
11 models| Model | Size | RAM | Why | Run |
|---|---|---|---|---|
| Qwen3.6 35B-A3B | 35B | 32GB | Agent-tuned MoE with the strongest open-weight tool-calling here; 100K+ context, runs on a 24GB Mac. | |
| Qwen3.5 35B-A3B Instruct | 35B | 32GB | The model leading "Claude Code locally" guides actually deploy; disables internal CoT so Claude Code drives reasoning. |
| Model | Size | RAM | Why | Run |
|---|---|---|---|---|
| Qwen2.5 Coder 14B | 14B | 16GB | Trained for tool use; the most dependable mid-size coding workhorse for agent CLIs. | |
| Gemma 4 31B | 31B | 32GB | Low tool-call error rates in agentic testing; run with thinking off. | |
| LFM2 24B-A2B Instruct | 24B | 24GB | Liquid's tool-dispatch MoE, built for on-device agents, fits ~14.5GB. |
| Model | Size | RAM | Why | Run |
|---|---|---|---|---|
| Qwen3 30B | 30B | 32GB | Capable agentic MoE; reliable tool calls but a generation behind the 3.5/3.6 agent models. | |
| Qwen2.5 Coder 7B | 7B | 8GB | Solid 8GB fallback with real tool-use training; weaker on long multi-step chains. | |
| Mistral Small 22B | 22B | 32GB | Decent function calling, fits ~32GB Macs, but long tool sequences can hit format errors. |
| Model | Size | RAM | Why | Run |
|---|---|---|---|---|
| DeepSeek-R1 Distill Qwen 14B | 14B | 16GB | Strong reasoning, but R1 distills drop tool calls into content instead of the tool_calls array. | |
| Phi-4 14B | 14B | 24GB | Lacks proper tool-calling; fine as a chat model, unreliable as an agent. | |
| Qwen3.5 4B Instruct | 4B | 6GB | Agent-tuned but too small to stay coherent across long Claude Code loops. |
Tiers weigh tool-calling reliability, context window, and coding quality for Claude Code specifically. A model can rank higher for one tool than another. RAM figures are for Q4 quantization. Sources are listed below.
Local setup notes
Run a local OpenAI-compatible server (Ollama, llama.cpp, or LM Studio), then either point the official Claude Code at it through a LiteLLM proxy that translates the Messages API, or use the open-source Open Claude Code fork and set its OPENAI_BASE_URL to your server (e.g. http://localhost:11434/v1) with any dummy API key. Raise the context window to 32K+ for the agentic loop, and disable internal chain-of-thought on Qwen3.x models so the agent drives the reasoning.
Get told when a better model fits your MacBook Air M5 16 GB
Get one email when a new open-weight model is a better fit for this machine.
For: MacBook Air M5 16 GB
You'll also get the weekly ModelFit email. By signing up you agree to our Privacy Policy. Unsubscribe from either email anytime, in one click.
Frequently asked questions
Which local model is best for Claude Code?
Can Claude Code run on a local model?
How much RAM does Claude Code need for local models?
Sources
- Claude Code: official docs (Anthropic API only out of the box)
- Open Claude Code: open-source reimplementation with configurable OPENAI_BASE_URL
- Configurable OPENAI_BASE_URL / ANTHROPIC_BASE_URL (env config, undocumented in the README)
- Per-model agentic tool-calling results (shared Claude Code loop)
- DeepSeek-R1 distills drop tool calls into content
- ModelFit: Claude Code on local LLMs, complete setup guide
- ModelFit: Run Claude Code free with Ollama, 4 steps
Other AI coding tools
- OpenCodeOpen-source terminal coding agent (Ollama / OpenAI-compatible)CLI agent
- OpenClawSelf-hosted agentic assistant with first-class Ollama supportSelf-hosted agent
- AiderTerminal AI pair-programmer with its own edit-format leaderboardTerminal pair-programmer
- ClineAutonomous coding agent for VS Code (formerly Claude Dev)IDE extension
- Roo CodeAutonomous VS Code agent with modes (a Cline fork)IDE extension
- Continue.devOpen-source chat, edit & autocomplete for VS Code / JetBrainsIDE extension
- GooseBlock's open-source autonomous developer agent (MCP-driven)CLI agent
- Open Claude CodeOpen-source Claude Code CLI reimplementation, with an undocumented endpoint override for local modelsCLI agent
- CodexOpenAI's coding agent, driven by a local model via its built-in Ollama providerCLI agent