npm / pre-commit
pre-commit
What changed in pre-commit 2, from its official release notes, upgrade guides and advisories. Sources checked 2026-10-27.
3 breaking2 security4 fixes and other
See which of these apply to your code, ranked, in your agent:
npx @unstale/cli initpre-commit 29 changes
Breaking changes 3
The generated wrapper is now a small bash script that execs the package's hook file via an absolute path; scripts parsing the wrapper must adjust.
Node.js 16.13 or newer is now required.
Signal-terminated scripts are no longer treated as successful.
Security 2
Hook file mode is tightened from 0777 to 0755.
Gitdir parsing is hardened against missing matches and bad input, and gitdir paths are resolved relative to the directory containing the .git file.
Fixes and other changes 4
The hook unsets this environment variable so commits triggered from emacs/magit behave like command-line commits.
The hook changes to the git root before resolving pre-commit, helping Yarn Plug'n'Play and GUI git clients with an unexpected working directory.
If the package is missing, the hook warns and exits 0 instead of throwing a module-not-found stack trace, so commits are not blocked.
Submodule installs now write the pre-commit hook under the submodule's git modules directory; linked worktrees are handled correctly too.