Picture the usual setup. You read a leaderboard, download the top open model that fits your GPU, and wire it into your editor for tab completion.
Every suggestion takes four seconds. Half of them start with "Sure! Here's the code you asked for."
So you switch it to agent mode instead, and it confidently edits six files to fix a bug that lived in one.
Nothing was wrong with the model. It was the wrong model for both jobs.
"Best local LLM for coding" isn't one answer. It's at least four, and the right one depends on what you're asking the model to do.
The short version: pick by task first, hardware second. For tab completion you need a small model trained on fill-in-the-middle with thinking off; Continue recommends Qwen 2.5 Coder 1.5B or 7B locally. For repository edits and agent work you need a larger model with reliable tool calls and at least 64K of context. Then check what fits your VRAM (our 12GB VRAM coding guide is a good start), and test on your own repo before you trust any leaderboard.
The best local LLM for coding starts with your task, not a leaderboard

Here's how the four jobs differ:
| Task | What the model must do | What matters most | Evidence that actually tells you something |
|---|---|---|---|
| Tab completion | Fill the gap between the code before and after your cursor | Latency and a fill-in-the-middle (FIM) format | Time to first suggestion; acceptance rate in your own editor |
| Small edits and chat | Rewrite a function, explain an error, write a test | Instruction following, short answers | Pass rate on small, checkable tasks |
| Repository edits and review | Change several files consistently; spot real bugs | Context length, diff discipline | Tests passing after the change; reviewer agreement |
| Agent work | Plan, call tools, run commands, iterate | Tool-call reliability, long context | Task success on a real repo across several attempts |
Completion and agentic coding need different evidence
This is where most people get it wrong. A benchmark like SWE-bench Verified measures whether a model can resolve a GitHub issue end to end. That says nothing about whether it can finish your line in 200 milliseconds.
The reverse is also true. A model that's brilliant at completion may never have been trained to call tools at all.
And if you're not yet sure local is right for you at all, our guide on how to choose an LLM for your task compares local and hosted by cost, speed and privacy.
The public leaderboards have also aged. Aider's polyglot leaderboard, one of the few that ran open models through the same test setup, was last updated on 20 November 2025.
It scores 225 Exercism exercises across C++, Go, Java, JavaScript, Python and Rust. Most newer local-model scores are self-reported by vendors on their own scaffolds, which makes them hard to compare.
Our test protocol and what it cannot prove
We don't trust a coding model until we've run it on code we know. Here's the protocol behind every result we publish.
The test pack:
- A public repository pinned to one commit, so anyone can check out the same code.
- A fixed set of tasks in each category: completions, small edits, multi-file changes, review prompts and agent tasks.
- Pass criteria decided in advance, usually "the existing tests pass and the new test passes."
- Several attempts per task, because local models vary run to run.
- A log for every run: model and quantisation, runner and version, hardware, settings, pass and attempt counts, latency and peak memory.
What it can't prove:
- That a model is best for your codebase. A small task set is a signal, not a verdict.
- That results carry across hardware. Speed and memory change with the GPU, the runner and the quantisation.
- That the model hasn't seen similar code in training. Public repos can leak into training data.
- That today's result holds after the next model or runner update.
Make the test pack reproducible

If someone can't rerun your test, it's an anecdote. So we publish the repository commit, the task list, the exact prompts, the runner configuration and the raw log alongside the results. Each result in our table links to its log.
Choose a shortlist for completion and small edits
For tab completion, the rule is simple: use a model trained for fill-in-the-middle, and keep it small.
Continue, an open-source editor extension that supports local models, explains why. Its docs say the recommended autocomplete models "are trained with a highly specific prompt format," and that some of the best commercial chat models aren't, so they don't produce useful completions. For local use, Continue recommends Qwen 2.5 Coder in its 1.5B and 7B sizes.
Here's the weird part. Bigger doesn't help much here. Continue notes that most state-of-the-art autocomplete models are no more than 10B parameters.
ollama pull qwen2.5-coder:1.5b
Prefer a desktop app to the command line? Our Ollama vs LM Studio guide compares the two for local coding.
For small edits and chat in VS Code, you can run a second, larger instruction model alongside the completion model. Continue lets you assign different models to different roles in the same config.
When latency matters more than a longer answer
Tab completion lives or dies on speed. If a suggestion arrives after you've typed the next word, it's noise.
So switch thinking off. Continue's docs warn that "thinking-type models are not recommended as they generate more slowly," and show how to send think: false for models that can toggle it. If you're on a Mac, try an MLX build of your completion model and compare latency against the GGUF version.
Compare repository edits, review and agent tools
This is where model size starts to matter. Multi-file edits and agent loops need long context, steady instruction following and tool calls that don't break.
Our runner guide puts the floor at 64K tokens of context for coding agents, and notes that tool-call reliability depends more on the model than on the runner.
Here are the candidates we test first for this tier. The scores are vendor-reported on the vendor's own scaffold, not our tests:
| Candidate | Size | Vendor-reported coding scores | Source |
|---|---|---|---|
| Qwen 3.6 27B | 27B, 262K native context | SWE-bench Verified 77.2; Terminal-Bench 2.0 59.3; LiveCodeBench v6 83.9 | Qwen model card |
| Qwen 3.6 35B-A3B | 35B total, 3B active, 262K native context | SWE-bench Verified 73.4; Terminal-Bench 2.0 51.5; LiveCodeBench v6 80.4 | Qwen model card |
| Gemma 4 12B | 11.95B, 256K context | LiveCodeBench v6 72.0% (no SWE-bench score published) | Google model card |
Qwen notes its SWE-bench numbers use an internal agent scaffold with bash and file-edit tools and a 200K context window.
Your agent, your context limit and your quantisation will all move the result. Wondering whether a 27B model fits your card? Our 16GB VRAM and 32GB RAM guide covers the quantisations.
Wiring a local model into a coding agent
People search for "local LLM for Claude Code" and "local LLM with OpenCode" a lot. Both work through a local server.
Ollama has the shortest path. Since v0.15, ollama launch claude, ollama launch opencode or ollama launch codex picks a model and starts the agent with no config files; LM Studio and llama.cpp work too, but you point the agent at the port yourself. The Ollama vs LM Studio guide linked above covers each setup.
Whichever agent you use, set the context to at least 64K. A model with a short window will run out of room halfway through a multi-file change.
Read the diff before trusting the result
Stay with me here, because this is the habit that matters most. A local model can produce a change that passes the tests and still be wrong. It might delete a check, widen a type or edit a file it didn't need to touch.
So for repository edits, review the diff the way you'd review a junior developer's pull request. For code review tasks, judge the model on whether it found real problems, not on how many comments it wrote.
Check hardware fit in the dedicated guides

We keep hardware fit in separate guides, because the answer changes with every gigabyte:
- 12 GB cards: our 12GB VRAM coding guide (linked above) covers what fits, from Gemma 4 12B to mixture-of-experts models that spill into system RAM.
- 16 GB cards with 32 GB of RAM: our 16GB guide (linked above) covers the 27B-class plan and MoE options.
- 8 GB and 24 GB: the same rules apply. Fit the weights plus your context in VRAM, and test before you buy.
Separate model choice from runner choice
Choose the model for the task first. Then choose how to run it: Ollama, LM Studio, llama.cpp or MLX on a Mac. The runner affects speed, setup and API compatibility, but it doesn't make a weak model good at agent work.
When a local LLM for coding is the wrong trade-off
Local coding models are great for privacy, offline work and fast completions. They're a harder sell for three jobs.
Large repositories need long context, and long context needs memory. A model that fits comfortably at 8K may not fit at 64K.
Long agent loops punish small mistakes. A model that's right 90% of the time on each step fails often over a 20-step task.
And your time costs something. If you're spending evenings tuning quantisations to get an agent to finish a task a hosted model would finish in minutes, that's a cost too.
A common split is to keep completion local and send hard agent work to a hosted model. If you'd like BetterClaw agents to use a model on your own Mac, BetterClaw Desktop shares models from Ollama, LM Studio or llama.cpp with your agents; our local models docs explain the setup and requirements.
The best local LLM for coding is the one you've tested yourself
Here's the honest takeaway.
Leaderboards are a starting point, not an answer. They test someone else's tasks, on someone else's setup, at someone else's quantisation. Your repository is the only benchmark that predicts how a model will behave on your repository.
So build a small test pack, run your shortlist through it, and keep the log. It takes an afternoon. It saves weeks of working with the wrong model.
If you'd rather run agents without managing any of this, start free with BetterClaw.
The free plan includes 100 credits a month, and you bring your own model key, hosted or local, so you still pay your provider for hosted inference (see full pricing). We handle the infrastructure. You handle the interesting part.
Frequently Asked Questions
What is the best local LLM for coding?
It depends on the task. For tab completion, use a small fill-in-the-middle model such as Qwen 2.5 Coder 1.5B or 7B with thinking off. For repository edits and agent work, use a larger model with reliable tool calls and 64K or more of context, then test it on your own code before trusting a leaderboard.
How does a local coding LLM compare to a hosted model?
Local models win on privacy, offline use and fast completions. Hosted models still tend to finish more long, multi-step agent tasks on large repositories. Many developers keep completion local and send hard agent work to a hosted model.
How do I use a local LLM with Claude Code or OpenCode?
The shortest route is Ollama v0.15 or newer: ollama launch claude or ollama launch opencode picks a model and starts the agent with no config files. LM Studio and llama.cpp work too, but you point the agent at the local port yourself. Set the context to at least 64K.
Is a local LLM for coding worth it?
For completion and small edits, usually yes: a 1.5B completion model runs on modest hardware and costs nothing per token. For agent work, factor in the GPU you need for 27B-class models and the time you'll spend tuning. If that's more than a hosted model costs you, local isn't the saving it looks like.
Is a local coding model reliable enough for agent work?
Only after you've tested it on your own repository. Even a change that passes the tests can delete a check or touch files it shouldn't, so read every diff before you merge. Vendor scores such as SWE-bench come from the vendor's own setup, not yours.




