If you've opened Twitter lately, you've seen that everyone is talking about the Ralph Loop (it was called Ralph Wiggum before, but the name was changed due to copyright issues) for programming.
The Ralph Loop is a technique that keeps your AI agent working on a task (or a list of them) until it's 100% complete.
Basically, it consists of launching our AI agent with this format:
while :; do claude < PROMPT.md; done
If we analyze the script, we can see that we are:
- In an infinite loop
- Always reading what's in a PROMPT.md
The key is what's inside that prompt. The simplified content would be:
# Task list
<tasks>@tasks.json</tasks>
# Progress made
<progress>@progress.txt</progress>
# Steps to follow
1. From the task list, select the highest priority one (it doesn't have to be the first one). IMPORTANT: Work only on that task.
2. Verify that the task works. Run the tests and if applicable, open a browser to see that there are no errors.
3. Update the tasks file marking the task as done.
4. Add the progress made to the progress txt. This is a good place to leave notes for the next person who will do the next task.
5. Commit all changes.
# Completion
If you see that there are no tasks left in the tasks json, write: <promise>COMPLETED</promise>
Here we can see that we're going to have 2 very important files:
- tasks.json: A file that will contain a list of tasks to do. This could perfectly be a connector to JIRA, Linear, Notion, GitHub Issues...
- progress.txt: A file where the agent will leave notes about the tasks it does that it finds relevant. It's interesting so that the next agent knows which task to perform.
The task loop will stop once there are no tasks left (we need to modify the script so that if it sees the text <promise>COMPLETED</promise> it stops execution). We can also modify it to tell it how many tasks to complete via parameter.
The good thing about using this loop is that:
- Each iteration of the loop starts with a clean context. Therefore, there won't be context rot for each completed task.
- The agent is 100% autonomous.
And obviously, this script can be improved to:
- Get tasks from our task system.
- Create a branch for each of them and a pull request. This way there's human in the loop to validate that everything is correct.
- Notify us every time it completes a task or runs out of them.
- Add another agent to review the generated code.
- And many more things we can think of.
However, for this to work you need to have very solid foundations:
- A test base that quickly verifies that everything works.
- A good architecture so that adding new features doesn't worsen code quality.
- The linter/type checker/compiler must be fast.
This technique was published in July 2025, but it went viral just now because Anthropic launched a plugin to make it easy to do with Claude Code.
As of today, the plugin doesn't follow 100% the spirit of the technique, since it doesn't clean the context and works in a somewhat obscure way using hooks.
What the plugin does have are interesting things that we've applied: having the tasks json and a txt to write progress.
Our recommendation is to write the script by hand and iterate on it as needed.
If you want to learn more about these techniques and stay up to date, every Friday at Café con Codely at 9h CET we share them. Live on our YouTube and Twitch.