Setting up hooks for Claude Code
Failproof AI integrates with Claude Code via its hooks system. When you runfailproofai policies --install, it registers hook commands in Claude Code’s settings.json that fire on every tool call.
1
Install failproofai
2
Enable all built-in policies
3
Verify hooks are registered
PreToolUse, PostToolUse, Notification, and Stop events.4
Run Claude Code
sudo rm -rf / - it will be blocked.Setting up hooks for the Agents SDK
If you’re building with the Agents SDK, you can use the same hook system programmatically.1
Install failproofai in your project
2
Configure hooks in your agent
Pass hook commands when creating your agent process. The hooks fire the same way as in Claude Code - via stdin/stdout JSON:
3
Write a custom policy for your agent
4
Install the custom policy
Block destructive commands
The most common setup - prevent agents from doing irreversible damage.block-sudo- blocks allsudocommandsblock-rm-rf- blocks recursive file deletionblock-force-push- blocksgit push --forceblock-curl-pipe-sh- blocks piping remote scripts to shell
Prevent secret leakage
Stop agents from seeing or leaking credentials in tool output.PostToolUse - after a tool runs, they scrub the output before the agent sees it.
Get Slack alerts when agents need attention
Use the notification hook to forward idle alerts to Slack.Keep agents on a branch
Prevent agents from switching branches or pushing to protected ones.Require tests before commits
Remind agents to run tests before committing.Lock down a production repo
Commit a project-level config so every developer on your team gets the same policies. Create.failproofai/policies-config.json in your repo:
Build an org-wide quality standard with convention policies
The most impactful setup: commit.failproofai/policies/ to your repo with policies tailored to your project. Every team member gets them automatically — no install commands, no config changes.
1
Create the directory and add policies
2
Commit to git
3
Keep improving
As your team hits new failure modes, add policies and push. Everyone gets the update on their next
git pull. These policies become a living quality standard that grows with your team.More examples
Theexamples/ directory in the repo contains:

