📖 Living glossary (the new terms in this module)
Track 1 has already defined “model,” “agent,” “prompt,” and “harness.” Here are just the terms new of loops and queues—learn these before moving on:
while does this: “while X is true, repeat.”while in bash that calls Claude Code with the same prompt over and over, nonstop.agent:implement) that marks the state and triggers automations.🔁 The Ralph loop (Huntley)
🧠 Imagine it this way: a washing machine on the spin cycle—spinning, spinning, spinning nonstop until someone presses the button. The Ralph loop is that with AI: you “turn on the spin cycle,” and the agent runs the same instruction in circles on its own all night.
In July, the engineer Geoffrey Huntley published an article (14/jul) that went viral in the community: the Ralph loop. The idea is delightfully simple — you write a loop while in bash that calls the Claude Code passing the same prompt again and again. The agent finishes one pass, the loop restarts, and it receives the instruction again. It runs like this, in AFK, without you at the keyboard.
The name "Ralph" is an inside joke (a reference to the character Ralph Wiggum from The Simpsons, who does simple things without thinking too much) — and part of the fun is precisely that: brutally simple, yet effective. Why does it work? Because each new agent run starts with fresh context and rereads the state of the codebase and takes it one step further. It’s the rawest way to take you out of the equation. The common mistake here is thinking “loop = autonomous magic”: the loop only repeats; the agent still does the work, and it depends on the prompt and the harness behind it.
The Ralph loop: one while that reinjects the same prompt into Claude Code indefinitely.
⚠️ Common beginner mistake
Think that you can just "leave the loop running" and miracles will happen. Without a stop condition, a "done" criterion, and a well-written prompt, the loop can run all night repeating the same mistake—and burning tokens. The loop is the repetition engine; the intelligence is still your harness.
In one sentence: the Ralph loop is a while that repeatedly calls Claude Code with the same prompt, on its own.
Going deeper (optional): where did "Ralph" come from?
Huntley gave the technique the playful name "Ralph": the approach is as direct and naive as the character who simply does the obvious task in a loop, without a sophisticated strategy. The article’s insight is that, counterintuitively, this brute simplicity sometimes beats elaborate techniques—as long as the prompt and environment are good. It’s the "brute force" version of agentic automation.
🎯 Why a loop ≠ an answer
🧠 Imagine it this way: you want someone to paint a wall. You can (a) tell them to "paint walls forever" and hope they get yours right, or (b) give them a specific task: "paint this wall blue." Option (b) is almost always better. Loop ≠ task.
Here comes Pocock's position—and it's an important turning point. He recognizes that the Ralph loop is ingenious, but says in no uncertain terms: "I don't need to run it as a loop — I just need the AFK agent to pick up a specific task and do it." In other words, what really unlocks it isn’t the infinite repetition; é o AFK (the agent working without you present). The loop is just one way—and not the best—to achieve that.
Why? Because a single loop that tries to “do everything” doesn’t match how real teams work. A team doesn’t have a robot spinning forever; it has a backlog clear tasks, each with a beginning, middle, and end. Blind repetition wastes tokens, loses focus, and makes it harder to say “this is done.” According to Pocock, the right answer is to change the verb: instead of "loop", think about "pick up the next task from the queue". Same autonomy, much more control and clarity. A common mistake is confusing “running on its own” (good: AFK) with “running in circles” (rarely what you want).
Quick recall: for Pocock, what really unlocks autonomous work?
In one sentence: what unblocks you is AFK (a specific task done on its own), not repeating the loop endlessly.
📋 The task queue
🧠 Imagine it this way: the grocery store checkout line. People (tasks) arrive and get in line. Each cashier (node) calls the next person, serves them, finishes, and calls the next. Nobody stays "serving forever in circles" — one customer is served at a time until the line is empty.
Pocock’s central point is: "I think of this mainly as queues, not loops." A queue is simply your backlog tasks. And he gives the concrete example of Sand Castle (his tool): it looks at issues, triages it (is it trivial? is it possible?), adds the label agent:implement and the agent implements it via GitHub Actions (covered in module 4.3).
And then comes the definition that organizes everything: "all development is just a" task queue: PMs add tasks to the queue; you complete them; multiple nodes (devs) pick items from the queue." Notice how this describes any software team in the world — without any AI involved. The PM feeds the queue, developers consume. Pocock’s insight is that the “nodes” can now be agents instead of (or alongside) humans. You don’t change the team’s mental model—you just change who picks up the items. That’s why the queue fits naturally, and the one loop that “does everything” doesn’t match how teams work.
In one sentence: all development is a queue — PMs add items, and we (developers or agents) pick them up and complete them.
🔎 Triage and scope
🧠 Imagine it this way: a hospital emergency room. When the patient arrives, the nurse triage doesn't handle them right away — it classifies them: minor, urgent, or critical. Only then does each case go to the right place. The task queue works the same way: classifying before handling prevents waste and chaos.
Before an item becomes work, it goes through triage. In the Sand Castle workflow, Pocock looks at each issue and answers two questions: is it trivial? e is it possible? — and this can already be done in AFK. There’s a real issue (#795 in his example) that keeps changing its label: agent:explore → agent:in-progress, while the bot github-actions post a comment of "Triage" with a TL;DR and an estimate of Difficulty (difficulty).
Why does this matter? Because triage gives you scope — and scope is what separates a “pick-up-able” task from a vague request. When the agent gets “implement issue #795, medium difficulty, TL;DR: such-and-such,” it has a clear target. Compare that with “fix the bugs” tossed into a loop: there’s no place to start and no way to know when it’s done. Triage also filters out what no should go to the agent alone (things that require human judgment). The common mistake is to skip triage and dump everything raw into the queue — then the agent works hard on the wrong item or stumbles on an impossible one.
Triage is a funnel: it classifies each issue by trivial? e possible? before it becomes work.
🔬 Worked example: an issue’s lifecycle in the queue
Follow the issue #795 ("export button doesn't work in Safari") move through the queue:
- 1Join the queue — the PM (or a user) opens the issue. Raw state, without analysis.
- 2Label
agent:explore— starts AFK triage. The agent investigates and the bot posts: "TL;DR: Safari compatibility bug. Difficulty: low." - 3You prioritize — see that it’s trivial and safe. Add
agent:implement. - 4Label
agent:in-progress— GitHub Actions implements it, opens a PR, and the human checkpoint is only at the final review.
In one sentence: triage (trivial? possible?) gives you a clear scope — without it, the agent works on the wrong item.
👑 The medieval king
🧠 Imagine it this way: A king in a throne room. Problems arrive at the door all day — an invasion at the border, a failed harvest, an alliance proposal. The king doesn’t run to each one; they receives, evaluates, and prioritizes. It’s exactly the mindset of someone managing a queue.
David (the interviewer) offered an analogy that crystallizes the difference between a loop and a queue: the medieval king. Think of a minister in a distant region running in a loop on its own—it can go well, or it can go very wrong, and the king only finds out once the damage is done. That's the "loop" approach: blind autonomy, with no central prioritization. The sensible king doesn't want that.
The king wants the queue-based approach: the problems reach him (an invasion, a hunger, a proposal for brand deal — where it checks reputation first before accepting), and it prioritizes. Out of 50 bugs that come in, maybe only 3 are critical — and it decides which ones to tackle now. The point, in the conversation’s words: you keep in the command. The queue doesn't take away your decision-making power; it focuses it on what matters. The loop hands the kingdom to a distant minister; the queue keeps the crown on your head. Common mistake: delegating autonomy without keep the prioritization point — then you become an absent king, and the kingdom does whatever it wants.
✗ Loop = distant minister
- • Runs on its own in the background, without prioritization.
- • It could work—or end in silent disaster.
- • You only discover the damage at the end.
✓ Queue = king in command
- • Problems come in; you prioritize them.
- • 50 bugs, only 3 are critical right now.
- • Delegated autonomy, with the crown on your head.
In one sentence: be the king who receives and prioritizes the queue—not the one who hands the kingdom over to a minister in a loop.
🕸️ Multiple nodes in the queue
🧠 Imagine it this way: A busy restaurant kitchen. There’s a single order queue (the ticket rail), but several cooks. Each one takes the next order, prepares it, and sends it back. More cooks = the same queue clears faster — without anyone getting in another’s way.
Wrapping up the module: the biggest advantage of thinking in terms of a queue is that it scales with multiple nodes. Remember Pocock’s line: "multiple nodes (devs) pick up items from the queue." Each node could be you, a colleague, or an agent running in GitHub Actions (module 4.3). Since each task has a clear scope (thanks to triage), two or three agents can work in parallel on different tasks without getting in each other’s way—exactly what you saw in module 4.2 about parallelizing with sandboxes. The single loop doesn’t scale that way: it’s just one worker, spinning. The queue is an architecture—it makes room for “two, three, four of you,” as Pocock describes AFK. Use the skeleton below to try the Ralph loop and experience for yourself why, in the end, you’ll want to move from it to a queue with triage:
#!/usr/bin/env bash
# Ralph loop (Geoffrey Huntley, 14/jul) — o esqueleto cru:
# um while que chama o Claude Code com o MESMO prompt, de novo e de novo.
PROMPT="Pegue a próxima tarefa pendente em TODO.md, implemente-a,
rode os testes e marque-a como feita. Se TODO.md estiver vazio, escreva DONE.txt."
while true; do
# injeta o mesmo prompt no agente, em modo AFK (sem você no teclado)
claude code -p "$PROMPT"
# condição de parada: o agente sinaliza que a fila esvaziou
if [ -f DONE.txt ]; then
echo "Fila vazia — encerrando o loop."
break
fi
sleep 2 # respiro entre as passadas
done
# Lição do módulo: isto FUNCIONA, mas é um loop cego (1 nó, foco difuso).
# Prefira virar isto numa FILA: triagem -> label agent:implement ->
# vários nós (agentes em GitHub Actions) puxam itens em paralelo. Você, o rei, prioriza.
Quick recall: what's the biggest advantage of the queue over the single loop?
In one sentence: the queue is an architecture that scales — several nodes pull clear tasks in parallel; the loop is just one worker spinning.
🧾 Module Summary
while in bash that calls Claude Code with the same prompt, repeatedly.Next module:
4.5 — Self-improving systems: security review cron, telemetry → issue → fix, and why you don’t need the most expensive model.