Running Claude Code locally with Ollama lets you use an AI coding assistant without relying on cloud APIs on Windows 11, macOS, or Linux. This means better privacy, no API costs, and offline capability.

Run Claude Code Locally with Ollama

Thanks to Ollama’s compatibility with the Anthropic API, you can connect Claude Code to local models and run everything directly on your machine.

Step 1: Install Ollama

Ollama is the engine that runs AI models locally.

1. Download it from the official website or install via terminal (for windows):

irm https://claude.ai/install.ps1 | iex
Download Olama: Run Claude Code Locally
Download Olama

2. After installation, verify it’s running by visiting:

http://localhost:11434

Ollama runs in the background and serves models locally.

Step 2: Download a Local Model to Run Claude Code Locally

Next, you need an AI model to power Claude Code.

Example:

ollama pull glm-4.7-flash

You can also try:

qwen3-coder
gemma
gpt-oss
Download a Local Model
Download a Local Model

Choose based on your system RAM (larger models need more memory).

Step 3: Install Claude Code

Claude Code is a terminal-based AI coding assistant.

Install it using:

npm install -g @anthropic-ai/claude-code
Install Claude Code: run Claude code locally
Install Claude Code

This tool lets you write, edit, and debug code using natural language.

Step 4: Connect Claude Code to Ollama to Run Claude Code Locally

Now link Claude Code to your local Ollama server.

Add these environment variables through your terminal:

export ANTHROPIC_BASE_URL="http://localhost:11434"
export ANTHROPIC_AUTH_TOKEN="ollama"
export ANTHROPIC_API_KEY=""
Connect Claude Code to Ollama: run Claude code locally
Connect Claude Code to Ollama

Then, reload your terminal:

source ~/.bashrc
Reload Terminal
Reload Terminal

This tells Claude Code to use your local AI instead of the cloud.

Step 5: Launch Claude Code Locally

Now you can run Claude Code using your local model:

ollama launch claude --model glm-4.7-flash

Or:

claude --model glm-4.7-flash
Launch Claude Code Locally
Launch Claude Code Locally

You’ll now see Claude Code running directly in your terminal, powered by your local model.

Step 6: Start Coding with AI

Once running, you can:

  1. Ask it to write code.
  2. Debug errors.
  3. Refactor files.
  4. Automate development tasks.
Start Coding with AI
Start Coding with AI: Run Claude Locally

Claude Code can read and modify files in your working directory, acting like a real coding assistant.

System Requirements

  1. Minimum 8–16GB RAM (32GB recommended for large models).
  2. GPU improves performance significantly.
  3. Works on Windows, macOS, and Linux.

Summary

With Ollama, you can run Claude Code entirely on your local machine using open-source models. The setup is simple: install Ollama, download a model, connect Claude Code, and launch it. This gives you a fully private, free, and powerful AI coding assistant without relying on external services.

Leave a Reply

Your email address will not be published. Required fields are marked *