Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Setup Pre Commit?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/bolens-setup-pre-commit)
---
name: setup-pre-commit
description: Set up or improve local Git hooks and staged-file checks using the repo’s existing tools. Covers Husky, pre-commit, and Lefthook.
---
# Set Up Pre-Commit Checks
Build on the repository's existing tooling. Prefer a small, fast hook developers will keep enabled.
Use the project's pinned environment through [portable development environments](../ci-maintenance/references/development-environments.md).
Prefer mise or the established devenv/devcontainer toolchain over untracked global
installs. Verify hook execution from a noninteractive editor process as well as a
shell; do not make every commit download tools, rebuild a container, or start services.
## Inspect
1. Read `AGENTS.md`, contributor docs, manifests, lockfiles, existing hooks, CI, and Make/task targets.
2. Identify the repository ecosystems and canonical commands. Examples include:
- Node: package-manager scripts, lint-staged, Husky
- Python: `pre-commit`, Ruff, Black, mypy, pytest
- Go: gofmt, go vet, golangci-lint, go test
- Rust: cargo fmt, Clippy, cargo test
- Shell/config: shfmt, ShellCheck, repository validation targets
3. Preserve existing formatter and linter configuration. Do not introduce competing tools or style defaults.
## Design
- Reuse an existing hook framework. If none exists, choose the least invasive fit for the repo and explain the choice.
- Run formatting and linting on staged files when supported.
- Keep expensive full-suite tests in CI unless the suite is demonstrably fast or the user explicitly wants it locally.
- Never rewrite unrelated staged files. Warn before a formatter may modify files.
- Pin or lock new dependencies using the repository's normal conventions.
For commit-message validation, apply [semantic conventions](../git-hygiene/references/semantic-conventions.md) through a `commit-msg` hook using the repository's validator and allowed types. A staged-file `pre-commit` hook does not validate the final message. Match CI and release-parser rules, preserve required trailers, and test valid, invalid, scoped, and breaking messages in a disposable repository. PR titles require host-side validation when CI enforcement is in scope.
## Implement
Treat a request to set up hooks as authorization to edit repository configuration. Dependency downloads, changes outside the repository, and replacement of existing hooks still require the normal approvals.
Add only the files and scripts needed for the selected framework. Keep commands usable outside the hook, preferably through existing package scripts or Make/task targets.
Follow the user's and repository's commit instructions. When a commit is required, stage only task changes and preserve unrelated staged or unstaged work. Do not replace an existing hook without describing what will be preserved.
## Verify
1. Validate configuration syntax.
2. Run each underlying command directly.
3. Exercise the hook against representative staged files when this can be done without disturbing the user's index; otherwise explain the limitation.
4. Report runtime, files changed, and any checks intentionally left to CI.
When the requested work also changes CI workflow structure or required-check coverage, use [ci-maintenance](../ci-maintenance/SKILL.md) for that contract while keeping staged-file behavior here. Reuse the same underlying validation commands. Hook-only work does not require a CI redesign.