Ralph Loop is the orchestration framework that enables reliable autonomous code production. Four skills, retry-with-context, AFK mode, and GitHub issues as the task queue. Works with Claude Code, Codex, Hermes, or OpenClaw. Built a functioning app overnight for $3.
Why Big Prompts Fail
Most agents used as chatbots: big prompt, hope for a miracle. Even with plan mode, this produces inconsistent output. The agent drifts, hallucinates, loses context on long tasks.
The insight: reliable work does not come from a bigger prompt. It comes from smaller loops that can also use lower-intelligence models for micro-tasks.
The Ralph Loop Architecture
Start
-> Agent reads prompt + repo state
-> Does work / writes code
-> Orchestrator checks: is this done?
YES: exit, create PR, report results
NO: pick up previous context + error state -> new runThe key mechanism: each new run carries the previous run's context. The agent cannot make the same mistake twice because it knows what it tried and why it failed.
The GitHub repo becomes the brain of the operation. Issues become the task queue.
The Four Skills
grill-me: Asks clarifying questions iteratively. Forces specificity before any code is written. "Which framework? Which database? Which auth approach?" Some people go through 220 questions. You decide the depth.
to-PRD: Takes grill-me output, produces a detailed Product Requirements Document (can be 500-1000 lines). The agent's complete, reviewable understanding of what to build.
to-issues: Pushes the PRD to GitHub as issues with dependency graphs. Prerequisites are enforced. Parallelizable tasks are flagged.
ralph (executor): Reads issues, executes them, checks in between, creates PRs when done.
shape = grill-me + to-PRD combined. Use when you already know what you want and want to skip the slow Q&A iteration.
AFK Mode
Supervised: Execute one issue, ask you to check, proceed on confirmation. Good for initial runs.
AFK: "Go AFK, do everything." Ralph processes all issues, creates commits, returns final report: "Done. Here are the commits. Test these 4-5 things." You step away for hours.
Scheduling tasks: you can schedule a build to run overnight and have results in the morning.
Model Strategy
- Brainstorming/PRD phase: GPT-5.5 high or extra high (strong reasoning needed)
- Execution slices: GPT-5.5 low (individual tasks need less intelligence, saves cost)
- Or: Claude as brain, Codex as execution workers
- Or: Codex 5.5 high for PRD, Sonnet for execution
Live Results Demonstrated
App built overnight: PressWiz link gap analyzer. Checks competitor backlinks, identifies gap, builds 6-month link building plan with sourcing suggestions. Cost: $3. Time: while Nemanja slept.
Second result: Hermes dashboard redesign. Submitted before sleep; woke to a materially better UI.
When to Use Ralph vs /goal vs Kanban
| Method | Use When |
|---|---|
| Ralph | Production code, architecture-first, need reviewable PRD, want to control issue decomposition |
| /goal | Clear single-goal migrations, quick prototypes, when PRD review is not needed |
| Kanban | Non-code tasks (content, research, design), multi-agent pipelines without GitHub |
Ralph produces better output than /goal for production code. /goal is faster to start. (See the /goal comparison video for side-by-side results.)
GitHub Issue Dependency Format
Parent issue: the main feature with full description. Sub-issues: each specifies which other issues must complete first.
Issue 5.1 depends on: 1.1, 2.3
Issue 5.2 depends on: 5.1
Issues 3.1 and 3.2: can run in parallelThis structure is what agents need: unambiguous sequencing, clear parallelism opportunities.