freedzhost.cloud

Claude Code, two ways: on the subscription and on your own models

Claude Code is Anthropic's coding agent in the terminal. Most people use it one way: with a subscription, on Anthropic's models. It can also run on your own models, as long as something on your side speaks its protocol. We use both: the subscription for operations work, local models for an isolated junior that writes small patches all day.

What you get. The best of both worlds with one program: the frontier model when it matters, your own models for the hundred small patches of the day. Three variables switch between them.

1. On the subscription: the operations agent

npm install -g @anthropic-ai/claude-code
claude          # first run: sign in with your account

Give it a rules file at the root of the work folder, CLAUDE.md. It is read at every start. Write there what a newcomer must know: which machine is which, what never to do, how to hand work to the local agents. Keep it short and current: a rule superseded but left in place will be applied with full confidence.

2. Rules that are enforced, not read

A rule written in a file is advice. A hook is a program that Claude Code runs before each command, and that can refuse it. We turned three rules into hooks after each was broken once:

A hook is a small script that reads the planned command as JSON on its input and exits non-zero to refuse it, with a message the agent reads. Twenty lines of Python are enough.

3. Hooks beyond safety

Hooks fire at six moments: session start and end, each prompt you send, each tool about to run, each notification, and the end of each answer. Besides refusing dangerous commands, ours start and stop the music of Purrd while the agent works, and declare the agent's state to a console page that plays the sound in the browser. Settings also turn off telemetry and error reporting (DISABLE_TELEMETRY, DISABLE_ERROR_REPORTING).

4. On your own models: the junior

Claude Code speaks the Anthropic Messages API. A gateway such as LiteLLM translates it to your local models. Three variables are enough:

export ANTHROPIC_BASE_URL=http://your-gateway:4000
export ANTHROPIC_MODEL=coder-local            # the model name in the gateway
export ANTHROPIC_SMALL_FAST_MODEL=coder-local # otherwise it asks for a cloud model for small tasks
claude -p "Fix the failing test in tests/test_parse.py. Change only src/parse.py."

Before launching, check the model answers on $ANTHROPIC_BASE_URL/v1/messages: an agent started on a card that holds nothing fails after minutes, not seconds.

5. Isolate the junior

A local agent works without you watching. Give it a disposable copy of the repository, a closed list of files, the commit message, and a test to run. It opens a pull request; the CI runs; a human, or the operations agent, reads before merging. Short tasks come back clean; long ones break from fatigue, not difficulty.

Traps

Forget ANTHROPIC_SMALL_FAST_MODEL and the agent sends its small background tasks to a cloud model name the gateway does not know: errors that look like an outage.

Never paste your subscription credentials into the junior's environment. The two roles share a program, not an identity.

Sources

Found this useful? Tell us what to measure next.