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.
Instalación lista para agent
Este activo puede instalarse después de elegir el runtime, revisar el plan y ejecutar el comando correspondiente.
npx -y tokrepo@latest install f32bbd7e-7676-4647-ac10-d45eb49fa4ec --target codexEjecutar después de confirmar el plan con dry-run.
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
Preguntas frecuentes
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.
Referencias (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
Relacionados en TokRepo
Discusión
Activos relacionados
imgproxy — Fast Secure Image Processing Server in Go
Resize, crop, and convert images on-the-fly with imgproxy. A blazing-fast Go server powered by libvips for production-grade image transformation at scale.
git-filter-repo — Rewrite Git History Fast and Safely
A versatile tool for rewriting git repository history, officially recommended by the Git project as the replacement for git-filter-branch.
Hexo — Fast Node.js Blog Framework with Plugin Ecosystem
Hexo is a fast, simple, and extensible blog framework powered by Node.js. It renders Markdown posts into static HTML in seconds and supports hundreds of themes and plugins.
BFG Repo-Cleaner — Scrub Secrets and Large Files from Git History
A faster, simpler alternative to git-filter-branch for removing large files, passwords, and other unwanted data from git repository history.