Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

git-upstream-pr-diverged

БесплатноЗапускает вложенные скриптыНе проверен

Submit a diverged-fork commit to upstream as a clean PR via cherry-pick with re-derive fallback, message scrubbing, and regression checks. Use when direct…

laurigatesот laurigates★ 61 звезда на GitHub

Об этом скилле

/git:upstream-pr-diverged

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.

When to Use This Skill

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

Configuration

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.

Context

  • Current branch: !git branch --show-current
  • Working tree: !git status --porcelain=v2 --branch
  • Remotes: !git remote -v
  • Config file: !find . -path '*/.claude/*' -maxdepth 2 -name 'upstream-pr.local.md'

Parameters

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

Execution

Execute this upstream-PR workflow:

Step 1: Check eligibility

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.

Step 2: Prepare the branch

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:

  1. Verifies a clean working tree
  2. Re-runs the eligibility check
  3. Fetches the upstream remote
  4. Creates <branch_prefix><topic-slug> from <upstream_remote>/main (or /master)
  5. Cherry-picks <sha>
  6. Reports any conflict files

Step 3: Resolve conflicts (if any)

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.

When to abort and re-derive

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:

  • The original commit is a mechanical, re-applicable transform (e.g. print() → logging, deprecation rename, lint-rule auto-fixes) — the rules transfer cleanly even if line numbers don't.
  • Upstream's version of the file has additional lines the fork removed — re-derive lets you cover them with the same heuristic rather than rationalizing missing hunks.
  • The cherry-pick conflict count exceeds roughly 20 blocks across >2 files.

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).

Step 4: Pre-flight regression check

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 upstr
Полный SKILL.md на GitHub

Установить git-upstream-pr-diverged в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Bash(git status *)
Bash(git diff *)
Bash(git log *)
Bash(git show *)
Bash(git remote *)
Bash(git fetch *)
Bash(git switch *)
Bash(git checkout *)
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(git cat-file *)
Bash(git patch-id *)
Bash(gh pr *)
Bash(gh repo *)
Bash(bash *)
Bash(uv *)
Bash(pytest *)
Bash(ruff *)
Bash(python3 *)
Read
Edit
Write
Grep
Glob
TodoWrite

Вложенные файлы

REFERENCE.mdscripts/check-eligibility.shscripts/lib/load-config.shscripts/prepare-branch.shscripts/scrub-commit.sh

FAQ

Что делает скилл git-upstream-pr-diverged?

Submit a diverged-fork commit to upstream as a clean PR via cherry-pick with re-derive fallback, message scrubbing, and regression checks. Use when direct rebase fails.

Как установить скилл git-upstream-pr-diverged?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл git-upstream-pr-diverged запускает скрипты?

Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.

Похожие скиллы

Сравнить git-upstream-pr-diverged с