mail-contacts
Skill7 starsChanged 9 months agoMITView on GitHub
Extract contacts and build a communication directory from email history. Find email addresses, frequency of contact, and relationship strength. Use when user wants to find someone's email address, see all contacts, or understand their communication network. Arguments: optional person name, company, domain, or "top contacts" / "recent contacts".
In this repository32 other files it gives its agents.
- calendar-accountsSkill
- calendar-attendeesSkill
- calendar-conflictsSkill
- calendar-coreSkill
- calendar-eventSkill
- calendar-freeSkill
- calendar-recurringSkill
- calendar-searchSkill
- calendar-statsSkill
- calendar-todaySkill
- calendar-upcomingSkill
- mail-accountsSkill
- mail-action-itemsSkill
- mail-attachmentsSkill
- mail-bankingSkill
- 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
Files
Mail Contacts — Email Directory from Communication History
Query: $ARGUMENTS
Option A: Find a specific person's email address
DB="$HOME/Library/Mail/V10/MailData/Envelope Index"
NAME="<extracted from $ARGUMENTS>"
# Search senders
sqlite3 "$DB" "
SELECT DISTINCT a.address, a.comment as name, COUNT(*) as frequency
FROM messages m
JOIN addresses a ON m.sender = a.ROWID
WHERE (a.comment LIKE '%${NAME}%' OR a.address LIKE '%${NAME}%')
AND m.deleted=0
GROUP BY a.address ORDER BY frequency DESC LIMIT 10;" 2>/dev/null
# Search recipients (emails sent TO them)
sqlite3 "$DB" "
SELECT DISTINCT a.address, a.comment as name, COUNT(*) as frequency
FROM recipients r
JOIN addresses a ON r.address = a.ROWID
WHERE (a.comment LIKE '%${NAME}%' OR a.address LIKE '%${NAME}%')
GROUP BY a.address ORDER BY frequency DESC LIMIT 10;" 2>/dev/nullOption B: Top contacts directory
sqlite3 "$DB" "
SELECT a.address, a.comment as name,
COUNT(*) as emails_received,
MAX(datetime(m.date_received,'unixepoch','localtime')) as last_contact
FROM messages m
JOIN addresses a ON m.sender = a.ROWID
JOIN mailboxes mb ON m.mailbox = mb.ROWID
WHERE m.deleted = 0
AND mb.url NOT LIKE '%Spam%' AND mb.url NOT LIKE '%Sent%'
AND m.automated_conversation = 0
AND m.unsubscribe_type = 0
GROUP BY a.address
ORDER BY emails_received DESC LIMIT 50;" 2>/dev/nullOption C: All contacts from a company/domain
DOMAIN="<extracted from $ARGUMENTS>"
sqlite3 "$DB" "
SELECT DISTINCT a.address, a.comment as name, COUNT(*) as cnt
FROM messages m
JOIN addresses a ON m.sender = a.ROWID
WHERE a.address LIKE '%@${DOMAIN}%' AND m.deleted=0
GROUP BY a.address ORDER BY cnt DESC;" 2>/dev/nullOption D: Recent contacts (last 30 days)
SINCE=$(($(date +%s) - 2592000))
sqlite3 "$DB" "
SELECT DISTINCT a.address, a.comment,
MAX(datetime(m.date_received,'unixepoch','localtime')) as last_seen
FROM messages m
JOIN addresses a ON m.sender = a.ROWID
JOIN mailboxes mb ON m.mailbox = mb.ROWID
WHERE m.date_received >= ${SINCE} AND m.deleted=0
AND mb.url NOT LIKE '%Spam%'
AND m.automated_conversation = 0
AND m.unsubscribe_type = 0
GROUP BY a.address ORDER BY last_seen DESC LIMIT 30;" 2>/dev/nullOutput Format
For specific person search: show address(es), display name, frequency, last contact. For directory: table with name, address, frequency, last contact. Note: if multiple addresses for same person (aliases), group them. For company domain: list all people at that company who've emailed you.
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.

