Skip to content

Running prek for Fast Git Hooks

prek is a Rust-based Git hook manager designed as a fast drop-in replacement for pre-commit.

The important part is that existing .pre-commit-config.yaml files continue to work, so migration is mostly a command swap:

  • pre-commit run becomes prek run
  • pre-commit install becomes prek install
  • pre-commit autoupdate becomes prek auto-update

Install with uv:

Terminal window
uv tool install prek
prek --version

Other common install options:

Terminal window
brew install prek
pipx install prek
npm add -D @j178/prek

If the repo already has .pre-commit-config.yaml, you usually do not need to rewrite anything.

Run the hooks:

Terminal window
prek run

If you previously installed Git hooks with pre-commit, reinstall the hook shim once with force:

Terminal window
prek install -f

Run against the whole repository:

Terminal window
prek run --all-files

You can use native prek.toml or keep the ecosystem-standard YAML format.

Example prek.toml:

[[repos]]
repo = "https://github.com/pre-commit/pre-commit-hooks"
rev = "v6.0.0"
hooks = [
{ id = "check-yaml" },
{ id = "end-of-file-fixer" },
]

Equivalent .pre-commit-config.yaml:

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v6.0.0
hooks:
- id: check-yaml
- id: end-of-file-fixer

If you already use pre-commit, keeping .pre-commit-config.yaml makes migration simplest.

prek does not require a special .gitignore, but this is a practical baseline for a Python repo using Git hooks:

# Python
__pycache__/
*.py[cod]
.pytest_cache/
.mypy_cache/
.ruff_cache/
# Virtual environments
.venv/
venv/
# Build artifacts
build/
dist/
*.egg-info/
# Editor and OS files
.DS_Store
.idea/
.vscode/

If your hooks generate files locally, ignore those outputs too. The main rule is that prek run --all-files should not waste time scanning generated junk you never intend to commit.

Install the Git hook shim into .git/hooks:

Terminal window
prek install

Install hooks and prepare environments immediately:

Terminal window
prek install --install-hooks

After this, Git will run prek automatically during commit for the configured stages.

Run the default staged-file workflow:

Terminal window
prek run

Run everything:

Terminal window
prek run --all-files

Run one hook:

Terminal window
prek run end-of-file-fixer --all-files

Update pinned hook revisions:

Terminal window
prek auto-update

If you install prek with uv, a simple workflow looks like this:

name: prek
on:
push:
branches: [master]
pull_request:
branches: [master]
workflow_dispatch:
jobs:
prek:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v7
- name: Install prek
run: uv tool install prek
- name: Run prek
run: prek run --all-files --show-diff-on-failure

If you keep prek as a project dependency instead, run it through uv run:

- name: Install dependencies
run: uv sync
- name: Run prek
run: uv run prek run --all-files --show-diff-on-failure

List configured hooks:

Terminal window
prek list

See built-in Rust-native hooks:

Terminal window
prek util list-builtins

A practical migration flow from pre-commit is:

Terminal window
uv tool install prek
prek install -f
prek run --all-files
prek auto-update

This keeps the same hook config while replacing the Python-based runner with a single Rust binary. That is the easiest way to start using prek without changing the rest of your workflow.