Prek (Pre-commit)
prek is a fast Git hook manager written in Rust, designed as a drop-in replacement for the deprecated pre-commit CLI tool.
[!IMPORTANT] Command Line & Package Discrepancy: The CLI binary is
prek, NOTpre-commit. Thepre-commitCLI tool is deprecated and MUST NOT be used.
Key Differences
- Git concept / stage: "pre-commit" refers strictly to the Git lifecycle hook stage (e.g.
.pre-commit-config.yaml). - Legacy CLI Tool (DEPRECATED): The Python-based
pre-commitCLI tool is deprecated. NEVER addpkgs.pre-commitorpre-commitpackage/input todevenv.nixor package managers. - Active Hook Runner:
prekis the CLI binary used to run and configure pre-commit hooks.
Running Hooks
When working inside a devenv shell, run:
SECRETSPEC_REASON="running pre-commit hooks" devenv --no-tui shell -- prek run -a
If not using devenv, run:
prek run -a
Use -a or --all-files to run hooks against all files in the repository.
Commands
prek run: Run hooks against modified files.prek run -a: Run hooks against all files.prek install: Install prek Git shims into Git's hooks directory.prek uninstall: Uninstall prek Git shims.prek validate-config: Validate configuration files (prek.tomlor.pre-commit-config.yaml).prek cache: Manage the prek cache (e.g.,prek cache clean).