Get the FREE Ultimate OpenClaw Setup Guide →

ralph-wiggum-loop

Flagged

{"isSafe":false,"isSuspicious":true,"riskLevel":"high","findings":[{"category":"prompt_injection","severity":"high","description":"Usage of a dangerous permission-bypass flag when invoking external agents (claude, codex) via stdin in a loop. This effectively lowers safety constraints and could enable unintended actions by the agent.","evidence":"while [ ! -f PR_REVIEW_DONE ]; do\n cat CODE_REVIEW_PLAN.md | claude -p --dangerously-skip-permissions\ndone\n... and ...\nwhile [ ! -f PR_REVIEW_DONE ]; do\n cat CODE_REVIEW_PLAN.md | codex exec --yolo -\ndone"},{"category":"system_harm","severity":"medium","description":"Cleanup commands use rm -f and rm -rf, which can delete files or directories beyond intended scope if misused or run in an incorrect directory.","evidence":"rm -f CODE_REVIEW_PLAN.md PR_COMMENTS_PLAN.md PR_REVIEW_DONE\nrm -rf .pr-review/"},{"category":"data_exfiltration","severity":"medium","description":"Involves piping plan content to external agents (Claude/Codex) that operate externally; potential data leakage to external services depending on agent configuration and data handling.","evidence":"cat CODE_REVIEW_PLAN.md | claude -p --dangerously-skip-permissions\n... and ...\ncat CODE_REVIEW_PLAN.md | codex exec --yolo -"}],"summary":"The skill content enables an external-agent loop with a dangerous permission bypass and includes potentially destructive cleanup commands. It also relies on external agents that could process and transmit data externally. Use with strict access controls, remove dangerous permission bypass in production, and add safeguards (timeouts, auditing, explicit data handling rules) to mitigate risks."}

npx machina-cli add skill xpepper/pr-review-agent-skill/ralph-wiggum-loop --openclaw
Files (1)
SKILL.md
3.7 KB

Ralph Wiggum Loop

Overview

The Ralph Wiggum pattern: an external shell loop that spawns a fresh agent session per PR comment. Each invocation reads a plan file, does exactly one unit of work (triage or fix), then exits. The shell loop handles repetition.

This avoids context window exhaustion and works with any agent.

How to invoke

This skill is not invoked via chat. Instead, you run a shell loop in your terminal — the loop pipes CODE_REVIEW_PLAN.md to a fresh agent session for each iteration:

# Claude
while [ ! -f PR_REVIEW_DONE ]; do
  cat CODE_REVIEW_PLAN.md | claude -p --dangerously-skip-permissions
done

# Codex
while [ ! -f PR_REVIEW_DONE ]; do
  cat CODE_REVIEW_PLAN.md | codex exec --yolo -
done

See Setup below to get CODE_REVIEW_PLAN.md into your project.

Setup (once per PR)

  1. Copy CODE_REVIEW_PLAN.md from this skill to your project root:

    # Project-local install (default — installed without --global):
    cp .agents/skills/ralph-wiggum-loop/CODE_REVIEW_PLAN.md .
    
    # Global install (installed with --global):
    cp ~/.claude/skills/ralph-wiggum-loop/CODE_REVIEW_PLAN.md .
    

    The path depends on how the skill was installed. Check .agents/skills/ first (project-local); if not found, use your global skills directory.

  2. Optionally add both files to .gitignore:

    CODE_REVIEW_PLAN.md
    PR_COMMENTS_PLAN.md
    PR_REVIEW_DONE
    .pr-review/
    
  3. Start the loop:

    Claude:

    while [ ! -f PR_REVIEW_DONE ]; do
      cat CODE_REVIEW_PLAN.md | claude -p --dangerously-skip-permissions
    done
    

    Codex:

    while [ ! -f PR_REVIEW_DONE ]; do
      cat CODE_REVIEW_PLAN.md | codex exec --yolo -
    done
    

    Any agent that accepts stdin:

    while [ ! -f PR_REVIEW_DONE ]; do
      cat CODE_REVIEW_PLAN.md | <agent-command>
    done
    

How it works

IterationPR_COMMENTS_PLAN.md exists?What the agent does
1stNoFetches all PR comments, triages them, writes the file
2nd–NYesFixes the topmost unresolved comment, marks it done
FinalYes, all resolvedWrites PR_REVIEW_DONE, loop terminates

Each session is minimal: one triage pass or one comment fix.

State files (in project root)

  • CODE_REVIEW_PLAN.md — the instruction file (static, copied once)
  • PR_COMMENTS_PLAN.md — triage + progress state (generated, updated each run)
  • PR_REVIEW_DONE — written by the agent when all comments are addressed; stops the loop
  • .pr-review/plan-<id>.md — per-comment plan for non-trivial fixes (deleted after resolution)

Cleanup

rm -f CODE_REVIEW_PLAN.md PR_COMMENTS_PLAN.md PR_REVIEW_DONE
rm -rf .pr-review/

Do Not

  • Run the loop with --dangerously-skip-permissions on a repository you do not fully trust
  • Let the loop run unattended past the first few iterations without reviewing what the agent committed
  • Bundle all PR feedback into one large commit (each agent session commits at most one fix)
  • Delete PR_COMMENTS_PLAN.md while the loop is running — this is the shared state file

Source

git clone https://github.com/xpepper/pr-review-agent-skill/blob/main/ralph-wiggum-loop/SKILL.mdView on GitHub

Overview

Ralph Wiggum Loop uses an external shell loop to spawn a fresh agent session for each PR comment. This approach prevents context window exhaustion and works with any agent that accepts piped instructions. For in-session review, use pr-review-loop or copilot-review-loop instead.

How This Skill Works

You run a shell loop that feeds CODE_REVIEW_PLAN.md into a new agent session for every iteration. Each session handles exactly one unit of work (triage or fix) and then exits, with the loop continuing until PR_REVIEW_DONE is created.

When to Use It

  • You have a large volume of PR comments and want per-comment isolation to avoid context window limits.
  • You need to guarantee a fresh agent context for each comment instead of accumulating history.
  • Your environment supports gh CLI and stdin-piped agents (Claude, Codex, etc.).
  • You want a simple, repeatable shell-based workflow that scales with the number of comments.
  • You are OK with managing CODE_REVIEW_PLAN.md and PR_COMMENTS_PLAN.md as shared state across iterations.

Quick Start

  1. Step 1: Copy CODE_REVIEW_PLAN.md from the skill into your project root (project-local or global install).
  2. Step 2: Start the loop using your chosen agent (Claude or Codex) as shown in the SKILL; the loop reads CODE_REVIEW_PLAN.md and processes one comment per iteration.
  3. Step 3: When PR_REVIEW_DONE appears, the loop stops and you review the final changes.

Best Practices

  • Put CODE_REVIEW_PLAN.md in the project root from the skill’s location, so each PR has a stable plan.
  • Keep PR_REVIEW_DONE as the termination signal to avoid runaway loops.
  • Do not use --dangerously-skip-permissions in untrusted repos; audit agent actions.
  • Do not bundle all PR feedback into one commit; let each session fix address a single item.
  • Do not delete PR_COMMENTS_PLAN.md while the loop is running; it’s the loop’s shared state.

Example Use Cases

  • A large OSS PR with dozens of comments uses Claude in a per-comment loop to triage and fix items without overflowing the model’s context window.
  • Codex-based workflows process CODE_REVIEW_PLAN.md in a shell loop, handling one comment fix per iteration.
  • A project with gh CLI installed copies CODE_REVIEW_PLAN.md from the skill, then runs the while loop to address comments sequentially.
  • An automation script uses the generic <agent-command> to pipe CODE_REVIEW_PLAN.md, enabling any stdin-accepting agent.
  • The loop terminates cleanly when PR_REVIEW_DONE is written, signaling all comments have been addressed.

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers