git-add-u-after-async-post-commit-hook

git-add-u-after-async-post-commit-hook is a skill for Claude Code, Codex from wan-huiyan/agent-traffic-control. It costs 398 tokens per session (2,522 once invoked), scanned A, original, MIT.

A safety guide for amending Git commits when an asynchronous post-commit hook changes tracked files. A Git hook is an automatic script that runs after a repository action, and amending replaces the latest commit.

In plain words
What is it for?
Use it to detect, prevent, and recover from accidental deletions after commands such as git add -u, git commit --amend, and git push --force-with-lease.
Why use it?
It prevents a routine amend and force push from accidentally including thousands of unrelated file deletions caused by the hook.

Skill for Claude CodeCodex

Part of the agent-traffic-control plugin — 105 skills shipped together

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/wan-huiyan/agent-traffic-control/git-add-u-after-async-post-commit-hook
Any agent
npx skills add wan-huiyan/agent-traffic-control --skill git-add-u-after-async-post-commit-hook
Clone the repo
git clone --depth 1 https://github.com/wan-huiyan/agent-traffic-control

Made for: Claude Code, Codex.

Or install agent-traffic-control, the plugin that ships this one along with the rest of its 105 skills.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for git-add-u-after-async-post-commit-hook

README.md
[![agentmods](https://agentmods.dev/badge/skills/wan-huiyan/agent-traffic-control/git-add-u-after-async-post-commit-hook.svg)](https://agentmods.dev/skills/wan-huiyan/agent-traffic-control/git-add-u-after-async-post-commit-hook)
Your own site
<a href="https://agentmods.dev/skills/wan-huiyan/agent-traffic-control/git-add-u-after-async-post-commit-hook"><img src="https://agentmods.dev/badge/skills/wan-huiyan/agent-traffic-control/git-add-u-after-async-post-commit-hook.svg" alt="Measured on agentmods" height="20"></a>
Per session 398 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,522 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00398 $0.02522
Opus 5 $0.00199 $0.01261
Sonnet 5 $0.00080 $0.00504
Haiku 4.5 $0.00040 $0.00252

Measured 5d ago against content hash ae0048b1cd67, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-05, from the pricing page.

Security

Grade A, and why

git-add-u-after-async-post-commit-hook scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 5d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

plugins/agent-traffic-control/skills/git-add-u-after-async-post-commit-hook/SKILL.md · 239 lines

How it starts

The opening of the file, as written. The whole thing — 239 lines — stays where its author put it; the contents beside it link to each section on GitHub.

git add -u after async post-commit hook stages tracked-file deletions

Problem

You make a clean commit. The project's post-commit hook prints something like:

[post-commit] Python files changed — running doc update in background...

You then need to amend the commit (typo in message, wrong issue reference, etc.). You reach for the muscle-memory sequence:

git add -u && git commit --amend -m "..."   # ← TRAP

The amend output reports something terrifying:

[your-branch 480e2226] fix(...): your message
 1493 files changed, 4 insertions(+), 368977 deletions(-)
 delete mode 100644 .claude-memory/MEMORY.md
 delete mode 100644 .claude-memory/SESSION_CHECKPOINT_*.md
 delete mode 100644 scripts/...
 ...

If you immediately ran git push --force-with-lease, that catastrophe is now on the remote branch. The remote PR diff shows thousands of unrelated deletions mixed with your intended 6-file fix.

git status afterwards reveals the smoking gun — files that WERE tracked before the amend now show as Untracked:

On branch your-branch
Your branch is up to date with 'origin/your-branch'.

Untracked files:
        .claude-memory/
        .cursor/
        .github/
        MEMORY.md
        PRODUCT.md
        scripts/

Why it happens

The async post-commit hook fires after your first commit and starts a background process that:

  1. Reads tracked files (e.g. MEMORY.md, docs/site/*.html).
  2. Regenerates / renames / moves / deletes them as part of doc rebuild logic.
  3. May run git rm or otherwise mutate the index.

The hook is async (& / nohup), so the commit returns immediately and you get the prompt back. The hook is still running.

When you then run git add -u, git stages every change to tracked files — including all the deletions/modifications the hook performed. When you --amend, those deletions become part of the commit. Force-push propagates them to the remote.

Trigger conditions

ALL of these together:

  • Project has a post-commit hook that prints running ... in background, running ... in &, nohup, or similar — visible in git commit output.
  • You commit, see the hook log line, and don't wait for the background process.
  • You run git add -u (or git add . from repo root) before amending or before staging your next intentional change.
  • Your git diff --staged --stat reports far more files than you touched.

Read the full file on GitHub · 239 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 5d ago First seen · 239 lines · 398 tokens per session scan A ae0048b1cd67

Subscribe to this mod's changes

git-add-u-after-async-post-commit-hook is a skill published in the GitHub repository wan-huiyan/agent-traffic-control (3 stars, last pushed 2d ago), licensed MIT. It adds 398 tokens to every session and 2,522 once invoked, about $0.0020 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories

claude-code-bash-patterns

Claude Code Bash tool patterns with hooks, automation, git workflows. Use for PreToolUse hooks, command chaining, CLI orchestration, custom commands, or encountering bash permissions, command failures, security guards, hook configurations.

secondsky/claude-skills · 52 tokens

merge-worktree

Squash-merge the current worktree branch into the main branch (or a specified target). Analyzes git history and source code to craft a comprehensive commit message.

HyperAITeam/CLITrigger · 38 tokens

git-commit

Turn the working changes into one or more atomic commits with well-written messages. Use whenever the user runs /git-commit or asks to commit their work, wrap up a feature, or "commit what I have.".

thoughtbot/rails-consultant · 47 tokens

misuzu

Respond to PR review comments semi-automatically. Fetches all review threads and comments, splits them into logical units, fixes and commits one unit at a time, then replies and resolves review threads. Use when the user wants to address PR review feedback or respond to review comments.

ncaq/konoka · 59 tokens

commit-style

Commit message style guidelines. Use when writing or proposing git commit messages, including direct git commit commands outside the /commit skill.

ncaq/konoka · 28 tokens

bridge

Join a shared per-project chat between AI coding agents (Claude Code, Cursor, …) — group channels + DMs — and receive messages from other instances using whatever your agent supports (push, loop, or poll). Use when coordinating multiple agent instances on the same project.

msanchezdev/agent-bridge · 57 tokens