Skip to content
git-hooks logo

Git Hooks Skill

git-hooks

Set up and configure Git pre-commit hooks for code quality, secrets scanning, and commit message validation. Use when installing git hooks, configuring pre-commit checks, or enforcing code standards.

SKILL.md

Full skill instructions

Git Hooks Skill

When to Activate

Activate this skill when:

  • Setting up pre-commit hooks
  • Configuring commit message validation
  • Installing secrets scanners
  • Enforcing code quality standards
  • Automating pre-push tests

Quick Installation

# Use interactive installer (recommended)
./​AgentUsage/​pre_commit_hooks/​install_hooks.sh

# Or manual installation for Python project
cp AgentUsage/​pre_commit_hooks/​commit-msg .git/​hooks/
cp AgentUsage/​pre_commit_hooks/​pre-commit-python .git/​hooks/​pre-commit
cp AgentUsage/​pre_commit_hooks/​pre-commit-secrets-scanner .git/​hooks/​pre-commit-secrets
cp AgentUsage/​pre_commit_hooks/​pre-push .git/​hooks/
chmod +x .git/​hooks/​*

Available Hooks

Core Hooks (All Projects)

HookPurpose
commit-msgValidates conventional commit format
pre-commit-secrets-scannerPrevents leaked API keys/​secrets

Language-Specific

HookLanguageChecks
pre-commit-pythonPythonBlack, Ruff
pre-commit-javascriptJS/​TSPrettier, ESLint, TypeScript
pre-commit-goGogofmt, go vet
pre-commit-multi-languageMixedAuto-detects and runs appropriate tools

Automation Hooks

HookPurpose
pre-pushRuns tests before push
post-checkoutAuto-updates dependencies on branch switch
post-commitShows commit summary and TODOs

Hook Selection by Project

# Python Project
commit-msg + pre-commit-python + pre-commit-secrets-scanner + pre-push

# JavaScript Project
commit-msg + pre-commit-javascript + pre-commit-secrets-scanner + pre-push

# Go Project
commit-msg + pre-commit-go + pre-commit-secrets-scanner + pre-push

# Multi-language
commit-msg + pre-commit-multi-language + pre-commit-secrets-scanner + pre-push

What Each Hook Does

commit-msg

Validates commit message format:

# Accepted formats
feat: Add user authentication
fix: Correct validation error
docs(readme): Update installation

# Rejected
Update files  # No type
feat add feature  # Missing colon

pre-commit-secrets-scanner

Scans for exposed secrets:

  • Anthropic API keys (sk-ant-...)
  • OpenAI API keys (sk-...)
  • AWS credentials (AKIA...)
  • GitHub tokens (ghp_...)
  • Hardcoded passwords

pre-commit-python

# Runs automatically on staged .py files
uv run black --check $file
uv run ruff check $file

pre-push

# Runs before push
uv run pytest tests/  # or pnpm test, go test, cargo test

Testing Hooks

# Test pre-commit directly
.git/​hooks/​pre-commit

# Test with sample commit
git add .
git commit -m "test: verify hooks"

# Run with debug output
bash -x .git/​hooks/​pre-commit

Bypassing Hooks (Emergency Only)

# Skip all hooks
git commit --no-verify -m "Emergency fix"

# Only use when:
# - Emergency production fixes
# - Hook malfunction
# - Intentional override

Troubleshooting

Hook Not Running

# Check existence
ls -l .git/​hooks/

# Fix permissions
chmod +x .git/​hooks/​*

# Check syntax
bash -n .git/​hooks/​pre-commit

Permission Denied

chmod +x .git/​hooks/​*

Failed Quality Checks

# Run tools manually
uv run black --check .
uv run ruff check .

# Fix issues
uv run black .
uv run ruff check --fix .

# Retry commit
git commit -m "Your message"

Missing Tools

# Install code quality tools
uv add --dev black ruff

# Verify installation
which black
uv run black --version

Custom Hook Configuration

Modify pre-commit for Your Project

#!/​bin/​bash
# .git/​hooks/​pre-commit

# Get staged Python files
FILES=$(git diff --cached --name-only --diff-filter=ACM | grep '\.py$')

if [ -n "$FILES" ]; then
    # Run your tools
    uv run black --check $FILES || exit 1
    uv run ruff check $FILES || exit 1
fi

exit 0

Hook Execution Order

  1. pre-commit - Before commit (code quality)
  2. commit-msg - Validates message format
  3. post-commit - After commit (notifications)
  4. pre-push - Before push (tests)

Best Practices

DO ✅

  • Install secrets scanner on ALL projects
  • Use commit-msg for consistent history
  • Run tests in pre-push
  • Test hooks after installation

DON'T ❌

  • Skip hooks regularly
  • Disable secrets scanning
  • Ignore hook failures
  • Commit without testing hooks first

Related Resources

See AgentUsage/​pre_commit_hooks/ for:

  • setup_guide.md - Complete installation guide
  • examples.md - Custom hook examples
  • TROUBLESHOOTING.md - Common issues
  • Individual hook scripts for reference

More Security skills

supabase logo
Security

supabase

Handles the full Supabase workflow from schema changes to deployment, with built-in security guardrails that catch common traps like RLS...

2.7K 308.9K
View

Comprehensive guides and best practices for Neon Serverless Postgres, covering setup, connection methods, authentication, and platform APIs.

98 216.2K
View

Guide for setting up and using Firebase Authentication. Use this skill when the user's app requires user sign-in, user management, or secure data access using auth rules.

462 163.8K
View

A skill to evaluate how secure Firestore security rules are. Use this when Firestore security rules are updated to ensure that the generated rules are extremely secure and robust.

462 127.7K
View

Official skill for integrating Firebase AI Logic (Gemini API) into web applications. Covers setup, multimodal inference, structured output, and security.

462 125.1K
View

Complete Better Auth server and client setup with database adapters, session management, plugins, and security configuration.

222 118.2K
View

Deploy and manage projects on Vercel using token-based authentication. Use when working with Vercel CLI using access tokens rather than interactive login — e.g. "deploy to vercel", "set up vercel", "add environment variables to vercel".

31.9K 116.1K
View
cloudflare logo
Security

cloudflare

Complete Cloudflare platform integration with decision trees for compute, storage, AI, networking, security, and infrastructure-as-code.

3K 110.7K
View

Run Azure compliance and security audits with azqr plus Key Vault expiration checks. Covers best-practice assessment, resource review, policy/compliance validation, and security posture checks. WHEN: compliance scan, security audit, BEFORE running azqr (compliance cli tool), Azure best practices, Key Vault expiration check, expired certificates, expiring secrets, orphaned resources, compliance assessment.

253 103K
View
gws-gmail logo
Security

gws-gmail

Send, read, and manage Gmail messages, drafts, labels, and account settings.

31.2K 78.9K
View

Comprehensive website auditing across 230+ rules in 21 categories including SEO, performance, security, and accessibility.

94 72.3K
View
gws-shared logo
Security

gws-shared

Shared authentication, CLI syntax, and output formatting patterns for gws Google Workspace commands.

31.2K 63.4K
View

Security AI tools

StarByFace logo
Security

StarByFace

Discover your celebrity doppelgänger with StarByFace!

Free
View
GeoSpy logo
Security

GeoSpy

GeoSpy: Pricing, Features, FAQs, and Alternatives for AI Teams

Free
View

Detect AI-generated voices to protect against audio fraud.

Paid
View

Ensure Your Content's Originality with AI Plagiarism Checker

Freemium
View
Img Upscaler logo
Security

Img Upscaler

Upscale images by 400% without quality loss

Freemium
View
AICheatCheck logo
Security

AICheatCheck

Accurately Detect AI-Generated Content with TheChecker.AI

Free
View
D
Security

Detect GPT

Chrome extension that detects and flags AI-generated content

Free
View