Ralph Loop

Enter "Ralph Wiggum" mode for iterative, self-correcting development.

george11642 updated 6mo ago
Claude CodeGeneric
View source ↗
# /ralph-loop - Start Autonomous Development Loop

Enter "Ralph Wiggum" mode for iterative, self-correcting development.

## Instructions

When the user runs `/ralph-loop [task]`:

### 1. Initialize Loop

Set state:

  • iteration_count = 0
  • max_iterations = 50
  • last_checkpoint = null
  • task_description = [task]

### 2. Create Initial Checkpoint
```bash
git stash push -m "ralph-loop-start-$(date +%s)" 2>/dev/null || true
git add -A && git commit -m "CHECKPOINT: Ralph loop start" 2>/dev/null || true

3. Enter Loop

WHILE iteration_count < max_iterations:
    iteration_count++

    # 1. Analyze current state
    - Run tests
    - Check lint
    - Verify build

    # 2. Identify issues
    - Parse test failures
    - Parse lint errors
    - Parse build errors

    # 3. If no issues:
    IF all_checks_pass:
        - Update CLAUDE.md
        - Verify documentation current
        - Emit <promise>DOCS_OK</promise>
        - EXIT loop

    # 4. Fix highest priority issue
    - Prioritize: build > test > lint
    - Make minimal fix
    - Track what was changed

    # 5. Validate fix
    - Re-run failed check
    - IF still failing after 3 attempts on same issue:
        - Create checkpoint
        - Ask user for guidance
        - PAUSE loop

4. Exit Conditions

Success (emit DOCS_OK):

  • All tests pass
  • Lint clean
  • Build succeeds
  • CLAUDE.md updated
  • No debug code

Blocked:

  • Same error 3+ times
  • User interrupt
  • Max iterations reached

Paused:

  • Needs user decision
  • External dependency issue
  • Ambiguous requirement

5. Progress Reporting

Every 5 iterations, report:

╔═══════════════════════════════════════════════════════════════╗
║              RALPH WIGGUM LOOP - ITERATION #X                  ║
╠───────────────────────────────────────────────────────────────╣
║ Tests:  [X/Y passing]  Lint: [status]  Build: [status]        ║
║ Fixed this iteration: [description]                            ║
║ Remaining issues: [count]                                      ║
╚═══════════════════════════════════════════════════════════════╝

6. DOCS_OK Checklist

Before emitting <promise>DOCS_OK</promise>:

□ All tests pass           → npm test / pytest
□ Linting clean            → npm run lint / flake8
□ Build succeeds           → npm run build / python -m build
□ CLAUDE.md updated        → Module map accurate
□ No debug code            → No console.log/print/debugger
□ Paths verified           → All file paths in docs exist

Arguments

Argument Description Default
task Task description Required
--max-iter Maximum iterations 50
--no-checkpoint Skip checkpoints false
--verbose Show all output false

Example Usage

User: "/ralph-loop Fix all TypeScript errors" User: "/ralph-loop Implement user authentication --max-iter 100" User: "/ralph-loop Refactor database layer --verbose"

Safety Features

  1. Auto-checkpoint: Creates restore points every 10 iterations
  2. Bounded iterations: Default max 50, prevents infinite loops
  3. Error tracking: Stops if same error repeated 3 times
  4. User interrupt: Can pause at any time with Ctrl+C
  5. State preservation: Loop state saved for resume

Maintain Ralph Loop?

Let people know it's listed here — add the badge (live metrics, light/dark aware) or a plain link to your README or docs.

[Ralph Loop on getagentictools](https://getagentictools.com/loops/george11642-ralph-loop-start-autonomous-development-loop?ref=badge)
npx agentictools info loops/george11642-ralph-loop-start-autonomous-development-loop

The second line is the CLI lookup for this page — handy in READMEs and docs.