Home

Lefthook

Lefthook is an open-source tool that manages Git hooks for a project. It provides a centralized, language-agnostic way to run project-specific scripts in response to Git events such as commits and pushes. By replacing or augmenting the native .git/hooks, Lefthook ensures that checks like tests, linters, or formatting run consistently across developer machines.

Configuration is done in a YAML file named lefthook.yml placed at the repository root. The file defines

Installation and basic usage typically involve adding Lefthook to the project’s development tooling and running an

Lefthook emphasizes portability across operating systems and is commonly used in both open-source and commercial projects.

hooks
for
events
(for
example
pre-commit,
pre-push,
commit-msg)
and
the
commands
to
run
for
each
event.
Lefthook
installs
corresponding
scripts
into
the
repository’s
.git/hooks
directory
so
that
Git
triggers
them
automatically.
The
tool
is
designed
to
work
with
multiple
programming
languages
and
can
run
commands
from
diverse
toolchains
without
requiring
project-specific
wrappers.
install
command
to
generate
the
Git
hooks.
Once
installed,
developers
attempting
to
commit
or
push
will
have
Lefthook
execute
the
configured
commands,
and
failing
hooks
can
block
the
operation
until
issues
are
resolved.
This
helps
enforce
code
quality
gates
such
as
passing
tests
or
linting
before
integration.
It
competes
with
other
Git
hooks
managers
and
has
a
community-maintained
ecosystem
of
configurations
and
examples.
See
also
Git
hooks;
Husky;
pre-commit.