Loading video player...
This is Ralph Wigum, arguably the
dumbest character in the Simpsons that
has become the inspiration for a clever
Claude's code plug-in designed to run
Claude through the same prompt over and
over again until it's actually done,
even if it keeps failing. Naive and
relentless persistence. Perfect for lazy
models that give up too early and don't
complete the task. But why did Anthropic
even create this? And won't this cost a
lot of money since it's running the same
prompt again and again? Let's find out.
And before we do, don't forget to hit
subscribe.
Now, before I get into using Ralph with
Claude code, you need to understand
where the idea came from because it's
pretty weird. Goat farmer Jeffrey
Huntley, who I don't think is an actual
goat farmer, but that's beside the
point, came up with a technique earlier
this year he called Ralph, which is
essentially an infinite bash while loop
that takes a prompt, gives it to an
agent, then waits for the response, and
gives the agent back the exact same
prompt again. So, this is what it looks
like to run a prompt with AMP, and this
is what it looks like to use with clawed
code. It's simple, but very powerful
because if you give the agent a clear
completion criteria and a completion
signal, you can essentially leave it
running overnight and wake up to a
completed task. Jeff spoke about this
technique at a talk and an engineer used
it with lots of agents to deliver,
review, and test an MVP for under $300,
whereas it would have cost him $50,000
to hire a contractor. And during a YC
hackathon, the repo mirror team used it
to ship six different repos overnight,
one of which was a complete rewrite of
browser use from Python to TypeScript,
which made the founder smile. It was
also used to create a brand new
programming language from scratch in
under 3 months, which let's just say is
not a language I plan to use anytime
soon. But if you think the Anthropic
team wrote a oneline bash script and
turned that into a plug-in, you'd be
very wrong because the team have done a
lot of work to properly integrate it
into claude code. The way it works is
you type the Ralph slash command, give
it your prompt at the completion
promise, which can be complete or done,
and you can also add a max iteration,
which we'll talk more about later, and
it uses this information to create a
state file when it starts running. But
instead of relying on a bash loop, it
uses the clawed stop hook, which you can
learn all about in this video. But
essentially, the stop hook usually runs
when clawed code has finished a task,
and in this case checks for any active
loops by passing the state file, reads
the latest output, and if it can't find
the completion promise, it triggers
Claude to run the same prompt again. So
Claude will go back, look at the code
it's produced, and improved it based on
the prompt if it's missed anything out.
Let's go through a quick demo. This is a
Python script I use to delay audio from
my mic when I'm recording. And if I
wanted to convert this Python script to
TypeScript, I can use Ralph with my
prompt and D file and give it a
completion promise of done. I'll hit
enter to let it go to work. And usually
if I run this in a coding agent without
Ralph, the agent will complete the task
and will generate some code for me, but
part of the code won't work. But
luckily, inside my prompt MD file, I've
told it to write passing tests. So
hopefully it will write tests and run
those tests on the script until they
pass. Let's fast forward this process.
And now if we run the script, we can see
it's running correctly detecting my
audio devices. And everything is written
in TypeScript just like I asked it. It's
even generated some tests using the bun
test module. Now this is all good if
you're on a super expensive clawed plan
or have deep pockets if you're using API
based pricing. But if you want to use an
expensive model like Opus and don't want
to wake up to a huge bill, then this is
where the max iterations flag comes in
useful. This prevents infinite loops by
stopping iterations at a number set by
you. So each time the stop hook triggers
Claude to rerun the prompt, it
increments the max iterations number and
will stop when it hits the number
specified. But this isn't the only thing
to consider when using the Ralph
plug-in. You also have to use it with
clear completion criteria. So don't say
make it good or make it pretty. If you
have a complex task, break things down
into incremental steps and also don't
use it for tasks that require human
judgment. Personally, I think it would
be great to pair Ralph with something
like beads, which will give it
incremental steps and will make sure it
stays on the right path. But you may
have also noticed we're less than 10K
away from hitting 100K subscribers,
which is absolutely amazing. So, if you
haven't done so already, go ahead and
hit that subscribe button.
The Ralph Wiggum technique (from Geoffrey Huntley) is essentially a continuous AI agent loop that repeatedly feeds Claude the same prompt, allowing it to iteratively improve its work until completion. Instead of manually running code, checking results, and making fixes, you simply run one command and let Claude autonomously cycle through development, testing, debugging, and refinement. In this video, we'll explore how this plugin benefits developers by automating repetitive iteration cycles, making it perfect for well-defined tasks like building APIs with TDD, getting tests to pass, or working through multi-phase projects. We'll also cover best practices for prompt writing, safety mechanisms, and when this approach shines versus when traditional debugging makes more sense. š Relevant Links Article on Ralph - https://ghuntley.com/ralph/ Repomirror 6 repos - https://github.com/repomirrorhq/repomirror/blob/main/repomirror.md Claude hooks - https://www.youtube.com/watch?v=Q4gsvJvRjCU ā¤ļø More about us Radically better observability stack: https://betterstack.com/ Written tutorials: https://betterstack.com/community/ Example projects: https://github.com/BetterStackHQ š± Socials Twitter: https://twitter.com/betterstackhq Instagram: https://www.instagram.com/betterstackhq/ TikTok: https://www.tiktok.com/@betterstack LinkedIn: https://www.linkedin.com/company/betterstack š Chapters: 0:00 Intro 0:33 Where the Idea for Ralph Wiggum Came From 1:15 What Ralph has been used to build 1:56 How Anthropic changed Ralph for Claude Code 2:41 Demo of the Ralph plugin in Claude Code 3:25 Things to consider when using Ralph