Loading...
Loading...
Create autonomous iterative loops (Ralph Wiggum pattern) for multi-step tasks. Use when setting up automated workflows that iterate over a backlog of tasks with clear acceptance criteria. Triggers on requests like "create a ralph loop", "set up an iterative agent", "automate this migration", or "create an autonomous loop".
npx skill4agent add benjaming/ai-skills ralph-loopprompt.mdralph.shprogress.txtknowledge.mdpython ~/.claude/skills/ralph-loop/scripts/init_ralph.py <output-dir><promise>COMPLETE</promise>~/.claude/skills/ralph-loop/templates/| Template | Use Case |
|---|---|
| Migrating components, APIs, dependencies |
| Codebase analysis, documentation generation |
| Test generation, coverage improvement |
| Code cleanup, pattern enforcement |
| Blank template for unique workflows |
python ~/.claude/skills/ralph-loop/scripts/init_ralph.py \
--template migration \
--output ./my-loop \
--goal "Migrate React components from styled-components to Tailwind"python ~/.claude/skills/ralph-loop/scripts/init_ralph.py ./my-loopTaskCreate:
subject: "Migrate Button component"
description: "Convert Button from styled-components to Tailwind CSS classes"
activeForm: "Migrating Button component"TaskUpdate:
taskId: "2"
addBlockedBy: ["1"] # Task 2 waits for Task 1cd <output-dir>
./ralph.sh [max-iterations]<output-dir>/
├── ralph.sh # Executable bash loop
├── prompt.md # Iteration instructions (uses Task tools)
├── progress.txt # Execution log
├── knowledge.md # Accumulated learnings
└── logs/ # Per-run log filesTaskCreateTaskListTaskGetTaskUpdatependingin_progresscompletedblocksblockedBy# Ralph Agent: {Goal}
## Configuration
- List paths, files, tools
## Your Task (One Iteration)
### Step 1: Load Context
Use TaskList to get all tasks, read knowledge.md
### Step 2: Determine State
Check if all tasks are completed → output <promise>COMPLETE</promise>
### Step 3: Select Target
Use TaskList to find first task with:
- status: "pending"
- blockedBy: empty (no unresolved dependencies)
Use TaskUpdate to set status: "in_progress"
### Step 4-N: Execute
Task-specific steps using TaskGet for full details
### Final Step: Update
Use TaskUpdate to set status: "completed"
Update progress.txt and knowledge.md
## Completion
When all tasks completed: <promise>COMPLETE</promise># Create first task
TaskCreate:
subject: "Migrate Button component"
description: "Convert Button.tsx from styled-components to Tailwind. Update imports, replace styled() calls with className props using Tailwind utilities."
activeForm: "Migrating Button component"
# Create dependent task
TaskCreate:
subject: "Migrate Modal component"
description: "Convert Modal.tsx. Depends on Button migration since Modal uses Button internally."
activeForm: "Migrating Modal component"
# Set dependency
TaskUpdate:
taskId: "2"
addBlockedBy: ["1"]addBlockedBy| Issue | Solution |
|---|---|
| Loop never completes | Check completion marker in prompt.md matches ralph.sh |
| Tasks skipped | Verify status field updates in prompt.md |
| Context overflow | Reduce prompt.md size, move details to knowledge.md |
| Permission errors | Ensure ralph.sh has execute permissions |