The Ralph Wiggum Loop from First Principles
Software development now costs $10.42/hour when running Ralph loops—the key is deterministically malicking the array, starting with a screwdriver before grabbing the jackhammer.
Geoffrey Huntley, the creator of Ralph, walks through the technique from absolute first principles. The goal: help developers understand the fundamentals before jumping to power tools.
The Economics Shift
Running Ralph in a 24-hour loop costs roughly $10.42/hour in API fees. In that time, you output multiple days or weeks of traditional software development work. The economics of software development have fundamentally changed.
But to get these results, you need to understand the fundamentals first. Don't start with a jackhammer—learn to use a screwdriver.
Core Insight: Context Windows Are Arrays
The fundamental mental model: context windows are arrays.
- When you chat with the LLM, you allocate to the array
- When it executes tools, it auto-allocates to the array
- The LLM is a sliding window over this array
- The less that window needs to slide, the better
There's no server-side memory. The array is the memory. So allocate less, and be deliberate about what goes in.
Deterministically Malicking the Array
Ralph avoids context rot by deterministically controlling what enters the context window. Each loop iteration:
- Starts with a fresh context
- Injects the "pin" (specs, objectives, frame of reference)
- Works on exactly one task
- Commits and resets
The "pin" is a lookup table that links to specifications. It includes generative words that improve search tool hit rates—the more descriptors, the better the LLM finds relevant context instead of inventing.
Building Specs Through Conversation
"Would you believe I don't create my specs. I generate them. Then I review them and edit them by hand."
The workflow is like shaping clay on a pottery wheel:
- Start a conversation with the LLM
- Give it high-level direction ("I want analytics like PostHog")
- Let it interview you, asking questions
- Shape the specification through back-and-forth
- Export to a spec file
- Let Ralph rip on that spec
This preserves the conversation as the source of truth—you can resume planning later.
The Ralph Loop
The core implementation is simple:
while true; do
cat prompt.md | claude --dangerously-skip-permissions
done
The prompt tells Claude to:
- Study the specs lookup table
- Find the implementation plan
- Pick the most important task
- Complete it
- Update the plan
- Commit and push
Software Development vs. Software Engineering
Huntley draws a distinction:
- Software development: Now fundamentally automated with bash loops
- Software engineering: Keeping the locomotive on the rails
The new job is engineering back pressure to keep the generative function on track. You're a locomotive engineer now—not carrying cargo by hand onto the ship.
Diagram
flowchart LR
subgraph Loop[Ralph Loop]
Pin[Inject Pin/Specs] --> Pick[Pick Highest Priority Task]
Pick --> Work[Complete One Task]
Work --> Test[Run Tests]
Test --> Commit[Commit & Push]
Commit --> Reset[Reset Context]
Reset --> Pin
end
Human((Human))
Human -.->|Watch & Tune| Loop
Key Quotes
"If the idea of running Ralph makes you want to ralph, listen to it. Then engineer away those concerns. That is now the job."
"We're no longer carrying cargo by hand onto the ship. The shipping containers are here."
Loom: The Bigger Picture
Huntley's project "Loom" embodies these principles:
- Self-evolutionary software
- Humans on the loop, not in the loop
- Autonomous "weavers" that deploy without code review
- Feature experiments and analytics built-in
- Optimizing for machine-to-machine communication (why use JSON when you control the stack?)
Connections
- ralph-wiggum-technique-guide - Comprehensive guide building on these first principles
- ralph-wiggum-and-why-claude-codes-implementation-isnt-it - Huntley and Horthy explain why Anthropic's plugin differs from pure Ralph
- ralph-wiggum-as-a-software-engineer - Original article introducing the technique
- context-engineering-guide - The array-allocation mental model in broader context