Free 40-page Claude guide — setup, 120 prompt codes, MCP servers, AI agents. Download free →
CLSkills
Git & Version Controlbeginner

PR Description

Share

Generate detailed PR descriptions from branch diff

Works with OpenClaude

You 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 main or develop) exists with git branch -a
  • Uncommitted changes with git status — stash if needed before diffing
  • Base branch is up to date: git fetch origin

Steps

  1. Fetch the latest remote branches with git fetch origin to ensure accurate diff
  2. Get the diff summary with git diff origin/main..HEAD --stat (replace main with your target branch)
  3. Extract changed files with git diff origin/main...HEAD --name-only to list what changed
  4. Get the commit messages between branches with git log origin/main..HEAD --oneline for context
  5. Run git diff origin/main...HEAD --unified=1 to see actual changes (reduced context for readability)
  6. Generate the PR description by combining commit messages, file changes, and a summary of modifications
  7. 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

Quick Info

Difficultybeginner
Version1.0.0
AuthorClaude Skills Hub
gitpull-requestautomation

Install command:

curl -o ~/.claude/skills/pr-description.md https://claude-skills-hub.vercel.app/skills/git/pr-description.md

Related Git & Version Control Skills

Other Claude Code skills in the same category — free to download.

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.