連假後打開收件匣。247 封未讀。裡面某處藏著一份合約截止日、一場改了時間的會議、三封你真的想看的電子報,以及 200 封消失了也不會怎樣的訊息。問題不在於讀它們。問題在於判斷哪些重要。
這就是分揀問題。郵局每天早上都在面對它。數千封信件湧入。大部分是垃圾,但你不能在看過之前把任何一封丟掉。一個老練的郵差會慢慢學到哪些地址收到的是重要郵件、哪些只是廣告傳單。但你的收件匣沒有這種待遇。每封信在打開之前看起來都一樣。
如果你有一個已經知道你在乎什麼的郵差呢?
這篇文章就是要做這件事。一個 AI agent 讀完你的整個收件匣、依緊急度和類型分類每封信、擷取截止日期、事件和待辦事項,然後交給你一頁優先級摘要。你讀摘要,不讀收件匣。總時間:大約 30 秒。
升級:從瀏覽器擴充功能到終端 Pipeline
Anthropic 自家文件描述了用 Claude 搭配 Chrome extension 來清理促銷郵件、把信件變成活動追蹤器、從行事曆準備一天行程。那個方法可以用。但它綁定在瀏覽器上。依賴特定的擴充功能。而且是一封一封處理,隨著你瀏覽才進行。
終端原生的做法不同。你匯出收件匣 -- MBOX 檔、EML 資料夾、或 API dump -- 然後把整批餵給 AI agent。Agent 在一次執行中分類全部 200 封信。它產出 structured output:優先級摘要、擷取的事件、識別出的截止日期,以及可選的自動化 -- 透過 MCP 建立行事曆項目和任務。
三個優勢勝過擴充功能模式:
- 不限服務商。 MBOX 匯出適用於 Gmail、Outlook、Fastmail、ProtonMail、自架 IMAP。任何存在的 email 服務商。
- 批次處理。 一個指令處理 200 封信,不是 200 次個別互動。
- 可組合。 輸出是結構化資料。導向行事曆 MCP server、任務管理工具、Slack 摘要,或全部一起。
你會做出什麼
一條四階段的 pipeline:
- 匯出 -- 把收件匣 dump 到本地資料夾,格式為 MBOX 或 EML
- 分類 -- AI agent 讀每封信,標記緊急度(緊急 / 需處理 / 參考 / 噪音)和類型(會議 / 截止日 / 請求 / 電子報 / 通知 / 私人)
- 擷取 -- 拉出日期、截止日、待辦事項、事件細節、寄件者脈絡
- 摘要 -- 產出依優先級排序的摘要,30 秒內掃完
可選的第五階段:透過 MCP 把擷取的事件推到 Google Calendar、待辦事項推到任務管理工具。
結束後,你會有一個可重複的單指令 workflow,用於每日 email 分類。
事前準備
- Claude Code v2.1+ 搭配 API 存取
- Python 3.10+ 或 Node.js 18+(跑匯出 script 用)
- 一個可以匯出的 email 帳號(MBOX 匯出、IMAP 存取、或 API)
- 可選:Google Calendar 和任務管理工具的 MCP server
第一步:匯出你的收件匣
Agent 無法直接讀取你的 email 服務商。你需要先把信件拿到本地檔案系統。根據你的服務商有幾條路徑。
Gmail:Google Takeout
Gmail 使用者最簡單的路徑。到 takeout.google.com,只選 Gmail,選 MBOX 格式,下載。這會給你一個包含所有信件的 .mbox 檔。
要做每日自動化,Takeout 匯出太慢。改用 IMAP:
# 用一個輕量的 IMAP 匯出工具
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')
"
把 app-password 換成 Gmail 應用程式密碼(不是你的主密碼)。這只匯出未讀信件,每封存成獨立的 .eml 檔。
Outlook / 其他服務商
大部分桌面郵件客戶端可以匯出為 MBOX 或 EML。Thunderbird 原生就支援。Outlook 的話,匯出為 .pst 再用 readpst 轉換:
# 把 Outlook PST 轉成 MBOX
brew install libpst
readpst -o inbox-export/ -M outlook-export.pst
通用 IMAP
如果你的服務商支援 IMAP(大部分都支援),上面的 Python script 可以通用。改伺服器位址就好:
# Fastmail
imap.fastmail.com
# ProtonMail(透過 ProtonMail Bridge)
127.0.0.1:1143
# 自架
your-mail-server.com
重點是:把信件放進一個 .eml 檔案的資料夾或一個 .mbox 檔。格式不太重要。AI agent 兩種都能解析。
第二步:設定分類 Workflow
在 CLAUDE.md 加一段,告訴 agent 怎麼分類你的 email。這是你個人 context 存在的地方 -- agent 需要知道什麼對你重要。
## 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.
把方括號裡的佔位符換成你實際的名字、服務和偏好。具體程度很重要。一個知道你主管名字和關鍵服務的 agent,分類品質遠勝過泛用 prompt。
第三步:執行分類
收件匣匯出完畢、CLAUDE.md 設定好了,一行指令就搞定:
claude -p "Triage the emails in inbox-export/ and generate my priority digest"
Agent 讀取每個 .eml 檔、套用你的分類規則、輸出摘要。200 封信通常 15 到 30 秒,取決於信件長度和你的 API 方案。
輸出長這樣:
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)
47 封信直接消失,一封都不用讀。兩個緊急項目被揪出來,否則你可能好幾個小時才會注意到。一場改了時間的會議被攔截,避免你在錯誤的時間出現。
第四步:自動建立事件和任務(可選)
摘要本身就很有用。但擷取出的資料結構化程度夠高,可以往下游推送。如果你有 Google Calendar 和任務管理工具的 MCP server,agent 可以自動建立項目。
透過 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"
}
}
}
}
在 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.
現在指令能做更多事:
claude -p "Triage inbox-export/, generate my digest, and sync events and tasks"
Agent 讀信、分類、產摘要,然後呼叫行事曆和任務的 MCP tool 建立項目。一次執行就拿到晨間簡報和預建好的任務清單。
第五步:變成每日流程
Shell Alias
# 加到 .zshrc 或 .bashrc
alias emailtriage='python3 ~/scripts/export-inbox.py && claude -p "Triage inbox-export/ and generate my priority digest"'
Cron Job
# 每個工作日早上 8 點跑,摘要複製到剪貼簿
0 8 * * 1-5 cd ~/email-triage && python3 export-inbox.py && claude -p "Triage inbox-export/ and generate my priority digest" | pbcopy
導到 Slack
把摘要發到你自己的私人頻道:
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
調校分類
用了幾天後,你會注意到值得調整的模式。
太多誤判為緊急。 你的緊急規則太寬鬆了。收緊它。不要用「任何來自法務的都是緊急」,改成「來自法務且主旨包含 'deadline'、'expiration' 或 'signature required' 的才是緊急」。
電子報被誤分類。 把明確的寄件者網域加到噪音清單:Emails from noreply@linkedin.com, marketing@*, and *@substack.com are noise unless the subject matches [specific topics].
討論串缺少 context。 討論串中的單封信可能缺少脈絡。如果你匯出完整討論串(大部分 IMAP 工具都支援),加一條規則:When a message is part of a thread, read the full thread before classifying.
Token 爆量。 長信吃掉你的 API 預算。加上: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.
多窗格分類配置
高效率的 email 分類配置是三個窗格。第一個窗格:優先級摘要輸出。第二個窗格:Claude Code 跑分類作業,你可以針對特定信件問後續問題(「Sarah 那封 NDA 信到底寫了什麼?」)。第三個窗格:你的郵件客戶端或檔案瀏覽器,顯示原始匯出檔用於抽查。
這消除了摘要和原始來源之間的 context switch。當你在摘要裡看到需要驗證的東西,直接查原始信件,不用離開終端 session。
如果你管理多個 email 帳號 -- 工作和私人,或多個客戶信箱 -- workspace 切換讓你為每個帳號維護獨立的 CLAUDE.md 分類規則,各有各的匯出目錄和緊急度定義。
延伸應用
Email 分類是「資訊洪流到摘要」模式的一個實例。同樣的架構 -- 匯出、分類、擷取、摘要 -- 適用於:
- Slack 補進度 -- 匯出未讀頻道、依相關性分類、浮出待辦事項
- RSS 饋送分類 -- dump 500 篇文章、根據你的興趣浮出值得讀的 10 篇
- 客服工單排序 -- 匯出一個佇列、依嚴重度和主題分類、產出分配計畫
每種變體需要不同的匯出步驟和不同的 CLAUDE.md 分類規則。Agent pipeline 不變。
更多關於建立 AI CLI agent workflow 和多來源 pipeline 的內容,回饋彙整指南深入講解了 orchestrator-workers 模式。如果你已經在跑自動化站會報告,email 分類自然地接入同一個晨間流程。
總結
Email 分類就是在郵局分信。大部分是垃圾,但你不能在看過之前丟掉任何一封。AI agent 就是那個已經知道你在乎什麼的郵差。
設定:把收件匣匯出到本地檔案、在 CLAUDE.md 設定分類規則、跑一個指令。Agent 讀 200 封信、分類每封、擷取截止日期和事件、交給你一份優先級摘要。可選的 MCP 整合把事件推到行事曆、待辦事項推到任務管理工具。
總時間投入:大約 30 分鐘設定。之後,你每天的 email 分類從 30 多分鐘的捲動和決策,降到 30 秒讀摘要。那大約是一年 100 小時還給你 -- 你之前花在的不是讀信,是決定要不要讀信。決定的過程才是昂貴的部分。現在 agent 來處理。
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.