🌐
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
Discussions

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
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
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
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
🌐
Astral
docs.astral.sh › uv › guides › integration › pre-commit
Using uv with pre-commit | uv
1 week ago - To use uv with pre-commit, add one of the following examples to the repos list in the .pre-commit-config.yaml. To make sure your uv.lock file is up to date even if your pyproject.toml file was changed: ... repos: - repo: https://github.com/astral-sh/uv-pre-commit # uv version.
🌐
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
🌐
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 › astral-sh › uv › issues › 11641
Integrate with pre-commit (or replace it) · Issue #11641 · astral-sh/uv
February 19, 2025 - Additionally, the pre-commit devs refuse to add any kind of improvement in this area, wanting to keep configuration isolated to just their config file (not an unreasonable stance). In order to fix this, we would either need some kind of uv pre-commit task that wraps other pre-commit plugins and that does environment setup itself, or we would need a way to run uv in "pre-commit emulation" mode where it can operate on .pre-commit-config.yaml files, but where an additional option like install-uv-deps: true or install-requirements: [file_path] is available on hooks that trigger a uv sync or uv pip install -r ...
Author   astral-sh
🌐
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):
Find elsewhere
🌐
GitHub
github.com › akx › pre-commit-uv-action
GitHub - akx/pre-commit-uv-action: A GitHub action to run pre-commit using uv via setup-uv and pre-commit-uv
A GitHub action to run pre-commit using uv via setup-uv and pre-commit-uv - akx/pre-commit-uv-action
Author   akx
🌐
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. ⭐

🌐
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 ... environment. Below is 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....
🌐
GitHub
gist.github.com › difegam › 761f9e82c32f48feac399069047bb7fb
pre-commit-and pre-commit-uv.md · GitHub
pre-commit-uv patches pre-commit so that it uses uv to create environments and install hook dependencies, which speeds up the initial environment “seed” and subsequent installs.
🌐
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 - You can also generate such an initial .pre-commit-config.yaml file with · $ 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 ...
🌐
GitHub
github.com › tox-dev › action-pre-commit-uv › blob › main › action.yml
action-pre-commit-uv/action.yml at main · tox-dev/action-pre-commit-uv
a GitHub action to run `pre-commit` with `uv`. Contribute to tox-dev/action-pre-commit-uv development by creating an account on GitHub.
Author   tox-dev
🌐
Melmass
melmass.github.io › uv › guides › pre-commit.html
Using in pre-commit - uv
To compile requirements via pre-commit, add the following to the .pre-commit-config.yaml: - repo: https://github.com/astral-sh/uv-pre-commit # uv version.
🌐
DEV Community
dev.to › hugovk › speed-up-ci-with-uv-53n1
Speed up CI with uv ⚡ - DEV Community
April 6, 2025 - We can use uv to make linting and testing on GitHub Actions around 1.5 times as fast. ... name: Lint on: [push, pull_request, workflow_dispatch] env: FORCE_COLOR: 1 permissions: contents: read jobs: lint: runs-on: ubuntu-latest steps: - uses: ...
🌐
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]
🌐
Tiefenthaler
tiefenthaler.github.io › uv-datascience-project-template › guides › pre_commit
Pre-Commit - UV Data Science Project Template
You can update your hooks to the latest version automatically by running pre-commit autoupdate. By default, this will bring the hooks to the latest tag on the default branch. If you want to commit changes without running the pre-commit hooks, you can use the --no-verify flag with the git commit ...
🌐
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.
🌐
Tiefenthaler
tiefenthaler.github.io › uv-datascience-project-monorepo-template › guides › pre_commit
Pre-Commit - UV Data Science Project Mono-Repository Template
This project uses pre-commit to manage pre-commit hooks. Here's how to get started: Make sure you have uv installed.