What are hooks in Claude Code?

Hooks are shell scripts that run before or after Claude Code performs an action, editing a file, running a Bash command, finishing a tool call. They’re your safety net.

  • PreToolUse hooks can block dangerous actions: refuse to rm -rf /, refuse to push to main branch, refuse to write into vendor/, refuse to edit prod credentials. Hook returns non-zero exit, action is cancelled, you stay safe.
  • PostToolUse hooks auto-run lint / format / tests after every file edit. phpcs + phpstan + composer validate on every Magento file change, built into the CLI, not bolted on.
  • Stop hooks run when Claude finishes a session, great for auto-committing or running test suite.

Configure hooks in .claude/settings.json. They’re the difference between “cool AI demo” and “production-grade workflow.”

Kishan Savaliya
Kishan Savaliya
Adobe Certified Magento Commerce Developer
Ahmedabad [IN]working hours, replies within four hours
When do you need it

Read personally. Never shared. Or email the brief.

More on claude code developer guide

Need it fixed, not just explained?

Send the brief with your store URL; the written quote comes back within 24 hours.