Pre-commit Hooks

Use Azath with the pre-commit framework for managing git hooks across multiple languages and tools.


Why Use Pre-commit Framework?

While Azath's built-in azath init is sufficient for most projects, the pre-commit framework offers:

  • Multi-language hook support
  • Automatic hook updates
  • Consistent configuration across team
  • Integration with other tools (linters, formatters)

Installation

1. Install Pre-commit

pip install pre-commit
# or
brew install pre-commit

2. Create Configuration

Add Azath to your .pre-commit-config.yaml:

repos:
  - repo: https://github.com/BabalolaBrainiac/azath
    rev: v0.3.0
    hooks:
      - id: azath-scan

3. Install Hooks

pre-commit install

Available Hooks

Hook IDDescription
azath-scanScan staged files (pre-commit)
azath-scan-allDeep scan entire repo
azath-checkCheck specific files

Configuration Examples

Scan with Arguments

repos:
  - repo: https://github.com/BabalolaBrainiac/azath
    rev: v0.3.0
    hooks:
      - id: azath-scan
        args: ['--strict']

Multiple Hooks

repos:
  - repo: https://github.com/BabalolaBrainiac/azath
    rev: v0.3.0
    hooks:
      # Pre-commit scan
      - id: azath-scan
        stages: [commit]
      
      # Pre-push deep scan
      - id: azath-scan-all
        stages: [push]
        args: ['--summary']

Complete Example

repos:
  # General hooks
  - repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v4.5.0
    hooks:
      - id: trailing-whitespace
      - id: end-of-file-fixer
      - id: check-yaml
      - id: check-added-large-files

  # Language-specific hooks
  - repo: https://github.com/psf/black
    rev: 23.12.0
    hooks:
      - id: black

  # Azath secret scanning
  - repo: https://github.com/BabalolaBrainiac/azath
    rev: v0.3.0
    hooks:
      - id: azath-scan
        stages: [commit]

Manual Run

Test pre-commit hooks without committing:

# Run all hooks on all files
pre-commit run --all-files

# Run only Azath
pre-commit run azath-scan

# Run on specific files
pre-commit run azath-scan --files src/config.js

Comparison

Featureazath initPre-commit Framework
SetupOne commandConfig file + install
UpdatesManualAutomatic
Multi-languageNoYes
Team ConsistencyGoodExcellent