prek

prek is a variant of pre-commit, written in Rust, for managing and maintaining multilingual commit hooks.

An essential task is to make the same scripts available to the entire development team. pre-commit by yelp manages such hooks and distributes them to different projects and developers.

Git hooks are mostly used to automatically point out problems in the code before code reviews, for example to check the formatting or to find debug statements. pre-commit simplifies the sharing of hooks across projects. The language in which a linter was written, for example, is abstracted away – scss-lint is written in Ruby, but you can use it with pre-commit without having to add a Gemfile to your project.

Installation

Before you can execute the hooks, prek must be installed:

> powershell -ExecutionPolicy ByPass -c "irm https://github.com/j178/prek/releases/download/v0.4.9/prek-installer.ps1 | iex"
$ curl --proto '=https' --tlsv1.2 -LsSf https://github.com/j178/prek/releases/download/v0.4.9/prek-installer.sh | sh
$ brew install prek
$ uv add --group dev prek

Check the installation for example with

$ uv run prek -V
prek 0.4.9 (42b79a57f 2026-07-11)

Configuration

After Pre-Commit is installed, the .pre-commit-config.yaml file in the root directory of your project can be used to configure plugins for this project.

repos:
  - repo: https://github.com/pre-commit/pre-commit-hooks
    rev: 3e8a8703264a2f4a69428a0aa4dcb512790b2c8c # v6.0.0
    hooks:
    - id: trailing-whitespace
    - id: end-of-file-fixer
    - id: check-yaml
    - id: check-added-large-files

You can also generate such an initial .pre-commit-config.yaml file with

$ uv run prek sample-config > .pre-commit-config.yaml

If you want to apply check-json to your Jupyter notebooks, you must first configure that the check should also be used for the file suffix .ipynb:

 repos:
   - repo: https://github.com/pre-commit/pre-commit-hooks
     rev: 3e8a8703264a2f4a69428a0aa4dcb512790b2c8c # v6.0.0
     hooks:
     
     - id: check-json
       types: [file]
       files: \.(json|ipynb)$

See also

For a full list of configuration options, see Adding pre-commit plugins to your project.

You can also write your own hooks, see Creating new hooks.

Installing the git hook scripts

To ensure that pre-commit is also reliably executed before each commit, the script is installed in our project:

$ prek install
prek installed at .git/hooks/pre-commit

If you want to uninstall the git hook scripts, you can do so with prek uninstall.

Run

uv run prek run --all-files

runs all pre-commit checks independently of git commit:

$ uv run prek run --all-files
Trim Trailing Whitespace.................................................Passed
Fix End of Files.........................................................Passed
Check Yaml...............................................................Passed
Check for added large files..............................................Passed
prek run HOOK

executes single prek checks, for example prek run trailing-whitespace

Note

When a prek check is called for the first time, it is first downloaded and then installed. This may take some time, for example if a copy of node has to be created.

prek update [OPTIONS]

updates the hooks automatically:

$ uv run prek update --freeze --cooldown-days 7
https://github.com/pre-commit/pre-commit-hooks
  updating rev `v6.0.0` -> `3e8a8703264a2f4a69428a0aa4dcb512790b2c8c` (frozen: v6.0.0)

However, the hooks managed by prek are not limited to being executed before commits; they can also be used for other Git hooks, see Supported git hooks.