macOS automation patterns — AppleScript/osascript, accessibility, clipboard, notifications, window management. Use when automating macOS system tasks.
Reference for controlling and automating macOS from the command line.
osascript -e 'display notification "Message" with title "Assistant" sound name "Ping"'
echo "text" | pbcopy # Copy
pbpaste # Paste
open "https://example.com" # URL in default browser
open -a "Calculator" # Launch app
open -R /path/to/file # Reveal in Finder
osascript -e 'tell application "Safari" to activate'
osascript -e 'tell application "System Events" to get name of first process whose frontmost is true'
Many automation features require Accessibility access:
Works without permissions: notifications, dialogs, clipboard, Finder scripting, open command.