← ClaudeAtlas

git-amend-hits-async-post-commit-hook-commitlisted

Use when a `git commit --amend` silently rewrites the WRONG commit in a repo that has an async/background post-commit hook. Trigger: after a normal commit, `git log` shows an unexpected extra commit on top that a background hook created (`[auto-docs] ...`, a docs/site regen, a changelog/checkbox tick) — and a later `--amend` folds your change into THAT hook commit instead of your feature commit. The amend reports success; no error. Also use proactively before instructing subagents to `--amend` in any repo with a background post-commit hook. Sibling of git-add-u-after-async-post-commit-hook, git-rebase-stalls-async-post-commit-hook, worktree-index-corrupt-async-post-commit-hook.
wan-huiyan/agent-traffic-control · ★ 2 · Code & Development · score 79
Install: claude install-skill wan-huiyan/agent-traffic-control
# `git commit --amend` hits the async post-commit hook's commit ## Problem A repo has an **async post-commit hook** — it fires in the background after a commit and creates its OWN follow-up commit (auto-generated docs, a site regen, a changelog or plan-checkbox tick). If you (or a subagent) run `git commit --amend` after that hook has fired, `--amend` rewrites **the hook's commit**, not your work commit. Your change's content is folded into a commit titled e.g. `[auto-docs] ...`; your real `feat(...)` commit is left untouched. The amend "succeeds" — no error — so it is easy to miss. ## Context / Trigger Conditions - The repo has a background/async post-commit hook (look for a `post-commit` hook that backgrounds work, or commits with prefixes like `[auto-docs]`, `chore: regenerate site`, etc. appearing without a human authoring them). - You ran `git commit`, then later `git commit --amend` (often a code-review fix, a typo fix, or "tidy the last commit"). - `git log` shows HEAD's message is the hook's, not yours — and your change is inside that hook commit. - Especially common in **subagent-driven development**: a fix subagent is told to `--amend` its fix, but the async hook committed between the implementer subagent's commit and the fix subagent running. ## Solution 1. **Never `git commit --amend` in a repo with an async post-commit hook** — and never instruct a subagent to. Use a fresh `git commit`. A clean extra commit is harmless (it squash-merges aw