hk
hk is a fast and flexible git hook manager that executes linters in parallel with safe file-level locking, ensuring efficient development workflows without race conditions or data loss.
hk is a high-performance git hook manager designed to optimize development workflows by running linters and formatters with unprecedented speed and safety. Unlike traditional hook managers that execute tasks sequentially, hk leverages advanced file-level read/write locking to execute multiple linters in parallel, even when they target overlapping sets of files. This parallelism significantly reduces wait times without compromising the integrity of the codebase. Built in Rust, hk ensures minimal overhead and rapid startup times for every git operation. The tool is designed to integrate seamlessly into existing environments, maintaining compatibility with standard git hooks while offering enhanced features like smart stashing. Before running any fix operations, hk automatically stashes unstaged changes and performs a three-way merge upon completion, ensuring that your work-in-progress is never lost or incorrectly staged. Configuration is handled via Pkl, a type-safe language that provides robust validation and structured management of project settings. Users can define custom hooks or take advantage of a vast library of over 90 built-in, production-ready linter configurations. For those who require consistent linting rules across multiple repositories, hk supports a global configuration layer that merges seamlessly with local project settings. Whether managing a small personal project or a complex monorepo, hk provides the control, speed, and reliability required by modern engineering teams. It handles dependency management and environmental variables with ease, especially when integrated with tools like mise-en-place. Every feature, from its Rust-native utility commands to its intelligent workspace-aware execution, is optimized to make the development cycle faster, safer, and more predictable.
Some of the key features are:
- Parallel Execution with Locking: Safely run multiple linters simultaneously using advanced read/write file locks to prevent race conditions.
- Smart Stashing: Automatically preserves unstaged work during fixing operations through a three-way merge, ensuring only intended changes are committed.
- Pkl Configuration: Leverages Pkl-lang for type-safe, readable, and powerful configuration management.
- Built-in Utilities: Includes high-performance, Rust-native tools for common maintenance tasks like trailing whitespace removal and merge conflict detection.
- Built-in Linters: Access a massive, production-ready library of 90+ pre-configured linters and formatters that work out of the box.
- Workspace Awareness: Efficiently manages linting in monorepos by running tasks from the correct project-level context based on indicators like package.json or Cargo.toml.
- Git Integration: Offers global hook installation to simplify management across all local repositories.
- Flexible Stashing: Supports multiple strategies, including standard git stash and lightweight patch-file based methods for enhanced performance.
Some common use cases include:
- Enforcing Code Quality: Automatically lint and format code on pre-commit, ensuring a clean codebase without manual intervention.
- Monorepo Management: Efficiently target and run linters within specific sub-packages of a large monorepo using workspace indicators.
- Continuous Integration: Use in CI pipelines to perform high-speed checks with minimal configuration overhead.
- Work-in-Progress Protection: Safely apply auto-fixes to staged changes without destroying or incorrectly staging unrelated local work-in-progress.
- Standardizing Linting: Apply consistent global linting rules across dozens of repositories by layering global config files.
Comments
0Markdown is supported.