Use this checklist when adding a hook. The repo has three categories; pick the one that matches your tool and copy the closest existing hook as a starting point.
- Static binary download — upstream ships per-platform release binaries.
Start from
hooks/_template/. Reference:hooks/shfmt/. - Toolchain wrapper — tool ships with a language runtime the project
already requires. Reference:
hooks/gleam-format/. - JVM JAR — distributed as a JAR on Maven Central or a GitHub release.
Reference:
hooks/ktfmt/.
- Create
hooks/<id>/with:run.sh(executable,set -euo pipefail, sourceslib/platform.sh,lib/download.sh, and/orlib/jvm.shas appropriate).version.txt(single line, just the version, e.g.0.51).checksums.txtfor category 1/3 — one line per(os, arch)asset.README.mddescribing the hook.tests/ok.<ext>andtests/bad.<ext>fixtures.
chmod +x hooks/<id>/run.sh.- Add an entry to
.pre-commit-hooks.yamlwithid,name,description,entry: hooks/<id>/run.sh,language: script, file/type matchers, and defaultargs. - Add a pytest module
tests/test_<id>.pycovering at minimum:- success: hook exits 0 against
tests/ok.<ext>. - failure: hook exits non-zero against
tests/bad.<ext>. - idempotency: running against an already-formatted file leaves it untouched (where applicable).
- success: hook exits 0 against
- Add a row to the hook table in
README.md(move from "planned" to "stable" when shipped). - Add a
## [Unreleased]bullet inCHANGELOG.md. - Add a per-hook page under
docs/hooks/<id>.md. - Run
task lint && task test. - Verify
prek try-repo . <id> --all-filesworks locally.
- For category 1/3 hooks, populate real sha256 values from the upstream
release page in the same PR that introduces the hook. Do not ship a hook
with placeholder zeros —
download_toolrefuses to use them. - Renovate bumps
version.txtautomatically. The release engineer updateschecksums.txtin the same PR.