Table of Contents
Local AI Coding Environment Setup (Ollama + OpenCode)
Install ollama and do some tests from the command line
Get the current version (and proof of life)
ollama -- version
Get a model, this one is a 8b parameter coder model (but always check for better models, it is constantly changing):
ollama pull qwen3-coder:8b
Show all the models currently installed:
ollama list
Now make sure that the API running on the local server is up:
curl http://localhost:11434/api/tags
Overview
This setup creates a local coding assistant environment similar in workflow to tools such as Claude Code.
Components:
- Ollama runs local coding LLMs.
- OpenCode provides an agent-style coding interface.
- Qwen 2.5 Coder provides the coding intelligence.
- Git provides version tracking and a safe way for the AI to propose changes.
- Projects can be analysed, reviewed, refactored, and modified locally without sending source code to the cloud.
The target workflow:
- Open a code project in OpenCode.
- Ask the AI to analyse, review, or modify code.
- Review proposed changes.
- Commit changes through Git.
- Allow larger models to perform deeper analysis overnight.
Hardware
Test Machine
| Component | Specification |
|---|---|
| CPU | Intel i7-12800H |
| RAM | 32GB |
| GPU | NVIDIA GeForce MX550 (2GB) |
| OS | Windows 11 |
The system is CPU-focused. The GPU is too small to significantly accelerate larger models.
1. Install Ollama
Install Ollama for Windows.
Verify installation:
ollama --version
Check installed models:
ollama list
Ollama runs a local server:
http://localhost:11434
Verify the API:
curl http://localhost:11434/api/tags
This should return installed models.
2. Install Coding Models
Small Model
Install:
ollama pull qwen2.5-coder:7b
Good for quick tasks.
Approximate memory usage:
~5GB
Daily Coding Model
Install:
ollama pull qwen2.5-coder:14b
This became the preferred interactive model.
Approximate memory usage:
~10GB
Good balance between:
- reasoning ability
- speed
- memory usage
Large Reasoning Model
Install:
ollama pull qwen2.5-coder:32b
Approximate memory usage:
~24GB loaded
Excellent for:
- architecture reviews
- large code analysis
- overnight tasks
However, on a 32GB laptop it leaves Windows with little breathing room.
3. Configure Context Size
Ollama context can be increased using:
setx OLLAMA_NUM_CTX 16384
Restart applications after changing environment variables.
Verify:
echo %OLLAMA_NUM_CTX%
Check the active model:
ollama ps
Example:
NAME CONTEXT qwen2.5-coder:14b 16384
For a memory-limited machine, reduce if necessary:
setx OLLAMA_NUM_CTX 8192
4. Install OpenCode
Install the Windows OpenCode desktop beta.
OpenCode provides the agent workflow:
- project browsing
- multi-file analysis
- change planning
- editing
- Git-aware workflows
Important Distinction
Ollama is the “brain”.
OpenCode is the “agent”.
OpenCode decides:
- which files to inspect
- what prompts to send
- what changes to make
- how to sequence tasks
The LLM itself does not independently browse the project.
5. Configure OpenCode to Use Ollama
OpenCode configuration is stored at:
%USERPROFILE%\.config\opencode\opencode.jsonc
Example configuration:
{ "$schema": "https://opencode.ai/config.json", "provider": { "ollama": { "name": "ollama", "npm": "@ai-sdk/openai-compatible", "options": { "baseURL": "http://localhost:11434/v1" }, "models": { "qwen2.5-coder:7b": { "name": "qwen2.5-coder:7b" }, "qwen2.5-coder:14b": { "name": "qwen2.5-coder:14b" }, "qwen2.5-coder:32b": { "name": "qwen2.5-coder:32b" } } } } }
The `/v1` suffix is important because OpenCode uses the OpenAI-compatible API.
6. Prepare Projects for AI Work
Git is strongly recommended.
Example:
cd MyProject git init git add . git commit -m "Initial project snapshot"
This gives a clean rollback point before allowing AI changes.
OpenCode can then:
- inspect the repository
- create plans
- modify files
- show diffs
7. First Test Project
A small intentionally-buggy C# project was created to test the workflow.
The AI was asked:
Do not modify files. Analyse the entire project structure. Create REVIEW.md containing: 1. Project overview 2. Architecture summary 3. Bugs found 4. Potential runtime issues 5. Security concerns 6. Code quality issues 7. Recommended order of fixes
The model successfully:
- mapped the project
- identified bugs
- produced a structured review
- created a refactoring plan
8. Model Performance Notes
Qwen 2.5 Coder 14B
Best everyday model.
Advantages:
- fast enough
- good reasoning
- comfortable memory usage
- suitable for interactive coding
Qwen 2.5 Coder 32B
Advantages:
- deeper analysis
- better architectural reasoning
- useful for large code reviews
Disadvantages:
- consumes ~24GB RAM
- leaves Windows with ~1.7GB free
- can cause paging and sluggishness
Best use:
- Start a task.
- Let it run.
- Review results later.
Troubleshooting Notes
Problem: Ollama Model Not Found in OpenCode
Symptoms:
404 Not Found
Solution:
Check Ollama first:
ollama list
Confirm exact model name:
qwen2.5-coder:32b
The model ID must exactly match.
Problem: OpenCode Connects to Ollama but Cannot See Models
Check the API:
curl http://localhost:11434/api/tags
If models appear, Ollama is working.
The OpenCode provider should use:
http://localhost:11434/v1
not:
http://localhost:11434
Problem: Environment Variable Does Not Appear Immediately
After:
setx OLLAMA_NUM_CTX 16384
This:
echo %OLLAMA_NUM_CTX%
will not update in the same command window.
Open a new terminal.
Problem: 32B Model Makes Windows Slow
Check memory:
Get-Counter '\Memory\Available MBytes'
Example:
Available: 1700 MB
This means the machine is under pressure.
Unload:
ollama stop qwen2.5-coder:32b
Use 14B for normal work.
Problem: Git Commit Asks for Identity
Configure Git:
git config --global user.name "Your Name" git config --global user.email "you@example.com"
Then retry:
git commit -m "Initial project"
Problem: OpenCode GUI Configuration is Confusing
The real configuration is easier to edit manually:
%USERPROFILE%\.config\opencode\opencode.jsonc
Recommended Final Configuration
For this laptop:
| Purpose | Model |
|---|---|
| Daily coding | qwen2.5-coder:14b |
| Deep analysis | qwen2.5-coder:32b |
| Quick questions | qwen2.5-coder:7b |
Context:
16384
Workflow:
Git snapshot
↓
OpenCode analysis
↓
AI review/plan
↓
AI changes
↓
Review diff
↓
Commit
This provides a capable local coding assistant while keeping source code entirely on the local machine.