🎯

ralph-loop

🎯Skill

from benjaming/ai-skills

VibeIndex|
What it does

Generates autonomous iterative loops for multi-step tasks by creating a task management system with clear acceptance criteria and workflow tracking.

πŸ“¦

Part of

benjaming/ai-skills(12 items)

ralph-loop

Installation

Shell ScriptRun shell script
./ralph.sh [max-iterations]
πŸ“– Extracted from docs: benjaming/ai-skills
1Installs
-
AddedFeb 4, 2026

Skill Details

SKILL.md

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".

Overview

# Ralph Loop Creator

Create autonomous iterative loops that process a backlog of tasks with clear acceptance criteria. Named after the Ralph Wiggum pattern for spec-driven autonomous development.

Overview

A Ralph loop consists of:

  • Task System - Native Claude Code task management with dependency tracking
  • Prompt (prompt.md) - Instructions for each iteration
  • Runner (ralph.sh) - Bash script that loops until completion
  • Progress (progress.txt) - Execution log
  • Knowledge (knowledge.md) - Accumulated learnings

Quick Start

To create a new Ralph loop, gather requirements then run the init script:

```bash

python ~/.claude/skills/ralph-loop/scripts/init_ralph.py

```

Workflow

Step 1: Gather Requirements

Before creating a loop, clarify these parameters with the user using AskUserQuestion:

Loop Goal:

  • What is the global objective of this loop?
  • What domain/codebase does it operate on?

Task Structure:

  • What kind of tasks/items will be tracked?
  • What dependencies exist between tasks?
  • What metadata should each task have?

Iteration Process:

  • What steps should each iteration perform?
  • What tools/commands are needed?
  • What files should be read/written?

Acceptance Criteria:

  • How to validate a task is completed?
  • What checks should pass before marking done?
  • Should there be automated validation (tests, builds, typechecks)?

Exit Conditions:

  • When should the loop terminate? (all tasks done, specific marker, max iterations)
  • What completion marker to use? Default: COMPLETE

Step 2: Select or Create Template

Available templates in ~/.claude/skills/ralph-loop/templates/:

| Template | Use Case |

|----------|----------|

| migration.md | Migrating components, APIs, dependencies |

| exploration.md | Codebase analysis, documentation generation |

| testing.md | Test generation, coverage improvement |

| refactoring.md | Code cleanup, pattern enforcement |

| custom.md | Blank template for unique workflows |

Step 3: Generate Loop Files

After gathering requirements, generate the loop structure:

```bash

python ~/.claude/skills/ralph-loop/scripts/init_ralph.py \

--template migration \

--output ./my-loop \

--goal "Migrate React components from styled-components to Tailwind"

```

Or interactively:

```bash

python ~/.claude/skills/ralph-loop/scripts/init_ralph.py ./my-loop

```

Step 4: Create Tasks Using Task System

After generating the loop, create tasks using the native Task tools:

```

TaskCreate:

subject: "Migrate Button component"

description: "Convert Button from styled-components to Tailwind CSS classes"

activeForm: "Migrating Button component"

```

Set up dependencies between tasks:

```

TaskUpdate:

taskId: "2"

addBlockedBy: ["1"] # Task 2 waits for Task 1

```

Step 5: Run the Loop

```bash

cd

./ralph.sh [max-iterations]

```

Default max iterations: 50

File Structure

```

/

β”œβ”€β”€ ralph.sh # Executable bash loop

β”œβ”€β”€ prompt.md # Iteration instructions (uses Task tools)

β”œβ”€β”€ progress.txt # Execution log

β”œβ”€β”€ knowledge.md # Accumulated learnings

└── logs/ # Per-run log files

```

Task System Integration

The Ralph loop uses Claude Code's native Task management system:

Tools:

  • TaskCreate - Create new tasks with subject, description, activeForm
  • TaskList - View all tasks with status/owner/blockers
  • TaskGet - Fetch full task details by ID
  • TaskUpdate - Change status, set dependencies, mark complete

Status values: pending, in_progress, completed

Dependencies:

  • blocks - Tasks that cannot start until this one completes
  • blockedBy - Tasks that must complete before this one can start

Benefits over JSON backlog:

  • Native dependency tracking
  • Status validation (can't mark complete if tests fail)
  • Parallel agent coordination via owner field
  • Progress spinner shows activeForm text

Prompt Template Structure

```markdown

# 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 COMPLETE

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: COMPLETE

```

Creating Initial Tasks

After generating the loop, create tasks for the backlog. Example for a migration loop:

```

# 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"]

```

Tip: Use TaskUpdate with addBlockedBy to ensure tasks run in correct order.

Best Practices

  1. One task per iteration - Keep iterations focused
  2. Clear acceptance criteria - Define what "done" means
  3. Use dependencies - Set blockedBy for ordered tasks
  4. Incremental commits - Commit after each successful task
  5. Knowledge accumulation - Document learnings for future iterations
  6. Fail fast - Stop on errors, don't silently continue
  7. Idempotent operations - Safe to re-run if interrupted

Troubleshooting

| 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 |

References

  • [templates/](templates/) - Pre-built loop templates
  • [references/patterns.md](references/patterns.md) - Common iteration patterns

More from this repository10

🎯
confluence-cli🎯Skill

Manages Confluence content via command-line interface, enabling documentation workflows, page creation, and bulk content operations through scripting.

🎯
madai-investigator🎯Skill

I apologize, but I cannot generate a description because no context or details about the "madai-investigator" skill were provided in your request. Could you share more information about what this s...

🎯
applying-solid-principles🎯Skill

Guides developers in implementing clean, maintainable TypeScript code by applying and demonstrating SOLID design principles with practical examples.

🎯
vercel-react-best-practices🎯Skill

Implements best practices for React development on Vercel, optimizing performance, structure, and deployment workflows.

🎯
interview🎯Skill

Conducts an in-depth, iterative interview to clarify and explore implementation details, design choices, and potential challenges in a project plan.

🎯
skill-creator🎯Skill

Generates AI skills by automatically creating code templates, documentation, and project structures for rapid skill development.

🎯
frontend-design🎯Skill

Designs distinctive, production-grade frontend interfaces with exceptional aesthetic quality, avoiding generic AI design approaches.

🎯
ui-skills🎯Skill

Generates and manipulates UI components and interactions using AI-powered design and code generation techniques.

🎯
atlassian-cli-jira🎯Skill

Manages Jira work items, projects, and workflows via command-line interface, enabling bulk operations, automation, and scripting.

🎯
hooks🎯Skill

Automates and customizes Claude Code workflows by creating hooks for events like tool usage, prompt validation, session management, and permission handling.