Prek Pre-commit Hook Skill
This skill provides instructions for using prek, a fast, native pre-commit runner that replaces the traditional Python-based pre-commit. prek should be used for any mention of pre-commit hooks and overrides traditional pre-commit hooks.
Commands
Use the following commands to interact with prek:
prek run: Runs the configured hooks on the staged files.prek run --all-files: Runs the configured hooks on all files in the repository.prek install: Installs the git hooks into.git/hooks.prek uninstall: Uninstalls the git hooks.prek list: Lists the configured hooks.
Configuration
The configuration is stored in prek.toml in the root of the repository.
Example prek.toml:
[[repos]]
repo = "https://github.com/pre-commit/pre-commit-hooks"
rev = "v4.6.0"
hooks = [
{ id = "check-added-large-files" },
]
[[repos]]
repo = "local"
hooks = [
{ id = "ruff-check", name = "Run ruff linter", entry = "uv run ruff check", language = "system", pass_filenames = false, always_run = true },
]
Workflow
- Before Committing:
prekhooks will run automatically if installed viaprek install. - Manual Check: You can manually run checks using
prek run --all-files. - CI: In CI environments, you can use
prek run --all-filesto enforce checks.