From ef83ef1d8cda38ab346e3674c4f6b824139067c7 Mon Sep 17 00:00:00 2001 From: Matthew Hughes Date: Thu, 26 Mar 2026 20:48:48 +0000 Subject: [PATCH] Document `PRE_COMMIT` environment variable Document this variable, exposed since `v2.5.0`[1], as a way to determine if `pre-commit` is running. Because It took a bit of searching in the `pre-commit` repo to discover the existence of this variable. Link: https://github.com/pre-commit/pre-commit/commit/2f25085d60bf953fea457a3240c91886145dbcc5 [1] --- sections/new-hooks.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sections/new-hooks.md b/sections/new-hooks.md index 587ccfd5..7f21d439 100644 --- a/sections/new-hooks.md +++ b/sections/new-hooks.md @@ -4,6 +4,9 @@ installable package (gem, npm, pypi, etc.) or exposes an executable, it can be used with pre-commit. Each git repo can support as many languages/hooks as you want. +_new in 2.5.0_: `pre-commit` sets the `PRE_COMMIT=1` environment variable +during hook execution. + The hook must exit nonzero on failure or modify files. A git repo containing pre-commit plugins must contain a `.pre-commit-hooks.yaml`