Free book Autonomous AI coding

The loop that forgets on purpose.

Long sessions make AI assistants worse: the window fills, the answers drift and the costs climb. The Ralph Loop turns that weakness inside out; one task per fresh instance, results committed to git, then a clean slate for the next. This book is the practitioner's guide.

ralph.sh
$ ./ralph.sh --prd tasks.json

# iteration 14, fresh instance
[task 09/12] add retry to export job
✓ tests green
✓ committed 4f1c9a2
# instance terminated, context discarded
# memory lives in git, not the window

$ ./ralph.sh --prd tasks.json

fig. 1 · one task per instance; context never compounds

01 The premise

Why does an assistant that began the morning brilliant end the afternoon mediocre? Because a context window is not a memory; it is a desk, and every hour piles more paper onto it. Decisions made early get buried, summaries drift from what was actually agreed and the model starts producing work that is plausible rather than right.

The conventional response is to fight the forgetting: bigger windows, cleverer compaction, ever-longer prompts. The Ralph Loop does the opposite. It accepts that a fresh context is the model at its best and builds the whole workflow around that fact: one task, one clean instance, one commit, then the instance is thrown away. Memory lives in the filesystem, where it belongs.

02 The evidence

The degradation is measured, not imagined.

The research the book is built on, in six figures.

models fall below 50% accuracy at 32K tokens
11 / 12
NoLiMa Research, 2024
accuracy degradation in extended sessions
99 → 70%
GPT-4o Study
cost reduction with fresh-context iteration
~50%
JetBrains Research
of developers spend time correcting AI output
66%
Stack Overflow Survey
of agentic AI projects forecast to be scrapped by 2027
40%
Gartner Prediction
hallucination rate in reasoning-heavy scenarios
79%
Academic Research

03 The method

Five steps, repeated indefinitely.

Fresh-context iteration is almost embarrassingly simple to state; the craft is in the details the book supplies.

  1. Brief

    Give the model one specific, well-bounded task; nothing more.

  2. Build

    Let it work autonomously until the task is genuinely done.

  3. Commit

    Record the result to the filesystem as a git commit.

  4. Terminate

    Discard the instance, accumulated context and all.

  5. Repeat

    Start a fresh instance on the next task, clean as the first.

Compaction is the devil.

Geoffrey Huntley, creator of Ralph Wiggum Loops

04 Inside the book

Seven chapters, from origin story to post-mortem.

  1. History and discovery

    Where the technique came from, who shaped it and how it spread.

    Free preview
  2. Theory and foundations

    The science of context degradation, the research behind it and the economic case.

    Research
  3. Modes, workflows and PRD writing

    Build, plan and reverse modes; how to structure work so a loop can run it unattended.

    Core
  4. Practical application with Claude Code

    Step-by-step implementation, the snarktank/ralph setup and configuration.

    Hands-on
  5. Warnings and anti-patterns

    Security considerations, the fire-and-forget myth and the cases where Ralph is the wrong answer.

    Critical
  6. Beyond Claude Code

    Goose, Ralphy, Ralph Orchestrator and the Vercel AI SDK, compared without favour.

    Tools
  7. Troubleshooting and failure modes

    Decision trees, debugging, cost optimisation and recovery procedures.

    Reference

05 The readers

Wherever you are starting from

The book is arranged so that three quite different readers each find their chapter.

  • Beginner

    New to AI coding

    What a context window is, why it matters and a step-by-step first loop of your own.

  • Intermediate

    Using AI daily

    PRD writing, task sizing, workflow selection and the common mistakes worth skipping.

  • Advanced

    Building systems

    Cross-tool comparisons, troubleshooting decision trees and honest guidance on when not to loop.

06 The author

Written from practice, not prediction.

Harry Munro, Chartered Engineer and author of The Ralph Loop

Harry Munro is a Chartered Engineer, founder of the School of Simulation and author of Vibe Modelling (2025). Years of probabilistic modelling for London Underground taught him that accounting for real-world variability matters more than theoretical perfection; autonomous AI systems, it turns out, obey the same law.

Everything in the book has been run, broken and re-run on real projects; the troubleshooting chapter exists because the failures did.

07 The small print

Questions, answered

Do I need to know Claude Code already?

No. Basic command-line and git familiarity is enough; chapter 4 walks through the setup step by step.

Is this only for Claude?

No. Chapter 6 covers Goose, Ralphy, Ralph Orchestrator and the Vercel AI SDK; the principles are tool-agnostic.

Will this make my AI coding fire and forget?

It will not, and the book says so plainly; chapter 5 is devoted to dismantling exactly that myth.

I have been running Ralph loops for months. Is there anything here for me?

Yes; the troubleshooting decision trees and the cross-tool comparison were written with experienced practitioners in mind.

Read it tonight; loop it tomorrow.

Seven chapters, free, delivered as PDF and EPUB the moment you ask. If it saves you one derailed afternoon of context babysitting, it has paid for itself several times over; which, being free, is admittedly a low bar.

Prefer a copy you can keep? Buy on Amazon