Git hooks that only exist on one person’s machine, so a teammate or a coding agent commits without the checks.
Add "Git hook setup" from ntent to this repo.
Fetch https://ntent.app/r/f/hooks-path as plain text. Merge it into package.json, inside the "scripts" block, without disturbing what is already there. Then make exactly these edits and no others: Say which of these this repo is, and do that one. (1) No package.json at the root (a Python, Go or Rust repo): add no prepare line. Run `git config core.hooksPath scripts/git-hooks` once and put that line in the setup step the repo already documents (README, Makefile, a bootstrap script), because the setting is local to a clone. (2) package.json already has a `prepare` script: merge, never replace. Keep the existing command first and append ours after a `;`, so `"prepare": "husky; <our line>"`. The line ends in `exit 0`, so it has to be last. (3) Husky (a .husky/ folder, or core.hooksPath pointing at .husky/_): leave the path alone and chain. Add one line to .husky/pre-commit, after the husky.sh line if the file has one: `bash scripts/git-hooks/pre-commit || exit 1`. It says bash, not sh, because the hook is a bash script and on Debian and Ubuntu `sh` is dash, which fails it on every commit. (4) A .githooks/ folder, or any other core.hooksPath: same chain, one line in that folder’s pre-commit, creating the file with a `#!/bin/sh` first line if there is none. (5) The Python pre-commit framework (.pre-commit-config.yaml): do not set core.hooksPath, because `pre-commit install` refuses to run once it is set. Add a local hook under `repos:` instead: `- repo: local`, `hooks:`, `- id: ntent`, `name: ntent checks`, `entry: scripts/git-hooks/pre-commit`, `language: system`, `always_run: true`, `pass_filenames: false`. In every case where you chained rather than set the path, the pre-commit step still goes to scripts/git-hooks/pre-commit. Then, whatever the case, run `git check-ignore -v scripts/ AGENTS.md scripts/git-hooks/pre-commit`. A line of output means .gitignore hides it and the install would never be committed: add a negation line for it (`!scripts/`, `!AGENTS.md`), run the command again until it prints nothing, and say what you changed.
Then check it: Run the install, then `git config core.hooksPath` prints scripts/git-hooks. A fresh clone gets the same answer with no manual step. The line cannot fail an install: with no .git directory it prints nothing and exits 0, and where core.hooksPath already points somewhere else it prints one line to stderr and exits 0. Leave .git/hooks alone: it may hold hooks somebody else installed. Where the repo had hooks of its own (Husky, .githooks, a Python pre-commit config), do not trust the config to tell you they work. Stage a change that breaks a gate and commit it: the commit must be refused, naming the gate. Say which of the five cases in customise you took.Reads https://ntent.app/r/f/hooks-path
Read the code
"prepare": "git rev-parse --git-dir >/dev/null 2>&1 || exit 0; h=$(git config core.hooksPath); case \"$h\" in ''|scripts/git-hooks) git config core.hooksPath scripts/git-hooks ;; *) echo \"ntent: core.hooksPath is already $h, so scripts/git-hooks was not wired. Call scripts/git-hooks/pre-commit from the hook you have.\" >&2 ;; esac; exit 0"How to tell it works: Run the install, then `git config core.hooksPath` prints scripts/git-hooks. A fresh clone gets the same answer with no manual step. The line cannot fail an install: with no .git directory it prints nothing and exits 0, and where core.hooksPath already points somewhere else it prints one line to stderr and exits 0. Leave .git/hooks alone: it may hold hooks somebody else installed. Where the repo had hooks of its own (Husky, .githooks, a Python pre-commit config), do not trust the config to tell you they work. Stage a change that breaks a gate and commit it: the commit must be refused, naming the gate. Say which of the five cases in customise you took.