Use when setting up or running hooks with prek in any repository. prek is a Rust drop-in alternative to pre-commit for running Git hooks that check, format, lint, and validate code and repository files. Prefer it when speed, workspace mode, built-in hooks, shared toolchains, or native TOML configuration matter.
Use this skill when the user wants to set up or run Git hooks with prek.
prek is a Rust reimplementation of pre-commit. Its main job is to run hooks that check code and repository files before commit or on demand: formatters, linters, validators, security checks, and custom project checks.
Use the LLM-oriented index first:
Per that file, prefer explicit markdown docs when you need details:
Use prek to:
pre-commit, pre-push, and commit-msgpre-commitTypical jobs for hooks run by prek:
For new configs, prefer prek.toml.
Important repo types:
https://github.com/astral-sh/ruff-pre-commitrepo = "local": hooks defined in the current repositoryrepo = "meta": config-checking hooks like check-hooks-apply, check-useless-excludes, and identityrepo = "builtin": prek's offline Rust-native hooksMinimal examples:
[[repos]]
repo = "https://github.com/astral-sh/ruff-pre-commit"
rev = "v0.14.3"
hooks = [
{ id = "ruff" },
{ id = "ruff-format" },
]
[[repos]]
repo = "local"
hooks = [
{
id = "cargo-fmt",
name = "cargo fmt",
language = "system",
entry = "cargo fmt --",
files = "\\.rs$",
},
]
[[repos]]
repo = "builtin"
hooks = [
{ id = "trailing-whitespace" },
{ id = "check-yaml" },
]
These examples use TOML 1.1 multiline inline tables. Use [[repos.hooks]] array-of-tables if an editor or parser in the toolchain does not support that syntax yet, or when a hook has many fields such as env, pass_filenames = false, or priority.
Filtering patterns:
files = "\\.rs$"prek also supports globs: files = { glob = "src/**/*.rs" }exclude = { glob = ["target/**", "dist/**"] }Scheduling:
priority values run earlierpriority can run concurrentlypriority is evaluated within one config file, not across workspace projectsUseful prek-specific hook/config fields when editing TOML:
env for per-hook environment variablespriority for hook ordering and concurrencyminimum_prek_version for gating newer config featuresorphan = true to isolate a nested workspace project from parent configsWhen adopting prek in a repository:
.pre-commit-config.yaml or .pre-commit-config.yml.pre-commit to prek.pre-commit, reinstall the Git shims with prek install -f.prek.toml for a fresh setup.prek.prek validate-config.prek install --prepare-hooks.prek run --all-files..prekignore, and orphan: true.If the user explicitly wants maximum upstream portability, stay with .pre-commit-config.yaml and avoid prek-only keys.
Common install methods:
uv tool install prekbrew install prekmise use prekcargo binstall prekcargo install --locked prekprek install: install Git hook shims into the repo's effective hooks directoryprek prepare-hooks: prepare hook environments without installing Git shimsprek install --prepare-hooks: install shims and prepare environments in one stepprek run: run hooks for the current staged file selectionprek run --all-files: run hooks across the whole repositoryprek run <hook-id>: run only one hookprek list: list discovered hooks and projectsprek validate-config: validate prek.toml or .pre-commit-config.yamlprek auto-update: update pinned hook revisionsprek util yaml-to-toml: convert an existing YAML config to prek.tomlprek util identify <path>: inspect file tags when types, types_or, or exclude_types do not match as expectedUseful quality-of-life commands and options mentioned in the docs:
prek run --dry-runprek run --directory <dir>prek run --last-commitprek run --skip <hook-or-project>prek -C <dir> ...For debugging:
prek run -vvvPREK_NO_FAST_PATH=1 prek run: compare builtin fast-path behavior against the standard execution pathprek has two important builtin paths:
https://github.com/pre-commit/pre-commit-hooksrepo: builtin for offline, zero-setup built-in hooksReach for repo: builtin when speed, no-network setup, or minimal bootstrapping matters more than upstream pre-commit compatibility.
Builtin hooks called out by the docs include:
trailing-whitespacecheck-added-large-filescheck-case-conflictcheck-illegal-windows-namesend-of-file-fixerfile-contents-sorterfix-byte-order-markercheck-jsoncheck-json5pretty-format-jsoncheck-tomlcheck-vcs-permalinkscheck-yamlcheck-xmlmixed-line-endingcheck-symlinksdestroyed-symlinkscheck-merge-conflictdetect-private-keyno-commit-to-branchcheck-shebang-scripts-are-executablecheck-executables-have-shebangsprek.toml for new setups..pre-commit-config.yaml for migrations unless the user asks for TOML.repo: builtin when offline or zero-setup hooks are useful.pre-commit-hooks, remember that prek can use built-in Rust implementations for some common hooks.prek util yaml-to-toml instead of hand-converting YAML when migrating.