Every AI coding tool — Claude Code, Cursor, Copilot — ships with an LLM at the center. But the LLM is only a small part of the picture. The part most engineers don't think about is the harness: the layer between the model and your machine that decides what tools exist, what the model is allowed to do, how context flows in, and what happens when the model calls a tool. That layer is a stack. And understanding it changes how you build on top of it.
What the harness is
When you ask Claude Code to fix a bug, the model doesn't reach directly into your filesystem. It emits a structured tool call — something like Read({file_path: "src/lib/auth.ts"}) — and the harness intercepts that, checks permissions, executes the syscall, and feeds the result back as a tool result message. The model never touched your disk. The harness did.
This distinction matters because the harness is where reliability, security, and extensibility actually live. The model is stateless and probabilistic. The harness is deterministic and owns the execution loop.
The core layers
1. The tool registry
Tools are the vocabulary the model can speak. Each tool has a name, a JSON Schema describing its parameters, and a handler function. The harness validates every call against the schema before the handler runs — the model can't pass malformed input through to your filesystem.
Claude Code ships with ~20 built-in tools: Read, Edit, Write, Bash, WebFetch, and others. MCP (Model Context Protocol) lets you register external tools the same way — your internal API, a database, a docs server. The model treats them identically.
2. The permission system
Not every tool call gets executed automatically. The harness classifies operations by risk — file reads are low-risk, Bash commands that delete things are high-risk — and routes high-risk calls through a permission prompt before running. Users can pre-approve patterns in settings.json ("allow all npm commands"), and hooks can intercept calls before the prompt fires.
The model has no visibility into this. It emits the call; the harness decides what happens next.
3. Context management and compression
LLMs have fixed context windows. The harness manages what goes in and what gets summarized. Tool results are trimmed. Long files get chunked. When the conversation grows past a threshold, prior turns get compressed into a summary that preserves semantics without the token cost.
This is the layer that makes long coding sessions feel coherent even though the model is stateless. The harness is doing the stateful bookkeeping.
4. The hooks system
Hooks are shell commands that fire on harness events: before a tool call, after it completes, when a user message arrives. They run outside the model's loop — the model never sees them — and their output feeds back into context as a system-level message.
Hooks are how you wire in custom behavior without modifying the model or the tool registry. Memory systems, logging, linting on save, automatic test runs after edits — all hooks. They make the harness composable.
5. The agent loop
The harness runs the agentic loop: send message → receive response → if response has tool calls, run them → append results → send again. It manages turn structure, tracks which tool calls are in-flight, and handles errors (tool not found, timeout, permission denied) without crashing the session.
This loop is what turns a single-shot API call into a multi-step agent. The model participates in each turn; the harness owns the loop.
Why this matters for builders
If you're building on top of an AI coding tool — writing custom MCP servers, designing hooks, building plugins — you're building on the harness stack. The model's capabilities are fixed (until the next version ships). The harness is where you have leverage.
A well-designed harness is:
Observable. Every tool call, permission decision, and hook invocation is logged and attributable. You can reason about what the agent did and why.
Composable. New tools, hooks, and permissions can be layered in without touching the core loop. The model picks up new tools automatically.
Safe by default. Destructive operations require explicit confirmation. The blast radius of a bad model output is bounded by the permission system, not by hoping the model is careful.
What I'm building on this
I've been running Claude Code as my primary coding environment for several months. The harness stack is what I spend most of my architectural attention on — not prompt engineering, not model selection. Hooks that keep memory across sessions. MCP servers that surface internal tooling directly in the agent loop. Permission configs tuned to the project's risk profile.
I'll be writing more about specific patterns as I build them out. If you're doing similar work, reach out.
