prek
Better `pre-commit`, re-engineered in Rust
Description
pre-commit is a framework to run hooks written in many languages, and it manages the language toolchain and dependencies for running the hooks.
prek is a reimagined version of pre-commit, built in Rust. It is designed to be a faster, dependency-free and drop-in alternative for it, while also providing some additional long-requested features.
<!-- --8<-- [end: description] --><!-- --8<-- [start:features] -->[!NOTE] Although prek is pretty new, it’s already powering real‑world projects like CPython, Apache Airflow, FastAPI, and more projects are picking it up—see Who is using prek?. If you’re looking for an alternative to
pre-commit, please give it a try—we’d love your feedback!Please note that some languages are not yet supported for full drop‑in parity with
pre-commit. See Language Support for current status.
Features
- A single binary with no dependencies, does not require Python or any other runtime.
- Faster than
pre-commitand more efficient in disk space usage. - Fully compatible with the original pre-commit configurations and hooks.
- Built-in support for monorepos (i.e. workspace mode).
- Integration with
uvfor managing Python virtual environments and dependencies. - Improved toolchain installations for Python, Node.js, Bun, Go, Rust and Ruby, shared between hooks.
- Built-in Rust-native implementation of some common hooks.
Table of contents
Installation
<details> <summary>Standalone installer</summary>prek provides a standalone installer script to download and install the tool,
On Linux and macOS:
<!-- --8<-- [start: linux-standalone-install] -->curl --proto '=https' --tlsv1.2 -LsSf https://github.com/j178/prek/releases/download/v0.3.4/prek-installer.sh | sh
<!-- --8<-- [end: linux-standalone-install] -->
On Windows:
<!-- --8<-- [start: windows-standalone-install] -->powershell -ExecutionPolicy ByPass -c "irm https://github.com/j178/prek/releases/download/v0.3.4/prek-installer.ps1 | iex"
<!-- --8<-- [end: windows-standalone-install] -->
</details>
<details>
<summary>PyPI</summary>
<!-- --8<-- [start: pypi-install] -->
prek is published as Python binary wheel to PyPI, you can install it using pip, uv (recommended), or pipx:
# Using uv (recommended)
uv tool install prek
# Using uvx (install and run in one command)
uvx prek
# Adding prek to the project dev-dependencies
uv add --dev prek
# Using pip
pip install prek
# Using pipx
pipx install prek
<!-- --8<-- [end: pypi-install] -->
</details>
<details>
<summary>Homebrew</summary>
<!-- --8<-- [start: homebrew-install] -->
brew install prek
<!-- --8<-- [end: homebrew-install] -->
</details>
<details>
<summary>mise</summary>
<!-- --8<-- [start: mise-install] -->
To use prek with mise (v2025.8.11 or later):
mise use prek
<!-- --8<-- [end: mise-install] -->
</details>
<details>
<summary>Cargo binstall</summary>
<!-- --8<-- [start: cargo-binstall] -->
Install pre-compiled binaries from GitHub using cargo-binstall:
cargo binstall prek
<!-- --8<-- [end: cargo-binstall] -->
</details>
<details>
<summary>Cargo</summary>
<!-- --8<-- [start: cargo-install] -->
Build from source using Cargo (Rust 1.89+ is required):
cargo install --locked prek
<!-- --8<-- [end: cargo-install] -->
</details>
<details>
<summary>npmjs</summary>
<!-- --8<-- [start: npmjs-install] -->
prek is published as a Node.js package and can be installed with any npm-compatible package manager:
# As a dev dependency
npm add -D @j178/prek
pnpm add -D @j178/prek
bun add -D @j178/prek
# Or install globally
npm install -g @j178/prek
pnpm add -g @j178/prek
bun install -g @j178/prek
# Or run directly without installing
npx @j178/prek --version
bunx @j178/prek --version
<!-- --8<-- [end: npmjs-install] -->
</details>
<details>
<summary>Nix</summary>
<!-- --8<-- [start: nix-install] -->
prek is available via Nixpkgs.
# Choose what's appropriate for your use case.
# One-off in a shell:
nix-shell -p prek
# NixOS or non-NixOS without flakes:
nix-env -iA nixos.prek
# Non-NixOS with flakes:
nix profile install nixpkgs#prek
<!-- --8<-- [end: nix-install] -->
</details>
<details>
<summary>Conda</summary>
<!-- --8<-- [start: conda-forge-install] -->
prek is available as prek via conda-forge.
conda install conda-forge::prek
<!-- --8<-- [end: conda-forge-install] -->
</details>
<details>
<summary>Scoop (Windows)</summary>
<!-- --8<-- [start: scoop-install] -->
prek is available via Scoop.
scoop install main/prek
<!-- --8<-- [end: scoop-install] -->
</details>
<details>
<summary>Winget (Windows)</summary>
<!-- --8<-- [start: winget-install] -->
prek is available via winget.
winget install --id j178.Prek
<!-- --8<-- [end: winget-install] -->
</details>
<details>
<summary>MacPorts</summary>
<!-- --8<-- [start: macports-install] -->
prek is available via MacPorts.
sudo port install prek
<!-- --8<-- [end: macports-install] -->
</details>
<details>
<summary>GitHub Releases</summary>
<!-- --8<-- [start: pre-built-binaries] -->
Pre-built binaries are available for download from the GitHub releases page.
<!-- --8<-- [end: pre-built-binaries] --> </details> <details> <summary>GitHub Actions</summary> <!-- --8<-- [start: github-actions] -->prek can be used in GitHub Actions via the j178/prek-action repository.
Example workflow:
name: Prek checks
on: [push, pull_request]
jobs:
prek:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: j178/prek-action@v1
This action installs prek and runs prek run --all-files on your repository.
prek is also available via taiki-e/install-action for installing various tools.
If installed via the standalone installer, prek can update itself to the latest version:
prek self update
<!-- --8<-- [end: self-update] -->
Quick start
- I already use pre-commit: follow the short migration checklist in the quickstart guide to swap in
preksafely. - I'm new to pre-commit-style tools: learn the basics—creating a config, running hooks, and installing git hooks—in the beginner quickstart walkthrough.
Why prek?
prek is faster
- It is multiple times faster than
pre-commitand takes up half the disk space. - It redesigned how hook environments and toolchains are managed, they are all shared between hooks, which reduces the disk space usage and speeds up the installation process.
- Repositories are cloned in parallel, and hooks are installed in parallel if their dependencies are disjoint.
- Hooks can run in parallel by priority (hooks with the same
prioritymay run concurrently), reducing end-to-end runtime. - It uses
uvfor creating Python virtualenvs and installing dependencies, which is known for its speed and efficiency. - It implements some common hooks in Rust, built in prek, which are faster than their Python counterparts.
- It supports
repo: builtinfor offline, zero-setup hooks, which is not available inpre-commit.
prek provides a better user experience
- No need to install Python or any other runtime, just download a single binary.
- No hassle with your Python version or virtual environments, prek automatically installs the required Python version and creates a virtual environment for you.
- Built-in support for workspaces (or monorepos), each subproject can have its own
.pre-commit-config.yamlfile. prek runhas some nifty i