name: alfred-email-triage description: > [Alfred] Scan email threads via API. Classify each thread, execute Gmail actions, generate audit report. Every thread gets a closed status. allowed-tools: Read, Write, Edit, Glob, Grep, Bash(git:, pnpm:, npx tsx .claude/skills/*)
Alfred Email Triage
Inputs
context/WHO_IS_MASTER.md— email accountcontext/TEAM.md— sender→label routing, topic→label routing, escalation rules
Statuses
Every thread gets exactly ONE:
ACTION_NEEDED— requires Master decision/signature/approvalDELEGATED— routed to team member (label + archive)DONE— already handled (Master replied or thread resolved)ARCHIVED— FYI only, no action neededIGNORED— spam, marketing, noise
Default when unsure: ACTION_NEEDED.
Steps
Step 1: Load context
- Read
context/WHO_IS_MASTER.md. Note the email account. - Read
context/TEAM.md. Note the sender→label mapping, topic→label mapping, and escalation rules.
Step 2: Fetch threads via CLI
- Run:
npx tsx .claude/skills/sync-data-gmail/fetch.ts --count 100 > outputs/YYYY-MM-DD-HHmm-email-raw.json - Read
outputs/YYYY-MM-DD-HHmm-email-raw.json. Confirm the thread count. Each thread has:threadId— thread ID (used for execute actions)messageId— latest message IDfrom,fromName— latest message senderto— latest message recipientsubject— thread subjectdate— YYYY-MM-DDbody— latest message body (first 1000 chars)labels— current Gmail label IDsmessageCount— number of messages in threadparticipants— list of all thread participants ({name, email})
Step 3: Classify all threads
For each thread in the JSON:
- Label: Check
fromANDfromNameagainst sender→label mapping in TEAM.md. Note the label. This is mechanical — always apply regardless of classification. For Google notification emails (from drive-shares-dm-noreply@google.com, etc.), checkfromNamefor the real person (e.g. "Alec Fang (via Google Docs)"). - Classify using this priority order:
- Is Master (steven@worca.io) in
participantsAND no further action needed? → DONE. - Does the subject or body match an escalation rule from TEAM.md? → ACTION_NEEDED.
- Is the sender in the sender→label mapping? → DELEGATED to that label.
- Is the topic (from subject + body) covered by the topic→label mapping? → DELEGATED to that label.
- Is it a newsletter, marketing, or spam? (noreply@, newsletter@, substack, linkedin notifications, "unsubscribe") → IGNORED.
- Is it a receipt, confirmation, or FYI with no action? → ARCHIVED.
- None of the above? → ACTION_NEEDED.
- Is Master (steven@worca.io) in
- Write a one-line reason.
Step 4: Build output file
- Create
outputs/YYYY-MM-DD-HHmm-email-triage.mdwith all entries and their classifications. - Build Summary section with status counts and percentages.
- Build Master Action Items section from all ACTION_NEEDED entries:
- Lead with a bold action verb (Approve, Review, Reply, Grant, Watch, etc.)
- One line of context — just enough to decide priority
- End with
[#N]cross-referencing the full audit entry
- Build Full Audit section — every thread gets one entry:
- Format:
#N [STATUS] Subject - Sender/People - Date. Summary: one-line description. - For multi-person threads, list key participants (not just the latest sender)
- Include message count for threads with >1 message
- Format:
Step 5: Execute Gmail actions via CLI
- Build the actions array. For each thread:
threadId: the thread's threadId.addLabels: the label from step 5 (if any).archive: true if DELEGATED, DONE, ARCHIVED, or IGNORED. false if ACTION_NEEDED.
- Write to
/tmp/alfred-email-actions.json:{ "actions": [ { "threadId": "...", "addLabels": ["Alvin"], "archive": true }, ... ] } - Run:
npx tsx .claude/skills/alfred-email-triage/execute.ts --file /tmp/alfred-email-actions.json - Verify response shows expected success count.
Step 6: Finalize
- Set STATUS to COMPLETE in the output file.
Output
File: outputs/YYYY-MM-DD-HHmm-email-triage.md
STATUS: COMPLETE
# Email Triage — YYYY-MM-DD HH:mm
**Account:** steven@worca.io
**Threads scanned:** 50
**Date range:** [oldest] to [newest]
## Summary
- ACTION_NEEDED: X (Y%)
- DELEGATED: X (Y%)
- DONE: X (Y%)
- ARCHIVED: X (Y%)
- IGNORED: X (Y%)
## Master Action Items
Action verb leads. One-line context. [#N] cross-references the full audit entry.
→ **Approve** Arriane's Wise payment (from Alvin). Partial Dec invoice, remainder needs approval. [#8]
→ **Review** Patlytics next steps doc shared by Arthur Jen after today's meeting. [#11]
→ **Reply** to Sharon Drabeck (iHerb) — needs answer on auditor question this week. [#33]
## Full Audit
Format: #N [STATUS] Subject - Sender/People - Date. Summary: one-line description of what the email says.
#1 [DONE] Updated video conference: Worca Daily Team Huddle - Steven Lin - 2026-02-10. Summary: Master updated the weekly Thursday Asia huddle calendar invite.
#2 [DELEGATED→Alvin] Re: Notes: Calibration Call - Alvin Calma, Aprillyn - 2026-02-10. Summary: Alvin thanked Aprillyn for calibration notes. 2 msgs.
#3 [IGNORED] Weekly digest - Substack - 2026-02-10. Summary: Newsletter.
#4 [ACTION_NEEDED] Transfer approval - Wise - 2026-02-10. Summary: Transfer pending Master's approval for Worca Inc. 5 msgs.
...