Registry / devops / prek
library0.3.8pypypiunverified

Prek is a Rust-based reimplementation of the `pre-commit` framework, designed to manage Git hooks with dramatically improved performance and efficiency. It offers a faster, dependency-free alternative that is largely compatible with existing `.pre-commit-config.yaml` files, while also introducing new features like `prek.toml` configuration and built-in monorepo support. The project maintains an active development pace with frequent releases.

pip install prek
INSTALL
IMPORT
SIG · PREK
P
prek
devopspythonv0.3.8
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

This quickstart demonstrates how to install prek, generate a default configuration, set up the Git hooks, and trigger them with a commit. Prek will automatically use `.pre-commit-config.yaml` (or `prek.toml`) and manage hook environments.

# 1. Install prek (if not already done via pip) # curl --proto '=https' --tlsv1.2 -LsSf https://github.com/j178/prek/releases/download/v0.3.8/prek-installer.sh | sh # 2. Generate a sample configuration file prek sample-config > .pre-commit-config.yaml # 3. Install the Git hooks into your repository prek install # 4. Make a change to a file and commit # (e.g., echo 'new content' > some_file.py) git add . git commit -m "My first prek-checked commit"
prek --version
Debug
Known issues
gotchaPrek introduced `prek.toml` as an alternative configuration file format to `.pre-commit-config.yaml`. While existing YAML configurations are still supported, new projects or users might find `prek.toml` less error-prone. Converting existing configs can be done with `prek util yaml-to-toml`.
fix
Consider using `prek.toml` for new projects or converting existing `.pre-commit-config.yaml` files with `prek util yaml-to-toml`.
affects: >=0.3.2
gotchaThe `files` and `exclude` fields in configurations now support glob lists in addition to regular expressions. While this offers more readable and maintainable filters, ensure your patterns are correctly interpreted, especially if mixing glob and regex syntaxes or migrating older, heavily escaped regex patterns.
fix
Review `files` and `exclude` patterns. Leverage the `glob` mapping for simpler glob-based filtering where appropriate, or ensure existing regex patterns are still valid and correctly escaped.
affects: >=0.2.29
gotchaAlthough `prek` aims for high compatibility with `pre-commit` configurations, the documentation notes that "some languages are not yet supported for full drop-in parity." Users migrating from `pre-commit` with hooks in less common languages should verify support.
fix
Check the `prek` documentation's 'Language Support' section for specific language compatibility before migrating projects with diverse hook languages. Report any missing support to the project.
affects: <0.3.8 (and ongoing)
gotchaThe `prek` cache can grow over time. The `prek cache gc` command was introduced to clean up unused repositories, hook environments, and tool versions from the cache. Prior to this, manual intervention might have been necessary to manage disk space.
fix
Regularly run `prek cache gc` to manage disk space and remove stale cached resources.
affects: <0.3.0
gotchaA `SyntaxError` can occur if `prek` commands (or any shell commands) are attempted to be run directly as Python code within a script. Python's interpreter will not understand shell syntax like redirection (`>`).
fix
When invoking external commands like `prek sample-config` from a Python script, ensure they are executed through `subprocess.run()` (e.g., `subprocess.run(['prek', 'sample-config'], stdout=open('.pre-commit-config.yaml', 'w'))`) or `os.system()` (e.g., `os.system('prek sample-config > .pre-commit-config.yaml')`).
affects: '>=0.0.0'
gotchaAttempting to run `prek` command-line tools directly as Python code (e.g., `prek sample-config > output.yaml`) will result in a `SyntaxError`. `prek` is a command-line utility and must be executed in a shell environment or programmatically via Python's `subprocess` module.
fix
Ensure `prek` commands are executed in a shell (e.g., a `.sh` script) or through Python's `subprocess` module (e.g., `subprocess.run(['prek', 'sample-config'], stdout=open('.pre-commit-config.yaml', 'w'))`) when integrating into Python scripts.
affects: >=0.0.0
Errors
Common errors & fixes
error: Failed to parse `.pre-commit-config.yaml` caused by: error: line X column Y: missing field `rev`
The `.pre-commit-config.yaml` file has a syntax error, specifically a missing `rev` field for one of the repository definitions, which specifies the version of the hooks to use.
fix
Ensure that every repository entry in your `.pre-commit-config.yaml` file includes a `rev` field specifying a valid Git revision (e.g., a tag, branch name, or commit hash). Example: `repos: - repo: https://github.com/pre-commit/pre-commit-hooks hooks: [{ id: trailing-whitespace }] rev: v4.5.0`.
prek: command not found
The `prek` executable is not found in your system's PATH environment variable, or the installation was incomplete.
fix
Ensure `prek` is correctly installed via your chosen method (e.g., `pip install prek`, `brew install prek`, `cargo install prek`, or a standalone installer) and verify that its installation directory (e.g., `~/.cargo/bin` for Cargo, or the Python environment's bin directory for `pip`) is included in your system's PATH. Restart your terminal after installation to refresh the PATH.
Package name prek version is wrong. It should be at least X.Y.Z and is A.B.C.
The environment or tool attempting to run `prek` is detecting an older version of `prek` than required, possibly due to multiple installations or an incorrect PATH configuration within a specific project or virtual environment.
fix
Identify which `prek` executable is being called (e.g., by checking `which prek` or the specific Python environment path) and ensure it is updated to the required version using its respective package manager (e.g., `pip install --upgrade prek` in the correct virtual environment, or `brew upgrade prek`). Verify the version with `prek --version` in the problematic environment.
Prek hook not working
The Git hooks managed by `prek` are not executing as expected during Git operations, which can stem from incorrect installation of the hooks, invalid configuration, or permission issues with the hook files.
fix
First, ensure hooks are installed by running `prek install`. Verify that the `.pre-commit-config.yaml` or `prek.toml` configuration file is present and valid. Check the permissions of the hook files in your `.git/hooks/` directory, ensuring they are executable (e.g., `chmod +x .git/hooks/pre-commit`). If issues persist, try reinstalling hooks with `prek install --overwrite` or checking specific hook configurations within your config file.
Upgrade
Version history
0.3.8latest on PyPI · released Mar 23, 2026
Audit
Dependencies
pythonrequiredThe `prek` PyPI package is a Python wrapper that installs the standalone Rust binary. The core `prek` tool itself does not strictly require Python, but leverages `uv` for managing Python virtual environments for hooks.
Agent activity
7 hits · last 30 days
node
6
Resources