Permissions & Hooks: Gating the Agent
Gate a Claude agent: permission modes, disallowed_tools vs allowed_tools, deciding per call with can_use_tool, and using PreToolUse and PostToolUse hooks for audit logging and redaction.
Last updated
After this section you can
- Separate tool availability from per-call permission
- Pick a permission mode, and know why unattended runs need can_use_tool
- Deny, allow or rewrite a call from can_use_tool
- Know the two configurations that stop can_use_tool from ever firing
- Use hooks for audit logging and redaction, not only for blocking
- Scope a subagent to its own prompt, tools and context window
Permissions & Hooks: Gating the Agent
An SDK agent starts with a filesystem and a shell. Everything about making that safe is two options and one callback — plus hooks, for the things a permission cannot express.
Separate the two questions. disallowed_tools answers “may this tool exist at all”. can_use_tool answers “may this call, with these arguments, proceed” — and it can rewrite the arguments instead of just refusing.