Download any model you want with Ollama and use Claude Code to perform fully local, free, and unlimited code analysis and generation. Now you can review and develop your projects in a secure environment without needing an internet connection.
Ollama is a tool that lets you run different AI models on your computer. It is used to run AI applications like Claude Code fully locally and perform code analysis and generation without needing an internet connection.
Open your terminal or console and install Ollama using the following command.
curl -fsSL https://ollama.com/install.sh | shTo confirm the installation was successful and Ollama is running on your system, run the following command.
ollama listDownload any model you want using Ollama. For example, you can use the gemma4:e2b or Qwen2.5-coder:7b models. Run the commands below to make sure the model is downloaded.
Pull the model you want from Ollama. You can use the example models below.
ollama pull gemma4:e2b
ollama pull qwen2.5-coder:7bCheck that the model has been successfully downloaded and is ready to use.
ollama listOpen an editor like VSCode and create a .sh file to run Claude Code with the local model. This file will define which model to use and Claude Code's behavior settings.
Example file name: gemma4:e2b.sh or qwen2.5-coder.sh. After creating the file, paste the code below and save it.
#!/bin/bash
# Claude Code will use this model for code analysis and generation.
MY_MODEL="gemma4:e2b"
# Improves stability in code generation. Lower value produces more predictable code.
export OLLAMA_TEMPERATURE=0.2
# API address of the local Ollama server Claude Code connects to.
export ANTHROPIC_BASE_URL="http://localhost:11434/v1"
# API key for Claude Code to communicate with Ollama.
export ANTHROPIC_API_KEY="ollama"
# The model name used for Claude Code and subagents.
export ANTHROPIC_MODEL="$MY_MODEL"
# The model name used as a subagent inside Claude Code.
export CLAUDE_CODE_SUBAGENT_MODEL="$MY_MODEL"
# Skips project-specific settings; general settings apply for all projects.
export CLAUDE_CODE_SKIP_PROJECT_SETTINGS=1
# Activates Claude Code's system prompt. Model behavior follows predefined instructions.
export CLAUDE_CODE_USE_SYSTEM_PROMPT=1
# Defines how the model should behave; serves as a guide while coding.
export ANTHROPIC_CUSTOM_PROMPT="
You are a local AI software engineer running inside Claude Code.
Rules:
- Inspect repository before coding.
- Use file reading tools.
- Prefer editing existing files.
- Avoid hallucinating APIs.
- Explain which files you will modify before writing code.
- Focus on clean, maintainable and production-ready code.
- Do not use google_search.
"
# Starts Claude Code and prints the model being used.
echo "Starting Claude Code with local model..."
echo "Model: $MY_MODEL"
ollama launch claude --model "$MY_MODEL"Run the .sh file you created from the terminal to start Claude Code. This way, your selected model, subagents, and custom prompt can perform code analysis and generation completely locally.
You can now send commands via VS Code, Cursor, or the Claude Code interface to generate code, review files, and perform analysis. Subagents will run automatically in the background.
./gamma4.sh