Skip to content

Instantly share code, notes, and snippets.

@portfola
Last active July 14, 2026 22:16
Show Gist options
  • Select an option

  • Save portfola/0426a2ad41e48d4b0eb1acd282f04f60 to your computer and use it in GitHub Desktop.

Select an option

Save portfola/0426a2ad41e48d4b0eb1acd282f04f60 to your computer and use it in GitHub Desktop.
ralph loop
#!/bin/bash
n=1; while :; do
echo "=== Task loop #$n starting at $(date) ==="
output=$(claude --dangerously-skip-permissions --print --verbose < PROMPT.md 2>&1 | tee /dev/tty)
if echo "$output" | grep -qE "You.ve hit your ([[:alnum:]-]+ )?limit"; then
echo "=== Rate limited. Stopping loop #$n at $(date) ==="
break
fi
if echo "$output" | grep -q "ALL TASKS COMPLETE"; then
echo "=== All tasks complete. Stopping loop #$n at $(date) ==="
break
fi
echo "=== Run #$n complete at $(date). Restarting in 10s... ==="
((n++))
sleep 10
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment