Skip to content

Add --quiet / -q flag to suppress output for passing and skipped hooks#3675

Closed
nitzan-shaked wants to merge 1 commit into
pre-commit:mainfrom
nitzan-shaked:feat/quiet-mode
Closed

Add --quiet / -q flag to suppress output for passing and skipped hooks#3675
nitzan-shaked wants to merge 1 commit into
pre-commit:mainfrom
nitzan-shaked:feat/quiet-mode

Conversation

@nitzan-shaked
Copy link
Copy Markdown

Closes #823.

Summary

This adds a --quiet / -q flag to pre-commit run (and try-repo, which shares the same arg parser). In quiet mode:

  • Per-hook output is suppressed for hooks that pass or are skipped (both SKIP= and no-files-to-check variants).
  • Failed hooks still print their full output (hook name, exit code, stdout).
  • Verbose detail lines (- hook id:, - duration:) are also suppressed for passing hooks when --quiet is set.

This is the minimal implementation discussed in the issue. The goal is to reduce noise in large monorepos where dozens of hooks are skipped on every commit.

Changes

File What changed
pre_commit/main.py Add --quiet / -q arg to _add_run_options()
pre_commit/commands/run.py Propagate quiet through _run_single_hook(); suppress output for non-failing hooks
pre_commit/commands/hook_impl.py Add quiet=False to the _ns() Namespace so the git-hook code path doesn't crash
testing/util.py Add quiet=False to run_opts() helper
tests/commands/run_test.py 5 new tests covering all quiet-mode cases

Test plan

pytest tests/commands/run_test.py -k "test_quiet"   # 5 new tests
pytest tests/commands/run_test.py                    # 102 total, 0 failures
pytest tests/commands/hook_impl_test.py              # 44 tests, 0 failures

In quiet mode, per-hook output is suppressed for hooks that pass or are
skipped (both SKIP= and no-files-to-check variants). Failed hooks still
print their full output. Verbose detail lines (hook id, duration) are
also suppressed for passing hooks when --quiet is set.

Fixes pre-commit#823.
@asottile
Copy link
Copy Markdown
Member

asottile commented May 3, 2026

ai slop is not acceptable

@asottile asottile closed this May 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Quiet mode (pre-commit install --quiet) which outputs less while running

2 participants