git-local-hazards
БесплатноБез исполняемых скриптовНе проверенLocal git traps where a green command is wrong. Use when branching after a squash-merge, cutting a PR branch, after a clean merge or rebase, when a staged…
от laurigates★ 61 звезда на GitHubОб этом скилле
Git Local Hazards — Verify the Content, Not the Exit Code
Promoted from the always-loaded ~/.claude/rules/git-hazards.md rule, whose
stub keeps the gate lines. The body below is that rule's text. Sibling:
git-plugin:git-merge-hazards (GitHub PR/merge machinery), which follows the
same promotion pattern.
Six local-git traps, one law: a green git command is not proof the result is correct — exit 0 is a claim about mechanics, not content. Each: the trap, the 5-second check, the fix.
When to Use This Skill
| Use this skill when... | Use something else when... |
|---|---|
| Starting follow-up work after a branch's PR squash-merged | Deciding whether a branch really landed on GitHub → git-merge-hazards |
| Cutting a new PR branch | Another agent may be moving HEAD in this clone → git-coworker-check |
| A merge or rebase reported success over sibling work | Resolving an actual conflict → git-conflicts |
A staged file vanished or git status flaps |
Deleting a whole checkout → git-repo-delete-check |
About to reset --hard / checkout / restore / clean, or recovering after one |
1. Commits added after a squash-merge are orphaned
Anything committed to a branch after its squash-merge is in neither main
nor the squash commit. A fresh branch off origin/main silently lacks that
work; the first symptom is an ImportError far downstream.
- Check before follow-up work:
git grep <symbol> origin/main -- <path>— don't trust "the PR merged". The symbol must be unique to the change: a grep fortier == "deliver"reported a change as landed when the hit came from a pre-existing line that merely contained the same text (2026-08-19). Prefergit cherry origin/main <branch>—+means not upstream, and it survives SHA rewriting (rebase, cherry-pick), which plain ancestry checks do not. A squash-merge defeats it two ways: a multi-commit squash marks every commit+, landed or orphaned (no single commit's patch matches the combined squash commit), and even a single-commit squash reads+whenmainedited lines inside the diff's context before the merge (the patch-id cherry compares hashes context lines too). After a squash, take the boundary from the PR's frozen head instead:gh pr list --head <branch> --state all --json state,headRefOid, thengit log --oneline <headRefOid>..<branch>lists exactly the commits the merge did not include. The head SHA is the boundary, not commit dates: a commit made before the merge but pushed after it is dated earlier thanmergedAt. - Fix: replay only the orphans:
git rebase --onto origin/main <squash-point> <branch>, then verifygit log --oneline origin/main..HEADshows only the orphaned + new commits. Confirm nothing was lost by comparing trees, not diffs:git rev-parse HEAD^{tree} <old-tip>^{tree}must match.
The variant with no symptom at all: the PR merges WHILE you are still on the branch
The framing above assumes you come back later and branch afresh. The quieter
case is that you never leave: the PR is merged mid-session — by CI, by a
teammate, by the user in another window — and you keep committing to the same
branch. Every git push succeeds, git status is clean, and nothing says the
branch's PR is closed. Field case: REFERENCE.md.
- The tell is on the remote, not locally.
gh pr list --head <branch>returns nothing (and--state allshows MERGED) while you still have commits inorigin/main..HEAD. - Do not reuse the merged branch for the new PR. A merged PR cannot take new commits; push the rebased work to a new branch name so the fresh PR is not tangled with the closed one.
- Cheap habit: before the second push to any branch in a long session, run
gh pr list --head "$(git branch --show-current)" --json number,state.
2. Unpushed commits on local main ride into new branches
Branching off local main inherits whatever it is ahead of origin/main by;
the PR then bundles stray commits under an unrelated title (squash hides it —
visible only in the file list).
- Rule: cut PR branches from the remote, always:
git fetch origin && git switch -c <branch> origin/main. - Check when unsure:
git log --oneline origin/main..main— empty means clean.
3. A clean textual merge can duplicate identical additions
When two branches each add the same helper/import/enum arm in non-adjacent
spots, git merge sees no overlapping hunk, reports success, and keeps both
copies — a duplicate-definition build break (or worse, silent shadowing in
lax languages).
- Check: build/test the merged tree before committing the merge; when
siblings solved related problems,
grep -c '<symbol>' <file>— expect 1. - Fix: hand-resolve to a single combined definition; never trust "Automatic merge went well" as a verdict on content.
**The rebase variant: zero conflicts, b
Установить git-local-hazards в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
ReadGrepGlobBash(git *)Bash(gh pr list *)Bash(grep *)TodoWriteВложенные файлы
FAQ
Что делает скилл git-local-hazards?
Local git traps where a green command is wrong. Use when branching after a squash-merge, cutting a PR branch, after a clean merge or rebase, when a staged file vanishes, or before reset --hard.
Как установить скилл git-local-hazards?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл git-local-hazards запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
от Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
от Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropic