You open your inbox after a long weekend. 247 unread emails. Somewhere in there is a contract deadline, a meeting that got moved, three newsletters you actually want to read, and 200 messages that could vanish without consequence. The problem is not reading them. It is deciding which ones matter.
This is the sorting problem. A post office faces it every morning. Thousands of envelopes arrive. Most are junk, but you cannot throw any away until you have looked at it. A human mail carrier learns, over time, which houses get important deliveries and which get catalogs. But you do not have that luxury with email. Every message looks the same until you open it.
What if you had a postal worker who already knew what you cared about?
That is what this article builds. An AI agent that reads your entire inbox, classifies every message by urgency and type, extracts deadlines, events, and action items, then hands you a one-page priority digest. You read the digest instead of the inbox. Total time: about 30 seconds.
The Upgrade: From Browser Extension to Terminal Pipeline
Anthropic's own documentation describes using Claude with a Chrome extension to clean up promotional emails, turn messages into an event tracker, and prepare your day from your calendar. That approach works. But it is bound to a browser. It depends on a specific extension. And it processes emails one at a time as you look at them.
The terminal-native approach is different. You export your inbox -- MBOX file, EML directory, or API dump -- and feed the entire batch to an AI agent. The agent classifies all 200 messages in a single pass. It produces structured output: a priority digest, extracted events, identified deadlines, and optional automation to create calendar entries and tasks via MCP.
Three advantages over the extension model:
- Provider-agnostic. MBOX export works with Gmail, Outlook, Fastmail, ProtonMail, self-hosted IMAP. Any email provider that exists.
- Batch processing. 200 emails in one command, not 200 individual interactions.
- Composable. The output is structured data. Pipe it to a calendar MCP server, a task manager, a Slack summary, or all three.
What You Will Build
A pipeline with four stages:
- Export -- dump your inbox to a local directory as MBOX or EML files
- Classify -- AI agent reads every message, tags it by urgency (critical / action-needed / informational / noise) and type (meeting / deadline / request / newsletter / notification / personal)
- Extract -- pull out dates, deadlines, action items, event details, and sender context
- Digest -- generate a priority-sorted summary you can scan in 30 seconds
Optional fifth stage: push extracted events to Google Calendar and action items to a task manager, both via MCP.
By the end, you will have a repeatable one-command workflow for daily email triage.
Prerequisites
- Claude Code v2.1+ with API access
- Python 3.10+ or Node.js 18+ (for the export script)
- An email account with export capability (MBOX export, IMAP access, or an API)
- Optionally: MCP servers for Google Calendar and your task manager
Step 1: Export Your Inbox
The agent cannot read your email provider directly. You need to get messages onto your local filesystem first. There are several paths depending on your provider.
Gmail: Google Takeout
The simplest route for Gmail users. Go to takeout.google.com, select only Gmail, choose MBOX format, and download. This gives you a single .mbox file containing every message.
For daily automation, a Takeout export is too slow. Use IMAP instead:
# Using a lightweight IMAP export tool
pip install imap-tools
python3 -c "
from imap_tools import MailBox
import os, email
os.makedirs('inbox-export', exist_ok=True)
with MailBox('imap.gmail.com').login('you@gmail.com', 'app-password') as mb:
for i, msg in enumerate(mb.fetch('UNSEEN')):
with open(f'inbox-export/{i:04d}.eml', 'w') as f:
f.write(msg.obj.as_string())
print(f'Exported {i+1} messages')
"
Replace app-password with a Gmail App Password (not your main password). This exports only unread messages as individual .eml files.
Outlook / Other Providers
Most desktop email clients can export to MBOX or EML. Thunderbird does it natively. For Outlook, export as .pst and convert with readpst:
# Convert Outlook PST to MBOX
brew install libpst
readpst -o inbox-export/ -M outlook-export.pst
Generic IMAP
If your provider supports IMAP (most do), the Python script above works universally. Change the server address:
# Fastmail
imap.fastmail.com
# ProtonMail (via ProtonMail Bridge)
127.0.0.1:1143
# Self-hosted
your-mail-server.com
The point is: get your messages into a directory of .eml files or a single .mbox file. The format does not matter much. The AI agent can parse both.
Step 2: Configure the Classification Workflow
Create a CLAUDE.md section that tells the agent how to classify your email. This is where your personal context lives -- the agent needs to know what matters to you.
## Email Triage Workflow
When I ask you to triage my email, follow this sequence:
### Step 1: Read All Messages
Read every .eml file in the inbox-export/ directory (or parse the .mbox file).
For each message, extract: sender, subject, date, body (first 500 chars).
### Step 2: Classify Each Message
Assign two labels to each message:
**Urgency:**
- critical: requires response today, involves money, legal, or production incidents
- action-needed: requires response this week, someone is waiting on me
- informational: useful to know, no action required
- noise: newsletters I never read, automated notifications, marketing
**Type:**
- meeting: calendar invites, meeting changes, scheduling requests
- deadline: contains a due date or expiration
- request: someone asking me to do something specific
- newsletter: subscribed content, digests, roundups
- notification: automated alerts from services (GitHub, Jira, AWS, etc.)
- personal: from friends, family, or non-work contacts
### Step 3: Extract Actionable Items
For every message classified as critical or action-needed:
- Extract the specific action required
- Extract any dates or deadlines mentioned
- Note the sender and whether a reply is expected
For meeting-type messages:
- Extract event name, date/time, location (or video link)
- Note if this is a new invite, reschedule, or cancellation
### Step 4: Generate Priority Digest
Output a structured digest in this format:
**CRITICAL (respond today):**
- [sender] subject -- action: [what to do] -- deadline: [if any]
**ACTION NEEDED (this week):**
- [sender] subject -- action: [what to do]
**MEETINGS & EVENTS:**
- [date/time] event name -- [location/link] -- notes: [changes if any]
**DEADLINES:**
- [date] what is due -- from: [sender/context]
**INFORMATIONAL (skim later):**
- [count] notifications from [services]
- [count] newsletters: [list titles of worth-reading ones]
**NOISE (safe to archive):**
- [count] messages -- [brief summary of categories]
### Classification Rules
- My manager is: [NAME]. Anything from them is minimum action-needed.
- Production alerts from PagerDuty or AWS are always critical.
- GitHub notification emails are informational unless they @-mention me directly.
- Newsletters from [LIST YOUR KEEPERS] are informational. All others are noise.
- Calendar invites for today or tomorrow are critical. Further out is action-needed.
Replace the bracketed placeholders with your actual names, services, and preferences. The specificity matters. An agent that knows your manager's name and your critical services produces dramatically better classification than a generic prompt.
Step 3: Run the Triage
With your inbox exported and your CLAUDE.md configured, the command is:
claude -p "Triage the emails in inbox-export/ and generate my priority digest"
The agent reads every .eml file, applies your classification rules, and outputs the digest. For 200 messages, this typically takes 15-30 seconds depending on message length and your API tier.
The output looks like this:
CRITICAL (respond today):
- Sarah Chen <legal@company.com>: NDA expiration notice
-- action: sign renewal before March 24
-- deadline: 2026-03-24
- PagerDuty: Production alert - API latency spike
-- action: check monitoring dashboard, acknowledge or escalate
-- deadline: immediate
ACTION NEEDED (this week):
- James Liu <james@partner.co>: Q2 proposal review
-- action: review attached PDF, send feedback
- Maria Santos <maria@company.com>: Design review for v2.4 onboarding
-- action: review Figma link, leave comments by Friday
MEETINGS & EVENTS:
- 2026-03-24 10:00 AM: Sprint Planning (moved from Tuesday)
-- Zoom link: https://zoom.us/j/123...
-- note: rescheduled, was originally March 25
- 2026-03-25 2:00 PM: 1:1 with Manager
-- Google Meet, recurring
DEADLINES:
- 2026-03-24: NDA renewal signature
- 2026-03-28: Q2 budget submission (from finance@company.com)
- 2026-03-31: Performance self-review due
INFORMATIONAL (skim later):
- 12 GitHub notifications (3 PRs merged, 2 review requests, 7 CI results)
- 4 newsletters: TL;DR, Hacker Newsletter, Pragmatic Engineer, ByteByteGo
NOISE (safe to archive):
- 47 messages: promotional (23), social media notifications (11),
automated receipts (8), mailing list noise (5)
Forty-seven messages gone without reading a single one. Two critical items surfaced that you might have missed for hours. A rescheduled meeting caught before you showed up at the wrong time.
Step 4: Automate Event and Task Creation (Optional)
The digest is useful on its own. But the extracted data is structured enough to push downstream. If you have MCP servers for Google Calendar and a task manager, the agent can create entries automatically.
Calendar Integration via MCP
{
"mcpServers": {
"google-calendar": {
"command": "npx",
"args": ["-y", "@anthropic/mcp-server-google-calendar"],
"env": {
"GOOGLE_CALENDAR_CREDENTIALS": "/path/to/credentials.json"
}
},
"todoist": {
"command": "npx",
"args": ["-y", "@anthropic/mcp-server-todoist"],
"env": {
"TODOIST_API_TOKEN": "your-token-here"
}
}
}
}
Add a section to your CLAUDE.md:
### Post-Triage Automation
After generating the digest:
1. For each MEETING & EVENT item: check if it already exists on my calendar.
If not, create it. If it was rescheduled, update the existing event.
2. For each ACTION NEEDED item: create a task in Todoist with the deadline
(if specified) and a link back to the original email subject.
3. For CRITICAL items: create a task with priority P1 and today's date.
4. Never auto-archive or delete any email. Triage is read-only.
Now the command does more:
claude -p "Triage inbox-export/, generate my digest, and sync events and tasks"
The agent reads emails, classifies them, generates the digest, then calls the calendar and task MCP tools to create entries. You get a morning briefing and a pre-populated task list in one pass.
Step 5: Make It a Daily Routine
Shell Alias
# Add to .zshrc or .bashrc
alias emailtriage='python3 ~/scripts/export-inbox.py && claude -p "Triage inbox-export/ and generate my priority digest"'
Cron Job
# Run at 8:00 AM weekdays, pipe digest to clipboard
0 8 * * 1-5 cd ~/email-triage && python3 export-inbox.py && claude -p "Triage inbox-export/ and generate my priority digest" | pbcopy
Pipe to Slack
Send the digest to a private channel for yourself:
claude -p "Triage inbox-export/ and generate my priority digest" | curl -X POST \
-H "Authorization: Bearer $SLACK_BOT_TOKEN" \
-H "Content-Type: application/json" \
-d "{\"channel\": \"C01PRIVATE\", \"text\": \"$(cat -)\"}" \
https://slack.com/api/chat.postMessage
Tuning the Classification
After a few days of use, you will notice patterns worth adjusting.
Too many false criticals. Your urgency rules are too broad. Tighten them. Instead of "anything from legal is critical," try "anything from legal containing 'deadline', 'expiration', or 'signature required' is critical."
Newsletters misclassified. Add explicit sender domains to your noise list: Emails from noreply@linkedin.com, marketing@*, and *@substack.com are noise unless the subject matches [specific topics].
Missing context on threads. A single email in a thread may lack context. If you export full threads (most IMAP tools support this), add a rule: When a message is part of a thread, read the full thread before classifying.
Too many tokens. Long emails eat through your API budget. Add: For classification, read only the subject, sender, and first 300 characters of the body. Read the full body only for critical and action-needed messages during extraction.
The Multi-Pane Triage Layout
The productive setup for email triage is three panes. First pane: the priority digest output. Second pane: Claude Code running the triage, where you can ask follow-up questions about specific messages ("What exactly did Sarah's NDA email say?"). Third pane: your email client or a file browser showing the raw exports for spot-checking.
This eliminates the context switch between the summary and the source. When you see something in the digest that needs verification, you check the raw message without leaving your terminal session.
For people who manage multiple email accounts -- work and personal, or multiple client inboxes -- workspace switching lets you maintain separate CLAUDE.md classification rules for each account, each with its own export directory and urgency definitions.
Extending the Pattern
Email triage is one instance of the "firehose to digest" pattern. The same architecture -- export, classify, extract, summarize -- works for:
- Slack catch-up -- export unread channels, classify by relevance, surface action items
- RSS feed triage -- dump 500 articles, surface the 10 worth reading based on your interests
- Support ticket prioritization -- export a queue, classify by severity and topic, generate an assignment plan
Each variation needs a different export step and different CLAUDE.md classification rules. The agent pipeline stays the same.
For more on building AI CLI agent workflows and multi-source pipelines, the feedback synthesis guide covers the orchestrator-workers pattern in depth. If you are already running automated standup reports, email triage slots naturally into the same morning routine.
Recap
Email triage is sorting mail at a post office. Most of it is junk, but you cannot throw any away until you have looked at it. An AI agent is the postal worker who already knows what you care about.
The setup: export your inbox to local files, configure classification rules in CLAUDE.md, run one command. The agent reads 200 messages, classifies each one, extracts deadlines and events, and hands you a priority digest. Optional MCP integrations push events to your calendar and action items to your task manager.
Total time investment: about 30 minutes to set up. After that, your daily email triage drops from 30+ minutes of scrolling and deciding to 30 seconds of reading a digest. That is roughly 100 hours per year returned to you -- time you were spending not on reading email, but on deciding whether to read email. The deciding is the expensive part. Now the agent handles it.
Ready to streamline your terminal workflow?
Multi-terminal drag-and-drop layout, workspace Git sync, built-in AI integration, AST code analysis — all in one app.