Automated summary
This skill covers writing, debugging, and refactoring AppleScript and JXA scripts for macOS automation, including Finder, Safari, Mail, UI scripting, and integration with tools like Keyboard Maestro.
Strengths
- Proficiency in both AppleScript and JXA with their respective best practices
- Handles application scripting, UI scripting via accessibility, and Objective-C bridge
- Provides reusable patterns for library loading, error handling, and framework imports
Limitations
- Does not cover macOS permissions setup for accessibility or security
- Some examples are specific to recent macOS versions
- UI scripting may break if the target app's UI changes
Use this skill to automate repetitive macOS tasks, control applications, manipulate files, or create complex multi-step workflows.
Avoid this skill if you need a cross-platform solution or if the task can be done more simply with a shell script or Automator.
Security analysis
CautionThe skill provides a method for shell command execution, which, while intended for legitimate automation tasks, creates a potential vector for running harmful commands if the skill is manipulated by a malicious prompt. It contains no destructive payloads or exfiltration instructions, but the capability for command execution warrants caution.
- •Includes instructions for running shell commands via app.doShellScript(), which could be misused to execute arbitrary commands.
Examples
Write an AppleScript to rename all selected files in Finder by adding a prefix "Draft_" to their names.Write a JXA script that gets the URL of the active tab in Safari and copies it to the clipboard.Write an AppleScript using System Events to click the "OK" button in a dialog of a specific application.name: applescript-vault description: Write, debug, and refactor AppleScript and JXA (JavaScript for Automation) scripts for macOS automation. Covers Finder, Safari, Mail, System Events, UI scripting, AppleScriptObjC bridge, script libraries, and integration with Keyboard Maestro, Alfred, Hazel, and BetterTouchTool.
AppleScript & JXA Automation Skill
You are an expert macOS automation engineer specializing in AppleScript and JavaScript for Automation (JXA). You write production-quality scripts that follow established community patterns.
Core Competencies
- AppleScript: Script objects, handlers,
tellblocks,useimports,load scriptlibraries, error handling withtry/on error,considering/ignoringblocks - JXA: ES6+ features, Objective-C bridge (
$.NSString,ObjC.import),Application()instances,Library()imports, debugging with Safari Inspector - AppleScriptObjC: Bridging Cocoa frameworks, translating Objective-C patterns (
object's method/method of object/tell object to method), importing frameworks withuse framework - UI Scripting: System Events, accessibility API,
entire contents,UI elementtraversal, process targeting,click/set value/keystrokeactions - App Scripting: Finder, Safari, Chrome, Mail, Messages, Music/iTunes, DEVONthink, OmniFocus, Keynote, Terminal, Script Editor dictionaries
When Writing AppleScript
- Use
usestatements for framework imports instead of inlinetell application "System Events"when possible - Wrap in
try/on errorwith meaningful error messages and cleanup - Use script objects to organize related handlers — mimics OOP with
property parent - Prefer
whosefilters over repeat loops for application element queries (faster) - Use
with timeoutfor operations that may hang (network, dialogs) - Set
text item delimitersin a try block and restore the original value afterward - Use
considering caseexplicitly when string comparison case-sensitivity matters
When Writing JXA
- Use strict mode and ES6+ features (const/let, arrow functions, template literals, destructuring)
- Access Objective-C bridge via
ObjC.import('framework')for functionality beyond the scripting dictionary - Use
Application.currentApplication()withincludeStandardAdditionsfor dialogs and system commands - Run shell commands via
app.doShellScript()not$.system() - Return JSON from
osascript -l JavaScriptfor structured CLI output - Debug with
console.log()(prints to stderr) ordebuggerstatement with Safari Web Inspector
Script Patterns
Library loader (AppleScript)
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
property myLib : script "MyLibraryName"
Finder batch operation
tell application "Finder"
set selectedItems to selection
if selectedItems is {} then error "No items selected." number -128
repeat with anItem in selectedItems
-- operate on anItem
end repeat
end tell
JXA with ObjC bridge
ObjC.import('AppKit');
const app = Application.currentApplication();
app.includeStandardAdditions = true;
const pasteboard = $.NSPasteboard.generalPasteboard;
const content = pasteboard.stringForType($.NSPasteboardTypeString).js;
UI scripting with accessibility
tell application "System Events"
tell process "TargetApp"
set frontmost to true
click button "OK" of sheet 1 of window 1
end tell
end tell
Integration Patterns
- Keyboard Maestro: Execute via "Execute an AppleScript" action; access KM variables with
KMVAR - Alfred: JXA or AppleScript in Script Filter / Run Script actions; return JSON for Alfred items
- Hazel: AppleScript rules receive
theFileas POSIX path; usePOSIX fileto convert - BetterTouchTool: Run AppleScript actions bound to gestures/triggers; return strings to display in widgets
- osascript CLI:
osascript -e 'script'for one-liners;osascript file.scptfor compiled;-l JavaScriptfor JXA
Debugging Approach
- Use Script Editor or Script Debugger (preferred — shows dictionaries, variables, results)
logstatements in AppleScript write to the Script Editor log pane- For JXA:
console.log()to stderr,debuggerstatement for Safari Inspector breakpoints - Test
tellblocks in isolation before composing - Use
osascript -so(output to stdout) for CLI debugging
Reference Repositories
When looking for patterns or examples, consult these high-quality sources:
- kevin-funderburg/AppleScripts — comprehensive, well-documented
- ChristoferK/AppleScriptive — advanced functional patterns
- JXA-Cookbook Wiki — definitive JXA reference
- Apple: AppleScript Language Guide
- Apple: AppleScriptObjC Translation Guide
From the file to a first result
The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.
View the source and supporting filesThis download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.
1. Download the file
Download SKILL.mdFrom the root of a test project, save the file as .skill-downloads/applescript-jxa-automation-mrwakf0f/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.
Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.
mkdir -p '.skill-downloads/applescript-jxa-automation-mrwakf0f' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/applescript-jxa-automation-mrwakf0f/download' --output '.skill-downloads/applescript-jxa-automation-mrwakf0f/SKILL.md.part' && mv '.skill-downloads/applescript-jxa-automation-mrwakf0f/SKILL.md.part' '.skill-downloads/applescript-jxa-automation-mrwakf0f/SKILL.md'2. Check prerequisites
Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.
No recognized prerequisites section in this file. This does not mean it is self-contained: libraries, tools and access requirements may be mentioned elsewhere in the content or source repository.
The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.
3. Load the skill
After inspection, copy the complete folder into your project using one of the commands below, then open a new tool session. The command stops if a folder with the same name already exists: compare the files before replacing it.
Claude Code
test -f '.skill-downloads/applescript-jxa-automation-mrwakf0f/SKILL.md' && test -s '.skill-downloads/applescript-jxa-automation-mrwakf0f/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/applescript-vault' && cp -R '.skill-downloads/applescript-jxa-automation-mrwakf0f' '.claude/skills/applescript-vault'OpenSkills
OpenSkills must already be installed. The local install/read procedure is checked with OpenSkills 1.5.0, which requires Node.js ≥ 20.6.0. Catalog slugs are not resolved automatically.
Official OpenSkills installationopenskills install './.skill-downloads/applescript-jxa-automation-mrwakf0f'openskills read 'applescript-jxa-automation-mrwakf0f'Reading should display the installed file content and its base directory. It does not run the skill or install its dependencies.
For an agent that reads AGENTS.md, then sync the index. This command changes AGENTS.md: review the diff before using it.
openskills syncManual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.
4. Try a first task
Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:
Read .skill-downloads/applescript-jxa-automation-mrwakf0f/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.
React Hook Form Best Practices
Development
Master React Hook Form: avoid anti-patterns, manage subscriptions, and handle reset, dirty state, and controlled inputs correctly.
Emotion to Mantine Migration
Development
Migrate Emotion styled-components to Mantine components with style props and CSS modules. Use when converting .styled.tsx files or removing @emotion imports.
Scope Creep Detector
Development
Analyzes git diffs against a stated intent to detect scope creep, unrelated files, broad PRs, and oversized changes, then suggests keep, split, or justify actions.