Pre-Commit Hooks
ELI5 — The Vibe Check
Pre-commit hooks are scripts that run automatically before every Git commit. Lint your code, run quick tests, check for secrets — all before the commit even happens. It's like a spell checker that runs before you hit send. Catches problems at the source.
Real Talk
Pre-commit hooks are Git hooks that execute before a commit is finalized. They can run linters, formatters, type checkers, secret scanners, and lightweight tests. Managed via Husky (JS), pre-commit framework (Python), or raw shell scripts in .git/hooks/.
When You'll Hear This
"Pre-commit hooks caught an AWS key I almost committed." / "If the pre-commit hook fails, the commit is aborted — fix the issue first."
Related Terms
Git Hooks
Git Hooks are scripts that Git runs at specific moments — before commit, after push, before merge. They're like event listeners for your version control.
Husky
Husky manages Git hooks in your Node.js project. Pre-commit? Pre-push?
Lint-Staged
Lint-Staged runs linters only on files you're about to commit, not the entire project. Changed 3 files? Lint those 3.
Secret Scanning
Secret Scanning checks your code for accidentally committed passwords, API keys, and tokens. Pushed your AWS key to GitHub?