Skip to content

Instantly share code, notes, and snippets.

@luizbafilho
Created January 19, 2026 17:18
Show Gist options
  • Select an option

  • Save luizbafilho/31beec80d19642cc17c86e433f54f324 to your computer and use it in GitHub Desktop.

Select an option

Save luizbafilho/31beec80d19642cc17c86e433f54f324 to your computer and use it in GitHub Desktop.
pr-description
---
name: pr-description
description: Generate a PR description based on the work done in the current branch. Analyzes commits, diffs, and follows repo PR templates if available. Use when the user wants to create a PR description, write a pull request summary, or prepare a PR.
allowed-tools: Read, Bash, Glob, Grep
---
# PR Description Generator
## Instructions
When the user asks you to generate a PR description, follow these steps:
### Step 1: Identify the Base Branch
Determine the base branch to compare against:
```bash
# Try to find the default branch (main or master)
git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's@^refs/remotes/origin/@@' || echo "main"
```
If the user specifies a different base branch, use that instead.
### Step 2: Check for PR Template
Look for PR description templates in the repository in this order:
1. `.github/PULL_REQUEST_TEMPLATE.md`
2. `.github/pull_request_template.md`
3. `.github/PULL_REQUEST_TEMPLATE/default.md`
4. `docs/PULL_REQUEST_TEMPLATE.md`
5. `PULL_REQUEST_TEMPLATE.md`
```bash
# Search for PR templates
find . -maxdepth 3 -type f \( -iname "pull_request_template.md" -o -iname "PULL_REQUEST_TEMPLATE.md" \) 2>/dev/null | head -5
```
If a template is found, read it and use its structure for the PR description.
### Step 3: Gather Branch Information
Collect information about the work done in the branch:
```bash
# Get current branch name
git branch --show-current
# Get commit history compared to base branch
git log origin/main..HEAD --oneline
# Get detailed commit messages
git log origin/main..HEAD --pretty=format:"%h - %s%n%b"
# Get the diff summary (files changed)
git diff origin/main..HEAD --stat
# Get the actual diff for understanding changes
git diff origin/main..HEAD
```
### Step 4: Generate the PR Description
Based on the gathered information, create a comprehensive PR description:
**If a template exists:** Fill in the template sections with relevant information from the commits and diff.
**If no template exists:** Use this structure:
```markdown
## Summary
[Brief 1-2 sentence description of what this PR does]
## Changes
- [List of key changes made]
- [Each bullet should describe a logical change]
## Type of Change
- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] Documentation update
- [ ] Refactoring (no functional changes)
## Testing
[Describe how the changes were tested or how they can be tested]
## Related Issues
[Reference any related issues, e.g., "Closes #123" or "Related to #456"]
```
### Step 5: Copy to Clipboard
After generating the description, copy it to the clipboard:
```bash
echo "PR_DESCRIPTION_HERE" | pbcopy
```
Use a heredoc for multi-line content:
```bash
pbcopy << 'EOF'
## Summary
...rest of PR description...
EOF
```
### Step 6: Confirm to User
Let the user know:
1. The PR description has been generated
2. It has been copied to their clipboard
3. Display the full description so they can review it
## Important Notes
- Focus on the "why" not just the "what" - explain the purpose and context
- Keep the summary concise but informative
- Group related changes together logically
- If there are breaking changes, highlight them prominently
- Check all appropriate checkboxes in the "Type of Change" section
- Reference any related issues or tickets mentioned in commit messages
## Example Output
```markdown
## Summary
Add user authentication with JWT tokens to secure API endpoints.
## Changes
- Implement JWT token generation and validation
- Add login and logout endpoints
- Create authentication middleware
- Update protected routes to require authentication
- Add user session management
## Type of Change
- [ ] Bug fix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] Documentation update
- [ ] Refactoring (no functional changes)
## Testing
- Tested login/logout flow manually
- Added unit tests for JWT validation
- Verified protected routes return 401 without valid token
## Related Issues
Closes #42
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment