Claude Code Setup Guide
Run AI Coding Assistant Locally on Your Computer
Introduction
This guide will show you how to set up Claude Code to run with local AI models on your
computer. Instead of connecting to Anthropic's cloud servers, you'll run everything locally,
which means it's free and doesn't require an internet connection for the AI to work.
What You'll Need
• A computer with sufficient resources (see model requirements below)
• Claude Code CLI tool installed
• Ollama or another local AI model server
• Basic command-line knowledge
Step 1: Choose and Download a Local AI Model
First, you need to get a coding-focused AI model that will run on your computer. The size of
the model you choose depends on your computer's capabilities.
Model Recommendations:
Computer Capability Recommended Models Model Size
Powerful Computer qwen3-coder:30b 30 billion parameters
Standard Computer qwen2.5-coder:7b 7 billion parameters
Lower-End Computer gemma:2b 2 billion parameters
How to Download (using Ollama):
ollama pull qwen2.5-coder:7b
Note: Replace 'qwen2.5-coder:7b' with whichever model you chose from the table above.
Starting Your Local Model Server:
Once downloaded, start the Ollama server:
ollama serve
This will start a local server that Claude Code can connect to. Keep this terminal window open.
Step 2: Install Claude Code
Claude Code is Anthropic's official command-line tool for AI-assisted coding. You'll need to
install it on your system.
Installation:
Install Claude Code using npm:
npm install -g @anthropic-ai/claude-code
Or if you prefer yarn:
yarn global add @anthropic-ai/claude-code
Verify Installation:
claude --version
Step 3: Configure Claude Code to Use Your Local Model
This is the crucial step. By default, Claude Code connects to Anthropic's servers. You need to
configure it to connect to your local AI model instead.
Set the Base URL:
Configure Claude Code to point to your local Ollama server instead of Anthropic's API:
export ANTHROPIC_BASE_URL=[Link]
Set a Placeholder API Token:
Since you're running locally, you don't need a real API key, but Claude Code requires one to
be set. Use any placeholder value:
export ANTHROPIC_AUTH_TOKEN=local-model
Tip: Add these export commands to your shell configuration file (~/.bashrc, ~/.zshrc, etc.) so
you don't have to set them every time.
Step 4: Start Using Claude Code
Now you're ready to use Claude Code with your local AI model for real coding tasks!
Navigate to Your Project:
Go to any project folder where you want to work:
cd /path/to/your/project
Start Claude Code:
Launch Claude with your chosen model:
claude --model qwen2.5-coder:7b
Replace 'qwen2.5-coder:7b' with whichever model you downloaded in Step 1.
What Claude Code Can Do:
• View and analyze files in your project
• Write and modify code across multiple files
• Debug and refactor existing code
• Create complete applications from scratch
• Execute commands and see results
• Work with various programming languages and frameworks
Example: Create a Hello World Website
Once Claude Code is running, you can give it natural language instructions:
Make a hello world website
What happens next:
• Claude will analyze your project structure
• It will create or modify HTML, CSS, and JavaScript files as needed
• You'll see it working through each file in real-time
• The website files will be created in your project directory
Benefits of Running Locally
Benefit Description
No Cost No API fees or subscription costs - completely free
Privacy Your code never leaves your computer
Offline Work Works without internet connection once set up
No Rate Limits Use as much as you want, no throttling
Full Control Choose and customize your AI model
Troubleshooting
Common Issues and Solutions:
Issue: 'Connection refused' error
Solution: Make sure Ollama is running with 'ollama serve' in a terminal window.
Issue: 'Model not found' error
Solution: Verify you've pulled the model with 'ollama list' to see installed models.
Issue: Slow performance
Solution: Try a smaller model (like gemma:2b) if your computer struggles with larger models.
Issue: Auth token warnings
Solution: These warnings are normal when running locally and can be safely ignored.
Additional Resources
• Anthropic Documentation: [Link]
• Claude Code GitHub: [Link]
• Ollama Documentation: [Link]
• Model Library: [Link]
Guide created based on setup instructions from Charlie Hills (@charliejhills)