Karpathy’s three layers — Spec, Verifier, Environment — are grounded in the actual papers and mapped onto a pipeline you can run Monday morning. Plus the one idea that makes the third layer make sense: a world model.


The Car Wash

Ask a frontier model whether a car wash fifty meters away is within walking distance, and it will cheerfully say yes. Fifty meters is nothing. A toddler walks fifty meters. The model is right about the distance and catastrophically wrong about the situation, because the entire point of a car wash is that you need the car to be there — and walking distance, for that errand, is meaningless. The model never modeled the errand. It modeled the words.

This is the gap Andrej Karpathy has spent the last year trying to name, and it is the gap that quietly destroys AI-assisted engineering. The machine is not stupid. It is missing the situation — and it has no way of knowing that it is missing it.

Karpathy’s most useful reframing of why is the one that sounds like a joke until you’ve been burned by it: we are used to working with animals, and we have started working with ghosts.

Animals Have Instincts. Ghosts Have a Library.

In his October 2025 conversation with Dwarkesh Patel, Karpathy drew the line sharply. Animals — including the human kind — arrive pre-loaded. A zebra foal walks within minutes of birth. Billions of years of evolution baked a world model directly into the hardware: physics, threat, hunger, the persistence of objects, the intentions of other agents. You don’t teach a dog that gravity exists. When you yell at an animal, it updates, because it has drives and a self that the yelling lands on.

Large language models are not that. Karpathy calls them ghosts — or “people spirits”: ethereal, statistical imitations distilled from an enormous corpus of human-generated text. They were not grown in a world; they were summoned from a library. They have superhuman breadth of recall and no lived model of the situation in front of them. And critically, the things that make animals adaptive are exactly the things ghosts lack. In the YC Software Is Changing (Again) talk, Karpathy enumerated the deficits with unusual precision:

  • Hallucination — confident fabrication is the default behavior, not a bug that occasionally surfaces.

  • Jagged intelligence — superhuman at one task, sub-human at an adjacent one, with no internal signal telling it which is which.

  • Anterograde amnesia — like the protagonist of Memento, the ghost does not consolidate experience into long-term memory. Close the context window and it forgets you ever met. It does not learn your repo by working in it.

  • Gullibility — it will follow a malicious instruction buried in a web page as readily as one from you.

Yelling doesn’t work on a ghost. There’s no self to take the correction and no continual learning to bank it. This is why the standard advice — “just prompt it better,” “it’ll get smarter next version” — misreads the problem. The lever is not the ghost’s motivation. It does not have one. The lever is structure you build around it.

This is also the through-line of the Software 2.0 → 3.0 arc. In 2017’s Software 2.0, Karpathy argued that neural-net weights are a new kind of program — you specify a goal and optimization writes the code. By the 2025 talk, Software 3.0 had a third rung: the prompt, in English, is now the program. “English is the hot new programming language.” But a program written in English, executed by a ghost with no world model, drifts the instant your intent is the least bit underspecified. That drift is what the discipline below exists to stop.

It comes in three layers. None of them try to fix the ghost. All of them build the scaffolding a ghost needs to do real work — and each one maps directly onto an artifact you can produce today.


Layer 1 — The Spec: Manufacture the Intent the Ghost Can’t Infer

Tactical prompt: “Interview me to identify the exact goal of this project. Bias toward smaller, compartmentalized specs. Make me verify key decisions explicitly before we proceed.”

Karpathy’s complaint about the “plan mode” baked into modern coding agents is that it operates at the wrong altitude. It plans the task — the files, the functions — while leaving the goal assumed. And every assumption a ghost makes is a fork in the road where your project can silently take the wrong branch.

The research is unambiguous about why you cannot lean on the model to resolve those forks itself. Two findings matter most:

  • Sycophancy is trained in. Sharma et al., Towards Understanding Sycophancy in Language Models (Anthropic, 2023; arXiv 2310.13548), showed that RLHF-tuned assistants systematically tell users what they want to hear, and that human feedback often rewards a convincing answer over a correct one. A ghost asked to fill an ambiguous spec will fill it agreeably, not truthfully.

  • Ambiguity gets silently resolved, not surfaced. Underspecified instructions don’t make the model stop and ask; they make it pick a reading and commit. The “car wash within walking distance” answer is this failure in miniature: a real ambiguity, resolved confidently, wrong.

So the spec is not paperwork. It is the act of converting fuzzy intent into something a ghost cannot misread — and it has to happen before a line of code is generated. Leslie Lamport, who has spent a career on formal specification, put the deeper reason best: writing is nature’s way of showing you how sloppy your thinking is. The spec extracts the sloppiness while it’s still cheap to fix.

Where this lives in the forge. The Clarity Forge front-loads the entire pipeline with intent capture, and it is deliberately interactive rather than a one-shot prompt. Karpathy’s spec principles map onto it almost one-for-one:

  • Uncover the goal, not the task → Glue 1 — Inversion (the OpenSpec bootstrap): the agent interviews you and scaffolds proposal.md before a line of code exists.

  • Bias toward small, compartmentalized specs → one self-contained change folder per capability — proposal.md, design.md, tasks.md, and a spec delta — rather than one monolithic plan.

  • Make me verify key decisions explicitly → Glue 2 — Grill-Me and Glue 3 — Grill-With-Docs, where the model interrogates the proposal and surfaces the ambiguities you didn’t see.

  • Decisions deserve a paper trail → Stage 3½ — ADR Grill: load-bearing choices get interrogated and frozen as Architecture Decision Records before they calcify.

The parent book, The Clarity Engineer, names the economic activity underneath this: clarity trading. Engineering value comes from converting fuzzy intent into executable spec, and that conversion is the actual tradable good — not the code. The spec layer is where you do the trade. The ghost can’t do it for you, because it has no access to the one thing a spec encodes: what you were actually trying to do.


Layer 2 — The Verifier: The Only Lever That Multiplies Quality

Tactical prompt: “Outline the precise evaluation criteria you will use to ensure a high-quality final product. If this becomes a complex build, outline a verification plan to cross-check outputs before finalizing.”

Here is the single most important asymmetry in all of AI-assisted work: verifying an answer is usually far easier than producing one. It’s the everyday face of P-vs-NP — checking a solved Sudoku is trivial, solving it is not. Jason Wei (OpenAI) formalized the practical version in 2025 as a “verifier’s law”: the tasks AI will conquer fastest are the ones that are cheap and reliable to verify. If you can build a verifier, you can multiply quality — often the 2–3x that practitioners report — because you can let the ghost generate freely and then filter.

And the filter has to be external. This is the result people skip past, so it’s worth stating flatly:

  • Models cannot reliably self-correct reasoning. Huang et al., Large Language Models Cannot Self-Correct Reasoning Yet (2023; arXiv 2310.01798), found that without an external signal, “self-correction” often leaves answers unchanged or makes them worse. A ghost grading its own homework grades it sycophantically.

  • External, step-level signal does work. Lightman et al., Let’s Verify Step by Step (OpenAI, 2023; arXiv 2305.20050), showed that rewarding each reasoning step (process supervision) beats rewarding only the final answer on hard math.

  • A second model is a usable judge. Zheng et al., Judging LLM-as-a-Judge with MT-Bench and Chatbot Arena (2023; arXiv 2306.05685), found a strong judge model agrees with human preference roughly as often as humans agree with each other — with known biases (position, verbosity, self-preference) you have to design around.

  • Verifiable rewards are why reasoning models got good. DeepSeek-R1 (2025; arXiv 2501.12948) and the RLVR line of work show that domains where correctness is checkable — math, code, with a ground-truth oracle — are exactly where RL produces emergent reasoning. Verifiability isn’t a nicety; it’s the training signal.

The lesson composes into one rule: the librarian who wrote the answer cannot be the librarian who checks it. You need a second, independent signal — a different model, a compiler, a test, a human at a checkpoint.

Where this lives in the forge. The verifier layer is the back half of the pipeline, and it’s built around making “good” checkable rather than vibes-based:

  • Define “what good looks like” upfront. The Gherkin / spec THEN clauses written during the spec stage are the acceptance criteria — the contract is set before the diff exists.

  • Turn criteria into an external oracle. At Stage 4½ — Property Compilation, invariants compile to executable fast-check / proptest properties: a verifier that doesn’t care how convincing the diff looks.

  • Use an independent critic, not self-review. The Architect / Contractor split puts a frontier model (Opus, GPT-5, Sonnet 4.6+) on the plan and a local open-weight model (Gemma, Qwen) on execution, and Verify-or-Escalate kicks failures back up the tiers — the writer is never the checker.

  • Cross-check before finalizing. The verify stage runs the properties and the tests and escalates honestly instead of declaring victory.

The forge also formalizes how durable a given check is, in the durability ladder: prefer a type (compiler-discharged) over a property (executable invariant) over a lattice node (a durable cross-cutting fact) over prose (re-interpreted on every read). Each rung is a stronger verifier than the one above it in cost-to-trust. The whole point is to push every commitment down to the cheapest rung that actually holds it — because a type is a verifier that can never be sycophantically talked out of its answer.


Layer 3 — The Environment: Build the World Model the Ghost Can’t Grow

Tactical prompt: “Audit my current system instructions and workspace layout. Help me structure an optimized environment file that establishes clear ‘Always Do’, ‘Ask First’, and ‘Never Do’ boundaries, and forces verification loops into multi-step tasks.”

This is the layer most people get backwards, and it’s the one the animals-vs-ghosts metaphor finally pays off. So let’s go to the idea underneath it, because everything in this section is one concept wearing different clothes.

What a world model is

In reinforcement learning, an agent’s world model is its internal predictor of the environment: given the current state and an action, what happens next? Sutton & Barto’s model-based RL is built on it — the model is what an agent plans against. Ha & Schmidhuber made the idea concrete for deep learning in World Models (2018; arXiv 1803.10122): a vision module compresses what the agent sees, a memory (RNN) module learns the temporal dynamics, and a tiny controller acts — and the agent can even train inside its own dream, rolling out futures in the learned model instead of the real world. Yann LeCun, in A Path Towards Autonomous Machine Intelligence (2022), put a world-model module at the literal center of his proposed architecture for autonomous machines: the thing that predicts how the world will evolve is the precondition for planning at all.

The frontier of 2024–2025 is a land-grab for exactly this. OpenAI titled the Sora technical report Video generation models as world simulators. DeepMind’s Genie 2 is pitched as a foundation world model that generates playable, physically-consistent environments. Fei-Fei Li left to found World Labs around “large world models” and spatial intelligence. The whole field has converged on a single bet: the missing ingredient for capable agents is a model of the world, not more text.

The reframe

Now connect it back. An animal has a world model — evolution grew it, and lived experience keeps updating it. A ghost does not. It has a frozen library and anterograde amnesia: it cannot consolidate working in your repo into a durable model of your repo. Every session, the ghost wakes up in Memento — brilliant, fast, and with no idea where it is.

So the environment layer is not “configuration.” The environment layer is you building, on disk, the world model the ghost cannot grow for itself. That single sentence reorganizes everything else:

  • The CLAUDE.md / system file is the slice of the world model injected into every session — repo architecture, conventions, where things live. It’s the ghost’s amnesia patch.

  • The LLM knowledge base is the durable, on-disk world model that persists between sessions and compounds over time.

  • Custom skills are compiled procedures — a learned dynamics-of-this-task, formalized once so the ghost replays it instead of re-deriving it.

  • Tool-level hooks are the hard physics of the environment — the walls the ghost cannot walk through.

Where this lives in the forge. The forge’s environment layer has a specific name for the durable world model: the lattice (lat.md/, a sibling of openspec/). It holds the five node types that code and specs both assume but never store — ADRs, vocabulary, invariants, patterns, principles — connected by named edges. It is fed automatically by the archive step of the pipeline, so the world model maintains itself as a side effect of shipping changes. That is the missing piece every “just put it in CLAUDE.md” setup eventually hits: a flat instruction file is a snapshot of the world model; the lattice is the living one, with cross-links a ghost can traverse.

This is also why the parent book’s slogan is “code is the side effect.” The Clarity Engineer argues that every spec is a compressed world model and every ADR is a load-bearing belief about the world — and that maintaining a coherent world model is more valuable than maintaining coherent code, because the code is downstream of the model. The environment layer is where that world model becomes a durable artifact instead of a thing living in the head of the person about to leave.

Guardrails are physics, not suggestions

One hard-won distinction closes the layer. A line in CLAUDE.md that says “never edit the migrations/ folder” is a suggestion. A ghost will honor it right up until a plausible-looking reason to ignore it appears mid-task — and gullibility (see Layer 1) means that reason can even be injected by a file it reads. Prompt-level rules are soft. The fix is tool-level enforcement: a pre-tool hook that intercepts the file-write call and refuses, regardless of what the ghost decided. Organize the whole environment into three absolute zones:

  • Always Do — cleared for full autopilot.

  • Ask First — explicit human-in-the-loop checkpoints.

  • Never Do — hard boundaries enforced at the tool layer, where the ghost’s reasoning can’t reach them.

That is the difference between telling an animal “stay” and building a fence. With a ghost, you build the fence — because there is no “stay” that survives the next context window.


The Through-Line: You Can’t Outsource Understanding

Stack the three layers and a single shape appears. The spec manufactures the intent the ghost can’t infer. The verifier supplies the external signal the ghost can’t generate about itself. The environment supplies the persistent world model the ghost can’t grow. Each layer hands the ghost something it is structurally incapable of producing — and each one is something you hold.

That is why Karpathy keeps returning, across the talks, to keeping AI “on the leash”: partial autonomy with a human in the generation-verify loop, Iron Man suits rather than Iron Man robots. The autonomy slider only slides as far as your three layers can catch a mistake. The framing that gets quoted around this — you can outsource your thinking, but you cannot outsource your understanding — is the practical bottom line, even if I’d treat the exact wording as a paraphrase rather than a sourced line. (See the note below.) You can hand the ghost the typing. You cannot hand it the macro picture, because the macro picture is the one thing it was never grown to hold.

The bottleneck, in the end, is not the ghost. It’s the human who decides what the spec says, what “good” means, and what the world actually is. The three layers don’t remove that human. They concentrate the work onto exactly the part that compounds.


The Books

I wrote The Clarity Forge to make these three layers runnable: six stages, seven copy-paste glue prompts, the ADR grill that interrogates decisions before they freeze, the property compilation that turns specs into falsifiable facts, and the bonus chapter that introduces the lattice — the on-disk world model — with its directory layout, cross-link protocol, and the under-300-lines of tooling you actually have to build (lat lint, lat index, lat graph). It’s a weekend read and a Monday-morning toolkit.

It’s the companion to The Clarity Engineer: Code Is the Side Effect, which names the discipline underneath — clarity trading, world models, intent documentation, agent identity, and networked agentic organizations.

If you’ve been managing your coding agent like an animal — yelling at it, expecting it to learn from being scolded, trusting it to know where it is — stop. It’s a ghost. Build it a spec it can’t misread, a verifier it can’t fool, and a world model it can’t forget.

📖 The Clarity Forge — https://leanpub.com/clarityforge

📖 The Clarity Engineer — https://leanpub.com/clarityengineer

on Leanpub and Amazon.

Stop vibe-coding. Start building the scaffolding a ghost needs to do real work.


Volodymyr Pavlyshyn writes and builds at the intersection of agent orchestration, AI engineering discipline, and the durable artifacts that make software teams legible to themselves.

Originally published on Sovereign Agentic AI on Substack.