Sign in
Explore
Workflows · WorkflowEveryday codingReviewed

ralph.sh

The Ralph loop. Runs Amp or Claude Code once per iteration, up to a maximum count, and stops when the output reports COMPLETE.

Kind
Workflow
Works with
Claude Code
Languages
Shell
Source
Ralph @ 6c53cb0b831e
Path
ralph.sh
Jobs
Automation

Credit

Made by
snarktank
Original
github.com/snarktank/ralph/blob/6c53cb0b831ebe8739c6a003e22af…
License
MIT

Listed by Skill Manifest; not made by us.

InstallCopy it from the source repository, or sign in and let the assistant adapt it for your project.
Install factsScanned 3 Nov 2026
Adds
  • Steps in the source's README; what they create is not stated in the catalog
Runs scripts
Yes
  • command line in the text
Uses the network
None found
Needs secrets
None found
Reads environment variables
  • TOOL
  • BASH_SOURCE
  • SCRIPT_DIR
  • PRD_FILE
  • LAST_BRANCH_FILE
  • CURRENT_BRANCH
Calls other skills
  • /promise
Source revision
6c53cb0b831e
Licence
MIT
Last activity
2 Feb 2026
Review
Reviewed

Found by a static scan of the stored text; nothing is run. “None found” is not a guarantee, so read what you install before you run it.

  • What this adds depends on the source's own instructions
#!/bin/bash
# Ralph Wiggum - Long-running AI agent loop
# Usage: ./ralph.sh [--tool amp|claude] [max_iterations]

set -e

# Parse arguments
TOOL="amp"  # Default to amp for backwards compatibility
MAX_ITERATIONS=10

while [[ $# -gt 0 ]]; do
  case $1 in
    --tool)
      TOOL="$2"
      shift 2
      ;;
    --tool=*)
      TOOL="${1#*=}"
      shift
      ;;
    *)
      # Assume it's max_iterations if it's a number
      if [[ "$1" =~ ^[0-9]+$ ]]; then
        MAX_ITERATIONS="$1"
      fi
      shift
      ;;
  esac
done

# Validate tool choice
if [[ "$TOOL" != "amp" && "$TOOL" != "claude" ]]; then
  echo "Error: Invalid tool '$TOOL'. Must be 'amp' or 'claude'."
  exit 1
fi
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PRD_FILE="$SCRIPT_DIR/prd.json"
PROGRESS_FILE="$SCRIPT_DIR/progress.txt"
ARCHIVE_DIR="$SCRIPT_DIR/archive"
LAST_BRANCH_FILE="$SCRIPT_DIR/.last-branch"

# Archive previous run if branch changed
if [ -f "$PRD_FILE" ] && [ -f "$LAST_BRANCH_FILE" ]; then
  CURRENT_BRANCH=$(jq -r '.branchName // empty' "$PRD_FILE" 2>/dev/null || echo "")
  LAST_BRANCH=$(cat "$LAST_BRANCH_FILE" 2>/dev/null || echo "")
…