From hb
Sets up Husky pre-commit hooks with lint-staged (Prettier), type checking, and tests. Detects package manager and configures commit-time formatting and validation.
How this skill is triggered — by the user, by Claude, or both
Slash command
/hb:setup-pre-commitThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Before proceeding, use the Read tool to read `package.json`, and Glob tool to detect:
Before proceeding, use the Read tool to read package.json, and Glob tool to detect:
package-lock.json, pnpm-lock.yaml, yarn.lock, bun.lockb.prettierrc, .prettierrc.*, prettier.config.*Detect package manager from lock file: package-lock.json (npm), pnpm-lock.yaml (pnpm), yarn.lock (yarn), bun.lockb (bun). Default to npm if unclear.
Install devDependencies:
husky lint-staged prettier
Initialize Husky:
npx husky init
This creates .husky/ dir and adds prepare: "husky" to package.json.
Create .husky/pre-commit (no shebang needed for Husky v9+):
npx lint-staged
<pm> run typecheck
<pm> run test
Replace <pm> with detected package manager. If repo has no typecheck script in package.json, omit that line and tell the user. Same for test.
Create .lintstagedrc:
{
"*": "prettier --ignore-unknown --write"
}
Create .prettierrc (only if no Prettier config exists):
{
"useTabs": false,
"tabWidth": 2,
"singleQuote": true,
"trailingComma": "all"
}
Verify:
.husky/pre-commit exists and is executable.lintstagedrc existsprepare script in package.json is "husky"npx lint-staged to confirm it worksCommit all changed/created files: Add pre-commit hooks (husky + lint-staged + prettier)
This runs through the new pre-commit hooks -- a good smoke test.
.husky/pre-commit without asking user firstprettier --ignore-unknown skips files Prettier can't parse (images, etc.)package.json found -- report and stop.husky/pre-commit -- ask user before overwritinghusky init fails -- check node_modules exists, suggest running install firstnpx lint-staged verification fails -- check Prettier is installed, check .lintstagedrc syntaxtypecheck or test scripts -- omit from hook, tell user which were skippednpx claudepluginhub helderberto/agent-skills --plugin hbSets up Husky pre-commit hooks with lint-staged (Prettier), type checking, and tests in the current repo.
Installs and configures Husky, lint-staged, and Prettier, plus optional typecheck and test scripts, for pre-commit hooks.
Installs and configures ecosystem-specific git pre-commit hooks (Husky, pre-commit, lefthook, cargo-husky) for formatting, linting, type-checking, and test gates.