Skip to content
Latchkey

pre-commit fail_fast: Stop at the First Failure

fail_fast tells pre-commit to stop running hooks as soon as one fails instead of running them all.

By default pre-commit runs every hook and reports all failures together. fail_fast short-circuits on the first failure, which can speed up tight local loops.

What it does

Set fail_fast: true at the top level (or on a single hook) and pre-commit aborts the run after the first hook that fails, skipping the rest. Without it, every hook runs so you see all problems in one pass.

Common usage

.pre-commit-config.yaml
fail_fast: true
repos:
  - repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v4.6.0
    hooks:
      - id: check-yaml
      - id: end-of-file-fixer

Keys

KeyWhat it does
fail_fast (top-level)Stop the whole run on the first failure
fail_fast (per-hook)Stop if this specific hook fails
default: falseRun all hooks and report every failure

In CI

In CI the usual preference is fail_fast: false (the default) so one run surfaces every issue, avoiding a fix-one-rerun-find-next loop that burns pipeline minutes. Reserve fail_fast for local use or for an ordered chain where a later hook is meaningless if an earlier one failed.

Common errors in CI

fail_fast is not an error source itself, but it can hide failures: a red CI run shows only the first failing hook, so engineers fix it, rerun, and hit the next one. If your pipeline seems to fail "one new way each time", check for fail_fast: true and consider turning it off for CI.

Related guides

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