Credit: This guide is inspired by JeredBlu's Ralph Wiggum Guide. I've adapted and extended it to fit my specific workflow using the
/create-prdcommand and Vercel's agent-browser CLI.
Ralph Wiggum is a method for running Claude Code in a continuous autonomous loop. Each iteration runs in a fresh context window, allowing the agent to work through a series of tasks until completion without context bloat.
Ideal for:
- Starting projects from scratch
- Building proof of concepts (POCs) with a clearly defined scope
- Greenfield development where requirements are well-understood
- Projects where you can define "done" precisely
Not ideal for:
- Complex existing codebases
- Vibe coding or exploratory work without clear goals
- Projects with ambiguous requirements
- Situations requiring frequent human judgment calls
The key insight: Ralph Wiggum works best when you have a clear plan. If you don't know exactly what you're building, stop and figure that out first. The /create-prd command helps you do exactly that.
The official Ralph Wiggum plugin for Claude Code has a fundamental flaw: it runs everything in a single context window. This means:
- Context gets bloated over time
- Increased hallucination risk as context fills up
- No true separation between iterations
- You may need to manually compact mid-run
The bash loop method (ralph.sh) starts a fresh context window for each iteration. This is the correct approach for long-running autonomous tasks.
You need Claude Code installed and configured. See the official documentation for setup.
Install the agent-browser CLI for headless browser automation:
npm install -g agent-browser
agent-browser install # Downloads ChromiumOn Linux, include system dependencies:
agent-browser install --with-depsThis tool allows Claude to verify its work visually by taking screenshots and interacting with your running application.
This repository includes everything you need:
.claude/settings.json- Sandbox and permissions configuration.claude/commands/create-prd.md- The/create-prdcommand.claude/skills/agent-browser-skill/SKILL.md- Agent browser instructionsPROMPT.md- Template for the Ralph loopralph.sh- The bash loop scriptactivity.md- Activity logging templatescreenshots/- Directory for visual verification
Run the /create-prd command in Claude Code:
/create-prd
This interactive command will:
-
Ask discovery questions one at a time:
- What problem are you solving?
- Who is your target audience?
- What are the 3-5 core features?
- What tech stack do you want?
- What architecture approach?
- UI/UX preferences?
- Authentication requirements?
- Third-party integrations?
- Success criteria?
-
Research options if you're unsure about tech stack or architecture
-
Generate
prd.mdwith:- Complete project requirements
- Tech stack decisions
- JSON task list with atomic, verifiable tasks
-
Update
PROMPT.mdwith your specific:- Start commands for your tech stack
- Build/lint commands
- Project-specific instructions
-
Update
.claude/settings.jsonwith permissions for:- CLI tools required by your tech stack
- Any third-party CLIs needed
- Commands specific to your project
-
Create/verify
activity.mdfor logging progress
After /create-prd completes, verify these files before running the loop:
Check prd.md:
- Are all features captured in the task list?
- Are tasks atomic (completable in one iteration)?
- Are tasks in the correct dependency order?
- Is the success criteria clear?
Check PROMPT.md:
- Is the start command correct for your tech stack?
- Are build/lint commands accurate?
Check .claude/settings.json:
- Are all necessary CLI tools permitted?
- Are sensitive files properly denied?
- Does the agent have what it needs to work autonomously?
This verification step is critical. The quality of your Ralph Wiggum run depends entirely on the quality of your PRD and configuration.
Once verified, start the autonomous loop:
./ralph.sh 20The number is your maximum iterations. Start with 10-20 for smaller projects.
The script will:
- Read
PROMPT.mdand feed it to Claude - Claude works on one task from
prd.md - Verifies with agent-browser
- Updates task status and logs to
activity.md - Commits the change
- Repeats with a fresh context window
The loop exits when:
- All tasks have
"passes": true(outputs<promise>COMPLETE</promise>) - Max iterations reached
While Ralph runs, you can monitor:
activity.md- Detailed log of what was accomplished each iterationscreenshots/- Visual verification of each completed task- Git commits - One commit per task with clear messages
- Terminal output - Real-time progress
Your Product Requirements Document with a JSON task list:
[
{
"category": "setup",
"description": "Initialize Next.js project with TypeScript",
"steps": [
"Run create-next-app with TypeScript template",
"Install additional dependencies",
"Verify dev server starts"
],
"passes": false
}
]Tasks should be:
- Atomic: One logical unit of work
- Verifiable: Clear success criteria
- Ordered: Respect dependencies
- Categorized: setup, feature, integration, styling, testing
Instructions for each iteration. References @prd.md and @activity.md. Updated by /create-prd with your specific start commands.
Permissions and sandbox configuration. Updated by /create-prd based on your tech stack to ensure the agent can run all necessary commands.
Example permissions that might be added based on your PRD:
Bash(prisma:*)for Prisma CLIBash(supabase:*)for Supabase CLIBash(firebase:*)for Firebase CLIBash(vercel:*)for Vercel CLIBash(docker compose:*)for Docker workflows
The bash loop script. Key features:
- Fresh context window per iteration
- Completion detection via
<promise>COMPLETE</promise> - File existence validation
- Color-coded output
- Graceful handling of max iterations
Activity log where the agent records:
- Date and time
- Task worked on
- Changes made
- Commands run
- Screenshot filename
- Issues and resolutions
The /create-prd command exists because planning is everything. Don't skip the discovery questions. Don't rush through them. A well-defined PRD is the difference between a successful Ralph run and wasted API credits.
Ralph Wiggum is for proof of concepts, not production applications. Define the minimum viable version of your idea. You can always iterate later.
Always review prd.md, PROMPT.md, and .claude/settings.json before starting the loop. Catching issues here saves iterations.
Use 10-20 iterations initially. You can always run more if needed. This prevents runaway costs if something goes wrong.
Watch the first 2-3 iterations to ensure things are working correctly. Check that:
- The dev server starts properly
- Agent-browser can access localhost
- Tasks are being marked as passing correctly
- Activity log is being updated
The default .claude/settings.json enables sandboxing. This provides isolation for long-running autonomous tasks. Don't disable it unless you have a specific reason.
- Check if the task is too ambiguous
- Review
activity.mdto see what it's attempting - Consider breaking the task into smaller steps
- Verify the dev server is running
- Check that the port in
PROMPT.mdmatches your actual port - Ensure agent-browser is installed correctly
- Review
.claude/settings.json - Add missing CLI tools to the allow list
- Check that the command pattern matches (e.g.,
Bash(npm run:*))
- This shouldn't happen with the bash loop (fresh context each iteration)
- If using the plugin (not recommended), switch to
ralph.sh
- Review remaining tasks in
prd.md - Check if tasks are too large or ambiguous
- Run again with
./ralph.sh 30or more iterations