skills/apple-mail/mail-digest/SKILL.md
Email digest for any time period — today, yesterday, last N hours/days, this week, a specific date, or while-I-was-away ranges. Categorizes by urgency, surfaces unread, flags financial/security emails, filters noise. Auto-invoke when user asks about email for any time period: "what came in today", "catch me up", "any emails this week", "what did I miss", "emails from yesterday", "last 3 hours", "since Monday".
npx skillsauth add aashari/ai-agent-skills mail-digestInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Period: $ARGUMENTS (default: today)
Interpret $ARGUMENTS naturally. Map to START and END unix timestamps:
| Expression | START | END | |---|---|---| | "today" / (empty) | midnight today local | now | | "yesterday" | midnight yesterday | midnight today | | "last 2 hours" | now − 7200s | now | | "last N hours" | now − N×3600s | now | | "last N days" | now − N×86400s | now | | "this week" | last Monday midnight | now | | "last week" | Monday of prev week | last Sunday midnight | | "since Monday" | most recent Monday midnight | now | | "YYYY-MM-DD" | that date midnight | that date 23:59:59 | | "catch me up" / "while I was away" | infer from context or ask — default last 5 days |
DB="$HOME/Library/Mail/V10/MailData/Envelope Index"
# Use SQLite date expressions directly — never compute Unix epochs manually (wrong year risk).
# "today" → >= date('now','localtime')
# "yesterday" → >= date('now','-1 day','localtime') AND < date('now','localtime')
# "last 48h" → >= datetime('now','-48 hours')
# "last 7 days" → >= date('now','-7 days','localtime')
# Apply the range in the WHERE clause below using datetime() comparisons.
sqlite3 "$DB" "
SELECT datetime(m.date_received,'unixepoch','localtime') as dt,
s.subject, a.address as sender, a.comment as name,
mb.url as mailbox, m.ROWID,
m.read, m.flagged, m.is_urgent, m.size,
m.automated_conversation, m.unsubscribe_type
FROM messages m
JOIN subjects s ON m.subject = s.ROWID
JOIN addresses a ON m.sender = a.ROWID
JOIN mailboxes mb ON m.mailbox = mb.ROWID
WHERE datetime(m.date_received,'unixepoch','localtime') >= date('now','localtime')
-- adjust the expression above based on $ARGUMENTS
AND m.deleted = 0
AND mb.url NOT LIKE '%Spam%'
AND mb.url NOT LIKE '%Trash%'
AND mb.url NOT LIKE '%Junk%'
AND mb.url NOT LIKE '%Draft%'
AND mb.url NOT LIKE '%Sent%'
ORDER BY m.is_urgent DESC, m.date_received DESC;" 2>/dev/null
Tier 1 — Needs Attention (read these):
is_urgent = 1flagged = 1read = 0 AND automated_conversation != 2 AND unsubscribe_type = 0 (real person, unread)Tier 2 — FYI (skim):
automated_conversation = 1 (transactional — Jira, Slack, bank receipts)Tier 3 — Noise (count only, don't enumerate):
automated_conversation = 2 — bulk automated emailsunsubscribe_type > 0 — newsletter/mailing list emailsFor Tier 3, just report: "X automated emails (Y monitoring, Z CI/CD, W marketing)"
For Tier 1 emails, get body preview. Check summaries table first (fast, no file I/O):
sqlite3 "$DB" "
SELECT m.ROWID, su.summary
FROM messages m
JOIN summaries su ON m.summary = su.ROWID
WHERE m.ROWID IN (<ROWID1>,<ROWID2>,...)" 2>/dev/null
For any ROWIDs without a summary entry, fall back to emlx parsing:
python3 ~/.claude/skills/_mail-shared/parser.py <ROWID1> <ROWID2> ...
Pull the first ~200 chars of meaningful body content as a preview for each.
Always call out explicitly if found in the window:
Email Digest — [RESOLVED DATE RANGE]
Total: X | Unread: Y | Flagged: Z | Accounts: N
Needs Attention (X) | Time | From | Subject | Preview | |---|---|---|---|
FYI (X) | Time | From | Subject | |---|---|---|
Financial (X emails)
Security (X events)
Noise filtered: X total (breakdown by type)
If the window has zero emails: say so and suggest a wider range. If the window has >200 emails: summarize by sender domain and ask if they want to drill into a category. Offer at the end: "Want me to read any of these, or dive into a specific category?"
data-ai
Show work emails only, filtered to Exchange/EWS accounts and corporate email domains. Digest with priorities. Use when user asks about work email, work inbox, or wants to separate work from personal mail. Arguments: optional date range or "today", "yesterday", "this week".
testing
Intelligent inbox triage — surface the most important emails across all accounts, prioritized by urgency and requiring attention. Use when user wants a smart overview of what needs their attention, asks "what's important in my email", or wants help deciding what to read first. Arguments: optional time window (default: last 48 hours) or account filter.
data-ai
Find flight bookings, hotel reservations, travel itineraries, and booking confirmations from email. Use when user asks about upcoming trips, travel plans, booking references, flight details, or hotel reservations. Arguments: optional destination, airline, date range, or booking service.
testing
Show who sends the most email, communication frequency analysis, and relationship mapping. Use when user asks who emails them most, top contacts, communication patterns, or wants to understand their email social graph. Arguments: optional time range (default: last 90 days), account filter, or "humans only" to exclude automated senders.