You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If I understand the current flow correctly, the UI would no show the permission requests unless there are already permissions pre-approved for this action. This means if there are not enough permissions I have to manually edit them.
Moreover the interface would confusingly report that the action is completed successfully, even though it didn't
And this is what shows up in the log:
📄 Parsed JSON response: {
type: 'result',
subtype: 'success',
is_error: false,
duration_ms: 11677,
duration_api_ms: 14838,
num_turns: 50,
result: 'I need permission to create a README file. Would you like me to create it?',
session_id: '53bb8ff4-889c-4474-987e-6e3cbe14f0f7',
total_cost_usd: 0.35889380000000004,
usage: {
input_tokens: 8,
cache_creation_input_tokens: 372,
cache_read_input_tokens: 20123,
output_tokens: 20,
server_tool_use: { web_search_requests: 0 },
service_tier: 'standard',
cache_creation: { ephemeral_1h_input_tokens: 0, ephemeral_5m_input_tokens: 372 }
},
permission_denials: [
{
tool_name: 'Write',
tool_use_id: 'toolu_01XxURFzPvy6Dav6RiGABhq4',
tool_input: [Object]
}
],
uuid: '5437b78d-9312-4a1d-82b0-8b5fe876a60f'
}
Claude CLI process exited with code 0
Maybe I'm missing something, but it seems like there is no way to handle this permission denial via the stream-json interface.
#!/bin/bash
# PreToolUse hook for Claude Code - forwards requests to backend via Unix socket
# Read input from stdin
hook_input=$(cat)
# Forward to backend via Unix socket (message already includes session_id)
curl -s \
--unix-socket "${SOCKET_PATH:-/tmp/pre-tool-use-hooks.sock}" \
-X POST \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $AUTH_TOKEN" \
-d "$hook_input" \
"http://localhost/hook/permission" \
--max-time 300 \
--fail-with-body || {
echo '{"hookSpecificOutput": {"hookEventName": "PreToolUse", "permissionDecision": "deny", "permissionDecisionReason": "Failed to connect to approval server"}}'
}
Now when claude would need permissions, it would communicate with the app via socket (or http, doesn't matter). Subsequently this would trigger websocket message to the user that an approval is required, which can be shown in the UI. When the user replies, curl command returns and now claude knows it can proceed.
What do you think about implementing that? Or is there is some other obvious way to handle this, which I'm missing?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
If I understand the current flow correctly, the UI would no show the permission requests unless there are already permissions pre-approved for this action. This means if there are not enough permissions I have to manually edit them.
Moreover the interface would confusingly report that the action is completed successfully, even though it didn't
And this is what shows up in the log:
Maybe I'm missing something, but it seems like there is no way to handle this permission denial via the stream-json interface.
One way I found to handle this is to use
PreToolUse
hook https://docs.anthropic.com/en/docs/claude-code/hooks#pretooluse-decision-controlI've implemented a small prototype locally, which works like this.
First, I define a hook in
~/.claude/settings.json
:Now when claude would need permissions, it would communicate with the app via socket (or http, doesn't matter). Subsequently this would trigger websocket message to the user that an approval is required, which can be shown in the UI. When the user replies,
curl
command returns and now claude knows it can proceed.What do you think about implementing that? Or is there is some other obvious way to handle this, which I'm missing?
Beta Was this translation helpful? Give feedback.
All reactions