What the PermissionRequest Hook Does in Claude Code
The PermissionRequest hook is the Claude Code hook that runs at the exact moment a permission prompt would appear. It lets a script answer the prompt (allow or deny) or step aside and let the prompt show. That makes it the right place to send permission decisions somewhere other than the terminal. This guide explains when it fires, what it receives, what it can return and how it differs from PreToolUse, based on Anthropic's hooks documentation, and then shows how a service can sit behind it.
When the PermissionRequest hook fires
Claude Code hooks are commands the harness runs on lifecycle events. The docs describe PermissionRequest as firing when a tool call needs a permission decision. In other words, it runs only when the permission system would otherwise ask.
That is narrower than PreToolUse, which runs before every matched tool call. If a command is already allowed by a rule, PreToolUse still fires and PermissionRequest does not. If the session is in a mode that never asks, there is nothing for it to answer.
The docs also say the hook fires in sessions that cannot show a prompt, such as non-interactive runs and background subagents. In those sessions, if nothing returns a decision, the tool call is denied.
What the hook receives
Like every hook, it gets a JSON object on standard input with common fields such as session_id, cwd, permission_mode and hook_event_name. The event-specific fields are:
tool_name: for exampleBash,EditorWebFetch.tool_input: the arguments, such as the command string or file path.mcp_server: present for MCP tools.permission_suggestions: an optional list of suggested permission updates.
A minimal script that looks at the command:
#!/usr/bin/env bash
input=$(cat)
tool=$(echo "$input" | jq -r '.tool_name')
cmd=$(echo "$input" | jq -r '.tool_input.command // empty')
What the hook can return
The hook output is JSON on standard output. To decide, print a decision object inside hookSpecificOutput.
Allow:
{
"hookSpecificOutput": {
"hookEventName": "PermissionRequest",
"decision": { "behavior": "allow" }
}
}
Deny, with a message Claude will read. The docs show only the allow example; this shape follows from their field table (behavior, and message for deny only), and it is what Forkit's own hook prints:
{
"hookSpecificOutput": {
"hookEventName": "PermissionRequest",
"decision": {
"behavior": "deny",
"message": "Migrations on staging need Ben's approval."
}
}
}
Per the docs:
updatedInput(allow only) replaces the tool's input, so a hook can rewrite a command before allowing it.updatedPermissions(allow only) applies permission updates.message(deny only) tells Claude why. A good message lets the agent try another route instead of asking again.interrupt(deny only), when true, stops Claude.
To make no decision, print nothing and exit 0. In an interactive session the normal permission prompt then appears. This is the important safety property: a hook that fails, times out or has no opinion leaves the built-in behaviour in place.
Two details that are easy to get wrong. Exit code 2 does not deny here; the docs say a PermissionRequest hook that exits 2 without a decision object leaves the flow unchanged. And an "allow" from the hook does not override a matching deny or ask rule in your settings; those are still evaluated.
PermissionRequest vs PreToolUse
PreToolUse |
PermissionRequest |
|
|---|---|---|
| Fires | Before every matched tool call | Only when a prompt would appear |
| Decision field | hookSpecificOutput.permissionDecision |
hookSpecificOutput.decision.behavior |
| Values | allow, deny, ask, defer |
allow, deny |
| Exit code 2 | Blocks the call | Ignored |
| Best for | Hard rules that apply always | Answering the permission prompt |
Use PreToolUse for "never edit .env", which should hold even where the tool is allowed. Use PermissionRequest for "someone should answer this prompt", because it runs exactly when there is a prompt to answer, and its silence falls back to the prompt.
Registering the hook
Hooks are configured in a settings file. An entry looks like this:
{
"hooks": {
"PermissionRequest": [
{
"hooks": [
{ "type": "command", "command": "~/.claude/hooks/ask.sh", "timeout": 120 }
]
}
]
}
}
The docs give a default timeout of 600 seconds for command hooks. Set your own to match how long you are willing to wait for an answer.
What to build on it
A local policy script. Allow known-safe commands, deny known-bad ones, stay silent on the rest. This overlaps with allow and deny rules in settings, which are simpler for static patterns. A script earns its place when the decision needs logic: the current branch, the time of day, the contents of a file.
A remote approver. The script sends the request to a service, waits for an answer and prints it. This is how a permission prompt can be answered from another device or by another person.
A logger. Record every prompt and how it was answered, to find which rules to write next.
How Forkit uses the hook
Forkit's Claude Code integration registers a PermissionRequest hook. When it fires:
- The hook posts the request to Forkit: tool, command or path, repository, branch, session.
- Forkit checks command rules. A matching deny always wins; a matching allow answers at once.
- If an owner has set an orchestrator agent, and the tool is one it may answer, the orchestrator can decide.
- Otherwise the request waits for a person, in the web inbox or
forkit watch. They can allow once, allow for an hour, always allow (which adds a rule) or deny with a note. - The hook long-polls for the answer for
FORKIT_PERMISSION_WAITseconds, 90 by default. - With an answer, the hook prints the allow or deny JSON shown above. A denial's note becomes the
message. - With no answer, the hook withdraws the request and prints nothing, so Claude Code shows its own prompt.
Requests that touch production, secrets or money skip steps 2 and 3 and go straight to a person. For agents with no terminal (fan-out agents in sandboxes, or any agent with FORKIT_ON_TIMEOUT=deny), step 7 records a denial instead.
While a request is pending, the session's thread is in the waiting state and sits at the top of the inbox, because the agent is stopped.
Things to watch for
- Allow rules upstream. If your settings already allow a command, the hook never sees it. That is correct, but it surprises people testing a new hook.
- Bypass modes. With permission prompts skipped, there are no requests.
- Timeouts. A hook timeout shorter than your wait means the hook is killed before it can answer.
- Deny rules still apply. An allow from a hook cannot beat a deny rule.
- Messages are read by the model. Write deny messages as instructions the agent can act on.
Codex has a hook with the same name; see the Codex hooks guide. For the wider picture, see Claude Code permission modes compared and how to approve Claude Code remotely.
Where Forkit fits
Forkit is a ready-made service behind the PermissionRequest hook: shared rules, an optional orchestrator, a person, and a fallback to the normal prompt. npx forkit-cli init registers it. It is free to try. More at forkit-mcp.com.