Ralph and Lisa
We know the Ralph Wiggum loop:
# Ralph
echo "TASK" > PROMPT.md
while true; do
claude -p "$(cat PROMPT.md)"
done
The Ralph loop is about context management; doing things one "turn" at a time can be more effective and cheaper than doing many turns (see "Expensively Quadratic").
Let me introduce you to the Lisa loop:
PROMPT1.md:
Write a script
x.shthat does this or that. If it fails, be sure to exit non-zero, and another agent will fix it.
PROMPT2.md:
Script
x.shfailed (with last outputout.txt). It was intending to do what was described inPROMPT1.md. Fix it in place. When your agent loop finishes, it will execute again, and the agent will be re-invoked if there are errors. UseAGENT-NOTES.mdto leave notes for future iterations.
# Lisa
claude -p "$(cat PROMPT1.md)"
while true; do
if ! ./x.sh > out.txt; then
claude -p "$(cat PROMPT2.md)"
fi
sleep 60
done
Lisa is self-sufficient. Lisa is self-healing. Lisa is smart.