Point Claude Code at a Local Model With Ollama, in Its Own Worktree, With No API Bill
Scored daily by a customisable AI persona to surface the most relevant engineering leadership news.
Directly actionable guide to running Claude Code locally with Ollama, cutting API costs—perfect for AI agent developers.
Ollama v0.14.0 (January 16, 2026) now serves the Anthropic Messages API, letting Claude Code run its full agent loop—read, edit, test, iterate—against a local model like qwen3-coder:30b with no API key or per-token cost. The critical caveat is context window sizing: Ollama defaults to 4K tokens on GPUs under 24 GiB VRAM, but agents need at least 64K tokens, requiring explicit `OLLAMA_CONTEXT_LENGTH=64000` or a desktop slider adjustment. A wrapper script with environment variables (`ANTHROPIC_BASE_URL`, `ANTHROPIC_AUTH_TOKEN=ollama`, `CLAUDE_CODE_MAX_CONTEXT_TOKENS`) provides a clean, isolated setup in a disposable git worktree for testing tool-calling fidelity, context awareness, and latency before trusting the model with real work.