github-pr
Create GitHub pull requests using gh CLI with automatic stacked PR detection. Use when the user asks to create a PR, open a pull request, make a PR, or mentions creating/opening a pull request on GitHub.
When & Why to Use This Skill
This Claude skill automates the end-to-end process of creating GitHub pull requests using the GitHub CLI (gh). It features advanced logic for detecting 'stacked PRs,' ensuring that dependent branches are correctly mapped to their parent branches rather than defaulting to main. By automating context gathering, remote pushing, and standardized PR formatting, it significantly reduces manual overhead in the software development lifecycle.
Use Cases
- Streamlining the PR creation process by automatically extracting ticket numbers from branch names for standardized titles.
- Managing complex development workflows where multiple features are built sequentially (stacked branches), ensuring correct base branch targeting.
- Ensuring local changes are fully pushed to the remote repository before attempting to open a pull request.
- Quickly initializing draft pull requests to facilitate early-stage code reviews and collaborative feedback within a team.
| name | github-pr |
|---|---|
| description | Create GitHub pull requests using gh CLI with automatic stacked PR detection. Use when the user asks to create a PR, open a pull request, make a PR, or mentions creating/opening a pull request on GitHub. |
GitHub Pull Request
Create pull requests using GitHub CLI with stacked PR detection.
Instructions
Step 1: Gather Context
Run the skill's context-gathering script:
<skill-location-dir>/scripts/gather-pr-context.sh
The script outputs the current working directory first. Verify you are in the correct repository before proceeding.
Step 2: Analyze Context
From the script output, determine:
Stacked vs Normal PR:
- Parse
git log --oneline --decoratefor branch refs in parentheses - First branch NOT current and NOT
main/origin/main= parent branch - Parent is
main→ Normal PR - Parent is other branch → Stacked PR
Push status:
git log origin/<branch>..HEADempty → pushed ✓- Shows commits → need to push first
Existing PR:
gh pr listreturns data → PR exists, offer to update- Empty → create new PR
Step 3: Push if Needed
git push -u origin HEAD
Step 4: Create PR
Normal PR:
gh pr create --draft --base main --title "title" --body "body"
Stacked PR:
gh pr create --draft --base <parent-branch> --title "title" --body "body"
Guidelines:
- Use ticket number from branch name as title prefix (e.g., PAT-123)
- Keep description short and proportional to changes
- For stacked PRs, describe only THIS branch's changes
- Create in draft mode unless explicitly requested otherwise
Step 5: Output
Normal PR:
Created PR
* Merge : `<branch>` into `main`
* PR URL: <url>
Stacked PR:
📚 Stacked PR 📚
* Merge : `<branch>` into `<parent>`
* New PR : <url>
* Parent PR: <parent-url or "⚠️ No Parent PR">
Rules
- NEVER include attribution markers in PR titles or descriptions. This includes but is not limited to:
- "Co-Authored-By" or "Co-authored-by" headers
- "Generated by", "Created by", "Written by" followed by any AI/LLM name
- Footers like "🤖 Generated with Claude Code" or similar
- Any mention of AI tools: Claude, GPT, Copilot, Codex, Gemini, Cursor, or other LLMs/assistants
- Any text or links indicating AI involvement in creating the PR
Requirements
- GitHub CLI (
gh) installed and authenticated - Git remote configured
- Push access to repository