How to run Claude Code on a local Ollama model in a throwaway worktree
Based on a guide by Gabriel Anhaia on DEV Community · Nov 28, 2026
You'll end with: Claude Code driving qwen3-coder:30b on your own machine through Ollama, tested in a git worktree for tool calls, context, and speed.
Why it's worth having: The agent loop runs with no Anthropic key and no per-token bill, on a model that sits on your own disk.
At a glance
The method, in short
- 1Pull qwen3-coder:30b, a 19GB model with a 256K window, and start Ollama with OLLAMA_CONTEXT_LENGTH=64000.
- 2In a wrapper script, set ANTHROPIC_BASE_URL to localhost:11434, map every model alias to the local model, and cap context at 64000.
- 3Run a small task with a test in a throwaway git worktree, check /status and /context, and keep permission prompts on.
- 4Watch whether the model calls Claude Code's read and edit tools, or only describes the edit in prose.
Read the full guide from Gabriel Anhaia on DEV Community
The post has the wrapper script, the Ollama context settings, and a curl test for tool calls.