What Is the Ralph Wiggum Technique for AI Coding Agents?

157.5K views
•
January 5, 2026
by
Matt Pocock
YouTube video player
What Is the Ralph Wiggum Technique for AI Coding Agents?

TL;DR

The Ralph Wiggum technique runs a coding agent inside a simple bash for loop that repeatedly picks the highest-priority task from a PRD, completes only that one feature, updates the list, and commits, until the backlog is empty. Clearing context each iteration keeps the model sharp, making it a simpler, more reliable alternative to multi-phase plans or agent swarms.

Transcript

I'm going to do something I don't usually do for these videos and give it a pretty hypy intro. One of the dreams of coding agents is that you can wake up in the morning to working code that your coding agent has worked through your backlog and has just spit out a whole bunch of code for you to review and it works. Now, people have been trying to ma... Read More

Key Insights

  • Ralph Wiggum is a bash loop that hands a coding agent a task list and runs it again and again until every task is complete, credited to Jeffrey Huntley in an article published on the 14th of July.
  • The technique works because it clears the agent's context between iterations, so the model never gets swamped by too many tokens, which is when LLMs 'get really stupid' and produce crappier code.
  • Simple orchestration like Ralph became viable only because underlying models such as Opus 4.5 and GPT 5.2 are now very good, making complex swarms, meshes, and orchestrators unnecessary.
  • Ralph mirrors how real engineers work: pick the next highest-priority task from the board, complete it, return to the board, and repeat until the sprint is done, rather than pre-planning an exact path through every task.
  • The loop takes a maximum iteration count as an argument and yells if you omit it, giving a stop condition in case the LLM never decides the work is finished.
  • The PRD is a plans/prd.json file of user stories, each carrying a 'passes' flag that doubles the document as a to-do list; the LLM marks items 'passes: true' when the feature works in the app.
  • A progress.txt file acts as the LLM's memory for the sprint, appended to (not overwritten) so learnings accumulate; 'append' is used deliberately because 'update' makes the model rewrite the whole file.
  • The prompt forces work on only a single feature per loop and requires a git commit each iteration, preventing the agent from biting off more than it can chew and giving it queryable history for context.

Explore YouTube Video Summarizer or Get YouTube Transcript Extractor

Questions & Answers

Q: What is the Ralph Wiggum technique in AI coding?

Ralph Wiggum is a bash for loop for running coding agents. You give an LLM a list of tasks to complete and run it again and again until the work is done. Credited to Jeffrey Huntley in an article published on the 14th of July, it is an extremely simple approach to agent orchestration that the presenter calls a vast improvement over any other AI coding setup he has tried, letting you actually ship working code with long-running agents.

Q: Why does clearing context between loop iterations matter?

A single AI cannot work through an entire backlog at once because the collective tasks are too big to fit in one context window, so the model gets confused, breaks, and produces crappy code. By clearing its context as it goes and working on only one feature per loop, the agent avoids adding too many tokens to the context window. LLMs get really stupid as you add more tokens, so keeping each iteration focused preserves code quality.

Q: How is the PRD file structured for Ralph?

The plans/prd.json file contains a bunch of user stories, each describing a feature to build, such as a 'beats' feature that displays three orange ellipsis dots below a clip. Every item has a 'passes' flag telling the LLM whether that story currently passes in the application code. This makes the PRD both a product requirements document and a to-do list: an item is considered done when it has 'passes: true' on it.

Q: What is the progress.txt file used for?

progress.txt is a free-text log that the LLM appends to with its learnings as it goes through the sprint, acting as the LLM's memory for that sprint. The presenter usually deletes it at the end of a sprint. It is passed into the loop alongside the PRD so the agent sees prior learnings, and the prompt advises using it to leave a note for the next person working in the codebase.

Q: Why use append instead of update for progress.txt?

The prompt tells the LLM to append its progress to progress.txt because append is really important. If you tell the model to update the file, it will usually rewrite the entire file, whereas telling it to append means it just sticks some new content at the end. This preserves the accumulated history of learnings across loop iterations instead of overwriting them each time the agent runs.

Q: Why does each loop iteration make a git commit?

The prompt tells the agent to make a git commit of the feature it worked on, committing the PRD, the progress.txt file, and all the work it did. This means every pass through the loop produces a git commit. It is really useful because the LLM can query the git history, as well as read progress.txt, to see what was done previously and gain context for what it needs to do now.

Q: Why should tasks in the PRD be kept small?

The prompt restricts the agent to a single feature per loop to prevent it from biting off more than it can chew, since asking an LLM to do the whole thing degrades code as tokens pile up. Task sizing matters too: if one enormous task sits among smaller ones, the LLM gets swallowed up when it reaches it. Designing all tasks nice and small makes things easier for the agent, and it is just good practice for humans as well.

Q: How does the ralph.sh script actually run the loop?

The ralph.sh script first sets error mode so any errors are thrown. You run it and pass in the maximum number of iterations; omitting that makes it yell at you. It runs a for loop that stops if you pass the max iterations, giving a stop condition in case the LLM never completes. It logs a line, then invokes a CLI coding agent, passing in the local plans/prd.json and progress.txt files, with a prompt listing the steps to complete.

Summary & Key Takeaways

  • The dream of waking up to working code from a coding agent has driven attempts at agent swarms, meshes, and orchestrators, but the Ralph Wiggum technique achieves it with just a bash for loop. It is a dramatic simplification over other AI coding orchestration setups and lets you ship working code with long-running agents.

  • Previously the presenter used big multi-phase markdown plans, building them in plan mode and running each phase in a fresh context window. That approach is hard to modify: adding a task means squeezing it between steps and reworking the whole path, which does not reflect how engineers actually pick tasks off a board.

  • The ralph.sh script sets error mode, takes a max-iteration count, logs each pass, and invokes a CLI coding agent (Claude, open code, codex, whatever) passing in prd.json and progress.txt. The prompt tells it to find the highest-priority feature, work only on that, update the PRD, append progress, and make a git commit.


Read in Other Languages (beta)

Share This Summary 📚

Explore More Summaries from Matt Pocock 📚