Mac automation

From aiskillstore/marketplace · View interactive version

Mac automation is an AI agent skill from the GitHub repository aiskillstore/marketplace. This skill should be used when the user requests Mac automation via AppleScript, including: Mail operations, Reminders/Calendar management, Safari control, Finder operations, system controls (volume, brightness, notifications, app launching), third-party apps (development tools, task management, med

How to use this skill

Skill file

Mac Automation via AppleScript

This skill enables control of macOS applications and system functions through AppleScript execution via the osascript command.

Core Principle

Execute AppleScript commands using the Bash tool with osascript:

osascript -e 'AppleScript code here'

For multi-line scripts:

osascript <<'EOF'
tell application "App Name"
    -- commands here
end tell
EOF

Supported Applications & Functions

1. Mail (邮件)

2. Reminders (提醒事项)

3. Calendar (日历)

4. Notification Center (通知中心)

5. Safari

6. Finder

7. System Controls (系统控制)

8. Third-Party Applications

Many third-party apps support AppleScript. Common categories include development tools (iTerm2, VS Code), task management (OmniFocus, Things), media players (Spotify), browsers (Chrome), and communication tools. To check if an app supports AppleScript, open Script Editor to browse its dictionary, or try basic commands like tell application "AppName" to get name.

Execution Guidelines

Security Considerations

  1. Permission Prompts: First-time use of certain apps triggers macOS permission dialogs. Inform user if automation fails due to permissions.
  1. Sensitive Operations: For destructive operations (delete, shutdown), confirm with user before executing.
  1. Privacy-Sensitive Data: When reading emails or calendar events, only display what user explicitly requests.

Error Handling

Common errors and solutions:

Best Practices

  1. Use exact app names: "Mail", "Reminders", "Calendar", "Safari", "Finder"
  2. Escape special characters: Use \" for quotes in strings
  3. Handle Unicode: AppleScript handles Chinese/Unicode natively
  4. Check app state: Some operations require app to be running

Quick Reference

Notifications

osascript -e 'display notification "消息内容" with title "标题"'

Open Application

osascript -e 'tell application "AppName" to activate'

Volume Control

# Get volume
osascript -e 'output volume of (get volume settings)'
# Set volume (0-100)
osascript -e 'set volume output volume 50'
# Mute
osascript -e 'set volume output muted true'

System Commands

# Get clipboard
osascript -e 'the clipboard'
# Set clipboard
osascript -e 'set the clipboard to "text"'

Additional Resources

Reference Files

For detailed AppleScript patterns by application, consult:

Example Files

Working examples in examples/:

Utility Scripts

Scripts in scripts/:

Workflow Patterns

Pattern 1: Information Retrieval

  1. Execute AppleScript to query data
  2. Parse output
  3. Present formatted results to user

Pattern 2: Action Execution

  1. Confirm action with user if destructive
  2. Execute AppleScript
  3. Verify success
  4. Report result

Pattern 3: Multi-App Automation

  1. Chain multiple AppleScript calls
  2. Pass data between calls using shell variables
  3. Handle errors at each step

Common User Requests

| User Request | Action |

|-------------|--------|

| "发送邮件给xxx" | Use Mail to create and send |

| "提醒我明天..." | Create Reminder with due date |

| "添加日历事件" | Create Calendar event |

| "打开xxx网站" | Safari open URL |

| "调低音量" | Set volume lower |

| "显示通知" | Display notification |

| "打开文件夹" | Finder reveal |

Troubleshooting

If AppleScript fails:

  1. Check app is installed
  2. Verify permissions in System Preferences
  3. Ensure app name is exact
  4. Try running app manually first
  5. Check for syntax errors in script

For permission issues, guide user to:

System Preferences > Privacy & Security > Automation

Self-Improvement Protocol

When an AppleScript execution fails or produces unexpected results, follow this protocol to improve the skill's reference documentation:

1. Error Analysis

2. Reference File Review

3. Documentation Update

When you identify a fixable issue in the reference documentation:

For incorrect examples:

For missing edge cases:

For common pitfalls:

4. Update Guidelines

Use the Edit tool to modify reference files:

Edit tool on: references/{app}-applescript.md
- Fix incorrect code examples
- Add warning notes for known issues
- Include error messages and solutions

5. Documentation Standards

When updating reference files, maintain:

6. Version Tracking

After significant improvements:

This protocol ensures the skill continuously improves based on real-world usage and errors encountered.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.