GitHub PR Manager
Instructions
When to Invoke This Skill
- Creating a pull request after implementing changes
- Checking status of an existing PR (mergeable, checks, reviews)
- Merging an approved PR
- Validating PR state before operations
Capabilities
Create Pull Request
- Generate PR from current branch
- Create descriptive title and body
- Link to related issues
- Add appropriate labels
View PR Status
- Check if PR is open/closed/merged
- Verify mergeable state
- Review CI check status
- Check review approvals
Merge Pull Request
- Squash merge with single commit
- Auto-delete remote branch
- Validate before merging
Standard Workflows
Creating a PR
Verify Current Branch
git branch --show-current
Ensure you're on a feature branch, not main/master
Push Branch (if not already pushed)
git push -u origin HEAD
Create PR
gh pr create --title "<type>: <description>" --body "$(cat <<'EOF'
## Summary
Resolves #<issue_number>
<Brief description of changes>
## Changes Made
- <List key changes>
## Testing
- <How to test these changes>
🤖 Generated with [Claude Code](https://claude.com/claude-code)
EOF
)"
Checking PR Status
Fetch PR Information
gh pr view <pr_number> --json state,mergeable,statusCheckRollup,reviewDecision
Interpret Results
state: "OPEN", "CLOSED", "MERGED"
mergeable: "MERGEABLE", "CONFLICTING", "UNKNOWN"
reviewDecision: "APPROVED", "CHANGES_REQUESTED", "REVIEW_REQUIRED"
Merging a PR
Validate PR State
gh pr view <pr_number> --json headRefName,state,mergeable
- Verify state is "OPEN"
- Verify mergeable is "MERGEABLE"
- Extract branch name for cleanup
Perform Squash Merge
gh pr merge <pr_number> --squash --delete-branch
This will:
- Squash all commits into one
- Merge to main/master
- Delete remote branch
- Delete local tracking branch (if it exists)
Update Local Repository
git checkout main
git pull origin main
Clean Up Local Branch (if still exists)
# Check if branch still exists
git branch --list <branch-name>
# Delete only if exists
if git branch --list <branch-name> | grep -q <branch-name>; then
git branch -d <branch-name>
fi
Note: The --delete-branch flag usually handles this, but verify to ensure cleanup
Error Handling
Authentication Issues:
- Run:
gh auth status
- If not authenticated:
gh auth login
PR Not Mergeable:
- Check for conflicts: Inform user to resolve merge conflicts
- Check for failing CI: Wait for checks to pass
- Check for required reviews: Request reviews from team
Branch Deletion Fails:
- Branch may be protected
- User may have the branch checked out
- Branch may not exist locally (already deleted or never checked out)
- Always check branch existence before deletion
- Ignore "branch not found" errors - treat as already cleaned up
PR Title and Body Standards
Title Format:
<type>: <brief description>
Types: feat, fix, chore, docs, refactor, test, perf
Body Format:
## Summary
Resolves #<issue>
<1-2 sentence description>
## Changes Made
- <Bullet list of key changes>
## Testing
- <How changes were tested>
- <Manual test steps if needed>
## Screenshots (if UI changes)
<Optional screenshots>
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Examples
Example 1: Create PR from feature branch
User: "Create a PR for this feature"
Action:
1. Verify on feature branch
2. Push if needed
3. Create PR with structured body linking to issue
Output: PR URL and number
Example 2: Check PR status before merging
User: "Is PR #123 ready to merge?"
Action:
1. Fetch PR status
2. Check mergeable state, CI status, reviews
Output: "PR #123 is ready to merge" or list blockers
Example 3: Merge approved PR
User: "Merge PR #123"
Action:
1. Validate PR state and extract branch name
2. Squash merge with branch deletion
3. Switch to main and pull
4. Verify local branch cleanup (check existence first)
Output: "PR #123 merged successfully, branch cleaned up"
1---2name: github-pr-manager-33description: Create, view, and merge GitHub pull requests with validation. Use when creating PRs from branches, checking PR status, or merging approved PRs with cleanup.4---56# GitHub PR Manager78## Instructions910### When to Invoke This Skill11- Creating a pull request after implementing changes12- Checking status of an existing PR (mergeable, checks, reviews)13- Merging an approved PR14- Validating PR state before operations1516### Capabilities17181. **Create Pull Request**19 - Generate PR from current branch20 - Create descriptive title and body21 - Link to related issues22 - Add appropriate labels23242. **View PR Status**25 - Check if PR is open/closed/merged26 - Verify mergeable state27 - Review CI check status28 - Check review approvals29303. **Merge Pull Request**31 - Squash merge with single commit32 - Auto-delete remote branch33 - Validate before merging3435### Standard Workflows3637#### Creating a PR38391. **Verify Current Branch**40 ```bash41 git branch --show-current42 ```43 Ensure you're on a feature branch, not main/master44452. **Push Branch** (if not already pushed)46 ```bash47 git push -u origin HEAD48 ```49503. **Create PR**51 ```bash52 gh pr create --title "<type>: <description>" --body "$(cat <<'EOF'53 ## Summary54 Resolves #<issue_number>5556 <Brief description of changes>5758 ## Changes Made59 - <List key changes>6061 ## Testing62 - <How to test these changes>6364 🤖 Generated with [Claude Code](https://claude.com/claude-code)65 EOF66 )"67 ```6869#### Checking PR Status70711. **Fetch PR Information**72 ```bash73 gh pr view <pr_number> --json state,mergeable,statusCheckRollup,reviewDecision74 ```75762. **Interpret Results**77 - `state`: "OPEN", "CLOSED", "MERGED"78 - `mergeable`: "MERGEABLE", "CONFLICTING", "UNKNOWN"79 - `reviewDecision`: "APPROVED", "CHANGES_REQUESTED", "REVIEW_REQUIRED"8081#### Merging a PR82831. **Validate PR State**84 ```bash85 gh pr view <pr_number> --json headRefName,state,mergeable86 ```87 - Verify state is "OPEN"88 - Verify mergeable is "MERGEABLE"89 - Extract branch name for cleanup90912. **Perform Squash Merge**92 ```bash93 gh pr merge <pr_number> --squash --delete-branch94 ```95 This will:96 - Squash all commits into one97 - Merge to main/master98 - Delete remote branch99 - Delete local tracking branch (if it exists)1001013. **Update Local Repository**102 ```bash103 git checkout main104 git pull origin main105 ```1061074. **Clean Up Local Branch** (if still exists)108 ```bash109 # Check if branch still exists110 git branch --list <branch-name>111112 # Delete only if exists113 if git branch --list <branch-name> | grep -q <branch-name>; then114 git branch -d <branch-name>115 fi116 ```117 **Note**: The `--delete-branch` flag usually handles this, but verify to ensure cleanup118119### Error Handling120121**Authentication Issues:**122- Run: `gh auth status`123- If not authenticated: `gh auth login`124125**PR Not Mergeable:**126- Check for conflicts: Inform user to resolve merge conflicts127- Check for failing CI: Wait for checks to pass128- Check for required reviews: Request reviews from team129130**Branch Deletion Fails:**131- Branch may be protected132- User may have the branch checked out133- Branch may not exist locally (already deleted or never checked out)134- Always check branch existence before deletion135- Ignore "branch not found" errors - treat as already cleaned up136137### PR Title and Body Standards138139**Title Format:**140```141<type>: <brief description>142```143144Types: `feat`, `fix`, `chore`, `docs`, `refactor`, `test`, `perf`145146**Body Format:**147```markdown148## Summary149Resolves #<issue>150151<1-2 sentence description>152153## Changes Made154- <Bullet list of key changes>155156## Testing157- <How changes were tested>158- <Manual test steps if needed>159160## Screenshots (if UI changes)161<Optional screenshots>162163🤖 Generated with [Claude Code](https://claude.com/claude-code)164```165166## Examples167168### Example 1: Create PR from feature branch169```170User: "Create a PR for this feature"171Action:1721. Verify on feature branch1732. Push if needed1743. Create PR with structured body linking to issue175Output: PR URL and number176```177178### Example 2: Check PR status before merging179```180User: "Is PR #123 ready to merge?"181Action:1821. Fetch PR status1832. Check mergeable state, CI status, reviews184Output: "PR #123 is ready to merge" or list blockers185```186187### Example 3: Merge approved PR188```189User: "Merge PR #123"190Action:1911. Validate PR state and extract branch name1922. Squash merge with branch deletion1933. Switch to main and pull1944. Verify local branch cleanup (check existence first)195Output: "PR #123 merged successfully, branch cleaned up"196```