🪝 Hooks
👨🍳 Cookbook
Hook configurations for different languages and frameworks
Language-specific hook configurations.
hooks:
pre-commit:
parallel: true
builtin: ["scan_secrets"]
custom:
- command: "npx eslint {staged_files} --fix"
description: "Fix ESLint issues"
glob: ["*.{js,ts,jsx,tsx}"]
stage_fixed: true
- command: "npx prettier --write {staged_files}"
description: "Format with Prettier"
glob: ["*.{js,ts,jsx,tsx,json,md}"]
stage_fixed: true
commit-msg:
builtin: ["conventional_commits"]
pre-push:
custom:
- command: "npm test"
description: "Run test suite"
fail_on_error: truehooks:
pre-commit:
parallel: true
builtin: ["scan_secrets"]
custom:
- command: "cargo fmt -- --check"
description: "Check formatting"
glob: ["*.rs"]
- command: "cargo clippy -- -D warnings"
description: "Run Clippy lints"
glob: ["*.rs"]
commit-msg:
builtin: ["conventional_commits"]
pre-push:
custom:
- command: "cargo test"
description: "Run all tests"
- command: "cargo build --release"
description: "Verify release build"hooks:
pre-commit:
parallel: true
builtin: ["scan_secrets"]
custom:
- command: "black {staged_files}"
description: "Format with Black"
glob: ["*.py"]
stage_fixed: true
- command: "ruff check {staged_files} --fix"
description: "Fix with Ruff"
glob: ["*.py"]
stage_fixed: true
- command: "mypy {staged_files}"
description: "Type check"
glob: ["*.py"]
commit-msg:
builtin: ["conventional_commits"]
pre-push:
custom:
- command: "pytest"
description: "Run pytest suite"hooks:
pre-commit:
parallel: true
builtin: ["scan_secrets"]
custom:
- command: "gofmt -w {staged_files}"
description: "Format Go code"
glob: ["*.go"]
stage_fixed: true
- command: "golangci-lint run {staged_files}"
description: "Run linters"
glob: ["*.go"]
commit-msg:
builtin: ["conventional_commits"]
pre-push:
custom:
- command: "go test ./..."
description: "Run all tests"
- command: "go build ./..."
description: "Verify build"Multi-Language Repository
For monorepos with multiple languages:
hooks:
pre-commit:
parallel: true
builtin: ["scan_secrets"]
custom:
# Rust
- command: "cargo fmt -- --check"
description: "Check Rust formatting"
glob: ["*.rs"]
# TypeScript
- command: "npx eslint {staged_files} --fix"
description: "Fix ESLint issues"
glob: ["*.{ts,tsx}"]
stage_fixed: true
# Python
- command: "black {staged_files}"
description: "Format Python"
glob: ["*.py"]
stage_fixed: true
commit-msg:
builtin: ["conventional_commits"]
pre-push:
custom:
- command: "cargo test"
description: "Run Rust tests"
- command: "npm test"
description: "Run JS tests"
- command: "pytest"
description: "Run Python tests"Framework-Specific
Next.js
hooks:
pre-commit:
parallel: true
builtin: ["scan_secrets"]
custom:
- command: "npx next lint --fix {staged_files}"
description: "Fix Next.js linting"
glob: ["*.{js,jsx,ts,tsx}"]
stage_fixed: true
- command: "npx prettier --write {staged_files}"
description: "Format files"
glob: ["*.{js,ts,jsx,tsx,json,md}"]
stage_fixed: trueDjango
hooks:
pre-commit:
parallel: true
builtin: ["scan_secrets"]
custom:
- command: "black {staged_files}"
description: "Format Python"
glob: ["*.py"]
stage_fixed: true
- command: "python manage.py check"
description: "Django system check"
pre-push:
custom:
- command: "python manage.py test"
description: "Run Django tests"Rails
hooks:
pre-commit:
parallel: true
builtin: ["scan_secrets"]
custom:
- command: "bundle exec rubocop -A {staged_files}"
description: "Auto-fix Ruby issues"
glob: ["*.rb"]
stage_fixed: true
pre-push:
custom:
- command: "bundle exec rspec"
description: "Run RSpec tests"