| Crates.io | monk |
| lib.rs | monk |
| version | 0.3.4 |
| created_at | 2024-09-19 16:41:20.737282+00 |
| updated_at | 2025-08-11 16:59:31.408438+00 |
| description | Monk is a simple Git hooks manager written in Rust. It allows you to manage and automate Git hooks easily using a YAML configuration file. |
| homepage | https://github.com/daynin/monk |
| repository | https://github.com/daynin/monk |
| max_upload_size | |
| id | 1380481 |
| size | 197,168 |
build.rs files. Automate the hooks installation process.Keep calm, monk will protect your repo!
You can install it using cargo:
cargo install monk
You can add it as a build dependency:
cargo add --build monk
Then create a build.rs file:
pub fn main() {
monk::init();
}
In this case, monk will be installed automatically and will initialize all hooks from monk.yaml
.
This is the most convenient option for Rust projects, as it doesn't require contributors to install monk manually.
You can also install monk using Nix:
nix profile install github:daynin/monk
You can install monk using GNU Guix directly from GitHub:
# Install latest version from main branch
guix package -f <(curl -s https://raw.githubusercontent.com/daynin/monk/main/monk.scm)
Note: This will automatically fetch and build the latest version from the main branch.
Create a configuration file named monk.yaml in your project root:
pre-commit:
commands:
- cargo fmt -- --check
- cargo clippy -- -D warnings
pre-push:
commands:
- cargo test
For projects with multiple modules or mixed technologies, you can configure different hooks for different paths:
pre-commit:
paths:
"api/":
commands:
- cargo fmt -- --check
- cargo clippy -- -D warnings
working_directory: "api"
"frontend/":
commands:
- npm run lint
- npm test
working_directory: "frontend"
"shared/":
commands:
- cargo fmt -- --check
- cargo clippy -- -D warnings
- cargo test
working_directory: "shared"
pre-push:
paths:
"api/":
commands:
- cargo test
- cargo build --release
working_directory: "api"
"frontend/":
commands:
- npm run build
working_directory: "frontend"
# Global hooks (run for any changes)
commit-msg:
commands:
- echo "Validating commit message..."
Path-based features:
🎯 Selective execution: Only runs hooks for paths with changed files
📁 Working directory: Each hook can specify its working directory
🔄 Multi-module support: Perfect for monorepos with multiple Rust crates
🌐 Mixed technology: Supports different tech stacks in the same repo
If you installed monk manually, run:
monk install
If you added it as a build dependency and set up build.rs as shown above, the hooks will be installed automatically when you build your project.
To run specific hooks manually, use the run command
monk run pre-commit
monk automatically creates backup files for existing hooks and restores them when you remove monk's hooks.
To remove the hooks, run:
monk uninstall