Skip to content
Back to skills

Setup Pre Commit

ASecurity

Set up or improve local Git hooks and staged-file checks using the repo’s existing tools. Covers Husky, pre-commit, and Lefthook.

  • 3 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added November 6, 2026
toolspythonrustgoshellnodegit

Works with

  • cli

Security analysis

A100/100

Pro scans all 3 files and shows the line behind each finding

Scanned November 20, 2026

npx -y skills add bolens/agent-skills --skill setup-pre-commit --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Setup Pre Commit?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Setup Pre Commit
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/bolens-setup-pre-commit/badge)](https://www.skillsdirectory.com/skills/bolens-setup-pre-commit)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
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.

Files in this skill

  • SKILL.md3.6 KB
  • UPSTREAM.md428 B
  • agents/openai.yaml199 B

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in tools →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.