automating-contacts
/automating-contacts
Automates macOS Contacts via JXA with AppleScript dictionary discovery. Use when asked to "automate contacts", "JXA contacts automation", "macOS address book scripting", "AppleScript contacts", or "Contacts app automation". Covers querying, CRUD, multi-value fields, groups, images, and ObjC bridge fallbacks.
- Author
- SpillwaveSolutions ↗
- Repository
- automating-mac-apps-plugin ↗
- Licence
- MIT
- Last repository change
- 22.08.2026
Assessment and security
- Files in this package
- 9
- Scripts
- 3
- HTML comments
- 0
- URLs in SKILL.md
- 0
No signals detected. Repository changed on 22.08.2026, without references to retired models or APIs.
MIT, open: use and modify while retaining author attribution.
- 3 scripts in this package. Review them before installing, as Claude may execute them.
Scripts: scripts/export_contacts_to_csv.py, scripts/import_contacts_from_csv.py, scripts/search_contacts.py
What it does and when to use it
Automates macOS Contacts via JXA with AppleScript dictionary discovery. Use when asked to "automate contacts", "JXA contacts automation", "macOS address book scripting", "AppleScript contacts", or "Contacts app automation". Covers querying, CRUD, multi-value fields, groups, images, and ObjC bridge fallbacks.
Triggers from the description
Original author description
Automates macOS Contacts via JXA with AppleScript dictionary discovery. Use when asked to "automate contacts", "JXA contacts automation", "macOS address book scripting", "AppleScript contacts", or "Contacts app automation". Covers querying, CRUD, multi-value fields, groups, images, and ObjC bridge fallbacks.
How it works
- Relationship to Other Skills
- Core Framing
- Workflow (default)
- Quickstart (upsert + group)
- Pitfalls
- When Not to Use
- What to load
SKILL.md preview
---
name: automating-contacts
description: Automates macOS Contacts via JXA with AppleScript dictionary discovery. Use when asked to "automate contacts", "JXA contacts automation", "macOS address book scripting", "AppleScript contacts", or "Contacts app automation". Covers querying, CRUD, multi-value fields, groups, images, and ObjC bridge fallbacks.
allowed-tools:
- Bash
- Read
- Write
---
# Automating Contacts (JXA-first, AppleScript discovery)
## Relationship to Other Skills
- **Standalone for Contacts:** Use this skill for Contacts-specific operations (querying, CRUD, groups).
- **Reuse `automating-mac-apps` for:** TCC permissions setup, shell command helpers, UI scripting fallbacks, and ObjC bridge patterns.
- **Integration:** Load both skills when combining Contacts automation with broader macOS scripting.
- **PyXA Installation:** To use PyXA examples in this skill, see the installation instructions in `automating-mac-apps` skill (PyXA Installation section).
## Core Framing
- Contacts dictionary is AppleScript-first; discover there, implement in JXA
- Object specifiers: read with methods (`name()`, `emails()`), write with assignments
- Multi-value fields (emails, phones, addresses) are elements; use constructor + `.push()`
- Group membership: `add ... to` command or `.people.push`; handle duplicates defensively
- TCC permissions required: running host must have Contacts access
## Workflow (default)
1) Inspect the Contacts dictionary in Script Editor (JavaScript view).
2) Prototype minimal AppleScript to validate verbs; port to JXA with specifier reads/writes.
3) Use `.whose` for coarse filtering; fall back to hybrid (coarse filter + JS refine) when needed.
4) Create records with proxy + `make`, then assign primitives and push multi-values; `Contacts.save()` to persist.
5) Verify persistence: check `person.id()` exists after save; handle TCC permission errors.
6) Manage groups after person creation; guard against duplicate membership with existence checks.
7) For photos or broken bridges, use ObjC/clipboard fallback; for heavy queries, batch read or pre-filter.
8) Test operations: run→check results→fix errors in iterative loop.
### Validation Checklist
- [ ] Contacts permissions granted (System Settings > Privacy & Security > Contacts)
- [ ] Dictionary inspected and verbs validated in Script Editor
- [ ] AppleScript prototype runs without errors
- [ ] JXA port handles specifiers correctly
- [ ] Multi-value fields pushed to arrays properly
- [ ] Groups existence checked before creation
- [ ] Operations saved and verified with `.id()` checks
- [ ] Error handling wraps all operations
## Quickstart (upsert + group)
```javascript
const Contacts = Application("Contacts");
const email = "ada@example.com";
try {
const existing = Contacts.people.whose({ emails: { value: { _equals: email } } })();
const person = existing.length ? existing[0] : Contacts.Person().make();
person.firstName = "Ada";
person.lastName = "Lovelace";
// Handle multi-value email
const work = Contacts.Email({ label: "Work", value: email });
person.emails.push(work);
Contacts.save();
// Handle groups with error checking
let grp;
try {
grp = Contacts.groups.byName("VIP");
grp.name(); // Verify exists
} catch (e) {
grp = Contacts.Group().make();
grp.name = "VIP";
}
Contacts.add(person, { to: grp });
Contacts.save();
console.log("Contact upserted successfully");
} catch (error) {
console.error("Contacts operation failed:", error);
}
```
## Pitfalls
- **TCC Permissions**: Photos/attachments require TCC + Accessibility; use clipboard fallback if blocked
- **Yearless birthdays**: Not cleanly scriptable; use full dates
- **Advanced triggers**: Delegate geofencing to Shortcuts app
- **Heavy queries**: Batch read or pre-filter to avoid timeouts
## When Not to Use
- Non-macOS platforms (use platform-specific APIs)
- Simple AppleScript-only solutions (skip JXA complexity)
- iCloud sync operations (use native Contacts framework)
- User-facing apps (use native Contacts framework)
- Cross-platform contact management (use CardDAV or vCard APIs)
## What to load
- JXA basics & specifiers: `automating-contacts/references/contacts-basics.md`
- Recipes (query, create, multi-values, groups): `automating-contacts/references/contacts-recipes.md`
- Advanced (hybrid filters, clipboard image, TCC, date pitfalls): `automating-contacts/references/contacts-advanced.md`
- Dictionary & type map: `automating-contacts/references/contacts-dictionary.md`
- **PyXA API Reference** (complete class/method docs): `automating-contacts/references/contacts-pyxa-api-reference.md`
Files in this package (9)
- SKILL.md 5 KB
- references/contacts-advanced.md 2 KB
- references/contacts-basics.md 2 KB
- references/contacts-dictionary.md 2 KB
- references/contacts-pyxa-api-reference.md 21 KB
- references/contacts-recipes.md 2 KB
- scripts/export_contacts_to_csv.py 3 KB
- scripts/import_contacts_from_csv.py 3 KB
- scripts/search_contacts.py 5 KB
Versions
The database has no other skills named automating-contacts.
Database snapshot: 13.11.2026 · package version 050e5564cb97 (SHA-256 digest of the entire package)
Downloads in the last 30 days: 0 · ranking
Similar skills
- 100automating-calendar
Automates macOS Calendar via JXA with AppleScript dictionary discovery. Use when asked to "create calendar events", "automate calendar", "JXA calendar scripting", "EventKit automation", or "PyXA calendar automation". Covers events, calendars, recurrence, time zones, batch… - 100automating-pages
Automates Apple Pages using JXA with AppleScript dictionary discovery. Use when asked to "automate Pages documents", "create documents programmatically", "JXA Pages scripting", or "export Pages to PDF". Covers documents, templates, text, styles, export, tables, images, and… - 100applescript
AppleScript and JXA automation for macOS. Use when user asks to automate apps, control system, run AppleScript/osascript, or integrate with macOS applications. - 100apple-notes-install-auth
Set up macOS automation access for Apple Notes via AppleScript, JXA, and Shortcuts. Use when configuring accessibility permissions, setting up osascript access, or initializing Apple Notes automation on macOS. Trigger: "setup apple notes", "apple notes automation", "apple notes permissions". - 100apple-notes-hello-world
Create, read, and list Apple Notes using JXA and AppleScript. Use when learning Notes automation, creating your first automated note, or testing read/write access to Apple Notes from scripts. Trigger: "apple notes hello world", "create apple note", "read apple notes", "apple… - 100macos-control
Control macOS GUI applications via mouse automation, keyboard input, screenshots, image recognition, and AppleScript execution. Use when you need to interact with macOS app UIs, take screenshots, click buttons, type text, scroll, drag, or locate images on screen.