Available now · worldwide on Amazon
The Agentic Codebase
The Five-Layer Architecture That Makes Agent Work Survive Production
Demo an agent in an afternoon, regret it in six months. Build repos that last.
STACK turns repositories into operating systems for human-agent collaboration: structure, toolchain, agent configuration, connection, and knowledge gates that survive tool churn.
Get the book
Also on Bol.com → Third-party listing (not our storefront). Amazon remains the primary buy path.
Reading from another country?Pick your own Amazon marketplace — same edition, your store.
Amazon links may include affiliate tags. That does not change the price you pay. Bol.com listings are third-party.
English & Dutch editions · Kindle, Paperback, Hardcover · free on Kindle Unlimited · Nederlandse editie →
- pages
- 482
- chapters
- 18
- hours of reading
- ± 7
- editions
- EN · NL
The editions
Choose your format
Same book, your format. You buy on Amazon, not on this site.
-
Kindle
Read now. Kindle Unlimited members get it at no extra cost.
Buy on Amazon -
Paperback
The working copy. Mark it up. Take it into the meeting.
Buy on Amazon -
Hardcover
The shelf edition. Dark full-art jacket, built to stay in the room.
Buy on Amazon
Available now
The Five-Layer Architecture That Makes Agent Work Survive Production
The agent was fast for a week. Then it started editing the wrong module, re-deriving conventions you had already decided, and pasting plausible code that broke a contract no file ever wrote down. You spend your day correcting a collaborator that cannot read the rules, because the rules live in your head, not in the repo. Output went up; trust went down.
The reflex is to switch models, write a longer prompt, and add another tool. That scales the problem rather than the work: a better model follows a broken repository faster.
This book offers the opposite of a prompt trick: a repository designed for machine collaborators. The Agentic Codebase introduces the STACK framework (Structure, Toolchain, Agent configuration, Connection layer, Knowledge and quality): five layers that turn an agent from a guessing intern into a bounded contributor who reads the contract before it writes the code.
What you can do
What this book puts in your hands
You will learn to:
- Lay out a repo and entry points so an agent finds the right file without being told twice.
- Write AGENTS.md and CLAUDE.md as versioned standing context with real ownership, not aspirational comments, and keep them honest across Cursor, Claude Code, and your own stack.
- Define MCP servers and tool contracts with least-privilege scopes, and install hooks and guardrails that block the bad edits they can actually see before merge.
- Promote recurring work into skills, roles, and subagents. Then gate the whole loop with evals and CI, so judgment written once does its checking on every run.
The framework
STACK: the system behind the book
Structure, Toolchain, Agent configuration, Connection, Knowledge/quality
-
Structure
Layout, entry points, workspaces, and boundaries an agent can navigate on its first minute in the repo.
-
Toolchain
The shells, commands, and CLI contracts an agent is allowed to run, written down instead of remembered.
-
Agent configuration
AGENTS.md, CLAUDE.md, rules, skills, and subagent charters as versioned standing context.
-
Connection
MCP servers, tool contracts, hooks, and guardrails with least privilege and a real failure story.
-
Knowledge and quality
Memory tiers, context budgets, evals, and CI, so a model upgrade does not silently lower the bar.

From the book
Five STACK layers: Structure, Toolchain, Agent configuration, Connection layer, and Knowledge and quality as the stack agents run inside
The Agentic Codebase, printed page: Five STACK layers: Structure, Toolchain, Agent configuration, Connection layer, and Knowledge and quality as the stack agents run inside
Inspect more pagesLook inside
Pages from the print edition.
Five STACK layers: Structure, Toolchain, Agent configuration, Connection layer, and Knowledge and quality as the stack agents run inside
Demo-to-production gap: drifted prompts, divergent rules, ungoverned tools, and bloated context pass a watched demo but compound across
Memory tiers: hot loads every run; warm loads at launch or on
MCP topology: host, clients, JSON-RPC bus, stdio server, and HTTP server. Tools declare schema, auth, scope, limits, timeout, idempotency, and
Lethal trifecta diagram: private data, untrusted content, and exfiltration path overlap at the breach. Least-privilege scoping keeps any session
Five STACK layers in a vertical stack, all enclosed by the repository
Canonical NexumOS repository anatomy: small root, named agent-configuration homes, bounded src workspaces, and archive quarantine for
Three levels of skill progressive disclosure: description at startup, SKILL.md body when relevant, bundled reference and template files on demand
Role isolation: an orchestrator delegates to triage, billing-reconciler, and release-notes. Each role has its own context, least-privilege tools,
Purchase takes place on Amazon, not on this website.
Buy the paperback on AmazonFrom the book
Read a page
Introduction
Introduction: The Repo Is the Agent OS
A demo proves the model can do the work. A repository proves the work can be done again. The gap between those two sentences is the subject of this book.
What you can do afterwards
You will understand why agentic systems fail in repositories rather than in models. You will name the disease, agentic repo debt, and leave with STACK: the five-layer map every agentic codebase must get right.
Use this chapter when
A demo wins the room but a new hire cannot reproduce it; rules and prompts live in chat history; "ask the person who knows the setup" is your onboarding plan.
What you get
What you get
- The STACK framework: Structure, Toolchain, Agent configuration, Connection, Knowledge/quality
- Versioned patterns for AGENTS.md, CLAUDE.md, rules, skills, and subagent charters
- MCP server design, tool contracts, hooks, and guardrails that survive tool churn
- Agent memory tiers, context budgeting, evals, and CI for production discipline
- A copyable artifact per chapter: directory trees, SKILL.md, rule files, eval specs
Who it's for
- Onboard a second human or agent without losing conventions
- Stop duplicating CLAUDE.md across three tools
- Add MCP servers without a security surprise
- Run evals when you change rules or skills
- Keep the repo alive through a model upgrade
Who it's for
Who this book was written for
The result is not a faster way to ship one feature. It is a codebase that compounds: each rule you encode is correctness the agent inherits, and the system gets more autonomous as you write less of the code yourself.
If you build with agents and refuse to let speed erode your standard, this was written for the engineer you are when the diff is large, the agent is confident, and the contract is yours to define.
The reader it was written for
Technical founders and staff engineers already using Cursor or Claude Code daily, who can read a repo tree and are tired of “it worked in chat” dying in CI.
Also a fit for
Engineering leads standardizing how a team uses agents: AGENTS.md, skills, MCP, evals.
What you will use it on
- Onboard a second human or agent without losing conventions
- Stop duplicating CLAUDE.md across three tools
- Add MCP servers without a security surprise
- Run evals when you change rules or skills
- Keep the repo alive through a model upgrade
Probably not for you if
- Non-technical founders; start with AI Agents for Startup Strategy
- ML researchers training foundation models
- Readers who refuse a terminal workflow
The contents
Chapter by chapter
Every chapter of The Agentic Codebase with its printed epigraph, what you can do afterwards, and the moment it is built for.
Introduction
Introduction: The Repo Is the Agent OS
A demo proves the model can do the work. A repository proves the work can be done again. The gap between those two sentences is the subject of this book.
What you can do afterwards
You will understand why agentic systems fail in repositories rather than in models. You will name the disease, agentic repo debt, and leave with STACK: the five-layer map every agentic codebase must get right.
Use this chapter when
A demo wins the room but a new hire cannot reproduce it; rules and prompts live in chat history; "ask the person who knows the setup" is your onboarding plan.
Chapter 1
The Agentic Repo Problem
Nothing crashed. That was the problem. The same agent that dazzled the room in its first week live began, in its second, to rot the codebase quietly, and quiet rot has no stack trace.
What you can do afterwards
You will be able to name the four ways an ad-hoc agent setup decays a repository. You will recognize each one in your own tree, and you will see why they are not four bugs. They are one missing layer of architecture.
Use this chapter when
Your agent worked perfectly in a demo and started misbehaving a sprint later. Use it when a new teammate cannot reproduce the behavior everyone swears they saw.
Chapter 2
STACK: Five Layers
Four failure modes, one underlying absence. Chapter 1 gave them names; this chapter supplies the structure that makes the absence impossible: five layers, each one a home for a kind of intelligence a normal codebase never has to carry. STACK is that structure, and the map you will walk for the rest of this book.
What you can do afterwards
You will map any repository to the five-part STACK sequence: Structure, Toolchain, Agent configuration, Connection, and Knowledge/quality. Then you will run the audit that scores each one from absent to versioned-and-tested.
Use this chapter when
You inherit a repo agents already touch, you are about to add your first agent to a brownfield codebase, or you cannot say where your prompts, rules, and tool contracts actually live.
Chapter 3
Structure — Layout and Entry Points
An agent does not explore your repository. It forages, and a maze charges a toll on every wrong turn that a route never asks for.
What you can do afterwards
You will design the front door of a repository so a fresh agent, or a new engineer, can route in its first minute. The tree gets named entry points, predicate-rich directories, and a navigation map an agent reads on entry.
Use this chapter when
A new agent re-derives your layout on every run. Use it when an agent reinvents code that already exists two directories over, or when "where does X live?" is answered only by the person who built the repo.
Chapter 4
Workspaces and Boundaries
A repository agents can navigate is the first half of Structure. The other half is a repository they can navigate without loading the parts they do not need. At scale, that second half decides whether your agents stay reliable or start hallucinating couplings that were never there.
What you can do afterwards
You will decide where to draw workspace boundaries so an agent can load a unit's full context and change it correctly. You will scope per-workspace instructions under one root and recognize the "distributed monolith" that blows the context budget.
Use this chapter when
Your repo has grown past one cohesive thing. Use it when agents keep over-loading code to make small changes, or when you are choosing between a monorepo and several repos and want a reason that is not taste.
Chapter 5
AGENTS.md and CLAUDE.md
A repository can hold five contradictory descriptions of how it works, and every agent that reads it will obey a different one. The cure is not a better instruction file. It is one instruction file the others bow to.
What you can do afterwards
You will author a single root constitution for your repository: scope, commands, shell mandate, safety floor, quality gates, and a repo map. Then you will wire every agent tool to read that one file instead of five drifting copies.
Use this chapter when
Your `CLAUDE.md` disagrees with a `.cursorrules` that disagrees with the code, or you are adding your first root instruction file and want it to age well instead of bloating into noise.
Chapter 6
Rules Across Tools
One constitution, singular. That was Chapter 5's win for NexumOS, and within a month the question that breaks it: every tool wants its own copy, in its own folder, in its own dialect. So how do you keep one truth when five surfaces each demand to hold it?
What you can do afterwards
You will version your rules as code, scope them by glob, and keep one canonical source. Per-tool copies will be generated or imported from that source, curing the rule drift that made Chapter 1's agent right on Monday and wrong on Tuesday.
Use this chapter when
Your team uses more than one agent tool, or your `.cursor/rules` and `CLAUDE.md` no longer agree. Use it when you have debugged "the agent ignored our rule" and found a second rule contradicting the first.
Chapter 7
Agent Skills
What you can do afterwards
You will take a prompt your team retypes from memory and turn it into a versioned, reviewable, testable skill package. The result is a folder with a `SKILL.md`, a trigger description, an on-demand body, and a golden test that pins behavior.
Use this chapter when
The same instructions get pasted into chat every week. Use it when your "good" prompts live in someone's head or a Slack thread, or when you cannot tell whether last month's edit made a capability better or worse.
Chapter 8
Roles and Subagents
Skills give your repo capabilities. They do not answer who is chartered to use them, under what constraints, or when that worker must stop. That is where an agent that can do anything starts doing the wrong thing. A skill is a power; a role is the hire with a job description who is chartered to pick it up.
What you can do afterwards
You will replace generic "the agent" with a small roster of chartered roles. Each role gets a written mandate, least-privilege tool list, typed inputs and outputs, and a named escalation path. Each can become a scoped subagent that runs in its own clean context.
Use this chapter when
One catch-all agent is doing triage, deploys, and billing writes from the same context. Use it when destructive incidents trace to "the agent had every tool just in case," or when parallel agent workers are arriving faster than you can review their output.
Chapter 9
Prompts, Commands, and Workflows
Chapter 8 gave NexumOS a roster of chartered roles. But a role is a who, not a what. The triage agent now has a mandate; it still has no script. This chapter writes the script, and writes it as code, because the operation your agents run forty times a week should not live in your memory of how the demo went.
What you can do afterwards
You will turn your most-repeated chat operation into a parameterized, version-controlled command with a golden test case. You will also learn to chain those commands into short workflows with named human checkpoints instead of one heroic pipeline.
Use this chapter when
You catch yourself retyping the same five-step instruction from memory. Use it when teammates each have their own version of "the way we ship a fix," or when last month's agent workflow quietly stopped producing the same shape of output.
Chapter 10
Memory and Context Tiers
What you can do afterwards
You will write a memory policy that sorts every piece of standing context into three tiers: hot session, warm project, cold archive. The agent will load the smallest high-signal set on each run, not the largest the window allows. You will leave with a copy-pasteable tier table and a context budget your repo can enforce.
Use this chapter when
Your agent contradicts itself deep in a long session, a stale decision keeps resurfacing, or your root instruction file has crept past two screens. Use it when you cannot say which things in context were chosen and which merely accumulated.
Chapter 11
MCP Servers and Tool Contracts
What you can do afterwards
You will turn the tools your agents call from bare functions into governed contracts: schema, auth, limits, timeouts, idempotency, and named failure modes. You will also make the chapter's highest-return security decision, local versus remote, on purpose instead of by default.
Use this chapter when
Your agents call MCP servers nobody wrote a spec for. Use it when a tool lives in someone's personal config, when its scope is unclear, or when last week's tool silently changed what it does.
Chapter 12
Hooks and Guardrails
A contract declares what a tool is allowed to do. It does not stop the tool from being asked to do something else.
What you can do afterwards
You will move the one invariant that must hold every run out of prose and into a deterministic hook. It fires on the event, validates the call, and holds no matter what the model chose. You will write, test, and ship your first PreToolUse gate this week.
Use this chapter when
A rule in your `CLAUDE.md` says "never force-push," "always run tests before committing," or "don't touch `.env`." Use it when you have caught the agent doing the thing anyway, or when you cannot afford to.
Chapter 13
Plugins and Marketplaces
A skill you write is code you trust because you wrote it. A plugin you install is code you trust because someone else wrote it, and the agent that runs it holds your credentials and a shell. This chapter closes the gap between those two sentences.
What you can do afterwards
You will stop installing third-party agent capability on vibes. Instead, you will curate it as the supply-chain dependency it is: score every plugin against six dimensions, pin what you keep, and fork what you cannot pin.
Use this chapter when
A teammate drops a "you have to try this" plugin in the channel. Use it when a marketplace listing promises exactly the thing you were about to build, or when you cannot name where your team's agents got their extra tools.
Chapter 14
Shells and ReasonKit-tools
Every plugin you install, every skill it bundles, every tool it exposes ends the same way: a command runs in a shell. Chapter 13 taught you to evaluate what you install. The shell is the room all of it executes inside, and most teams have never decided what that room contains. This chapter furnishes it.
What you can do afterwards
You will declare your repository's shell and CLI toolchain as versioned config. A human or agent should be able to recreate the environment from a new checkout. You will also learn when to use a structured shell that hands the agent rows it can filter, and when to use a POSIX shell for CI portability.
Use this chapter when
A command works on your laptop and fails on a teammate's. Use it when an agent's pipeline breaks because the assumed CLI version is different, or when nobody can name the shells and tools your repo expects without asking the person who set it up.
Chapter 15
Integrations, Evals, and CI for Agents
A green test suite is the only sentence in a codebase that says "this still works" and can be trusted. Rule files and skill files have never been allowed to say it. This chapter changes that.
What you can do afterwards
You will treat your `AGENTS.md`, your rules, and your skills as the untested production code they already are. Each gets a golden-task eval, a merge gate, a pass-rate threshold, and a cost budget. Agent runs also become traceable, so a "harmless" edit can no longer regress behavior in silence.
Use this chapter when
You cannot tell whether last week's rule tweak helped or hurt. Use it when a one-line prompt change broke a workflow nobody noticed for days, or when your only test of "did this help" is whether the next demo feels good.
Chapter 16
Vibe Coding vs Production Discipline
Speed does not threaten maintainability; speed in the wrong container does. This chapter gives the wrong container a sanctioned shape and a door that only opens through the gates.
What you can do afterwards
You will stop treating speed and discipline as a choice. Instead, you will treat them as two modes with two territories: fast exploration in a sanctioned lane that never touches the main repo's invariants, and gated production work that decides what merges.
Use this chapter when
You are tempted to skip the gates "just this once" to keep momentum. Use it when an agent-generated spike looks good enough to merge straight to main, or when every fast win has left a little debt behind.
Conclusion
Conclusion: Maintain the Stack
A demo proves the model can do the work once. A versioned stack proves the work survives the people who built it and the model that replaces them. This book was the distance between those two sentences; this chapter is the habit that keeps you on the second one.
What you can do afterwards
You will leave with a maintenance habit, not a finish line: the STACK audit, completed once for NexumOS. Then you will put the same audit on a cadence for your own repo, so the five layers stay versioned instead of rotting back into folklore.
Use this chapter when
You have built the stack: structure, configuration, connections, and knowledge. Now you have to keep it alive through model upgrades, new teammates, and a hundred small "just this once" shortcuts.
Editions
Editions and specifications
| Edition | Formats | Chapters | Pages | Reading time | ISBN (paperback) |
|---|---|---|---|---|---|
| English The Agentic Codebase | Kindle, Paperback, Hardcover | 18 | 482 | ± 7 hours | 9798187627509 |
| Dutch De agentische codebase | Kindle, Paperback, Hardcover | 18 | 520 | ± 7 hours | 9798187630967 |
Both editions are written natively. The Dutch text is not a machine translation of the English. · Trim size: 6x9″
Get the book
One title, every Amazon marketplace. Pick your format and your store.
Get the book
Also on Bol.com → Third-party listing (not our storefront). Amazon remains the primary buy path.
Reading from another country?Pick your own Amazon marketplace — same edition, your store.
Amazon links may include affiliate tags. That does not change the price you pay. Bol.com listings are third-party.
Frequently asked
What readers usually want to know
What is The Agentic Codebase about?
STACK turns repositories into operating systems for human-agent collaboration: structure, toolchain, agent configuration, connection, and knowledge gates that survive tool churn. The subtitle is: The Five-Layer Architecture That Makes Agent Work Survive Production.
What is the STACK framework?
STACK: Structure, Toolchain, Agent configuration, Connection and Knowledge and quality. Structure, Toolchain, Agent configuration, Connection, Knowledge/quality
In which formats is The Agentic Codebase available?
The Agentic Codebase ships as Kindle, Paperback and Hardcover, on every Amazon marketplace worldwide. The Kindle edition is enrolled in Kindle Unlimited, so KU members read it free.
Is there a Dutch edition?
Yes. The Dutch edition is De agentische codebase, written as a native edition rather than a machine translation. It is available on Amazon too.
How long is The Agentic Codebase?
This edition runs 18 chapters, 482 pages in print and roughly 7 hours of reading.
Who is The Agentic Codebase for?
If you build with agents and refuse to let speed erode your standard, this was written for the engineer you are when the diff is large, the agent is confident, and the contract is yours to define.
Is there companion material for The Agentic Codebase?
Yes. The companion archive downloads from this book page: copyable artifacts that sit next to the chapters.
This will slow us down.
What slows you down is a repo that cannot survive a second engineer or a model upgrade. STACK is the architecture that keeps agent work reproducible.
Our stack changes every month.
That is why the layers are versioned. Toolchain and MCP contracts are allowed to churn; Structure and Knowledge gates are what keep the bar from sliding.
We are too small for architecture.
A solo founder plus agents is already a multi-actor repo. STACK is sized for that, not for an enterprise platform team.
Vibe coding works for us.
Vibe coding wins the demo. STACK is for the six months after, when the agent edits the wrong module and nobody can say which rule allowed it.
The production system
How this book was made
Every title moves through the same gated production line: sourced research, a claim-level evidence ledger, structural review, fact-checking, red-team critique, and a bilingual final edit. AI agents do specialist work inside those gates; judgment, voice, and accountability stay human.
- Claims enter an evidence ledger with a source and a confidence grade before they reach the page
- English and Dutch are two native editions, not a translation of one another
- Every chapter clears readability, rhythm, and style gates before it is typeset
Books