agentleFS
shyamsridhar123shyamsridhar123/kevin-copilot/.github/skills/ralph-loop/SKILL.md

ralph-loop

Skill7 starsChanged 3 months agoMITView on GitHub

Autonomous Ralph Wiggum Loop — iterative task execution with fresh context, filesystem memory, and git versioning

26 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use to-issues and review.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • GoogleSkill

    to-issues

    Break a plan, spec, or PRD into independently-grabbable issues on the project issue tracker using tracer-bullet vertical slices.

    Also in 3 projects that use this

  • SentrySkill

    review

    Fixture review skill.

    Also in 3 projects that use this

The file

We split this skill into the rules it gives an agent

8 rules. 0 are common, 2 are distinctive, and 6 are very specific to this project.

  • 0

    Common

    Most of the 22 edited versions we read keep these.

  • 2

    Distinctive

    This author's own choices. Worth a look.

  • 6

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    If the argument is a task description (not a path to an existing PRD or plan file):

    line 33
  2. Very specific:

    If the argument is a path to a plan file (e.g., docs/plans/feature.md), use that as the PRD and generate only PROGRESS.md from its tasks.

    line 60
  3. Very specific:

    Read PRD.md and PROGRESS.md to determine the next PENDING task, then execute iterations until all tasks are complete.

    line 64
  4. Very specific:

    Read PROGRESS.md and select the first task with status PENDING.

    line 70
  5. Distinctive:

    After the executor sub-agent completes:

    line 100
  6. Very specific:

    When all tasks in PROGRESS.md are DONE (or BLOCKED):

    line 112
  7. Very specific:

    Default keyword is DONE.

    line 128
  8. Very specific:

    With /ce-compound: After loop completion, run /ce-compound to document learnings

    line 151

“Common” is measured: kept by at least 6 in 10 of the 22 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Arguments

[task description or PRD path] [--completion-promise KEYWORD]

Ralph Wiggum Loop

An autonomous coding loop that executes tasks iteratively with fresh context per iteration, using the filesystem as memory and git for version control. Inspired by the Ralph Wiggum pattern — persistent trial-and-error with external state tracking.

Core Principle

Ralph loop = Fresh context + Filesystem memory + Git versioning

Each iteration starts with a clean context window. Progress is tracked in PROGRESS.md, requirements live in PRD.md, and every completed task is committed to git. This avoids context pollution and produces reliable results for multi-step work.

Usage

/ralph-loop "Build the authentication module"
/ralph-loop docs/plans/my-plan.md
/ralph-loop "finish all slash commands" --completion-promise "DONE"

Execution Flow

Phase 0: Planning (if no PRD exists)

If the argument is a task description (not a path to an existing PRD or plan file):

  1. Read existing plan files — Check docs/plans/ for a relevant plan. If one exists and matches the task, use it as the PRD.
  2. Generate PRD — If no plan exists, create PRD.md in the project root with:
    • Goal: One-sentence summary of what success looks like
    • Tasks: Numbered list of atomic, independently-executable tasks
    • Acceptance Criteria: Testable criteria for each task
    • Completion Promise: The keyword to output when all tasks are done (default: DONE)
  3. Generate PROGRESS.md — Create PROGRESS.md in the project root with:
    # Progress
    
    ## Status: IN_PROGRESS
    
    | # | Task | Status | Notes |
    |---|------|--------|-------|
    | 1 | [task name] | PENDING | |
    | 2 | [task name] | PENDING | |
  4. Commit initial state:
    git add PRD.md PROGRESS.md
    git commit -m "ralph-loop: initialize PRD and progress tracking"

If the argument is a path to a plan file (e.g., docs/plans/feature.md), use that as the PRD and generate only PROGRESS.md from its tasks.

Phase 1: Coordination Loop

Read PRD.md and PROGRESS.md to determine the next PENDING task, then execute iterations until all tasks are complete.

For each iteration:

Step 1 — Pick Next Task

Read PROGRESS.md and select the first task with status PENDING. If no PENDING tasks remain, go to Phase 2 (Completion).

Step 2 — Execute Task

Spawn a fresh sub-agent (via the Task tool) for the selected task. The sub-agent prompt MUST include:

You are a Ralph Executor. Complete this single task with fresh context.

**Task:** [task description from PRD]
**Acceptance Criteria:** [criteria from PRD]

Instructions:
1. Read PRD.md and PROGRESS.md for full context
2. Implement the task — write code, create files, run tests
3. Verify your work meets the acceptance criteria
4. Update PROGRESS.md: set this task's status to DONE with brief notes
5. Stage and commit your changes:
   git add -A
   git commit -m "ralph-loop: complete task [N] — [brief description]"

Do NOT modify other tasks. Do NOT skip testing. One task only.

<critical_requirement> Each executor sub-agent runs with fresh context — it has no memory of previous iterations. All state comes from the filesystem (PRD.md, PROGRESS.md, existing code, git history). </critical_requirement>

Step 3 — Verify Completion

After the executor sub-agent completes:

  1. Read PROGRESS.md — Confirm the task status was updated to DONE
  2. Quick review — Spawn a brief reviewer sub-agent to check:
    • Does the code compile/pass linting?
    • Were tests added or do existing tests still pass?
    • Does the change match the acceptance criteria?
  3. If review fails — Update task status to FAILED with notes, then re-attempt. Each task gets up to 3 total attempts (1 initial + 2 retries). After the third failed attempt, mark the task as BLOCKED and continue to the next task.
  4. If review passes — Continue to next iteration (back to Step 1)

Phase 2: Completion

When all tasks in PROGRESS.md are DONE (or BLOCKED):

  1. Update PROGRESS.md — Set top-level status:
    • COMPLETE if all tasks are DONE
    • PARTIAL if any tasks are BLOCKED
  2. Final commit:
    git add PROGRESS.md
    git commit -m "ralph-loop: all tasks complete"
  3. Output completion promise — If --completion-promise was provided:
    <promise>[KEYWORD]</promise>
    Default keyword is DONE.
  4. Summary:
    ✓ Ralph Loop Complete
    
    Tasks: [N] total, [X] done, [Y] blocked
    Commits: [Z] commits made
    PRD: PRD.md
    Progress: PROGRESS.md
    
    Blocked tasks (if any):
    - Task [N]: [reason]

Integration with Compound Engineering

The ralph-loop skill works with existing CE skills:

  • As orchestrator: Called by /lfg and /slfg as an optional first step to autonomously execute all workflow commands
  • With /ce-plan: Can use plan files from docs/plans/ as the PRD input
  • With /ce-work: Each executor iteration is similar to a focused /ce-work session
  • With /ce-review: The verification step performs lightweight review; for thorough review use /ce-review after the loop completes
  • With /ce-compound: After loop completion, run /ce-compound to document learnings

State Files

FilePurposeCreated By
PRD.mdRequirements and task listPhase 0 (Planning)
PROGRESS.mdTask status trackingPhase 0, updated each iteration

These files are committed to git and serve as the filesystem memory that enables fresh-context execution.

Design Decisions

  • One task per iteration: Keeps each sub-agent focused and prevents context pollution
  • Git commits per task: Enables rollback of individual tasks and provides audit trail
  • 3 total attempts per task: 1 initial attempt + up to 2 retries prevents infinite loops on genuinely broken tasks
  • Reviewer sub-agent: Catches issues before they compound across iterations
  • BLOCKED status: Allows the loop to continue past stuck tasks rather than halting entirely

Common Mistakes to Avoid

❌ Wrong✅ Correct
Execute multiple tasks in one sub-agentOne task per sub-agent with fresh context
Skip git commits between tasksCommit after every completed task
Carry conversation context across iterationsEach iteration reads state from filesystem
Retry failed tasks indefinitely3 total attempts (1 initial + 2 retries), then mark BLOCKED and continue
Modify PRD.md during executionPRD.md is read-only after planning phase

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.