---
name: build-tailapps-app
description: Build or change a TailApps app (menu bar app, widget, monitor, small tool, Siri or Shortcuts action) with the tailapps MCP tools so it fits every surface (menu, menu bar and Dock status, pop-out, Dashboard, iPhone and its widget, Shortcuts and Siri) and works across the user's devices where it can.
---

# Building a TailApps app

A TailApps app is one JSON document. TailApps draws it natively on the Mac and the iPhone and runs its sources and actions. You build it with the `tailapps` MCP tools. Never write Swift, an Xcode project or a shell script when a TailApps app can do the job.

The user expects two things from every app you make:

1. **It looks right everywhere it can appear.** That means the menu, the menu bar, the Dock, a pop-out window, the Dashboard and the iPhone, not just one card.
2. **It works on their other devices** wherever that's possible, and it is honest where it isn't.

## Workflow

1. **Search first.** If the gallery MCP (`tailapps-gallery`) is connected, call `search_gallery`. When an approved app fits, show the user what it does and give them `install_link`.
2. **Read the catalogue.** Call `get_catalog` with no arguments for the summary. Then call `get_catalog { "section": "components", "names": [...] }` (or `steps`, `sources`, `views`…) for the parts you'll use. Don't guess keys: unknown keys are errors.
3. **Check real data.** Before you bind to a CLI's or API's fields, run it or fetch it once and look at the real output.
4. **Write the app**, covering every surface (below) and the device plan (below).
5. **Validate.** Call `validate_app { app, targets: ["macos", "ios"] }`. Fix every error. Then read `warnings`, `targets`, `surfaces` and `suggestions`, and fix what applies.
6. **Install.** Call `create_app`. Use `kind: "scratch"` for a one-off task UI, and the default `kept` otherwise. To change it later, call `update_app` with the whole document.
7. **Check it works.** Use `get_state` to see what sources returned, and `run_action` to try a button. Then tell the user what to approve and set up. If the app talks across devices, that includes ⋯ › **Sync to My Devices** on each device.

## Surfaces: give every one a deliberate answer

| Surface | What the user sees | What drives it |
|---|---|---|
| **TailApps menu** | The app's tile in the stacked menu, at narrow width | `views.menubar`: `card` (which card), `in_menu`: `"card"` for apps you use (buttons, lists) or `"row"` for apps you glance at |
| **Menu bar status** | The app's own item in the macOS menu bar, if the user keeps it there | `views.menubar.label` (short, under 24 chars), `label_tone` (good, warn, bad, accent = busy), `label_icon` (an SF Symbol that can follow the state), `label_fill` (a hue or tone, or a binding like `"$hue"`: the status as a coloured pill; the text colour is picked for you unless you set `label_text`) |
| **Dock status** | A round button in TailApps' Dock that opens into a coloured pill when busy, warn or bad | The same `label`, `label_tone` and `label_icon`. There's one status per app, so write it once and make it meaningful |
| **Pop-out window** | The app in its own floating window (⋯ › Pop Out, a Dock click, and `shortcuts.open` when `views.floating` is set; without it the shortcut opens the menu) | `views.floating`: `card`, `width` (narrow, default or wide), `pin`. Use a roomier card here when the menu card is compact |
| **Dashboard** | A tile on the Mac's Dashboard grid | The menubar card, always in full (rows expand). Make sure that card reads well on its own |
| **iPhone** | The app screen on the phone, plus its tile in the Apps list | `views.phone.card`. Without it, the phone shows the menubar card. Give the phone its own card when its buttons must do something different (see Devices) |
| **iPhone notifications and Inbox** | A banner even while TailApps is closed, and an item in the phone's Inbox | `"alert"` on a `send` step (the iPhone shows it; a Mac ignores it). Use `notify` for a local notification on the device that runs it, e.g. in the Mac copy's `on_receive` |
| **Keyboard** | A global shortcut that opens the app or runs an action, and hold-to-talk | `shortcuts.open` and `shortcuts.actions` (with `on_release` for hold-to-talk) |
| **iPhone widget** | A Home Screen widget (small, medium or large) the user can point at the app; a tap opens it. Only for apps that run on the iPhone and are approved there, not a Mac-only app's preview | Nothing to declare: it draws the card the iPhone shows (`views.phone.card`, else the menubar card) with the values TailApps saved when it was last on screen. It runs no sources or steps and its buttons don't run yet, so put the number or status that matters at the top of that card, not in a `map` or an image (neither draws there). Keep state small: an app whose state is over 256 KB gets no widget |
| **Shortcuts, Siri and Spotlight** | "Run Mute in System Controls" in Shortcuts and Spotlight, and "Run Mute in System Controls in TailApps" for Siri | `"expose": true` on an action (see Shortcuts both ways, below). The name is the action's key made readable (`mute` → "Mute"), so give exposed actions clear keys |

Rules of thumb:

- **Always give a status** (`label`, plus `label_tone` and `label_icon` when the state changes) unless the app truly has nothing to say at a glance. Without one, the app can't appear in the menu bar or the Dock status area.
- **Card or row:** a monitor or status app → `row` with a good label. A tool with buttons and fields → `card`.
- **Add `views.floating`** when the app is something people keep open (a log, a chat, a checklist, a timer): pick `width`, and `pin: true` if it should float on top.
- **Countdowns never poll:** store the end time (`ends_at`) and show it with `{ "timer": "$ends_at", "mode": "until", "on_end": "<action>" }` (runs when it hits zero, shown or not), a ring with `{ "progress": "$ends_at", "from": "$started_at" }`, and the status with `"label": "$ends_at | until"`. All three redraw every second by themselves; don't add an `every: 5` source for a clock. Do the maths with `increment`, not a script: start is `set` `ends_at` to `$now`, then `increment` it by the length in seconds; pause is `set` `left` to `$ends_at`, then `increment` `left` by `"-$now"` (a minus takes a binding away); resume is `set` `ends_at` to `$now`, then `increment` it by `$left`. Then the timer runs on the iPhone too. See examples/pomodoro.json.
- **Alarms and many timers:** `on_end` runs only while TailApps runs, and not in a list. For an alarm that must ring with the app quit or the phone locked, schedule it when the timer starts: `{ "notify": { "title": "$args.name", "body": "Time's up", "at": "$now | add:$args.left", "id": "$args.id" } }`, and take it back on pause or reset with `{ "notify": { "cancel": "$args.id" } }`. Read typed lengths with `$entry | seconds` ("4:30", "25", "Tea 10 min"; `seconds:'rest'` is the name), show a stopped one with `$left | duration:'clock'`, big digits with `"size": "xxl"`, and coloured cards with `{ "column": [...], "style": "tile", "hue": "$item.hue" }`. See examples/timer.json.
- **Pop-outs and big text:** `"floating": { "card": "mini", "chrome": "none" }` pops the app out with no header or frame (a card whose root is a tile becomes the window; the user can show the header again). `"size": "fill"` on a text, stat or timer makes it one line as big as the space allows, so it grows when the user resizes the pop-out. Give the pop-out its own small card rather than the full one. See examples/timer.json.
- **Design the menubar card to stand alone**, because the Dashboard and, by default, the iPhone show it too.
- **Don't** make a separate card for every surface "just because". One good card is fine when it works everywhere. Add a `floating` or `phone` card only when that surface needs something different.
- Use tokens only: tone, size, emphasis, gap and one `style.accent`. No pixel sizes or colours.

### Rows and groups (§50)

- **Rows of things are `cell`s**, not hand-built `row`s: `{ "cell": "$item.name", "subtitle": "$item.url", "leading": "globe", "status": "good", "count": "$item.unread", "accessory": "chevron", "on": "open", "args": { "id": "$item.id" } }`. `trailing` takes one part (a badge, a button, a row of icon buttons, a menu, or a toggle `field` whose label the cell's title replaces). For the picked row: `"selected": { "value": "$item.id", "is": "$picked" }` and an `on` action that sets `$picked`.
- **Group related rows with `{ "column": [...], "style": "inset" }`**: one rounded group, hairlines between its parts. A `list` straight inside puts each row in the group, so a header `cell` then a list of `cell`s is one group. Settings-like screens are one or two of these.
- **Icon buttons:** `"icon": "trash"` on a `button` or `menu`; add `"icon_only": true` for a toolbar of small icons (the label is still required: it's what VoiceOver reads). A `menu` with its own `on` is a split button: the label runs `on`, the arrow opens the menu. A ⋯ menu is `{ "menu": "More", "icon": "ellipsis", "icon_only": true, "items": [...] }`. See examples/dev-hosts.json.

### Files in: drop zones (§51)

- **To take files, use a `drop` part**: `{ "drop": "Drop images to convert", "on": "convert", "accept": ["image"], "multiple": true }`. The user drops files on it or clicks it (taps on iPhone) to choose; the action gets `$args.files`, always a list of `{ path, name, base, ext, kind, type, size, modified }` (one file: `$args.files.0.path`). Don't declare `files` in the action's args. The zone draws its own drag-over, working, done and error states: don't add a busy badge for it.
- `accept` takes kinds (`image`, `video`, `audio`, `pdf`, `text`, `json`, `csv`, `archive`), extensions (`".heic"`) or type ids. `max` (with `multiple`) and `max_mb` cap what comes in. `size: "l"` for a card that is mostly the zone, `"s"` for a slim one once results show.
- No permission and no folder setting needed: the drop is the approval, and only those files are readable to the app's steps. You can't pass files through `run_action`; ask the user to drop them. Batch work over several files: `{ "each": "$args.files", "do": [ … ] }` (below), or a script that reads `$args.files` as JSON (`jq -r '.[].path'`) when it needs a CLI.
- **A short video, then share or upload it:** `{ "camera.take": { "mode": "video", "max_seconds": 60 }, "as": "clip" }` (permissions `camera` and `mic.record`, from a tap only; Mac and iPhone) gives `$clip.path` (an MP4, 24 hours in the app's temporary folder) plus `$clip.seconds`. Show it with `{ "player": "$clip_path" }` (store the path in state first), `{ "share": { "file": "$clip_path" } }` opens the share sheet (permission `share`, a tap only), and `files.save` to a bucket uploads it: give that action `"timeout": 900`, since a clip on mobile data takes a while. See examples/clip.json.
- **A screen recording (Mac):** `{ "screen.record.start": { "target": "pick", "sound": true, "system_audio": true } }` (permission `screen.record`, plus `mic.record` for `sound`; from a click only) starts it; `target` is `pick` (Apple's picker), `display`, `area` (the user drags a rectangle) or an `$item.id` from a `{ "system": "displays" }` or `{ "system": "windows", "every": 5 }` source (permissions `displays.read`, `windows.read`). Keep a `recording` bool in state for the Stop button, and set it to false *before* the stop step, so a failed stop can't leave the card stuck on Stop. `{ "screen.record.stop": {}, "as": "rec" }` gives `$rec.path` (an MP4) and `$rec.seconds`; if the user stopped it from the menu bar, the next stop still returns it (with `stopped_by`). Then `player`, `share` or `files.save` as for a clip. For a 2 × 2 grid of big choices, give buttons and menus `"layout": "stacked"` (icon above label). See examples/recorder.json.
- **Start a Mac screen recording from the iPhone:** add the permission `screen.record.remote` next to `screen.record`. Then a send from the user's other signed-in devices may start it: the phone `send`s `{ do, at: $now }` to an inbox the Mac copy has (`"platforms": ["macos"]`), and that inbox's `on_receive` runs `screen.record.start` with `target` `display` or a `displays`/`windows` id (never `pick` or `area`: nobody is at the Mac; never from `on_sync` or a replayed send). Only start for a fresh ask: `"if": "$args.event.at | times:-1 | add:$now | tone:{good:'<=120', else:'bad'} | map:{good:true, else:false}"`, so a start queued while the Mac slept doesn't run later. Keep the Mac awake after the start succeeds (`awake.start` with `display: true`, permission `power.control`), show progress with synced state (`"sync": true` on a `phase` and a `started_at` the phone reads with a `timer`), and send the MP4 back with the send's `file` (at most 10 MB: check `$rec.size | tone:{good:'<=10000000', else:'bad'} | map:{good:true, else:false}`, and upload bigger ones to a storage setting and send the link). The phone plays a received file in a `player`. See examples/remote-recorder.json.
- **A nicer screenshot or photo:** `{ "image.compose": { "image": "$shot", "background": { "gradient": ["purple", "orange"] }, "padding": "l", "corners": "m", "shadow": true, "aspect": "16:9" }, "as": "nice" }` (no permission; Mac and iPhone) writes a new picture, `$nice.path`, and leaves the original alone. `background` is `{ "hue": "blue" }`, `{ "gradient": [2–4 hues], "angle": 135 }` or `{ "image": "assets/beach.jpg", "blur": 0.3 }`; every key may be a binding, so style fields can feed it. To put style controls in a small panel, give a button `"popover": [parts]` instead of `on` (fields there `bind` the card's state; give them `"on_change"` to re-run the compose). Ring the picked picture in a gallery with `"selected": { "value": "$item", "is": "$shot" }`. See examples/shot-editor.json.
- **Let the person draw or mark up a picture:** `{ "canvas": "markup", "bind": "$marked", "background": "$shot", "tools": ["arrow", "rect", "pen", "redact", "eraser"], "on_change": "render" }` (no permission; Mac and iPhone). Declare the key `{ "type": "object", "default": {} }`; after each change it holds `{ path, items, width, height, count, empty, at }`, and `$marked.path` (a `drawings/…` PNG with the picture under the marks; "" until something is drawn) works wherever a step or `image` takes a picture, e.g. `"image": "$marked.path | default:$shot"`. `background` is `blank`, `grid`, `lines`, `dots` or a picture binding; `redact` hides a part with a solid block; tones are fixed colours (`red`, `yellow`, `blue`, `black`, `white`…). The person draws, the app never does: the only step is `{ "canvas.clear": "markup" }`, which you run in the step that gives it a new picture. The value is the canvas's id (kebab-case). See examples/shot-editor.json.
- **A camera bubble (Mac):** a card whose layout is `{ "player": "camera", "shape": "circle", "platforms": ["macos"] }` (permission `camera`; `"camera:<name>"` picks a camera by name) shows the live camera, nothing recorded. Make it the pop-out, `"views": { "floating": { "card": "bubble", "chrome": "none", "pin": true } }`, and it floats as a round window that screen recordings keep in. Open and close it from a button with `{ "pop_out": "toggle" }` (or `true` / `false` / a binding; from a click only, Mac only, no permission). See examples/recorder.json.
- **A photo from the camera:** `{ "camera.take": {}, "as": "photo" }` (permission `camera`, from a tap only; the Mac opens TailApps' own camera window), then `{ "files.save": { "data": "$photo.path", "to": "$settings.dest", "name": "photo-{$now}.jpg" }, "as": "saved" }` to a `storage` setting with `"allow": ["s3"]` uploads it from the phone; `$saved.url` is the link. Give the setting (and the button) `"platforms": ["ios"]` so only the phone asks for a bucket: with no `platforms` a required setting also needs a bucket on the Mac before the card runs there. See examples/photo-drop.json.
- **Photos from the iPhone's library:** `{ "photos.pick": {}, "as": "photo" }` (or `{ "multiple": true, "max": 5 }` for a list), from a tap only, no permission (the system's photo picker; the app sees only what's picked). Same result as `camera.take`: a JPEG, no location, `$photo.path`, 4096 px on its long side by default (`max_px`; keep it at 4096 or less for a `send`, which carries at most 10 MB). iPhone only: on a Mac use `files.pick` with `"accept": ["image"]`.
- A button that needs files first: a `files.pick` step (`{ "files.pick": { "accept": ["pdf"], "multiple": true }, "as": "picked" }`); cancel stops the action quietly. It only opens from the user's click. See examples/image-convert.json and examples/transcribe-file.json.

### The clipboard (§61)

- **What's on the clipboard now, from a button:** `{ "clipboard.read": ["text", "image"], "as": "copied" }` (permission `clipboard.read`; `{}` reads text, image and files). It only runs from the user's click, tap or shortcut, never from a source, timer, inbox or `run_action`. `$copied.kind` is `files`, `text`, `image`, `empty` or `hidden` (a password manager's copy: nothing is read). `$copied.image` is a PNG path later steps use (`share`'s `file` too): OCR what I copied is `{ "clipboard.read": ["image"], "as": "copied" }` → `{ "vision.ocr": "$copied.image", "as": "text" }` (Mac and iPhone; ask for the image only, since text wins when both are there). `$copied.files` (Mac) is a list like `$args.files`. On the iPhone, iOS may ask to allow the paste; files aren't there.
- **Follow every copy (Mac):** a source `{ "clipboard": ["text", "image"] }` holds the latest copy `{ change, kind, text, image, files, from, at }` and runs again after each copy. A clipboard history is `"on_change": { "action": "keep", "watch": "$clip.change" }` with `keep` doing `remove` (same text) + `push` to a list with `max`, rows with a Copy button (`clipboard.write`). Set top-level `"sync": "never"`, and give the source `"platforms": ["macos"]` so the card still shows on the iPhone. Images live a day in the app's temporary folder: save them with `files.save` to keep them. See examples/clipboard-history.json. What an app keeps from the clipboard (the source and every key filled from it) shows as hidden in `get_state`, and `run_action` results from such an app are hidden too: check it in the card, not with get_state. A copy of a key stored in Connections or a sign-in token comes through as `kind: "hidden"`.

### Times, zones and lists people edit (§52)

- **Totals, top lists and joined names need no script**: `$expenses | sum:'amount' | currency` (also `avg`, `min`, `max`; no field for a list of numbers), `$runs | sort:'-ms' | limit:5` (`'-'` = largest first; `limit:-3` = the last three), `$people | pluck:'name' | join` ("Anna, Ben, Cara"; `join:' · '`; `| unique` drops repeats), `$line | split:','`, `$temp | round:1` (stays a number, so `tone` still works). Combine with `where`: `$expenses | where:{paid:false} | sum:'amount'`. See examples/expenses.json. A search box filters a list with no script: bind a `search` field to `$query`, then `$items | search:$query` (every word, any value, case and accents ignored; empty keeps all; `search:$query:'title,notes'` looks only in those fields). Show any value as indented JSON in a `code` part with `$item.data | json` (`json:'line'` for one line); see examples/debug-feed.json.
- **Clocks need no script**: `$now | time:$item.tz` is the time of day in a zone (IANA name like `Europe/Warsaw`; `'seconds'` as a second argument adds seconds), `$now | offset:$item.tz` is `-9h` / `+5h 30m` / `0h` (word it with `map:{'0h':'Same time'}`), `$now | hour:$item.tz` is a number for tone thresholds (`tone:{bad:'<7 or >=23', warn:'<9 or >=18', else:'good'}`). Shift a time with `add`: `$now | add:$shift | time:$item.tz`, with `shift` in seconds from a slider. `$item.cc | flag` turns a country code into its flag (a `cell`'s `leading` takes it). `$now | zone:$item.tz` is the zone's short name (`PST`, `GMT+9`), `zone:'local':'city'` the city this device is in ("London"), and `$now | date:'day':$item.tz` the day it is there (`Tue, Nov 24`).
- **How far through the year, quarter, month, week or day** is `$now | through:'year'` (0…1, this device's calendar): put it straight in a `progress`, or write it with `percent:0` ("90%", also as a menu-bar `label`). `through:'year':'day'` is the day of the year (329), `'days'` its length (365/366) and `'left'` the days after today; the same for `'quarter'`, `'month'` and `'week'`. Live by the minute, no script or source, runs on the iPhone. See examples/year-progress.json.
- **Where a value sits in a range is a line `gauge`**: `{ "gauge": "$now | hour:$item.tz", "min": 0, "max": 24, "style": "line", "band": [9, 18], "tone": "$now | hour:$item.tz | tone:{neutral:'<9 or >=18', else:'good'}" }` draws the day as a track with working hours stronger and a dot for now.
- **Converters and encoders need no script**: `$rates.rates | pick:$to | times:$amount | currency:$to:'full' | default:'—'` converts money (`pick` reads a field named at run time, `times` multiplies, `currency` takes a bound code). `| encode:'base64'` / `'base64url'` / `'hex'`, `| decode:'base64'` / `'hex'` / `'url'` (null when invalid: add `| default:'Not valid'`), `| hash` (sha256; also `'sha1'`, `'md5'`, `'sha512'`); URLs still use `| url`. A QR code is the `qr` part with a text template: `WIFI:T:{$security};S:{$ssid | encode:'wifi'};P:{$password | encode:'wifi'};;` joins a network, `BEGIN:VCARD…` with `encode:'vcard'` values adds a contact. See examples/currency.json, qr-code.json and encoder.json (all run on the iPhone).
- Only `add`, `times`, `pick`, `currency`, `time`, `offset`, `hour`, `zone`, `date` (its zone), `where`, `share` and `default` take a `$binding` argument; it has no formatters of its own. A card that shows `$now` redraws by itself each minute (each second when it shows seconds), and so does a `views.menubar.label` that reads it (`"{$cities.0.cc | flag} {$now | time:$cities.0.tz}"`), so don't add a polling source for a clock. Keep a clock's `label_tone` calm (good/neutral). For a countdown to a stored time, still use the `timer` part.
- **Build a fetch URL from input with `url`**: `"https://…/search?name={$args.value | url}"`.
- **Lists people edit**: `push` adds, `remove` takes out: `{ "remove": { "cities": { "match": { "tz": "$args.tz" } } } }` or `{ "at": -1 }`. No duplicates: `remove` the same match, then `push`. Reorder with `move`: `{ "move": { "cities": { "match": { "tz": "$args.tz" }, "by": -1 } } }` (Move Up; `"to": 0` for the top). Edit one field of a row from a ⋯ menu item with `ask` (`"default": "$args.note"`) then `update`. See examples/world-clock.json (runs on the iPhone too).

### To-dos, notes and progress (§56)

- **A to-do row is a `cell` with `check`**: `{ "cell": "$item.title", "check": "$item.done", "on_check": "tick", "args": { "id": "$item.id" } }`. The tick runs `tick` with `$args.value` (true/false, don't declare it); the action is one `update` step: `{ "update": { "todos": { "match": { "id": "$args.id" }, "set": { "done": "$args.value" } } } }`. Ticked rows are struck through for you. Don't build tick boxes from buttons or icons. Add with `push` (give each item an `id`, e.g. `"$now"`), clear finished ones with `{ "remove": { "todos": { "match": { "done": true } } } }`. Always push `"done": false`: `where`/`share` count a missing `done` as false, but `match` in `update`/`remove` compares the value itself.
- Counts and progress from a list: `{$todos | where:{done:false} | count} left`, `"progress": "$todos | share:'done'"`. A lone tick box: `field` toggle with `"style": "check"`.
- **Notes are `message` with `"style": "note"`**: `title`, `hue`, `time`, `lines: 3` for a preview, `markdown: true` for headings, bullets, `- [ ]` lines and quotes, `on` to open one for editing. Edit in a `field` `textarea` bound to a `$draft`, saved with `update`. Keep chat bubbles (no style) for conversations.
- **Progress styles**: `percent: true` shows 42%; `split: 5` (or `"$todos | count"`) cuts a bar or ring into pieces; a list of `{ value, hue, label }` is a breakdown on a bar, `segmented` or a `ring` (a donut); `size` sets a bar's thickness. See examples/todo.json, examples/notes.json, examples/progress.json (all run on the iPhone).

### Batches and folders (§65.8)

- **Do the same steps for every item: `each`**: `{ "each": "$files", "do": [ … ], "max": 200, "as": "done" }` runs `do` once per item with `$item` and `$index`. A failed item is noted in `$done.failed` (`[{ index, error }]`) and the rest go on; `$done.done` counts the ones that worked. Inside `do`, no step that waits on the person (`ask`, pickers, the camera, `share`, `clipboard.read`) and no second `each`: run those once before it.
- **Take posts from any tool or language, no token (Mac):** add `"port": 47312` to an `inbox` source and the permission `listen:47312`. Then a plain `POST` of JSON to `http://127.0.0.1:47312/` (any path, e.g. `curl -d '{"value":"hi"}' 127.0.0.1:47312`) lands in that inbox like a hook's event. Senders use `127.0.0.1` (not `localhost`, which some resolve to IPv6). Ports 1024–65535, not 47311, at most 3 per app, one inbox per port, not with `verify`. Only programs on this Mac get in (web pages and other host names are refused). create_app and get_app return the inbox's `port_url` while it listens. Use it for a sender that can't add a header; otherwise the token inbox (`hook_command`, `url`) is fine. If what's sent is private, the sender checks before each post, over `127.0.0.1` (never `localhost`), that TailApps holds the port: `GET /proof` with a fresh 64-hex nonce in `X-TailApps-Nonce` answers `{"proof": hex(HMAC-SHA256(key: inbox token, "tailapps-loopback-v1\n" + nonce))}`, the token being `"<app>/<inbox>"` in `~/Library/Application Support/TailApps/inbox-tokens.json` (never put it on a command line). Or pipe through `hook_command`, which checks for you.
- **A folder's files (Mac):** `{ "files.list": "$settings.inbox", "as": "files" }` (a `folder` setting, permission `files.read:inbox`, or `files.write:inbox` if the app also changes files there) gives the files directly in it, A–Z, each `{ path, name, base, ext, kind, type, size, modified }`. Store it in state for a list, and list again after changing files.
- **Rename or move (Mac):** `{ "files.rename": { "file": "$item", "name": "{$settings.prefix} {$item.base}" } }` (the file keeps its extension) and `{ "files.move": { "file": "$item", "to": "$settings.done" } }`, each needing `files.write:<setting>` for the folders involved (a move: both). Only files inside a chosen folder; nothing is overwritten (a clash gets " 2") and nothing is deleted. `files.info` gives one file's details. Give a big batch a `confirm` and `"timeout": 600`.
- **A long batch the person can follow and stop: make the action a job**: `"job": true` (with `"timeout"` up to 3600). Show `{ "progress": "$job.move_all.progress", "label": "Moving {$job.move_all.done} of {$job.move_all.total}", "when": "$running.move_all" }` (the `each` inside counts), and a Stop button whose action is `{ "job.cancel": "move_all" }`. `$job.<action>.status` is `idle`, `running`, `done`, `failed` or `cancelled`. Declare `notify` and it says when it's done. Don't name a state key or `as` result `job` in such an app. See examples/folder-tidy.json.

### Calendar and Reminders (§37.4)

- **Today's events: a `calendar` source**, `"today": { "calendar": { "days": 1 } }` (permission `calendar.read`; `"calendars": ["Work"]` for some only). Each event is `{ id, title, start, end, all_day, ongoing, location, notes, calendar, hue, join, attendees, status }` (`ongoing`: happening now); put the list straight into a `calendar` part (`"view": "agenda"`). `join` is the meeting link (Zoom, Meet, Teams, Webex, FaceTime) or null: `{ "if": "$args.item.join", "then": [{ "open": "$args.item.join" }] }` with `open:url`. Next meeting countdown for a menu-bar label: `"{$today | where:{all_day:false, ongoing:false} | pick:0 | pick:'start' | until:'short'}"`. Read-only: there's no step to add events.
- **Reminders: a `reminders` source**, `{ "reminders": { "list": "$settings.list", "done": false } }` (`reminders.read`) → `{ id, title, due, notes, list, priority, done }`. Tick with a `cell` `check` whose `on_check` runs `{ "reminders.done": { "id": "$args.id", "done": "$args.value" } }`, add with `{ "reminders.add": { "title": "$draft", "list": "$settings.list" } }` (both `reminders.write`). Don't copy reminders into state or `set` them: both sources refresh by themselves when anything changes, so take no `every`.
- **Let the user pick calendars or a list in Settings**: `"settings": { "calendars": { "type": "calendar.calendars", "label": "Calendars to show" }, "list": { "type": "reminders.lists" } }`, then `"calendars": "$settings.calendars"` and `"list": "$settings.list"`.
- **Do something at a time from state: `alarms`**, `"alarms": { "heads_up": { "at": "$today | where:{all_day:false}", "time": "$item.start", "before": 120, "action": "warn" } }`. The action gets `$args.item` and `$args.time` (don't declare them); `"at": "$ends_at"` for one time. On the iPhone it rings only while TailApps is open, so for a locked phone also schedule `{ "notify": …, "at": … }`. See examples/my-day.json.

### On-device AI and translation (§65.10)

- **Ask the device's own model: `ai.generate`** (`ai.generate` permission; Apple Intelligence, macOS 26 / iOS 26, nothing leaves the device). `{ "ai.generate": "Rewrite politely: {$draft}", "as": "text" }` gives text; with `shape` it gives JSON in exactly that shape: `{ "ai.generate": { "prompt": "Summarise and list the to-dos:\n\n{$draft}", "shape": { "summary": "text", "todos": ["text"] } }, "as": "out" }`, then `{ "set": { "result": "$out" } }` and bind `$result.summary`. Shape types are the action arg types (`text`, `int`, `int:1-5`, `number`, `bool`, `enum:a|b`), objects of them and lists of one. Prompt ≤ 8 KB. Show `$running.<action>` while it thinks. Where Apple Intelligence is off it fails with `ai_unavailable`, so say in the card that it needs it.
- **Translate: `translate`** (`translate` permission), `{ "translate": "$result.summary", "to": "$lang", "as": "fr" }` (`from` defaults to `auto`). Only language pairs the person has downloaded in Settings work; others fail with `translate_unavailable`, which says where. See examples/summarise.json.

### Shortcuts both ways: `shortcuts.run` and `expose` (§30, §65.13)

- `{ "shortcuts.run": "Arrive home", "input": "$args.text", "as": "out" }` runs a Shortcut from the Shortcuts app by its exact name. The name is literal (never a binding) and each one needs its own permission, `shortcuts.run:Arrive home`, so one step per Shortcut. On the Mac `$out` is the Shortcut's text output (or null); on the iPhone it's tap only, opens Shortcuts and returns null. It's the way to reach what TailApps has no step for (Focus, brightness, Low Power Mode, HomeKit scenes): say in the card which Shortcut the person needs to have.
- **Let Shortcuts and Siri run an action: `"expose": true`** on it ("Run Mute in System Controls"): the other way round, Shortcuts, Siri and Spotlight run the card's action. Only for an action with no `args`, no `confirm`, no `$args` and no tap-only step (`ask`, pickers, the camera, `scan.code`, `location.get`, `share`, `clipboard.read`, `screen.record.start`); use state instead of args. An action is offered only on devices where it runs: one with `mic.record.start` or `shortcuts.run` (tap only on the iPhone) is offered on the Mac but not the iPhone. See examples/keep-awake.json.

### What the Mac is doing: the `activity` source (§37.3)

- **A call started, the screen locked, the user stepped away (Mac only):** a source `{ "activity": ["mic", "camera", "front_app", "running", "locked", "idle"] }` (list only what the card needs) holds `{ mic, camera, front_app: { name, bundle_id }, running: [...], locked, idle }`. `mic`/`camera` are true while any app uses one (never what's said or seen); `idle` is seconds since the last key or click, in 30 s steps. It refreshes by itself: react with `"on_change": { "action": "follow", "watch": "{$mac.mic} {$mac.camera}" }`. Permissions: `activity` for mic, camera, locked and idle; `activity.apps` for front_app and running (then also set top-level `"sync": "never"`: which apps someone uses is private). The card is about the Mac, so it doesn't run on the iPhone. See examples/on-air.json.

### Tabs, swipes, menus, questions and detail cards (§65.7)

- **Two or three views of the same data in one card: a `tabs` part**, `{ "tabs": [{ "label": "Open", "count": "$open | count", "children": [ … ] }, { "label": "Done", "children": [ … ] }] }`. The pick is remembered for the user. Don't fake tabs with buttons and a state key.
- **Row actions go in the list's `swipe`**: `"swipe": { "leading": [{ "label": "Done", "icon": "checkmark", "hue": "green", "on": "complete" }], "trailing": [{ "label": "Delete", "icon": "trash", "style": "destructive", "on": "remove" }] }`. The action gets `$args.item` and `$args.index` without declaring them: `{ "remove": { "todos": { "match": { "id": "$args.item.id" } } } }`. The Mac shows them on right-click, so don't add a second ⋯ menu for the same actions.
- **Less common actions on a part or row: `context_menu`**, `[{ "label": "Rename…", "icon": "pencil", "on": "rename", "args": { "id": "$item.id" } }]` (right-click, long press).
- **Drag a file or text out of the card (Mac): `drag`** on any part, `"drag": "$item.path"` (a capture, a file dropped or picked for it, or one in a folder the user chose) `{ "files": "$tray" }` (several: "Drag all") or `{ "text": "$item.text" }`. The receiver always gets a copy. `"on_dragged": "took"` runs once a receiver took it (not for a drag let go over nothing), with `$args.item`, so a tray can remove it. The iPhone can't drag out: add a Share item (`{ "share": { "file": "$args.path" } }`, permission `share`). See examples/tray.json.
- **Say it worked with `toast`**: `{ "toast": "Copied" }`, or `{ "toast": { "text": "Deleted", "undo": "restore", "args": { … } } }` after a delete, with a `restore` action that pushes the item back. A run nobody tapped skips it.
- **Ask one question with `ask`**, not a `field` and a Save button: `{ "ask": { "title": "Rename", "input": "text", "default": "$args.title" }, "as": "name" }` then `{ "if": "$name", "then": [ … ] }`; `"choices": ["Inbox", "Done"]` to pick one; `"input": "number"`. Cancel stops the action. Only from a tap or click, never from a source, timer or inbox.
- **Pull to refresh on the iPhone**: `"refresh": "<source>"` on the list. See examples/reading-list.json.
- **A row that opens its own screen: a detail card.** Give the card `"params": { "id": "text" }`, open it from the row with `{ "open_card": "plant", "args": { "id": "$args.id" } }` (cell `"on": "open_plant", "args": { "id": "$item.id" }`, `"accessory": "chevron"`), and read live values as `"$plants | where:'id':$params.id | pick:0 | pick:'name'"`. Use a stable id, never `$index`. It gets a Back button; end Save or Delete actions with `{ "close_card": true }`. Views and tabs can't show a card with params, so keep one without. See examples/plants.json.
- **A card's main actions go in its `toolbar`**: `"toolbar": [{ "label": "Add a plant", "icon": "plus", "on": "add" }]`, 1 to 3 icon buttons at the top right (the iPhone's navigation bar). `icon` is required; the label is what VoiceOver reads.
- **Two to five separate screens of one app: app tabs**, `"views": { "phone": { "tabs": [{ "card": "plants", "label": "Plants", "icon": "leaf" }, { "card": "history", "label": "History", "icon": "clock" }] }, "floating": { "tabs": [ … ] } }` in place of `card`. A bottom bar on the iPhone, a segmented control in the Mac's pop-out; the menu shows the first tab. For views of the same data inside one card, use the `tabs` part instead.

### Buttons, keypads and touch

- **Feedback without a notification:** `{ "haptic": "success" }` (also warning, error, light, medium, heavy, selection) and `{ "sound": "done" }` (alert, error, tap, pop) need no permission; `{ "speak": "Build finished" }` needs `speak` (or `{ "text": …, "voice": "en-GB", "rate": 1.2 }`). Mac and iPhone; on the iPhone only while TailApps is open there, so for a locked phone use `notify` (or `send` with `alert`). One sound and one speak a second per app.
- **Several buttons of equal weight (a keypad, a number pad, a set of presets): put them in a `grid`**, not rows. Grid columns are equal and each button fills its cell, so every key is the same size, edge to edge. Set `columns` (e.g. `4`) and keep it the same at every width.
- **Fill every row.** Don't leave a hole at the end: give the last key `"span": 2` (e.g. `=` on a calculator), or rearrange.
- **Tell keys apart with `style`:** digits `secondary` (neutral), operators no style (tinted), clear or delete `destructive`, the one main key `primary`. Not everything the same colour.
- **`size: "l"` for keys meant for a finger** (about 56 pt tall on iPhone). Use it on the phone card for keypads and the main action.
- **One full-width action:** a button with `"grow": true` stretches across its row.
- **Order the card for the phone:** what you're entering, then the keys, then the result. Keep help text to one short `subtle` line or leave it to the `description`.

## Devices: make it work across the user's devices where it can

The same app is installed on each device (the user adds it on the iPhone from their Mac's list). Copies share **synced state keys** (`"sync": true`) and talk through the app's own **inbox** sources and **send** steps, and only after the user turns on **Sync to My Devices** for the app on each device. No tool can turn that on.

### 1. What runs where

- **Mac and iPhone:** `set`, `push`, `increment`, `if`, `refresh`, `fetch`, `notify`, `open`, `clipboard.write` (text), `clipboard.read` (a tap on the iPhone; no files there), `send`, `mic.record.*` (a tap on the iPhone), `speech.transcribe`, `files.pick`, `camera.take`, `scan.code`, `location.get` and `share` (a tap only; the camera sheet, the share sheet), the `player` part, `files.save` to a storage setting set to a bucket (the iPhone asks for the bucket and its keys in the card's ⋯ › Settings…), fetch sources and synced inboxes.
- **Also on the iPhone:** `vision.ocr` and `vision.codes` (QR codes and barcodes in a photo: `{ "vision.codes": "$photo.path", "as": "codes" }` → `[{ type, value }]`, permission `vision.ocr`), and the `network`, `power` (no `time_left` there) and `device` system sources. `{ "system": "device" }` needs no permission and gives `name`, `kind` (mac, iphone, ipad), `os`, `os_version`, `appearance`, `locale`, `time_zone`, `low_power`. To show the phone's battery on the Mac, give the phone's power source an `on_change` that `send`s it.
- **A battery card:** `{ "system": "power" }` also gives `cycles`, `health` (%), `condition` (good, fair, poor, service), `temperature` (°C) and `adapter_watts` on the Mac, and `{ "system": "bluetooth", "every": 120 }` gives each device's `battery` plus earbuds' `left`, `right` and `case`. For alerts at a level, give the power source `"on_change": { "action": "check", "watch": "{$power.battery} {$power.status}" }`, compare against a state threshold with `$power.battery | times:-1 | add:$low_at | tone:{good:'>=0', else:'bad'} | map:{good:true, else:false}` in an `if`, and keep which alert last fired (`warned`) so it rings once per crossing. To see each device's battery on the other, copy a small `{ battery, status, at }` into a `"sync": true` key from a source with `"platforms"`. See examples/battery.json.
- **Also on Mac and iPhone:** the `calendar` and `reminders` sources and `reminders.add` / `reminders.done`, `ai.generate`, `translate`, `shortcuts.run` (on the iPhone a tap that opens Shortcuts, with no output), `sound`, `toast`, `ask`, `open_card` / `close_card`, `each`, `alarms`, `haptic`, `speak` and jobs (these last four on the iPhone only while TailApps is open: for a locked phone use `notify`), `awake.start` / `awake.stop`, `files.info`, and a Face ID or Touch ID `confirm`.
- **iPhone only:** `photos.pick` (the system's photo picker; result like `camera.take`'s, `$photo.path`). On a Mac its button shows Needs iPhone: use `files.pick` with `"accept": ["image"]` there.
- **Mac only:** `cli` and `script` (sources and steps), `screen.capture`, `screen.record.*`, the live camera `player` and `pop_out`, `files.save` to a folder, `clipboard` sources, the `audio`, `wifi`, `bluetooth`, `usage`, `displays` and `windows` system sources and the audio (volume, mute, speakers, microphone), Wi-Fi, Bluetooth and `display.sleep` steps (§30, below), `wallpaper.set`, `files.list` / `files.rename` / `files.move`, the `activity` source, folder and file settings, a storage setting whose `allow` leaves out `s3`, Connections (keys) for now, inboxes fed by agent hooks. An inbox fed by a push URL reaches the phone too when the user sets the URL to All My Devices: give that source `"platforms": ["macos", "ios"]` (the Today example). A Mac-only setting doesn't have to keep the app off the phone: give it `"platforms": ["macos"]` and only the Mac asks for it. The same goes for a Mac-only source (a cli, a script, a hook-fed inbox, a fetch with a key): give it `"platforms": ["macos"]` and only the Mac runs it, then send the phone what it needs (next section).
- `validate_app` with `targets: ["macos", "ios"]` tells you which actions are off on the iPhone, and `surfaces` sums it up. On the iPhone, a button whose action can't run shows **Needs a Mac**. That's acceptable only when the user really only uses it on the Mac.

### 2. Pick the pattern

- **It already runs on both** (fetch, set, notify…). Nothing to do. Sync only if the devices should share something: next pattern.
- **Shared value or list** (a counter, a toggle, saved cities, a to-do list, running timers): add `"sync": true` to the state key, e.g. `"cities": { "type": "list", "default": [], "sync": true }`. Every change to it, by any step, reaches the app's other copies with sync on, the newest change wins, and a copy added later starts with the latest value. No inbox or send needed. A list or object syncs as one value, so keep items together in one key. Don't sync what belongs to one screen (a search box, a picked row, results) or a source's key. Store times as absolute (`ends_at`, not seconds left), so a timer lines up everywhere. To react on the device that receives (schedule its own `notify` with `at` for a timer started elsewhere), add top-level `"on_sync": "<action>"`: it gets `$args.keys`, `$args.previous` (each key's value before, e.g. to cancel a removed timer's notification), `$args.from` and `$args.replay`, its `send` steps send nothing and its writes to synced keys stay on that device. See examples/world-clock.json, examples/timer.json and examples/todo.json.
- **Shared log or chat** (notes, pings, shots): push locally and `send` the item. `on_receive` pushes it with `$args.from` (the device name). Mark your own items, e.g. `who: "me"` / `"them"`.
- **Reply to one device:** `on_receive` also gets `$args.from_id`, the sending device's id (`dev_…`). Add `"to": "$args.from_id"` to a `send` step to answer only that device; without `to`, a send goes to every device.
- **Let the user pick devices:** a source `{ "devices": "others" }` holds the user's other devices as `[{ label, value }]` (name, id). Bind it to a `checklist` (`"label": "$item.label", "value": "$item.value", "bind": "$picked"`, `$picked` a list) or a `select`'s `options`, then `"to": "$picked"`: one send per picked device. Nothing picked fails rather than sending to all, so disable the button on `$picked | count | map:{0:true, else:false}`. See examples/device-messenger.json.
- **Talk to another app:** `{ "send": { "<its inbox>": value }, "app": "<its id>" }` hands a value to another app's inbox. That inbox must opt in with `"from_apps": ["<your app id>"]` (or `"any"`); `get_app` lists what an app accepts. Needs `send:<app>/<inbox>` (`send:*/<inbox>` when `app` is a binding, like `"$args.from_app"` to reply). It stays on this device (no sign-in) unless you add `"to": "devices"` or device ids, which need Sync to My Devices. The receiver's `on_receive` gets `$args.from_app` and `$args.from_app_name`. No `file`. See examples/pomodoro.json and examples/focus-light.json.
- **The Mac watches something the phone should see** (a CLI's output, a script, agent hooks, an API with a key): give that source `"platforms": ["macos"]`. Its `on_change` (or the hook inbox's `on_receive`) `send`s a small summary to a second inbox, e.g. `status`, with an `alert` for the moments that matter ("CI failed", "Claude needs you"). That inbox's `on_receive` sets the state the phone card shows. Send on change, not on every run, and keep the payload small.
- **The phone drives something only the Mac can do** (a CLI, a script, Bluetooth, a serial or USB device, a file on the Mac):
  1. Give the phone its own card (`views.phone`) whose buttons only `send` to an inbox, e.g. `cmd`.
  2. The Mac copy's `on_receive` for `cmd` runs the script or CLI with `$args.event`.
  3. **Report back:** after it succeeds, the Mac `send`s the result to a second inbox (e.g. `done`). The phone builds its list or state only from that, so it never shows something that didn't happen. Don't `push` on the phone when it sends.
  4. Say in the phone card that the Mac must be awake with TailApps open.
- **Hardware on the user's Wi-Fi with an HTTP API** (an ESP32 web server, a smart plug, Home Assistant): use `fetch` to its local address (`"http://192.168.1.50/led"` with `net:192.168.1.50`, or `net:esp32.local`). The same button then works on the Mac and on an iPhone on the same Wi-Fi. Don't use curl in a script.
- **Notify the other device:** to reach an iPhone, add `"alert": "short text"` to the `send` step. Keep secrets out of it: alert text isn't end-to-end encrypted. A Mac ignores `alert`, so for a phone → Mac ping, `notify` in the Mac copy's `on_receive`.
- **Files:** a `send` step's `file` key (from the Mac or the iPhone: a capture, a `camera.take` or `photos.pick` photo, a `files.pick` file, or a received one; ≤ 10 MB) arrives as `$args.file` (`received/<name>`), which `image`, `gallery` and steps can use.

### 3. What can't be multi-device, and how to say so

- **Sensitive apps** (clipboard history, secrets): set top-level `"sync": "never"`. Then there are no send steps at all.
- **Purely local tools** (a port killer, a disk-space monitor for this Mac): it's fine to stay Mac only. Say so in the app's `description`, and don't add a phone card that pretends otherwise.
- **Mac-only parts on a shared card:** give the part `"platforms": ["macos"]` so the iPhone hides it instead of showing a dead button.

### 4. Replays and `on_receive` hygiene

- A copy added later on an iPhone gets the last 20 sends (30 days) replayed through `on_receive`. During a replay `notify` and `send` do nothing, but other steps run. So keep `open` steps and outside `fetch` calls out of `on_receive`, or the replay repeats them.
- `$args.event` is data from the user's own devices, but still check it: guard with `if` before you use a field.
- Every send arrives, in order. Clearing a list on all devices means sending a "clear" event (e.g. `{ "clear": true }`) that `on_receive` handles with `if`.

## Inputs: native controls with `field`

Every input is one `field` with a `type`, drawn as the platform's own control: `text`, `search`, `textarea`, `number`, `stepper`, `toggle` (a switch; `"style": "checkbox"` on the Mac), `slider`, `select`, `segmented`, `date` (`"time": true` adds a time, `"style": "graphical"` shows the month), `time` (stores `"HH:MM"`), `color` (a hue name). Don't build these from buttons.

- `bind` keeps the pick in a state key. To do something when it changes, add `on_change`: the action gets `$args.value` and `$args.previous` without declaring them. A slider runs it when let go (`"live": true` while dragging); text fields half a second after typing stops.
- To control something the app reads from a source (the volume, Wi-Fi), use `value` instead of `bind`, plus `on_change`: `{ "field": "Volume", "type": "slider", "value": "$sound.volume", "min": 0, "max": 100, "unit": "%", "on_change": "set_volume" }` with `"set_volume": { "steps": [{ "audio.volume.set": "$args.value" }] }`.
- `options` (select, segmented) are strings, or `{ "label": "High", "value": 3 }` when what's stored differs from what's shown; segmented options can have an `icon`.
- `format` (one formatter, like `"percent"`) and `unit` (`"°C"`) change how a slider's or stepper's number is shown, never what's stored.
- An `on_change` action with `confirm` only works with `value` (the control goes back if the user says no), not `bind`.
- In show_ui, fields only `bind` to `$ui.<name>`: no `value` or `on_change`.

## Scan a code, find where I am (Mac and iPhone)

- **Scan with the camera:** `{ "scan.code": { "types": ["qr"] }, "as": "code" }` (leave `types` out for every type) → `$code.type`, `$code.value`, permission `camera`. Cancel stops the action. For a code in a photo or picked file use `vision.codes` instead.
- **Where am I:** `{ "location.get": { "accuracy": "best" }, "as": "here" }` (or `"city"`, about a kilometre) → `$here.lat`, `$here.lng`, `$here.accuracy` (metres), `$here.at`, permission `location`. Show it with a `map` part, or `send` it to the user's other devices. One fix per tap; there's no background location or "tell me when I arrive".
- Both run only from the user's own click or tap, never from a source, timer, inbox, another device or `run_action`. See examples/scanner.json and examples/where-i-am.json.

## System controls (Mac): sound, Wi-Fi, Bluetooth, network, power, usage

No script needed for these. A source `{ "system": "audio" }` (or `network`, `power`, `wifi`, `bluetooth`) holds that part of the Mac and refreshes when macOS says it changed; `{ "system": "usage", "every": 5 }` holds CPU, GPU, memory and disk use (it has no change notice, so give it `every`); `get_catalog { "section": "system" }` has each value's shape. Steps change things: `audio.volume.set` (0–100 or `{ "by": -10 }`), `audio.mute` / `audio.input.mute` (true, false, "toggle"), `audio.output.set` / `audio.input.set` (a device name or id from the audio source's `outputs` / `inputs`), `wifi.power`, `wifi.join` (a network the Mac already knows), `bluetooth.connect` / `bluetooth.disconnect` (a paired device's name or address), `display.sleep`, `wallpaper.set` (the desktop picture: a picture the app may read, like a dropped file's path, or `{ "image": "$args.item.path", "screen": "all" | "main" | "<name>", "fit": "fill" | "fit" | "stretch" | "center" }`; examples/wallpaper.json also lets an iPhone pick it).
- **Now playing (Mac):** `{ "system": "media" }` (permission `media.read`) holds what Music or Spotify plays: `app`, `state` (playing, paused, stopped, or none when no player is open), `title`, `artist`, `album`, `artwork` (an https cover from Spotify, null for Music), `position`, `duration`, `progress` (0–1, for a paused bar), and while it plays `started_at` / `ends_at`, so `{ "progress": "$np.ends_at", "from": "$np.started_at" }` and a `timer` move by themselves (no `every`). Steps (permission `media.control`): `media.play`, `media.pause`, `media.toggle`, `media.next`, `media.previous` (`{}`, or `{ "app": "Spotify" }`), `media.seek` (seconds, `{ "to": 30 }` or `{ "by": -15 }`). macOS asks once per player (Automation). For the iPhone, sync the Mac's value in a `"sync": true` state key and route the phone's buttons through a send (see examples/now-playing.json).

- Read and change are separate permissions: `audio.read` / `audio.control`, `wifi.read` / `wifi.control`, `bluetooth.read` / `bluetooth.control`, `network.read`, `power.read` / `power.control`, `usage.read`, `wallpaper.control`, `media.read` / `media.control`. Ask only for what the app uses: a battery card needs `power.read` only.
- TailApps gives the building blocks; the app decides. "Office mode" is a `wifi` source's `on_change` with an `if` on `$wifi.network` and `audio.output.set`. "Switch to AirPods" is a button with `bluetooth.connect` then `audio.output.set`.
- The Wi-Fi network's name needs Location (macOS asks once); until then `network` is null and `name_hidden` is true. Show that honestly instead of "Not connected".
- Bluetooth on/off has no public API: use `cli:blueutil` with `requires`, or the user's own Shortcut.
- A volume slider or Wi-Fi switch is a `field` with `value` and `on_change` (see Inputs), not a row of buttons.
- The card's ⋯ menu offers Undo for the last volume, mute, device or Wi-Fi power change, so apps don't need their own undo.
- **Keep awake (Mac and iPhone):** `{ "awake.start": { "display": true, "minutes": 60 } }` (both optional; `display` keeps the Mac's screen on too, the iPhone always keeps its screen on while TailApps is open) and `{ "awake.stop": {} }`, permission `power.control`. It ends by itself after `minutes` or when the app is turned off; the Mac starts it again, with the time left, after TailApps restarts (an update, say); starting again replaces the last one. Keep your own state to show it (a `timer` on an `until` time with `on_end`), and word an open-ended one "until you stop it". See examples/keep-awake.json.

## Confirm with Face ID or Touch ID

- `"confirm": { "text": "Unlock the front door?", "auth": "biometric" }` on an action asks for Face ID, Touch ID or the passcode (Mac and iPhone) instead of a Yes/Cancel question, on every run, whoever starts it. Cancel stops the action, and the run fails with "Not confirmed". No permission. Use it for actions that open, unlock, pay or delete; a plain `"confirm": "Sure?"` is enough for the rest. It fails while the iPhone is locked or TailApps is in the background, so don't put it on an `on_receive` or timer action.

## Permissions and safety (the validator enforces these)

- Every cli, script, fetch and capability needs a matching string in `permissions` (`net:<host>`, `script:<name>`, `send:<inbox>`, `inbox:<name>`…). `validate_app` names the missing ones.
- `cli` takes a bare binary and an args array. There's no shell. For pipes, use a script in `scripts`.
- Scripts and CLIs run in a sandbox. They can't read `~/.ssh`, `~/.aws`, browser data or TailApps' own files. They write only to `$TMPDIR`, caches and folders the user picked for a `files.write:<setting>`. A script gets the network only with a `net:<host>` permission (cli steps always have it). For the GitHub CLI's sign-in add `uses:gh`; for git over SSH add `uses:git-ssh`. A blocked file or host fails the step with "TailApps blocked …" and says what to declare.
- Keys go in Connections (`"auth": "<connection>"`, `env: { "TOKEN": "connection:<name>" }`), never in the app or the chat.
- For a service with OAuth (Linear, Google…), prefer a sign-in over an API key: an `oauth` provider plus `"auth": "oauth:<provider>"` on the fetch (SPEC §63). PKCE only, never a client secret. The card shows "Sign in with <name>" until the person signs in, on the Mac and the iPhone alike; `create_app` returns `sign_ins_missing`. Never ask for a token in chat.
- Folder, file and connection settings are picked by the user. Agents can't prefill them.
- State holds raw values. Format at display time with pipes (`| ago`, `| currency`…).

## Before you call create_app

- [ ] `validate_app` with `targets: ["macos", "ios"]` has no errors, and you've read `warnings`, `surfaces` and `suggestions`.
- [ ] `views.menubar` has a `card` or `row` choice and a short `label` (with `label_tone` and `label_icon` if the state changes).
- [ ] `views.floating` is set if people keep the app open, or if `shortcuts.open` should pop it out.
- [ ] The menubar card works alone, for the Dashboard and the phone default.
- [ ] Groups of buttons are a `grid` with full rows (`span` for the last), styled by role, `size: "l"` on the phone.
- [ ] On the iPhone: every visible button runs there, or the phone has its own card that routes through the Mac, or the app is deliberately Mac only and says so.
- [ ] Cross-device: values that should be the same everywhere are synced state keys (`"sync": true`); messages and logs use send and inbox. The Mac reports back for routed work, and `"sync": "never"` is set for sensitive apps.
- [ ] Tell the user what to approve, what to set up, and to turn on Sync to My Devices on each device when the app uses it.
