by PageAI-Pro
A long-running AI agent loop. Ralph automates software development tasks by iteratively working through a task list until completion.
# Add to your Claude Code skills
git clone https://github.com/PageAI-Pro/ralph-loopLast scanned: 5/30/2026
{
"issues": [],
"status": "PASSED",
"scannedAt": "2026-05-30T15:25:13.573Z",
"npmAuditRan": true,
"pipAuditRan": true
}No comments yet. Be the first to share your thoughts!
30 days in the Featured rail · terms & refunds
📚 Full docs: ralphloop.sh
Ralph is a long-running AI agent loop. Ralph automates software development tasks by iteratively working through a task list until completion. This allows for long running agent loops, effectively enabling AI to code for days at a time.
This is an implementation that actually works, containing a hackable script so you can configure it to your env and favorite agentic AI CLI. It's set up by default to use Claude Code in Docker Sandboxes, and supports multiple Docker Sandboxes agents.
I recommend using a CLI to bootstrap your project with the necessary tools and dependencies, e.g.:
npx @tanstack/cli create lib --add-ons eslint,form,tanstack-query,nitro --no-git
If you must start from a blank slate, which is not recommended, see Starting from scratch. You can also go for a more barebone start by running
npx create-vite@latest src --template react-ts
Run this in your project's directory to install Ralph.
npx @pageai/ralph-loop
Docs: ralphloop.sh
Use the prd-creator skill to generate a PRD from your requirements.
Open up Claude Code or Cursor etc., switch to plan mode, and prompt it with your requirements. Like so:
Use the prd-creator skill to help me create a PRD and task list for the below requirements.
An app is already set up with React, Tailwind CSS and TypeScript.
Requirements:
- A SaaS product that helps users manage their finances.
- Target audience: Small business owners and freelancers.
- Core features:
- Track income and expenses.
- Create and send invoices.
- Track payments and receipts.
- Generate reports and insights.
- Connect to bank accounts and credit cards.
- Connect to accounting software.
- Connect to payment processors.
- Use the shadcn/ui library for components.
- Integrate with Stripe for payments.
- Use Supabase for database.
- You can find env variables in the .env.example file: SUPABASE_URL, SUPABASE_PUBLISHABLE_KEY, STRIPE_SECRET_KEY, etc. are available in the runtime.
// etc.
Check out the video for a more realistic example on how to write requirements.
.env and add it to .gitignore/docs and mention them in the requirementsThen, follow the Skill's instructions and verify the PRD and then tasks. It is highly recommended that you review individual task requirements before starting the loop. Review EACH TASK INDIVIDUALLY.
Install and sign in to Docker Sandboxes first. See Docker's AI overview and Docker Sandboxes docs for the official setup flow.
Authenticate your chosen Docker Sandboxes agent before running Ralph. Claude is the default:
./ralph.sh --login
Ralph prints all supported login commands, then opens the selected agent inside the correctly named sandbox. To log in to a different supported agent, pass --agent:
./ralph.sh --login --agent codex
Follow the instructions to log in to that agent. Ralph names sandboxes as ralph-<agent>-<current-dir>-<hash8>, for example ralph-claude-my-app-a1b2c3d4. To print the exact sandbox name without starting the loop, run:
./ralph.sh --print-name
./ralph.sh --print-name --agent cursor
Once the sandbox exists (after the first --login or after Ralph runs at least once), publish your dev server port to the host with ./ralph.sh --ports. The port is captured from the dev-server URL you set during install and stored in RALPH_DEFAULT_PORTS in ralph.sh:
./ralph.sh --ports
./ralph.sh --ports --agent codex
👉 Answer "Yes" to Bypass Permissions mode, that's the exact reason why you are using the Docker sandbox.
Alternative: API keys — you can configure API keys for supported agents instead of interactive login, but this is usually more expensive and not recommended. See Docker's supported agents docs for per-agent setup details.
If you want to use a different agentic CLI, see Running with a different agentic CLI.
./ralph.sh -n 50 # Run Ralph Loop with 50 iterations
✍️ Note: the first iteration will be spent on ensuring the named sandbox environment is set up correctly. Expect 5 minutes to complete.
# Run the agent loop (default: 10 iterations)
./ralph.sh
# Run with custom iteration limit
./ralph.sh 5
./ralph.sh -n 5
./ralph.sh --max-iterations 5
# Run exactly one iteration
./ralph.sh --once
# Run with a different supported agent
./ralph.sh --agent codex
./ralph.sh -a cursor -n 5
# Log in to an agent inside Ralph's deterministic sandbox
./ralph.sh --login
./ralph.sh --login --agent cursor
# Publish the configured dev port to the selected agent sandbox
./ralph.sh --ports
./ralph.sh --ports --agent codex
# Print the deterministic sandbox name
./ralph.sh --print-name
./ralph.sh --print-name --agent codex
# Pass extra options to the selected agent
./ralph.sh --agent codex -- --model gpt-5.5
./ralph.sh -a gemini -- --model pro
# Show help
./ralph.sh --help
NB: you might need to run
chmod +x ralph.shto make the script executable.
The default "mode" is "implementation". Depending on your use case, you might want to change
.agent/PROMPT.mdto a different mode, e.g. "refactor", "review", "test" etc.
⚠️ If you want to use a different language or testing framework, see below.
This script assumes the following are installed:
If you'd like to use a different language, testing framework etc. please adjust .agent/PROMPT.md to reflect your setup, server ports and startup commands etc.
👉 The loop is controlled by this prompt, which will be sent to the agent each iteration.
Each iteration, Ralph will:
.agent/tasks.json.agent/tasks/TASK-{ID}.jsonThis was kept hackable so you can make it your own. The script follows the original concepts of the Ralph Wiggum Loop, working with fresh contexts and providing clear verifiable feedback.
It also works generically with any task set.