← ClaudeAtlas

setup-rust-pre-commitlisted

Set up fast pre-commit hooks for a Rust repo — format and lint the staged changes only, with CI left as the real gate.
rewrite-rs/skills · ★ 2 · Code & Development · score 76
Install: claude install-skill rewrite-rs/skills
# Setup Rust Pre-commit A pre-commit hook is a convenience, never a gate. CI is the gate: it runs on every push whether or not a local hook ever fired. A hook that tries to be the gate gets slow, and a slow hook gets bypassed with `--no-verify` within a week — at which point the repo has neither a hook nor the honesty of admitting it. Like `/setup-rust-ci`, this skill runs only when the user invokes it — a hook executes on someone's behalf at every commit, and the model never decides that on its own. ## The one rule, stated first A hook that takes longer than about two seconds will be bypassed. Everything else in this skill follows from that: format and lint, never test; staged files, never the workspace; report and stop, never fix silently. ## Ask which mechanism before writing anything Three, and the choice is the user's: | Mechanism | Fits when | Costs | |---|---|---| | `core.hooksPath` script | Rust-only repo, no other hook needs | Each contributor runs one `git config` line; nothing enforces that they did | | `lefthook` | Mixed repo, wants parallel hooks, no Python | One binary dependency | | `pre-commit` | The repo already uses it for other languages | Python toolchain, and the Rust hooks shell out to cargo anyway | Detect what is already there — an existing `.pre-commit-config.yaml`, `lefthook.yml`, or `core.hooksPath` setting — and match it rather than introducing a second mechanism. The complete files for all three, ready to paste, are in `HOOKS.md`. ## What