[FEATURE] Permission hook or API for remote/programmatic approval of tool use prompts
Summary
When Claude Code runs inside a PTY (e.g., via node-pty in a web-based terminal dashboard), there is no programmatic way to respond to permission prompts. This blocks building remote approval workflows such as mobile app approval, CI/CD pipelines, or team-based authorization.
Problem
Claude Code's permission prompt ("Do you want to proceed? 1. Yes 2. Yes 3. No") cannot be answered via pty.write(). Characters written to the PTY stdin appear in the terminal output but are not consumed by the permission handler. This has been tested with:
pty.write('1')— character echoes to terminal but prompt ignores itpty.write('3\r')— same result with carriage returnpyautogui.hotkey('3')via Windows SendInput API — keystroke not captured- Direct HTTP API →
sendToSession()→session.pty.write()— same behavior
The permission prompt appears to read input through a mechanism that bypasses normal PTY stdin, making it impossible for any external process to respond.
Use Case
I'm building PAN — a personal AI operating system with an Android app, web dashboard, and Node.js server. Claude Code runs in PTY sessions served via WebSocket to a browser-based xterm.js terminal.
When Claude needs permission approval, I want to:
- Detect the permission prompt (working — via PTY output pattern matching)
- Send a push notification to the user's phone (working — Android notification with Allow/Deny buttons)
- Authenticate via biometric (fingerprint) on the phone for security
- Send the approval back to Claude Code (broken — no method works)
This would be more secure than the current keyboard-only approach since it adds biometric authentication as a factor.
Proposed Solutions (any of these would work)
- Permission hook — A
PermissionRequesthook event that fires when Claude Code needs approval, with a response mechanism (HTTP callback, file-based, or stdin) - Permission API endpoint — If
claude serve(#37211) is implemented, include a/permissionsendpoint to list pending prompts and respond to them - Fix PTY stdin handling — Make the permission prompt read from normal PTY stdin so
pty.write()works like keyboard input - CLI flag — Something like
claude --approve-via=http://localhost:7777/approvethat delegates permission decisions to an external service
Environment
- Windows 11, Claude Code CLI (Max subscription)
- PTY via node-pty 1.1.0, terminal via xterm.js 5.5.0
- Also tested with pyautogui SendInput (OS-level keystroke injection)
---
Built with PAN — Personal AI Network
5 Comments
Found 3 possible duplicate issues:
This issue will be automatically closed as a duplicate in 3 days.
🤖 Generated with Claude Code
Not a duplicate — this issue specifically documents that
pty.write()cannot interact with permission prompts at all (characters echo but are not consumed), which is the root cause behind #38061 and #35637.Those issues report the symptom (prompts don't propagate remotely). This issue identifies the technical root cause and proposes concrete solutions (permission hook, API endpoint, or fixing PTY stdin handling).
We tested exhaustively:
pty.write('1')— echoes but ignoredpty.write('3\r')— sameThe linked issues would also be resolved by any of the proposed solutions here.
A
PermissionRequesthook event already exists. Does it cover your use case?https://code.claude.com/docs/en/hooks#permissionrequest
Resolved! The
PermissionRequesthook works perfectly for remote/mobile approval.The flow that works:
{"hookSpecificOutput": {"hookEventName": "PermissionRequest", "decision": {"behavior": "allow"}}}The key was the response format — needs
hookSpecificOutput.decision.behavior, not just{behavior: "allow"}.Thank you for pointing us to the PermissionRequest hook — we searched for it and couldn't find it initially. This completely solves the remote approval problem.
Built with PAN — Personal AI Network
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.