Command Palette

Search for a command to run...

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

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от 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 for tier == "deliver" reported a change as landed when the hit came from a pre-existing line that merely contained the same text (2026-08-19). Prefer git 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 + when main edited 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, then git 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 than mergedAt.
  • Fix: replay only the orphans: git rebase --onto origin/main <squash-point> <branch>, then verify git log --oneline origin/main..HEAD shows 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 all shows MERGED) while you still have commits in origin/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

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

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

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

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

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

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

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

Read
Grep
Glob
Bash(git *)
Bash(gh pr list *)
Bash(grep *)
TodoWrite

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

REFERENCE.md

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), без исполняемых скриптов.

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

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