Claude Code can work on an owned repository through a model served by Ollama on your machine. Ollama's current Claude Code integration connects directly through its Anthropic-compatible API. This guide takes one bounded code change from a recorded baseline to a human decision about the diff. It is for a developer who can install both tools, authorize edits in the repository, and run a suitable local coding model. BIG CHANGE checked the manuals on 20 October 2026; we did not run the model or test a repository.
The big change
- What changed: Ollama now documents a direct Claude Code route to its local Anthropic-compatible server, with a launcher or explicit local endpoint settings. A separate proxy is unnecessary for this documented setup.
- Why it matters: You can keep the Claude Code workflow while choosing a local model, checking its actual context allocation, and reviewing a real repository edit against the project's original acceptance check.
- What to watch: A selected local tag and a running model do not prove every request stayed local or that its code is correct. Check effective routing, tool access, the full diff and the check result before accepting the change.
1. Record the repository's starting point
Work in a Git repository you own or are authorized to change. Use a reviewable branch or disposable checkout. Name one small behavior or defect to change, the files it may affect and a stop condition. Find the repository's existing acceptance command, such as its documented test or build check; do not substitute a generic command. Run it before the agent edits anything and record the command, exit status and relevant output. Record the branch, git status and any existing diff too. Existing changes belong in your baseline, not in an AI result.
Confirm your organization's code and dependency policies permit the chosen model and tools. Claude Code may read files and run commands under its effective permission settings. A request to “touch only these files” guides the agent but does not confine its filesystem access.
2. Install a fitting local model and allocate context
Install a current Ollama release and Claude Code CLI through their official instructions, subject to your machine and organization rules. Record ollama --version and claude --version. Ollama introduced Anthropic Messages compatibility in version 0.14.0 in January 2026; that date does not establish the minimum version for today's ollama launch command.
Choose a model whose current catalog entry shows tool support, whose license permits your use, and whose weights and context allocation fit your machine. One concrete local example is qwen3-coder:30b, listed with tools, a roughly 19 GB Q4_K_M artifact and Apache License 2.0. That is a download size, not a RAM or VRAM requirement. Its advertised model context does not mean your machine can allocate it. If this model does not fit, choose another documented tool-capable local tag and replace the tag consistently in the following commands.
From a terminal, after the Ollama app or local server is running, download and confirm the exact tag:
ollama pull qwen3-coder:30b
ollama listOllama recommends at least 64,000 tokens for coding agents and says a larger context uses more memory. Set 64k or more in the existing Ollama app's settings, if your hardware supports it. If you operate the server yourself, configure that existing service with OLLAMA_CONTEXT_LENGTH=64000 using the platform-specific server instructions; do not start a second server on port 11434. After a model request loads, ollama ps shows its actual CONTEXT and PROCESSOR. Stop or reduce task scope and choose a fitting setup if the intended allocation cannot load. Do not report the catalog's maximum as the allocated context.
3. Route Claude Code to the local server
Open a terminal in the chosen repository. Ollama documents this launcher route; use the same local tag confirmed by ollama list:
ollama launch claude --model qwen3-coder:30bOllama documents this non-Claude model route. Anthropic's gateway manual says Anthropic does not support routing Claude Code to non-Claude models through a gateway. Treat this as an Ollama-documented integration without Anthropic support for that routing, and check the actual session before relying on it.
For a manual setup, Ollama's integration instructions instead use ANTHROPIC_AUTH_TOKEN=ollama, an explicitly empty ANTHROPIC_API_KEY, and ANTHROPIC_BASE_URL=http://localhost:11434. This optional Bash command sets all three for this Claude Code process only, from the owned repository directory; it does not change a global shell profile:
ANTHROPIC_AUTH_TOKEN=ollama ANTHROPIC_API_KEY="" ANTHROPIC_BASE_URL=http://localhost:11434 claude --model qwen3-coder:30bFor other shells, use the preferred Ollama launcher above or the current first-party manual's shell-specific setup. Inspect existing Claude Code settings that may override the command's variables. Do not print any pre-existing credential while checking settings. The expected effective readback is the chosen local tag and http://localhost:11434; that is a check for the reader to perform, not a result BIG CHANGE observed. The local server ignores the ollama placeholder token; it is not an access-control secret. The documented local route does not require an Ollama cloud key or an Anthropic inference key. Claude Code software terms and connected services still apply.
Keep the server bound locally under Ollama's server configuration guidance. A :cloud tag or https://ollama.com base URL is a cloud route with a different data and cost decision. Pause before sending repository content if the model or destination is unclear.
4. Check the route, then request one edit
Before allowing file changes, inspect Claude Code's effective model and connection with /status where available. Compare that readback with the launcher or manual endpoint, ollama list, and, after a request loads the model, ollama ps. Record the exact loaded tag, allocated CONTEXT and PROCESSOR; a CPU split may change whether the workflow is practical. Where available, inspect the local server's request evidence as well. These checks establish configuration and model loading, not a complete audit of all network traffic. Review enabled MCP tools, web fetch/search, telemetry and any cloud settings separately if local handling matters to your code policy.
Use Claude Code's normal approval prompts and permission controls. Ask for the single owned-repository task in ordinary language: identify the required behavior, allowed scope, original acceptance command and where to stop. Ask it to report changed files and check output. Keep commit, push and release decisions with the repository owner, and decline unexpected network or tool actions. A model's claim that it used the local endpoint or passed a check is not verification.
5. Decide from the full diff and the original check
Inspect every changed file and the full Git diff, including changes outside the requested scope. Compare the change with the original behavior and repository policy, including any new dependency's license. Run the same recorded acceptance command yourself after the edit. Record its exit status and relevant output alongside the baseline. Accept the change only when the diff matches the request, the independent check gives an acceptable result, and the routing and permissions evidence meets your requirements. Otherwise leave the branch unaccepted and retain the exact failure for review.
If Ollama cannot be reached, check the running app or service and ollama list before trying the coding task. If the model cannot load or ollama ps reports insufficient context, check memory and the context setting; use a smaller scoped task or a fitting local model. If /status or effective settings show a hosted provider, stop before sending code and repair the current shell or Claude Code settings. A tool-call error may come from model compatibility or a permission denial; inspect the exact response before changing either. If an attempt already edited files, inspect its diff before reverting or continuing. After a failed acceptance check, diagnose the code and rerun the check only after a reviewed correction.
Local inference avoids a provider's per-token inference charge for the downloaded model, but it uses hardware, storage and electricity. Downloads, telemetry, web tools, MCP integrations or cloud model settings may send data or incur other costs. Ollama supports a subset of Anthropic's Messages API, with limits on features including token counting, prompt caching, batches, citations, PDFs and forced tool choice; individual models also vary in tool ability. There is no measured speed, quality, privacy or savings result from BIG CHANGE's documentation review. For a different local-agent setup, see our Junie Local guide; this procedure specifically retains Claude Code and checks its Ollama route.
Sources & further reading
- Ollama, “Claude Code” gives the current launcher, manual local settings and cloud alternative. It documents a route, not a successful run in a reader's repository.
- Ollama, “Anthropic compatibility” describes the local endpoint, ignored placeholder token, model pull and API feature limits. Compatibility does not certify every model or tool call.
- Ollama, “Context length” explains the 64k coding recommendation, memory trade-off and
ollama psreadback. The actual machine determines feasible allocation. - Ollama's qwen3-coder:30b entry lists the example artifact, tools and linked Apache 2.0 license. Recheck the exact model entry before downloading or redistributing it.
- Claude Code installation and permission settings describe access and tool approvals. Neither proves a specific session's effective endpoint or safe repository outcome.
- Anthropic, “Other LLM gateways” states that Anthropic does not support routing Claude Code to non-Claude models through a gateway. Ollama separately documents the local integration described here.



