# 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. ## Install Save as a script file and run: ## Quick Use ```bash # Install npm install lefthook --save-dev # Or: brew install lefthook # Initialize npx lefthook install ``` ```yaml # lefthook.yml pre-commit: parallel: true commands: lint: glob: "*.{ts,tsx}" run: npx biome check --write {staged_files} typecheck: glob: "*.{ts,tsx}" run: npx tsc --noEmit test: glob: "*.test.{ts,tsx}" run: npx vitest run --reporter=dot {staged_files} pre-push: commands: audit: run: npm audit --production ``` Now `git commit` auto-runs lint + typecheck + test in parallel. --- ## Intro Lefthook is a blazing-fast Git hooks manager written in Go with 5,000+ GitHub stars. It runs linters, formatters, and tests on git commit and push in parallel — replacing Husky + lint-staged with a single, zero-dependency binary that starts in milliseconds. Configure once in `lefthook.yml` and every team member gets consistent code quality checks. Best for teams who want fast, reliable pre-commit hooks without Node.js runtime overhead. Works with: any git repository, any language. Setup time: under 2 minutes. --- ## Why Lefthook Over Husky | Feature | Husky + lint-staged | Lefthook | |---------|-------------------|----------| | Speed | ~500ms startup | ~5ms startup | | Dependencies | Node.js required | Single Go binary | | Parallel execution | No | Yes (built-in) | | Config | .husky/ + lint-staged | Single lefthook.yml | | Glob filtering | lint-staged | Built-in globs | ### Parallel Execution ```yaml pre-commit: parallel: true # All commands run simultaneously commands: lint: { run: "biome check {staged_files}" } format: { run: "prettier --check {staged_files}" } test: { run: "vitest run --changed" } ``` 3 commands run in parallel instead of sequentially. ### Smart File Filtering ```yaml commands: lint-ts: glob: "*.{ts,tsx}" # Only TypeScript files run: biome check {staged_files} lint-py: glob: "*.py" # Only Python files run: ruff check {staged_files} lint-go: glob: "*.go" # Only Go files run: golangci-lint run {staged_files} ``` ### Staged Files Only `{staged_files}` passes only the files you changed — no wasted work: ```yaml commands: format: glob: "*.{ts,tsx,js,jsx}" run: biome check --write {staged_files} stage_fixed: true # Re-stage auto-fixed files ``` ### Skip Hooks When Needed ```bash git commit --no-verify -m "wip: quick save" ``` ### CI-Friendly Lefthook works in CI too: ```yaml # .github/workflows/hooks.yml - run: npx lefthook run pre-commit ``` ### Key Stats - 5,000+ GitHub stars - Written in Go (5ms startup) - Parallel command execution - Glob-based file filtering - Zero Node.js dependency ### FAQ **Q: What is Lefthook?** A: A fast Git hooks manager that runs linters, formatters, and tests on commit/push in parallel, replacing Husky + lint-staged with a single binary. **Q: Is Lefthook free?** A: Yes, open-source under MIT license. **Q: Can I use Lefthook without Node.js?** A: Yes, install via Homebrew, Go, or download the binary directly. --- ## Source & Thanks > Created by [Evil Martians](https://github.com/evilmartians). Licensed under MIT. > > [lefthook](https://github.com/evilmartians/lefthook) — stars 5,000+ Thanks for making git hooks fast and painless. --- ## 快速使用 ```bash npm install lefthook --save-dev npx lefthook install ``` ```yaml # lefthook.yml pre-commit: parallel: true commands: lint: glob: "*.{ts,tsx}" run: npx biome check {staged_files} ``` --- ## 简介 Lefthook 是 Go 编写的极速 Git Hooks 管理器,GitHub 5,000+ stars。并行运行 linter、格式化和测试,启动仅 5ms。替代 Husky + lint-staged。适合需要快速可靠 pre-commit 检查的团队。 --- ## 来源与感谢 > Created by [Evil Martians](https://github.com/evilmartians). Licensed under MIT. > > [lefthook](https://github.com/evilmartians/lefthook) — stars 5,000+ --- Source: https://tokrepo.com/en/workflows/f32bbd7e-7676-4647-ac10-d45eb49fa4ec Author: Script Depot