🌐
Astral
docs.astral.sh › uv › guides › integration › pre-commit
Using uv with pre-commit | uv
2 days ago - rev: 0.11.21 hooks: - id: uv-lock · To keep a requirements.txt file in sync with your uv.lock file: ... repos: - repo: https://github.com/astral-sh/uv-pre-commit # uv version.
🌐
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
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
Integrate with pre-commit (or replace it)
Summary We currently use Poetry (though this applies to uv as well) for managing our dependencies along with pre-commit for hooking into Git to perform various code lints. This generally works fine, but for mypy it becomes a huge pain si... More on github.com
🌐 github.com
8
February 19, 2025
Add uv-run hook
We have a small python script with a handful of external dependencies which we want to run as a local pre-commit hook. To ensure that the dependencies are installed, it would be great to use PEP-723 inline script metadata and use uv run ... More on github.com
🌐 github.com
6
January 10, 2025
When to use pre-commit hook vs GitHub actions?
You should be using them both. Run pre-commit locally to run checks before committing to your local GitHub repository. Then run GitHub actions when you push and/or create a pull request to the remote repository on GitHub. I use tox to build Python projects with GitHub actions so that the entire build process can be checked across platforms. pre-commit doesn’t do that for me but it still does a lot to my code beforehand so this is why I use both. If the project builds successfully with GitHub actions using tox and all tests pass then I allow the pull request to be approved for merging. If anything fails it’s time to refactor the code and resubmit. More on reddit.com
🌐 r/Python
21
63
October 26, 2023
🌐
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
- uses: astral-sh/setup-uv@v7 with: version: 0.6.0 - uses: tox-dev/action-pre-commit-uv@v1 with: uv-install: 'false' By default, this action runs all the hooks against all the files.
Starred by 21 users
Forked by 3 users
🌐
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. ⭐

🌐
Adam Johnson
adamj.eu › tech › 2025 › 05 › 07 › pre-commit-install-uv
pre-commit: install with uv - Adam Johnson
May 7, 2025 - (Unfortunately, it seems pre-commit itself won’t be adding uv support.) With pre-commit installed globally, you can now install its Git hook in relevant repositories per usual: $ cd myrepo $ pre-commit install pre-commit installed at .git/hooks/pre-commit · $ pre-commit run --all-files [INFO] Installing environment for https://github.com/pre-commit/pre-commit-hooks.
🌐
GitHub
github.com › tox-dev › pre-commit-uv
GitHub - tox-dev/pre-commit-uv · GitHub
In general, upstream recommends ... of what you could expect demonstrated on this project's own pre-commit setup (with a hot uv cache): ❯ hyperfine 'pre-commit install-hooks' 'pre-commit-uv install-hooks' Benchmark 1: pre-commit install-hooks Time (mean ± σ): 54.132 ...
Starred by 204 users
Forked by 7 users
Languages   Python
🌐
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. Add the following to your .pre-commit-config.yaml: - repo: https://github.com/commitizen-tools/commitizen rev: 'v3.27.0' # Use a recent version hooks: # Checks if the commit message follows the conventional format.
🌐
Python-boilerplate
python-boilerplate.github.io › uv-template › features › pre-commit
Pre-commit Hooks - python boilerplate
Prevents committing code that doesn't meet project standards · ! Setup (runs automatically on make init)Run all hooks manually · make init # or manually: uv run pre-commit install --install-hooks · uv run pre-commit run --all-files · Edit the .pre-commit-config.yaml file and add the required ...
Find elsewhere
🌐
GitHub
github.com › marketplace › actions › pre-commit-uv
pre-commit-uv · Actions · GitHub Marketplace
- uses: astral-sh/setup-uv@v7 with: version: 0.6.0 - uses: tox-dev/action-pre-commit-uv@v1 with: uv-install: 'false' By default, this action runs all the hooks against all the files.
🌐
GitHub
github.com › astral-sh › uv › issues › 11641
Integrate with pre-commit (or replace it) · Issue #11641 · astral-sh/uv
February 19, 2025 - Git runs the pre-commit hook, which invokes uv pre-commit run pre-commit ...
Author   astral-sh
🌐
GitHub
github.com › astral-sh › uv › blob › main › docs › guides › integration › pre-commit.md
uv/docs/guides/integration/pre-commit.md at main · astral-sh/uv
repos: - repo: https://github.com/astral-sh/uv-pre-commit # uv version. rev: 0.11.2 hooks: - id: uv-lock
Author   astral-sh
🌐
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 sample-config > .pre-commit-config.yaml · If you want to apply check-json to your Jupyter notebooks, you must first configure that the check should also be used for the file suffix .ipynb: repos: - repo: https://github.com/pre-commit/pre-commit-hooks rev: v6.0.0 hooks: …
🌐
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 - # ... allow_dirty = false commit = true message = "Bump version: {current_version} → {new_version}" pre_commit_hooks = ["uv sync", "git add uv.lock"] # The new bit. commit_args = "" This ensures that prior to pre-commit being run, the version update gets added to uv.lock, and it is included ...
🌐
Melmass
melmass.github.io › uv › guides › pre-commit.html
Using in pre-commit - uv
- repo: https://github.com/astral-sh/uv-pre-commit # uv version. rev: 0.2.13 hooks: # Compile requirements - id: pip-compile args: [requirements-dev.in, -o, requirements-dev.txt] files: ^requirements-dev\.(in|txt)$
🌐
GitHub
github.com › astral-sh › ty-pre-commit
GitHub - astral-sh/ty-pre-commit: A pre-commit hook for ty. · GitHub
Under the hood, the hook runs uv's preview uv check command. Each hook revision pins both the corresponding ty version and the latest uv version that was available when that ty version was released. New ty releases trigger ty-pre-commit releases; new uv releases do not trigger releases on their own.
Author   astral-sh
🌐
GitHub
github.com › astral-sh › uv-pre-commit › blob › main › .pre-commit-hooks.yaml
uv-pre-commit/.pre-commit-hooks.yaml at main · astral-sh/uv-pre-commit
files: ^(uv\.lock|pyproject\.toml|uv\.toml)$ args: [] pass_filenames: false · additional_dependencies: [] minimum_pre_commit_version: "2.9.2" - id: uv-export · name: uv-export · description: "Automatically run 'uv export' on your project dependencies" entry: uv export ·
Author   astral-sh
🌐
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
repos: - repo: https://github.com/pre-commit/pre-commit-hooks rev: v3.2.0 hooks: - id: trailing-whitespace - id: end-of-file-fixer - id: check-yaml - id: check-added-large-files · You can also generate such an initial .pre-commit-config.yaml file with · $ uv run pre-commit sample-config > ...
🌐
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 · The configuration for pre-commit is quite simple, and an example configuration with just ggshield is below. This is placed in .pre-commit-config.yml in the root of the repo which the configuration will apply to. You will need to run pre-commit install after the configuration file is in place. repos: - repo: https://github.com/gitguardian/ggshield rev: v1.38.0 # This version will change over time hooks: - id: ggshield language_version: python3 stages: [pre-commit]
🌐
GitHub
github.com › astral-sh › uv-pre-commit › issues › 37
Add uv-run hook · Issue #37 · astral-sh/uv-pre-commit
January 10, 2025 - We have a small python script with a handful of external dependencies which we want to run as a local pre-commit hook. To ensure that the dependencies are installed, it would be great to use PEP-723 inline script metadata and use uv run ...
Author   astral-sh
🌐
GitHub
github.com › dribia › sync-with-uv
GitHub - dribia/sync-with-uv: Pre-commit hook to sync pre-commit config versions with uv.lock · GitHub
A pre-commit hook for keeping in sync the repos rev in .pre-commit-config.yaml with the packages version locked into uv.lock.
Author   dribia