Git hooks are the right place to catch problems - lint and test before a commit or push, so bad code never enters history - but wiring them up by hand is fiddly and they run slowly one after another. Lefthook is a fast, language-agnostic hooks manager that fixes both. You declare your hooks in one YAML file, and Lefthook runs the commands in parallel, only on the relevant files, so the pre-commit check that used to feel like a tax becomes nearly instant.
Hooks in One Config
A single lefthook.yml describes what runs and when, and it runs jobs concurrently:
# lefthook.yml
pre-commit:
parallel: true
commands:
phpcs:
glob: '*.php'
run: vendor/bin/phpcs {staged_files}
biome:
glob: '*.{ts,js}'
run: npx biome check {staged_files}
Fast and Team-Friendly
Because it only runs on staged files and runs commands in parallel, the checks stay quick even as they grow. The config is committed, so the whole team gets the same hooks automatically, and Lefthook is a single binary with no runtime dependency of its own.
Rough Edges and Limitations
- Hooks can be bypassed.
--no-verifyexists; hooks are a helpful gate, not a hard guarantee (CI still matters). - Install step per clone. Contributors need to run the install once to activate the hooks.
- Keep them fast. Slow hooks tempt people to skip them - reserve the heavy checks for CI.
For enforcing quality at the commit boundary without slowing anyone down, Lefthook is one of the fastest and most flexible hook managers available.
Internal link suggestion: link "one config file" to the pre-commit post, the Python-ecosystem alternative.