pre-commit run <hook-id>: Run a Single Hook
pre-commit run <hook-id> executes just the named hook instead of the whole suite.
When one hook is failing, run it alone to iterate faster. The id is the hook id from your config, not the repo name.
What it does
pre-commit run takes an optional hook id as a positional argument and runs only that hook. Combined with --all-files or --files it controls both which hook and which files are checked.
Common usage
pre-commit run black --all-files
pre-commit run flake8 --files src/app.py
# run a hook that lives in a specific stage
pre-commit run commitizen --hook-stage commit-msgOptions
| Flag | What it does |
|---|---|
| <hook-id> | The id field of the hook to run (positional) |
| --files <paths> | Restrict the run to specific files |
| -a / --all-files | Run against the whole repo |
| --hook-stage <stage> | Run hooks configured for that stage |
| -v / --verbose | Show output even on success |
Common errors in CI
"No hook with id <x>" means the positional argument is wrong: use the hook id from the hooks: list, not the repo url or the tool binary name. If the hook only runs at a non-default stage, add --hook-stage; otherwise pre-commit reports it as having no matching hook and the step appears to do nothing.