The glue code for Apple Shortcuts.

GlueJS adds a Run JavaScript action to Shortcuts. Describe what you want to an AI coding agent like Claude or ChatGPT; it writes the script and the shortcut together, and you install it with one tap.

Code where Shortcuts gets clumsy

Shortcuts is great at triggers and device data. It's painful at loops, JSON, math and APIs. GlueJS handles exactly that part, and nothing else.

Shortcuts brings the data

Health, Calendar, Location, the share sheet, other apps' actions. Shortcuts handles those permissions. GlueJS only asks for Local Network access when a script needs it.

Real JavaScript, fast

Weeks of Health samples crunched in milliseconds. Top-level await, modern syntax, npm packages bundled ahead of time.

Web APIs and your home

fetch any HTTPS API, or devices on your home network like Home Assistant.

Keys that stay put

Scripts get a stand-in for each API key. GlueJS inserts the real value only for the sites you allowed.

Widgets

Publish a number or a short list to a home-screen widget, and let it refresh itself on a schedule.

A run log that explains failures

Every run from every shortcut: input, output, console and the exact line that failed. Run it again in one tap.

How it works

  1. Tell your coding agent (Claude Code, or ChatGPT’s Codex) what you want: “a button that logs my workout and a widget with my streak.”
  2. It writes a small script and the shortcut around it, tests it on your Mac, and builds a signed shortcut file.
  3. Open the file and tap Add Shortcut. It syncs to your iPhone.
  4. Run it once, then automate it in Shortcuts.

What you need

  • An iPhone with iOS 18 or later and GlueJS.
  • A Mac (macOS 12 or later, signed into iCloud) with an AI coding agent that can run commands on it: Claude Code (Claude) or Codex (ChatGPT). The agent installs the gluejs-ios tools from npm.
  • For the Apple Intelligence examples: an iPhone that supports it, with iOS 26 or later.
// Did It: log today, keep a streak widget
const logged = new Set(Store.get('habit:Workout') ?? []);
logged.add(today);
Store.set('habit:Workout', [...logged]);

const streak = daysInARow(logged, today);
Widget.set('Workout', {
  title: 'Workout',
  value: `🔥 ${streak} days`,
});
return `${streak} days in a row!`;

What people build

Small, specific things no big app will ever make for you. Each one is a sentence to your coding agent; it writes the script and the shortcut, and you tap Add Shortcut. Your agent can start from any of them.

Location trigger

What the gym really costs

“Every time I arrive at the gym, log it and show what each visit is costing me this month.”

🏋️ 9 visits
$5.00 per visit · last month 6 ($7.50 each)
How it works
  1. WhenArrive at the gymShortcuts automation
  2. Shortcuts getsMembership priceText in the shortcut
  3. GlueJSLog the visit, work out cost per visitStore; ignores repeat arrivals
  4. ThenWidget + notificationSilent on repeat arrivals
Steps
A location automation runs the shortcut when you arrive. GlueJS adds the visit to its Store (arriving twice within 3 hours counts once, because GPS can fire more than once) and divides your membership by this month's visits.
Connects to
Nothing. It works offline.
You'll be asked
Once: allow Shortcuts to use your location for the automation, and allow the shortcut to run GlueJS.
Leaves your phone
Nothing. Your location is only used by iOS to trigger the automation; GlueJS never sees it.
Calendar + Health + Weather

When should I run today?

“Each morning, find the best hour to run: when I'm free, it's light, dry and not too hot. Show my miles this week too.”

🏃 6pm–7pm
66°F, 0% rain · 12.4 mi this week
How it works
  1. WhenAlarm stoppedShortcuts automation
  2. Shortcuts getsToday's calendarCalendar
  3. Shortcuts getsThis week's distanceApple Health
  4. Shortcuts getsHourly forecast and sunsetApple Weather
  5. GlueJSFind the best free daylight hourRain, temperature, your calendar
  6. ThenWidget + notification
Steps
Shortcuts reads today's events from Calendar, your walking + running distance from Health, and the hourly forecast and sunset from Apple Weather. GlueJS removes hours you're busy or it's dark, scores the rest on rain and temperature, and adds up this week's distance.
Connects to
Nothing. GlueJS makes no network requests; the forecast comes from Apple Weather.
You'll be asked
Once each: Location (for the forecast), Calendar, Health access to Walking + Running Distance, and to share them with GlueJS.
Leaves your phone
Nothing.
Share sheet

Scale any recipe

“When I share a recipe, ask how many people I'm cooking for and scale the ingredients.”

Scaled × 1½
3⅓ cups flour · 1½ cups (3 sticks) butter · 3 eggs
How it works
  1. WhenShare a recipe pageSafari share sheet
  2. Shortcuts gets“6 servings”Ask for input
  3. GlueJSRead the ingredients, rescale every amountFractions and ranges too
  4. ThenShow result
Steps
Share a recipe page or selected text. GlueJS reads the page's machine-readable ingredient list (most recipe sites include one for search engines) and rescales every amount.
Connects to
The recipe website you shared, to read the page.
You'll be asked
Once: allow the shortcut to share Safari items with GlueJS.
Keys & cost
None.
On-device AI · Health

Migraine patterns

“Let me log migraines with one tap, and once a month tell me whether they line up with pressure changes — privately.”

6 of your 9 migraines came after a big pressure drop, which only happens 17% of the time where you live. A drop is forecast for Thursday.
How it works
  1. WhenTap “Migraine”Home Screen or Action button
  2. ThenLog a headacheApple Health
  3. WhenMonthly: “Migraine Patterns”
  4. Shortcuts getsHeadaches, last 90 daysApple Health
  5. GlueJSCompare with 3 months of pressureOpen-Meteo
  6. Apple IntelligenceWrite a short summaryApple Intelligence, on device
  7. ThenShow result
Steps
Headaches are logged in Apple Health, so they're backed up, synced and visible to your doctor. Monthly, GlueJS compares each one with the pressure change in the 24 hours before it, against how pressure usually changes in your town. Apple Intelligence writes it up on the phone.
Connects to
Open-Meteo for pressure; Apple Intelligence on this iPhone.
Leaves your phone
Only your town's name. Your headache history never does.
Needs
An iPhone with Apple Intelligence turned on. Switching the step to Private Cloud Compute or ChatGPT works too, but sends the summary off the phone. Not medical advice.
Public data

Aurora alert

“Tell me when the northern lights might be visible from my town — but only if it's dark and clear.”

🌌 Aurora possible now
18% chance to the north, Kp 5.3, 10% cloud cover.
How it works
  1. WhenEvery evening hourTime automations
  2. GlueJSAurora + Kp forecast, clouds, darknessNOAA, Open-Meteo
  3. ThenNotify only on good nightsAt most once a night
  4. ThenWidgetRefreshes hourly
Steps
Checks NOAA's aurora forecast for the sky between you and the pole, geomagnetic activity, and local cloud cover and darkness. Silent unless all three line up.
Connects to
NOAA Space Weather Prediction Center and Open-Meteo.
Leaves your phone
Your town's name, to Open-Meteo.
Keys & cost
None; both are free public services.
Stocks · API key

What my portfolio is worth

“Show what my shares are worth and my total gain, and alert me if anything moves 3% or NVDA drops below $120.”

🔔 MSFT −4.2% today
🔔 NVDA is below $120: now $117.20
$11,537, −$53 (−0.5%) today
How it works
  1. WhenDaily automationWidget also refreshes every 30 min
  2. Shortcuts getsHoldings & alertsText in the shortcut
  3. GlueJSFetch quotes, add up value and gain, check alertsFinnhub
  4. ThenWidget + alertsEach alert once a day
Steps
You list holdings (“AAPL 10 @ 150”) and alerts in the shortcut. Apple's Stocks app doesn't track shares, cost or alerts.
Connects to
Finnhub stock quotes.
Leaves your phone
Ticker symbols only, never how many shares you own.
Keys & cost
A free Finnhub key, saved in your iCloud Keychain by a one-tap setup shortcut; it can only be sent to finnhub.io.
Widget · Offline

Caffeine cutoff

“When I log a coffee, tell me when I'll be under 50 mg so I can sleep, and keep it on a widget.”

☕ 210 mg
Sleep-friendly after 10:40 PM · 318 mg today
How it works
  1. WhenAction button
  2. Shortcuts gets“latte”Ask for input
  3. GlueJSLog it, work out what's left5-hour half-life
  4. ThenWidget + notificationRefreshes every 30 min
Steps
GlueJS knows typical caffeine per drink, keeps two days in its Store, and recalculates on the widget every 30 minutes without logging anything new.
Connects to
Nothing. It works offline.
Keys & cost
None.
Widget · Offline

Sourdough starter

“Tap when I feed my starter, and show me on a widget when it'll peak.”

🍞 Peak in 3h 10m
Peaks around 5:40 PM · fed 1:16 PM (1:2:2, 70°F)
How it works
  1. WhenHome Screen icon
  2. Shortcuts getsFeed ratio and kitchen temperatureText in the shortcut
  3. GlueJSEstimate the peakBaker's rule of thumb
  4. ThenWidget countdownRefreshes every 30 min
Steps
Estimates rise time from the feeding ratio and kitchen temperature, then counts down: rising, at its peak, past peak, hungry.
Connects to
Nothing. It works offline.
Make it yours
Ask your agent to tune the timings after watching your own starter for a few days.

Why GlueJS?

Write familiar JavaScript, control what data goes in, and see what happened on every run.

You choose the input

Shortcuts handles device-data permissions and passes in what your automation needs. Open the shortcut to see exactly what's shared.

Familiar JavaScript

Use web APIs like fetch, write TypeScript, and bundle compatible npm packages.

Control where keys go

Use API keys through placeholders. GlueJS inserts their values only for hosts you allow.

A record of every run

Inspect inputs, outputs, logs and errors. Run a script again in one tap.

Build and update on your Mac

Your coding agent can type-check, test and generate the shortcut. Sync script edits to your phone without reinstalling.

No account. No tracking.

We don't receive your script data. Backups and sync follow your Apple settings. Privacy policy

Built to be written by AI

The documentation is written for coding agents like Claude and ChatGPT first: one complete reference with exact limits, error messages and templates, plus TypeScript definitions. Point your agent at it.

llms.txt

Start here. An index of everything an agent needs.

reference.md

The full contract: script runtime, fetch and secrets, Store, Widget, the shortcut format and builder.

gluejs.d.ts

Type definitions for Secrets, Store, Widget and script input.

gluejs-ios

The tools, from npm: npx gluejs-ios new, run, build. Type-checks, bundles and signs the shortcut.

Pricing

Free

3 runs a day

Runs from Shortcuts and widget refreshes count. The Playground and Run Again in the app are always free.

GlueJS Unlimited

$4.99 / year

For daily automations and self-refreshing widgets, which use several runs a day. Through the App Store; cancel anytime in Settings.