agentleFS
narenaryannarenaryan/agent-skills/skills/git/git-hooks/SKILL.md

git-hooks

Skill0 starsChanged 39 days agoMITView on GitHub

Use when hooks are unexpected, missing, or misconfigured; covers effective paths, visibility, lifecycle, bypasses, and checkout scope

  • Commits and pushes

The file

We split this skill into the rules it gives an agent

1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Commit flow: pre-commit → prepare-commit-msg → editor → commit-msg → post-commit.

    line 37

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Git Hooks

Hooks run on named Git events from the effective path. Git ignores non-executable files; failed pre-hooks abort, post-hooks do not.

Locate the effective hooks

git rev-parse --git-path hooks
git rev-parse --git-common-dir
git config --show-origin --get core.hooksPath

--git-path hooks resolves the path: $GIT_DIR/hooks normally, $GIT_COMMON_DIR/hooks in linked worktrees. Relative core.hooksPath follows hook cwd (non-bare clients: worktree root; bare/receive: $GIT_DIR).

Distribution

Clones omit source .git/hooks; templates can seed hooks and core.hooksPath can redirect to shared/global hooks. After reviewing and trusting the scripts, use a tracked directory:

git config core.hooksPath .githooks
git commit --no-verify          # bypass pre-commit + commit-msg
git push --no-verify            # bypass pre-push

Visibility and checkout scope

  • A custom zsh chpwd function can list executable non-.sample hooks once per path; call it at shell startup too, and avoid alert fatigue.
  • A .pre-commit-config.yaml declares checks, not an installed hook. Installer-marker checks miss custom wrappers.
  • Sharing a working copy can bring active .git metadata. Linked worktrees share common-dir hooks; see Git worktrees.

Client-Side

Commit flow: pre-commit → prepare-commit-msg → editor → commit-msg → post-commit.

HookArgsAbort?Use
pre-commit—yeslint, format, fast tests
prepare-commit-msgmsg-file, source, shayesinject ticket ID, templates
commit-msgmsg-fileyesvalidate message format
post-commit—nonotifications
pre-rebaseupstream [branch]yesblock rebasing published commits
post-rewriteamend|rebase; stdin: old→new shanore-run artifact gen after amend
post-checkoutprev, new, branch-flagnoLFS smudge, regenerate artifacts
post-mergesquash-flagnorestore untracked state
pre-pushremote, url; stdin: local-ref local-sha remote-ref remote-shayesfull tests, block force-push to main
pre-auto-gc—yesdefer gc when busy

Patch flow (git am): applypatch-msg → pre-applypatch → post-applypatch.

Server-Side (on bare repo)

HookArgsScopeAbort?
pre-receivestdin old new ref per updated refonce per pushyes (rejects all)
updateref, old, newper refyes (that ref only)
post-receivestdin like pre-receiveonceno — CI triggers

update is the granular gatekeeper: protect branches, reject non-FF on main, require signed commits.

pre-push and pre-receive receive ref-update records on stdin; read them when validating refs.

Pitfalls

  • For Bash hooks, use set -euo pipefail; POSIX sh lacks pipefail.
  • core.hooksPath replaces the default dir; copy any needed defaults in.
  • Client hooks are advisory; enforce security server-side or in CI.
  • Prompt listings are visibility aids, not hook validation or enforcement.

See source and validation notes.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.