Leanpub Header

Skip to main content

Loop Engineering: The Practical Guide to Building AI Agents That Work While You Sleep.

Stop prompting your AI. Start engineering the loop. The best engineers no longer babysit agents — they design systems that discover work, verify it, and run while they sleep. Loop Engineering is the complete guide: goals, verification, memory, scheduling, and orchestration with Claude Code — plus four end-to-end builds. Wake up to finished work, not chat transcripts.

Minimum price

$39.00

$49.00

You pay

Author earns

$

Also available for 2 book credits with a Reader Membership

PDF
EPUB
About

About

About the Book

**Stop prompting your AI agents. Start engineering the loops that run them.**


A quiet revolution has reshaped how the best engineers and teams work with AI. They no longer sit at the keyboard feeding prompts to a coding agent — they design **loops**: autonomous systems that discover work, execute it, verify it against real standards, remember what happened, and run on a schedule while nobody watches. In the morning, a human reviews pull requests, reports, and drafts — not chat transcripts.


This is **loop engineering** — the discipline behind agentic AI's leap from assistant to workforce — and this book is the first comprehensive, practical guide to doing it well.


**A complete textbook AND a hands-on user's guide.** Written for developers, technical PMs, founders, and operators alike, every concept is taught in plain language before any code appears — and every principle is then implemented, step by step, with the Claude toolkit: Claude Code, the /goal command, cloud routines, subagents, hooks, skills, dynamic workflows, and the Claude Agent SDK. The principles transfer to any capable agent platform.


**Inside, you'll learn how to:**


- Move up the stack from prompt engineering to context, harness, and loop engineering — and diagnose failures by layer
- Write goals and stop conditions an autonomous agent can actually be held to (and know when a task isn't loop-ready)
- Build verification that works: the generator/evaluator split, adversarial review, deterministic gates, and defense in depth — because in loops, the verifier, not the model, is the bottleneck
- Give your loops memory that outlives the model: progress files, contracts, CLAUDE.md, and git as a state spine
- Schedule unattended runs safely — triggers, cadences, budgets, idempotency, and the dead-man's switch
- Orchestrate at scale with subagents, parallel worktrees, and dynamic workflows — and choose pipeline vs. swarm with the coupling test
- Apply the six orchestration patterns every production loop is built from
- Take loops beyond code: research digests, support triage, content pipelines, data cleanup, and CRM hygiene
- Control the hidden costs — verification debt, comprehension rot, cognitive surrender, token blowout — with a twelve-number operating dashboard
- Secure and govern it all: prompt-injection defense, least privilege, irreversibility gates, charters, owners, and post-mortems


**Four complete end-to-end builds** — a self-healing CI loop, a backlog-burning feature loop, a competitive-intelligence digest, and a long-horizon multi-session project — each with its prompts, configurations, rehearsal plan, and a real failure diagnosed and fixed. Plus five appendices: a one-page design checklist, six copy-paste templates, a glossary, decision trees, and an annotated reading list.


**Who this book is for:** software developers adopting Claude Code and agentic workflows; technical product managers and founders who must scope, budget, and govern AI agents; and knowledge workers automating recurring responsibilities — no terminal required for the concepts, the patterns, or the governance.


AI can now generate almost anything. What's scarce is judgment — and loop engineering is how you scale yours. **Read this book, and build agents you can actually trust with the night shift.**

Share this book

Author

About the Author

Geoff Muir

Geoff is a seasoned AI enthusiast who has dedicated countless hours and resources to understanding how AI agents really work — not just what they can generate, but how to make them work reliably, autonomously, and at scale.

His hands-on exploration of Claude, Claude Code, and agentic workflows has led him to write Loop Engineering: The Practical Guide to Building AI Agents That Work While You Sleep, a comprehensive guide to the discipline behind autonomous AI work.

In Loop Engineering, Geoff shares his wealth of practical knowledge, taking readers beyond prompting and into the systems that make agents dependable: verifiable goals, verification that can't be fooled, memory that outlives the model, safe scheduling, and orchestration at scale. He demystifies agent orchestration step by step, offering field-tested strategies, complete worked builds, and the governance practices that turn capable AI into trustworthy AI.

Join Geoff in exploring the frontier of autonomous AI — and discover how to engineer loops you can trust with the night shift.

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

See full terms...

Earn $8 on a $10 Purchase, and $16 on a $20 Purchase

We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

In fact, authors have earned over $15 million writing, publishing and selling on Leanpub.

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub