Git Hooks Generator
Generate pre-commit, pre-push, and other Git hook scripts
Hook manager
Package manager
Git Hook Stage
Pre-Commit Checks
pre-commit
# Block accidental commit of .env secrets
if git diff --cached --name-only | grep -qE "(^|/)\.env($|\.)" && ! git diff --cached --name-only | grep -qE "\.env\.example$"; then
echo "Error: Refusing to commit .env secret file. Unstage it first." >&2
exit 1
fi
npx --no -- lint-staged
npm run typecheck
Setup Instructions
npx --no -- husky init # Save script into .husky/pre-commit
Companion Configuration
{
"lint-staged": {
"*.{ts,tsx,js,jsx}": [
"eslint --fix",
"prettier --write"
],
"*.{json,md,css}": [
"prettier --write"
]
}
}