Guardy
🪝 Hooks

🔗 Hook Types

Git hook types that are supported by Guardy Hooks

pre-commit

Runs before each commit is created. Use for:

  • Secret scanning
  • Code formatting
  • Linting
  • Running tests on changed files
hooks:
  pre-commit:
    parallel: true
    builtin: ["scan_secrets"]
    custom:
      - command: "cargo fmt -- --check"
        description: "Check Rust formatting"
        glob: ["*.rs"]

commit-msg

Validates commit messages. Use for:

  • Enforcing conventional commits
  • Checking message format
  • Adding issue references
hooks:
  commit-msg:
    builtin: ["conventional_commits"]
    custom:
      - command: "grep -qE '^[A-Z]+-[0-9]+' {commit_msg_file}"
        description: "Ensure JIRA ticket reference"

pre-push

Runs before pushing to remote. Use for:

  • Running full test suite
  • Building the project
  • Final security checks
hooks:
  pre-push:
    custom:
      - command: "cargo test"
        description: "Run all tests"
      - command: "cargo build --release"
        description: "Verify release build"

post-checkout

Runs after checking out a branch. Use for:

  • Installing dependencies
  • Updating database schemas
  • Cleaning build artifacts
hooks:
  post-checkout:
    custom:
      - command: "pnpm install"
        description: "Install dependencies"
        when: "package.json changed"

post-merge

Runs after a merge. Use for:

  • Updating dependencies
  • Running migrations
  • Rebuilding assets
hooks:
  post-merge:
    custom:
      - command: "make migrate"
        description: "Run database migrations"

Best Practices

  1. Start Simple - Begin with secret scanning, add more over time
  2. Use Parallel - Enable for faster execution
  3. Stage Fixed Files - Auto-stage formatted files
  4. Test Locally - Use guardy hooks run before committing
  5. Document Bypasses - Explain when/why to skip hooks
  6. Monitor Performance - Move slow checks to pre-push