Skip to main content

Example Hooks

Here are practical examples of hooks you can use in your projects. Each example includes the hook script and the corresponding configuration.
Block shell commands that could be destructive:Hook Script (/etc/augment/hooks/security-block-dangerous.sh):
Configuration:
Automatically format code files using language-specific formatters (Biome, Ruff, gofmt, rustfmt) before the agent edits them.Hook Script (/etc/augment/hooks/auto-format.sh):
Configuration:
Supported Formatters:
Monitor when the agent accesses sensitive files:Hook Script (/etc/augment/hooks/audit.sh):
Configuration:
A simple hook to block sudo commands:Hook Script (/etc/augment/hooks/validate-tool.sh):
Configuration:
Inject development context when a session starts:Hook Script (/etc/augment/hooks/load-context.sh):
Configuration:
Run cleanup when a session ends:Hook Script (/etc/augment/hooks/cleanup.sh):
Configuration:
Prevent agents from accessing production systems or sensitive data:Hook Script (/etc/augment/hooks/block-prod.sh):
Configuration:
Log all tool executions for compliance:Hook Script (/etc/augment/hooks/audit-log.sh):
Configuration:
Block excessive API calls to MCP servers:Hook Script (/etc/augment/hooks/rate-limit.sh):
Configuration:
Block the agent from stopping until tests are modified:Hook Script (/etc/augment/hooks/require-tests.sh):
Configuration:

Advanced Configuration Patterns

These patterns show how to combine multiple hooks effectively:
Execute multiple hooks in order for the same event:
If any hook returns exit code 2, execution is blocked and subsequent hooks are not run.
Use multiple matcher configurations for different tools:

See Also