DEV Community

TheCodeStreet
TheCodeStreet

Posted on

Claude Code For Free: Local Setup with Ollama + Qwen 3.8

I love Claude Code. I don't love watching the usage meter while I experiment.

So I tried running it against a local model instead. It works, it costs nothing, and the setup is shorter than this intro. Here's the TL;DR version.

The idea in one line

Claude Code can talk to any Anthropic-compatible endpoint. Ollama (0.15+) exposes one locally, so you swap the cloud model for Qwen 3.8 running on your own GPU.

Before you start

  • ~32 GB of memory between RAM and VRAM (the 27B model is ~18 GB)
  • ~20 GB free disk
  • A GPU helps a lot. Without one it runs, just slowly. ## 1. Install the two tools
# Claude Code (macOS / Linux / WSL)
curl -fsSL https://claude.ai/install.sh | bash

# Ollama (macOS / Linux). On Windows, grab the installer from ollama.com
curl -fsSL https://ollama.com/install.sh | sh

ollama --version   # needs 0.15 or newer
Enter fullscreen mode Exit fullscreen mode

Windows users can install Claude Code from PowerShell with irm https://claude.ai/install.ps1 | iex.

2. Run the one command

ollama launch claude --model qwen3.8:27b
Enter fullscreen mode Exit fullscreen mode

That's the whole trick. Ollama starts Claude Code wired to the local model. If you'd rather download first, run ollama pull qwen3.8:27b before it.

3. (Optional) Make it the default for a project

If you want plain claude to always use Qwen in a repo, drop this in .claude/settings.local.json:

{
  "env": {
    "ANTHROPIC_BASE_URL": "http://127.0.0.1:11434",
    "ANTHROPIC_AUTH_TOKEN": "ollama",
    "ANTHROPIC_API_KEY": "",
    "ANTHROPIC_MODEL": "qwen3.8:27b",
    "ANTHROPIC_DEFAULT_OPUS_MODEL": "qwen3.8:27b",
    "ANTHROPIC_DEFAULT_SONNET_MODEL": "qwen3.8:27b",
    "ANTHROPIC_DEFAULT_FABLE_MODEL": "qwen3.8:27b",
    "ANTHROPIC_DEFAULT_HAIKU_MODEL": "qwen3.8:27b",
    "CLAUDE_CODE_SUBAGENT_MODEL": "qwen3.8:27b",
    "CLAUDE_CODE_MAX_CONTEXT_TOKENS": "65536"
  }
}
Enter fullscreen mode Exit fullscreen mode

Two things worth knowing:

  • The auth token is required but ignored, and the empty API key stops a real key from being picked up.
  • Bump Ollama's context length to 64k so it matches 65536. Otherwise Claude Code loses track of your files mid-task. Keep this file out of Git. It's machine-specific.

Does it actually build things?

I gave it one prompt:

Create a simple Snake game in a single index.html file
using HTML, CSS, and vanilla JavaScript.
Use a neon cyberpunk design, arrow-key controls, score tracking,
collision detection, and a restart button.
No external libraries or files.
Save the complete, working code to index.html.
Enter fullscreen mode Exit fullscreen mode

It produced a working game first try: neon styling, arrow keys, score, collisions, restart. All on my machine.

The honest part

It's slower and less sharp than the hosted Claude models. For side projects, learning, and quick throwaway builds, though, I'm not going back to paying for every experiment.

Quick fixes if you get stuck:

  • command not found: start Ollama, then open a new terminal.
  • Model won't load: try a smaller Qwen size.

- Slow or forgetful: close GPU-heavy apps and raise the context length.

Full step-by-step guide (with troubleshooting and FAQ) is on my blog: Claude Code For Free: Local Setup with Ollama + Qwen 3.8.

Next up: the same free setup inside VS Code. Have you tried running coding agents on local models? What's your go-to model? 👇

Top comments (0)