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.
Ready-to-run agent install
This asset can be installed after the agent chooses its runtime, checks the plan, and runs the matching command.
npx -y tokrepo@latest install f32bbd7e-7676-4647-ac10-d45eb49fa4ec --target codexRun after dry-run confirms the install plan.
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
GitUI — Blazing-Fast Terminal UI for Git Written in Rust
GitUI brings a Rust-fast terminal interface to Git: browse commits, stage hunks, view diffs, manage branches, and resolve conflicts — all without leaving the keyboard. A great complement (or alternative) to lazygit.
Yazi — Blazing Fast Terminal File Manager in Rust
Yazi is a blazing fast terminal file manager written in Rust, based on async I/O. Preview images and videos in terminal, fuzzy search, batch operations, plugin system, and seamless integration with tools like fzf, zoxide, and rg.
Lazygit — Simple Terminal UI for Git Commands
Lazygit is a simple terminal UI for git commands. Stage files, commit, push, rebase, cherry-pick, squash, and browse history without memorizing 30 git commands. Written in Go and designed for speed with vim-style keybindings.
fzf — Blazing Fast Command-Line Fuzzy Finder
fzf is a general-purpose command-line fuzzy finder written in Go. Blazing fast, portable, and composable with any list-producing command. Interactive picker for files, commands, history, git branches, processes, and more.