CLI Reference¶
prek¶
Better pre-commit, re-engineered in Rust
Usage
Commands
prek install
Install the prek git hook
prek install-hooks
Create hook environments for all hooks used in the config file
prek run
Run hooks
prek list
List available hooks
prek uninstall
Uninstall the prek git hook
prek validate-config
Validate
.pre-commit-config.yaml
filesprek validate-manifest
Validate
.pre-commit-hooks.yaml
filesprek sample-config
Produce a sample
.pre-commit-config.yaml
fileprek auto-update
Auto-update pre-commit config to the latest repos' versions
prek gc
Clean unused cached repos
prek clean
Clean out pre-commit files
prek init-template-dir
Install hook script in a directory intended for use with
git config init.templateDir
prek try-repo
Try the pre-commit hooks in the current repo
prek self
prek
self management
prek install¶
Install the prek git hook
Usage
Arguments
- HOOK|PROJECT
Include the specified hooks or projects.
Supports flexible selector syntax:
-
hook-id
: Run all hooks with the specified ID across all projects -
project-path/
: Run all hooks from the specified project -
project-path:hook-id
: Run only the specified hook from the specified project
Can be specified multiple times to select multiple hooks/projects.
-
Options
--allow-missing-config
Allow a missing
pre-commit
configuration file--cd
,-C
dirChange to directory before running
--color
colorWhether to use color in output
May also be set with the
PREK_COLOR
environment variable.[default: auto]
Possible values:
auto
: Enables colored output only when the output is going to a terminal or TTY with supportalways
: Enables colored output regardless of the detected environmentnever
: Disables colored output
--config
,-c
configPath to alternate config file
--help
,-h
Display the concise help for this command
--hook-type
,-t
hook-type--install-hooks
Create hook environments for all hooks used in the config file
--no-progress
Hide all progress outputs.
For example, spinners or progress bars.
--overwrite
,-f
Overwrite existing hooks
--quiet
,-q
Do not print any output
--refresh
Refresh all cached data
--skip
hook|projectSkip the specified hooks or projects.
Supports flexible selector syntax:
-
hook-id
: Skip all hooks with the specified ID across all projects -
project-path/
: Skip all hooks from the specified project -
project-path:hook-id
: Skip only the specified hook from the specified project
Can be specified multiple times. Also accepts
PREK_SKIP
orSKIP
environment variables (comma-delimited).-
--verbose
,-v
Use verbose output
--version
,-V
Display the prek version
prek install-hooks¶
Create hook environments for all hooks used in the config file.
This command does not install the git hook. To install the git hook along with the hook environments in one command, use prek install --install-hooks
.
Usage
Arguments
- HOOK|PROJECT
Include the specified hooks or projects.
Supports flexible selector syntax:
-
hook-id
: Run all hooks with the specified ID across all projects -
project-path/
: Run all hooks from the specified project -
project-path:hook-id
: Run only the specified hook from the specified project
Can be specified multiple times to select multiple hooks/projects.
-
Options
--cd
,-C
dirChange to directory before running
--color
colorWhether to use color in output
May also be set with the
PREK_COLOR
environment variable.[default: auto]
Possible values:
auto
: Enables colored output only when the output is going to a terminal or TTY with supportalways
: Enables colored output regardless of the detected environmentnever
: Disables colored output
--config
,-c
configPath to alternate config file
--help
,-h
Display the concise help for this command
--no-progress
Hide all progress outputs.
For example, spinners or progress bars.
--quiet
,-q
Do not print any output
--refresh
Refresh all cached data
--skip
hook|projectSkip the specified hooks or projects.
Supports flexible selector syntax:
-
hook-id
: Skip all hooks with the specified ID across all projects -
project-path/
: Skip all hooks from the specified project -
project-path:hook-id
: Skip only the specified hook from the specified project
Can be specified multiple times. Also accepts
PREK_SKIP
orSKIP
environment variables (comma-delimited).-
--verbose
,-v
Use verbose output
--version
,-V
Display the prek version
prek run¶
Run hooks
Usage
Arguments
- HOOK|PROJECT
Include the specified hooks or projects.
Supports flexible selector syntax:
-
hook-id
: Run all hooks with the specified ID across all projects -
project-path/
: Run all hooks from the specified project -
project-path:hook-id
: Run only the specified hook from the specified project
Can be specified multiple times to select multiple hooks/projects.
-
Options
--all-files
,-a
Run on all files in the repo
--cd
,-C
dirChange to directory before running
--color
colorWhether to use color in output
May also be set with the
PREK_COLOR
environment variable.[default: auto]
Possible values:
auto
: Enables colored output only when the output is going to a terminal or TTY with supportalways
: Enables colored output regardless of the detected environmentnever
: Disables colored output
--config
,-c
configPath to alternate config file
--directory
,-d
dirRun hooks on all files in the specified directories.
You can specify multiple directories. It can be used in conjunction with
--files
.--dry-run
Do not run the hooks, but print the hooks that would have been run
--files
filesSpecific filenames to run hooks on
--from-ref
,--source
,-s
from-refThe original ref in a
<from_ref>...<to_ref>
diff expression. Files changed in this diff will be run through the hooks--help
,-h
Display the concise help for this command
--hook-stage
hook-stageThe stage during which the hook is fired
[default: pre-commit]
Possible values:
manual
commit-msg
post-checkout
post-commit
post-merge
post-rewrite
pre-commit
pre-merge-commit
pre-push
pre-rebase
prepare-commit-msg
--last-commit
Run hooks against the last commit. Equivalent to
--from-ref HEAD~1 --to-ref HEAD
--no-progress
Hide all progress outputs.
For example, spinners or progress bars.
--quiet
,-q
Do not print any output
--refresh
Refresh all cached data
--show-diff-on-failure
When hooks fail, run
git diff
directly afterward--skip
hook|projectSkip the specified hooks or projects.
Supports flexible selector syntax:
-
hook-id
: Skip all hooks with the specified ID across all projects -
project-path/
: Skip all hooks from the specified project -
project-path:hook-id
: Skip only the specified hook from the specified project
Can be specified multiple times. Also accepts
PREK_SKIP
orSKIP
environment variables (comma-delimited).-
--to-ref
,--origin
,-o
to-refThe destination ref in a
from_ref...to_ref
diff expression. Defaults toHEAD
iffrom_ref
is specified--verbose
,-v
Use verbose output
--version
,-V
Display the prek version
prek list¶
List available hooks
Usage
Arguments
- HOOK|PROJECT
Include the specified hooks or projects.
Supports flexible selector syntax:
-
hook-id
: Run all hooks with the specified ID across all projects -
project-path/
: Run all hooks from the specified project -
project-path:hook-id
: Run only the specified hook from the specified project
Can be specified multiple times to select multiple hooks/projects.
-
Options
--cd
,-C
dirChange to directory before running
--color
colorWhether to use color in output
May also be set with the
PREK_COLOR
environment variable.[default: auto]
Possible values:
auto
: Enables colored output only when the output is going to a terminal or TTY with supportalways
: Enables colored output regardless of the detected environmentnever
: Disables colored output
--config
,-c
configPath to alternate config file
--help
,-h
Display the concise help for this command
--hook-stage
hook-stageShow only hooks that has the specified stage
Possible values:
manual
commit-msg
post-checkout
post-commit
post-merge
post-rewrite
pre-commit
pre-merge-commit
pre-push
pre-rebase
prepare-commit-msg
--language
languageShow only hooks that are implemented in the specified language
Possible values:
conda
coursier
dart
docker
docker-image
dotnet
fail
golang
haskell
lua
node
perl
python
r
ruby
rust
swift
pygrep
script
system
--no-progress
Hide all progress outputs.
For example, spinners or progress bars.
--output-format
output-formatThe output format
[default: text]
Possible values:
text
json
--quiet
,-q
Do not print any output
--refresh
Refresh all cached data
--skip
hook|projectSkip the specified hooks or projects.
Supports flexible selector syntax:
-
hook-id
: Skip all hooks with the specified ID across all projects -
project-path/
: Skip all hooks from the specified project -
project-path:hook-id
: Skip only the specified hook from the specified project
Can be specified multiple times. Also accepts
PREK_SKIP
orSKIP
environment variables (comma-delimited).-
--verbose
,-v
Use verbose output
--version
,-V
Display the prek version
prek uninstall¶
Uninstall the prek git hook
Usage
Options
--cd
,-C
dirChange to directory before running
--color
colorWhether to use color in output
May also be set with the
PREK_COLOR
environment variable.[default: auto]
Possible values:
auto
: Enables colored output only when the output is going to a terminal or TTY with supportalways
: Enables colored output regardless of the detected environmentnever
: Disables colored output
--config
,-c
configPath to alternate config file
--help
,-h
Display the concise help for this command
--hook-type
,-t
hook-type--no-progress
Hide all progress outputs.
For example, spinners or progress bars.
--quiet
,-q
Do not print any output
--refresh
Refresh all cached data
--verbose
,-v
Use verbose output
--version
,-V
Display the prek version
prek validate-config¶
Validate .pre-commit-config.yaml
files
Usage
Arguments
- CONFIG
The path to the configuration file
Options
--cd
,-C
dirChange to directory before running
--color
colorWhether to use color in output
May also be set with the
PREK_COLOR
environment variable.[default: auto]
Possible values:
auto
: Enables colored output only when the output is going to a terminal or TTY with supportalways
: Enables colored output regardless of the detected environmentnever
: Disables colored output
--config
,-c
configPath to alternate config file
--help
,-h
Display the concise help for this command
--no-progress
Hide all progress outputs.
For example, spinners or progress bars.
--quiet
,-q
Do not print any output
--refresh
Refresh all cached data
--verbose
,-v
Use verbose output
--version
,-V
Display the prek version
prek validate-manifest¶
Validate .pre-commit-hooks.yaml
files
Usage
Arguments
- MANIFEST
The path to the manifest file
Options
--cd
,-C
dirChange to directory before running
--color
colorWhether to use color in output
May also be set with the
PREK_COLOR
environment variable.[default: auto]
Possible values:
auto
: Enables colored output only when the output is going to a terminal or TTY with supportalways
: Enables colored output regardless of the detected environmentnever
: Disables colored output
--config
,-c
configPath to alternate config file
--help
,-h
Display the concise help for this command
--no-progress
Hide all progress outputs.
For example, spinners or progress bars.
--quiet
,-q
Do not print any output
--refresh
Refresh all cached data
--verbose
,-v
Use verbose output
--version
,-V
Display the prek version
prek sample-config¶
Produce a sample .pre-commit-config.yaml
file
Usage
Options
--cd
,-C
dirChange to directory before running
--color
colorWhether to use color in output
May also be set with the
PREK_COLOR
environment variable.[default: auto]
Possible values:
auto
: Enables colored output only when the output is going to a terminal or TTY with supportalways
: Enables colored output regardless of the detected environmentnever
: Disables colored output
--config
,-c
configPath to alternate config file
--file
,-f
fileWrite the sample config to a file (
.pre-commit-config.yaml
by default)--help
,-h
Display the concise help for this command
--no-progress
Hide all progress outputs.
For example, spinners or progress bars.
--quiet
,-q
Do not print any output
--refresh
Refresh all cached data
--verbose
,-v
Use verbose output
--version
,-V
Display the prek version
prek auto-update¶
Auto-update pre-commit config to the latest repos' versions
Usage
Options
--bleeding-edge
Update to the bleeding edge of the default branch instead of the latest tagged version
--cd
,-C
dirChange to directory before running
--color
colorWhether to use color in output
May also be set with the
PREK_COLOR
environment variable.[default: auto]
Possible values:
auto
: Enables colored output only when the output is going to a terminal or TTY with supportalways
: Enables colored output regardless of the detected environmentnever
: Disables colored output
--config
,-c
configPath to alternate config file
--freeze
Store "frozen" hashes in
rev
instead of tag names--help
,-h
Display the concise help for this command
--jobs
,-j
jobsNumber of threads to use
[default: 3]
--no-progress
Hide all progress outputs.
For example, spinners or progress bars.
--quiet
,-q
Do not print any output
--refresh
Refresh all cached data
--repo
repoOnly update this repository. This option may be specified multiple times
--verbose
,-v
Use verbose output
--version
,-V
Display the prek version
prek gc¶
Clean unused cached repos
Usage
Options
--cd
,-C
dirChange to directory before running
--color
colorWhether to use color in output
May also be set with the
PREK_COLOR
environment variable.[default: auto]
Possible values:
auto
: Enables colored output only when the output is going to a terminal or TTY with supportalways
: Enables colored output regardless of the detected environmentnever
: Disables colored output
--config
,-c
configPath to alternate config file
--help
,-h
Display the concise help for this command
--no-progress
Hide all progress outputs.
For example, spinners or progress bars.
--quiet
,-q
Do not print any output
--refresh
Refresh all cached data
--verbose
,-v
Use verbose output
--version
,-V
Display the prek version
prek clean¶
Clean out pre-commit files
Usage
Options
--cd
,-C
dirChange to directory before running
--color
colorWhether to use color in output
May also be set with the
PREK_COLOR
environment variable.[default: auto]
Possible values:
auto
: Enables colored output only when the output is going to a terminal or TTY with supportalways
: Enables colored output regardless of the detected environmentnever
: Disables colored output
--config
,-c
configPath to alternate config file
--help
,-h
Display the concise help for this command
--no-progress
Hide all progress outputs.
For example, spinners or progress bars.
--quiet
,-q
Do not print any output
--refresh
Refresh all cached data
--verbose
,-v
Use verbose output
--version
,-V
Display the prek version
prek init-template-dir¶
Install hook script in a directory intended for use with git config init.templateDir
Usage
Arguments
- DIRECTORY
The directory in which to write the hook script
Options
--cd
,-C
dirChange to directory before running
--color
colorWhether to use color in output
May also be set with the
PREK_COLOR
environment variable.[default: auto]
Possible values:
auto
: Enables colored output only when the output is going to a terminal or TTY with supportalways
: Enables colored output regardless of the detected environmentnever
: Disables colored output
--config
,-c
configPath to alternate config file
--help
,-h
Display the concise help for this command
--hook-type
,-t
hook-typeWhich hook type to install
Possible values:
commit-msg
post-checkout
post-commit
post-merge
post-rewrite
pre-commit
pre-merge-commit
pre-push
pre-rebase
prepare-commit-msg
--no-allow-missing-config
Assume cloned repos should have a
pre-commit
config--no-progress
Hide all progress outputs.
For example, spinners or progress bars.
--quiet
,-q
Do not print any output
--refresh
Refresh all cached data
--verbose
,-v
Use verbose output
--version
,-V
Display the prek version
prek try-repo¶
Try the pre-commit hooks in the current repo
Usage
Arguments
- HOOK|PROJECT
Include the specified hooks or projects.
Supports flexible selector syntax:
-
hook-id
: Run all hooks with the specified ID across all projects -
project-path/
: Run all hooks from the specified project -
project-path:hook-id
: Run only the specified hook from the specified project
Can be specified multiple times to select multiple hooks/projects.
-
Options
--all-files
,-a
Run on all files in the repo
--cd
,-C
dirChange to directory before running
--color
colorWhether to use color in output
May also be set with the
PREK_COLOR
environment variable.[default: auto]
Possible values:
auto
: Enables colored output only when the output is going to a terminal or TTY with supportalways
: Enables colored output regardless of the detected environmentnever
: Disables colored output
--config
,-c
configPath to alternate config file
--directory
,-d
dirRun hooks on all files in the specified directories.
You can specify multiple directories. It can be used in conjunction with
--files
.--dry-run
Do not run the hooks, but print the hooks that would have been run
--files
filesSpecific filenames to run hooks on
--from-ref
,--source
,-s
from-refThe original ref in a
<from_ref>...<to_ref>
diff expression. Files changed in this diff will be run through the hooks--help
,-h
Display the concise help for this command
--hook-stage
hook-stageThe stage during which the hook is fired
[default: pre-commit]
Possible values:
manual
commit-msg
post-checkout
post-commit
post-merge
post-rewrite
pre-commit
pre-merge-commit
pre-push
pre-rebase
prepare-commit-msg
--last-commit
Run hooks against the last commit. Equivalent to
--from-ref HEAD~1 --to-ref HEAD
--no-progress
Hide all progress outputs.
For example, spinners or progress bars.
--quiet
,-q
Do not print any output
--refresh
Refresh all cached data
--show-diff-on-failure
When hooks fail, run
git diff
directly afterward--skip
hook|projectSkip the specified hooks or projects.
Supports flexible selector syntax:
-
hook-id
: Skip all hooks with the specified ID across all projects -
project-path/
: Skip all hooks from the specified project -
project-path:hook-id
: Skip only the specified hook from the specified project
Can be specified multiple times. Also accepts
PREK_SKIP
orSKIP
environment variables (comma-delimited).-
--to-ref
,--origin
,-o
to-refThe destination ref in a
from_ref...to_ref
diff expression. Defaults toHEAD
iffrom_ref
is specified--verbose
,-v
Use verbose output
--version
,-V
Display the prek version
prek self¶
prek
self management
Usage
Commands
prek self update
Update prek
prek self update¶
Update prek
Usage
Arguments
- TARGET_VERSION
Update to the specified version. If not provided, prek will update to the latest version
Options
--cd
,-C
dirChange to directory before running
--color
colorWhether to use color in output
May also be set with the
PREK_COLOR
environment variable.[default: auto]
Possible values:
auto
: Enables colored output only when the output is going to a terminal or TTY with supportalways
: Enables colored output regardless of the detected environmentnever
: Disables colored output
--config
,-c
configPath to alternate config file
--help
,-h
Display the concise help for this command
--no-progress
Hide all progress outputs.
For example, spinners or progress bars.
--quiet
,-q
Do not print any output
--refresh
Refresh all cached data
--token
tokenA GitHub token for authentication. A token is not required but can be used to reduce the chance of encountering rate limits
May also be set with the
GITHUB_TOKEN
environment variable.--verbose
,-v
Use verbose output
--version
,-V
Display the prek version