Notes8 min · 16 Aug 2026

What happens when a program runs?

Typing one word starts a chain that runs from a program on your machine to a model on someone else's, then down through memory and the processor to switches, and back out as light on the screen.

  1. 01The question
  2. 02The harness and the model
  3. 03Where each one runs
  4. 04What starting a program means
  5. 05Why a computer gets slow
  6. 06Cores, threads and taking turns
  7. 07Many simple cores: the GPU
  8. 08From instructions to switches
  9. 09Where true and false came from
  10. 10Back to typing claude

01The question

Claude Code can run models other than Claude. People point it at Kimi or GPT and it carries on working, which makes plain what it is: not the model, but the program round the model, the . That raises the question this note follows down. If the harness isn't the clever part, what does it actually do? And when you type claude, what runs, where, and on what?

It builds on How does my terminal find a tool?, which covers how the shell finds the word you typed, and What actually runs my code?, which sets out engine, harness and environment.

02The harness and the model

A language model does one thing: it reads text and writes text. It can't open a file, run a command or decide to stop, because it has no way to touch anything. The harness is the part with hands. It sends the model the conversation, reads what comes back, and acts on it.

That works because what comes back is structured. When the model wants something done, it writes a : not a vague request, but data in an agreed shape, such as which tool, which file, which text to replace with which. From there the harness needs no intelligence at all. It is ordinary code: does that text appear in the file exactly once? Then replace it and write the file; if not, say why. The loop round it is just as plain. Send the conversation, get a reply; if the reply contains a tool call, run it, add the result to the conversation and go again; if it doesn't, the turn is over.

Fig 01
Step 1 of 7
  1. You
    Type a request
    Say hello instead of hi
One turn of an agent, step by step. Ink is the model; outlines are the harness.
  • The model decides: which file matters, what to change, whether the work is finished.
  • The harness does: checks the change applies, writes it to disk, runs the command, enforces limits on time and steps, and chooses what the model is shown in the first place, since a whole codebase never fits.

Without a model, the harness can load its settings and wait. It can carry out a tool call, but it can never decide to make one. And because its code doesn't depend on whose model answers, it can talk to any model that accepts the same request shape and replies with tool calls it can read; Claude Code reads an environment variable for the address it sends requests to. A different model may still stumble in it, because the harness was tuned against Claude's habits.

The model proposes in text. The harness turns text into consequences.

03Where each one runs

The harness runs on your machine. It is a program like any other, loaded into your memory as a . The model doesn't: it is far too large for a laptop and needs racks of GPUs, so it stays loaded on the provider's servers, answering huge numbers of conversations at once. The API is neither of them. It is the wire between: a request carrying the conversation goes out over the internet, a reply comes back.

So the harness is in your memory, the model is in someone else's, and the API joins the two. It is also why the program feels the same on a cheap laptop as an expensive one: the heavy work never happens on your machine. Where it runs follows the same request from the server's side.

04What starting a program means

~/.local/bin/claude is a , and the real program is elsewhere, in ~/.local/share/claude. That split is on purpose. ~/.local/bin is a shared shelf on where many tools put a small entry, so the shell only has to look in one place; each tool keeps its real files in a folder of its own. (/usr/local/bin is the same idea for every account on the machine; ~/.local/bin is for yours alone.)

Following the link isn't the shell's job. The shell asks the to run a path, and the kernel resolves links as it opens any file, for any program. From there it does the same for every program, whether it was typed or double-clicked.

Fig 02
Step 1 of 6
  1. Shell
  2. Kernel
  3. Disk
  4. Memory
  5. Core

zsh reads claude and searches PATH. It finds ~/.local/bin/claude.

From a word typed to a program running. Each step is done by whatever is in ink.

A program file is bytes: instructions for the processor, and data. Running it means the kernel sets up a new process with its own private memory and a number, its PID, maps the file into so its bytes can be read at memory speed, and points a processor core at the first instruction. A program with windows goes through the same steps; it just has more code once it's running, an event loop waiting for clicks. And one process starts another: the terminal starts the shell, /bin/zsh, and the shell starts claude. Activity Monitor, or ps and top in a terminal, lists them all with their PIDs.

05Why a computer gets slow

Every open program holds a share of RAM until it quits, and RAM has a fixed size. When it fills, the system doesn't refuse. macOS first squeezes memory that hasn't been touched lately, then moves some of it out to the disk, into , to make room. The disk is far slower than RAM, so a machine that keeps moving memory in and out of it slows to a crawl. That is the usual cause of everything freezing with too much open.

The other cause is the processor itself: too many programs wanting to compute at the same moment, so they wait their turn. That is the subject of the next section, and it shows as stutter rather than a freeze.

06Cores, threads and taking turns

A is the part of the processor that executes instructions: fetch one, carry it out, fetch the next, billions of times a second. One core follows one stream of instructions at a time. Those streams are : every process has at least one, and many have dozens.

There are always far more threads than cores. The system gives each runnable thread a few milliseconds on a core, then takes it off and puts another on, so quickly it looks simultaneous. Each swap is a , and it isn't free. More cores means more threads truly running at once; it doesn't end the taking of turns.

Fig 03
Core 1
A
B
A
B
B
D
A
B
E
A
B
A
  • AVideo export
  • BBrowser page
  • CMusic
  • DChat app
  • EEditor
  • FSync

15 times a thread had work and waited for a core. Each hand-over is a context switch.

Six threads, most of them idle, shared over the cores. Each column is a few milliseconds.

Eight cores doesn't mean eight apps. An open app is mostly idle: a chat app waiting for a message, an editor waiting for a key. It is loaded in memory but asks for no core until it has work. On one Mac at a quiet moment, Activity Monitor counted 585 processes and 3,677 threads, with the processor 88% idle. A browser shows the other side: Brave lists a renderer process per site, each with its own PID, so that one crashing page can't take the rest down, and each with twenty-odd threads doing rendering, scripts and network inside it.

Apple's chips also mix two kinds of core. Performance cores are large and fast; efficiency cores are small and frugal, and the system sends background work to them. An M1 Pro has eight or ten cores, two of them efficiency cores.

07Many simple cores: the GPU

A CPU core is a generalist, built to follow code full of decisions: if this, do that, remember what happened three steps ago. Each core is large, so a chip has only a handful. A goes the other way: thousands of small arithmetic units that do little deciding, arranged so that one instruction is carried out on many pieces of data at once. An M1 Pro's GPU has up to 16 cores, and each is a block of many such units.

Brightening a 4K image means multiplying about eight million pixel values by the same number. A CPU works through them a few at a time; a GPU gives each unit a different pixel and does thousands in one step. Running a language model is the same shape of work, mostly multiplying very large tables of numbers, which is why models run on GPUs, and why Why does thinking harder cost more? counts its cost in GPU work.

08From instructions to switches

is numbers. On an Intel Mac, the two bytes 10110000 01100001 mean put the number 97 into a register. Apple's own chips use a different instruction set, ARM, where every instruction is 32 bits, but the idea is the same: a bit pattern, and nothing else.

A pattern means something only because the processor was built to react to it. Part of each core, the decoder, is a tree of that looks at the bits and sends a signal down one line out of many: the line that sets the adding circuit going, or the one for moving a value. Change one bit and a different line lights. Nothing is read or interpreted; the meaning was fixed when the chip was designed.

The circuits on those lines are gates too, and gates are switches. A transistor lets current through or doesn't, and Why does thinking harder cost more? shows how a few of them make AND, OR and NOT. Wire an AND and an XOR side by side and you have a half adder, the start of the circuit that adds.

Fig 04
A
B
Switch A1
Switch B1
XOR gate
One or the other, not both
AND gate
Both
Sum0
Carry1
ABCarrySumA + B
00000
01011
10011
11102

1 + 1 = 2. Carry 1, sum 0: 10 in binary.

A half adder. Set the two inputs and watch which outputs carry current. 1 + 1 comes out as 10, two in binary.

The intelligence isn't in the electricity. It was put into the shape of the wiring, once, and current follows the shape.

Everything that looks like a decision comes down to these. Does claude exist in this folder? Is this file a link? Does this bit pattern match ADD? Each is a yes or a no, a 1 or a 0, and opening a program is millions of them, one after another, too fast to see.

Data is bits too. The letter A is stored as the number 65, 01000001, because the people who drew up ASCII in the 1960s agreed it would be; Unicode kept the same number. That byte is data, not an instruction. To show it, a program runs ordinary instructions that look up 65 in a font, which describes the shape of the letter, and draw that shape. The drawing ends up in a , a block of memory holding the colour of every pixel, which the display hardware reads from top to bottom 60 or 120 times a second and turns into light. Nothing decides to show you anything: the screen simply keeps reading that memory.

09Where true and false came from

None of this began with machines. Around 350 BCE, Aristotle noticed that some arguments hold because of their shape, whatever they are about: if all X are Y, and Z is an X, then Z is Y. Logic treated every statement as either true or false, and studied the shapes.

  • 1854. George Boole wrote logic as algebra, which is arithmetic with symbols standing for any value: true as 1, false as 0, AND behaving like multiplication. Checking an argument became a calculation. (The word comes from al-jabr, in a book by al-Khwarizmi, whose name also gives us algorithm.)
  • 1937. Claude Shannon, in his master's thesis, showed that circuits of switches carry out Boole's algebra exactly: switches in series are AND, in parallel are OR.
  • After that, the switch kept shrinking: relays that clicked, vacuum tubes, the transistor in 1947, many transistors on one chip in 1958. An M1 Pro has 33.7 billion.

Each step kept the idea and made the switch smaller. A half adder works the same in relays as in the chip in a laptop.

10Back to typing claude

The shell, itself a program in /bin, finds claude on PATH. The kernel follows the link, maps the program into memory and starts a process. A core runs its instructions, each one a bit pattern lighting one line in the decoder and sending current through gates. The program, the harness, sends your words over the API to a model on someone else's GPUs and acts on the tool calls that come back. When it prints a reply, instructions draw letters into the framebuffer, and the display turns that memory into light.

Every layer is a story told about the one under it. At the bottom, current is let through or stopped, in a pattern someone designed to mean something.

Connected

  • Note · same thingSuggested
    What actually runs my code?

    The harness and engine of that note, seen from inside a running agent: what the harness does without the model, and where each one lives.

  • Hole · same thingSuggested
    Why does thinking harder cost more?

    Both go down to switches. This note gets there from a program starting; thinking gets there from the cost of a reply, and shows the gates themselves.

  • Note · same thingSuggested
    How does my terminal find a tool?

    That note ends with the shell finding the file. This one starts there: what the kernel does with it next.

Terms

Checked

What the chat had wrong or only half right, against sources. The note above already says the corrected thing.

  1. Running a program means the OS copies the whole binary from disk into RAM.The kernel maps the file into the process's memory and reads pages from disk as they are first used, so a program starts before all of it is loaded.Apple, Memory usage performance guidelines
  2. When RAM is full, the system swaps the least-used memory straight to disk.macOS compresses memory that hasn't been used lately first, and swaps to disk when that isn't enough.Apple, Activity Monitor: memory
  3. The M1 Pro's GPU has 224 execution units and almost 1,800 shaders.Apple describes it as up to 16 GPU cores. The finer counts came from a benchmark site, not from Apple, so they are left out.Apple Newsroom, Introducing M1 Pro and M1 Max
  4. The instruction 10110000 01100001 is what a Mac's CPU runs.It is x86, which Intel Macs ran. Apple's chips use ARM64, whose instructions are 32 bits each.Arm, A64 instruction set
  5. The opcode 0000 means ADD and 0001 means SUBTRACT.Made up to show the idea. Real encodings differ by processor and are listed in its manual.Arm, A64 instruction set
  6. To print text, a program writes it to memory wired straight to the screen.A terminal program writes bytes to the terminal; the terminal app draws the letters, usually with the GPU, into a framebuffer, and the display hardware reads that out. Memory-mapped I/O is real, but the program doesn't write pixels.Apple, Metal: drawing to the screen
  7. ENIAC, in 1945, was doing Boolean logic in binary, like a laptop.ENIAC counted in decimal, ten states per digit. Binary machines came alongside it: Zuse's Z3 in relays (1941), and the stored-program computers after it.Penn Engineering, ENIAC
  8. Shannon's 1937 insight was that electrical switches could do Boolean logic.Right, from his master's thesis, published in 1938 as A Symbolic Analysis of Relay and Switching Circuits.MIT, Shannon's thesis