Hooks
Hooks
7 pre-configured hooks for Laravel code quality and security
How Hooks Work
Hooks are shell scripts that run automatically in response to Claude Code events. They enforce code quality standards, prevent security issues, and automate common tasks.
Runs before user prompts are processed (e.g., git commit)
Runs after tools like Edit/Write modify files
pre-commit.sh
UserPromptSubmitComprehensive pre-commit validation with PHP syntax, Pint formatting, PHPStan analysis, security scanning, and Blade template checks.
post-edit.sh
PostToolUseAuto-formats PHP files after edit/write operations and updates IDE helper files for better autocompletion.
security-scan.sh
PostToolUseScans for secrets, API keys, passwords, and debug functions. Detects AWS, Stripe, GitHub tokens and more.
migration-safety.sh
PostToolUseWarns about destructive migration operations like dropColumn, dropTable, and truncate. Checks for down() methods.
blade-lint.sh
PostToolUseValidates Blade templates for security and best practices. Checks CSRF tokens, XSS prevention, and directive usage.
test-runner.sh
PostToolUseAutomatically runs related tests when files are modified. Supports both Pest and PHPUnit test frameworks.
env-check.sh
PostToolUseValidates environment files and blocks .env commits. Checks for secrets in .env.example and duplicate keys.
Installation
Add hooks to your project's .claude/settings.json:
{
"hooks": {
"UserPromptSubmit": [
{
"matcher": "git commit",
"command": "bash .claude-plugins/laravel-agent/hooks/scripts/pre-commit.sh"
}
],
"PostToolUse": [
{
"matcher": "Edit",
"command": "bash .claude-plugins/laravel-agent/hooks/scripts/post-edit.sh \"$TOOL_INPUT_FILE_PATH\""
},
{
"matcher": "Write",
"command": "bash .claude-plugins/laravel-agent/hooks/scripts/post-edit.sh \"$TOOL_INPUT_FILE_PATH\""
}
]
}
}
Exit Codes
Success - all checks passed
Warning - non-blocking issues
Error - blocks the operation