There are several choices:

  • an adhoc job which runs pre-commit run --all-files as demonstrated in pre-commit.com docs (you probably also want --show-diff-on-failure if you're using formatters)
  • pre-commit.ci a CI system specifically built for this purpose
  • pre-commit/action a github action which is in maintenance-only mode (not recommended for new usecases)

disclaimer: I created pre-commit, and pre-commit.ci, and the github action

Answer from anthony sottile on Stack Overflow
🌐
Pre-commit
pre-commit.ci
pre-commit.ci
Developers spend a fair chunk of time during their development flow on fixing relatively trivial problems in their code. pre-commit.ci both enforces that these issues are discovered (which is opt-in for each developer's workflow via pre-commit) but also fixes the issues automatically, letting developers focus their time on more valuable problems.
🌐
GitHub
github.com › marketplace › pre-commit-ci
pre-commit ci - GitHub Marketplace
Developers spend a fair chunk of time during their development flow on fixing relatively trivial problems in their code. pre-commit.ci both enforces that these issues are discovered (which is opt-in for each developer's workflow via pre-commit) but also fixes the issues automatically, letting developers focus their time on more valuable problems.
🌐
GitHub
github.com › pre-commit-ci
pre-commit.ci · GitHub
pre-commit.ci has 10 repositories available. Follow their code on GitHub.
🌐
Medium
motlin.medium.com › pre-commit-or-ci-cd-5779d3a0e566
Pre-Commit or CI/CD - Craig Motlin - Medium
June 1, 2024 - Why push code that won’t pass the linter? With CI/CD, the developers get feedback only after they’ve pushed their changes. Pre-commit hooks get feedback to the developer as soon as possible.
🌐
Switowski
switowski.com › blog › pre-commit-vs-ci
pre-commit vs. CI - Sebastian Witowski
November 28, 2023 - Conveniently, CI runs checks in the background - you push your code to the repository and move on to work on the next feature. And if something breaks, you get a notification. But if you work on a small- to medium-size project and don't go crazy with the number of checks and linters in your configuration, pre-commit will probably run in a split of a second (except for tests - they usually take much longer, but I will talk about them in a moment).
🌐
Lorenzwalthert
lorenzwalthert.github.io › precommit › articles › ci.html
Continuous Integration • precommit
When initializing pre-commit in your repo with precommit::use_precommit(), you can specify the Continuous integration provider with ci = "native" if you want to use pre-commit.ci or ci = "gha" if you want to use GitHub Actions.
Find elsewhere
🌐
CRAN
cran.r-project.org › web › packages › precommit › vignettes › ci.html
Continuous Integration
When initializing pre-commit in your repo with precommit::use_precommit(), you can specify the Continuous integration provider with ci = "native" if you want to use pre-commit.ci or ci = "gha" if you want to use GitHub Actions.
🌐
Reddit
reddit.com › r/devops › pre-commit vs pre-push vs ci/cd for linting and formatting?
r/devops on Reddit: pre-commit vs pre-push vs CI/CD for linting and formatting?
November 6, 2022 -

So, I generally use commits as a saving mechanism, but after adding a linting and formatting pre-commit hook, I do find myself committing less often. While this does help me catch syntax errors, and I guess I could argue that my commits are cleaner, this does seem to be a bit inconvenient. I think part of it is breaking the mold of what I'm used to, but I also wonder if I would be more productive if I moved it to a pre-push, or even to part of my CI pipeline (running before my tests). Does anyone have any recommendations?

🌐
Nshephard
blog.nshephard.dev › posts › pre-commit-ci
Pre-Commit.ci : Integrating Pre-Commit into CI/CD – blog.nshephard.dev
February 6, 2023 - But what if for some reason you disabled pre-commit just to make some changes rather than addressing the failed linting or test? Or if you work on an open-source project and someone else contributes how can you ensure that their contributed code meets the code-style chosen by the project and that all tests pass in light of the changes that are being introduced? The solution to this is Continuous Integration/Continuous Delivery (CI/CD) which runs various hooks on GitHub/GitLab etc.
🌐
GitHub
github.com › pre-commit › action
GitHub - pre-commit/action: a GitHub action to run `pre-commit` · GitHub
To use this action, make a file .github/workflows/pre-commit.yml. Here's a template to get started: name: pre-commit on: pull_request: push: branches: [main] jobs: pre-commit: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - uses: actions/setup-python@v3 - uses: pre-commit/action@v3.0.1
Starred by 552 users
Forked by 199 users
🌐
Readthedocs
lincc-ppt.readthedocs.io › en › v2.0.7 › practices › ci_precommit.html
Continuous Integration Pre-Commit — LINCC Frameworks Python Project Template 2.0.7 documentation
Continuous integration Pre-Commit is the practice of running a set of hooks that enforce code styling consistency whenever new changes are proposed.
🌐
Python for Data Science
python4data.science › en › latest › productive › git › advanced › hooks › ci.html
pre-commit in CI pipelines - Python for Data Science
March 2, 2025 - name: pre-commit on: pull_request: push: branches: [main] jobs: pre-commit: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 - uses: actions/cache@v4 with: path: ~/.cache/pre-commit key: pre-commit|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }} - uses: pre-commit/action@v3.0.1
🌐
to be continuous
to-be-continuous.gitlab.io › doc › ref › pre-commit
pre-commit - to be continuous - GitLab
include: # 1: include the template - project: 'to-be-continuous/pre-commit' ref: '1.5.0' file: '/templates/gitlab-ci-pre-commit.yml' variables: # 2: set/override template variables # ⚠ this is only an example PRE_COMMIT_SKIP: "check-byte-order-marker,no-commit-to-branch" PRE_COMMIT_ARGS: "-v --show-diff-on-failure"
🌐
GitHub
github.com › pre-commit › pre-commit.com › blob › main › sections › advanced.md
pre-commit.com/sections/advanced.md at main · pre-commit/pre-commit.com
3 weeks ago - jobs: - job: precommit # ... variables: PRE_COMMIT_HOME: $(Pipeline.Workspace)/pre-commit-cache steps: # ... - script: echo "##vso[task.setvariable variable=PY]$(python -VV)" - task: CacheBeta@0 inputs: key: pre-commit | .pre-commit-config.yaml | "$(PY)" path: $(PRE_COMMIT_HOME) like azure pipelines, circleci also uses immutable caches:
Author   pre-commit
🌐
Medium
medium.com › @alexgidiotis_96550 › elevate-your-ci-mastering-pre-commit-hooks-and-github-actions-for-flawless-code-integration-bd0ae7a071c2
Elevate Your CI: Mastering Pre-commit Hooks and GitHub Actions for Flawless Code Integration | by Alex Gidiotis | Medium
November 17, 2023 - Following these steps, pre-commit will now run the specified hooks on every commit. Now that we’ve defined our CI checks, we need to make sure that our CI pipeline will automatically run every time a new commit is pushed to the repository.
🌐
Xnok
xnok.github.io › infra-bootstrap-tools › docs › tools › pre-commit
Pre-commit: Your First Line of Defense for Clean Code · Infra Bootstrap Tools
2 weeks ago - Learn how to use the pre-commit framework to automate code quality checks before they ever leave your machine. This guide covers everything from installation and configuration to creating custom hooks and integrating with your CI/CD pipeline, helping you and your team maintain high standards with minimal effort.
🌐
GitHub
github.com › pre-commit-ci › pre-commit.ci
GitHub - pre-commit-ci/pre-commit.ci: Website for https://pre-commit.ci
Website for https://pre-commit.ci. Contribute to pre-commit-ci/pre-commit.ci development by creating an account on GitHub.
Starred by 50 users
Forked by 12 users
Languages   Python 83.8% | Makefile 16.2% | Python 83.8% | Makefile 16.2%
🌐
Stack Overflow
stackoverflow.com › collectives › articles › 71270196 › how-to-use-pre-commit-to-automatically-correct-commits-and-merge-requests-with-g
How to use pre-commit to automatically correct commits and merge requests with GitLab CI - Stack Overflow
February 25, 2022 - When a pre-commit validation fails, we attempt to apply automatic fixes and commit those fixes automatically. ... Create a project access token and create a CI/CD variable PRE_COMMIT_ACCESS_TOKEN with the token as a value (make sure this token is masked!)