setup-pre-commitcommit 3216582SKILL.md · Code Standards
Setup Pre-Commit Hooks
Sets up a Husky pre-commit hook in the current repo that runs Prettier via lint-staged, plus typecheck and tests.
Installs dev dependencies, adds a git pre-commit hook and commits the changes.
npx skills add mattpocock/skills --skill setup-pre-commitCommand selected. Copy it manually.
- Permissions
- read-repo
- write-files
- shell
- network
- Compatible with
- Claude Code, Codex, Copilot, Gemini CLI
- GitHub
- 308.7k
- Source
- Community · Matt Pocock
- Status
- Scan passed
- License
- MIT
- Category
- Code Standards
Core rule
Adapt the hook to the detected package manager, and omit the typecheck or test line, telling the user, when the repo has no such script.
Execution Phases
Phase 01Detect and install
Detect npm, pnpm, yarn or bun from the lockfile and install husky, lint-staged and prettier as devDependencies.
Phase 02Initialise Husky
Run npx husky init, then write .husky/pre-commit to run lint-staged, typecheck and test.
Phase 03Add configs
Create .lintstagedrc running prettier --ignore-unknown --write on staged files, and .prettierrc only if no Prettier config exists.
Phase 04Verify and commit
Check the files and prepare script, run npx lint-staged, then commit so the new hook runs as a smoke test.
Permissions (summarised from SKILL.md)
| Capability | Needed | Details |
|---|---|---|
| File writes | Limited | Creates or edits only .husky/pre-commit, .lintstagedrc, .prettierrc and package.json. |
| Command execution | Limited | Runs the package manager install, npx husky init, npx lint-staged and a git commit. |
| Network outbound | Limited | Only the package registry, to install dependencies. |
SKILL.md frontmatter (YAML)
---
name: setup-pre-commit
description: Set up Husky pre-commit hooks with lint-staged (Prettier), type checking, and tests in the current repo. Use when user wants to add pre-commit hooks, set up Husky, configure lint-staged, or add commit-time formatting/typechecking/testing.
---