AI: The Ralph Loop "Ralph Loop" (or Ralph Wiggum Loop) is an architectural pattern where an AI coding agent is wrapped in an infinite while loop to execute tasks autonomously over long periods. How a "Ralph Loop" Works Task: You feed the loop a structured backlog, like a local Product Requirements Document (prd.json) or a checklist. Fresh Instance: The loop spawns a brand-new AI agent session (using tools like Claude Code or Gemini CLI) with a clean context window. Execution & Memory: The agent reads the checklist, picks the highest-priority task, edits the code, and runs your compiler, linter, or test suite. Stop Hook Intercept: When the AI attempts to exit, a custom script or hook intercepts it and verifies if the code compiled and if tests passed. Next Iteration: If the task failed, the script launches a fresh agent instance. Because the previous agent modified files and left notes on disk, the new agent picks up right where the last one left off. The loo...