Skip to main content
Ready-to-use examples for common scenarios. Each one shows how to install and what to expect.

Setting up hooks for Claude Code

Failproof AI integrates with Claude Code via its hooks system. When you run failproofai 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

You should see hook entries for PreToolUse, PostToolUse, Notification, and Stop events.
4

Run Claude Code

Policies now run automatically on every tool call. Try asking Claude to run 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.
What this does:
  • block-sudo - blocks all sudo commands
  • block-rm-rf - blocks recursive file deletion
  • block-force-push - blocks git push --force
  • block-curl-pipe-sh - blocks piping remote scripts to shell

Prevent secret leakage

Stop agents from seeing or leaking credentials in tool output.
These fire on 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.
Install it:

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:
Then commit it:
Every team member who has failproofai installed will automatically pick up these rules.

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

The examples/ directory in the repo contains: