Open Weight Thoughts
All articles

· 7 min read

How to Build a Fully Local AI Coding Setup With Cline

By X. Martínez

  • guides

Yes: you can run Cline as a genuinely local coding agent by pointing it at Ollama on localhost, with a local code model and no cloud-model API key. The practical setup is Cline in VS Code, Ollama as the local model server, and Qwen3-Coder 30B as the default model—provided your machine has enough memory to run it without turning every edit into a coffee break.

Decide what “fully local” means before you install anything

For this setup, inference happens on your machine: your prompts, repository context, model responses, and tool calls go from Cline to a server on localhost. That removes per-request costs and keeps source code out of a model provider’s inference API.

It doesn’t mean you never touch the internet. You’ll initially download the Cline extension, Ollama, and model weights. VS Code extensions may also check for updates or send telemetry depending on your settings. If you need an air-gapped environment, download and verify those artifacts elsewhere, transfer them in, disable updates and telemetry, then test with networking disabled. “Local inference” is an architecture; “air-gapped” is an operational policy.

Also, local does not mean harmless. Cline can read files and propose terminal commands. A model running privately can still delete the wrong directory, expose a secret through a pasted command, or make a confident but bad migration. Keep approvals on, work in a Git repository, and treat the agent as a fast junior collaborator with a shell—not as an unattended deployment system.

Start with hardware you can actually use

The sensible baseline is 32GB of system or unified memory and roughly 20GB of free disk for the default 4-bit Qwen3-Coder 30B package. Cline’s local-model guidance recommends that 4-bit setup as the entry point at 32GB RAM; 64GB gives you more breathing room for an 8-bit version, larger contexts, the IDE, browsers, containers, and the actual project you’re building.

A dedicated GPU improves tokens per second, but it isn’t mandatory. Apple Silicon machines with sufficient unified memory are viable, as are Linux or Windows PCs where Ollama can use an appropriate GPU backend. CPU-only inference works too, but it’s easiest to tolerate for bounded tasks: explain this module, add a test, repair this failing function. It becomes frustrating when an agent repeatedly scans a large repository and runs long commands.

Don’t confuse a model’s advertised native context window with what you should allocate on day one. Large context consumes memory through the KV cache. Begin at 32K or 64K context, confirm the agent is stable, then raise it only if your real tasks need it. A smaller, responsive context is more useful than a huge one that swaps memory and makes Cline look broken.

Install the local runtime and prove it works first

Install Ollama for your operating system, then pull and run the coding model from a terminal. qwen3-coder:30b is a useful default because it is a coding-oriented, tool-capable model, and its standard local Ollama build is about 19GB.

ollama pull qwen3-coder:30b
ollama run qwen3-coder:30b

Ask it a boring but concrete question—such as “Write a TypeScript function that parses a semantic version string”—and wait for a response. This removes a whole class of troubleshooting later: if the model cannot run interactively, Cline is not the thing to debug yet.

Ollama normally exposes its local API at http://localhost:11434/api. There is no authentication requirement for that loopback endpoint. Keep it on loopback unless you have a deliberate reason to serve another machine: exposing a local model server on your LAN changes the security problem substantially.

Next, create a named Ollama model with a context window that matches your machine. Make a file named Modelfile in an empty directory:

FROM qwen3-coder:30b
PARAMETER num_ctx 65536

Then build it and check that Ollama can launch it:

ollama create cline-qwen -f Modelfile
ollama run cline-qwen

This small indirection is worth it. Rather than remembering which runtime flag you used six weeks ago, Cline can always target cline-qwen. If RAM pressure, slowdowns, or incomplete responses appear, reduce num_ctx to 32768, recreate the model, and try again.

Connect Cline to Ollama, not an OpenAI-compatible workaround

Install the Cline extension in VS Code, open its panel, and open Cline Settings. Set the API provider to Ollama, choose cline-qwen from the model list, and leave the endpoint as the local Ollama server if Cline has detected it. This provider path needs no API key; Cline talks directly to your running Ollama instance.

Enable Cline’s Use Compact Prompt setting. Agentic coding involves a lot of scaffolding: tool instructions, file context, command outputs, and the ongoing task. Compact prompts reduce that overhead, leaving a modest local context window for the code and evidence that actually matter.

Now open a throwaway Git repository and give Cline a task that has a testable finish line: “Inspect the test failures, explain the likely root cause, propose a minimal fix, and wait for approval before editing.” If it can read files, describe the plan, make the edit after you approve it, and run the relevant test, your end-to-end local loop is working.

Use a workflow that local models can win at

Local agents are strongest when you constrain the problem and give them a way to verify their work. Avoid handing over “refactor the backend” as the first task. Instead, make the task narrow enough that the model can inspect the relevant files, form a hypothesis, change a small surface area, and run a command that proves or disproves the result.

  • Ask for investigation before modification: “Find where retry behavior is decided. Explain the call path and name the two files you would change.”
  • Ask for a plan with explicit acceptance criteria, then approve only the plan you understand.
  • Keep terminal approval enabled, especially for package-manager commands, database tooling, generated migrations, and anything using rm, git, or deployment credentials.
  • Make Git checkpoints. Commit a working state before larger agent tasks, and review the diff before accepting “done.”
  • Give the agent one verification command: a focused test, typecheck, linter, or reproducible failing command. Local agents get much more reliable when the loop includes evidence.

When a task needs broad architectural reasoning, a huge unfamiliar repository, or a long chain of independently correct edits, a local 30B model may take more supervision than a frontier hosted model. That is not a failure of the setup. It’s the trade: you gain privacy, control, offline operation, and zero marginal token cost; you spend more attention on scoping and verification.

Fix the three failures you’ll hit first

If Cline says it cannot connect, verify the runtime before changing extension settings. Run ollama list, then send a direct request to the local API. If that fails, restart Ollama. If it works but Cline fails, reopen Cline Settings and confirm that you selected Ollama—not a generic OpenAI-compatible provider—and that the selected model name exactly matches ollama list.

ollama list
curl http://localhost:11434/api/generate -d '{
  "model": "cline-qwen",
  "prompt": "Reply with OK",
  "stream": false
}'

If the model is painfully slow or produces truncated, confused tool sequences, reduce the context window first and close memory-heavy apps. Then consider a smaller or more aggressively quantized model if your hardware demands it. Better to have an agent that reliably handles a focused change in a few minutes than one configured for a giant context it cannot sustain.

If shell integration is unavailable, check Cline’s configured terminal profile and switch it to a shell your environment actually supports, such as Bash. Finally, don’t solve quality problems by granting more autonomy. Narrow the request, ask it to inspect before editing, and require a test. That turns a fully local Cline install from a novelty into a coding tool you can trust often enough to keep open.

Sources & citations

  1. [1]Cline — Local Models Overview
  2. [2]Cline — Authorization & Model Selection
  3. [3]Ollama — Quickstart
  4. [4]Ollama — API Introduction
  5. [5]Ollama Library — qwen3-coder:30b
  6. [6]Ollama — OpenAI Compatibility and Context Size
How to Build a Fully Local AI Coding Setup With Cline | Open Weight Thoughts