Back to Home11/14/2025, 7:46:24 PM

Better pre-commit, re-engineered in Rust

44 points
18 comments

Mood

thoughtful

Sentiment

mixed

Category

tech

Key topics

pre-commit hooks

Rust

developer tools

Debate intensity60/100

A new Rust-based pre-commit tool, 'prek', is introduced as a potentially faster alternative to the existing 'pre-commit' framework, sparking discussion about its benefits and drawbacks.

Snapshot generated from the HN discussion

Discussion Activity

Active discussion

First comment

N/A

Peak period

15

Day 5

Avg / period

8

Comment distribution16 data points

Based on 16 loaded comments

Key moments

  1. 01Story posted

    11/14/2025, 7:46:24 PM

    5d ago

    Step 01
  2. 02First comment

    11/14/2025, 7:46:24 PM

    0s after posting

    Step 02
  3. 03Peak activity

    15 comments in Day 5

    Hottest window of the conversation

    Step 03
  4. 04Latest activity

    11/19/2025, 5:11:04 PM

    2h ago

    Step 04

Generating AI Summary...

Analyzing up to 500 comments to identify key contributors and discussion patterns

Discussion (18 comments)
Showing 16 comments of 18
matthewfcarlson
15h ago
2 replies
I didn’t think pre-commit was that slow but I’ll admit I am intrigued. UV has been a godsend so why not?
rsyring
13h ago
1 reply
You can speed up pre-commit a lot by making it use uv but it requires a separate project:

https://github.com/tox-dev/pre-commit-uv/discussions/51

The pre-commit author was straight up hostile to discussions of uv support and ended up deleting the issue I started and banned me from the GH repo. Weirdest OSS experience I've ever had.

cweagans
13h ago
Wow, that guy is something. wtf is his problem.
emschwartz
15h ago
Agreed. For a Rust project, running Clippy and rustfmt is slow, but I’d be surprised to learn that pre-commit itself was a non-negligible part of that.
WhyNotHugo
15h ago
2 replies
Looks like this is just a clone of pre-commit, with the same general design.

> pre-commit is a framework to run hooks written in many languages, and it manages the language toolchain and dependencies for running the hooks

The “and” here are the main annoyances with pre-commit. It does too many things, which would each be best served by a separate tool.

As a developer working on a project, I already have mechanisms to set up a development environment. Having pre-commit install another copy of the dev environment is redundant, and typically necessitates duplicating dependency declarations too.

I’d much rather see a tool that focuses on running commit hooks, while leaving dependency management to another tool. Most projects already have something in place anyway, since dependencies are necessary for development beyond the scope of pre-commit hooks.

The really useful part of pre-commit is that it: (1) only runs hooks based on file that changed and (2) stashes all unstaged changes and untracked files.

juped
14h ago
The latter is possibly just a Git feature that should come into existence (it's annoying to have to make sure your hook is robust against this). But I think "being a package manager" is what they think the main point is.
hambes
13h ago
probably not relevant to you, since it is yet another tool for managing your development environment, but maybe have a look at devenv (https://devenv.sh). it's main purpose is managing the development environment, but it has integration for pre-commit (or even prek iirc) that let's pre-commit do it's thing, but takes over the dependency management.
dboreham
14h ago
3 replies
Imho pre-commit is an antipattern. It tends to break (or rather the janky things it typically runs break) but more importantly whatever needs to be run to gate commits has to be run server-side anyway (people disable precommit, it sometimes produces false negatives, so can't be relied upon). So once you're running the checks server side now you have a second problem which is that the two checks don't always produce the same result. Better to enforce checks in CI, but also provide a way for the dev to run the same check themselves, manually.
ArcHound
14h ago
Well, I have one well-documented exception to this rule: Secret detection. You really don't want to push secrets to your repository, especially if it's hosted as public on GitHub. Those damned attackers can find the secrets in minutes after you've pushed them so you really don't have the time to catch and rotate this (unless you're able to properly attribute and rotate them from the CI... in which case, I'd love to see it).
thebigspacefuck
2h ago
Slow feedback loops are an antipattern. Do you like waiting 5 minutes for your checks to run on a separate computer that reports to a separate interface that you then have to navigate to and inspect the error and pull it back into your dev environment to fix? It’s soo much better running locally in 20 seconds and knowing your shit will pass or exactly where the problem is
rsyring
14h ago
And...that's exactly why you might want to use pre-commit. Set it up to run locally, treating the dev environment check as the first class citizen, then just run pre-commit on all files in CI.

We use that pattern for almost all our projects. Example: https://github.com/level12/coppy

jryio
13h ago
1 reply
Why would lefthook not be a more reliable tool (in design)

https://github.com/evilmartians/lefthook

nikolay
13h ago
I've tried to use it early on, but it hasn't moved much over time. It was opinionated and neglected. Meanwhile, pre-commit is supported by everyone. There are other alternatives, such as Husky, hk, and git-hooks, but they don't offer the out-of-the-box support that pre-commit does.
move-on-by
14h ago
Interesting timing since the pre-commit author recently said it’s more or less been in maintenance mode but is now interested in adding new features.

For me, I would say the most intriguing feature is no Python dependencies.

rtyu1120
15h ago
I wish there's a better comparison to other native solutions like lefthook. I assume the builtin hooks is a core differentiator but I'm not sure if this would be useful outside the Python community.

2 more comments available on Hacker News

ID: 45931273Type: storyLast synced: 11/19/2025, 5:35:53 PM

Want the full context?

Jump to the original sources

Read the primary article or dive into the live Hacker News thread when you're ready.