.claude/skills/macos-applescript-tcc-hang/SKILL.md
Fix AppleScript hanging indefinitely when automating macOS apps (Messages, Mail, etc.) due to stale TCC (Transparency, Consent, and Control) Automation entries. Use when: (1) `osascript` hangs on `tell application "Messages"` operations like sending, counting chats, or accessing accounts, (2) Simple AppleScript like `tell app "Messages" to name` works but any operation touching accounts/chats/participants hangs forever, (3) AppleScript returns "AppleEvent timed out (-1712)" after ~2 minutes, (4) Automation that previously worked stops working after macOS update or system changes, (5) Rebooting doesn't fix the hang. The fix is `tccutil reset AppleEvents` followed by re-approving permission popups.
npx skillsauth add Dbochman/dotfiles macos-applescript-tcc-hangInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
AppleScript automation of macOS apps (especially Messages.app) hangs indefinitely or
times out with error -1712. The TCC (Transparency, Consent, and Control) database
entries for AppleEvents become stale or corrupted, causing the AppleScript scripting
bridge to block on operations that access app internals (accounts, chats, contacts)
while simple property queries (name) still work.
osascript -e 'tell application "Messages" to name' returns immediately (works)osascript -e 'tell application "Messages" to count of chats' hangs foreverosascript -e 'tell application "Messages" to send "hi" to buddy "+1..." of (1st account whose service type = iMessage)' hangs foreverexecution error: Messages got an error: AppleEvent timed out. (-1712)macOS stores AppleEvents (Automation) permissions in the TCC database at
~/Library/Application Support/com.apple.TCC/TCC.db. When entries become stale
(after macOS updates, app updates, or process identity changes), the scripting bridge
gets stuck trying to validate permissions rather than prompting for new consent.
The key insight is that the TCC subsystem doesn't cleanly fail — it hangs the AppleEvent dispatch, making the calling process block indefinitely.
tccutil reset AppleEvents
This clears ALL Automation permission entries. Every app that uses AppleScript to control other apps will need to re-authorize.
Run an AppleScript that triggers the permission prompt:
osascript -e 'tell application "Messages" to send "test" to buddy "+1XXXXXXXXXX" of (1st account whose service type = iMessage)'
Important: This must run from a context that has GUI access:
open /path/to/script.command (runs in GUI session)A system dialog will appear: "Terminal.app wants to control Messages.app" (or whatever app is calling osascript). Click OK/Allow.
Any background services (like OpenClaw gateway) that use osascript need to be
restarted so their child processes get fresh TCC authorization:
launchctl stop ai.openclaw.gateway
launchctl start ai.openclaw.gateway
The first send attempt from the service may trigger another permission popup for the service's app bundle identity.
After resetting and approving:
# Should return immediately with the message sent
osascript -e 'tell application "Messages" to send "test" to buddy "+1XXXXXXXXXX" of (1st account whose service type = iMessage)'
# Should return a number (not hang)
osascript -e 'tell application "Messages" to count of chats'
Before resetting TCC, confirm the issue is TCC-related:
# Test 1: Simple property (should work even with stale TCC)
osascript -e 'tell application "Messages" to name'
# Expected: "Messages" (instant)
# Test 2: Internal object access (hangs with stale TCC)
osascript -e 'tell application "Messages" to count of accounts'
# Expected if broken: hangs, then "AppleEvent timed out (-1712)"
# Test 3: Send attempt
osascript -e 'tell application "Messages" to send "test" to buddy "+1..." of (1st account whose service type = iMessage)'
# Expected if broken: hangs indefinitely
If Test 1 works but Test 2/3 hangs, the issue is stale TCC entries.
tccutil reset AppleEvents is a nuclear option — it resets permissions for ALL apps.
You can try resetting for a specific app first: tccutil reset AppleEvents com.apple.Terminal
but this doesn't always work for the scripting bridge.osascript call must originate from a process
that macOS associates with a GUI-capable app bundle. Using open -jg script.command
from a LaunchAgent runs the script in the Aqua session where permission dialogs can appear.op read TCC hang (which is Mach port / Security framework
based) — see skill 1password-cli-launchd-hang.chat id AppleScript path (for group chats) is affected the same way as the buddy
path (for DMs) — both hang when TCC is stale.development
Search the web for current information, news, facts, and answers. Use when asked questions about current events, needing to look something up, finding websites, researching topics, or when you need up-to-date information beyond your training data.
development
Summarize any URL, YouTube video, podcast, PDF, or file into concise text. Use when asked to read an article, summarize a link, get the gist of a video or podcast, extract content from a URL, or when you need to understand what a web page or document contains.
development
Play music via Spotify and control Google Home speakers. Use when asked to play music, songs, artists, playlists, podcasts, or control speakers/volume/audio.
testing
Create new OpenClaw skills, modify and improve existing skills, and measure skill performance with evals. Use when users want to create a skill from scratch, update or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy. Also use when asked to "make a skill", "turn this into a skill", "improve this skill", or "test this skill".