resolve-pr-conflicts
БесплатноЗапускает вложенные скриптыНе проверенResolve a pull request's merge conflicts by rebasing the PR branch onto its base, so the PR can land later with a rebase merge and a linear history. Use when…
от ericmjl★ 45 звёзд на GitHubОб этом скилле
Resolve PR conflicts so the PR can rebase-merge
Rebase a pull request branch onto the tip of its base branch, resolve the conflicts that follow, and publish the result, so that GitHub offers a rebase merge and the base branch stays linear.
One question drives every step: after the rebase, does the PR still change exactly what it changed before, on top of today's base? GitHub's conflict flag does not show that. A comparison of the commits and content before and after the rebase does.
Usage
Use this skill when a PR cannot merge because its branch is out of date.
- "Resolve conflicts in such a way that we can rebase to merge later."
- "Fix the merge conflicts on #N." "#N is conflicting."
- "We've recently merged some PRs, so make sure the PR is up to date."
- "Refresh this PR." "Rebase it on main." "Keep it rebase-mergeable."
- "Merge them all", and one PR fails with "the merge commit cannot be cleanly created".
- A stacked PR turns
CONFLICTINGright after the PR below it merged.
Inputs you should accept:
- PR number, URL, or branch. Default: the PR for the current checkout.
- The base branch. Default: the PR's base branch on GitHub.
Requirements
git2.38 or newer, for the read-only merge testgh, authenticated, with push access to the PR's head branch- A checkout of the repository, and room for a scratch worktree
- The repository's checks, run on the rebased tree: lint, typecheck, the tests for the changed files, any changelog validator
- This skill's two scripts, in
scripts/, run from a checkout of the repository
What it does
Seven steps: survey → prepare → rebase → resolve → verify → push → confirm and report. Only the push changes anything that other people can see.
Three facts explain most conflicts:
- GitHub offers a merge, by any method, only when a plain three-way merge
of the head into the base is clean. So a conflicting PR also blocks
gh pr merge --rebase, and GitHub's own error says so: "the merge commit cannot be cleanly created". The fix is a rebase of the branch, then a push. - A rebase merge gives the PR's commits new SHAs on the base. A PR that
is stacked on that branch still carries the old SHAs. GitHub's merge test
counts those commits as conflicts, although their content is already on the
base. A plain
git rebasedrops them, and the rebased tree is then identical to the old one. - Bots move text on the base. Release automation moves changelog entries out of the unreleased section. A rebase can then merge a file without a conflict and still put the PR's entry in the wrong place. "No conflict" is not "correct".
How it works
Step 1 — Survey, read-only
Change nothing in this step.
gh pr view <PR> --json number,title,state,isDraft,baseRefName,headRefName,headRefOid \
mergeable,mergeStateStatus,reviewDecision,commits,statusCheckRollup
bash scripts/pr_conflict_survey.sh --base origin/<base> --head origin/<head> \
--pr <PR> --repo <owner/repo>
The script prints four things:
- The base, the head, and their merge-base.
- The head's commits, with a
-on each one that the base already has by content. - The files that both sides changed.
- A dry-run merge, which is the test that GitHub runs. The script exits 0 when that merge is clean and 1 when it conflicts.
Read the output, then classify the PR:
| Survey says | Cause | Route |
|---|---|---|
| Dry run conflicts, and both sides edited the same lines | A real conflict | Steps 2 to 7 |
Dry run conflicts, and the head's commits are marked - |
A stacked PR whose parent merged | Steps 2 to 7; expect a pure replay |
| Dry run clean, but the head is behind the base | Out of date only | Steps 2 to 7, with nothing to resolve. gh pr update-branch <PR> --rebase also works |
mergeable is UNKNOWN |
GitHub is still computing | Wait a few seconds and ask again |
| The head branch belongs to a bot, such as dependabot | The bot owns the branch | Comment @dependabot rebase and stop; see gh-cli |
| The head is on a fork you cannot push to | No push access | Stop; give the author the rebased patch or the recipe |
| Two valid behaviors conflict, and the choice is a product call | Not a text conflict | Describe both options to the user and stop |
Record three values for the rest of the run:
git fetch origin "+refs/heads/<head>:refs/remotes/origin/<head>" "+refs/heads/<base>:refs/remotes/origin/<base>"
OLD_HEAD="$(git ls-remote origin "refs/heads/<head>" | cut -f1)" # live, not the tracking ref
NEW_BASE="$(git rev-parse "origin/<base>")"
OLD_BASE="$(git merge-base "$NEW_BASE" "$OLD_HEAD")" # where the PR forked
Step 2 — Prepare
Work in a checkout that nothing else uses. Another session can switch branches in a shared checkout in the middle of a rebase. Use a scratch worktree, and confirm the branch before every command.
SCRATCH="$(mktemp -d)/
Установить resolve-pr-conflicts в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл resolve-pr-conflicts?
Resolve a pull request's merge conflicts by rebasing the PR branch onto its base, so the PR can land later with a rebase merge and a linear history. Use when the user says 'resolve conflicts in such a way that we can rebase to merge later', 'fix the merge conflicts on #N', 'the PR is conflicting' or 'dirty', 'make sure the PR is up to date', 'refresh, rebase, or update this PR on main', 'keep it rebase-mergeable', or when a merge fails with 'the merge commit cannot be cleanly created' and a stacked PR goes CONFLICTING after its parent merges. Surveys the cause read-only, rebases in a scratch checkout, resolves each conflict by the PR's intent, proves that every commit and change survived, force-pushes with a lease pinned to the old head, and confirms MERGEABLE on GitHub. Never merges the base into the branch (no merge commits) and never merges the PR itself (gh-cli).
Как установить скилл resolve-pr-conflicts?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл resolve-pr-conflicts запускает скрипты?
Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.
Похожие скиллы
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…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от 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…
от Anthropic