Preface — None of This Is Mine
Introduction — Constraint Engineering, Named
- The argument in one paragraph
- How the book is structured
- Where the evidence comes from
- A note on Claude Code as the working example
- Scope and sources
- How to read it — by use-case
Part I — Foundations
Chapter 1 — The Agent Is Already in Your Codebase
- A Tuesday with the agent and a Friday with the same agent
- The naive response and why it breaks
- Why the book is structured around the repo
- The repo audit, in concrete terms
- The one-page repo audit
Chapter 2 — Old Principles, New Substrate
- The agent did not invent any of this
- The amplification thesis
- Two pressures the canon now has to absorb
- Why “stronger standards” is the wrong slogan
- I did not invent these standards
- Where the canon lands in this book
- The canon-to-charter map
Chapter 3 — The Reliability Problem (and Why Determinism Is the Wrong Goal)
- The model is non-deterministic, and that part is not a defect
- Reliability is not determinism
- The three reliability levers
- The levers are filters; reliability is what survives them
- Determinism belongs in the workflow
- What this book is not
- None of this is original to this book
- The claim, made falsifiable
- Reading an unreliable run
Chapter 4 — Charter and Harness: What Each One Is
- The charter: what you author
- The harness: the engine that applies it
- What’s in each box
- Sort your own repo
Chapter 5 — Harness and Charter: The Boundary
- The machine: charter → harness → model → result
- The standard: the charter
- The line
- The case that looks like an exception
- Where context and the loop sit
- The word, and where I had it pointed
- Why the seam is worth the trouble
- The card
Chapter 6 — Taxonomy: The Seven Words and the One Test That Sorts Them
- The one test
- The seven words
- The symmetry
- What is neither
- How to read the rest of the book
- The artifact: the classifier card
Chapter 7 — The Repo as a Behavioral System
- Three classes of signal
- Why instruction loses to imitation
- The repo is the environment
- A worked example
- Why each channel matters on its own
- What this means for where to invest
- Repo audit
Chapter 8 — The Charter’s Layers and the Reliability Levers
- The charter has layers
- Concentric, not stacked
- The litmus test for placement
- The three reliability levers, restated
- The layer-by-lever grid
- The layer × concern matrix
- The policy layer does not have to be one
- Concrete failure modes by layer
- How the rest of the book uses the grid
- The blank grid, ready to copy
Chapter 9 — Objections
- “The models will eat this”
- “This is platform engineering with a new coat of paint”
- “Context engineering already names this”
- “Hand-authored charters will be compiled away”
- The ledger
Chapter 10 — Related Work: Where This Sits
- AGENTS.md: the file the field agreed on
- Harness engineering at Thoughtworks: the same name, independently
- Prompt engineering and context engineering: the supplied-versus-authored cut
- Platform engineering: the nearest older sibling
- DORA and Accelerate: the measurement standard not yet met
- SRE: error budgets become gate budgets
- MLOps and AI engineering: the other axis
- DSPy: the compiler objection
- The map on one card
Part II — Authoring the Charter
Chapter 11 — The Instruction Layer
- The file read on every turn
Chapter 12 — Rule Files: Iron Laws, Golden Rules, and Preferences
- Three tiers, one file
- Scope and traces
- The cardinal sin
- Where rules come from, and where they go
- Rules bound a move; a command or a skill walks a job
Chapter 13 — The Corpus and the Docs
- The corpus
- Docs are corpus
Chapter 14 — Cascade, Scope, and Inheritance
- Three rules resolve the cascade
- Memory files: the cascade in one slice
- Locks
- The resolved view
- Required declarations
- Three failure modes, all structural
- A worked example
Chapter 15 — Ontologies: One Meaning Per Term
- The agent hears only what is written
- The glossary as charter artifact
- Ubiquitous language for an absent reader
- The ontology the agent believes
- What holds between the terms
- Terms rot
Chapter 16 — Memory and the Token Budget
- Three kinds, and only one of them survives
- The conversion is the discipline
- The agent’s memory is a budget, not a vault
- Where it lives in the layers
- The window is working memory, and it costs you every turn
- The number that matters is not the ceiling
- Three tiers
- Lazy-load by region
- Two sample baselines
- The cost of bloat
- The pre-flight check
- Three rules for keeping the budget honest
- Compact with focus
- Constraint loss: the failure compaction causes
- Prompt patterns that respect the budget
- A note on context-reduction tooling
- The artifact
Part III — Code, Tools, and Checks
Chapter 17 — The Legible Codebase: Architecture and Seams
- Architecture as Communication
- Explicit Seams and Bounded Contexts
- The artifacts
Chapter 18 — The Legible Codebase: Names and Boring Code
- Naming as a Behavioral Signal
- Boring Code: Predictability over Cleverness
- The artifacts
Chapter 19 — Tests and Gates
- Tests are guides and sensors
- TDD as the agent loop
- The test pyramid still holds
- Characterization tests before legacy refactors
- Output-based tests beat implementation-based tests
- Mock the unmanaged, run the managed
- Flaky tests are charter failures
- A make-this-testable recipe
- Tests are coverage; gates are speed
- The thirty-second budget
- What runs on the fast layer
- Two gates, two jobs
- Hook hygiene
- The slow ratchet
- Scoring code health as a sensor
- The happy path is verified; QA moves to the edges
- The artifact
Chapter 20 — Declaring Tools: Skills, Sub-Agents, Hooks, Plugins, and MCP
- What a tool is
- Contract in the repo, reach in the world
- Minimum capability and the ladder
- The tool inventory
- Skills: reusable multi-phase workflows
- Sub-agents: specialists with refusal scopes
- Hooks: declared to the charter, executed by the harness
- Plugins: behaviors that travel
- MCP: typed bridges to the world
Chapter 21 — Bounding Tools
- What the agent actually reads
- Names and signatures
- Output shape and error feedback
- Idempotency, and saying so
- Description text as a contract
- Every tool is a capability grant
- Permission scopes, named
- Permission posture as a productivity lever
- Destructive operations
- Secret handling
- Sandboxing is a declared policy
- Rate limits as a safety mechanism
- Audit logs that read like a forensic record
- What the safety layer is not
- The artifact — the tool-safety matrix
Chapter 22 — Verifying the Charter Itself
- The charter is code; verify it like code
- Pre-commit safeguards for the charter’s own files
- Code Health for the charter
- A failing safeguard is not negotiated away
- The verify, review, ship loop
- The charter verifies itself
- The charter pre-flight
- The verify skill
Chapter 23 — Retrofitting a Charter into a Repo That Fights You
- There is no single truth to describe
- Delete the lies before you write the truth
- Describe the dominant pattern, not the aspirational one
- Give the agent a rule for living in a mixed codebase
- Bound the charter’s authority to a seam you understand
- Characterize before you let the agent change what you cannot describe
- Ship the small honest charter and let the flywheel grow it
- The artifact: a retrofit charter starter
Chapter 24 — Reading an Unfamiliar Codebase with the Agent
- The claim has to carry a citation
- The imitation trap, seen from the other side
- The reconnaissance loop
- A charter turns reconnaissance into orientation
- Reading is read-only
- The artifact: a reconnaissance skill
Part IV — Scaling and Operating the Charter
Chapter 25 — The Org Charter
- Two scopes, two masters
- What earns the org layer
- The rule of three
- What does not belong
- Consumed as a dependency
- One port spec, many adapters
- Three artifacts, three lifespans
- Principles travel; idioms stay home
- One repo, many agents
- Where a team is on the curve
- The artifact
Chapter 26 — The Charter as a Queryable Service
- Ask instead of carry
- Two halves: policy and context
- Why an MCP server is the right surface
- The tradeoff the service does not escape
- When to serve and when to compile
- The artifact
Chapter 27 — Patterns and Anti-Patterns
- Patterns — the shapes that work
- Anti-patterns — the shapes that fail
- The artifact — a printable cheat sheet
Chapter 28 — Flywheels and Post-Mortems
- The two motions
- Learning, batched
- Pruning, audited
- How the catalog feeds the wheels
- Cadence
- The flywheel ledger
- Post-mortems: from incident to charter patch
- When to run a post-mortem
- Near-misses are free post-mortems
- The run has to be legible first
- Mining the logs for the failures nobody reported
- A short retrospective after every workflow
- The five recurring patterns
- Blameless, but for the charter
- The patch is structural
- The flywheel consumes the output
- The artifact
Chapter 29 — The Codebase That Gets Better With Use
- The compounding claim
- The mechanism, in five moves
- The opposite mechanism, in the absence of discipline
- Measuring the compounding
- The cultural signal
- The quarterly health snapshot
Chapter 30 — Charter Evals
- The charter’s missing test suite
- What an eval is, precisely
- Two questions: capability evals and charter evals
- The protocol, in full
- Build the set from your own failures
- Scoring: deterministic, inferential, and human
- The numbers that matter
- Eval-driven charter development
- The connection to EFC
- Honest limits
- Artifact — a starter eval suite
Chapter 31 — Charter Debt and Versioning
- The symptoms
- The boy-scout rule applies to the charter
- The debt ledger
- The weekly ledger
- What letting debt grow actually costs
- Debt versus the flywheels
- Comprehension debt is charter debt’s twin
- The artifact — a charter-debt ledger row
- The release bites back
- Why cadence is the answer to drift
- Forward-only, always
- Diff and ask
- Versioning semantics
- The release loop
- Changelog discipline
- The artifact — the CHANGELOG entry template
Chapter 32 — Modes and the Curator
- Pacing, not phasing
- Paired — the cadence for unknown ground
- Solo — the cadence for known ground
- Autopilot — the cadence for high-confidence stretches
- Modes are not skill levels
- Stepping up, stepping back
- Mode selection lives in the charter
- The rubric
- From author to curator
- The work, named
- Pair-programming with a constrained partner
- Anti-patterns — what curation is not
- Why the framing matters culturally
- The curator’s daily rhythm
- What is not the curator’s job
- The artifact
Part V — Harness Engineering
Chapter 33 — What Harness Engineering Is
- Agent = Model + Harness
- Two levels of harness
- The dark factory, and the lit one
- The five jobs
- When you actually need to build one
- When an AI product outgrows the API call
- The harness does not care where you sit
- The artifact: should you build a harness?
Chapter 34 — DAG or Loop: The Shape of Control Flow
- Two shapes, one question
- A DAG is just composition
- When the graph earns a framework
- Branching: the path forks on a value
- Map-reduce: fan out wide, fold once
- Failure is an edge, not an exception
- The single edge that turns a DAG into a loop
- The double dovetail
- The symmetry worth naming
- The artifact: a composable stage pipeline
Chapter 35 — Loop Engineering
- Two loops
- What loop engineering is
- The loop feeds itself, and its memory lives on disk
- Structured output: the feedback the loop routes on
- The outer loop: delegate to agents that carry the charter
- What it looks like in practice
- The orchestrator is a team, and Brooks already warned you
- Where it breaks, and how to stop it
- The artifact: a loop spec with the bounds built in
- The bug already had a name
- The orchestrator is a queue
- The primitives you already built by hand
- The queue does not replace the single loop
- Where the queue lives in the stack
- The artifact: a queue spec
Chapter 36 — RAG: Retrieval as a Harness Job
- Fetch strategies, plural
- Search the tree, or search an index
- The vector store, and why it is a harness job
- The corpus is the cache; retrieval is the fetch
- Assembly is a pipeline
- Three ways the supply chain fails
- Retrieval in the factory
- Measuring the supply chain
- The artifact: a retrieval policy
Chapter 37 — Security, Permissions, and Sandboxing
- Least privilege, per run
- Deny by default
- Production is a human gate
- The check is a wrapper, not a habit
- Fail closed
- Isolation for what the check can’t foresee
- Secrets live at the boundary
- Retrieved content is untrusted too
- Log every privileged call
- The artifact: a permission and sandbox config
Chapter 38 — Injection Inside the Grant
- The gate had nothing to refuse
- Where the instruction comes from
- Keep the grant tight — then keep going
- Separate the plan from the payload
- Spotlight what you cannot reduce
- Bound the decision, not just the capability
- Tripwires on the diff
- Exfiltration rides allowed channels
- Detection, because prevention leaks
- The honest limit
- The artifact: a merge gate the fleet cannot talk past
Chapter 39 — Model Selection and Routing
- Route the step, not the task
- The model is a seam, so routing is a policy over it
- Start cheap, escalate on failure
- A model version is a dependency — pin it
- Routing is a decision, and decisions can be wrong
- The artifact: a routing policy with an escalation ladder
Chapter 40 — Cost and Resource Control
- Every call costs three things
- The ceiling has to throw
- Poison items and attribution
- Routing and caching: paying less for the same answer
- Rate limits and backpressure
- When the ceiling moves up a layer
- Cost is a sensor on everything upstream
- What the spend buys
- The artifact: a budget config
Chapter 41 — Testing the Harness
- Test what the model doesn’t touch
- The model is a seam
- Routing tests: assert every branch, especially the one evals skip
- Bounds tests: prove the ceiling stops the loop
- Structured-output tests: prove the retry fires and the giving-up is real
- Integration tests: prove resume does not repeat work
- Determinism is a thing you engineer into the test
- What not to test
- The artifact: a harness test file
Chapter 42 — Building the Harness on a Framework
- The account you need first
- The shape every version builds
- LangChain
- LangGraph
- Deepagents
- Pydantic AI
- The three you may want instead
- Choosing, and not choosing
- Build vs buy, one layer up
- The artifact
Chapter 43 — Framework Patterns and Structure
- LangGraph: control flow as a graph
- LangChain: output shape as a contract
- Deepagents: decomposition made explicit
- Pydantic AI: the contract between model and code
- The same benefit, four doors
- The artifact
Chapter 44 — Harness Concerns, Solved
- Implementing tools
- Structured output
- Bounded retries and error feedback
- Memory and the token budget
- Streaming
- Sandboxing the tool surface
- The artifact
Chapter 45 — Building a Coding Harness
- The agent loop is the harness
- The tools the loop turns on
- The gate closes the loop; the cap catches it
- Fresh clone, sandboxed tools, PR out
- The artifact
Chapter 46 — Harness Evals
- Two targets, one job
- A corpus is data
- A scorer is a function you pass in
- The runner is a map
- Gating on the number
- Offline and online
- The artifact: harness eval template
Part VI — Orchestration Engineering
Chapter 47 — Intent Contracts (and Why Vibe Coding Breaks at Team Scale)
- What vibe coding hides
- Narrow the input, at team scale
- Seven sections, every time
- Falsifiable matters
- Tag what is known
- Goal mode and debate mode
- The ticket is the contract
- Split the contract at Intake
- A context budget per contract
- What this discipline is borrowed from
- The honorable mention: spec-driven development
- The contract template
Chapter 48 — The Six Phases and Interrupts
- Why six
- A touchpoint at every phase boundary
- Each phase has an exit, and the exit is explicit
- The observability test for any gate
- The ticket is the contract
- What goes wrong without phase discipline
- A short note on tooling
- Interrupts: how agents ask
- Guessing is the failure mode
- The shape of an interrupt
- The shape of a resolution
- One question per interrupt
- The interrupt rate is a sensor on the charter
- Anti-patterns
- When the interrupt is the agent’s only honest move
- The inverse: when the human has to correct the agent
- The artifact
Chapter 49 — Topology and the Daemon
- Three names, one system
- When a second agent earns its slot
- When the second agent does not earn its slot
- The four topology patterns
- Pipeline vs barrier: when stages have to wait
- Patterns for discovery work
- Two operational rules for any pattern
- Topology nodes meet the charter
- The daemon in the middle
- The sixty-second tick
- Fresh clones, every time
- Fire-and-forget dispatch
- The dispatch is one line, until it is not
- The operational surface
- A worked tick
Chapter 50 — The Orchestrator on a Framework
- A node is a harness
- The frameworks, one altitude up
- Why not one clever agent
- The artifact
Chapter 51 — Orchestrator Patterns in a Framework
- Supervisor and router
- Fan-out and fan-in
- Pipeline
- Hierarchy and teams
- The same benefit, one floor up
- The artifact
Chapter 52 — Orchestrator Concerns, Solved
- Shared state across agents
- Capping the fan-out
- Durability across a long run
- Human-in-the-loop, mid-topology
- Observability across the fleet
- Cost across the fleet
- The artifact
Chapter 53 — Reducible Workflows: The DAG That Loops
- The shape has a name: a reducible graph
- A single loop
- Nested loops: TDD
- Deeper nesting, and where it lives
- The reducible orchestrator
- The artifact: a reducible-workflow check
Chapter 54 — Beyond the Reducible Graph: State Machines, Choreography, and Sagas
- When the process never ends: state machines
- When there is no orchestrator: choreography
- When you cannot just stop: sagas and compensation
- Which shape?
Chapter 55 — Orchestration Patterns
- The orchestrator is a queue, not an agent
- The process is data, and there is more than one
- Bounded, recoverable work is canon, not invention
- Routing, failover, quotas
- Human attention is data
- Everything is a row
- When to split the agent
- The review, in one page
Chapter 56 — Dark Factories
- Where the human stands
- Sensors report, gates refuse
- The asymmetry: analyze freely, change under a signer
- Bounds are policy
- What the meter says
- Field notes
- What the dark cannot do
- The artifact: a lights-out readiness policy
Chapter 57 — Lights-On Factories
- The platform layer
- The autonomy ladder
- The frozen record
- Coverage and imitation surfaces
- Experiments in production
- What openness costs
- The openness config
Chapter 58 — Orchestrator Evals
- The unit of measure changes
- The failures live between the agents
- Two ways to run one
- The artifact: an orchestrator scorecard
Part VII — Cross-Cutting Concerns
Chapter 59 — From Tribal Knowledge to Deterministic Workflow
- The four rungs
- The direction is the point
- Maintaining the ladder against reality
- The work is the process, not the artifact
- The artifact
Chapter 60 — Cross-Cutting: The Themes That Hold on Both Sides
- The three levers are substrate-independent
- Constraints come in layers, and the layers have precedence
- Everything accrues debt
- Everything runs against a finite budget
- The model’s output is untrusted, so validate at the boundary
- Measurement over assertion
- Feedback loops keep both honest
- Reach for the heavier substrate late
- Where this hands off
- The artifact: the cross-cutting audit
Chapter 61 — The Layers a Business Governs
- The stack is taller than the code
- Governance is the org charter, grown up
- Govern before, observe after
- The hardest question is not whether the rules were followed
- Authority: the slot the mechanism cannot fill
- Purpose: the layer that makes the rest worth building
- The same discipline, all the way up
Epilogue — Containment, Not Completeness
- The harness does not escape it either
- Sensors outside the rules
- What does not change is consistency
Appendix A — Vocabulary Reference
- Foundations and Taxonomy
- The Charter: Files That Govern
- The Codebase
- The Delivery Process and Orchestration
- The Organization
- Operating the Charter
- From Experiments to Tool
- Part V — The Harness
Appendix B — Templates
- CLAUDE.md skeleton (Ch 11)
- Rule file skeleton — iron, golden, preference (Ch 12)
- Corpus map — five directories (Ch 13)
- Skill skeleton — eight checkpoints (Ch 20)
- Agent definition skeleton (Ch 20)
- Hook configuration skeleton — five patterns (Ch 20)
- Plugin manifest skeleton (Ch 20)
- MCP tool design checklist — eight questions (Ch 20)
- Intent contract template — seven sections (Ch 47)
- Phase-transition checklist (Ch 48)
- Interrupt template (Ch 48)
- Release-readiness gate — five checks (Ch 48)
- PR template — five sections (Ch 48)
- Org-rule charter (Ch 25)
- Promotion-candidate template (Ch 25)
- Three-artifact decision tree (Ch 25)
- Post-mortem template (Ch 28)
- Charter-debt ledger row (Ch 31)
- Charter CHANGELOG entry (Ch 31)
- Mode-selection rubric (Ch 32)
- Curator’s daily checklist (Ch 32)
- 30-day calendar template
Appendix C — Sources
- Foundational engineering canon
- Foundational agent literature
- Adjacent disciplines
- Mathematics and theory
- Contemporary harness and agent-coding writing
- Naveen Gaddam — AI Replaced 80% of Coding, Only These 7 Skills Are Left (Medium, 2026). A popular-register version of a thesis the book argues at length: syntax automates, engineering does not. Included as a pointer to how the argument travels outside the practitioner core.
medium.com/@gaddamnaveen192/ai-replaced-80-of-coding-only-these-7-skills-are-left-128e13d3020d - Honorable mentions: tools, frameworks, and runtimes
- The author’s blog archive
Appendix D — The Tools Behind the Book
- sigma — the harness layer, built from scratch
- open-refinery — the agentic-workflow layer, kept open
- What the three tools embody
- Run the post-mortem on your own tool
- Keystone: the synthesis
- What Keystone is, in one paragraph
- The charter discipline, shipped
- The first command
- The directory layout
- Sensors, signals, playbooks, adapters — the lifecycle in markdown
- The companion surfaces
- The three-ring principle, mapped
- The cascade, now a policy tree
- Forward-only upgrades
- A worked first task, end-to-end
- The full chain, every contract
- What the agent reads on each turn
- What Keystone does not do
- What Keystone kept and dropped
- A copyable getting-started recipe
Appendix E — For the Junior Engineer
- Comprehension is the job
- What the team owes you
- Pair with a senior, and the agent makes three
- Read open source with an agent
- Exercises
- The path