Gem

Lefthook

A fast git hooks manager for any language, configured in one YAML file.

Would you recommend Lefthook?

No votes yet. Tried it? Be the first to say.

One vote per person. No account needed.

Overview

Lefthook installs git hooks from a `lefthook.yml` in your repo and runs their commands in parallel, optionally only on the staged files that match a glob. It's a single Go binary published to npm, Homebrew, RubyGems, PyPI and more, so it fits a JavaScript, Ruby, Python or Go project without adding another runtime.

Instead of
Husky plus lint-staged, or the pre-commit framework
Reach for it when
You want formatters, linters and tests to run quickly on commit or push, with the config checked into the repo.

Key features

  • One config file

    Hooks and their commands live in lefthook.yml in the repo.

  • Parallel commands

    Runs a hook's commands at the same time for faster commits.

  • Staged-file filtering

    {staged_files} and glob limit each command to the files that matter.

  • Auto-staging fixes

    stage_fixed: true re-adds files that a formatter changed.

  • Local overrides

    lefthook-local.yml lets individual developers skip or change commands without editing the shared config.

  • Any ecosystem

    Published to npm, Homebrew, RubyGems, PyPI, Go, apt and winget.

In depth

A typical config

yaml
# lefthook.yml
pre-commit:
  parallel: true
  commands:
    format:
      glob: "*.{js,ts,json,css}"
      run: npx biome format --write {staged_files}
      stage_fixed: true
    lint:
      glob: "*.{js,ts}"
      run: npx biome lint {staged_files}
    go-vet:
      glob: "*.go"
      run: go vet ./...

pre-push:
  commands:
    test:
      run: npm test

Setup

bash
npm install --save-dev lefthook   # installs the hooks for you
# or: brew install lefthook, then:
lefthook install                  # write the git hooks from lefthook.yml
lefthook run pre-commit           # run a hook manually

Good to know

  • LEFTHOOK=0 git commit skips hooks for one command; lefthook-local.yml (git-ignored) is the tidier way to change them for one person.
  • skip options can disable commands during merges or rebases.
  • It's maintained by Evil Martians and has been in active use since 2019.

Strengths and watch-outs

Strengths

  • Fast, and needs no extra runtime: it's a single Go binary.
  • One tool for monorepos that mix languages.
  • The config is short and readable compared with Husky scripts plus lint-staged settings.

Watch out for

  • Hooks can always be skipped with --no-verify, so still run the same checks in CI.
  • Every developer needs it installed; the npm package's install script helps, while other ecosystems need a setup step.
  • It runs your commands but doesn't install linters for you, unlike the pre-commit framework.

Try it in a few minutes

Terminal
npm install --save-dev lefthook   # or: brew install lefthook / gem install lefthook / pipx install lefthook
npx lefthook install

Alternatives

Husky with lint-staged

The JavaScript default, with two tools and two configs to do the same job.

pre-commit

A Python framework that also installs and pins the hook tools themselves, at the cost of speed.

Plain .git/hooks scripts

No dependencies, but not shared through the repo by default.

Related tools

Other tools that share topics with Lefthook.

lazygit

github.com
Gem

A fast terminal UI for git: staging hunks, rebasing and resolving conflicts.

Instead of git add -p, git rebase -i in an editor, GUI clients

fzf

junegunn.github.io
Gem

A fuzzy finder for anything you can list: files, shell history, git branches, processes.

Instead of Scrolling through `history | grep`, typing long paths by hand, and one-off select menus in shell scripts

T3 Code

t3.codes
New

One fast app for driving Claude Code, Codex and other coding agents, from your desk or your phone.

Instead of A terminal tab per agent, each vendor's own desktop app, and SSH-ing in from your phone to check on a long run