Hooks
Deterministic control over agent behavior — run a formatter after every edit or block dangerous commands before they execute.
Overview
The most common uses: auto-running Prettier or ESLint on every file the agent edits, blocking dangerous Bash commands (rm -rf and friends) before execution, logging every operation for audits, or sending a notification when a long task completes.
A PreToolUse hook can return an exit code that blocks execution — making hooks a real security layer: your policies are enforced at the system level, not by model goodwill.
Who Is This For?
- Enforcing formatting and linting automatically on every edit
- Blocking dangerous commands or writes to sensitive files
- Keeping an audit log of all agent operations
- Notifications when long-running tasks complete
Installation
Add a hooks block to .claude/settings.json — e.g. run Prettier after every file edit (PostToolUse) or block dangerous Bash commands (PreToolUse). Configuration
{"hooks":{"PostToolUse":[{"matcher":"Edit|Write","hooks":[{"type":"command","command":"npx prettier --write "$CLAUDE_FILE_PATHS""}]}]}} Explore AI Tools
Discover the best AI tools that complement your skills
Read AI & Design Articles
Tips and trends in the world of design and AI
Related Servers
Snyk Security Scan
Detect vulnerabilities in your dependencies and application code. Get actionable remediation advice and automatic fix pull requests.
SonarQube Code Quality
Run continuous code quality and security analysis to catch bugs, code smells, and vulnerabilities before they reach production.
OWASP ZAP Security Testing
Perform automated web application security testing to find common vulnerabilities like XSS, injection flaws, and misconfigurations.