What is pre-commit, and why I run it bef ...

What is pre-commit, and why I run it before every commit

Nov 05, 2026
27

image

pre-commit is a small tool that runs checks on your files before Git accepts a commit: formatters, linters, secret scanners, YAML validation. If a check fails, the commit is refused and you fix it right there, not in a code review two days later.

Why I use it: on my blog's repo it runs ruff, black, bandit, mypy, djlint, semgrep and trivy on every commit. Most of what it catches is boring, a trailing space, an unformatted file, and that is the point. The boring stuff never reaches the pull request, so the review is about the change itself.

How it works, in one minute: a .pre-commit-config.yaml file lists the hooks. "pre-commit install" wires them into .git/hooks. From then on "git commit" runs them. "pre-commit run --all-files" checks the whole repo once, which is what you do when you add it to an old project.

The full post, in Turkish, is on the blog: https://miraccanyilmaz.me/blog/pre-commit-nedir/

Vous aimez cette publication ?

Achetez un server à Mirac Can Yılmaz

Plus de Mirac Can Yılmaz