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.
In this repository32 other files it gives its agents.
- calendar-accountsSkill
- calendar-attendeesSkill
- calendar-conflictsSkill
- calendar-eventSkill
- calendar-freeSkill
- calendar-recurringSkill
- calendar-searchSkill
- calendar-statsSkill
- calendar-todaySkill
- calendar-upcomingSkill
- mail-accountsSkill
- mail-action-itemsSkill
- mail-attachmentsSkill
- mail-bankingSkill
- mail-contactsSkill
- mail-coreSkill
- mail-digestSkill
- mail-expensesSkill
- mail-fromSkill
- mail-meetingsSkill
- mail-needs-replySkill
- mail-newsletterSkill
- mail-readSkill
- mail-searchSkill
- mail-securitySkill
- mail-statsSkill
- mail-subscriptionsSkill
- mail-threadSkill
- mail-top-sendersSkill
- mail-travelSkill
- mail-triageSkill
- mail-workSkill
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
- Distinctive: line 29
All timestamps are seconds since January 1, 2001, not 1970.
- Very specific: line 45
Always use OccurrenceCache as the entry point for any time-windowed query.
- Distinctive: line 148
Only fetch attendees for specific events — never bulk join, it's slow:
≈ “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.
Files
Apple Calendar — Local Data Reference
Database Location
$HOME/Library/Group Containers/group.com.apple.calendar/Calendar.sqlitedbWAL 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
| Table | Key Columns |
| CalendarItem | ROWID, 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 |
| OccurrenceCache | event_id (→CalendarItem.ROWID), occurrence_date, occurrence_start_date, occurrence_end_date |
| Calendar | ROWID, title, color, type, store_id |
| Store | ROWID, name (email/account name), type, disabled |
| Location | ROWID, title, latitude, longitude, address |
| Participant | ROWID, owner_id (→CalendarItem.ROWID), email, entity_type, role, status |
| Recurrence | ROWID, owner_id, frequency, interval, specifier |
CalendarItem.status Values
0— none / tentative1— confirmed2— cancelled (exclude these)
CalendarItem.invitation_status Values
0— none (own events)3— pending invite (not yet accepted)
Store.type Values
0— local1— local5— "Found in Mail" — always exclude (auto-created duplicates from email invites)
Participant.entity_type Values
7— attendee8— organizer
Participant.status Values
0— needs-action1— accepted2— declined3— tentative
Participant.role Values
0— non-participant / unknown1— required2— optional
Recurrence.frequency Values
1— daily2— weekly3— monthly4— 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 onlyCanonical 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;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
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.

