Before you start · 20 minutes
Building with an agent, against your own model
Nothing yet. This is the twenty minutes that makes the next four projects go quickly: where the agent fits, what to tell it, and how to read what it hands back. Every project after this one carries its own instructions for both agents, so this is the only time the workflow is explained rather than used.
- Claude Code
- Codex
- Pip
Before you start
- Running in Pip: a text server.
- 8 GB of memory or more. Less than that and the model you need will not load.
- Installed already: A terminal, Claude Code or Codex.
Worth reading first: What "local AI" means, The tools people use.
Building it with an agent
There are two different models in play and it is worth being blunt about which is which, because almost every confusion on this surface comes from mixing them up. The agent that writes your code is a large cloud model with a long context and a lot of training on code. The model your finished app talks to is the one running on your own machine through Pip. You are using the first to build software that depends only on the second. When the app ships, the cloud model is gone and your machine is doing the work on its own.
With Claude Code
Claude Code reads your files and runs commands, so it wants the situation rather than a specification. Open a terminal in an empty folder and tell it what you are trying to make and what it is allowed to assume:
I want to build <the thing>. It must talk only to a local
OpenAI-compatible server at http://127.0.0.1:8081/v1 — no
cloud API, no API key that matters, nothing leaves this
machine. Use the openai package pointed at that base URL.
Start by writing the smallest version that proves the
connection works, and let me run it before you build on it.
That last sentence is the one that matters. An agent given a whole project will happily write all of it before you have confirmed the first request even reaches your model, and then you are debugging four things at once.
With Codex
Codex asks fewer questions back, so give it more of the shape up front — the file layout, the endpoint, and the constraint — in one instruction:
Create a Python project with this layout:
main.py, requirements.txt, README.md
It talks to an OpenAI-compatible server at
http://127.0.0.1:8081/v1 using the openai package with
api_key="not-needed" and base_url set to that address.
No cloud calls anywhere. main.py should <do the thing>.
Handle a connection error by telling the user their local
server is not running, rather than raising a traceback.
The last line is worth keeping in every instruction you write. A refused connection is the single most common thing that goes wrong on this surface, and an agent will not think to handle it unless you say so.
Read what it gave you
Generated code is a draft. These are the things that go wrong on this particular project, in roughly the order they are worth checking.
- Is the base URL actually local? Search the generated code for "api.openai.com" and for "anthropic". A model trained on thousands of cloud examples will sometimes reach for one out of habit, and the code will look perfectly correct while quietly not being the thing you asked for.
- Is there a real API key in the file? There should not be. Local servers do not check it, so "not-needed" is the honest value. If the agent invented one, it is a habit, not a requirement.
- Does it stream, and did you want it to? Streaming feels much faster on a local model because the first token arrives long before the last. An agent will not add it unless asked.
- What happens when the server is off? Run the code with Pip stopped. A traceback is a bug you have not fixed yet.
- Is the context window respected? Your local model has a much shorter one than the agent that wrote the code. A script that pastes an entire document into one request works on a cloud model and fails on yours.
- Can you explain every line? If you cannot, you have a dependency you do not understand in something you are about to rely on. Ask the agent to explain it, then decide whether to keep it.
Where to take it next
- Keep a CLAUDE.md or AGENTS.md in each project folder saying "this project talks only to a local model at 127.0.0.1:8081, never a cloud API". Both agents read it, and it stops you repeating the constraint every session.
- Try giving the same instruction to both agents and diffing what comes back. The differences tell you a lot about what each one assumes when you have not said.
- Once a project works, ask the agent to write the tests for it — then read them, because tests an agent wrote against code an agent wrote can agree with each other and both be wrong.