Loading...
Loading...
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.
npx skill4agent add autumnsgrove/groveengine git-hooks# 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/*| Hook | Purpose |
|---|---|
| Validates conventional commit format |
| Prevents leaked API keys/secrets |
| Hook | Language | Checks |
|---|---|---|
| Python | Black, Ruff |
| JS/TS | Prettier, ESLint, TypeScript |
| Go | gofmt, go vet |
| Mixed | Auto-detects and runs appropriate tools |
| Hook | Purpose |
|---|---|
| Runs tests before push |
| Auto-updates dependencies on branch switch |
| Shows commit summary and TODOs |
# 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# Accepted formats
feat: Add user authentication
fix: Correct validation error
docs(readme): Update installation
# Rejected
Update files # No type
feat add feature # Missing colonsk-ant-...sk-...AKIA...ghp_...# Runs automatically on staged .py files
uv run black --check $file
uv run ruff check $file# Runs before push
uv run pytest tests/ # or pnpm test, go test, cargo test# 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# Skip all hooks
git commit --no-verify -m "Emergency fix"
# Only use when:
# - Emergency production fixes
# - Hook malfunction
# - Intentional override# Check existence
ls -l .git/hooks/
# Fix permissions
chmod +x .git/hooks/*
# Check syntax
bash -n .git/hooks/pre-commitchmod +x .git/hooks/*# 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"# Install code quality tools
uv add --dev black ruff
# Verify installation
which black
uv run black --version#!/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 0AgentUsage/pre_commit_hooks/setup_guide.mdexamples.mdTROUBLESHOOTING.md