/git-plugin:git-upstream-pr-diverged <sha-to-send-upstream>from git-plugin
Submits a single commit from a heavily-diverged fork to upstream as a clean PR via cherry-pick with re-derive fallback, message scrubbing, and regression checks. Use when direct rebase fails.
Ships in git-plugin. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
Submit a single commit from a heavily-diverged fork back to upstream as a clean, regression-free PR. The simpler /git:upstream-pr covers aligned-fork cherry-picks; this skill handles the case where direct rebase fails.
| Use this skill when... | Use /git:upstream-pr instead when... |
|---|---|
| Fork has substantially diverged from upstream | Fork and upstream are roughly aligned |
| Cherry-pick may produce many conflicts on shared modules | Single commit applies cleanly |
| You need patch-id matching for already-applied content | You want a quick cherry-pick + cross-fork PR |
| The change touches files that may be fork-only | All touched files exist upstream |
| The PR needs commit-message scrubbing (fork issue refs, Claude trailers) | Commit messages are already upstream-clean |
| Pre-flight regression check against upstream baseline matters | The change is trivial enough to skip pre-flight |
Optional per-project settings live in .claude/upstream-pr.local.md (gitignored): upstream_remote (default upstream), upstream_repo, branch_prefix (default pr-upstream/), linter_cmd and test_cmd (empty skips the pre-flight), pr_body_template_path. Field table, defaults and an example file: REFERENCE.md § Configuration.
git branch --show-currentgit status --porcelain=v2 --branchgit remote -vfind . -path '*/.claude/*' -maxdepth 2 -name 'upstream-pr.local.md'Parse from $ARGUMENTS:
| Parameter | Required | Description |
|---|---|---|
<sha> | Yes | Commit SHA on the fork to send upstream |
--topic <slug> | No | Topic slug for branch name; auto-derived from commit subject if omitted |
Execute this upstream-PR workflow:
Run the eligibility check before touching any branch:
bash "${CLAUDE_SKILL_DIR}/scripts/check-eligibility.sh" <sha>
Exit codes drive next steps:
| Exit | Meaning | Action |
|---|---|---|
0 | Every touched file exists upstream and content is novel | Proceed to Step 2 |
1 | At least one fork-only file | Stop. Tell the user the change isn't standalone-PR-able; predecessor feature must land first |
3 | Content already applied upstream under a different SHA | Stop. Report the matching upstream commit; nothing to PR |
The patch-id check (git patch-id --stable) catches re-applied content from maintainer re-merges or squashes — even when the SHA differs.
Derive a topic slug from the commit subject if --topic was not provided. Then:
bash "${CLAUDE_SKILL_DIR}/scripts/prepare-branch.sh" <topic-slug> <sha>
The script:
<branch_prefix><topic-slug> from <upstream_remote>/main (or /master)<sha>When the cherry-pick produces conflicts, preserve upstream's surrounding shape, not the fork's. The goal is the smallest readable diff against upstream — a maintainer must see the change make sense in upstream's current code, not in the fork's.
If the cherry-pick produces dozens of conflict blocks across multiple files (typical when upstream and fork have drifted heavily on shared modules), abort and re-derive instead of fighting hunks:
git cherry-pick --abort
git checkout -b <branch> <upstream_remote>/main
# Re-apply the change against upstream's actual current files.
Re-derive is the right call when:
print() → logging, deprecation rename, lint-rule auto-fixes) — the rules transfer cleanly even if line numbers don't.Heuristic: extract the original commit's before → after map (e.g. git show <sha> | grep -E '^[-+].*pattern') and use it as the rulebook when re-applying against upstream. The PR body should disclose the re-derive (see REFERENCE.md § Built-in PR body template).
For refactor / cleanup PRs, verify lint and test parity against the pristine upstream baseline, not against the fork. This catches stray formatter touches, accidental import reordering, and indentation drift from Edit-tool replacements.
If linter_cmd and test_cmd are configured, run a stash roundtrip:
# Baseline (pristine upstream):
git stash push -- <changed-files>
<linter_cmd> <changed-files> 2>&1 | tail -1 # error count
<test_cmd> 2>&1 | tail -1 # pass count
git stash pop
# After (with your changes): run the same two commands and compare.
Both numbers must match (or improve). Quote both in the PR body's "Testing Performed" section.
For Python files, also run python3 -c "import ast; ast.parse(open(F).read())" on every edited file — catches indentation breaks that ruff might miss on already-warning-laden upstream code.
Run the scrub helper:
bash "${CLAUDE_SKILL_DIR}/scripts/scrub-commit.sh" --check
If violations are reported, run without --check to amend interactively:
bash "${CLAUDE_SKILL_DIR}/scripts/scrub-commit.sh"
The scrub rules:
Closes #74, Addresses #19, etc. point at the fork's tracker, not upstream's.Co-authored-by: Claude ..., Generated with [Claude Code]. Upstream doesn't follow that convention.bandit B607, ty, vulture), describe the underlying problem instead.fix(security):, feat(parser):, etc.The amend wraps git commit --amend with PRE_COMMIT_ALLOW_NO_CONFIG=1 because upstream may have no .pre-commit-config.yaml and a locally-installed pre-commit hook would otherwise refuse the commit.
Before pushing, verify with:
git diff <upstream_remote>/main..HEAD
Every hunk should be defensible to a maintainer who has never seen the fork.
git push origin <branch>
gh pr create --repo <upstream_repo> --base main \
--head <fork-owner>:<branch> \
--title "<conventional-commit subject>" \
--body "<body template: REFERENCE.md>"
If pr_body_template_path is configured, use that template; otherwise use the built-in one in REFERENCE.md § Built-in PR body template.
| Context | Command |
|---|---|
| Eligibility check | bash check-eligibility.sh <sha> (exit 0/1/3) |
| Prepare branch | bash prepare-branch.sh <topic> <sha> |
| Scrub check (CI mode) | bash scrub-commit.sh --check |
| Diff against upstream | git diff <upstream_remote>/main..HEAD --stat |
| Cross-fork PR | gh pr create --repo <upstream_repo> --head <fork-owner>:<branch> |
| Patch-id of HEAD | git show HEAD | git patch-id --stable |
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
git, cherry-pick, pull-request, fork-sync, upstream-contribution
52 skills in this plugin
/deadbranchdeadbranch CLI for stale-branch cleanup — dry-run preview, TUI or non-interactive delete, protects main/develop/WIP. Use when asked to clean up branches, prune branches, or remove stale branches./external-pr-trustAuthorship as a precondition of merging — bot vs stranger classification, what a merge executes, the merge-guard hook. Use when bulk-merging PRs, or when a merge is denied for a non-self author./gh-cli-agenticgh CLI commands with JSON output for agents. Use when querying PRs, issues, runs, or repo metadata; inspecting PR checks; fetching failed CI logs; or mapping a github.com URL to an API call./git-api-prGitHub API PR creation without local git. Use when submitting file changes as a PR without local commits — quick fixes, typos, config updates, or bypassing local git state./git-branch-namingBranch names: type prefix (feat/, fix/, chore/), issue number, kebab-case. Use when picking a name for a new branch or setting a repo's branch-naming convention./git-branch-pr-workflowBranch management and PR workflows — git switch/restore, GitHub MCP. Use when creating branches, opening PRs, or working with feature branches.npx claudepluginhub laurigates/claude-plugins --plugin git-pluginOther plugins' skills for the same job