pre-commit: a framework for managing multi-language Git hooks
The pre-commit repository: the tool that installs, isolates and runs Git hooks declared in a YAML file, with hooks written in Python, Node, Go, Rust, Ruby, Docker and more, pinned to exact versions.
Drafted with AI from official documentation. Scripts were run in a test environment and repository links verified. Awaiting a human check. Did it work for you? Last edited Outdated?
pre-commit/pre-commit
- Stars
- 15.6k
- Forks
- 1k
- Language
- Python
- Licence
- MIT
- Last push
- 13 Oct 2026
On GitHub: A framework for managing and maintaining multi-language pre-commit hooks.
Open on GitHubpre-commit (about 15,600 stars on GitHub) was created by Anthony Sottile and is released under the MIT license. It solves the boring part of Git hooks: distributing them to every clone, installing each hook’s language runtime and dependencies in an isolated environment, running only on the staged files, and pinning everything to versions so a hook upgrade is a reviewed commit rather than a surprise. Hooks are published by their own projects (ruff, black, eslint, shellcheck, terraform fmt, hadolint and hundreds more) and the pre-commit/pre-commit-hooks repository ships the general-purpose ones.
Use it in any repository where more than one person commits. The payoff is a cleaner history (no whitespace churn, no broken YAML) and faster CI, because the cheap checks already passed on the laptop. It also runs as a plain command in CI, so the same configuration is the single source of truth for both.
Install it with pipx install pre-commit or brew install pre-commit, add a .pre-commit-config.yaml and run:
pre-commit sample-config > .pre-commit-config.yaml
pre-commit install
pre-commit run --all-files
pre-commit autoupdate
sample-config writes a minimal starting configuration with the standard hooks. Besides the pre-commit stage the tool can manage commit-msg, pre-push and other Git hook types with pre-commit install --hook-type pre-push. The repository hosts the documentation source for pre-commit.com and the issue tracker; hook-specific problems belong to the hook’s own repository. Credit to Anthony Sottile and the pre-commit contributors.
Did this work for you?
No votes yet. Be the first.
If it did not work, the report form below tells the editors what went wrong.
See also
- 0044 A starter set of Git aliases Short names for the Git commands you type all day, such as a one-line status, a graph log, and a safe force… Beginner · Cheat sheet · Linux, macOS, Windows Script Git tools 15 Oct 2026
- 0313 What is CI/CD? CI/CD is the habit of automatically testing every code change and, once it passes, deploying it without manual steps. Beginner · Explains an idea · Any system Article Pipelines, runners & hooks 15 Oct 2026
- 0378 Continuous integration explained What continuous integration means, why small frequent merges plus an automated build on every change prevent integration pain, what a good pipeline… Beginner · Explains an idea · Any system Article Pipelines, runners & hooks 15 Oct 2026
- 0379 Your first GitHub Actions workflow: run tests on every push Build a working GitHub Actions pipeline from nothing: a small Python project with a test, a workflow file that runs pytest on… Beginner · Guided project · Any system Article GitHub Actions · Pipelines, runners & hooks 15 Oct 2026
- 0381 pre-commit hooks: catch mistakes before they are committed Install the pre-commit framework, configure hooks for whitespace, YAML and JSON syntax, large files, leaked private keys, Python linting and shellcheck, run… Beginner · Step by step · Linux, macOS, Windows Article Pipelines, runners & hooks · Setup 15 Oct 2026
- 0454 Scan your own code and containers in CI: Gitleaks, Semgrep and Trivy Set up a GitHub Actions workflow that runs Gitleaks, Semgrep and Trivy on every push of your own project, learn what each… Intermediate · Step by step · Any system Article Pipelines, runners & hooks · Security testing & CTF 15 Oct 2026
History
Every saved edit is kept. The plot on the sleeve draws one line per edit. Open any edit to see exactly what changed.
- Dominik +1,574 chars