git-upstream-pr
FreeNo executable scriptsNot checkedSubmit PRs to upstream repos from a fork — commit selection, squashing, cross-fork creation. Use when contributing changes upstream or cherry-picking fork…
by laurigates★ 61 GitHub starsAbout this skill
/git:upstream-pr
Submit clean, atomic PRs to upstream repositories from fork work.
When to Use This Skill
| Use this skill when... | Use something else instead when... |
|---|---|
| Contributing changes back to the upstream repo | Committing to your own fork/repo → /git:commit |
| Cherry-picking fork commits for upstream PR (single or multi-commit, squashing) | Creating a PR within the same repo → /git:pr |
| Fork and upstream are roughly aligned | Fork has substantially diverged from upstream → /git:upstream-pr-diverged (patch-id eligibility, re-derive fallback, scrubbing) |
| Need a clean branch based on upstream/main | Working on a branch already tracking upstream |
Context
- Current branch: !
git branch --show-current - Git status: !
git status --porcelain=v2 --branch - Remotes: !
git remote -v - Has upstream: !
git remote -v - Origin URL: !
git remote -v - Upstream URL: !
git remote -v - Recent commits: !
git log --oneline --max-count=20 - Stash list: !
git stash list
Parameters
Parse these from $ARGUMENTS:
| Parameter | Required | Description |
|---|---|---|
--commits sha1,sha2,... |
No | Comma-separated commit SHAs to cherry-pick (interactive selection if omitted) |
--branch name |
No | Name for the upstream PR branch (auto-generated if omitted) |
--upstream owner/repo |
No | Override upstream repo (detected from remote if omitted) |
--draft |
No | Create PR as draft |
--dry-run |
No | Show what would happen without making changes |
Execution
Execute this fork-to-upstream PR workflow:
Step 1: Validate fork environment
- Verify this is a git repository:
git rev-parse --git-dir - Check if
upstreamremote exists (from context) - If no
upstreamremote:- Try to detect via
gh repo view --json parent -q '.parent.nameWithOwner' - If found, add it:
git remote add upstream https://github.com/<owner/repo>.git - If not found, ask user with AskUserQuestion for the upstream repo URL
- Try to detect via
- Fetch upstream:
git fetch upstream - Record the current branch name and check for uncommitted changes
- If uncommitted changes exist, stash them:
git stash push -m "upstream-pr: WIP before upstream PR"
Step 2: Assess fork state
Report the fork's divergence from upstream:
Fork status:
Upstream: <upstream-repo>
Behind upstream/main: N commits
Ahead of upstream/main: M commits
If --dry-run is set, also show which commits would be selected and stop here.
Step 3: Select commits
If --commits provided:
- Parse the comma-separated SHA list
- Validate each SHA exists:
git rev-parse --verify <sha> - Show summary of selected commits
If --commits not provided:
- Show recent commits that are ahead of upstream/main:
git log --oneline --format='%h %s (%cr)' upstream/main..HEAD - Use AskUserQuestion to let the user select which commits to include
- Present commits as options with their subject lines
Step 4: Create clean branch from upstream/main
- Generate branch name if
--branchnot provided:- Extract scope from first commit message (e.g.,
feat(auth): add OAuth->feat/auth-add-oauth) - Fallback:
upstream-pr/<date>
- Extract scope from first commit message (e.g.,
- Create branch from upstream/main:
git switch -c <branch-name> upstream/main
Step 5: Cherry-pick and squash
- Cherry-pick each selected commit in order:
git cherry-pick <sha1> <sha2> ... - If cherry-pick conflicts occur:
- Report the conflict to the user
- Reference git-conflicts for resolution
- After resolution:
git cherry-pick --continue
- Squash all cherry-picked commits into one atomic commit:
git reset --soft upstream/main git commit -m "<conventional commit message>" - Use AskUserQuestion to confirm or edit the commit message
- Default message: derived from the cherry-picked commits
- Format: conventional commit with scope
Step 6: Push to fork
git push -u origin <branch-name>
If --dry-run, show the command without executing.
Step 7: Create cross-fork PR
- Determine the upstream repo (from
--upstreamor detected remote) - Determine the fork owner (from
originremote URL) - Create the PR:
Addgh pr create \ --repo <upstream-owner/upstream-repo> \ --base main \ --head <fork-owner>:<branch-name> \ --title "<conventional commit title>" \ --body "<PR description>"--draftif the flag was provided. - Report the PR URL to the user
Step 8: Restore working state
- Switch back to the original branch:
git switch <original-branch> - If changes were stashed in Step 1, pop them:
git stash pop - Report completion summary:
Upstream PR created: PR: <url> Branch: <branch-name> Commits: N cherry-picked, squashed in
Install git-upstream-pr in Claude Code & Claude Desktop
Sign up to install this skill
Create a free account to reveal the install command and save the skill to your library.
- Reveal the one-line install command
- Save skills to your synced library
- Get notified when skills update
Allowed tools
Tools this skill is permitted to call.
Bash(git status *)Bash(git diff *)Bash(git log *)Bash(git remote *)Bash(git fetch *)Bash(git switch *)Bash(git cherry-pick *)Bash(git reset *)Bash(git commit *)Bash(git push *)Bash(git stash *)Bash(git rev-list *)Bash(git rev-parse *)Bash(git branch *)Bash(gh pr *)Bash(gh repo *)Bash(gh auth *)AskUserQuestionReadGrepGlobTodoWriteFAQ
What does the git-upstream-pr skill do?
Submit PRs to upstream repos from a fork — commit selection, squashing, cross-fork creation. Use when contributing changes upstream or cherry-picking fork commits.
How do I install the git-upstream-pr skill?
Copy the skill folder into ~/.claude/skills (the Claude Code tab above does this in one command), or install it as a plugin.
Does the git-upstream-pr skill run scripts?
No, this skill is instructions only (SKILL.md) with no executable scripts.
Related skills
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
by Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
by Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
by Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
by Anthropic