Install
$ agentstack add skill-helderberto-agent-skills-setup-pre-commit ✓ scanned · ✓ verified — works with Claude Code, Cursor, and more.
Security review
✓ PassedNo issues found. Passed automated security review. · v0.1.0 How review works →
- ✓ Prompt-injection patterns
- ✓ Secret / credential exfiltration
- ✓ Dangerous shell & filesystem operations
- ✓ Untrusted network calls
- ✓ Known-malicious package signatures
What it can access
- ✓ Network access No
- ✓ Filesystem access No
- ✓ Shell / process execution No
- ✓ Environment & secrets No
- ✓ Dynamic code execution No
From automated source analysis of v0.1.0. “Used” means the capability is present in the source — more access means more to trust, not that it’s unsafe.
About
Setup Pre-Commit Hooks
What This Sets Up
- Husky pre-commit hook
- lint-staged running Prettier on all staged files
- Prettier config (if missing)
- typecheck and test scripts in the pre-commit hook (if they exist)
Workflow
- 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:
``bash 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 run typecheck run test ` Replace 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:
``json { "*": "prettier --ignore-unknown --write" } ``
- Create
.prettierrc(only if no Prettier config exists):
``json { "useTabs": false, "tabWidth": 2, "singleQuote": true, "trailingComma": "all" } ``
- Verify:
.husky/pre-commitexists and is executable.lintstagedrcexistspreparescript in package.json is"husky"- Prettier config exists
- Run
npx lint-stagedto confirm it works
- Commit all changed/created files:
Add pre-commit hooks (husky + lint-staged + prettier)
This runs through the new pre-commit hooks -- a good smoke test.
Rules
- Never overwrite existing Prettier config
- Never overwrite existing
.husky/pre-commitwithout asking user first - Always use detected package manager consistently
- Husky v9+ doesn't need shebangs in hook files
prettier --ignore-unknownskips files Prettier can't parse (images, etc.)- Pre-commit runs lint-staged first (fast, staged-only), then full typecheck and tests
Error Handling
- No
package.jsonfound -- report and stop - Existing
.husky/pre-commit-- ask user before overwriting husky initfails -- check node_modules exists, suggest running install firstnpx lint-stagedverification fails -- check Prettier is installed, check.lintstagedrcsyntax- No
typecheckortestscripts -- omit from hook, tell user which were skipped
See Also
- [validate-code](../validate-code/SKILL.md) -- run lint/typecheck/tests manually
- [commit](../commit/SKILL.md) -- create git commits following repo style
Source & license
This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.
- Author: helderberto
- Source: helderberto/agent-skills
- License: MIT
Install and usage instructions live in the source repository linked above.
Reviews
No reviews yet — be the first.
Write a review
Versions
- v0.1.0 Imported from the upstream source.