Correct command to install pre-commit globally is,

Copy$ uv tool install pre-commit
$ which pre-commit
/home/username/.local/share/../bin/pre-commit

See official uv docs; The uv tool interface.

Answer from Meesum Qazalbash on Stack Overflow
🌐
Astral
docs.astral.sh › uv › guides › integration › pre-commit
Using uv with pre-commit | uv
1 week ago - A guide to using uv with pre-commit to automatically update lock files, export requirements, and compile requirements files.
🌐
Adam Johnson
adamj.eu › tech › 2025 › 05 › 07 › pre-commit-install-uv
pre-commit: install with uv - Adam Johnson
May 7, 2025 - The install command also adds pre-commit-uv, a plugin that patches pre-commit to use uv to install Python-based tools. This drastically speeds up using Python-based hooks, a common use case.
Discussions

I Built a tool that auto-syncs pre-commit hook versions with `uv.lock`
You sir, are a credit to your family name and a boon to the human race. More on reddit.com
🌐 r/Python
29
108
August 28, 2025
How to install pre-commit globally with uv - Stack Overflow
I have in the past installed pre-commit using: pipx install -g pre-commit I've moved to using uv now, and I see documentation on the web that says to install something globally, you use almost the... More on stackoverflow.com
🌐 stackoverflow.com
How to use pre-commit in uv-based project?
I continuously have problems with it... For example, when I hit commit button in Cursor (VsCode): > git -c user.useConfigOnly=true commit --quiet --allow-empty-message --file - /home/dante/.cache/uv/archive-v0/E42P0RZofT8YmAsd9Qkve/bin/python: No module named pre_commit More on github.com
🌐 github.com
2
June 21, 2025
What are your favourite pre-commit hooks and why?
You may fancy me mad, but this is my standard python pre-commit stack: end-of-file-fixer trailing-whitespace fix-byte-order-marker mixed-line-ending name-tests-test no-commit-to-branch autoflake args: [ "--in-place", "--remove-unused-variables", "--remove-all-unused-imports" ] isort black cspell doc8 args: [ "--max-line-length", "112", "--file-encoding", "utf-8" ] flake8 additional_dependencies: [ flake8-pytest-style, flake8-bugbear, flake8-comprehensions, flake8-print, darglint ] bandit pylint More on reddit.com
🌐 r/Python
83
120
April 24, 2024
🌐
GitHub
github.com › astral-sh › uv-pre-commit
GitHub - astral-sh/uv-pre-commit · GitHub
rev: 0.11.19 hooks: # Update the uv lockfile - id: uv-lock # Change <path/to/project> to your relative path files: <path/to/project>/pyproject.toml args: [--project, <path/to/project>] To synchronize your dependencies upon branch checkout, pull or rebase: default_install_hook_types: - pre-commit - post-checkout - post-merge - post-rewrite repos: - repo: https://github.com/astral-sh/uv-pre-commit # uv version.
Starred by 333 users
Forked by 23 users
Languages   Python
🌐
GitHub
github.com › tox-dev › pre-commit-uv
GitHub - tox-dev/pre-commit-uv · GitHub
Use uv to create virtual environments and install packages for pre-commit. ... Compared to upstream pre-commit will speed up the initial seed operation. In general, upstream recommends caching the pre-commit cache, however, that is not always ...
Starred by 204 users
Forked by 7 users
Languages   Python
🌐
PyPI
pypi.org › project › pre-commit-uv
pre-commit-uv · PyPI
Use uv to create virtual environments and install packages for pre-commit. ... Compared to upstream pre-commit will speed up the initial seed operation. In general, upstream recommends caching the pre-commit cache, however, that is not always ...
      » pip install pre-commit-uv
    
Published   Feb 18, 2026
Version   4.2.1
🌐
Reddit
reddit.com › r/python › i built a tool that auto-syncs pre-commit hook versions with `uv.lock`
r/Python on Reddit: I Built a tool that auto-syncs pre-commit hook versions with `uv.lock`
August 28, 2025 -

TL;DR: Auto-sync your pre-commit hook versions with uv.lock

# Add this to .pre-commit-config.yaml
- repo: https://github.com/tsvikas/sync-with-uv
  rev: v0.3.0
  hooks:
    - id: sync-with-uv

Benefits:

  • Consistent tool versions everywhere (local/pre-commit/CI)

  • Zero maintenance

  • Keeps pre-commit's isolation and caching benefits

  • Works with pre-commit.ci

The Problem

PEP 735 recommends putting dev tools in pyproject.toml under [dependency-groups]. But if you also use these tools as pre-commit hooks, you get version drift:

  • uv update bumps black to 25.1.0 in your lockfile

  • Pre-commit still runs black==24.2.0

  • Result: inconsistent results between local tool and pre-commit.

What My Project Does

This tool reads your uv.lock and automatically updates .pre-commit-config.yaml to match.

Works as a pre-commit (see above) or as a one-time run: uvx sync-with-uv

Target Audience

developers using uv and pre-commit

Comparison 

❌ Using manual updates?

  • Cumbersome

  • Easy to forget

❌ Using local hooks?

- repo: local
  hooks:
    - id: black
      entry: uv run black
  • Breaks pre-commit.ci

  • Loses pre-commit's environment isolation and tool caching

❌ Removing the tools from pyproject.toml?

  • Annoying to repeatedly type pre-commit run black

  • Can't pass different CLI flags (ruff --select E501 --fix)

  • Some IDE integration breaks (when it requires the tool in your environment)

  • Some CI integrations break (like the black action auto-detect of the installed version)

Similar tools:

  • sync_with_poetry - Poetry version

  • sync-pre-commit-lock - PDM/Poetry plugin

Try it out: https://github.com/tsvikas/sync-with-uv

Star if it helps! Issues and PRs welcome. ⭐

🌐
Linux Mint
markpitblado.me › blog › setting-up-a-great-python-experience
Setting up a great python experience
April 7, 2025 - uv tool install pre-commit --with pre-commit-uv --force-reinstall
Find elsewhere
🌐
GitHub
github.com › tox-dev › action-pre-commit-uv
GitHub - tox-dev/action-pre-commit-uv: a GitHub action to run `pre-commit` with `uv` · GitHub
name: pre-commit on: pull_request: push: branches: [main] jobs: pre-commit: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: tox-dev/action-pre-commit-uv@v1 ... The action auto-detects the right invocation: if a pyproject.toml exists it uses uv run, otherwise it uses uvx for isolated tool execution. By default (uv-install: 'auto'), the action detects whether uv is already available and only installs it if needed. You can override this with 'true' (always install) or 'false' (never install):
Starred by 20 users
Forked by 3 users
🌐
PyDevTools
pydevtools.com › blog › sync-with-uv-eliminate-pre-commit-version-drift
Sync with uv: Eliminate Pre-commit Version Drift | pydevtools
September 26, 2025 - sync-with-uv automatically synchronizes tool versions between uv.lock and .pre-commit-config.yaml to prevent version drift.
🌐
Fmind
mlops-coding-course.fmind.dev › 5. Refining › 5.2. Pre-Commit Hooks.html
5.2. Pre-Commit Hooks - MLOps Coding Course
# Interactively create a properly formatted commit message uv run cz commit # Bump the version and update the changelog based on commit history uv run cz bump # Display information about the commitizen configuration uv run cz info · To enforce this standard automatically, integrate commitizen with your pre-commit hooks.
🌐
Python for Data Science
python4data.science › en › latest › productive › git › advanced › hooks › pre-commit.html
pre-commit framework - Python for Data Science
April 24, 2026 - ... $ uv run pre-commit run --all-files Trim Trailing Whitespace.................................................Passed Fix End of Files.........................................................Passed Check Yaml.................................
🌐
Python for Data Science
python4data.science › en › 24.3.0 › productive › git › advanced › hooks › pre-commit.html
pre-commit framework - Python for Data Science 24.3.0
... $ uv run pre-commit run --all-files Trim Trailing Whitespace.................................................Passed Fix End of Files.........................................................Passed Check ...
🌐
Ministry of Intrigue
andrlik.org › dispatches › til-bump-my-version-uv
TIL - Using pre-commit hooks with Bump My Version, pre-commit, and uv · Ministry of Intrigue
October 14, 2024 - This ensures that prior to pre-commit being run, the version update gets added to uv.lock, and it is included in the commit of changes coming from bump-my-version. This seems to resolve my issue with the minimum amount of risk, though if you have a better way to solution for this, I would love ...
🌐
GitHub
github.com › astral-sh › uv › issues › 14183
How to use pre-commit in uv-based project? · Issue #14183 · astral-sh/uv
June 21, 2025 - > git -c user.useConfigOnly=true commit --quiet --allow-empty-message --file - /home/dante/.cache/uv/archive-v0/E42P0RZofT8YmAsd9Qkve/bin/python: No module named pre_commit · How to install the pre-commit so python will have access to it? python -m pre-commit will be enough, I guess. No response · No response · Reactions are currently unavailable · No one assigned · questionAsking for clarification or supportAsking for clarification or support · No type · Give feedback · No fields configured for issues without a type.
Author   astral-sh
🌐
GitHub
github.com › marketplace › actions › pre-commit-uv
pre-commit-uv · Actions · GitHub Marketplace
name: pre-commit on: pull_request: push: branches: [main] jobs: pre-commit: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: tox-dev/action-pre-commit-uv@v1 ... The action auto-detects the right invocation: if a pyproject.toml exists it uses uv run, otherwise it uses uvx for isolated tool execution. By default (uv-install: 'auto'), the action detects whether uv is already available and only installs it if needed. You can override this with 'true' (always install) or 'false' (never install):
🌐
Cetyler
cetyler.github.io › til › 2025 › 2025-5-14_uv_precommit
Install pre-commit with uv – Christopher Tyler
May 15, 2025 - A good reminder that using uv to ... an excerpt from Adam’s article. ... The install command also adds pre-commit-uv, a plugin that patches pre-commit to use uv to install Python-based tools....
🌐
Fossies
fossies.org › linux › uv › docs › guides › integration › pre-commit.md
uv: docs/guides/integration/pre-commit.md | Fossies
To use uv with pre-commit, add one of the following examples to the repos list in the .pre-commit-config.yaml.
🌐
Samedwardes
samedwardes.com › blog › 2025-03-20-pre-commit-for-data-science
pre-commit for Data Science - samedwardes.com
March 20, 2025 - - repo: https://github.com/astral-sh/uv-pre-commit · rev: 0.6.8 · hooks: # Keep your requirements.txt file up to date with your uv.lock file on · # every commit. - id: uv-export · # -------------------------------------------------------------------------- # Jupyter ·
🌐
Openlibrary
docs.openlibrary.org › developers › tools › pre-commit.html
Pre-Commit Guide | Open Library Docs
March 31, 2026 - The --with pre-commit-uv flag adds a plugin that patches pre-commit to use uv for installing Python-based hooks, which is much faster than the default behavior.