Command Palette

Search for a command to run...

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

git-merge-hazards

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

Traps in GitHub's merge machinery. Use when merging a PR, merging a stacked or serial PR chain, auditing whether a branch really landed, or merging over red CI.

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

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

Git Merge Hazards

When to Use This Skill

Use this skill when... Use something else when...
Merging a PR, or proving a branch landed The PR's green CI ran against an older main → git-plugin:worktree-stale-base-merge
Deciding whether a red PR can merge (§4) Deciding whether a red AI-review check is a real finding → github-actions-plugin:ai-review-max-turns
Merging an ad-hoc stacked chain (§2, §3) Release-please PRs are piling up or conflicting → git-plugin:release-please-pr-workflow

The numbered sections mirror the ~/.claude/rules/pr-merge-hazards.md rule; differences: references/sync-notes.md.

Six traps in GitHub's merge machinery, one law: "PR merged" says nothing about content — and a red check is not proof of failure. Sibling: git-plugin:git-local-hazards (local git).

1. --merged misses squash-merged branches

A squash-merge collapses a branch into one fresh-SHA commit on main, so the branch's own commits are never ancestors — git branch --merged (and any ancestry check) reports it unmerged. "Files identical to main" also fails once main drifts the same files.

  • Check, in order of authority:
    • gh pr list --state all --head <branch> --json state → a MERGED PR is authoritative. Reach for this first; the git-side checks below are all one-way.
    • git cherry main <branch> → marks a commit - when a patch-equivalent commit is already upstream, + when it is not. Survives squash and cherry-pick, and does not care that main drifted.
    • git merge-tree --write-tree main <branch> equals git rev-parse main^{tree} → contained. A match proves containment; a non-match proves nothing.
  • Not immune to drift (corrected 2026-07): once main moves on over the same files, merging an already-merged branch back would re-introduce its older versions, so the trees differ and merge-tree reports not contained for work that fully landed. Observed reporting three merged branches as unmerged. Same trap as "files identical to main". Use the PR state or git cherry to decide; keep merge-tree only as a positive-containment shortcut.
  • Fix: just -g branch-audit (in private_dot_config/just/git.just) prints MERGED vs REVIEW + a paste-ready delete. Its REVIEW bucket measured ~90% false positives (#2268), so a REVIEW line is a question to settle with gh pr list --state all --head <branch>, not a verdict.
  • A non-match is "review", not proof of unmerged — don't force the count to zero.

2. Merging a stacked base auto-CLOSES the child PR

When PR B is based on PR A's branch, merging A and deleting its branch auto-closes B (GitHub does not retarget it), and a closed PR whose base branch is gone cannot be reopened.

  • Check the base first (skill-only): gh pr view <base> --json state,mergeStateStatus,mergeable before retargeting. Proceed only when state is OPEN and mergeable is MERGEABLE; the mergeStateStatus values and the UNKNOWN wait are in references/no-force-push-stack.md.
  • Fix — order matters: retarget the child first, while the base PR is open:
    1. gh pr edit <child> --base main
    2. gh pr merge <base> --<method> --delete-branch (method: pr-merge-method.py)
    3. git rebase --onto origin/main <old-base-tip> <child-branch> (drops the base's commits) + git push --force-with-lease
    4. merge the child.
  • No-force alternative (skill-only, preferred when the child builds only on its base): merge main into the child with no force-push, after a classification that decides whether -X ours is lossless. Recipe: references/no-force-push-stack.md. The rebase path in the Fix steps is the fallback.
  • Delta-apply (skill-only) when the child forked from an older base head, or an independent PR shares its files: references/delta-apply-stack.md.
  • Fork PR on an open upstream PR's head (skill-only): merging pushes into that PR too: references/fork-upstream-base.md.
  • If already auto-closed: the head branch survives — rebase as above, gh pr create fresh, comment "Superseded by #new" on the closed one.
  • Nothing tells you this happened, and only a scheduled sweep finds it; a dead base ref tells an auto-close from a human close: references/stranded-child-audit.md.

3. Stacked-chain merges: push by SHA, never HEAD: — and expect auto-close races

Read references/stacked-chain-push.md before any force-push or merge in a stacked-PR chain. It carries the push-by-SHA refspec form, the empty-diff auto-close, the mergeability and CI-registration races, the pre-push check, and auto-close recovery.

4. A red PR may still be mergeable — UNSTABLE is not `BLOC

Полный SKILL.md на GitHub

Установить git-merge-hazards в Claude Code и Claude Desktop

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

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

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

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

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

Read
Grep
Glob
Bash(gh pr *)
Bash(gh issue *)
Bash(gh api *)
Bash(git cherry *)
Bash(git merge-tree *)
Bash(git rev-parse *)
Bash(git rev-list *)
Bash(git log *)
Bash(git reflog *)
Bash(git rebase *)
Bash(git merge *)
Bash(git checkout *)
Bash(git worktree *)
Bash(git diff *)
Bash(git add *)
Bash(git commit *)
Bash(git -C *)
Bash(git merge-base *)
Bash(grep *)
Bash(awk *)
Bash(jq *)
Bash(git push *)
Bash(git fetch *)
Bash(git cat-file *)
Bash(sleep *)
Bash(just *)
Bash(bash *)
TodoWrite

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

references/closing-keyword-cases.mdreferences/delta-apply-stack.mdreferences/fork-upstream-base.mdreferences/merge-endpoint-failures.mdreferences/merge-over-red-triage.mdreferences/merge-shepherd.mdreferences/no-force-push-stack.mdreferences/serial-merge-chain.mdreferences/stacked-chain-push.mdreferences/stranded-child-audit.mdreferences/sync-notes.mdscripts/merge-chain.sh

FAQ

Что делает скилл git-merge-hazards?

Traps in GitHub's merge machinery. Use when merging a PR, merging a stacked or serial PR chain, auditing whether a branch really landed, or merging over red CI.

Как установить скилл git-merge-hazards?

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

Скилл git-merge-hazards запускает скрипты?

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

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

Сравнить git-merge-hazards с