Claude Code + Ollama: Coding with a Local Model
Claude Code is Anthropic's agentic coding tool. It reads your project, edits files, and runs commands from the terminal. With Ollama, you can run it on a model hosted on your own machine instead of in the cloud.
Why local models?
- Your code never leaves your machine
- No API costs
- Works offline
In this guide, you'll install Claude Code, run it inside IntelliJ IDEA, connect it to Ollama, and test it on a small Java project.
Step 1: Install Claude Code
Install it globally with npm:
npm install -g @anthropic-ai/claude-code
Then open a terminal and run:
claude
If the Claude Code prompt appears, the installation worked.
Step 2: Run It Inside IntelliJ IDEA
You don't need to leave your IDE. Open your project in IntelliJ, open the built-in terminal (View → Tool Windows → Terminal), and run:
claude
Claude Code now has access to your project files and works right next to your code.
Step 3: Connect It to Ollama
Ollama exposes an Anthropic-compatible API, so Claude Code can talk to a local model.
1. Install Ollama
Ollama lets you download and run language models on your own machine. Your code never leaves your computer and there is no per-request cost.
On https://ollama.com you can create a free account. The dashboard shows your free quota for cloud models. For the rest of this tutorial (100% local), it isn't required.
2. Pull a coding model:
ollama pull qwen3.5:9b
3. Point Claude Code at Ollama:
export ANTHROPIC_AUTH_TOKEN=ollama
export ANTHROPIC_BASE_URL=http://localhost:11434
claude --model qwen3.5:9b
On Windows PowerShell, use $env:ANTHROPIC_AUTH_TOKEN="ollama" and $env:ANTHROPIC_BASE_URL="http://localhost:11434" instead of export.
Alternatively, let Ollama handle the setup with one command, using --model
ollama launch claude --model qwen3.5:9b
Step 4: Build a Demo Project
Let's test the setup with a small Java project: a console task manager.
Create an empty Java project in IntelliJ, open the terminal, start Claude Code, and give it this prompt:
Create a simple Java console app: a task manager. Users can add,
list, complete and delete tasks. Save tasks to a text file so they
persist. Keep it to 2-3 classes.
Claude Code will plan the work, create the files, fix the errors, and ask for your permission before making changes. Approve the actions and watch it work.
Then run the app and try it out:
Notice that it doesn't only generate code. It also creates the files, runs the program, and fixes its own errors.
Cloud vs Local: Quick Comparison
| Cloud Claude | Local model (Ollama) | |
|---|---|---|
| Privacy | Code is sent to the API | Stays on your machine |
| Cost | Subscription / API | Free |
| Speed | Fast | Depends on your hardware |
| Quality | Highest | Good for small tasks |
Conclusion
Claude Code with Ollama is a practical way to try agentic coding without sending your code anywhere, as long as your machine can handle the model. Start with a small project like this one, then try it on your own code.
Thanks for reading!








Top comments (2)
Clear and simple
Well done, bro! 👏