agentleFS
aashariaashari/ai-agent-skills/skills/apple-calendar/calendar-core/SKILL.md

calendar-core

Skill7 starsChanged 9 months agoMITView on GitHub

Background technical reference for Apple Calendar data on macOS. Auto-loaded when any calendar-* skill executes. Contains DB path, CoreData epoch conversion, schema, canonical query, and filtering rules.

The file

We split this skill into the rules it gives an agent

3 rules. About 0 are common, 2 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    All timestamps are seconds since January 1, 2001, not 1970.

    line 29
  2. Very specific:

    Always use OccurrenceCache as the entry point for any time-windowed query.

    line 45
  3. Distinctive:

    Only fetch attendees for specific events — never bulk join, it's slow:

    line 148

≈ “Common” is an estimate: at least 1 in 5 of the 364,980 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Apple Calendar — Local Data Reference

Database Location

$HOME/Library/Group Containers/group.com.apple.calendar/Calendar.sqlitedb

WAL mode — always accompanied by .sqlitedb-shm and .sqlitedb-wal. Reads work fine against the live database without locking.

DB="$HOME/Library/Group Containers/group.com.apple.calendar/Calendar.sqlitedb"
sqlite3 "$DB" "SELECT ..."

Critical: CoreData Epoch (NOT Unix Epoch)

All timestamps are seconds since January 1, 2001, not 1970. Convert in SQLite:

datetime(field + 978307200, 'unixepoch', 'localtime')

Convert current time to CoreData timestamp in bash:

NOW_CD=$(( $(date +%s) - 978307200 ))
FUTURE_CD=$(( $(date +%s) + N * 86400 - 978307200 ))

Critical: OccurrenceCache for Recurring Events

Never query CalendarItem.start_date directly for date-range queries. It only holds the original first occurrence. Future instances of recurring events only exist in OccurrenceCache.

Always use OccurrenceCache as the entry point for any time-windowed query.

occurrence_start_date is NULL for some recurring events — use COALESCE(occurrence_start_date, occurrence_date) for start time.

SQLite Schema

Key Tables

TableKey Columns
CalendarItemROWID, summary, start_date, end_date, start_tz, end_tz, all_day, description, url, conference_url, location_id, has_attendees, has_recurrences, status, invitation_status, hidden, organizer_id, self_attendee_id, calendar_id
OccurrenceCacheevent_id (→CalendarItem.ROWID), occurrence_date, occurrence_start_date, occurrence_end_date
CalendarROWID, title, color, type, store_id
StoreROWID, name (email/account name), type, disabled
LocationROWID, title, latitude, longitude, address
ParticipantROWID, owner_id (→CalendarItem.ROWID), email, entity_type, role, status
RecurrenceROWID, owner_id, frequency, interval, specifier

CalendarItem.status Values

  • 0 — none / tentative
  • 1 — confirmed
  • 2 — cancelled (exclude these)

CalendarItem.invitation_status Values

  • 0 — none (own events)
  • 3 — pending invite (not yet accepted)

Store.type Values

  • 0 — local
  • 1 — local
  • 5 — "Found in Mail" — always exclude (auto-created duplicates from email invites)

Participant.entity_type Values

  • 7 — attendee
  • 8 — organizer

Participant.status Values

  • 0 — needs-action
  • 1 — accepted
  • 2 — declined
  • 3 — tentative

Participant.role Values

  • 0 — non-participant / unknown
  • 1 — required
  • 2 — optional

Recurrence.frequency Values

  • 1 — daily
  • 2 — weekly
  • 3 — monthly
  • 4 — yearly

Standard Exclusion Filters

Always apply:

WHERE ci.hidden = 0          -- exclude hidden events
  AND ci.status != 2         -- exclude cancelled events
  AND s.type != 5            -- exclude "Found in Mail" duplicates
  AND s.disabled = 0         -- active accounts only

Canonical Query Template

SELECT
  ci.ROWID as id,
  ci.summary as title,
  COALESCE(
    datetime(oc.occurrence_start_date + 978307200, 'unixepoch', 'localtime'),
    datetime(oc.occurrence_date + 978307200, 'unixepoch', 'localtime')
  ) as start_local,
  datetime(oc.occurrence_end_date + 978307200, 'unixepoch', 'localtime') as end_local,
  ci.all_day,
  ci.start_tz as timezone,
  COALESCE(l.title, '') as location,
  ci.conference_url,
  ci.has_attendees,
  ci.has_recurrences,
  ci.status,
  ci.invitation_status,
  c.title as calendar_name,
  s.name as account_name
FROM OccurrenceCache oc
JOIN CalendarItem ci ON oc.event_id = ci.ROWID
LEFT JOIN Calendar c ON ci.calendar_id = c.ROWID
LEFT JOIN Store s ON c.store_id = s.ROWID
LEFT JOIN Location l ON ci.location_id = l.ROWID
WHERE oc.occurrence_date >= NOW_CD
  AND oc.occurrence_date <= FUTURE_CD
  AND ci.hidden = 0
  AND ci.status != 2
  AND s.type != 5
  AND s.disabled = 0
GROUP BY ci.ROWID, date(oc.occurrence_date + 978307200, 'unixepoch', 'localtime')
ORDER BY oc.occurrence_date;

GROUP BY ci.ROWID, date(...) deduplicates multi-day spanning events that appear once per day in OccurrenceCache.

Fetching Attendees (On-Demand Per Event)

Only fetch attendees for specific events — never bulk join, it's slow:

SELECT email, entity_type, role, status
FROM Participant
WHERE owner_id = EVENT_ROWID
ORDER BY entity_type DESC, status;

Filter s.disabled = 0 to get only active accounts. Discover your active accounts with:

SELECT s.name, s.type, COUNT(*) as calendars
FROM Store s
JOIN Calendar c ON c.store_id = s.ROWID
WHERE s.type != 5 AND s.disabled = 0
GROUP BY s.ROWID
ORDER BY s.name;

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.