---
title: "How to Run Claude Code on a Local Model on Mac"
description: "One switch in ToolPiper runs new sessions of your normal claude on a model on your Mac. Open sessions stay put, and Off puts your settings file back."
date: 2026-08-29
updated: 2026-11-06
author: "Ben Racicot"
tags: ["Claude Code", "Text Generation", "Local Inference", "Privacy", "macOS", "Apple Silicon", "Developer Tools"]
type: "article"
canonical: "https://modelpiper.com/blog/claude-code-local-model-mac"
---

# How to Run Claude Code on a Local Model on Mac

> One switch in ToolPiper runs new sessions of your normal claude on a model on your Mac. Open sessions stay put, and Off puts your settings file back.

## TL;DR

Turn on the Engine switch in the Claude Code row on ToolPiper's Home screen and pick a model. New sessions of your normal claude run on that model, and sessions already open stay as they are. A local model needs a trained context window of at least 98,304 tokens and enough memory. The switch writes a few entries to Claude Code's user settings and puts the file back as it found it when you turn it off.

Claude Code talks to Anthropic. That is the whole product, and most days it is the right answer. But some work cannot leave the machine, some of it happens on a plane, and some of it is a loop you do not want metered. For those, you want the same agent answering from a model on your own hardware.

In ToolPiper that is one switch. You keep typing `claude`, and the sessions you already have open keep doing what they were doing.

## What actually changes when you do this?

ToolPiper writes a few entries to Claude Code's user settings file, ~/.claude/settings.json: its own address on 127.0.0.1, the models you can run, and a command that hands Claude Code a token. Each new claude session reads that file when it starts and answers from the model you picked. Turn the switch off and the file goes back as ToolPiper found it.

Byte for byte, when nothing else changed in it, spacing and key order included. If you edited the file while the switch was on, your edit survives and the file comes back in sorted form. A value of your own for a key the switch wrote comes back too.

We built it this way because a second command for the same agent was the wrong shape. Claude Code reads settings at launch and has documented keys for a gateway and a model list, so one `claude` can do both jobs.

## What happens to the sessions I already have open?

Nothing. A session already running stays where it is, because a long conversation should never land on a smaller model because of a click in another window. Only new sessions start on the engine.

The way this works: Claude Code applies a settings change to every running session, so the switch first writes a `ConfigChange` hook on its own, and only after sessions have loaded it does it write the engine's entries. The hook makes any session not on the engine refuse the change. A new session reads the file at launch, runs no hook, and starts on the engine.

The catch is that while the switch is on, a session not on the engine takes no edit to that file at all, your own included, since Claude Code reloads the file all or nothing. Those edits arrive when you turn it off.

## What you need

**You don't need:** an API key for a local model, a Docker container, Python, a config file you write by hand, or an internet connection once the model is downloaded.

**You do need:** a Mac with Apple Silicon, ToolPiper running, the official `claude` CLI, and a language model the switch can offer. ToolPiper never installs a language model on its own, so choose one first: open **Choose a language model** on Home. Gemma 4 E4B, Gemma 4 12B and Qwen 3.8 27B all qualify, and the switch lists what fits your Mac. A cloud model you added runs on your own account and needs Pro.

## Why does a local model need a window of 98,304 tokens?

Claude Code holds about 33K back for compaction whatever the window is. At its lowest setting it compacts between 65K and 70K of usage, and the window still has to hold the reply and the compaction. So the switch offers a local model only if it was trained for at least 98,304 tokens and fits your Mac's memory.

Your local chats don't change. ToolPiper runs a chat at that chat's own window and gives Claude Code a separate entry of the model at 98,304. That separation has a cost: the same model in chat and in Claude Code at once loads twice, so its memory counts twice.

## How long does a turn take on a local model?

It depends on the model and on how much of the window the conversation fills. The longest wait is compaction: on a large local model, a turn that holds a compaction takes minutes. Smaller models get there sooner.

Claude Code's prompts are large before you type anything, and a repo with a big `CLAUDE.md` starts close to the compaction point. Every reply still arrives on your Mac with nothing metered. Pick the model to fit the work: a small one for the loop you run all day, a larger one when the reasoning matters and you can wait for it.

## Can I use more than one model?

Yes. `/model` inside Claude Code lists every model the switch can offer, local and cloud together. Each model compacts at its own number, so sessions on different models run side by side without one limit for all of them. A model you add while a session is open compacts at its own number from the next new session.

## How does Claude Code get the credential?

ToolPiper mints a narrow token that can only reach chat and its Messages endpoint, and stores it in ToolPiper's own folder as claude-code-engine.key with mode 0600. The settings file names a command that prints it, so the token never enters the settings file.

Off revokes the token. The settings also blank Claude Code's credential keys, so a key exported from your `.zshrc` doesn't reach ToolPiper ahead of the token.

## How to tell it worked

Start a new session and type `/model`. It lists ToolPiper's models and only those. The Claude Code row on Home names the model and says whether it runs on your Mac or on your own cloud account.

## When it doesn't work

### "Claude Code needs at least 98K"

The row names your model and its window. Choose a model trained for at least 98,304 tokens that fits your Mac, and the switch offers it.

### The switch says your settings already name something

Settings that name another server, credential helper, credential, pinned model, context window or their own `modelPicker` are yours, and the switch could not put them back. It says so and writes nothing. The same goes for hooks turned off in your settings or by a policy on this Mac, a Claude Code older than the release this was measured on, and a settings file that isn't JSON.

### `model_not_found` after turning it off

A session where you picked a model with `/model` keeps that pick, and Anthropic doesn't know the name. Run `/model` again in that session and nothing is lost. A session that never picked one comes back on its next message.

### A session says it can't connect

ToolPiper closed while that session was on the engine. It stays pointed at ToolPiper so your code never moves to the cloud because an app quit. Reopen ToolPiper, or start a new session, which runs normally because Quit takes the entries out of the file. If ToolPiper crashes or the Mac loses power, a small launchd agent does the same cleanup.

### "command not found" for `claude-tp`

Earlier builds shipped a separate launcher called `claude-tp`. It is gone, along with the `claude_code_install` and `claude_code_uninstall` tools. A `~/.local/bin/claude-tp` link left from one of those builds fails with a plain not-found and harms nothing, and `rm ~/.local/bin/claude-tp` clears it. ToolPiper revokes the old launcher's token and deletes its config by itself.

## What about the tools?

Engine decides which model thinks. Tools decide what the agent can do: browser automation, screen capture, transcription, system control, scraping and the rest. They are two separate switches on the same row, and you can have either, both or neither.

The Tools switch runs Claude Code's own command for you. By hand it is:

```
claude mcp add -s user --transport http toolpiper http://127.0.0.1:9998/mcp
```

`-s user` makes it work in every folder. Without it the server exists only in the folder you ran it in. A new session has the tools, and a session already open picks them up with `/reload-plugins`. The address is the IPv4 literal `127.0.0.1` and not `localhost`, because ToolPiper's listener is pinned to IPv4 loopback and macOS resolves the name to IPv6 first.

## What this does not do

It does not route a Claude subscription through ToolPiper. While the switch is on, `/model` in a new session lists ToolPiper's models, and a new session on your Anthropic account means turning it off. Sessions already open stay on your account either way.

It also does not make every model the right one for every job. Long multi-file refactors and deep reasoning across a large context reward a larger model, local or cloud. The small local model is for the loop you run fifty times a day, for anything under NDA, and for the flight.

## Try it

Download ToolPiper at [modelpiper.com](https://modelpiper.com), choose a language model on Home, and turn on **Engine** in the Claude Code row.

## Steps

### 1. Choose a model ToolPiper can run for Claude Code

Open **Choose a language model** on ToolPiper's Home screen. A local model needs a trained context window of at least 98,304 tokens and enough memory on your Mac; Gemma 4 E4B, Gemma 4 12B and Qwen 3.8 27B all qualify. A cloud provider you added works too, and needs Pro.

### 2. Turn on Engine in the Claude Code row

Find **Connect your coding agent** on Home and turn on **Engine** in the Claude Code row. It takes a few seconds, then the row shows a picker with every model it can offer. If it can't offer one, or your settings already name another server or credential, the row says why and writes nothing.

### 3. Start a new claude session

Run `claude` as you always do. A new session starts on the model you picked. Sessions you already have open stay as they are, and keep working the whole time.

### 4. Confirm it with /model

Type `/model`. It lists ToolPiper's models, local and cloud together, and you can move this session to another one from there. The first message also loads a local model.

### 5. Turn it off whenever you want

Turn the switch off. New sessions go back to your Anthropic account, a session that was on the engine moves back on its next message, and the settings file returns as ToolPiper found it. If you picked a model with `/model` in a session, run `/model` once more there.

## FAQ

### Does this change my existing Claude Code setup?

While it's on, yes, in one file. Engine writes a few entries to Claude Code's user settings, `~/.claude/settings.json`. Turning it off puts the file back as ToolPiper found it, byte for byte when nothing else changed. If settings there already name another server, credential or pinned model, the switch tells you and writes nothing.

### Will it interrupt the sessions I have open?

No. Only new sessions start on the engine. Sessions already open stay on your Anthropic account and keep answering through both clicks.

### Can I use both a local model and Anthropic's models?

Yes, at different times or in different windows. A session opened before you turned Engine on stays on your Anthropic account while new sessions run on ToolPiper's models. Turn the switch off and new sessions go back to your account. Claude Code doesn't offer one `/model` list that holds both a subscription and a local model today, because every row goes to one address.

### Where is the credential stored, and can other processes read it?

The token lives in `claude-code-engine.key` in ToolPiper's own folder, `~/Library/Application Support/ToolPiper/`, with mode `0600`, so only your user account can read it. It can reach chat and the Messages endpoint and nothing else, and it never enters the settings file. Off revokes it.

### Does my local chat change?

No. A local chat stays at its own window. Claude Code gets its own entry of the model at 98,304 tokens, so the same model in chat and in Claude Code at once loads twice.

### Do I need this to use ToolPiper's tools in Claude Code?

No. Tools are a separate switch on the same row, and it runs one command for you: `claude mcp add -s user --transport http toolpiper http://127.0.0.1:9998/mcp`. That works on stock Claude Code talking to Anthropic. Engine is for choosing where the model runs, which is a separate question from which tools are available.

### What happened to claude-tp?

Engine replaced it. The `claude-tp` helper and the `claude_code_install` and `claude_code_uninstall` tools are gone, and your normal `claude` does the job. An old `~/.local/bin/claude-tp` link fails with a plain not-found and harms nothing. Delete it whenever you like.
