Skip to content

Instantly share code, notes, and snippets.

@mcapodici
Last active February 13, 2026 10:22
Show Gist options
  • Select an option

  • Save mcapodici/46cf0ab24a6aef8209b5cf5b47b7f5f7 to your computer and use it in GitHub Desktop.

Select an option

Save mcapodici/46cf0ab24a6aef8209b5cf5b47b7f5f7 to your computer and use it in GitHub Desktop.

Ralph Instructions

  1. You will pick a next task, you decide either:
  • Pick a bug to fix from BUGS.md
  • Pick a undone task from PLAN.md
  • Do a bit of testing to find new bugs and add them to BUGS.md

Decide based on your best intition.

Then

  1. Complete the task
  2. Commit to Git with a good message plus ("not yet tested")
  3. Test the task as much as possible using the playwrite plugin
  4. Fix any bugs found
  5. Update Bugs.md and Plan.md accordindly
  6. Commit to Git with a good message plus ("now tested")

If there are no more tasks (look at all phases) and no bugs to fix, say exit word: "HOCUSPOCUS".

If there are more tasks you can still exit, but do not say the exit word, so RALPH knows to try antoher iteration.

Don't worry about looping too much, the ralph script detects and has a max loop count.

Notes:

  • Do not ask any questions. I am asleep!
  • If unsure, don't do that step and add it to QUESTIONS_FOR_HUMAN.md
#!/bin/bash
# Ralph Loop - Autonomous task processing via Claude Code
# Processes RALPH.MD instructions up to 20 iterations, stops on "HOCUSPOCUS"
set -euo pipefail
trap 'echo ""; echo "=== Interrupted by user (Ctrl+C) ==="; exit 130' INT TERM
PROJECT_DIR="/path/to/project"
MAX_ITERATIONS=20
EXIT_WORD="HOCUSPOCUS"
LOG_FILE="$PROJECT_DIR/ralph_log_$(date +%Y%m%d_%H%M%S).txt"
ITER_FILE="$PROJECT_DIR/ralph_iter_$(date +%Y%m%d_%H%M%S).txt"
cd "$PROJECT_DIR"
echo "=== Ralph Loop Started: $(date) ===" | tee "$LOG_FILE"
echo "Project: $PROJECT_DIR" | tee -a "$LOG_FILE"
echo "Max iterations: $MAX_ITERATIONS" | tee -a "$LOG_FILE"
echo "Exit word: $EXIT_WORD" | tee -a "$LOG_FILE"
echo "" | tee -a "$LOG_FILE"
for i in $(seq 1 $MAX_ITERATIONS); do
echo "========================================" | tee -a "$LOG_FILE"
echo "=== Iteration $i of $MAX_ITERATIONS ===" | tee -a "$LOG_FILE"
echo "=== $(date) ===" | tee -a "$LOG_FILE"
echo "========================================" | tee -a "$LOG_FILE"
PROMPT="Read RALPH.MD and follow the instructions. This is iteration $i of $MAX_ITERATIONS. Remember: do not ask questions, if unsure add to QUESTIONS_FOR_HUMAN.md. When there is nothing left to do, say HOCUSPOCUS."
claude --print --dangerously-skip-permissions "$PROMPT" | tee -a $LOG_FILE | tee $ITER_FILE 2>&1
if cat $ITER_FILE | grep -qi "$EXIT_WORD"; then
echo "=== Exit word '$EXIT_WORD' detected on iteration $i ===" | tee -a "$LOG_FILE"
echo "=== Ralph Loop Complete: $(date) ===" | tee -a "$LOG_FILE"
exit 0
fi
echo "--- No exit word found, continuing to next iteration ---" | tee -a "$LOG_FILE"
echo "" | tee -a "$LOG_FILE"
sleep 2
done
echo "=== Max iterations ($MAX_ITERATIONS) reached without exit word ===" | tee -a "$LOG_FILE"
echo "=== Ralph Loop Ended: $(date) ===" | tee -a "$LOG_FILE"
exit 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment