macos is one signed binary that gives a script or an AI agent your Mac's calendar, contacts, mail, messages, notes, reminders, windows and screen, with JSON out and plain exit codes.
brew install manuaudio/tap/macos-clior, without Homebrew:
curl -fsSL https://raw.githubusercontent.com/manuaudio/macos-cli/main/install.sh | bashThe recording is real: an agent's three calls on a Mac, under a fresh home folder, with a test contact the script creates and deletes (scripts/demo/record.sh):
macos doctor --for-agent | jq '{ready, missing: .missing[:3]}'
macos calendar events --json --calendar "Demo Gigs"
macos contacts search "Quillfeather" --jsonAdd the skill to Claude Code, Codex, Cursor and the other agents skills.sh knows:
npx skills add manuaudio/macos-cliIn Claude Code it is also a plugin:
/plugin marketplace add manuaudio/macos-cli
/plugin install macos-cli@macos-cli
OpenClaw takes it from ClawHub:
clawhub install macos-cliThe agent starts with macos doctor --for-agent: every macOS permission, its state and how a person grants it, without showing a single prompt. Then it calls macos <area> <action> --json and reads one JSON value from stdout. A failure is JSON too, with stderr empty:
The exit code says what kind of failure it was: 64 a bad command line, 3 not found, 4 not allowed, 5 timed out, 6 the app failed (the full table). Sending mail and messages, deleting, clicking, typing and the keychain start turned off; only a person at a terminal can turn one on, in a policy file the agent cannot change (the policy file).
| Area | Examples |
|---|---|
| Calendar | list, rich JSON export, create (custom alarms), update, delete (by id or title) across all linked calendars |
| Reminders | create, complete, list by list, due dates, when arriving at or leaving home, work or an address |
| Contacts | search, read, create, update, by name, email or phone; export every card per account |
| Messages | send iMessage/SMS, read threads, search, export rows from chat.db for ingestion |
| indexed search and read, sending addresses, drafts, send and reply with an explicit sender and delivery confirmation | |
| chats, read, search, doctor; policy-gated send to individual chats or phone numbers | |
| Notes | read, create, search Apple Notes |
| Music | now playing, play/pause, skip, library queries |
| Safari | read the current tab, list tabs, open URLs, run a page's JavaScript |
| Screen | full/window/region screenshots, screen recording check |
| OCR | extract text from the screen, a region, or any image |
| Windows | list, move, resize, focus app windows |
| Input | type text, send shortcuts, move and click the mouse |
| Accessibility | find and click UI elements by name, dump the UI tree |
| System | battery, focus modes, processes, disks, network shares, defaults, network |
| Keychain | read/write passwords and secrets (with your approval) |
| Files and PDF | search files, read metadata, extract PDF text |
| Tours | Master Tour tours, days, hotels, crew and guest lists; a Daysheets tour's days from its calendar feed |
macos <area> --help explains one area, and SKILL.md lists every command, its flags and whether it writes.
Three tools an agent might use on a Mac instead, as of 2026-11-11:
| Scope | Install | JSON | Permissions | GitHub stars | |
|---|---|---|---|---|---|
| macos-cli | 40+ areas: calendar, contacts, mail, messages, notes, reminders, windows, screen, the Accessibility tree | Homebrew or curl | bash, one signed binary |
every data command, errors included | doctor --for-agent reports every area without prompting; sends, deletes and input start off, and only a person turns them on |
1 |
| remindctl | Reminders | Homebrew | --json on its commands |
doctor, status and authorize for Reminders |
417 |
| imsg | Messages | Homebrew | NDJSON, JSON-RPC | Full Disk Access to read, Automation to send | 1,406 |
| apple-mcp | Messages, Notes, Contacts, Mail, Reminders, Calendar, Maps | npx into an MCP client, runs on Bun |
MCP tool results | macOS Automation prompts per app; no policy of its own | 3,112, archived |
Pick remindctl or imsg when one app is all you need; they go deeper there. macos-cli is for an agent that needs the whole Mac through one binary and one error contract.
brew install manuaudio/tap/macos-cliHomebrew installs the Release: a single macos binary for Apple silicon, signed with a Developer ID and notarized by Apple. brew upgrade macos-cli updates it, and the permissions you granted stay, because every release carries the same signature. Type the full name: Homebrew refuses a short brew install macos-cli from a tap you have not trusted.
No Homebrew:
curl -fsSL https://raw.githubusercontent.com/manuaudio/macos-cli/main/install.sh | bashThe same signed, notarized binary, without Homebrew: the script checks its sha256, Developer ID signature, team and version, and installs it to $HOME/.local/bin/macos. No Xcode, no sudo, no background service, no second executable.
Update the curl install in place, at the same path, so the permissions you granted stay with it (--check only reports):
macos updateInstall somewhere else on your PATH:
curl -fsSL https://raw.githubusercontent.com/manuaudio/macos-cli/main/install.sh | MACOS_CLI_INSTALL_DIR="$HOME/bin" bashBuild from source instead with MACOS_CLI_SIGN_MODE=adhoc ./install.sh (needs Xcode Command Line Tools and Swift 5.9+), or with your own certificate by setting MACOS_CLI_SIGN_IDENTITY. An ad-hoc build has one catch: macOS ties privacy grants to the signature, so it asks again for Calendars, Contacts and the rest after every rebuild. docs/SIGNING.md has the details.
The installer does not grant any macOS privacy permission for you — it prints guidance and leaves you in control (see Permissions).
Requirements: macOS 13 (Ventura)+ on Apple silicon. Make sure
$HOME/.local/binis on yourPATH(the installer reminds you if it isn't).
macos --version
macos doctor # every macOS permission, its state, and how to get it (never prompts)
macos setup # checks every capability end to end — one line per capability, passed or failed# Calendar & reminders
macos calendar events --json
macos reminders create --title "Call the bank" --due "2026-07-21 09:00"
# Find a contact, then text them
macos contacts search "Ryan" --json
macos messages send --to "+13105550100" --text "On my way"
# See your screen — literally
macos screenshot full --output ~/shot.png
macos ocr full # everything on screen → plain text
# Read the web page you're looking at
macos safari read --json
# Drive the UI like a human (Accessibility)
macos ax find "Sign In" # locate it
macos ax click "Sign In" # click it — by label, no pixel coordinates
macos keyboard type "hello world"Commands that return data take --json for clean, parseable output:
macos system battery --json
# {
# "charging" : false,
# "level" : 87,
# "plugged_in" : false,
# "time_remaining_minutes" : 312
# }macOS CLI is one binary and nothing else — no MCP server, no HTTP bridge, no daemon. An agent drives it exactly the way you do: it runs macos <area> <action> --json as a subprocess and parses the result. That is the whole integration. Point your agent framework's shell/exec tool at $HOME/.local/bin/macos and it can read your calendar, triage your inbox, move windows, and click buttons by name.
# Whatever your agent can shell out to, it can call:
"$HOME/.local/bin/macos" reminders export --json
"$HOME/.local/bin/macos" calendar events --jsonThe repo's SKILL.md teaches an agent the tool: check permissions first, then every
command, which ones write, the error envelope and the exit codes. One line adds it to Claude Code,
Codex, Cursor and the other agents skills.sh knows:
npx skills add manuaudio/macos-cliClaude Code also installs it as a plugin: /plugin marketplace add manuaudio/macos-cli, then /plugin install macos-cli@macos-cli. The plugin is this repository's SKILL.md, nothing more.
Hermes Agent takes it from its URL:
hermes skills install https://raw.githubusercontent.com/manuaudio/macos-cli/main/SKILL.mdThe skill's command list is generated from the binary (bash scripts/gen-skill.sh). The binary
prints the same list itself with macos commands --json, each command's flags and whether it
writes.
Before an agent reads anything, it can ask the binary what macOS allows it, without triggering a single prompt:
// macos doctor --for-agent (trimmed)
{
"ok": true,
"ready": false,
"missing": ["calendars", "full_disk_access"],
"areas": [
{ "area": "calendars", "state": "not_determined", "granted": false, "needed_by": ["calendar"],
"hint": "A person runs `macos authorize calendars`, or turns it on in System Settings › Privacy & Security › Calendars.",
"authorize": "macos authorize calendars" },
{ "area": "reminders", "state": "granted", "granted": true, "needed_by": ["reminders"],
"hint": null, "authorize": "macos authorize reminders" }
],
"binary": { "path": "…/macos", "bundle_id": "com.manuaudio.macos-cli", "version": "…", "signature": "…", "team_id": "…" },
"session": { "terminal": false, "gui_session": true, "note": "…" },
"capabilities": { "calendar.read": true, "mail.send": false }
}Areas: calendars, reminders, contacts, full_disk_access, accessibility, screen_recording,
location, and automation.<app> for Mail, Messages, Notes, Safari, Music, Photos, Finder and
System Events. A state is granted, denied, not_determined, restricted, write_only or
unknown (macOS answers Automation only for a running app). capabilities is the auth.json
policy below, resolved.
macos authorize <area> asks macOS for one area: it shows the system prompt (waiting at most
--timeout seconds, default 60), or opens the settings pane for the areas macOS never prompts for
again. A person clicks Allow; the agent cannot.
A command never waits on a prompt nobody can see. When Calendars, Reminders or Contacts are
undecided and no person is at a terminal (an agent's shell, cron, launchd), the command fails at
once with access_denied, "state": "not_determined" and the authorize command to run. Notes
reads without Full Disk Access fail with access_denied, "area": "full_disk_access", never
count: 0.
~/.config/macos-cli/auth.json turns capabilities on and off (macos auth list). Turning one
on — auth grant, auth reset, auth setup — asks the person at the terminal to type a
confirmation, read from /dev/tty, so piped input cannot answer it. Without a terminal it refuses
with person_required (exit 4) and the policy is unchanged: the agent the policy restricts cannot
lift it. auth deny needs no confirmation.
From a person's accounts, agents draft; a person sends. mail.draft is on by default:
mail draft and mail reply --draft save the message unsent in the owning account's Drafts
and answer with its id and account, for the person to read and send. mail.send (and
whatsapp.send) start off; with them off, mail send and mail reply stop with
capability_denied (exit 4) before Mail creates anything.
These commands are built for unattended, read-mostly automation — stable JSON, fail-closed filters, and a machine-readable error contract:
| Command | What it guarantees |
|---|---|
macos reminders status --json |
Reports the Reminders authorization state without prompting — safe to poll. |
macos reminders export --json |
Rich read-only export. --list NAME is fail-closed: an unknown list yields zero rows, never all of them. |
macos reminders export --timeout N |
A fetch timeout is a hard error — prints {"status":"error","error":"fetch_timeout",…} on stdout and exits 5, so a hang can never be mistaken for "zero reminders." |
macos reminders complete --id ID |
The only way to complete a reminder. Defaults to a dry run; it writes only when --approve exactly matches a non-empty APPLE_EVENTKIT_APPROVE_TOKEN environment variable. complete-safe is a kept alias. |
macos calendar export --json |
Rich read-only export as a single envelope {ok,status,count,filter,calendars,events}. Enumerates all linked calendars from all sources by default; --calendar NAME is fail-closed (unknown name ⇒ zero events and zero calendars, never all). --from/--to validate from ≤ to and emit a structured invalid_date_range/invalid_date error + exit 64 on bad input. |
macos calendar … --calendar-id ID |
events, export, create, update and delete take the id calendar calendars --json prints (with source, writable and color). A write by a --calendar NAME that two calendars share is refused with ambiguous_calendar (exit 64) and both ids, never sent to the first one found. |
macos calendar delete --id ID |
Deletes exactly one event by stable identifier (EKSpanThisEvent). --id and --title/--date are mutually exclusive; a missing id prints {"error":"event_not_found",…,"deleted":false} and exits 3. Result carries only id + deleted — no private event content. |
macos notes export --json |
Read-only Notes export straight from the local store (Unicode-preserving), with a fail-closed --folder filter. |
The old reminders done command is retired — it was an ungated write. It now performs no writes and prints a one-line pointer to reminders complete.
Example — let an agent complete a reminder only after you've set the approval token in its environment:
export APPLE_EVENTKIT_APPROVE_TOKEN="$(openssl rand -hex 16)" # you set this, once
macos reminders complete --id "$ID" # dry run — no token passed, nothing changes
macos reminders complete --id "$ID" --approve "$APPLE_EVENTKIT_APPROVE_TOKEN" # writesUnder --json a failure is one JSON object on stdout, and stderr stays empty. The export commands always answer this way, with or without the flag. Branch on error; message and hint are for people and may change.
// macos calendar events --json --calendar "Nope"
{
"ok": false,
"status": "error",
"error": "calendar_not_found",
"message": "No calendar is named 'Nope'.",
"hint": "Run `macos calendar calendars` to see the names.",
"calendar": "Nope",
"exit_code": 3
}| Exit | Meaning | error codes |
|---|---|---|
| 0 | Success | — |
| 64 | The command line was rejected: unknown option, missing argument, a value that doesn't parse | usage, invalid_argument, invalid_date, invalid_date_range, invalid_alarm, invalid_delete_mode, invalid_timezone, ambiguous_calendar |
| 3 | The named thing does not exist | not_found, calendar_not_found, event_not_found |
| 4 | Not allowed | capability_denied (turned off in auth.json), access_denied (macOS privacy settings), person_required (a policy change only a person may make), credentials_missing / credentials_refused (a tour connector has no key, or the service refused it) |
| 5 | No answer in time | timeout, fetch_timeout |
| 6 | The system or an app reported an error | app_error |
Commands that only perform an action (move a window, click, play music) print a line of text and have no --json output; asked for --json, they answer with a usage error that says so. Without --json, a failure is one Error: line and usually a Hint: line on stderr.
Two read shapes, chosen for compatibility:
calendar events --jsonreturns a bare array (unchanged since 0.7.0). Every element still carries the six stable keysid,title,calendar,start,end,all_day; richer fields (source,location,notes,url,timezone,created,last_modified,status,availability,recurring,organizer,attendees,alarms) are additive and appear only when the event has them.calendar export --jsonwraps those same event objects in the ingestion envelope (this is the shape to prefer for sync):
// macos calendar export --from 2026-07-01 --to 2026-07-31 --json (fake data)
{
"ok": true,
"status": "ok",
"count": 1,
"filter": null, // echoes --calendar, or null when unfiltered
"calendars": ["Home", "Work", "Gigs"],// exactly the resolved (never broadened) set
"events": [
{
"id": "F1A2B3C4-0000-0000-0000-000000000001",
"title": "Load-in",
"calendar": "Gigs",
"source": "iCloud",
"start": "2026-07-20T22:00:00Z",
"end": "2026-07-21T01:00:00Z",
"all_day": false,
"recurring": false,
"location": "The Example Room",
"timezone": "America/Los_Angeles",
"last_modified": "2026-07-10T18:04:00Z",
"status": "confirmed",
"availability": "busy",
"attendees": ["Stage Manager", "[email protected]"],
"alarms": [1440, 60]
}
]
}Dates are ISO8601 UTC unless --timezone America/Los_Angeles (any IANA name) asks for another zone, which is also the zone --from/--to are read in. --start/--end are accepted for --from/--to. export --since 2026-11-01 (or an ISO 8601 date-time) keeps only events created or changed since then. --from is inclusive, --to is the exclusive upper bound; both default to a bounded ±1-year window and accept explicit multi-year ranges (a single EventKit query spans at most ~4 years — chunk beyond that). An unknown --calendar returns a valid envelope with count: 0 and calendars: [] — never all.
calendar update --id ID --alarm 15 --alarm 60 replaces an event's alarms; --clear-alarms removes them.
Create with custom alarms (each --alarm is minutes-before and repeatable; with no --alarm the event has no alarms; the result echoes the minute list, never notes):
// macos calendar create --title "Soundcheck" --start "2026-07-20 16:00" \
// --alarm 120 --alarm 30 --json (fake data)
{ "id": "…", "title": "Soundcheck", "calendar": "Gigs",
"start": "…", "end": "…", "all_day": false, "alarms": [120, 30] }Both macos contacts get <id> --json and macos contacts export now carry a job_title field. It is a string that is always present — the contact's title, or an empty string "" when the contact has no title. It is never null and never omitted, matching the export convention so an ingestion consumer sees one stable shape. Every pre-0.8.1 key (id, name, organization, phones, emails, and the rich export fields) is unchanged — job_title is purely additive.
Because the field reads back exactly as written, an agent can do a verified read-after-write around contacts update --job-title:
macos contacts update "$ID" --job-title "Tour Manager" # write
macos contacts get "$ID" --json | jq -r .job_title # → "Tour Manager"The written value appears verbatim in the very next get/export, so the write can be confirmed rather than assumed.
contacts export carries a history_token. Pass it back as --since TOKEN and the export holds only the contacts added or changed since, plus deleted_ids, and a new history_token.
contacts export --per-source lists each account's own cards (iCloud, Google, On My Mac) instead of the linked person, each with source, source_id and source_type. Every exported card has is_me, true on the owner's card (false everywhere when Contacts has no My Card set).
messages export --since-rowid N reads chat.db, read-only, and prints every message after rowid N, oldest first: rowid, guid, date (ISO 8601, UTC), handle, service, text (taken from attributedBody when the text column is empty), is_from_me, chat_guid, chat_handles, attachments and the associated_message_type and item_type that mark tapbacks and system rows. last_rowid is the next run's --since-rowid. messages latest --json gives the newest message time and rowid per service. Both need messages.read and Full Disk Access for the macos binary.
macos messages export --since-rowid 412000 --limit 500 | jq '.messages[] | select(.associated_message_type == 0) | .text'
macos messages latest --jsondisk mount smb://user@host/share mounts the share under /Volumes through NetFS, no root needed, and never shows a dialog. The password is the keychain item Finder saved for the server, or the value of the environment variable --password-env names; a URL with a password in it is refused. A share already mounted (by its .local name or the Bonjour name Finder uses) is reported where it is, not mounted twice. It needs disk.mount, which is on by default; disk.write (ejecting and unmounting) stays separate.
macos disk mount smb://[email protected]/Arimaka --json # {"mounted": true, "already": true, "mount_point": "/Volumes/Arimaka", …}
NAS_PASSWORD=… macos disk mount smb://[email protected]/TimeMachine --password-env NAS_PASSWORDsafari js SCRIPT (formerly safari execute, still accepted) runs JavaScript in a page and prints what it returns: the front window's current tab, --tab N in --window N, or the first tab whose URL contains --url TEXT. The script acts with that page's signed-in session, so it has its own capability, safari.js, off by default and separate from safari.execute. Safari needs Develop › Allow JavaScript from Apple Events.
macos safari js --url venmo.com "document.title"mail search QUERY --json returns each message's message_id (the Message-ID header), account and mailbox; mail read --id MESSAGE_ID reads that one message. Both take --mailbox NAME and --account NAME, which skip every other mailbox; an unknown one is not_found, not zero results.
macos mail accounts --json lists account ids and all sending addresses. Draft, send
and reply require --from [email protected]; mail draft and mail reply --draft save unsent
in that account's Drafts (mail.draft), sends need mail.send. An unowned address returns
sender_not_found (exit 3), without creating or sending a message. Duplicate ownership
is rejected. Use macos mail addresses add Work [email protected] --wait 600 (or
remove) to change an account's addresses; this requires the mail.write policy.
Mail must already be configured to send from that address at its provider.
Long bodies use --body-file message.txt or --body-file - for UTF-8 stdin.
After a send, macos waits up to --wait seconds for a new matching Sent-folder record
in Mail's read-only Envelope Index. A timeout returns still_in_outbox (exit 5);
check Mail before retrying to avoid duplicates. This confirms Mail filed the message,
not delivery to the recipient. Busy Apple events return mail_busy (exit 5).
Search matches indexed sender, recipients and subject; reading retrieves the body
through Mail. Older or inaccessible indexes fall back to Mail's search.
macos whatsapp chats --limit 3 --json, whatsapp read Alex --since 2026-01-01T00:00:00Z --json and whatsapp search hello --json read a read-only
ChatStorage database; a locked database uses a temporary SQLite backup.
macos whatsapp doctor --json checks the reader, app, Accessibility and send policy.
macos whatsapp send +15555550100 --text-file message.txt --json opens the app's
send URL and presses its Accessibility Send button only after matching the recipient
and composer text. It reports send_requested, not recipient delivery. Individual
chat ids, exact unique names and JIDs also work; group sending is unavailable.
Sending starts disabled; a person enables whatsapp.send through macos auth grant.
Readers need Full Disk Access; sending also needs Accessibility. No pointer or
keyboard events are synthesized.
Both read only, and both answer in JSON, with or without --json.
Master Tour uses Eventric's public API with your API key (my.eventric.com/portal/apikey). Save it once; the secret is read from stdin, never from the command line:
pbpaste | macos mastertour login --key YOUR_KEY
macos mastertour tourstour ID gives every day of a tour with its id; day ID, events DAY_ID, hotels DAY_ID, summary TOUR_ID YYYY-MM-DD, crew TOUR_ID and guestlist EVENT_ID read the rest. Each prints the API's data object.
Daysheets has no public API, but every tour has a calendar feed (Tour Settings → Add a calendar feed). Its URL opens the tour, so treat it as a password: macos daysheets login reads it from stdin and keeps it in the login keychain, and no output or error prints it.
pbpaste | macos daysheets login
macos daysheets days --from 2026-12-01 --to 2026-12-07days is a list of {date, events}; day YYYY-MM-DD is one of them (an empty events on a day with nothing). Each event has title, all_day, start, end, start_time, end_time and time_zone (the event's own zone), location, venue and city (LOCATION split at its first comma), notes and uid.
The environment wins over the keychain: MASTERTOUR_KEY and MASTERTOUR_SECRET, DAYSHEETS_FEED_URL. MACOS_CLI_KEYCHAIN=off uses the environment alone. Without a key the answer is credentials_missing (exit 4), naming what to set; a key the service refuses is credentials_refused. The policy names are mastertour.read and daysheets.read.
macOS gates these capabilities behind privacy permissions — by design. On first use you'll be prompted to grant Automation, Calendars, Contacts, Accessibility, Screen Recording, etc. Run macos doctor any time to see exactly what's granted and what's missing, and macos authorize <area> to ask for one. Nothing is bypassed; you stay in control.
git clone https://github.com/manuaudio/macos-cli
cd macos-cli
swift build -c release
mkdir -p ~/.local/bin && cp .build/release/macos-cli ~/.local/bin/macosSwiftPM names the product macos-cli; it is installed as macos. ./install.sh does the same and signs the binary; make test runs the tests.
Issues and PRs welcome. The codebase is plain Swift + swift-argument-parser — one command per file under Sources/macos-cli/Commands/.