Urgent.News

What's breaking now, across thousands of outlets.

AI

5 Pitfalls I Hit Building a Daemon That Auto-Approves Claude Code's Computer Use Dialog

Last time I wrote about the morning my Wi-Fi was dead for five hours . This post is in the same "stop babysitting an unattended machine" vein: a small daemon that presses Enter on Claude Code's Computer Use approval dialog for you . My first attempt, launched from launchd, produced nothing but nine osascript timeout lines at 22-second intervals and never sent a single keystroke. Once I moved it…

This article recounts a developer's struggles while creating a daemon to automatically approve Claude Code's Computer Use approval dialog. The initial attempt using launchd to launch the daemon resulted in nine osascript timeout lines at 22-second intervals, with no keystrokes sent. Moving the daemon to run as a child process of Terminal allowed it to successfully send '\r' to the dialog within seconds.

The issue was that pressing "Allow for this session" manually each time failed since Computer Use approval dialog would reappear every time a session boundary was crossed.

The developer sought to make the approval permanent, but found no settings in settings.json or ~/.claude.json that could achieve this. The approval state lives only in session memory and vanishes when process boundaries are crossed. They also tried bypassing permissions using bypassPermissionsModeAccepted: true in ~/.claude.json, but this only suppresses the dangerous operation confirmation, not the Computer Use approval dialog.

The final solution involved writing a Python script, cu_dialog_autoallow.py, to poll Terminal tabs every 2 seconds. When the dialog string appears, the script sends '\r' to approve. To prevent misfires, the script checks which option the cursor is on before sending the Enter key. If the default cursor is on the Deny side, it skips sending Enter to avoid a denial. The script also deduplicates Enter sends per tty with an 8-second window and prevents multiple instances from running simultaneously.

A significant challenge encountered was that launching the daemon as a standalone process under launchd led to silent hangs due to AppleEvent limitations under TCC (Automation) context. The workaround was to launch the daemon as a child process of Terminal, which allowed it to successfully interact with the Computer Use dialog without hanging.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in AI

More from Saturday 19 September →