Git Hooks Integration
Automate quality checks on every commit and push. Never push broken code again.
🚀 Quick Setup
One-Command Installation
This installs: - pre-commit - Runs STANDARD verification - pre-push - Runs FULL verification
📋 Hook Levels
| Hook | Trigger | Verification Level | Bypass |
|---|---|---|---|
| pre-commit | git commit |
STANDARD | --no-verify |
| pre-push | git push |
FULL | --no-verify |
What Each Level Checks
STANDARD (pre-commit): - ✅ Syntax errors - ✅ Linting (ruff) - ✅ Formatting - ✅ Import sorting
FULL (pre-push): - Everything in STANDARD, plus: - ✅ Unit tests - ✅ Security scan - ✅ Dependency audit
⚙️ Configuration
Custom Hook Config (.boring.toml)
[boring.hooks]
pre_commit_level = "STANDARD" # BASIC|STANDARD|FULL
pre_push_level = "FULL" # STANDARD|FULL
auto_fix = true # Auto-fix linting issues
timeout_seconds = 300 # Max hook runtime
[boring.hooks.bypass_patterns]
# Skip verification for these file patterns
skip_files = ["*.md", "docs/*", "*.txt"]
Manual Hook Scripts
If you prefer manual control, create .git/hooks/pre-commit:
And .git/hooks/pre-push:
Make them executable:
🛠️ Commands
Install Hooks
Check Status
Uninstall Hooks
Upgrade Hooks
🔄 Workflow Example
# Make changes
vim src/main.py
# Stage changes
git add src/main.py
# Commit triggers pre-commit hook
git commit -m "feat: add user authentication"
# ✅ Syntax Check: Passed
# ✅ Linting: Passed (3 auto-fixed)
# ✅ Formatting: Passed
# [main abc1234] feat: add user authentication
# Push triggers pre-push hook
git push origin main
# ✅ Syntax Check: Passed
# ✅ Linting: Passed
# ✅ Tests: 42 passed
# ✅ Security: No issues
# Pushing to origin...
⚡ Performance Tips
Use Incremental Mode
Hooks automatically use incremental verification: - Only checks staged files (pre-commit) - Only checks commits to push (pre-push)
Skip Heavy Checks
For quick commits during development:
# .boring.toml
[boring.hooks]
pre_commit_level = "BASIC" # Fast syntax check only
pre_push_level = "STANDARD" # Save FULL for CI
Bypass When Needed
# Skip hooks (use sparingly!)
git commit --no-verify -m "WIP: work in progress"
git push --no-verify
🏢 Team Configuration
Shared Hook Config
Commit .boring.toml to share with team:
Recommended Team Settings
# .boring.toml
[boring.hooks]
pre_commit_level = "STANDARD"
pre_push_level = "FULL"
auto_fix = true
[boring.quality_gates]
min_coverage = 40
max_complexity = 15
🔧 Troubleshooting
Hook Not Running
Hook Too Slow
# .boring.toml
[boring.hooks]
pre_commit_level = "BASIC" # Faster
timeout_seconds = 60 # Add timeout
Tests Failing in Hook
See Also
- Quality Gates - CI/CD integration
- Performance - Optimization
- Pro Tips - Best practices