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 Dangerous Commands
Block Dangerous Commands
Block shell commands that could be destructive:Hook Script (Configuration:
/etc/augment/hooks/security-block-dangerous.sh):Auto-Format Code Before Editing
Auto-Format Code Before Editing
Automatically format code files using language-specific formatters (Biome, Ruff, gofmt, rustfmt) before the agent edits them.Hook Script (Configuration:Supported Formatters:
/etc/augment/hooks/auto-format.sh):Audit Sensitive File Access
Audit Sensitive File Access
Monitor when the agent accesses sensitive files:Hook Script (Configuration:
/etc/augment/hooks/audit.sh):Block Sudo Commands
Block Sudo Commands
A simple hook to block sudo commands:Hook Script (Configuration:
/etc/augment/hooks/validate-tool.sh):Load Context at Session Start
Load Context at Session Start
Inject development context when a session starts:Hook Script (Configuration:
/etc/augment/hooks/load-context.sh):Session Cleanup
Session Cleanup
Run cleanup when a session ends:Hook Script (Configuration:
/etc/augment/hooks/cleanup.sh):Block Production Database Access
Block Production Database Access
Prevent agents from accessing production systems or sensitive data:Hook Script (Configuration:
/etc/augment/hooks/block-prod.sh):Compliance Auditing
Compliance Auditing
Log all tool executions for compliance:Hook Script (Configuration:
/etc/augment/hooks/audit-log.sh):Rate Limiting MCP Tools
Rate Limiting MCP Tools
Block excessive API calls to MCP servers:Hook Script (Configuration:
/etc/augment/hooks/rate-limit.sh):Require Tests Before Finishing
Require Tests Before Finishing
Block the agent from stopping until tests are modified:Hook Script (Configuration:
/etc/augment/hooks/require-tests.sh):Advanced Configuration Patterns
These patterns show how to combine multiple hooks effectively:Multiple Hooks on Same Event
Multiple Hooks on Same Event
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.
Combining Matchers
Combining Matchers
Use multiple matcher configurations for different tools:
See Also
- Hooks - Learn how hooks work and configure them
- Permissions - Tool permission system
- Rules & Guidelines - Custom rules and guidelines