#1051·prek

Add support for automatic re-commit after formatter hooks (Black/Ruff)

Author: RajitRoyCreated Nov 9, 2025Updated Sep 13, 2026
Labelsidea

Currently, when using formatter hooks such as Black or Ruff, the commit process is interrupted:

  1. The formatter modifies files.
  2. The commit fails due to file changes.
  3. The user must manually stage and re-commit.

This behavior is understandable, but it can disrupt workflow efficiency, especially for purely formatting-related hooks.

Proposal: Please consider introducing an option (for example, --auto-fix-continue) or a configuration flag that automatically re-stages the modified files and continues the commit process after successful formatting.

Rationale:

  • Helps reduce repetitive manual steps when formatters are used as part of the hook chain.
  • Maintains a seamless and efficient commit flow.
  • Provides a smoother experience for new or less experienced developers, who may otherwise be confused by commit interruptions after automatic formatting.
  • Keeps behavior configurable for users who prefer strict pre-commit validation.

Example Workflow:

bash
# Current behavior
git commit -m "refactor utils"
# → Black runs, modifies files
# → Commit fails
# → User must git add . && git commit again

# Proposed behavior
git commit -m "refactor utils"
# → Black runs, modifies files
# → Prek automatically re-stages changes and continues the commit
# → Commit succeeds without interruption

Additional Suggestion: It would be great if this could be implemented as a per-hook configuration option, allowing only specific tools (e.g., formatters like Black or Ruff) to auto-fix and continue, while other hooks (e.g., linters, tests) retain the standard failure behavior.