-
π Used by "Vibe-Coding Cleaning Specialists" β effectively guides your AI model to better results, never compromise security, and never push broken code
-
π‘οΈ Block secrets, API keys & credentials in every commit/push
-
π¦ Catch errors early: TypeScript, Lint, Build & Cypress tests auto-run at the right time
-
π Beautiful commit messages β fully supports Conventional Commits & Gitmoji
-
β‘ Zero config for most Node, TypeScript & Rails projects
-
π Easy install, totally portable, and proven across real-world codebases
Protect your main branch. Ship with confidence. Focus on building, not fixing leaks/reviewing noisy PRs.
-
Clone or copy this repository to a location on your machine:
git clone <repository-url> ~/git-hooks # or simply copy the directory to your desired location
-
Install hooks in your repository:
cd /path/to/your/repo cp ~/git-hooks/pre-commit .git/hooks/ cp ~/git-hooks/pre-push .git/hooks/ cp ~/git-hooks/prepare-commit-msg .git/hooks/ cp -r ~/git-hooks/shared .git/hooks/
-
Make hooks executable:
chmod +x .git/hooks/pre-commit chmod +x .git/hooks/pre-push chmod +x .git/hooks/prepare-commit-msg chmod +x .git/hooks/shared/*.sh
You can create a simple install script to set up hooks across multiple repositories:
#!/bin/bash
HOOKS_DIR="$HOME/Development/__git-hooks"
REPO_DIR="$1"
if [ -z "$REPO_DIR" ]; then
echo "Usage: $0 <repository-path>"
exit 1
fi
cd "$REPO_DIR" || exit 1
cp "$HOOKS_DIR/pre-commit" .git/hooks/
cp "$HOOKS_DIR/pre-push" .git/hooks/
cp "$HOOKS_DIR/prepare-commit-msg" .git/hooks/
cp -r "$HOOKS_DIR/shared" .git/hooks/
chmod +x .git/hooks/pre-commit
chmod +x .git/hooks/pre-push
chmod +x .git/hooks/prepare-commit-msg
chmod +x .git/hooks/shared/*.sh
echo "β
Git hooks installed successfully in $REPO_DIR"Automatically scans your code for sensitive data before committing or pushing:
- API Keys: Google, OpenAI, AWS, Firebase
- Database Connection Strings: MongoDB, PostgreSQL, MySQL, Redis
- Slack Tokens & Webhooks: Bot tokens, user tokens, webhook URLs
- Private Keys: RSA, DSA, EC, OpenSSH private keys
- Environment Variables: Next.js, React, Vite env vars with actual values
- Authentication Credentials: Passwords, secrets, tokens
What happens: If sensitive data is detected, the commit/push is blocked with helpful error messages and suggestions on how to fix it.
- Automatically runs
tsc --noEmitfor TypeScript projects - Detects TypeScript configuration files (
tsconfig.json,tsconfig.app.json, etc.) - Blocks commits if type errors are found
- Runs
npm run lintif available in your project - Ensures code follows your project's style guidelines
- Blocks commits if linting errors are found
Note: Some game repositories (TrafficRun, CrossyRoad, SpaceShooter) are permanently excluded from TypeScript and linting checks.
- Automatically runs Cypress tests before pushing
- Checks if dev server is running on
localhost:3000 - Main branch: Tests are required (push blocked if server not running)
- Other branches: Tests are optional (warning only if server not running)
- Automatically runs build checks when pushing to Heroku
- Detects Heroku remotes and ensures production readiness
- Blocks push if build fails
Interactive helper for creating consistent commit messages using Gitmoji and Conventional Commits format.
- Gitmoji Support: Suggests appropriate emojis based on staged files
- Conventional Commits: Encourages format like
feat(scope): description - Smart Suggestions: Analyzes staged files and suggests commit type
- Interactive Prompt: Guides you through creating a proper commit message
- Help System: Type
helpto see full Gitmoji reference
git commit
# Hook will prompt you with suggestions based on your staged filesβ¨ feat(auth): add OAuth2 loginπ fix(api): resolve user validation errorπ docs(readme): update installation guideπ¨ style(ui): improve button hover effectsβ»οΈ refactor(utils): simplify date formatting
The hooks automatically detect your project type:
- TypeScript Projects: Detects
tsconfig.jsonfiles - Rails Projects: Detects
Gemfileandconfig/application.rb - Repository Name: Extracts repo name for context-aware checks
- π Security check on staged files
- π TypeScript type checking (if TypeScript project)
- π§Ή Linting (if lint script available)
- β Commit proceeds if all checks pass
- π Security check on commits being pushed
- π§ͺ Cypress tests (if available and server running)
- π¨ Build check (if pushing to Heroku)
- β Push proceeds if all checks pass
- π Analyzes staged files
- π‘ Suggests appropriate Gitmoji and commit type
- π― Prompts for commit message
- βοΈ Writes formatted message to commit file
If you absolutely need to bypass hooks (use with caution):
# Skip pre-commit hook
git commit --no-verify
# Skip pre-push hook
git push --no-verifyTo exclude specific repositories from certain checks, edit shared/quality-checks.sh:
# Example: Skip TypeScript checks for a specific repo
if [ "$repo_name" = "YourRepoName" ]; then
echo "${YELLOW}β οΈ Skipping TypeScript check for $repo_name${NC}"
return 0
fiEdit shared/security-check.sh to add new sensitive data patterns:
SENSITIVE_PATTERNS=(
# ... existing patterns ...
"your-custom-pattern-here" # Add your pattern
)Edit prepare-commit-msg to change the commit message format or add new suggestions.
- Ensure hooks are executable:
chmod +x .git/hooks/* - Check that hooks are in
.git/hooks/directory - Verify hook file names match exactly (no
.sampleextension)
- Run
npx tsc --noEmitmanually to see errors - Check your
tsconfig.jsonconfiguration - Some projects may need to be excluded (see Customization)
- Ensure dev server is running:
npm run dev - Check that
cypressdirectory exists - Verify
package.jsonhas atestscript
- Review the detected pattern
- Consider adding the file to
.gitignoreif it's a test fixture - Adjust patterns in
shared/security-check.shif needed
- Never commit sensitive data: Use environment variables or secrets management
- Keep hooks updated: Pull latest changes from this repository regularly
- Fix issues locally: Don't bypass hooks, fix the underlying issues
- Use consistent commit messages: Follow the Gitmoji and Conventional Commits format
- Run tests before pushing: Ensure your dev server is running for Cypress tests
Feel free to submit issues or pull requests to improve these hooks!
This collection of git hooks is provided as-is for use across your repositories.