Chapter 0: Introduction
What this book is
Open your coding agent. Cursor, Claude Code, Copilot, whichever one helps you code. Ask it to fix a bug. It reads your files, edits your code, runs your tests, and reports back in plain language.
The first time you watch it work, you wonder how. The answer is stranger than you expect. The whole show runs on four plain parts: an HTTP call, an array, some JSON, and a loop. That is the entire inventory. The magic is in the arrangement.
This book takes the machine apart, part by part. The central thesis is simple: you do not need an agent framework to have an agent. You need the four parts, and a clear view of what each one does.
The chapters then follow one loop as it grows. It starts as a plain conversation. It learns to read, then to act, then to use real tools, and finally to manage its own memory. By the last chapter, the parts stack into something you will recognize on sight: the coding agent you use every day.
Prerequisites
You need two skills:
- You have made a single LLM API call.
- You have used a coding agent as a user.
That is the whole list. You do not need the first book, Patchbook: LLMs are just APIs, before this one. When one of its ideas shows up, this book hands you the short paragraph you need on the spot. If you have already read it, you will spot the callbacks.
Who this book is for
- Coding agent users: You drive one every day, and now you want to see the engine.
- Software engineers and full-stack developers: You want agent features without adopting a framework you cannot see inside.
- Architects and tech leads: You must reason about agent memory, retrieval, and tool behavior before approving them in production.
- Pragmatic builders: You want to hold each piece in your hands before assembling the whole.
What you will learn
By the last chapter, you will be able to answer these questions:
- What is actually happening while my coding agent runs?
- How does a conversation become memory, and why does the agent forget?
- How do retrieval and attachments move knowledge into the model?
- How does a model act, and why did JSON output come first?
- Why do long sessions get worse over time, and what do compaction and sessions do about it?
The format: theory plus prompt
Each chapter ends with a Try it block. It holds one to three prompts. You paste a prompt into any current LLM, or into your own coding agent, and watch the idea happen in front of you.
There is no setup. No SDKs, no API keys, nothing to install. Your chat subscription is the lab.
Structure of the book
The book is a spiral. Each chapter ends with a limitation of what you just learned. The next chapter fixes it. You are always solving the problem the previous chapter created.
Chapter 1 is an essay. It shows you the machinery inside the thing you use every day. Chapters 2 to 6 are technical. They follow the loop as it gains each new ability:
- Chapter 2, The simplest agent. The loop every agent is built from.
- Chapter 3, Knowledge in the loop. Retrieval and attachments.
- Chapter 4, The first way to act. JSON output, then the tool contract.
- Chapter 5, The toolbox. Reading, writing, and running.
- Chapter 6, Memory. Compaction, sessions, and the reveal.
About the Patchbook series
Patchbook is a series of short technical books by Monarch Wadia, written as practical conceptual upgrades for working software engineers.
Patchbook titles are not academic textbooks, nor are they brittle tutorials for a framework that will be obsolete next quarter. Each chapter delivers one durable mental model. You can read a chapter in five minutes, understand the mechanics under the hood, and apply it in any language: Go, Python, TypeScript, Rust, or Java.