agentleFS
haoyiyinhaoyiyin/applescript-skill/SKILL.md

applescript

Skill2 starsChanged 8 months agoMITView on GitHub

Universal AppleScript automation for macOS. Control Chrome, Finder, Mail, Calendar, Messages, Music, Terminal, and any scriptable app. Use when asked to automate macOS apps, control browsers, manage files, send messages, or perform system actions. Triggers on "AppleScript", "osascript", "control Chrome", "automate Mac", or any macOS app automation request.

2 other projects use a version of this.

Adopted by

Most recently taken up by

  • Other versions2 projects use a version of this.

    Word for word · 0

    None found.

    Edited · 0

    None found.

    Wrote their own version · 2

    1. dannote/dot-pi★ 57same name
    2. ckqbuilds/applescriptskill★ 8same name

    How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.

The file

We split this skill into the rules it gives an agent

9 rules. About 0 are common, 9 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈9

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Always check if the target app is controllable:

    line 35
  2. Distinctive:

    If count is 0 but app should be open → restart app:

    line 45
  3. Distinctive:

    Use when app is visible to AppleScript:

    line 126
  4. Distinctive:

    Use when app is not directly controllable (multi-profile Chrome bug):

    line 134
  5. Distinctive:

    Always verify prerequisites: before executing

    line 191
  6. Distinctive:

    Use Method 1: when possible (more reliable than keyboard simulation)

    line 192
  7. Distinctive:

    Check app state: before assuming success

    line 194
  8. Distinctive:

    Never use for malicious automation (spam, fraud, etc.)

    line 204
  9. Distinctive:

    Check if an app supports AppleScript:

    line 238

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

AppleScript Skill - Universal macOS Automation

Control any scriptable macOS application via AppleScript. Works with Chrome, Finder, Mail, Calendar, Messages, Music, Terminal, and more.


How It Works

Claude → osascript → macOS App (native control)
  • Native macOS technology — built into every Mac
  • Direct app control — no web scraping, no API tokens
  • Uses existing sessions — logged-in cookies, open windows, current state
  • Undetectable — apps can't distinguish from human interaction

Prerequisites

  • macOS only (AppleScript doesn't exist on Windows/Linux)
  • For Chrome/Safari: Enable "Allow JavaScript from Apple Events" in Developer menu
  • Some apps may require Accessibility permissions

Method Detection (Run First)

Always check if the target app is controllable:

# Check if app is running
osascript -e 'tell application "System Events" to count processes whose name is "APP_NAME"'

# Check if app has windows (for browsers)
osascript -e 'tell application "APP_NAME" to return count of windows'

If count is 0 but app should be open → restart app:

osascript -e 'tell application "APP_NAME" to quit'
pkill -x "APP_NAME"
sleep 2
open -a "APP_NAME"
sleep 3

Quick Reference by App

Google Chrome / Safari

ActionCommand
Open URLtell app "Chrome" to tell active tab of first window to set URL to "https://..."
Get current URLtell app "Chrome" to tell active tab of first window to return URL
Execute JStell app "Chrome" to tell active tab of first window to execute javascript "..."
New windowtell app "Chrome" to make new window
New tabtell app "Chrome" to tell first window to make new tab with URL "..."

Finder

ActionCommand
Open foldertell app "Finder" to open folder "path/to/folder"
Create foldertell app "Finder" to make new folder at desktop with properties {name:"Test"}
List filestell app "Finder" to get name of every file of folder "path"
Move filetell app "Finder" to move file "old" to folder "new"
Delete filetell app "Finder" to delete file "path"

Mail

ActionCommand
Send emailSee references/mail.applescript
Get unread counttell app "Mail" to return unread count of inbox
Open mailboxtell app "Mail" to open inbox

Messages (iMessage)

ActionCommand
Send messagetell app "Messages" to send "Hello" to buddy "contact@email.com"
Open chattell app "Messages" to chat with "contact@email.com"

Music (iTunes)

ActionCommand
Playtell app "Music" to play
Pausetell app "Music" to pause
Next tracktell app "Music" to next track
Set volumeset volume output volume 50

Terminal

ActionCommand
Run commandtell app "Terminal" to do script "ls -la"
New tabtell app "Terminal" to tell window 1 to create tab with default profile
Get outputUse references/terminal.applescript

System

ActionCommand
Set volumeset volume output volume 50
Get volumeget volume settings
Set brightnessUse references/brightness.applescript
Sleep displaytell app "System Events" to key code 125 using {control down}

Two Methods

Method 1: Direct AppleScript (Preferred)

Use when app is visible to AppleScript:

osascript -e 'tell application "Chrome" to tell active tab of first window to set URL to "https://example.com"'

Method 2: System Events (Fallback)

Use when app is not directly controllable (multi-profile Chrome bug):

osascript -e '
tell application "System Events"
    tell process "Chrome"
        set frontmost to true
        keystroke "l" using {command down}  -- Focus address bar
        delay 0.2
        keystroke "https://example.com"
        delay 0.2
        key code 36  -- Enter
    end tell
end tell'

JavaScript Execution (for Browsers)

Simple JS (no escaping needed with JXA)

osascript -l JavaScript -e '
var chrome = Application("Google Chrome");
var tab = chrome.windows[0].activeTab;
tab.execute({javascript: "document.title = \"Hello\""});
'

Complex JS with Result (document.title trick)

# Run JS that writes result to document.title
osascript -e 'tell app "Chrome" to tell active tab of first window to execute javascript "fetch(\"/api/me\").then(r=>r.json()).then(d=>{document.title=\"R:\"+JSON.stringify(d)})"'

# Wait and read title
sleep 2
osascript -e 'tell app "Chrome" to return title of active tab of first window'

Error Handling

ErrorSolution
"Application isn't running"open -a "AppName" first
"count of windows = 0"Hard restart app (quit + pkill + open)
"Not authorized"System Preferences → Privacy → Accessibility
JS execution failsEnable "Allow JavaScript from Apple Events" in browser Dev menu
TimeoutAdd with timeout of 30 seconds wrapper

Best Practices

  1. Always verify prerequisites before executing
  2. Use Method 1 when possible (more reliable than keyboard simulation)
  3. Add delays between rapid actions (0.2-0.5s)
  4. Check app state before assuming success
  5. Handle multi-profile Chrome by restarting if windows = 0
  6. Use JXA (-l JavaScript) for complex scripts (avoids escaping hell)

Security Notes

  • AppleScript requires user permissions (Accessibility, Automation)
  • Apps can see AppleScript events (but can't distinguish from human)
  • Never use for malicious automation (spam, fraud, etc.)
  • Respect rate limits and terms of service

Examples

See references/ for complete scripts:

  • references/chrome.applescript — Browser automation patterns
  • references/finder.applescript — File management patterns
  • references/mail.applescript — Email automation patterns
  • references/messages.applescript — iMessage patterns
  • references/terminal.applescript — Terminal automation

When to Use This Skill

✅ Use this skill when:

  • User asks to control a macOS app
  • Need to automate browser actions
  • Want to send messages, emails, or notifications
  • Need to manage files via Finder
  • Want to control system settings (volume, brightness)

❌ Don't use this skill when:

  • On Windows or Linux (use computer-use MCP instead)
  • App doesn't support AppleScript (check with tell app "AppName" to get scriptable)
  • Need visual recognition (use computer-use with screenshots)

Testing Scriptability

Check if an app supports AppleScript:

osascript -e 'tell application "AppName" to get scriptable'

Or open Script Editor → File → Open Dictionary → select app.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.