Trending:
Software Development

Prek, Rust rewrite of pre-commit, runs Git hooks 7x faster

Open-source tool prek delivers the same Git hook functionality as pre-commit but with 26ms runtime versus 176ms, thanks to Rust's parallel execution. Home Assistant and Apache Iceberg projects are making the switch.

What it is

Prek is a Rust-based reimplementation of pre-commit, the Python tool that runs linting and formatting checks before Git commits. The project hit 4.4k GitHub stars by offering the same functionality with significantly better performance: hooks run in 26.3ms compared to pre-commit's 176.7ms.

The tool is a drop-in replacement. It uses the same .pre-commit-config.yaml files, requiring only a one-time prek install --install-hooks command to switch over.

Why it matters

Developers run pre-commit hooks hundreds of times per day. The cumulative time savings add up, particularly in CI pipelines. Prek also cuts disk usage in half by sharing hook environments across projects instead of duplicating them.

Home Assistant announced their switch on January 13, noting faster checks through parallel execution. Apache Iceberg Python opened an issue to evaluate the migration.

The technical advantage

Prek ships as a single binary with no Python dependency. It parallelizes both repository cloning and hook installation, where pre-commit handles these sequentially. The Rust implementation also adds quality-of-life features like prek run --directory for running hooks in specific paths and --last-commit for checking only changed files.

The counterargument

Hacker News discussion raised a familiar critique: pre-commit's architecture duplicates development toolchains. If your project already has linters configured for local development, pre-commit (and now prek) creates a second set of tool definitions just for Git hooks.

Some teams prefer separating hook management from dependency management entirely. For them, speed improvements don't address the fundamental question of whether pre-commit's approach is the right one.

What to watch

Adoption by major open-source projects like Home Assistant provides real-world validation. The test comes when enterprise teams evaluate whether the performance gains justify switching established workflows. Prek is MIT-licensed and actively maintained, with 1,236 commits and recent feature additions including Julia language support.