/git-plugin:git-local-hazardsfrom git-plugin
Detects local git traps where a green exit code masks incorrect state: orphaned commits after squash-merge, stale PR branches, and vanished staged files.
Ships in git-plugin. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
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.
| 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 |
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.
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.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 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.
gh pr list --head <branch>
returns nothing (and --state all shows MERGED) while you still have commits
in origin/main..HEAD.gh pr list --head "$(git branch --show-current)" --json number,state.main ride into new branchesBranching 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).
git fetch origin && git switch -c <branch> origin/main.git log --oneline origin/main..main — empty means clean.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).
grep -c '<symbol>' <file> — expect 1.The rebase variant: zero conflicts, broken result, no textual overlap. Same
law, and easier to miss because a rebase that replays cleanly feels verified.
When main gains a file that depends on state your branch removed, the two
never touch the same lines, so there is nothing to conflict on — and the merged
tree is still broken.
Field case: REFERENCE.md.
main
added while you were away (git log --oneline --name-only <old-base>..origin/main)
and ask whether any of it depends on something your branch deletes — an
extension, a column, a helper, a config key. Then run the suite on the target
environment, not just the one you develop in.git add aborts atomically on a bad pathspecgit add fileA nonexistent stages nothing — not "fileA plus a warning".
Classic trip: git mv old new, edit new, then git add new old → the stale
old aborts the add, and the commit ships the rename with pre-edit content.
git status --short first, then stage every
confirmed-present path in ONE git add -- A B C, and run git commit as a
separate call. List every path in that single call rather than chaining
git add A && git add B — the chain races on index.lock and the git-chain
hook blocks it (#3042). After git mv + edit, stage <newname>, not the
stale <oldname>.git status --short before committing — the index column must
show the change you intend.Sibling of the push-by-SHA HEAD race in git-plugin:git-merge-hazards (the
stacked-chain protocol and its three async races): the index and HEAD are
process-global, so a coworker session's commit lands between two of your Bash
calls with no warning. Field case: REFERENCE.md.
git log --oneline -3 — did HEAD
move? — and git log -1 -- <path>; a fresh commit touching the path is the
discriminator between "lost" and "landed".HEAD:<path> and keep the committed version unless yours
is genuinely newer.reset --hard is often still in a pre-commit stashUnstaged content has no reflog entry, so this looks unrecoverable — but
pre-commit stashes unstaged changes around every run, and those stash
commits go dangling and survive until gc.
git status before reset --hard/checkout/restore/clean;
git stash -u anything present.git fsck --lost-found, then per dangling commit (not blob)
git show <c>:<path>; rank by git diff --numstat HEAD <c> -- <path>
against the diff shape you remember.git-plugin:git-merge-hazards — GitHub-side traps: squash-merge detection,
stacked-PR auto-close, push-by-SHA races, merging over redgit-plugin:git-coworker-check — detection before destructive ops, and the
shared-checkout branch-isolation check before git push -ugit-plugin:git-pr-sync-check — is the current PR branch still liveWhat SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub laurigates/claude-plugins --plugin git-plugin52 skills in this plugin
/deadbranchdeadbranch CLI for stale-branch cleanup — dry-run preview, TUI or non-interactive delete, protects main/develop/WIP. Use when asked to clean up branches, prune branches, or remove stale branches./external-pr-trustAuthorship as a precondition of merging — bot vs stranger classification, what a merge executes, the merge-guard hook. Use when bulk-merging PRs, or when a merge is denied for a non-self author./gh-cli-agenticgh CLI commands with JSON output for agents. Use when querying PRs, issues, runs, or repo metadata; inspecting PR checks; fetching failed CI logs; or mapping a github.com URL to an API call./git-api-prGitHub API PR creation without local git. Use when submitting file changes as a PR without local commits — quick fixes, typos, config updates, or bypassing local git state./git-branch-namingBranch names: type prefix (feat/, fix/, chore/), issue number, kebab-case. Use when picking a name for a new branch or setting a repo's branch-naming convention./git-branch-pr-workflowBranch management and PR workflows — git switch/restore, GitHub MCP. Use when creating branches, opening PRs, or working with feature branches.Other plugins' skills for the same job