Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
L

lefthook

> 开发工具
Open source

Fast and powerful Git hooks manager for any type of projects.

8.6K stars0 likes2 views
WebsiteGitHub

About

Fast and powerful Git hooks manager for any type of projects.

Lefthook

A Git hooks manager for Node.js, Ruby, Python and many other types of projects.

  • Fast. It is written in Go. Can run commands in parallel.
  • Powerful. It allows to control execution and files you pass to your commands.
  • Simple. It is single dependency-free binary which can work in any environment.

Introduction post

Lefthook is built by Evil Martians, an American design and engineering consultancy for developer tools, AI, and cybersecurity startups.

Install

With Go (>= 1.26):

bash
go install github.com/evilmartians/lefthook/[email protected]
  • or as a go tool
bash
go get -tool github.com/evilmartians/lefthook/[email protected]

With NPM:

bash
npm install lefthook --save-dev

For Ruby:

bash
gem install lefthook

For Python:

bash
pipx install lefthook

Installation guide with more ways to install lefthook: apt, brew, winget, and others.

Usage

Configure your hooks, install them once and forget about it: rely on the magic underneath.

TL;DR

bash
# Configure your hooks
vim lefthook.yml

# Install them to the git project
lefthook install

# Enjoy your work with git
git add -A && git commit -m '...'

More details

  • Configuration for lefthook.yml config options.
  • Usage for lefthook CLI options, and features.
  • Discussions for questions, ideas, suggestions.

Why Lefthook

  • Parallel execution

Gives you more speed. docs

yaml
pre-push:
  parallel: true
  • Flexible list of files

If you want your own list. Custom and prebuilt examples.

yaml
pre-commit:
  jobs:
    - name: lint frontend
      run: yarn eslint {staged_files}

    - name: lint backend
      run: bundle exec rubocop --force-exclusion -- {all_files}

    - name: stylelint frontend
      files: git diff --name-only HEAD @{push}
      run: yarn stylelint {files}
  • Glob and regexp filters

If you want to filter list of files. You could find more glob pattern examples here.

yaml
pre-commit:
  jobs:
    - name: lint backend
      glob: "*.rb" # glob filter
      exclude:
        - "*/application.rb"
        - "*/routes.rb"
      run: bundle exec rubocop --force-exclusion -- {all_files}
  • Execute in sub-directory

If you want to execute the commands in a relative path

yaml
pre-commit:
  jobs:
    - name: lint backend
      root: "api/" # Careful to have only trailing slash
      glob: "*.rb" # glob filter
      run: bundle exec rubocop -- {all_files}
  • Run scripts

If oneline commands are not enough, you can execute files. docs

yaml
commit-msg:
  jobs:
    - script: "template_checker"
      runner: bash
  • Tags

If you want to control a group of commands. docs

yaml
pre-push:
  jobs:
    - name: audit packages
      tags:
        - frontend
        - linters
      run: yarn lint

    - name: audit gems
      tags:
        - backend
        - security
      run: bundle audit
  • Support Docker

If you are in the Docker environment. docs

yaml
pre-commit:
  jobs:
    - script: "good_job.js"
      runner: docker run -it --rm <container_id_or_name> {cmd}
  • Local config

If you are a frontend/backend developer and want to skip unnecessary commands or override something in Docker. docs

yaml
# lefthook-local.yml
pre-push:
  exclude_tags:
    - frontend
  jobs:
    - name: audit packages
      skip: true
  • Direct control

If you want to run hooks group directly.

bash
$ lefthook run pre-commit
  • Your own tasks

If you want to run specific group of commands directly.

yaml
fixer:
  jobs:
    - run: bundle exec rubocop --force-exclusion --safe-auto-correct -- {staged_files}
    - run: yarn eslint --fix {staged_files}
bash
$ lefthook run fixer
  • Control output

You can control what lefthook prints with output option.

yaml
output:
  - execution
  - failure

Guides

  • Install with Node.js
  • Install with Ruby
  • Install with Homebrew
  • Install with Winget
  • Install for Debian-based Linux
  • Install for RPM-based Linux
  • Install for Arch Linux
  • Install for Alpine Linux
  • Usage
  • Configuration

Examples

Check examples

Articles

  • 5 cool (and surprising) ways to configure Lefthook for automation joy
  • Lefthook: Knock your team’s code back into shape
  • Lefthook + Crystalball
  • Keeping OSS documentation in check with docsify, Lefthook, and friends
  • Automatically linting docker containers
  • Smooth PostgreSQL upgrades in DockerDev environments with Lefthook
  • Lefthook for React/React Native apps

Issues· 87 open

View all issuesOpen on GitHub
  • #1256

    `pre-commit` hangs on Windows with `parallel: true`

    bugWindowsUpdated Sep 17, 2026
  • #1548

    Generated hook shim exits 0 when the lefthook binary is missing, silently skipping configured hooks (fail-open)

    Updated Sep 17, 2026
  • #1480

    Unstaged changes in unrelated files are discarded by `git checkout .` when restoring hidden changes fails

    bugUpdated Sep 8, 2026
  • #1529

    Concurrent commits in linked worktrees destroy each other's unstaged changes: the backup patch and stash are shared per common git dir

    Updated Sep 4, 2026
  • #1518

    `lefthook` not found when called with `push` hook command

    bugUpdated Aug 31, 2026
  • #1511

    ai: Claude Code Stop/PreToolUse hooks need exit code 2 to block, but `lefthook run` always exits 1

    Updated Aug 29, 2026
  • #719

    Prepackaged PHP Composer

    feature requestUpdated Aug 26, 2026
  • #1493

    `lefthook run post-checkout` blocks until stdin EOF, deadlocking when the caller holds stdin open

    Updated Aug 16, 2026
  • #1398

    `lefthook install` bakes install-time absolute path into hook shim, breaking git worktrees

    Updated Aug 13, 2026
  • #1489

    `lefthook install` should recognize `lefthook-local.yml` without creating `lefthook.yml`

    bugUpdated Aug 12, 2026

> Tags

Gogitgogolanghacktoberfest

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 30, 2026
Category开发工具
PricingOpen source

> Related tools

V
VS Code
流行的开源代码编辑器
G
Git
分布式版本控制系统
V
Vite
下一代前端构建工具