Configs2026年7月2日·1 分钟阅读

Prek — Fast Git Hooks Manager Written in Rust

Prek is a fast git hooks manager written in Rust, designed as a drop-in alternative to pre-commit. It runs hook scripts in parallel with minimal configuration overhead.

Agent 就绪

Agent 可直接安装

这个资产可安装;Agent 先选择当前运行时、检查安装计划,再运行匹配命令。

Native · 98/100策略:允许
Agent 入口
任意 MCP/CLI Agent
类型
Skill
安装
Single
信任
信任等级:Established
入口
Prek Overview
直接安装命令
npx -y tokrepo@latest install fc0ee751-7615-11f1-9bc6-00163e2b0d79 --target codex

先 dry-run 确认安装计划,再运行此命令。

Introduction

Prek is an open-source git hooks manager written in Rust by j178. It serves as a faster alternative to the popular pre-commit framework, focusing on speed and simplicity. Prek is designed to be a drop-in replacement, reading existing pre-commit configuration files while executing hooks significantly faster through parallel execution and a compiled runtime.

What Prek Does

  • Manages git hook scripts across pre-commit, commit-msg, post-commit, and other git hook stages
  • Runs hook checks in parallel by default, reducing total hook execution time
  • Reads .pre-commit-config.yaml files for compatibility with existing pre-commit setups
  • Installs itself as the git hook handler with a single command
  • Caches hook environments and tool installations to avoid repeated setup on each commit

Architecture Overview

Prek is a single compiled Rust binary with no runtime dependencies. When triggered by a git hook event, it reads the repository's configuration file, resolves which hooks apply to the changed files, and executes them in parallel across available CPU cores. Hook repositories are cloned and cached locally. The Rust implementation avoids the Python startup overhead that pre-commit incurs, resulting in noticeably faster hook execution, especially in large repositories with many hooks.

Self-Hosting & Configuration

  • Install via cargo install prek, or download a prebuilt binary from GitHub releases
  • Run prek install in a repository to set up the git hook integration
  • Configure hooks in .prek.toml or use an existing .pre-commit-config.yaml
  • Set environment variables like PREK_CACHE to control where hook tools are cached
  • Supports running on Linux, macOS, and Windows

Key Features

  • Parallel hook execution across all available cores by default
  • Compatible with the pre-commit config format for easy migration
  • Single static binary with no Python or Node.js dependency
  • Fast startup time due to compiled Rust implementation
  • Built-in support for common hook languages including Python, Node, Rust, and Go

Comparison with Similar Tools

  • pre-commit — the established Python-based hooks framework; widely adopted but slower due to Python startup and sequential default execution
  • Lefthook — Go-based git hooks manager with parallel execution; similar speed goals but uses its own config format
  • Husky — JavaScript-focused git hooks tool tied to the npm ecosystem; less suitable for polyglot repositories
  • overcommit — Ruby-based hooks manager with built-in hook definitions; requires a Ruby runtime

FAQ

Q: Can I use my existing pre-commit config with Prek? A: Yes. Prek can read .pre-commit-config.yaml files directly, making migration straightforward.

Q: How much faster is Prek compared to pre-commit? A: Speed improvements depend on the number of hooks and repository size. The main gains come from parallel execution and eliminating Python startup overhead. Benchmarks in the project repository show significant reductions in hook run time.

Q: Does Prek support custom local hooks? A: Yes. You can define local hooks in the configuration file that run arbitrary commands without needing an external hook repository.

Q: What platforms does Prek support? A: Prek runs on Linux, macOS, and Windows. Prebuilt binaries are available for all three platforms.

Sources

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产