Setup Pre-Commit
Pack:
engineeringSource:engineering/setup-pre-commit/SKILL.mdUse this skill when the user wants commit-time checks without overloading the hook.
- Husky setup
- lint-staged configuration
- Prettier or existing formatter integration
- package-manager-aware hook commands
- choosing what belongs in pre-commit versus CI
Default path
Section titled “Default path”- Detect the package manager and current scripts.
- Install the minimum hook dependencies.
- Initialize Husky if the repo does not already use it.
- Configure
lint-stagedfor staged-file formatting or linting. - Keep the pre-commit hook fast:
- staged formatting or linting first
- lightweight checks second
- heavy suites in CI unless the repo explicitly wants them locally
- Verify the hook against the current scripts instead of inventing missing commands.
When to deviate
Section titled “When to deviate”- Keep the hook even smaller when the repo already struggles with slow local tooling.
- Add more checks only if the repo already runs them reliably and the team explicitly wants them before commit.
- Skip formatter or lint changes if the repo already has a working hook stack that only needs a small fix.
Guardrails
Section titled “Guardrails”- Do not add
typecheckortestto the hook if the repo does not already support them cleanly. - Prefer staged-file checks over whole-repo checks in pre-commit.
- Keep the hook deterministic and package-manager-aware.
- Do not introduce a formatter config if the repo already has one.
- turning pre-commit into a slow mini-CI pipeline
- inventing scripts the repo does not actually have
- running whole-repo checks when staged-file checks are enough
- overwriting an existing formatter setup without reason
Verification checklist
Section titled “Verification checklist”- the package manager and current scripts were detected first
- hook commands are fast enough for normal commit flow
- checks operate on staged files where possible
- CI-only work stays out of pre-commit unless explicitly desired
- the hook matches the repo’s real tooling, not imagined tooling
Output Shape
Section titled “Output Shape”When answering with this skill, prefer:
- packages to install
- files to create or update
- exact hook content
- what should stay in CI instead
Good Triggers
Section titled “Good Triggers”- pre-commit, Husky, lint-staged, commit hooks, run formatter on commit