Skip to content

Instantly share code, notes, and snippets.

@danii1
Last active June 5, 2025 07:20
Show Gist options
  • Save danii1/96fb96e408c12435e66bf4ed313d8933 to your computer and use it in GitHub Desktop.
Save danii1/96fb96e408c12435e66bf4ed313d8933 to your computer and use it in GitHub Desktop.
pr_review.sh
#!/bin/bash
# PR Review Script
# Usage: pr_review [source_branch] [target_branch]
# Pulls latest changes from both branches and performs AI review
source_branch=""
target_branch="master"
# Parse arguments
if [ -n "$1" ]; then
source_branch=$1
fi
if [ -n "$2" ]; then
target_branch=$2
fi
# If no source branch specified, use current branch
if [ -z "$source_branch" ]; then
source_branch=$(git branch --show-current)
if [ -z "$source_branch" ]; then
echo "Error: Could not determine current branch and no source branch specified"
echo "Usage: pr_review [source_branch] [target_branch]"
echo " source_branch: branch to review (defaults to current branch)"
echo " target_branch: branch to compare against (defaults to master)"
exit 1
fi
fi
echo "Reviewing branch '$source_branch' against '$target_branch'..."
# Store current branch to restore later if needed
current_branch=$(git branch --show-current)
# Pull latest changes for target branch
echo "Pulling latest changes for target branch '$target_branch'..."
git checkout "$target_branch" || {
echo "Error: Could not switch to target branch '$target_branch'"
exit 1
}
git pull origin "$target_branch" || {
echo "Warning: Could not pull latest changes for '$target_branch'"
}
# Switch to source branch and pull latest changes
echo "Pulling latest changes for source branch '$source_branch'..."
git checkout "$source_branch" || {
echo "Error: Could not switch to source branch '$source_branch'"
exit 1
}
git pull origin "$source_branch" || {
echo "Warning: Could not pull latest changes for '$source_branch'"
}
echo "Results of the automated PR review:" > /tmp/review.md
claude -p "Perform PR review on the diff between branch '$source_branch' and '$target_branch', find actual bugs, do not nitpick on things. Add disclaimer that it's an AI generated review and not a human one." >> /tmp/review.md
pbcopy < /tmp/review.md
echo "Review completed and copied to clipboard!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment