Skip to content
Latchkey

pre-commit run --all-files: Lint Everything in CI

pre-commit run --all-files executes all configured hooks across the entire repository, not just staged changes.

This is the canonical way to run pre-commit in a pipeline. By default pre-commit only sees staged files; --all-files makes it check the whole tree so CI catches everything.

What it does

pre-commit run executes the configured hooks. With --all-files it ignores the git staging area and passes every file in the repo to each hook, which is what you want in CI where nothing is staged.

Common usage

Terminal
pre-commit run --all-files
# print the diff a fixer made so the failure is actionable
pre-commit run --all-files --show-diff-on-failure
# force color in CI logs
pre-commit run --all-files --color always

Options

FlagWhat it does
-a / --all-filesRun hooks against every file in the repo
--show-diff-on-failurePrint the diff when a hook modifies files
--color <when>always, never, or auto (force color in CI logs)
-v / --verbosePrint hook output even when it passes
--files <paths>Run only against the listed files instead of all

In CI

Cache ~/.cache/pre-commit keyed on the hash of .pre-commit-config.yaml so hook environments are not rebuilt each run. Add --show-diff-on-failure so when an autofixing hook (black, prettier) changes files, the log shows exactly what would have been committed. Many hooks fail the job by exiting non-zero after they rewrite files.

Common errors in CI

A green local commit but a red CI run usually means CI ran --all-files while your commit only checked staged files; an old file finally got linted. "files were modified by this hook" with exit code 1 is a fixer (black, isort) rewriting code: the run "fails" so you commit the fix. The first CI run logs "[INFO] Initializing environment for ..." while it builds hook envs; that is normal, not an error.

Related guides

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