Aulafy
Courses/Claude Code + Local AI/Local code agents with Ollama

Local code agents with Ollama

You can use local models for coding tasks without sending your project to the cloud, but you need to design the workflow with context, permissions, and verification. The promise isn't "same as Claude Code"; the good promise is privacy, predictable cost, and control.

  • Understand when a local code agent is worth it and when it isn't.
  • Configure Ollama for code models with enough context.
  • Create an edit and verification workflow that doesn't break your repo.

The honest map

A local agent works very well for bounded tasks: explaining code, generating tests, creating scripts, refactoring a small component, or preparing a change plan. For large migrations, huge repositories, or long reasoning, the norm is to use a hybrid approach: local for privacy and drafts, cloud for difficult decisions or final review.

The practical foundation is Ollama. Its official documentation lets you run models on macOS, Windows, and Linux, and expose a local API for integrations. On Apple Silicon, MLX can be useful for experiments and performance with unified memory, but it doesn't turn any laptop into an unlimited workstation.

TerminalCode
# 1. Comprueba Ollama
ollama --version
ollama list

# 2. Descarga un modelo de código o propósito general
ollama pull qwen2.5-coder:7b

# 3. Prueba una tarea pequeña
ollama run qwen2.5-coder:7b "Explica este bug: un array vacío rompe un reduce sin valor inicial"

# 4. API local para integraciones
curl http://localhost:11434/api/generate -d '{
  "model": "qwen2.5-coder:7b",
  "prompt": "Escribe una función TypeScript que valide emails sin dependencias.",
  "stream": false
}'

Checklist before letting it touch files

  • Work on a branch: never test a local agent on `main`.
  • Define scope: which folder it can read, which files it can edit, and which commands it can execute.
  • Require a plan: before editing, have it list files, risks, and success criteria.
  • Verify cold: install dependencies and run tests after the change.
  • Log metrics: time, tokens, errors, and commands executed.
TerminalCode
# Flujo mínimo para trabajar con seguridad
git checkout -b agent-local/tarea-pequena

# Pide primero un plan, no cambios
# Después de aplicar cambios:
npm install
npm run lint
npm run build
git diff --stat
git diff

Official sources

  • Ollama Quickstart
  • Ollama: context length
  • MLX documentation