pre-commit
pre-commit.com
pre-commit
The first time pre-commit runs on a file it will automatically download, install, and run the hook. Note that running a hook for the first time may be slow. For example: If the machine does not have node installed, pre-commit will download and build a copy of node.
GitHub
github.com › pre-commit › pre-commit-hooks
GitHub - pre-commit/pre-commit-hooks: Some out-of-the-box hooks for pre-commit · GitHub
- repo: https://github.com/pre-commit/pre-commit-hooks rev: v6.0.0 # Use the ref you want to point at hooks: - id: trailing-whitespace # - id: ...
Starred by 6.5K users
Forked by 789 users
Languages Python
Videos
10:38
Boost Your Git Workflow with Pre-Commit Hooks | Wahl Network - YouTube
12:23
Pre-Commit: Enforce coding best-practices - YouTube
29:33
Complete guide to GitHooks - Creating your own pre-commit hooks ...
04:52
How to Run a Python Script Upon Commit Using a Pre-Commit Hook ...
00:53
Git pre-commit hook in 45 seconds! #Shorts - YouTube
05:59
The easy way to keep your repos tidy. - YouTube
Git
git-scm.com › book › en › v2 › Customizing-Git-Git-Hooks
Git - Git Hooks
Exiting non-zero from this hook aborts the commit, although you can bypass it with git commit --no-verify. You can do things like check for code style (run lint or something equivalent), check for trailing whitespace (the default hook does exactly this), or check for appropriate documentation on new methods. The prepare-commit-msg hook is run before the commit message editor is fired up but after the default message is created.
Atlassian
atlassian.com › git › tutorials › git-hooks
Git Hooks | Atlassian Git Tutorial
December 16, 2025 - Or, if you’re writing a new script from scratch, you can simply add a new file matching one of the above filenames, minus the .sample extension. As an example, try installing a simple prepare-commit-msg hook.
GitHooks
githooks.com
Git Hooks - A Guide for Programmers
These hook scripts are only limited by a developer's imagination. Some example hook scripts include: pre-commit: Check the commit message for spelling errors.
Medium
medium.com › data-science › custom-pre-commit-hooks-for-safer-code-changes-d8b8aa1b2ebb
Custom pre-commit hooks for safer code changes | by Thierry Jean | TDS Archive | Medium
March 14, 2024 - The preferred way of working with pre-commit hooks is through the pre-commit Python library. We can set it up with the following steps: Create a git repository for your project with git init · Install the pre-commit library with pip install pre-commit · Add a .pre-commit-config.yaml to your repository. Here’s an example:
Stefanie Molin
stefaniemolin.com › articles › devx › pre-commit › setup-guide
How to Set Up Pre-Commit Hooks | Stefanie Molin
December 7, 2025 - There are other docstring formats, but since I wrote this hook, I’ll feature it here 😊 For this section, we use the exclude key to instruct pre-commit not to run this hook on any files in the tests/ or docs/ directories: - repo: https://github.com/numpy/numpydoc rev: v1.6.0 hooks: - id: numpydoc-validation exclude: (tests|docs)/.* Example setup for the numpydoc-validation pre-commit hook.
Apache
hamilton.apache.org › how-tos › pre-commit-hooks
pre-commit hooks - Hamilton - Apache Software Foundation
A pre-commit hook is a script or command that’s executed automatically before making a commit. The goal of these hooks is to standardize code formatting and catch erroneous code before being committed. For example, popular hooks include ensuring files have no syntax errors, sorting imports, ...
Stefanie Molin
stefaniemolin.com › articles › devx › pre-commit › hook-creation-guide
Pre-Commit Hook Creation Guide | Stefanie Molin
September 1, 2025 - Be sure to add something like this to your README so people can easily include your hook in their .pre-commit-config.yaml files: - repo: https://github.com/stefmolin/filename-validation rev: 0.1.2 hooks: - id: validate-filename · The README is also a good spot to document any configuration options your hook supports (like the --min-len option). Often, this is done by providing an additional usage example:
Reddit
reddit.com › r/experienceddevs › what are your pre-commit hooks?
r/ExperiencedDevs on Reddit: What are your pre-commit hooks?
June 8, 2023 -
Hi folks!
I'm curious to know what pre-commit hooks you're using.
I start with linters and formatters.
Top answer 1 of 46
208
I've found precommit hooks to be pretty clunky. A precommit hook failing comes at an awkward time and interrupts my train of thought for making a commit. I've also found that managing the tools and config for them is pretty annoying, either manually or with pre-commit . Instead, I have my editor run formatters/linters/etc and add checks for them in CI. Format-on-save is just the way to go.
2 of 46
183
No pre commit hooks at all. Linting and formatting checks are in the CI, and all projects have a VSCode devcontainer with enabled auto formatting but we don’t have pre commit hooks.
Git
git-scm.com › docs › githooks
Git - githooks Documentation
This hook is invoked by git-merge[1], and can be bypassed with the --no-verify option. It takes no parameters, and is invoked after the merge has been carried out successfully and before obtaining the proposed commit log message to make a commit. Exiting with a non-zero status from this script causes the git merge command to abort before creating a commit. The default pre-merge-commit hook, when enabled, runs the pre-commit hook, if the latter is enabled.
Prettier
prettier.io › docs › precommit
Pre-commit Hook · Prettier
This will install husky and lint-staged, then add a configuration to the project’s package.json that will automatically format supported files in a pre-commit hook.
GitHub
github.com › pre-commit › pre-commit
GitHub - pre-commit/pre-commit: A framework for managing and maintaining multi-language pre-commit hooks. · GitHub
Starred by 15.2K users
Forked by 961 users
Languages Python 97.4% | R 2.0% | Shell 0.5% | Dockerfile 0.1% | Lua 0.0% | Ruby 0.0%
GitHub
github.com › astral-sh › ruff-pre-commit
GitHub - astral-sh/ruff-pre-commit: A pre-commit hook for Ruff. · GitHub
repos: - repo: https://github.com/astral-sh/ruff-pre-commit # Ruff version. rev: v0.15.12 hooks: # Run the linter. - id: ruff-check types_or: [ python, pyi, jupyter, pyproject ] args: [ --fix ] # Run the formatter.
Starred by 1.9K users
Forked by 96 users
Languages Python
Medium
gatlenculp.medium.com › effortless-code-quality-the-ultimate-pre-commit-hooks-guide-for-2025-57ca501d9835
Effortless Code Quality: The Ultimate Pre-Commit Hooks Guide for 2025
February 9, 2025 - While extensive tests may be too time consuming for a pre-commit hook, it can be helpful to run fast local tests to detect unexpected failures in your code before you are 10 commits in and unsure which one broke your code. The example below uses pytest. The first hook checks that the tests don’t contain any syntax errors and can be successfully collected.