Skip to content

Instantly share code, notes, and snippets.

@arbel03
Created January 26, 2026 12:14
Show Gist options
  • Select an option

  • Save arbel03/42da301ca4dc682b770491abb3c00e71 to your computer and use it in GitHub Desktop.

Select an option

Save arbel03/42da301ca4dc682b770491abb3c00e71 to your computer and use it in GitHub Desktop.
install-ralph.sh
#!/bin/bash
# Ralph Installation Script
# Adds Ralph scripts and skills to an existing project
# Based on: https://github.com/snarktank/ralph
set -e
RALPH_BASE_URL="https://raw.githubusercontent.com/snarktank/ralph/refs/heads/main"
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
echo_info() {
echo -e "${GREEN}[INFO]${NC} $1"
}
echo_warn() {
echo -e "${YELLOW}[WARN]${NC} $1"
}
echo_error() {
echo -e "${RED}[ERROR]${NC} $1"
}
# Check if we're in a git repository
if ! git rev-parse --is-inside-work-tree > /dev/null 2>&1; then
echo_error "Not inside a git repository. Please run this script from within a git project."
exit 1
fi
# Get the git root directory
PROJECT_ROOT=$(git rev-parse --show-toplevel)
cd "$PROJECT_ROOT"
echo_info "Installing Ralph to: $PROJECT_ROOT"
# Create necessary directories
echo_info "Creating directories..."
mkdir -p scripts/ralph
mkdir -p tasks
mkdir -p .claude/skills/prd
mkdir -p .claude/skills/ralph
# Function to download a file
download_file() {
local remote_path=$1
local local_path=$2
echo_info "Downloading $remote_path..."
if curl -fsSL "${RALPH_BASE_URL}/${remote_path}" -o "$local_path"; then
echo_info " -> $local_path"
else
echo_error "Failed to download $remote_path"
return 1
fi
}
# Download Ralph scripts
download_file "ralph.sh" "scripts/ralph/ralph.sh"
download_file "prompt.md" "scripts/ralph/prompt.md"
download_file "CLAUDE.md" "scripts/ralph/CLAUDE.md"
download_file "prd.json.example" "scripts/ralph/prd.json.example"
# Download skills
download_file "skills/prd/SKILL.md" ".claude/skills/prd/SKILL.md"
download_file "skills/ralph/SKILL.md" ".claude/skills/ralph/SKILL.md"
# Make ralph.sh executable
echo_info "Setting execute permission on ralph.sh..."
chmod +x scripts/ralph/ralph.sh
# Update .gitignore
echo_info "Updating .gitignore..."
GITIGNORE_ENTRIES=(
"# Ralph - AI agent loop files"
"scripts/ralph/*"
"tasks/*"
".claude/skills/prd"
".claude/skills/ralph"
"prd.json"
"progress.txt"
"archive/"
)
# Create .gitignore if it doesn't exist
if [ ! -f .gitignore ]; then
touch .gitignore
echo_info "Created .gitignore file"
fi
# Check and add entries that don't exist
ADDED_HEADER=false
for entry in "${GITIGNORE_ENTRIES[@]}"; do
# Skip comment line check - always add header before first new entry
if [[ "$entry" == "# Ralph"* ]]; then
continue
fi
if ! grep -qxF "$entry" .gitignore 2>/dev/null; then
# Add header comment if this is the first entry we're adding
if [ "$ADDED_HEADER" = false ]; then
echo "" >> .gitignore
echo "# Ralph - AI agent loop files" >> .gitignore
ADDED_HEADER=true
fi
echo "$entry" >> .gitignore
echo_info " Added to .gitignore: $entry"
else
echo_warn " Already in .gitignore: $entry"
fi
done
echo ""
echo_info "Ralph installation complete!"
echo ""
echo "Next steps:"
echo " 1. Create a PRD: Load the prd skill and create a PRD for [your feature]"
echo " 2. Convert to JSON: Load the ralph skill and convert tasks/prd-[feature].md to prd.json"
echo " 3. Run Ralph: ./scripts/ralph/ralph.sh --tool claude [max_iterations]"
echo ""
echo "Files installed:"
echo " scripts/ralph/ralph.sh - Main Ralph loop script"
echo " scripts/ralph/prompt.md - Prompt template for Amp"
echo " scripts/ralph/CLAUDE.md - Prompt template for Claude Code"
echo " scripts/ralph/prd.json.example - Example PRD format"
echo " .claude/skills/prd/SKILL.md - PRD generation skill"
echo " .claude/skills/ralph/SKILL.md - PRD to JSON conversion skill"
echo ""
echo "For more info: https://github.com/snarktank/ralph"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment