macos-automation
AppleScript, JXA, Shortcuts, Automator, osascript, System Events, accessibility API
What this skill does
# macos-automation
## Purpose
This skill automates tasks on macOS using tools like AppleScript, JXA, Shortcuts, Automator, osascript, System Events, and the accessibility API, enabling script-based control of apps and system functions.
## When to Use
- Automate repetitive workflows, such as file management or app interactions.
- Integrate with macOS apps for custom behaviors, like triggering actions via keyboard shortcuts.
- Script complex sequences involving multiple apps, e.g., when Shortcuts alone isn't sufficient.
- Handle accessibility tasks, like UI element manipulation, when apps don't expose direct APIs.
- Use for rapid prototyping of automations in environments like shell scripts or IDEs.
## Key Capabilities
- Execute AppleScript via osascript for app control, e.g., manipulating Finder or Safari.
- Run JXA (JavaScript for Automation) to interact with macOS APIs, supporting modern JavaScript syntax.
- Create and invoke Shortcuts programmatically for quick actions, like sharing files.
- Use Automator workflows as scripts, convertible to applications or services.
- Leverage System Events for UI automation, including keyboard/mouse simulation via accessibility API.
- Access macOS-specific APIs like NSAppleScript for embedding in Objective-C/Swift code.
## Usage Patterns
- Run scripts from the command line using osascript; for example, pipe AppleScript code directly.
- Embed JXA in Node.js environments by loading the JXA module and executing via `Application('Finder').activate()`.
- Chain Shortcuts with other tools by exporting as URLs and invoking via `open` command.
- Use Automator to build workflows, then save as .applescript files for osascript execution.
- For accessibility, ensure "Accessibility" is enabled in System Preferences > Security & Privacy, then use System Events to target UI elements like `tell application "System Events" to click button "OK" of window "Main"`.
- Always check for required permissions, such as Full Disk Access, before running scripts that access files.
## Common Commands/API
- **osascript CLI**: Use `osascript -e 'tell application "Finder" to make new folder at desktop'` to create a folder; handle errors by checking the exit code.
- **JXA Example**: In a JavaScript file, use `const app = Application('Safari'); app.activate(); app.documents[0].url = 'https://example.com';` to open and navigate a URL.
- **Shortcuts Integration**: Run a shortcut via `shortcuts run "My Shortcut" -i '{"input": "text"}'`; pass inputs as JSON for parameterized execution.
- **Automator API**: Convert workflows to AppleScript with `tell application "Automator" to run workflow "path/to/workflow"`.
- **System Events API**: For UI automation, use `osascript -e 'tell application "System Events" to keystroke "a" using {command down}'` to simulate Command+A.
- **Config Formats**: Store scripts in plain text files (.applescript) and invoke with `osascript path/to/script.applescript`; for JXA, use ES6 modules in .js files.
## Integration Notes
- Integrate with other tools by wrapping osascript calls in shell scripts; e.g., use `$ export APPLESCRIPT_PATH='/path/to/script'` and run via `osascript $APPLESCRIPT_PATH`.
- For JXA, require the OSA module in Node.js: `npm install osa` and use `const OSA = require('osa'); OSA.runAppleScript('...')`.
- If accessibility features are needed, set the env var `$ACCESSIBILITY_ENABLED=1` after granting permissions in System Preferences.
- Auth/keys: For scripts accessing protected resources, use env vars like `$osascript_API_KEY` (though rare); more commonly, handle macOS permissions via `tccutil` CLI, e.g., `tccutil reset AppleEvents com.example.app` to reset access.
- Embed in larger apps by compiling AppleScript into bundles or using JXA in Electron apps for cross-tool integration.
## Error Handling
- Check osascript exit codes: If a script fails, capture with `osascript -e 'script' 2>&1` and parse stderr for messages like "Execution error: ...".
- In JXA, wrap code in try-catch: `try { Application('Finder').activate(); } catch (e) { console.error(e.message); }` to handle app not found errors.
- For Shortcuts, verify with `shortcuts run "Name" --wait-for-result` and check output for failures.
- Use Automator's built-in logging by enabling in workflow settings, then review logs via Console app.
- General pattern: Always run scripts with elevated privileges if needed, e.g., via `sudo osascript -e '...'`, and handle permission errors by prompting users to adjust settings.
## Concrete Usage Examples
1. **Automate App Launch and Action**: Use osascript to open Safari and load a page: `osascript -e 'tell application "Safari" to open location "https://example.com"' followed by 'tell application "Safari" to activate'`. This is useful for daily workflows; extend by adding error checks.
2. **UI Automation with Shortcuts**: Create a Shortcut to resize windows, then invoke via CLI: `shortcuts run "Resize Window" -i '{"app": "Finder", "width": 800}'`. Combine with JXA for dynamic inputs, e.g., in a script: `Application('Shortcuts').run('Resize Window', {input: JSON.stringify({app: 'Finder'})})`.
## Graph Relationships
- Related to: macos cluster (direct parent), applescript skill (sub-skill for scripting), shortcuts skill (integrated tool), automation cluster (broader category).
- Dependencies: Requires macos-os (base system), interacts with accessibility-api skill for UI tasks.
Related in Backend & APIs
jfrog
IncludedInteract with the JFrog Platform via the JFrog CLI and REST/GraphQL APIs. Use this skill when the user wants to manage Artifactory repositories, upload or download artifacts, manage builds, configure permissions, manage users and groups, work with access tokens, configure JFrog CLI servers, search artifacts, manage properties, set up replication, manage JFrog Projects, run security audits or scans, look up CVE details, query exposures scan results from JFrog Advanced Security, manage release bundles and lifecycle operations, aggregate or export platform data, or perform any JFrog Platform administration task. Also use when the user mentions jf, jfrog, artifactory, xray, distribution, evidence, apptrust, onemodel, graphql, workers, mission control, curation, advanced security, exposures, or any JFrog product name.
cupynumeric-migration-readiness
IncludedPre-migration readiness assessor for porting NumPy to cuPyNumeric. Use BEFORE substantial porting work begins when the user asks whether code will scale on GPU, whether they should migrate to cuPyNumeric, which NumPy patterns transfer cleanly, what must be refactored before porting, or mentions pre-port assessment, scaling analysis, or refactor planning. Inspect the user's source code, look up NumPy usage, cross-reference the cuPyNumeric API support manifest, and distinguish distributed-scaling-friendly patterns from blockers such as unsupported APIs, scalar synchronization, host round-trips, Python/object-heavy control flow, shape/data-dependent branching, and in-place mutation hazards. Produce a verdict of READY, LIGHT REFACTOR, SIGNIFICANT REFACTOR, or NOT RECOMMENDED, with concrete refactor pointers.
alibabacloud-data-agent-skill
IncludedInvoke Alibaba Cloud Apsara Data Agent for Analytics via CLI to perform natural language-driven data analysis on enterprise databases. Data Agent for Analytics is an intelligent data analysis agent developed by Alibaba Cloud Database team for enterprise users. It automatically completes requirement analysis, data understanding, analysis insights, and report generation based on natural language descriptions. This tool supports: discovering data resources (instances/databases/tables) managed in DMS, initiating query or deep analysis sessions, real-time progress tracking, and retrieving analysis conclusions and generated reports. Use this Skill when users need to query databases, analyze data trends, generate data reports, ask questions in natural language, or mention "Data Agent", "data analysis", "database query", "SQL analysis", "data insights".
token-optimizer
IncludedReduce OpenClaw token usage and API costs through smart model routing, heartbeat optimization, budget tracking, and native 2026.2.15 features (session pruning, bootstrap size limits, cache TTL alignment). Use when token costs are high, API rate limits are being hit, or hosting multiple agents at scale. The 4 executable scripts (context_optimizer, model_router, heartbeat_optimizer, token_tracker) are local-only — no network requests, no subprocess calls, no system modifications. Reference files (PROVIDERS.md, config-patches.json) document optional multi-provider strategies that require external API keys and network access if you choose to use them. See SECURITY.md for full breakdown.
resend-cli
IncludedUse this skill when the task is specifically about operating Resend from an AI agent, terminal session, or CI job via the official resend CLI: installing/authenticating the CLI, sending/listing/updating/cancelling emails, batch sends, domains and DNS, webhooks and local listeners, inbound receiving, contacts, topics, segments, broadcasts, templates, API keys, profiles, or debugging Resend CLI/API failures. Trigger on mentions of Resend CLI, `resend`, `resend doctor`, `resend emails send`, `resend domains`, `resend webhooks listen`, `resend emails receiving`, or agent-friendly terminal automation.
alibabacloud-odps-maxframe-coding
IncludedUse this skill for MaxFrame SDK development and documentation navigation on Alibaba Cloud MaxCompute (ODPS). Helps answer MaxFrame API, concept, official example, and supported pandas API questions; create data processing programs; read/write MaxCompute tables; debug jobs (remote or local); and build custom DPE runtime images. Trigger when users mention MaxFrame, MaxCompute with MaxFrame, ODPS table processing, DPE runtime, MaxFrame docs/examples, DataFrame/Tensor operations, or GPU runtime setup. Works for both English and Chinese queries about Alibaba Cloud data processing with MaxFrame.