Pre-commit hooks are a waste of time


Pre-commit hooks are a waste of time.

Why? Because they enforce standards too early. Pre-commit hooks make us wait for a quality check on every commit.👎

The code shouldn't need to be "right" to save my changes.

The code only needs to be right before merge.

Solution? Use CI.
I should be able to *instantly* commit anything.

This CI server assures I can’t merge broken code. And the CI server avoids wasting my time waiting for premature quality checks on every commit.

The CI server assures the code is worthy before I can merge it. 👍
Tip: If you’re tired of waiting for a pre-commit hook on every commit, do this:

git commit -m “commit message” --no-verify

The no-verify flag disables commit hooks.

And as a long-term solution, assure CI is configured. Then you can safely delete all pre-commit hooks.
Concern: “I like a fast feedback loop for lint issues”.

I don’t need to wait for CI or a pre-commit for this feedback.

My editor and terminal report lint issues in *real-time*.

Can’t beat that. 🔥

(And if they don’t today, fix that!)
Many good responses.

A few points:

Pre-commit hooks aren't a waste of time if they're:
1. Very fast.
2. Necessary.

I often see hooks that take 10-30+ sec to re-verify things I already know because they're reported *real-time* in my editor and terminal, and checked via CI too.
CI time is expensive. So pre-commit hooks save $.

True. But dev time is expensive too.

So:
1. Assure the hook is fast & necessary.
2. Provide *real-time* feedback during dev in the terminal/editor so the hook isn't necessary.
3. Run fast checks first on CI so it fails fast.

View original on X