ScriptsApr 7, 2026·2 min read

Lefthook — Fast Git Hooks Manager in Go

Blazing-fast Git hooks manager written in Go. Run linters, formatters, and tests on git commit/push in parallel. Zero-dependency single binary. Replaces Husky + lint-staged. 5,000+ stars.

TL;DR
Lefthook runs linters and formatters on git commit/push in parallel, zero dependencies.
§01

What it is

Lefthook is a fast Git hooks manager written in Go. It runs linters, formatters, and tests on git commit and push events in parallel. It ships as a single binary with zero runtime dependencies, replacing the combination of Husky plus lint-staged in JavaScript projects or pre-commit in Python projects.

Lefthook targets any development team that wants pre-commit quality checks without the overhead of Node.js or Python runtimes. It works with any language and any toolchain because it simply executes shell commands you configure.

§02

Why it saves time or tokens

Lefthook runs checks in parallel by default, which makes pre-commit hooks significantly faster than sequential alternatives. It only runs checks on changed files (glob and staged-file filtering), so large repositories do not suffer from full-codebase scans on every commit. The YAML config is simpler than Husky's package.json scripts, producing fewer AI generation errors.

§03

How to use

  1. Install Lefthook: go install github.com/evilmartians/lefthook@latest or download the binary
  2. Run lefthook install in your repo to set up Git hooks
  3. Create a lefthook.yml config file defining your hooks
§04

Example

pre-commit:
  parallel: true
  commands:
    lint:
      glob: '*.{js,ts}'
      run: npx eslint {staged_files}
    format:
      glob: '*.{js,ts,css}'
      run: npx prettier --check {staged_files}
    test:
      run: npm test -- --bail

pre-push:
  commands:
    typecheck:
      run: npx tsc --noEmit
FeatureLefthookHusky + lint-staged
Runtime dependencyNone (Go binary)Node.js
Parallel executionBuilt-inlint-staged only
Config formatYAMLpackage.json + rc
Staged file filter{staged_files}lint-staged glob
Language supportAnyPrimarily JS/TS
§05

Related on TokRepo

§06

Common pitfalls

  • Lefthook must be installed by every developer on the team; add lefthook install to your onboarding docs or a setup script
  • The {staged_files} placeholder only works in pre-commit hooks; pre-push hooks do not have a staged files concept
  • Parallel execution means command output can interleave; use --no-tty in CI to get cleaner logs

Frequently Asked Questions

How does Lefthook compare to Husky?+

Husky requires Node.js and uses shell scripts or package.json scripts for hooks. Lefthook is a single Go binary with no runtime dependency and uses YAML configuration. Lefthook runs commands in parallel by default, while Husky relies on lint-staged for that. Lefthook works with any language, not just JavaScript projects.

Does Lefthook work with monorepos?+

Yes. Lefthook supports glob patterns and directory filters so you can run different commands for different parts of a monorepo. You can scope commands to specific directories and use the root option to specify the working directory for each command.

Can I skip Lefthook hooks temporarily?+

Yes. Use LEFTHOOK=0 git commit to skip all hooks for a single commit. You can also use git commit --no-verify, which is the standard Git mechanism for skipping hooks. However, skipping hooks should be rare and justified.

Does Lefthook support remote hooks configuration?+

Yes. Lefthook supports extends and remotes in its config, letting you pull hook definitions from a shared repository. This is useful for organizations that want to standardize pre-commit checks across many repositories without duplicating configuration.

How do I install Lefthook on CI?+

On CI, you typically do not need Lefthook because the CI pipeline runs its own checks. If you do want hooks in CI, install the binary via curl or your package manager and run lefthook install. Most teams use Lefthook locally and rely on CI for the authoritative check.

Citations (3)
  • Lefthook GitHub— Lefthook is a fast Git hooks manager written in Go
  • Git Docs— Git hooks documentation for pre-commit and pre-push
  • Evil Martians— Evil Martians engineering team maintains Lefthook
🙏

Source & Thanks

Created by Evil Martians. Licensed under MIT.

lefthook — stars 5,000+

Thanks for making git hooks fast and painless.

Discussion

Sign in to join the discussion.
No comments yet. Be the first to share your thoughts.

Related Assets