The Claude Code PermissionRequest hook runs when Claude Code is about to show you a permission prompt. It receives the tool name and input as JSON on stdin and can answer by printing a decision object with behavior allow or deny; exit code 2 is ignored on this event. It can approve requests for you, which is exactly why it should be used with a narrow matcher or not at all for approvals.
The Claude Code PermissionRequest hook is the hook event that fires at the exact moment Claude Code is about to ask you for permission to use a tool. A hook on this event can answer the prompt for you (allow or deny), or simply observe it and let the normal prompt appear. It is the most direct way to plug your own logic, or another app, into Claude Code's permission flow.
This guide covers when the hook fires, what it receives, how it answers, and why letting a script approve requests deserves more caution than most hooks. For the general mechanics of hooks, read the Claude Code hooks guide first.
When does the PermissionRequest hook fire?
In Claude Code, PermissionRequest runs when Claude Code is about to prompt you for permission to use a tool. It does not run for every tool call: calls already covered by an allow rule, calls blocked by a deny rule, and calls that your permission mode approves never reach a prompt, so the hook never sees them.
A few details from the official reference:
- It also runs when Claude Code would otherwise auto-deny a call that cannot prompt.
- It does not run for a sandboxed command's network request. For that prompt, use a
Notificationhook with thepermission_prompttype. - In a non-interactive
claude -prun with no permission prompt tool or callback, outsidedontAskmode, a call that would prompt is denied unless something approves it, such as aPermissionRequesthook.
Compare this with PreToolUse, which fires before every matching tool call, whether or not a prompt would follow. If you want to block something everywhere, PreToolUse is the better fit. If you want to react only when a human decision is actually needed, PermissionRequest is the right event. The permission prompt glossary entry explains what the prompt itself contains.
What input does the PermissionRequest hook receive?
A Claude Code PermissionRequest hook receives the common hook fields (session_id, transcript_path, cwd, permission_mode, hook_event_name) plus:
tool_name: the tool Claude wants to use, such asBash,Editor an MCP tool name.tool_input: the tool's arguments, for example thecommandfor Bash or thefile_pathfor an edit.mcp_server: present for MCP tools.permission_suggestions: an optional array of suggested permission updates. The docs note that it is not an exact list of the options shown to you.
Unlike PreToolUse, the input has no tool_use_id. A minimal example for a Bash request looks like this:
{
"session_id": "abc123",
"cwd": "/Users/you/myproject",
"hook_event_name": "PermissionRequest",
"permission_mode": "default",
"tool_name": "Bash",
"tool_input": {
"command": "npm run lint"
}
}The matcher for this event is the tool name, using the same rules as other tool events: Bash, Edit|Write, or a regex such as mcp__.*.
How does a PermissionRequest hook answer allow or deny?
A Claude Code PermissionRequest hook answers by exiting 0 and printing a JSON object with a decision inside hookSpecificOutput. Exit code 2 is not read as a decision on this event, so the JSON is the only way to grant or refuse.
The decision fields:
| Field | Used with | Effect |
|---|---|---|
behavior | always | "allow" grants the permission, "deny" refuses it |
updatedInput | allow | Replaces the tool's whole input object |
updatedPermissions | allow | Permission updates to apply, such as a mode change |
message | deny | Tells Claude why the request was refused |
interrupt | deny | If true, stops Claude |
An allow that also rewrites the command:
{
"hookSpecificOutput": {
"hookEventName": "PermissionRequest",
"decision": {
"behavior": "allow",
"updatedInput": {
"command": "npm run lint"
}
}
}
}A deny with a reason Claude can act on:
{
"hookSpecificOutput": {
"hookEventName": "PermissionRequest",
"decision": {
"behavior": "deny",
"message": "Network installs are not allowed in this repo. Use the vendored packages."
}
}
}If the hook prints nothing and exits 0, Claude Code shows the normal prompt. That "no opinion" path is the safe default for any hook that only wants to observe, log or forward the request.
Some tools that require user interaction, such as ExitPlanMode, need updatedInput with the allow, or Claude Code ignores the allow and still shows the prompt. The official hooks guide uses exactly this case as its example:
{
"hooks": {
"PermissionRequest": [
{
"matcher": "ExitPlanMode",
"hooks": [
{
"type": "command",
"command": "jq -c '{hookSpecificOutput: {hookEventName: \"PermissionRequest\", decision: {behavior: \"allow\", updatedInput: .tool_input}}}'"
}
]
}
]
}
}When this hook approves, the transcript shows "Allowed by PermissionRequest hook" where the dialog would have been.
What limits apply to a hook's allow?
A hook's allow in Claude Code does not override everything. Per the official docs, a hook in a settings file or plugin cannot loosen restrictions past what permission rules allow: deny rules from settings still apply, and some prompts cannot be suppressed by a hook, including reads from network paths and MCP tools marked as requiring user interaction.
Through updatedPermissions, a hook can also switch the session's permission mode, for example to acceptEdits with destination: "session". Switching to bypassPermissions only works if the session was started with bypass mode available. For background on the modes, see Claude Code permission modes.
Why is automating approvals with this hook risky?
A PermissionRequest hook that returns allow answers on your behalf, silently, every time it matches. The official guide warns that matching .* or leaving the matcher empty would auto-approve every permission prompt, including file writes and shell commands. That is the same outcome as skipping permissions, just harder to notice.
The concrete risks:
- Prompt injection. A README, issue or web page can contain instructions that push the agent to run a command. The permission prompt is often the last point where a person reads that command. A script that approves by pattern cannot judge intent. See prompt injection.
- String matching is fragile. A rule like "allow anything starting with
npm" also allowsnpm install some-unknown-packagewith its install scripts. - Silent failure modes. If your hook crashes or times out, you want the result to be "ask the human", never "allow". Writing hooks that fail closed takes care.
- Shared configs. A permissive hook committed to
.claude/settings.jsonapplies to everyone who trusts the folder.
Safer patterns: use the hook to deny or to forward, and let a person decide. Use allow rules in settings for the small set of commands you really trust, as described in how to allow commands in Claude Code. If you must auto-approve, scope the matcher to one tool and validate tool_input strictly. The auto approve risks post goes deeper.
Answering permission requests from the menu bar
The PermissionRequest hook is also how you can answer a prompt without switching to the terminal. Allowbar, a Mac menu bar app for Claude Code and Codex, registers its own hook entries in ~/.claude/settings.json (leaving your other hooks alone) and receives events on a small local server on your Mac.
When a request arrives, a Dynamic Island style panel slides down from the top of the screen with the project, the tool and the exact command. You pick Allow, Block, or Terminal to send the question back to the terminal. A ring counts down, and when it runs out the question goes back to the terminal.
Allowbar is built around the risks described above: it never approves anything on its own, has no rules that approve for you, and treats a missing answer as "ask in the terminal", never as approval. Commands your own allow rules already cover do not show up at all. It is Mac only (macOS 14 or later) and works with Claude Code and Codex.
Allowbar is in private beta. Join the waitlist; the launch price is $9.99 instead of $29.90.
Sources:
Frequently asked questions
What is the difference between PreToolUse and PermissionRequest?
PreToolUse fires before every matching tool call and can block with exit code 2 or a deny decision in every permission mode. PermissionRequest fires only when Claude Code is about to show you a permission prompt, and answers with a decision object. Use PreToolUse for hard rules and PermissionRequest to handle actual prompts.
Can a PermissionRequest hook block with exit code 2?
No. Claude Code does not read exit code 2 as a decision on this event. To refuse, exit 0 and print a decision with behavior: "deny", optionally with a message for Claude.
What happens if my PermissionRequest hook prints nothing?
Claude Code shows the normal permission prompt in the terminal. Printing nothing is the right behavior for hooks that only log or notify.
Does the PermissionRequest hook fire for commands I already allowed?
No. Calls matched by your allow rules, or approved by the current permission mode, never reach a prompt, so the hook does not run for them.
Is it safe to auto-approve everything with this hook?
No. An empty or .* matcher that returns allow approves every file write and shell command without you seeing it, which removes the main defense against mistakes and prompt injection. Keep humans in the loop for anything outside a short, trusted list.