[FEATURE] Permission hook or API for remote/programmatic approval of tool use prompts

Status Fixed / completed
Maintainer reply ✓ Yes — dicksontsai
Activity 5 comments · opened Mar 24, 2026 · closed Mar 25, 2026
💡 Likely answer: A maintainer (dicksontsai, collaborator) responded on this thread — see the highlighted reply below.

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 it
  • pty.write('3\r') — same result with carriage return
  • pyautogui.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:

  1. Detect the permission prompt (working — via PTY output pattern matching)
  2. Send a push notification to the user's phone (working — Android notification with Allow/Deny buttons)
  3. Authenticate via biometric (fingerprint) on the phone for security
  4. 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)

  1. Permission hook — A PermissionRequest hook event that fires when Claude Code needs approval, with a response mechanism (HTTP callback, file-based, or stdin)
  2. Permission API endpoint — If claude serve (#37211) is implemented, include a /permissions endpoint to list pending prompts and respond to them
  3. Fix PTY stdin handling — Make the permission prompt read from normal PTY stdin so pty.write() works like keyboard input
  4. CLI flag — Something like claude --approve-via=http://localhost:7777/approve that 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

View original on GitHub ↗

5 Comments

github-actions[bot] · 6 months ago

Found 3 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/38061
  2. https://github.com/anthropics/claude-code/issues/35637
  3. https://github.com/anthropics/claude-code/issues/29827

This issue will be automatically closed as a duplicate in 3 days.

  • If your issue is a duplicate, please close it and 👍 the existing issue instead
  • To prevent auto-closure, add a comment or 👎 this comment

🤖 Generated with Claude Code

Tereseus · 6 months ago

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 ignored
  • pty.write('3\r') — same
  • Windows SendInput via pyautogui — keystroke not captured
  • All confirmed that Claude Code reads permission input through a mechanism that bypasses normal PTY stdin

The linked issues would also be resolved by any of the proposed solutions here.

dicksontsai collaborator · 6 months ago

A PermissionRequest hook event already exists. Does it cover your use case?
https://code.claude.com/docs/en/hooks#permissionrequest

Tereseus · 6 months ago

Resolved! The PermissionRequest hook works perfectly for remote/mobile approval.

The flow that works:

  1. Claude Code fires PermissionRequest hook → PAN server receives it
  2. Server stores pending permission, broadcasts to mobile phone
  3. User presses Allow/Deny on phone notification
  4. Server responds to hook with {"hookSpecificOutput": {"hookEventName": "PermissionRequest", "decision": {"behavior": "allow"}}}
  5. Claude Code proceeds — ~5 second round trip

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

github-actions[bot] · 6 months ago

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.