# Lefthook: A Fast and Powerful Git Hooks Manager for Any Project

This repository profile is provided by osrepos.com, an open source repository discovery platform.

Source: osrepos.com
Repository profile: https://osrepos.com/repo/evilmartians-lefthook
Generated for open source discovery and AI-assisted research.

Lefthook is a robust Git hooks manager written in Go, designed for speed and flexibility across various project types. It simplifies the process of enforcing code quality and consistency, supporting parallel execution and custom command configurations. This tool ensures your team's code stays in shape with minimal setup and powerful features.

GitHub: https://github.com/evilmartians/lefthook
OSRepos URL: https://osrepos.com/repo/evilmartians-lefthook

## Summary

Lefthook is a robust Git hooks manager written in Go, designed for speed and flexibility across various project types. It simplifies the process of enforcing code quality and consistency, supporting parallel execution and custom command configurations. This tool ensures your team's code stays in shape with minimal setup and powerful features.

## Topics

- git
- go
- golang
- hooks
- manager
- development
- automation
- devops

## Repository Information

Last analyzed by OSRepos: Wed Dec 31 2025 20:00:44 GMT+0000 (Western European Standard Time)
Detail views: 3
GitHub clicks: 4

## Safety Notice

OSRepos shares public repositories for knowledge and discovery only. Review source code, dependencies, licenses, and security implications before running or installing anything.

## Content

## Introduction

Lefthook, developed by Evil Martians, is an incredibly fast and powerful Git hooks manager. Written in Go, it provides a simple, dependency-free binary that works seamlessly in any environment, making it an ideal solution for managing pre-commit, pre-push, and other Git hooks. Whether you're working with Node.js, Ruby, Python, or other project types, Lefthook helps automate code quality checks and maintain consistency across your team.

## Installation

Lefthook offers multiple installation methods to suit your development environment. Here are a few common ways to get started:

**With Go (>= 1.25):**

bash
go install github.com/evilmartians/lefthook/v2@v2.0.13


**With NPM:**

bash
npm install lefthook --save-dev


**For Ruby:**

bash
gem install lefthook


**For Python:**

bash
pipx install lefthook


For a comprehensive list of installation options, including `apt`, `brew`, and `winget`, please refer to the [official installation guide](https://lefthook.dev/installation/).

## Examples

Lefthook's power lies in its flexible configuration and diverse features. Here are some examples demonstrating its capabilities:

### Parallel Execution

Speed up your hook execution by running commands in parallel. This is particularly useful for multiple independent checks.

yml
pre-push:
  parallel: true


### Flexible File Lists

Control which files are passed to your commands, using `staged_files`, `all_files`, or custom Git diff commands.

yml
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

Filter the list of files using glob patterns or regular expressions to apply specific checks only where needed.

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


### Support for Docker

Integrate Lefthook with your Docker environment to run commands inside containers.

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


### Local Configuration Overrides

Use `lefthook-local.yml` to skip unnecessary commands or override configurations for specific development environments.

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


## Why Use Lefthook?

Lefthook stands out as a superior Git hooks manager due to several key advantages:

*   **Speed:** Written in Go, it's incredibly fast and supports parallel execution of commands.
*   **Power:** Offers fine-grained control over command execution, file filtering, and custom scripting.
*   **Simplicity:** A single, dependency-free binary that's easy to install and integrate into any project.
*   **Flexibility:** Supports various languages and environments, including Docker, and allows for local configuration overrides.
*   **Maintainability:** Helps enforce consistent code standards and automated checks across development teams.

## Links

*   [Official Documentation](https://lefthook.dev/)
*   [Configuration Guide](https://lefthook.dev/configuration/index.html)
*   [Usage Commands](https://lefthook.dev/usage/commands.html)
*   [Discussions on GitHub](https://github.com/evilmartians/lefthook/discussions)