ClawKit Logo
ClawKitReliability Toolkit
Back to Registry
Official Verified

ralph-loop

Generate copy-paste bash scripts for Ralph Wiggum/AI agent loops (Codex, Claude Code, OpenCode, Goose). Use when asked for a "Ralph loop", "Ralph Wiggum loop", or an AI loop to plan/build code via PROMPT.md + AGENTS.md, SPECS, and IMPLEMENTATION_PLAN.md, including PLANNING vs BUILDING modes, backpressure, sandboxing, and completion conditions.

skill-install — Terminal

Install via CLI (Recommended)

clawhub install openclaw/skills/skills/endogen/monitored-ralph-loop
Or

Ralph Loop (Event-Driven)

Enhanced Ralph pattern with event-driven notifications — Codex/Claude calls OpenClaw when it needs attention instead of polling.

Key Concepts

Clean Sessions

Each iteration spawns a fresh agent session with clean context. This is intentional:

  • Avoids context window limits
  • Each codex exec is a new process with no memory of previous runs
  • Memory persists via files: IMPLEMENTATION_PLAN.md, AGENTS.md, git history

File-Based Notification Fallback

If OpenClaw is rate-limited when Codex sends a wake notification:

  1. The notification is written to .ralph/pending-notification.txt
  2. Wake is attempted (may fail)
  3. When OpenClaw recovers, it checks for pending notifications
  4. Work is never lost — it's all in git/files

File Structure

project/
├── PROMPT.md                      # Loaded each iteration (mode-specific)
├── AGENTS.md                      # Project context, test commands, learnings
├── IMPLEMENTATION_PLAN.md         # Task list with status
├── specs/                         # Requirements specs
│   ├── overview.md
│   └── <feature>.md
└── .ralph/
    ├── ralph.log                  # Execution log
    ├── pending-notification.txt   # Current pending notification (if any)
    └── last-notification.txt      # Previous notification (for reference)

Notification Format

.ralph/pending-notification.txt:

{
  "timestamp": "2026-02-07T02:30:00+01:00",
  "project": "/home/user/my-project",
  "message": "DONE: All tasks complete.",
  "iteration": 15,
  "max_iterations": 20,
  "cli": "codex",
  "status": "pending"
}

Status values:

  • pending — Wake failed or not attempted
  • delivered — Wake succeeded

OpenClaw Recovery Procedure

When coming back online after rate limit or downtime, check for pending notifications:

# Find all pending notifications across projects
find ~/projects -name "pending-notification.txt" -path "*/.ralph/*" 2>/dev/null

# Or check a specific project
cat /path/to/project/.ralph/pending-notification.txt

Recovery Actions by Message Prefix

PrefixAction
DONE:Report completion to user, summarize what was built
PLANNING_COMPLETE:Inform user, ask if ready for BUILDING mode
PROGRESS:Log it, update user if significant
DECISION:Present options to user, wait for answer, inject into AGENTS.md
ERROR:Check logs (.ralph/ralph.log), analyze, help or escalate
BLOCKED:Escalate to user immediately with full context
QUESTION:Present to user, get clarification, inject into AGENTS.md

Injecting Responses

To answer a decision/question for the next iteration:

echo "## Human Decisions
- [$(date '+%Y-%m-%d %H:%M')] Q: <question>? A: <answer>" >> AGENTS.md

The next Codex session will read AGENTS.md and see the answer.

Clearing Notifications

Metadata

Author@endogen
Stars2387
Views1
Updated2026-03-09
View Author Profile
AI Skill Finder

Not sure this is the right skill?

Describe what you want to build — we'll match you to the best skill from 16,000+ options.

Find the right skill
Add to Configuration

Paste this into your clawhub.json to enable this plugin.

{
  "plugins": {
    "official-endogen-monitored-ralph-loop": {
      "enabled": true,
      "auto_update": true
    }
  }
}
Safety NoteClawKit audits metadata but not runtime behavior. Use with caution.