pre-commit manages automated checks that run before a Git commit is created.
It helps detect problems early and keeps repository checks consistent across development environments.
The tool is installed through Homebrew and declared in the project Brewfile.
It is part of the curated Homebrew environment; see Homebrew setup to install everything at once.
Verify the installation:
pre-commit --versionThe hooks used by this repository are declared in:
.pre-commit-config.yaml
Install the Git hooks locally after cloning the repository:
pre-commit installThe configuration declares default_install_hook_types, so a plain
pre-commit install wires up both hook types at once:
.git/hooks/pre-commit # quality checks (shellcheck, gitleaks, …)
.git/hooks/commit-msg # commit-msg-lint (gitmoji + Conventional Commits)
The generated Git hooks are local to the repository and are not committed.
Run the hooks against staged files:
pre-commit runRun all hooks against every tracked file:
pre-commit run --all-filesValidate the configuration file:
pre-commit validate-configUpdate hook revisions:
pre-commit autoupdateAny revision update must be reviewed and tested before being committed.
Gitleaks is enabled as the first repository hook.
It scans committed content for secrets such as:
- API keys;
- access tokens;
- passwords;
- private credentials.
Run only the Gitleaks hook:
pre-commit run gitleaks --all-filesGitleaks is an additional safety layer. Secrets must still never be deliberately added to the repository.
Beyond the built-in hooks, the configuration runs ShellCheck (shell scripts), markdownlint-cli2 (Markdown), lychee (link checking), editorconfig-checker, and Actionlint (GitHub Actions workflows). Gitleaks runs as a secret scanner.
On the commit-msg stage, the scripts/lint-commit-msg.sh shell linter
validates the commit message against the gitmoji + Conventional Commits format
(see docs/git/gitmoji.md).
Hadolint (Dockerfiles) is intentionally not enabled yet: the repository has no Dockerfiles for it to validate. Hooks are only added once relevant files exist.
Reinstall the local Git hook:
pre-commit uninstall
pre-commit installClear cached hook environments:
pre-commit cleanRun hooks with verbose output:
pre-commit run --all-files --verboseRemove the local Git hook:
pre-commit uninstallRestore the committed configuration if needed:
git restore .pre-commit-config.yaml