Run Claude Code Locally (100% Free)

Run Claude Code completely free forever, locally on your device using open-weight models via Ollama

πŸ”’

Fully Private

No cloud, all local

πŸ’°

100% Free

No API keys needed

⚑

Open Weight

Use GPT-OSS models

Step 1

Install Ollama

Go to ollama.com

Download and install Ollama for your OS.

After installing:

  • Make sure Ollama is running (menu bar icon on Mac)
  • Do NOT quit it β€” keep it running in the background
Step 2

Increase Context Length

Very Important Step:

  1. Open Ollama
  2. Go to Settings
  3. Set Context Length to:
    • 32,000 (recommended)
    • or 64,000 (if your device can handle it)
  4. Close settings (don't quit Ollama)

This is required for:

  • Tool calling
  • File edits
  • Claude Code–style agent behavior
Step 3

Download GPT-OSS Model

We'll use GPT-OSS 20B, which works well with Claude Code.

Open Terminal and paste:

ollama run gpt-oss:20b

What happens:

  • First run β†’ model downloads
  • After download β†’ chat starts
  • Type bye and press Enter to exit

To confirm it's installed:

ollama list
Step 4

Verify Ollama Is Running

Open your browser and go to:

You should see:

Ollama is running

If yes β†’ you're good to go βœ…

Step 5

Install Claude Code

macOS:

brew install anthropic/tap/claude

Verify installation:

claude --version

You should see a version number (for example 2.1.x). If not, update Claude Code before continuing.

Step 6

Run Claude Code with Local Model

IMPORTANT STEP: Connect Claude Code β†’ Ollama β†’ GPT-OSS

Go to any folder where you want to code, then paste:

ANTHROPIC_AUTH_TOKEN=ollama \
ANTHROPIC_BASE_URL=http://localhost:11434 \
claude --model gpt-oss:20b

When prompted:

  • Trust the folder β†’ Yes
  • Allow file edits β†’ Yes

πŸ’₯ That's it. Claude Code is now running locally with an open-weight model.

Step 7

Test It

Try a real example to verify everything is working:

"Create a simple Python script that prints Hello World"

Claude Code should create the file, write the code, and confirm it's done.

Ready to Start?

Follow these 7 steps to run Claude Code completely free and private on your device.

Need More Information?

Read the official Claude Code documentation for advanced usage and troubleshooting.