npm / lefthook
lefthook
What changed in lefthook 2, from its official release notes, upgrade guides and advisories. Sources checked 2026-10-18.
7 breaking12 new APIs and options1 performance11 behavior and defaults1 tooling44 fixes and other
See which of these apply to your code, ranked, in your agent:
npx @unstale/cli initlefthook 276 changes
Breaking changes 7
Color blending is removed.
The hook now fails when staging fixed files errors.
The minimum required Go version was updated.
Custom hooks are no longer installed to the hooks directory.
Custom templates are no longer escaped in command replacement.
Support for exclude regexp has been dropped.
The deprecated skip_output option is no longer supported.
New APIs and options 12
Packaging now supports Android.
Adds support for PHP Composer.
Adds integration with AI coding agents.
Introduces a setup hook option.
Allows installing hooks in non-Git repositories.
A timeout argument was added.
JSONC support was added, allowing configuration in JSONC format.
Adds the ability to show a diff when failing on changes.
Adds no_auto_install to lefthook.yml to control automatic installation.
Scripts can now accept optional arguments, allowing developers to pass arguments when using them.
Adds an optional standard glob matcher, doublestar, for configuring glob matching.
Adds the fail_on_changes option for non-CI environments.
Performance 1
A ghost hook is skipped when hooks are already configured.
Behavior and default changes 11
Install no longer writes an install-time lefthook path into AI hook configs.
Push files are diffed against the merge base with the default branch.
Forced colors are propagated to hook commands via CLICOLOR_FORCE.
Hints from lefthook install are less verbose.
Checks core.hooksPath when installing hooks.
Python wheels now contain one binary per platform.
Scripts are skipped when arguments are given with an empty file template.
Refetches and cleans up when the ref changes.
Lefthook now prefers using the executable found in $PATH.
Hooks now save the original executable location.
Windows uses sh as the command executor.
Tooling 1
Adds rudimentary shell completions for Lefthook commands.
Fixes and other changes 44
Cleanup now removes only the current stash hash, avoiding cleanup of other stashes.
Generates different patch names when running in a worktree.
The flag now ignores a trailing NUL.
The --output path is now passed to git diff as a single argument.
Submodules are no longer hashed when checking fail_on_changes.
Preserves unrelated unstaged changes when a conflict occurs.
Fixes staging fixed files when files are partially staged.
Paths in the generated hook shim are quoted.
Stdin is no longer piped into the post-checkout git-lfs hook.
The push-files fallback now resolves against the remote-tracking ref.
Fixed precedence for LEFTHOOK_OUTPUT.
PTY commands inherit the terminal size.
Updates the hooks path after resetting.
Lefthook no longer warns when the local hooks path equals the default hooks path.
Colors are changed to provide contrast.
The fallback push branch is separated from pathspecs.
The stage_fixed behavior is applied only when it is safe.
Unstaged changes are now always restored, preventing them from being lost during hook execution.
Skips PTY allocation when stdout is not a terminal.
Ensures root includes a trailing slash before path replacement.
Logs the full scoped name for skipped jobs.
Packaging no longer pipes stdout and stderr.
Normalizes the lefthook path used for the sh script on Windows.
Fixes an issue involving Git repository merges.
Prevents lefthook run from overwriting global hooks.
Uses pre-push stdin for push file detection.
Separates non-option arguments with -- in more commands.
Restores the {lefthook_job_name} template.
Support for Git debug versions was fixed.
Auto-staged changes are rolled back if unwanted changes are detected.
Colors are reset when reading configuration.
The JSON schema now accepts a string for file_types.
A direct file is read instead of reading all remotes.
Execution is skipped if an any-files template is empty.
The JSON schema now allows custom hooks, so configurations using them can be validated against the schema.
The extends value is set to an empty slice after loading remotes.
Makes the Git short status parser more robust.
Skips the template when the files are empty.
Improves separation of options and filenames for more git commands.
The pre-commit hook is skipped when there are no staged files.
Scanner errors are now checked and reported.
Fixes the JSON Schema values for glob_matcher.
Adds a mutex lock before all git commands.
The CLI accepts --fail-on-changes=false as an override value.