What You’ll Learn
What the pre-commit hook does and why it matters
The exact shell script used across these projects
How to process only staged files (fast, under 2 seconds)
Auto-installing the hook via composer post-autoload-dump
Bypassing the hook when necessary
The Problem with “I’ll Fix It Later”
Code review catches things. CI catches things. But both happen after the commit is made. The feedback loop is: write code → commit → push → wait for CI → fix → re-push. Each cycle is minutes to hours.
The pre-commit hook closes that loop to seconds. Before a commit is recorded, it runs Rector and Pint on only the files you changed. If Rector updates code patterns and Pint fixes formatting, those changes are added to your commit automatically.…