Skip to content

Instantly share code, notes, and snippets.

@rstacruz
Created March 3, 2025 06:00
Show Gist options
  • Save rstacruz/196620fdbfefa05fef62371fe275d889 to your computer and use it in GitHub Desktop.
Save rstacruz/196620fdbfefa05fef62371fe275d889 to your computer and use it in GitHub Desktop.
Use LLMs to generate a PR summary
#!/usr/bin/env bash
# Generates a prompt for a PR summary and copies it to clipboard.
#
# Usage: prompt-pr.sh 1234
#
# Paste into Claude and watch it generate a PR summary.
#
# Try following up with these questions:
#
# - given the PR description and this plan, is there anything in this PR that may need changing?
# - what are pros and cons of this change?
#
# More ideas: enhance this prompt with a repo map and a CONVENTIONS.md file
#
# <repo_map>
# $(aider --sonnet --no-show-model-warnings --show-repo-map)
# </repo_map>
#
# <conventions>
# $(cat CONVENTIONS.md)
# </conventions>
set -e
if [[ -z "$1" ]]; then
echo "Error: Please provide a PR number"
exit 1
fi
pr_number="$1"
copy_to_clipboard() {
if command -v pbcopy >/dev/null 2>&1; then
pbcopy # macOS
elif command -v wl-copy >/dev/null 2>&1; then
wl-copy # Wayland
else
echo "No clipboard command found"
exit 1
fi
}
cat <<EOF | copy_to_clipboard
Assist in tasks involving a Git repository.
Pull request details may be provided in <pr_diff>.
Pull request info may be provided in <pr_info>.
Context:
- I am reviewing a pull request.
- I need help summarising it. Reverse-engineer a possible plan that led to these changes.
Steps to do:
- Print out a draft of this reverse-engineered plan.
The plan should:
- Be a spec for an LLM assistant to carry out a task
- Have enough information for an LLM assistant to accomplish the task
- Have ambiguities answered
- Have a "Context" heading that describes info that relates to the task
- Have an "Objectives" heading with a list of high-level actions to do
- Have an "Actions" heading with a list of files and functions and the changes to be made to them
- Have an "Out of scope" heading for a list of things not to do (optional)
<pr_info>
$(gh pr view "$pr_number")
</pr_info>
<pr_diff>
$(gh pr diff "$pr_number")
</pr_diff>
EOF
echo "Prompt copied to clipboard ✓"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment