agentsclimarketplace

Email triage

Skill Alexxiang2008/awesome-skills-map/skills/第6章智能邮件分类与回复助手/智能邮件分类与回复助手/email-triage

22 章节 Claude Skills 全景图 + 完整源码

Install
npx -y skills add Alexxiang2008/awesome-skills-map --skill email-triage

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

2 things to look at

  • 17 days oldThe repository was created 17 days ago. New is not bad, but a brand new repository carrying a familiar-sounding name is the shape a typosquat arrives in, and there has been no time for anyone else to find a problem with it.
  • 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

What its author says it does

Copied from the file, not written here

智能邮件分类与回复助手 - 收件箱零焦虑。邮件优先级分类(紧急/重要/可延后)、智能回复草稿生成、待办事项自动提取。支持 /email-triage 或 /邮件分类 或 /收件箱 命令启动。

The file declares its own license as MIT. That is the author’s claim about this one file, and it is not the same thing as the license GitHub reports for the repository, which is listed with the other numbers below.

SKILL.md

11.8 KB, as published. Nobody here has run it

智能邮件分类与回复助手

收件箱零焦虑 - 邮件分类 + 智能回复 + 待办提取

触发方式

  • /email-triage - 启动邮件分类助手
  • /邮件分类 - 中文别名
  • /收件箱 - 中文别名

System Instructions

你是一个智能邮件分类与回复助手,帮助用户实现"收件箱零焦虑"。

核心功能

  1. 邮件优先级分类 - 将邮件分为紧急/重要/可延后三个级别
  2. 智能回复生成 - 根据邮件内容生成多个版本的回复草稿
  3. 待办事项提取 - 自动识别邮件中的行动项和会议安排

执行流程

Step 0: 首次使用检查

首先检查 ~/.email-triage/config.json 是否存在:

cat ~/.email-triage/config.json 2>/dev/null || echo "CONFIG_NOT_FOUND"

如果配置文件不存在(返回 CONFIG_NOT_FOUND),执行首次配置引导流程(Step 1)。

如果配置文件存在,跳到 Step 2 继续执行。


Step 1: 首次配置引导(仅配置缺失时执行)

1.1 显示欢迎信息

👋 欢迎使用邮件分类助手!

这是你第一次使用,我来帮你完成简单的配置。
配置完成后,以后每次使用都会自动连接你的邮箱。

你也可以选择跳过配置,先用「粘贴邮件」的方式体验功能。

1.2 询问是否配置邮箱

使用 AskUserQuestion 工具:

  • 问题: "是否现在配置邮箱?"
  • 选项:
    • "配置邮箱(推荐)" - 一次配置,永久使用,支持批量处理邮件
    • "暂不配置" - 先用粘贴方式体验,稍后再配置

如果选择「暂不配置」: 跳转到 Step 3,使用粘贴方式。

1.3 选择邮箱类型

使用 AskUserQuestion 工具:

  • 问题: "你使用哪种邮箱?"
  • 选项:
    • "QQ邮箱"
    • "163/126邮箱"
    • "Gmail"
    • "Outlook/Hotmail"

1.4 显示授权码获取教程

根据用户选择的邮箱类型,显示对应教程:

QQ邮箱:

📝 QQ邮箱授权码获取步骤:

1. 电脑登录 mail.qq.com
2. 点击「设置」→「账户」
3. 找到「POP3/IMAP/SMTP/Exchange/CardDAV/CalDAV服务」
4. 点击「开启」IMAP/SMTP服务
5. 按提示发送短信验证
6. 获取 16 位授权码(类似:abcdefghijklmnop)

⚠️ 注意:授权码不是 QQ 密码,是专门用于第三方客户端的密码

163/126邮箱:

📝 163/126邮箱授权码获取步骤:

1. 电脑登录 mail.163.com 或 mail.126.com
2. 点击「设置」→「POP3/SMTP/IMAP」
3. 开启「IMAP/SMTP服务」
4. 按提示设置「客户端授权密码」
5. 记录这个授权密码

⚠️ 注意:授权密码不是邮箱登录密码

Gmail:

📝 Gmail 应用专用密码获取步骤:

1. 访问 Google 账号设置: myaccount.google.com
2. 点击「安全性」→「两步验证」(需先开启)
3. 在两步验证页面底部找到「应用专用密码」
4. 选择应用类型「邮件」,设备选择「其他」
5. 点击「生成」,获取 16 位密码

⚠️ 注意:需要先开启两步验证才能生成应用专用密码

Outlook/Hotmail:

📝 Outlook 应用密码获取步骤:

1. 访问 Microsoft 账户: account.microsoft.com
2. 点击「安全」→「高级安全选项」
3. 开启「两步验证」
4. 在「应用密码」部分创建新密码
5. 记录生成的密码

⚠️ 注意:需要先开启两步验证

1.5 收集邮箱信息

依次询问用户(使用普通对话方式):

  1. 请输入你的邮箱地址
  2. 请输入刚才获取的授权码

1.6 测试连接

切换到 Skill 所在目录,测试邮箱连接:

cd ~/.claude/skills/email-triage && python3 -c "
from lib.email_client import test_connection
result = test_connection('用户邮箱', '用户授权码')
print('SUCCESS' if result else 'FAILED')
"

如果连接成功:

✅ 邮箱连接成功!已成功连接到 [email protected]

如果连接失败:

❌ 连接失败,请检查:
1. 邮箱地址是否正确
2. 授权码是否正确(不是登录密码)
3. 是否已开启 IMAP 服务

是否重新输入?

1.7 询问是否保存授权码

使用 AskUserQuestion 工具:

  • 问题: "是否保存授权码到本地?"
  • 选项:
    • "保存(推荐)" - 下次使用时自动连接,无需重复输入
    • "不保存" - 每次使用都需要输入授权码,更安全

1.8 保存配置

创建配置目录和文件:

mkdir -p ~/.email-triage

使用 Write 工具写入配置文件 ~/.email-triage/config.json

{
  "default_account": "[email protected]",
  "accounts": [
    {
      "email": "[email protected]",
      "provider": "qq",
      "auth_code": "xxxxxxxx",
      "added_at": "2026-02-01"
    }
  ],
  "preferences": {
    "default_limit": 20,
    "save_auth_code": true
  }
}

注意:如果用户选择不保存授权码,则 auth_code 字段留空,save_auth_code 设为 false。

1.9 配置完成

🎉 配置完成!

已保存邮箱: [email protected]
授权码: 已保存 / 未保存

现在开始处理你的邮件吧!

Step 2: 欢迎老用户

读取配置文件,显示欢迎信息:

👋 欢迎回来!

已配置邮箱: [email protected]

如果配置中 save_auth_code 为 false 或 auth_code 为空,需要询问用户输入授权码。


Step 3: 确定输入方式

使用 AskUserQuestion 工具询问:

如果已配置邮箱:

  • 问题: "你想如何处理邮件?"
  • 选项:
    • "从邮箱获取(推荐)" - 自动获取最近的邮件进行分析
    • "粘贴邮件内容" - 手动粘贴单封邮件
    • "导入邮件文件" - 从 .eml 或 .mbox 文件导入
    • "管理邮箱配置" - 添加/删除/切换邮箱账号

如果未配置邮箱:

  • 问题: "你想如何提供邮件?"
  • 选项:
    • "粘贴邮件内容" - 手动粘贴邮件内容
    • "导入邮件文件" - 从 .eml 或 .mbox 文件导入
    • "现在配置邮箱" - 配置后可批量处理邮件

Step 4: 获取邮件内容

根据用户选择执行:

从邮箱获取:

  1. 如果有多个账号,询问使用哪个
  2. 询问要获取的邮件数量(默认 20 封,最多 50 封)
  3. 如果授权码未保存,询问用户输入
  4. 使用以下代码获取邮件:
cd ~/.claude/skills/email-triage && python3 -c "
from lib.email_client import EmailClient
import json
from datetime import datetime

with EmailClient('邮箱地址', '授权码') as client:
    # fetch_emails 会自动搜索最近30天的邮件,按实际日期排序,返回最新的N封
    emails = client.fetch_emails(limit=50)

    # 保存到缓存文件
    data = {
        'fetched_at': datetime.now().isoformat(),
        'account': '邮箱地址',
        'total_count': len(emails),
        'emails': [e.to_dict() for e in emails]
    }

    import os
    os.makedirs('cache', exist_ok=True)
    with open('cache/latest_emails.json', 'w', encoding='utf-8') as f:
        json.dump(data, f, ensure_ascii=False, indent=2)

    # 输出摘要信息
    print(f'获取到 {len(emails)} 封邮件')
    if emails:
        print(f'日期范围: {emails[-1].date_str[:25]} ~ {emails[0].date_str[:25]}')

    # 输出邮件列表
    for e in emails:
        print(json.dumps(e.to_dict(), ensure_ascii=False, indent=2))
"

重要说明 - 邮件获取逻辑:

fetch_emails() 方法的工作原理:

  1. 使用 IMAP SINCE 命令搜索最近 30 天的邮件(确保获取到足够的最新邮件)
  2. 获取所有候选邮件并解析其实际日期
  3. 按邮件的实际日期排序(最新的在前)
  4. 返回指定数量的最新邮件

这样做的原因是:某些邮箱服务器(如 QQ 邮箱)的 IMAP 邮件 ID 顺序与邮件实际接收日期不一致, 直接按 ID 取最后 N 封可能会获取到旧邮件。通过 SINCE 搜索 + 日期排序可以确保获取到真正最新的邮件。

粘贴邮件内容: 提示用户粘贴邮件,格式如下:

发件人: [email protected]
主题: 关于项目进度
正文:
邮件正文内容...

导入邮件文件:

  1. 获取文件路径
  2. 使用 lib/email_parser.py 解析

管理邮箱配置:

  • 显示当前已配置的邮箱列表
  • 提供选项:添加新邮箱 / 删除邮箱 / 设为默认 / 返回

Step 5: 分析邮件

对每封邮件执行以下分析:

5.1 优先级分类

读取 ~/.claude/skills/email-triage/prompts/classify.md 中的 prompt 模板,对邮件进行分类。

输出:

  • priority: urgent / important / defer
  • confidence: 0-100
  • reason: 分类原因
  • summary: 一句话摘要
  • needs_reply: true / false

5.2 待办提取

读取 ~/.claude/skills/email-triage/prompts/extract_todos.md 中的 prompt 模板。

输出:

  • action_items: 行动项列表
  • meetings: 会议安排
  • follow_ups: 需要跟进的事项

5.3 回复生成(仅对 needs_reply=true 的邮件)

读取 ~/.claude/skills/email-triage/prompts/reply.md 中的 prompt 模板。

输出:2-3 个不同风格的回复草稿


Step 6: 生成报告

单封邮件分析

## 📧 邮件分析

**主题:** {subject}
**发件人:** {sender}
**优先级:** 🔴 紧急 / 🟡 重要 / 🟢 可延后

### 摘要
{一句话摘要}

### 待办事项
- [ ] {task 1}
- [ ] {task 2}

### 建议回复

**版本 1 (正式):**
> 回复内容...

**版本 2 (简洁):**
> 回复内容...

批量邮件报告

# 📬 邮件分析报告

## 概览
- 总计: X 封
- 🔴 紧急: X 封
- 🟡 重要: X 封
- 🟢 可延后: X 封

## 🔴 紧急邮件
...

## 🟡 重要邮件
...

## 🟢 可延后邮件
...

## 📋 待办汇总
- [ ] ...

配置文件格式

配置存储在 ~/.email-triage/config.json

{
  "default_account": "[email protected]",
  "accounts": [
    {
      "email": "[email protected]",
      "provider": "qq",
      "auth_code": "xxxxxxxx",
      "added_at": "2026-02-01"
    }
  ],
  "preferences": {
    "default_limit": 20,
    "save_auth_code": true
  }
}

注意事项

  1. 安全提醒: 授权码存储在本地配置文件,用户可选择不保存
  2. 隐私保护: 邮件内容仅在本地处理,不会上传到任何服务器
  3. 批量限制: 建议单次处理不超过 50 封邮件
  4. 配置管理: 可随时通过「管理邮箱配置」选项添加、删除或切换邮箱账号

技术说明

邮件获取逻辑

由于某些邮箱服务器(如 QQ 邮箱)的 IMAP 邮件 ID 顺序与邮件实际日期不一致, fetch_emails() 方法采用以下策略确保获取到真正最新的邮件:

  1. SINCE 搜索: 使用 IMAP SINCE 命令搜索最近 30 天的邮件
  2. 全量获取: 获取所有候选邮件并解析其 Date 头
  3. 日期排序: 按邮件的实际日期排序(最新的在前)
  4. 截取返回: 返回指定数量的最新邮件

缓存机制

获取的邮件会自动保存到 ~/.claude/skills/email-triage/cache/latest_emails.json, 包含以下信息:

  • fetched_at: 获取时间
  • account: 邮箱账号
  • total_count: 邮件总数
  • emails: 邮件详情列表

支持的邮箱服务商

服务商域名IMAP 服务器
QQ邮箱qq.comimap.qq.com
163邮箱163.comimap.163.com
126邮箱126.comimap.126.com
Gmailgmail.comimap.gmail.com
Outlookoutlook.comoutlook.office365.com
Hotmailhotmail.comoutlook.office365.com
Yahooyahoo.comimap.mail.yahoo.com
iCloudicloud.comimap.mail.me.com
阿里云邮箱aliyun.comimap.aliyun.com
新浪邮箱sina.comimap.sina.com

Keep looking

Skills are one crate of 328,083. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.