# prek - Pre-commit Re-engineered in Rust
# install via: `uv tool install prek`
# prek is a Rust-based drop-in replacement for pre-commit created by https://github.com/j178/prek
# Sources:
# - https://github.com/j178/prek
# - https://prek.j178.dev/
# - https://pypi.org/project/prek/
# - https://hugovk.dev/blog/2025/ready-prek-go/
# - https://pydevtools.com/blog/prek-pre-commit-but-fast/
default_stages:
- commit-msg
- pre-commit
repos:
- repo: https://github.com/mxr/sync-pre-commit-deps
rev: v0.0.3
hooks:
- id: sync-pre-commit-deps
# WORKAROUND: prek bug https://github.com/j178/prek/issues/1194
# commit-msg hooks don't receive the commit message file on Linux
- repo: local
hooks:
- id: conventional-pre-commit
name: Conventional Commit
stages: [commit-msg]
language: system
always_run: true
entry: uv run --with conventional-pre-commit conventional-pre-commit --strict --force-scope .git/COMMIT_EDITMSG
# Standard pre-commit hooks for general file maintenance
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v6.0.0
hooks:
- id: trailing-whitespace
exclude: (\.lock$)
- id: check-yaml
args: [--unsafe] # Allow Python tags in mkdocs.yml
- id: check-json
- id: check-toml
- id: check-added-large-files
args: ["--maxkb=10000"] # 10MB limit
- id: check-case-conflict
- id: check-merge-conflict
- id: check-symlinks
- id: mixed-line-ending
args: ["--fix=lf"]
- id: check-executables-have-shebangs
- id: check-shebang-scripts-are-executable
# Python formatting and linting
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.14.10
hooks:
- id: ruff
name: Lint Python with ruff
args: [--fix]
- id: ruff-format
name: Format Python with ruff
- repo: https://github.com/DavidAnson/markdownlint-cli2
rev: v0.20.0
hooks:
- id: markdownlint-cli2
# YAML/JSON formatting
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v4.0.0-alpha.8
hooks:
- id: prettier
name: Format YAML, JSON, and Markdown files
types_or: [yaml, json, markdown]
args: [--ignore-path, .prettierignore]
exclude: (\.lock$|mkdocs\.yml|docs/generated/)
- repo: https://github.com/DetachHead/basedpyright-prek-mirror
rev: 1.36.1
hooks:
- id: basedpyright
# Shell formatting
- repo: https://github.com/pecigonzalo/pre-commit-shfmt
rev: v2.2.0
hooks:
- id: shell-fmt-go
args:
- "--apply-ignore"
- -w
- -i
- "4"
- -ci
- repo: https://github.com/shellcheck-py/shellcheck-py
rev: v0.11.0.1
hooks:
- id: shellcheck
exclude: ^scripts/apt-fast
# Local hooks for type checking
- repo: local
hooks:
- id: mypy
name: mypy
entry: uv run -q --active --inexact --with pep723-loader --with mypy pep723-loader mypy
language: system
types: [python]
pass_filenames: true
args: ["--config-file", "pyproject.toml"]
# Configuration for specific hooks
default_language_version:
python: python3
exclude: (node_modules/|.venv/|__pycache__/|\.ruff_cache/|\.mypy_cache/|\.pytest_cache/|\.pem$|\.cer$|\.crt$|\.key$|\.lock$|mkdocs\.yml|docs/generated/)