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.
Get the book free
PDF and EPUB, sent to your inbox immediately. Prefer a copy you can keep? Buy it on Amazon.
$ ./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.
-
Brief
Give the model one specific, well-bounded task; nothing more.
-
Build
Let it work autonomously until the task is genuinely done.
-
Commit
Record the result to the filesystem as a git commit.
-
Terminate
Discard the instance, accumulated context and all.
-
Repeat
Start a fresh instance on the next task, clean as the first.
Compaction is the devil.
04 Inside the book
Seven chapters, from origin story to post-mortem.
- Free preview
History and discovery
Where the technique came from, who shaped it and how it spread.
- Research
Theory and foundations
The science of context degradation, the research behind it and the economic case.
- Core
Modes, workflows and PRD writing
Build, plan and reverse modes; how to structure work so a loop can run it unattended.
- Hands-on
Practical application with Claude Code
Step-by-step implementation, the snarktank/ralph setup and configuration.
- Critical
Warnings and anti-patterns
Security considerations, the fire-and-forget myth and the cases where Ralph is the wrong answer.
- Tools
Beyond Claude Code
Goose, Ralphy, Ralph Orchestrator and the Vercel AI SDK, compared without favour.
- Reference
Troubleshooting and failure modes
Decision trees, debugging, cost optimisation and recovery procedures.
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.
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 AmazonGet the book free
PDF + EPUB sent to your inbox immediately · Free