How Agents Work | Tool Comparison | Model Selection | Hardware | Setup and Testing | Safe Use
🚀 Local AI Can Edit Projects Directly—but the Model Is Only One Piece
As of 2026, local AI coding goes well beyond answering questions about code. A properly configured coding agent can read an entire project, find relevant files, edit existing code, create files, run terminal commands and tests, and keep fixing problems based on the resulting error output. The code can remain on your computer, with no per-token model API fees.
- 🎯 The key difference: Code completion predicts the next snippet, while a chat assistant tells you what to change. An agent actually invokes file and terminal tools and writes the changes to disk.
- 🧠 The model is not the agent: The model interprets the task and decides what to do next. The agent reads and writes files, searches the repository, and runs commands. Installing Ollama and a model alone does not give the model permission or tools to edit a project.
- 🔁 The full workflow: Understand the request → Search the codebase → Read files → Edit multiple files → Run tests → Analyze errors → Revise the code → Verify the result.
- 🔒 Why local matters: Private code, undisclosed products, and customer projects do not need to leave the computer, but only if the models, embeddings, and tools used are actually running on the local machine, rather than a remote version with Cloud in the name.
- ⚠️ What to check: Chat, code generation, and local-model support do not guarantee reliable tool use. A practical setup needs file tools, terminal access, tool calling, and an agent loop that can act, observe the result, and continue.
🧭 The Four Layers of a Local AI Coding System
- 🖥️ Editor layer: VS Code opens and displays the project—the developer's workbench. Terminal-based agents are editor-independent, so they can also work alongside Cursor, JetBrains IDEs, Vim, or other tools.
- 🛠️ Agent layer: Cline, Roo Code, Continue, Codex, Claude Code, and OpenCode read files, apply patches, run commands, and manage the action loop. This is the part that actually operates on the project.
- ⚙️ Model runner layer: Ollama or LM Studio loads the model and exposes it to the agent. Ollama is well suited to command-line use and automation; LM Studio is easier for newcomers who prefer a graphical interface.
- 🧠 Model layer: Models such as Qwen and Devstral analyze code, plan changes, and choose tools. Strong agentic coding, long-context handling, and reliable tool use make complex tasks more stable.
- ⚖️ Why both matter: Without an agent, even a strong model can only suggest changes. Pair a capable agent with a weak model and it may edit the wrong file, repeat actions, or make unreliable changes.
📊 Comparing the Leading Local Coding Agents
| Toolset |
| Cline + Ollama |
Reads and writes files, searches the codebase, applies patches, and runs commands. Plan mode handles research and planning; Act mode performs the changes. A CLI version can work without VS Code. |
A strong first choice for building a local agent, especially if you want to review each action clearly in the VS Code sidebar. |
| Roo Code + Ollama |
Provides read, edit, terminal, and MCP tools, with extensive customization for modes, permissions, and agent roles. It fully supports multi-file work. |
Best for experienced VS Code users who want fine-grained modes or several specialized agent roles. |
| Continue + Ollama |
Separates Chat, Plan, and Agent modes and lets you configure different models for chat, editing, Apply, autocomplete, and embeddings. |
Best if you need both a local agent and Tab completion: use a small model for low-latency completion and a larger model for complex tasks. |
| VS Code native Agent + Ollama |
Connects local models to chat and agent tools, although results depend on whether the model can reliably select file and terminal tools. |
Good for users willing to test compatibility. The local BYOK agent and native Inline Suggestions are separate features. |
| Codex / Claude Code + Ollama |
Reads, edits, runs, and debugs directly in the project directory without depending on VS Code. The agent shell supplies the tools while Ollama supplies the local model. |
Best for terminal-oriented developers, anyone who wants to separate the agent from the editor, or people who switch among several IDEs. |
| OpenCode / Copilot CLI + Ollama |
Understands codebases, edits files, and runs commands. OpenCode offers a more open agent shell, while Copilot CLI can also separate the agent from the model provider. |
Best for Linux, SSH, server, and terminal-only workflows, or for developers who prefer a more open toolchain. |
| Basic Ollama Chat |
The model can generate and explain code, but it has no project search, file-editing, or terminal execution pipeline. |
Useful for Q&A and code drafts, but it is not a coding agent and cannot modify the project directly. |
🧩 The VS Code Route: Cline, Roo Code, Continue, and the Native Agent
🛠️ Cline: The Easiest Place to Start
- Cline can read project files, search the codebase, apply patches, create files, and run terminal commands. For a task such as “add a Remember Me option to the login flow and run the tests,” it can inspect the front end, authentication logic, and API, then revise the implementation based on the results.
- Plan mode is suitable for researching problems and designing solutions first, and then Act mode will actually implement them. If the Agent only analyzes but does not modify the files, first confirm whether it is still in Plan mode and whether the "Edit project files" permission has been turned on.
- Auto Approve lets the agent work continuously, but it also increases the risk of file changes and terminal commands. Keep manual approval enabled at first, then gradually allow low-risk operations after the model behaves consistently.
- Run Cline CLI from the project directory, for example:
cline "Check the project and fix failing tests". It provides a Codex- or Claude Code-style terminal workflow while retaining Cline's agent capabilities.
🧰 Roo Code: More flexible permissions and roles
- Roo Code groups its capabilities into read, edit, command, and MCP tools, covering file access, shell execution, and external integrations while using a local model.
- It is very close to Cline's basic capabilities. If you prefer to use it out of the box, you can choose Cline first; when you need more detailed mode, permissions and role settings, Roo Code is usually more convenient.
- Start either extension with a small test. Once the model calls tools reliably, move on to a real repository and multi-file changes.
🧠 Continue: A Full Local Copilot Alternative
- Chat mode is used for conversations, Plan mode reads and analyzes projects, and Agent mode has complete tools for creating files, modifying files, and running terminal commands.
- Continue can assign different jobs to different models: a lightweight model for autocomplete, a larger model for agent tasks, and a separate embedding model for code retrieval.
- Some Ollama models claim to support tool use but still fail in Agent mode. Check the model's capability declaration, provider configuration, and whether
tool_use is enabled correctly.
🧩 VS Code Native Agent: A Successful Connection Does Not Guarantee Stable Tool Use
- Local models can participate in VS Code’s Chat and Agent workflows, but tool invocation, reasoning, and visual capabilities depend on the specific model. Being able to chat normally does not prove that it will call Edit File.
- If you ask it to edit
login.ts and it only prints replacement code without changing the file, the current setup is still functioning as a chat assistant.
- When the local BYOK model is used for agent-style modification, it will not automatically replace VS Code's native tab completion. If you want to keep the completion locally, you need an extension such as Continue that can connect to the local Autocomplete model.
⌨️ The Terminal Route: Work on a Project Without Opening VS Code
🧪 Codex + Ollama
- Install Codex CLI with
npm install -g @openai/codex, then run ollama launch codex. You can also use codex --oss to select a local model.
- Once launched inside a project directory, Codex operates directly on that repository, so you can use any editor. Codex App can also connect through
ollama launch codex-app if you prefer a graphical interface.
- Agent sessions include tool definitions, project code, command output, and action history. A context window of roughly 64K is a sensible starting point.
🧭 Claude Code + Ollama
- Run
ollama launch claude to connect the Claude Code agent shell to Ollama, or use claude --model qwen3.5 to select a local open model.
- Agent program and model source are two different things. Using Claude Code's project operation capabilities does not necessarily mean that you are calling Anthropic's cloud Claude model.
- Because file contents, tool definitions, and multiple debugging rounds all consume context, configure at least about 64K when the hardware allows it.
🌐 OpenCode, Copilot CLI and Cline CLI
- Use
ollama launch opencode for an open terminal workflow, or ollama launch copilot to let Copilot CLI use a model served by Ollama.
- Terminal Agent is especially suitable for Linux, SSH and server environments. As long as you enter the correct project directory, it can read the repository, modify files, and execute tests independently of the editor.
- Don't just look at the name when choosing a tool, check whether it also has Read File, Edit File or Apply Patch, Terminal, Tool Calling and Agent Loop.
🧠 Choosing a Model: Parameter Count, Context, and Quantization
| Local Model |
| Qwen3.5 9B |
The Ollama build is about 6.6GB and supports roughly 256K context plus tool calling, with relatively modest hardware requirements. |
Good for learning agent workflows, editing a single file, writing small scripts, working with HTML/CSS, and fixing simple bugs. Long tasks are less reliable. |
| Qwen3.5 27B / 35B |
The 27B version is about 17GB, and the 35B version is about 24GB. Both support about 256K context and tool calls. |
A better fit for midrange and high-end systems with enough VRAM and RAM, offering stronger reasoning and better understanding of complex projects. |
| Devstral Small 24B |
The Q4 build is about 14–15GB with roughly 128K context. It is trained for codebase exploration, tool use, and multi-file software engineering. |
A practical choice for systems with 24GB of VRAM or Macs with 32GB of unified memory, especially for medium-size projects, debugging, and multi-file edits. |
| Qwen3-Coder 30B |
The Q4 build is about 19GB, with roughly 30.5B parameters, a native 256K context window, and tool support. It is optimized for repository-level and agentic coding. |
Well suited to a primary local development machine with 64GB of RAM and at least 24GB of VRAM, handling debugging, refactoring, test loops, and multi-file tasks. |
📏 Parameter Count and Real Agent Capability
- Models in the 3B–4B range behave more like advanced code completion and are poor choices for complex agent tasks. Models in the 7B–9B range can edit individual files, add small features, and fix simple bugs, but long loops remain unreliable.
- At about 14B, models begin to deliver meaningful productivity. The 24B–30B range is especially important for local coding agents because it can handle repository understanding, multi-file edits, debugging, refactoring, and test loops more seriously.
- Just because the model can write code does not mean it can be an agent. Real tasks also require it to choose the right tool, fill in parameters, analyze tool output, maintain long-term goals, and judge when to stop, so Agentic Coding ability is more important than a single code benchmark score.
📚 Do Not Choose a Context Window by Its Advertised Maximum Alone
- An agent's context contains the system prompt, tool definitions, the request, project files, terminal output, Git diffs, and previous actions. An 8K window may be enough for chat, but 32K is a more realistic starting point for a coding agent.
- Cline and Roo Code can start at 32K. Long-running terminal agents such as Codex, Claude Code, and OpenCode are better served by 64K or more. Increase it further only for large repositories or broad refactors.
- A model's advertised 256K limit does not mean you should immediately set
num_ctx to 262144. Larger windows increase KV-cache use and can exhaust VRAM or RAM, reduce speed, and delay the first token.
🗜️ How to choose between Q4, Q5, Q6 and Q8
- Q4 is more heavily compressed, producing smaller files and lower VRAM requirements, usually with faster inference but a modest loss in quality. Q8 stays closer to the original model but consumes substantially more RAM and VRAM.
- Q4_K_M is a practical starting point for a local coding agent. Loading the entire model with a useful context window is usually better than choosing a higher-precision quantization that repeatedly runs out of memory.
🖥️ PC Hardware: Prioritize VRAM Without Ignoring RAM and Context
| Hardware Tier |
| 16GB RAM, no discrete GPU or 6GB VRAM |
Quantized 2B–7B models |
Enough for experimentation, code explanations, and small scripts. Each agent step may be slow, making long loops impractical. |
| 16–32GB RAM, 8GB VRAM |
7B–9B models |
Handles single-file edits, HTML/CSS, and straightforward Python or JavaScript work. |
| 32GB RAM, 12–16GB VRAM |
9B–14B models |
Begins to offer dependable productivity for React, APIs, WordPress plugins, and small to midsize web projects. |
| 64GB RAM, 24GB VRAM |
24B–30B Q4 models |
A practical sweet spot for local Coding Agents, suitable for Devstral Small 24B, Qwen3-Coder 30B, and context windows around 64K. |
| 96GB+ RAM, 32GB VRAM |
27B–35B models |
Provides room for higher-quality quantization, larger contexts, and several development services running in parallel. |
| 128GB+ RAM, 48GB+ VRAM |
Quantized 30B–70B models or larger |
A professional AI workstation tier. More than 80GB of VRAM expands the options for larger models and longer contexts. |
🎮 Why VRAM Comes First
- Performance is usually best when the entire model fits in VRAM. If it does not, some layers spill into system RAM. The model may still run, but transfers between CPU memory and the GPU can slow every step of the agent loop.
- Pure CPU operation is not completely unfeasible, but the Agent will request the model multiple times in a row for one task. Waiting tens of seconds for each step can make debugging, testing, and fixing processes unwieldy.
- A 19GB Qwen3-Coder 30B Q4 file does not leave a guaranteed 5GB free on a 24GB GPU. The KV cache, runtime, and context all require additional memory; 32GB or 48GB of VRAM provides more headroom.
💾 How to Prioritize RAM, SSD Capacity, and CPU
- 64GB of RAM is much more comfortable for sustained development because Windows, VS Code, browsers, Docker, Node.js, databases, Ollama, and development servers all compete with the model for memory.
- Individual model files commonly occupy 6GB, 15GB, 19GB, or far more. A collection can quickly consume hundreds of gigabytes, so use at least a 1TB SSD; a 2TB NVMe drive is better for long-term use.
- Of course the CPU is important, but when you're on a budget, it's usually not worth dropping 24GB of VRAM to 16GB for a small CPU boost. For local large models, GPU memory has higher priority.
🍎 How to choose unified memory for Apple Silicon
- Apple silicon uses unified memory shared by the CPU and GPU, so the usual PC split between system RAM and dedicated VRAM does not apply. A 16GB Mac is limited to smaller models, while 32GB can run a model such as Devstral 24B Q4 more seriously.
- With 64GB of unified memory, a Mac is well suited to local coding agents in the 24B–35B range. A 128GB model supports larger models and longer contexts. High-unified-memory Macs are especially attractive if local AI matters more than gaming.
- As a rough guide, pair about 8GB of VRAM with a 16K context, 16GB with 32K, and 24GB or more with 64K. Actual usage varies by model architecture and quantization.
⚙️ Installing VS Code + Cline + Ollama on Windows
1️⃣ Install the Runner and Download a Suitable Model
- Install Ollama, then choose a model that fits the hardware. With 24GB of VRAM, try
ollama pull qwen3-coder:30b or ollama pull devstral-small-2:24b. On a smaller GPU, start with ollama pull qwen3.5:9b.
- If you prefer a graphical interface, LM Studio makes it easy to find, download, and load models. Ollama is generally more convenient when coding agents and automation are the primary goal.
2️⃣ Install Cline and Connect It to Ollama
- Install Cline in the VS Code extension store, enter Settings, and set the API Provider to Ollama.
- The local endpoint is usually
http://localhost:11434. Select the model you downloaded and give the agent a reasonable context window.
- Do not enable automatic approval for every terminal command at first. Start by allowing project reads, workspace edits, and explicitly safe commands.
3️⃣ Verify the Agent Pipeline with a Minimal Test
- Create
test.txt containing hello. Tell the agent not to print the replacement text, but to edit the file directly so it contains hello world.
- If the file changes, the edit tool worked. If the model merely says that it “should be changed to hello world,” the mode, permissions, model, or tool configuration still needs attention.
- Next, ask it to create
hello.py, run the script, and confirm the output. Creating the file, executing it, and reading the result verifies the file tools, terminal tools, and tool-calling pipeline.
4️⃣ Move On to a Real Software Task
- Choose a small or midsize project with tests or a reliable build. Ask the agent to find and fix TypeScript errors, run
npm run build, and continue until the build succeeds.
- State the goal, allowed scope, required verification commands, and stopping condition. That produces more stable results than a vague request such as “help me fix it.”
🧪 Tasks Local Coding Agents Handle Well
🐛 Bug Fixes and Build Errors
- If login state disappears after a page refresh, the agent can search the authentication code, inspect localStorage and token handling, edit the relevant files, and run tests.
- When
npm run build reports several errors, the agent can read them, find the affected files, make changes, rebuild, and repeat until the build passes. Tasks with objective feedback are where agents add the most value.
🧱 Add Features and Modify Multiple Files
- When adding a bookmarking feature to a blog, an agent can update the database, API, backend, frontend, styles, and tests instead of generating one isolated function.
- Define the data structure, user flow, compatibility requirements, and acceptance commands so the agent can stop based on verifiable results rather than a subjective judgment.
♻️ Refactoring, Dependency Upgrades, and Test Loops
- When splitting a 2,000-line Python file, the agent can analyze dependencies, create modules, move functions, update imports, and run tests continuously—provided the project already has reliable test coverage.
- For a React upgrade, it can update
package.json, install dependencies, replace deprecated APIs, and verify compatibility through builds and tests.
🔍 Understand Unfamiliar Repositories and Build Projects from Scratch
- In an unfamiliar project, ask the agent how to start it, where login is implemented, where the database is initialized, and how requests flow through the system. Repository search and cross-file analysis are often faster than reading every file manually.
- For a new personal-finance app, the agent can create the directory structure, frontend, backend, database, and API, then launch the project and fix errors. A developer still needs to choose the architecture and review the security boundaries.
🧯 It Writes Code but Cannot Edit Files: Common Causes
❌ The Model Cannot Use Tools Reliably
- The model must select
edit_file, read_file, or a terminal tool and supply the correct path and parameters. A model that only produces natural language can offer suggestions but cannot perform the edit.
- Small models often become confused by many tool definitions, project files, conversation history, and complex requirements. Even a 3B or 7B model that nominally supports tools may fall back to plain-text answers during a long task.
🔧 Incorrect mode, permissions or provider configuration
- Chat and Plan modes usually do not perform real modifications and should be switched to Agent, Act or Code mode. No matter how smart the model is, it cannot write to the file when editing permissions are turned off.
- Confirm the Ollama endpoint, model name, context window, and capability declaration. Some integrations require an explicit
tool_use capability; without it, the model may never receive the available tools.
- Do not use a complex repository as the first diagnostic target. The
test.txt hello test quickly separates a tool-use problem from a project-understanding problem.
🔁 The Agent Repeats Itself or Loses the Goal on Complex Tasks
- A local 9B model may choose the wrong file, repeat an action, fix one bug while introducing another, or lose the original goal during a long loop. A complete toolset does not make it as capable as the strongest cloud models.
- Break large requests into small, verifiable tasks. Limit the directories or files it may edit and require tests at each stage; this is more reliable than asking it to “refactor the entire project” in one pass.
- When the context begins to accumulate irrelevant logs, it is more effective to reopen a focused task than to blindly expand the context window to the maximum.
🔒 Local Does Not Mean Risk-Free: Permissions, Git, and Privacy
- 🌿 Create a Git branch first: On a real project, start with
git checkout -b ai-test after committing a clean baseline. You can then review each diff and undo bad changes.
- 🛡️ Grant permissions gradually: Begin with workspace reads and edits plus safe commands. Disable edits outside the workspace and blanket command approval. Do not enable YOLO Mode at the outset.
- 💥 Terminal access carries greater risk: An agent may delete files, reset Git state, install dependencies, or run database migrations. Manually approve anything that could damage data, deploy software, or touch production.
- 📋 Inspect the result, not just the summary: Review the Git diff, then run tests, builds, and static checks. An agent's claim that it finished does not prove the code is correct or free of side effects.
- 🔐 Verify that the setup is truly local: Local Ollama models normally have no token fees, but hardware and electricity still cost money. If code must never leave the machine, also inspect agent telemetry, remote MCP tools, embedding services, and any model labeled as a Cloud version.
✅ Recommended Setups by Hardware and Workflow
| Use Case |
| First-time use, 16–32GB RAM |
VS Code + Cline + Ollama + Qwen3.5 9B |
Easy to install and verify, and suitable for single-file work or small projects. Keep expectations modest for complex agent loops. |
| Midsize projects, 32–64GB RAM |
VS Code + Cline + Ollama + Devstral Small 24B |
Good for web development, Python, JavaScript, React, bug fixes, and multi-file edits. A 24GB GPU is ideal. |
| Primary local coding agent |
Cline or Roo Code + Ollama + Qwen3-Coder 30B |
64GB of RAM, at least 24GB of VRAM, and a 2TB NVMe SSD form a realistic local-development sweet spot. |
| Editor-independent workflow |
Codex or Claude Code + Ollama + Qwen3-Coder/Qwen3.5 |
The agent operates directly in the project directory, making it suitable for terminal users, multi-IDE workflows, or anyone who wants to decouple the tool from the editor. |
| Open Linux and SSH workflow |
OpenCode + Ollama + local model |
Both the agent shell and model connection are more open, making this a good fit for servers, remote development, and terminal-only environments. |
| Also requires local tab completion |
Continue + Ollama: small model for completion, large model for agent tasks |
Separates frequent, low-latency completion from complex project work, creating an experience closer to a fully local Copilot. |
🏁 Bottom Line: Check the Toolchain, Not the Marketing Label
Local AI coding can now handle real project work, but the experience depends on how well the agent, model, runner, and hardware work together. Lightweight models are enough for learning the workflow. For sustained productivity, a capable 24B–30B model paired with 64GB of RAM and at least 24GB of VRAM comes much closer to a dependable local coding assistant.
- ✅ If you prefer VS Code: Start with Cline or Roo Code plus Ollama. Choose Continue if you also need local inline completion.
- ✅ If you prefer the terminal: Use Codex, Claude Code, or OpenCode to keep the agent independent of your editor.
- ✅ When evaluating a new tool: Confirm that Read File, Edit File or Apply Patch, Terminal, Tool Calling, and an Agent Loop are all present.
- ✅ Verify the setup: Put
hello in test.txt and ask the agent to edit the file directly. Move to a real repository only after the file actually changes.
- ✅ Maintain engineering discipline: Use Git, limit permissions, review diffs, and run tests. Agents can automate a great deal of mechanical work, but architecture, security boundaries, and final approval remain the developer's responsibility.