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.
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.
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.
How to use
- Install Lefthook:
go install github.com/evilmartians/lefthook@latestor download the binary - Run
lefthook installin your repo to set up Git hooks - Create a
lefthook.ymlconfig file defining your hooks
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
| Feature | Lefthook | Husky + lint-staged |
|---|---|---|
| Runtime dependency | None (Go binary) | Node.js |
| Parallel execution | Built-in | lint-staged only |
| Config format | YAML | package.json + rc |
| Staged file filter | {staged_files} | lint-staged glob |
| Language support | Any | Primarily JS/TS |
Related on TokRepo
- AI tools for coding — developer productivity tools on TokRepo
- Automation tools — CI, hooks, and automation helpers
Common pitfalls
- Lefthook must be installed by every developer on the team; add
lefthook installto 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-ttyin CI to get cleaner logs
Frequently Asked Questions
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.
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.
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.
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.
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
Related on TokRepo
Source & Thanks
Created by Evil Martians. Licensed under MIT.
lefthook — stars 5,000+
Thanks for making git hooks fast and painless.
Discussion
Related Assets
Kornia — Differentiable Computer Vision Library for PyTorch
Kornia is a differentiable computer vision library built on PyTorch that provides GPU-accelerated implementations of classical vision algorithms including geometric transforms, color conversions, filtering, feature detection, and augmentations, all with full autograd support for end-to-end learning.
AlphaFold — AI-Powered 3D Protein Structure Prediction
AlphaFold by Google DeepMind predicts three-dimensional protein structures from amino acid sequences with atomic-level accuracy, enabling breakthroughs in drug discovery, enzyme engineering, and structural biology research.
Flash Attention — Fast Memory-Efficient Exact Attention for Transformers
Flash Attention is a CUDA kernel library that computes exact scaled dot-product attention 2-4x faster and with up to 20x less memory than standard implementations by using IO-aware tiling to minimize GPU memory reads and writes.