/mac:jxafrom mac
Reference for writing JXA (JavaScript for Automation) scripts run through `osascript -l JavaScript`. Covers ES5 constraints, `run(argv)`, and the `Application()` bridge.
Ships in mac. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description, though model invocation is off: only you can start it.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
JavaScript for Automation (JXA) automates macOS apps via the Application() bridge. It runs on JavaScriptCore (ES5).
var (not let/const).map(), .filter(), .forEach())run() (not an object)// WRONG: JXA arrays don't have .map()
// var names = app.windows().map(function(w) { return w.name(); });
// CORRECT: use a for-loop
var windows = app.windows();
var names = [];
for (var i = 0; i < windows.length; i++) {
names.push(windows[i].name());
}
Script files define a function run(argv) entry point. osascript calls it and prints the return value. The function must be named run, not _run.
#!/usr/bin/env osascript -l JavaScript
function run(argv) {
var finder = Application("Finder");
var items = finder.desktop.items();
var names = [];
for (var i = 0; i < items.length; i++) {
names.push(items[i].name());
}
return JSON.stringify(names);
}
properties() for batch reads instead of individual getters.whose() for filtering when the app supports it (pushes work to the app)Application.currentApplication() accesses the current app contextsdef /Applications/AppName.appWhat SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub bendrucker/claude --plugin mac2 skills in this plugin
Other plugins' skills for the same job