Run AI coding models on your own computer, connect them to coding agents, and build a workflow with more control over your data and running costs.
Definition: A local AI coding assistant uses a language model running on your own computer to help write, explain, debug and edit code. Ollama is the model runtime. A coding agent such as Claude Code, Codex or OpenCode adds access to project files and multi-step work.
🎧 Listen to this guide on the Masterphub Podcast
Episode 14: Local AI Coding Assistants With Ollama
You do not need to build a model from scratch. With Ollama you download compatible models, run them locally and connect them to tools that work on real project files. Local models run on your hardware, so your limits are your computer, the model you choose and the quality of the agent you connect.
Ollama downloads and runs models and exposes an interface other applications can call. The model is the reasoning engine. The coding agent is the working environment: it reads files, runs commands and carries out multi-step tasks, within its permission settings.
These parts are not interchangeable. Ollama alone does not let a model edit files or run commands. That comes from the agent and its integration.
Note your RAM, CPU, GPU, VRAM, operating system and free storage. Model size matters, but so do quantization, context length and GPU memory. A smaller model that answers quickly is often more useful than a larger one that makes the machine struggle.
These are starting points, not guarantees. A computer with a capable GPU can behave very differently from a CPU-only one with the same RAM.
To get a first recommendation, ask an AI assistant:
Based on these hardware specifications, recommend three coding models that can run locally through Ollama. Prioritize reliable code generation, debugging quality, reasonable response speed, and compatibility with coding agents. Explain the expected memory requirements, limitations, and best use case for each model. Do not recommend a model that exceeds the available hardware without clearly explaining the trade-offs.
On Linux the fastest route is the official install script. Read it before you run it if you prefer: ollama.com/install.sh.
curl -fsSL https://ollama.com/install.sh | sh
Check that it installed:
ollama --version
On most distributions the installer sets Ollama up as a service. Check that it is running and starts on boot:
systemctl status ollama
sudo systemctl enable --now ollama
If something fails, read the service log:
journalctl -u ollama -f
If you have an NVIDIA GPU, confirm the driver sees it before you blame the model:
nvidia-smi
Windows and macOS: download the installer from ollama.com/download. On Windows use PowerShell or Windows Terminal for the commands below.
Browse the official model library at ollama.com/library and pick a model that fits your hardware.
There is no single best model. Quality, memory use, speed, context support and tool-calling reliability all matter. Three starting points to evaluate:
A coding-focused family for code generation, repository analysis, debugging and multi-file work. Model page. Some variants are demanding, so check the requirements of the exact variant, especially with limited GPU memory.
An option for local inference and coding workflows. Model page. Let your agent and hardware guide the choice.
Another model to evaluate for coding. Model page. Check current variants and requirements. Parameter count alone does not tell you how fast it will run on your computer.
Download and start one:
ollama run gpt-oss:20b
or
ollama run qwen3-coder
Ollama downloads the model if needed and opens a session. The first download can take a while. Later launches reuse the files. If a name or tag is not found, check the current name in the library.
Useful commands:
ollama list # models on this computer
ollama ps # models loaded now, and whether they run on GPU or CPU
ollama stop gpt-oss:20b # unload a model
Start simple: "Explain what a Python function is, show a small example, and identify two common mistakes beginners make." Then something practical: "Write a Python function that validates an email address using a basic pattern. Explain the limitations of the validation and provide three test cases." Check correctness, clarity and whether it follows your instructions. A plausible snippet does not make a model suitable for autonomous development.
The agent supplies the workflow: inspecting files, editing code, running tests and doing multi-step work. What works depends on the agent, the model and the configuration. Ollama documents integrations with Claude Code, Codex and OpenCode. Start with one.
Install Claude Code from its official documentation, open a terminal in your project folder and run:
ollama launch claude
Follow the prompts to pick a compatible model. See the official integration guide. Using Claude Code with an Ollama model does not mean you are running Anthropic''s Claude model locally. The tool and the model are separate parts.
Install Codex CLI from its official repository, then:
ollama launch codex
A documented alternative is:
codex --oss
See the official guide. As with Claude Code, an alternative model does not bring every feature of the native hosted model.
Install it from the OpenCode docs, then:
ollama launch opencode
Worth testing if another integration has trouble with tool calls.
Recommendation: get a simple project working with one agent before adding anything else.
Open a terminal in your project folder (for example my-project/ with src/, tests/ and a README), then launch the agent. Ask it to inspect before it changes anything:
Inspect this project without modifying any files.
Explain:
- The purpose of the project.
- The main folders and important files.
- The programming languages and frameworks used.
- How the application is started and tested.
- Any obvious risks or missing dependencies.
Do not install packages, execute destructive commands,
or modify files. Ask for permission before making changes.
If it cannot explain a small project, do not move on to refactoring.
The context window is how much the model can consider in one request: instructions, files, conversation, tool results and test output. Bigger helps with multi-file work and costs memory. Ollama''s default may be too small for agent workflows, and its integration docs recommend at least 64K tokens for supported setups. That is a target, not a requirement every computer handles well.
On Linux with the systemd service, set it as an environment variable:
sudo systemctl edit ollama
Add these lines in the editor that opens, then save:
[Service]
Environment="OLLAMA_CONTEXT_LENGTH=65536"
Apply it:
sudo systemctl daemon-reload
sudo systemctl restart ollama
On Windows or macOS, use the context length option in Ollama''s settings. Details: Ollama context length documentation. Watch memory and speed after you raise it. If the system gets unstable, lower the value or use a smaller model. A big window does not guarantee the model uses it well.
Pick a small task with a clear result, such as a simple bug:
Analyze this project and identify one small, verifiable bug.
Before making changes:
- Explain the problem.
- Identify the file or files involved.
- Describe the proposed fix.
- Explain how the fix will be tested.
Wait for my approval before editing files.
After approval:
- Make the smallest reasonable change.
- Run the relevant tests if available.
- Report the files changed.
- Show the test results.
- Explain any remaining uncertainty.
Do not claim that tests passed unless they were actually run.
This shows whether the agent reasons correctly, uses tools properly and reports honestly. If it works, try something slightly bigger, like input validation or tests for an existing function.
Likely causes: not enough GPU memory, CPU-only inference, a model that is too large, or a very large context. Run ollama ps to see whether the model is on GPU or CPU. Try a smaller model, close heavy applications and compare on a simple task.
Check the exact name and tag, free storage and memory, and that the service is running (systemctl status ollama on Linux).
Update Ollama and the agent, re-read the official integration steps and confirm the model is compatible. Make sure Ollama is running and the endpoint and environment variables are correct.
Use a smaller task, give clearer acceptance criteria and ask it to read the relevant files first. Poor tool use can mean the model is a weak fit for agent work.
Trim conversation history, split large tasks and check the context setting. If things get worse after raising the context, lower it and test again.
Check that the model supports the tool calling the agent needs and that the agent has the permissions it needs. Try another compatible model or agent.
Running a model locally can reduce how much code goes to an outside provider, but it does not guarantee your whole workflow is offline.
For your first project, work in a test repository or a copy.
ollama launch.Fifteen minutes is realistic for a prepared computer and a straightforward install. Large downloads and compatibility problems take longer.
A language model running on your own computer that helps generate, explain, debug and modify code. Ollama runs the model, and a coding agent adds project access and workflows.
Install Ollama, choose a compatible coding model, download it and connect it to a supported coding agent. Start with a small test project and check that it completes a simple task correctly.
Ollama and many downloadable models are free to use. You still need suitable hardware, storage and electricity. Cloud models and some third-party tools have their own pricing or limits.
After you download the model and install the tools, local inference can work offline. Initial downloads, updates and some agent features need a connection. Test your full setup before relying on it offline.
Yes. Use ollama launch claude or ollama launch codex and follow the prompts. Supported features depend on the model and integration.
There is no universal minimum. Smaller models run on modest hardware. Larger models and long contexts need more. Check the exact model and leave room for the system and other applications.
Not necessarily. Local models can be effective for explanations, smaller fixes and many everyday tasks. Hard reasoning and large projects may favor stronger hosted models.
A small existing app or a script with tests. Begin with inspection and explanation, then a change that is easy to verify.
A local assistant is not magic, and installing a model does not create a reliable developer. The value comes from a suitable model, a capable agent, clear instructions and disciplined testing. Start small, measure what works, and improve the setup only when you understand its limits.
Explore more AI tools, workflows and prompts at Masterphub.
Editorial note: model names, commands and integrations change. Recheck the official Ollama library and docs before relying on them. Last checked: October 14, 2026.