Generate detailed PR descriptions from branch diff
✓Works with OpenClaudeYou are a Git automation expert. The user wants to generate detailed PR descriptions automatically from branch diffs.
What to check first
- Current branch name with
git branch --show-current - Target branch (usually
mainordevelop) exists withgit branch -a - Uncommitted changes with
git status— stash if needed before diffing - Base branch is up to date:
git fetch origin
Steps
- Fetch the latest remote branches with
git fetch originto ensure accurate diff - Get the diff summary with
git diff origin/main..HEAD --stat(replacemainwith your target branch) - Extract changed files with
git diff origin/main...HEAD --name-onlyto list what changed - Get the commit messages between branches with
git log origin/main..HEAD --onelinefor context - Run
git diff origin/main...HEAD --unified=1to see actual changes (reduced context for readability) - Generate the PR description by combining commit messages, file changes, and a summary of modifications
- Copy the generated description to your clipboard or save to a file for pasting into GitHub/GitLab
Code
#!/bin/bash
# PR Description Generator
# Usage: ./generate-pr-desc.sh [base-branch] [head-branch]
BASE_BRANCH="${1:-origin/main}"
HEAD_BRANCH="${2:-HEAD}"
echo "=== PR DESCRIPTION GENERATOR ==="
echo ""
# Get branch names for context
CURRENT_BRANCH=$(git branch --show-current)
echo "## Branch Info"
echo "Current: $CURRENT_BRANCH"
echo "Comparing to: $BASE_BRANCH"
echo ""
# Get commit messages
echo "## Commits"
git log "$BASE_BRANCH..$HEAD_BRANCH" --pretty=format:"- %h: %s" --reverse
echo ""
echo ""
# Get list of changed files
echo "## Files Changed"
CHANGED_FILES=$(git diff "$BASE_BRANCH...$HEAD_BRANCH" --name-only)
FILE_COUNT=$(echo "$CHANGED_FILES" | wc -l)
echo "Total: $FILE_COUNT files"
echo ""
echo "$CHANGED_FILES" | sed 's/^/ - /'
echo ""
# Get statistics
echo "## Statistics"
git diff "$BASE_BRANCH...$HEAD_BRANCH" --stat
echo ""
# Get additions and deletions summary
CHANGES=$(git diff "$BASE_BRANCH...$HEAD_BRANCH" --numstat | awk '{added+=$1; removed+=$2} END {print "+" added " -" removed}')
echo "Summary: $CHANGES"
echo ""
# Generate a basic summary (can be enhanced with AI)
echo "## Summary"
echo "This PR includes the following changes:"
echo "- Updated $FILE_COUNT files"
echo "- Contains $(git log "$BASE_BRANCH..$HEAD_BRANCH" --oneline |
Note: this example was truncated in the source. See the GitHub repo for the latest full version.
Common Pitfalls
- Treating this skill as a one-shot solution — most workflows need iteration and verification
- Skipping the verification steps — you don't know it worked until you measure
- Applying this skill without understanding the underlying problem — read the related docs first
When NOT to Use This Skill
- When a simpler manual approach would take less than 10 minutes
- On critical production systems without testing in staging first
- When you don't have permission or authorization to make these changes
How to Verify It Worked
- Run the verification steps documented above
- Compare the output against your expected baseline
- Check logs for any warnings or errors — silent failures are the worst kind
Production Considerations
- Test in staging before deploying to production
- Have a rollback plan — every change should be reversible
- Monitor the affected systems for at least 24 hours after the change
Related Git & Version Control Skills
Other Claude Code skills in the same category — free to download.
Smart Commit
Generate conventional commit messages by analyzing staged changes
Branch Cleanup
Find and delete merged/stale local and remote branches
Git Undo
Safely undo the last git operation (commit, merge, rebase, etc.)
Changelog Generator
Generate CHANGELOG.md from git history using conventional commits
Conflict Resolver
Analyze and suggest resolutions for merge conflicts
Git Bisect Helper
Automate git bisect to find the commit that introduced a bug
Commit Splitter
Split a large commit into smaller, logical commits
Git Hooks Setup
Set up pre-commit, pre-push, and commit-msg hooks
Want a Git & Version Control skill personalized to YOUR project?
This is a generic skill that works for everyone. Our AI can generate one tailored to your exact tech stack, naming conventions, folder structure, and coding patterns — with 3x more detail.