Install
$ agentstack add skill-officialunofficial-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
Set up pre-commit hooks
What you end up with
- A Husky pre-commit hook
- lint-staged running Prettier over the staged files
- A Prettier config, if the repo lacks one
- typecheck and test scripts invoked from the hook
Steps
1. Detect the package manager
Look for a lockfile: package-lock.json (npm), pnpm-lock.yaml (pnpm), yarn.lock (yarn), or bun.lockb (bun). Use whichever is present, and fall back to npm when none is clear.
2. Install the dev dependencies
Add as devDependencies:
husky lint-staged prettier
3. Initialize Husky
npx husky init
This creates the .husky/ directory and adds a prepare: "husky" script to package.json.
4. Write .husky/pre-commit
Husky v9+ needs no shebang:
npx lint-staged
npm run typecheck
npm run test
Adapt it: swap npm for the detected package manager. If package.json has no typecheck or test script, drop the matching line and tell the user it was left out.
5. Write .lintstagedrc
{
"*": "prettier --ignore-unknown --write"
}
6. Write .prettierrc, only if none exists
Skip this when the repo already has a Prettier config. Otherwise use these defaults:
{
"useTabs": false,
"tabWidth": 2,
"printWidth": 80,
"singleQuote": false,
"trailingComma": "es5",
"semi": true,
"arrowParens": "always"
}
7. Confirm the setup
- [ ]
.husky/pre-commitexists and is executable - [ ]
.lintstagedrcexists - [ ] package.json has
"prepare": "husky" - [ ] A Prettier config is present
- [ ]
npx lint-stagedruns cleanly
8. Commit
Stage everything you created or changed and commit with: Add pre-commit hooks (husky + lint-staged + prettier). The commit itself flows through the new hook, which doubles as the first smoke test.
Notes
- Husky v9+ hook files do not take a shebang.
prettier --ignore-unknownpasses over files Prettier cannot parse, such as images.- The hook runs lint-staged first — fast, staged-only — before the full typecheck and tests.
Source & license
This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.
- Author: officialunofficial
- Source: officialunofficial/skills
- License: Apache-2.0
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.