Skip to content
Latchkey

pre-commit run: Gate CI Config Linters

pre-commit run --all-files executes your configured hooks, including actionlint and yamllint, giving one command to lint workflow and pipeline config in a PR gate.

Rather than invoking each CI-config linter separately, register them as pre-commit hooks and run them together. This page focuses on the CI-config linting use; for hook-authoring and error details see the existing pre-commit modules.

What it does

pre-commit reads .pre-commit-config.yaml, installs each hook's isolated environment, and runs the hooks against changed files (or all files). Hooks like rhysd/actionlint, adrienverge/yamllint, and zizmorcore/zizmor-pre-commit cover CI config.

Common usage

Terminal
pre-commit run --all-files
pre-commit run actionlint --all-files      # run a single hook
pre-commit run --files .github/workflows/ci.yml
pre-commit run --show-diff-on-failure

Options

FlagWhat it does
--all-filesRun hooks on every file, not just staged ones
<hook-id>Run only the named hook (e.g. actionlint)
--files <paths>Run against specific files
--show-diff-on-failurePrint the diff when an autofix hook changes files
--hook-stage <stage>Run hooks for a specific stage (e.g. manual)

In CI

Run pre-commit run --all-files in a PR job so contributors without hooks installed still get gated. Pin each hook rev to a tag or SHA so the linter version is reproducible. See the pre-commit modules for cache and network-fetch behavior in CI.

Common errors in CI

A failing hook prints its own errors then - hook id: actionlint and - exit code: 1. Files were modified by this hook from an autofix hook fails CI by design; re-commit the changes. command not found: pre-commit means it is not installed (pip install pre-commit).

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →