migrating from pre-commit to prek
β’ 256 words β’ 2 min
Today I learned: prek is a drop-in replacement
for pre-commit, rewritten in Rust. Same .pre-commit-config.yaml, same hook
ecosystem, much faster.
A single binary with zero dependencies, much faster than the original pre-commit, drop-in compatible.
Install:
% brew install prek
# or
% cargo install prekThen swap the command. Nothing else changes:
-pre-commit run --all-files
+prek run --all-files
Or skip the swap entirely: prek install -f drops in a shim that replaces the
pre-commit binary, so existing scripts and git hooks keep working unchanged.
The CI workflow on this blog (prek.yml)
now uses j178/prek-action instead of
pre-commit/action, and the monthly autoupdate job
(prek-autoupdate.yml)
runs prek auto-update --freeze β the --freeze
flag works the same.
The benchmark is what sold me. On cold
caches, prek is around 10x faster at resolving and installing hooks; on warm
runs, the difference is smaller but still noticeable.
Two other niceties pre-commit does not have:
-
Split configs across multiple files.
preksupports multi-file configs, so hooks can live next to the subproject they belong to in a monorepo instead of piling up in a single top-level YAML. -
Run against a commit or a range.
prek run --from-ref A --to-ref Brestricts the run to files changed between two refs β much faster thanprek run -abecause only the touched files are inspected. Example: lint everything on the current branch since it diverged frommaster:shell% prek run --from-ref "$(git merge-base master HEAD)" --to-ref HEAD
The .pre-commit-config.yaml file stays put, and pre-commit.ci still reads
it. No lock-in.
Backlinks
- Worktrunk (May 25, 2026)