Running Your First Hook¶
Install the hooks¶
This command:
- Creates a
.githooks/directory with universal hook scripts for each event defined in your configuration. - Runs
git config core.hooksPath .githooksso Git uses these scripts.
Important
The .githooks/ directory should be committed to version control. The scripts are universal — they never need to be regenerated after config changes.
Test it¶
Make a commit and watch GitHooks run your configured QA tools:
If all checks pass, the commit proceeds. If any check fails, the commit is blocked and you see the errors.
Run manually¶
You don't need to commit to run your QA tools. Use the CLI directly:
githooks flow qa # Run a flow (group of jobs)
githooks flow qa --fast # Only analyze staged files
githooks flow qa --only-jobs=phpstan_src # Run specific jobs from a flow
githooks flow qa --dry-run # Show commands without executing
githooks job phpstan_src # Run a single job
githooks job phpstan_src --format=json # JSON output for CI and AI integration
githooks job phpunit_all -- --filter=testFoo # Pass extra args to the tool
Check hook status¶
Shows which hooks are installed and whether they're synchronized with your configuration:
- synced — installed and matches configuration.
- missing — configured but not installed (run
githooks hookto fix). - orphan — installed but not in configuration.
Automate installation¶
Add the hook installation to your composer.json so every team member gets hooks automatically:
"scripts": {
"post-update-cmd": [
"vendor/bin/githooks hook"
],
"post-install-cmd": [
"vendor/bin/githooks hook"
]
}
PHP < 8.1
If you already have the ComposerUpdater script for PHP < 8.1, combine both:
Legacy mode (Git < 2.9)¶
If your environment doesn't support core.hooksPath, use legacy mode:
This copies hook scripts directly to .git/hooks/ instead.
What's next?¶
You have a working setup. From here you can:
- Learn the configuration in depth — hooks, flows, jobs, and all keywords.
- Explore the supported tools — each tool's options and examples.
- Set up parallel execution — speed up your QA runs.
- Add conditional hooks — run different tools on different branches.