关于 gmail
gmail 是通过 Gmail API 管理邮件的技能,支持多个 Google 账户的读取、搜索、发送和整理。发送流程包含上下文收集、草稿反馈和测试邮件确认。
主要功能
- 01管理多个 Google 账户
- 02读取和搜索邮件
- 03发送邮件并整理标签
- 04发送前测试并请求确认
- 05令牌过期时自动刷新
适用场景
- 01查找未读邮件或历史对话
- 02根据背景信息起草邮件
- 03测试并确认后向收件人发送邮件
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ team-attention/ plugins-for-claude-natives --skill gmail安装后在 Claude Code 中输入/gmail确认已加载。
包含的文件
除 SKILL.md 外,安装时一起下载的参考资料和脚本。
.gitignoreaccounts.yaml.examplepyproject.tomlassets/accounts.default.yamlemail-templates.mdsignatures.mdreferences/cli-usage.mdsearch-queries.mdsetup-guide.mdscripts/gmail_client.pylist_messages.pymanage_labels.pyread_message.pysend_message.pysetup_auth.pyscripts/core/__init__.pybatch_processor.pycache_manager.pyquota_manager.pyretry_handler.py详细介绍
Gmail 技能
通过 Gmail API 管理邮件——跨多个 Google 账号读取、搜索、发送和整理邮件。
账号设置
运行任何命令前,先读取 accounts.yaml 检查已注册的账号。
如果
accounts.yaml缺失或为空 → 阅读references/setup-guide.md进行初始设置
# accounts.yaml example
accounts:
personal:
email: [email protected]
description: Personal Gmail
work:
email: [email protected]
description: Work account
邮件发送工作流(5 个步骤)
发送邮件时,使用 TaskCreate 创建 5 个任务,并按顺序执行:
| 步骤 | 任务 | 关键操作 |
|---|---|---|
| 1 | 收集上下文 | 并行运行 Explore SubAgents:收件人信息、相关项目、背景信息 |
| 2 | 检查之前的对话 | 搜索 --query "to:recipient OR from:recipient newer_than:90d" → 使用 AskUserQuestion 选择邮件会话 |
| 3 | 起草邮件 | 撰写草稿 → 使用 AskUserQuestion 征求反馈 |
| 4 | 测试发送 | 向用户自己的地址发送 [TEST] 邮件 → 在 Gmail 网页版中打开 → 请求确认 |
| 5 | 正式发送 | 发送给收件人 → 报告完成情况 |
签名:在所有外发邮件末尾附加 ---\nSent with Claude Code
工作流示例:“给 John 发送会议邮件”
1. Create 5 Tasks
2. Step 1: Run parallel Explore SubAgents
- Search recipient (John) info (partners/, projects/, context.md, etc.)
- Search meeting context (calendar, recent meeting notes, etc.)
3. Step 2: Search "to:[email protected] OR from:[email protected]"
→ If previous conversation exists, AskUserQuestion (reply/new email)
4. Step 3: Draft email → AskUserQuestion (proceed/revise)
5. Step 4: Test send to my email → Open in Gmail web (`open "https://mail.google.com/mail/u/0/#inbox/{message_id}"`) → Request confirmation
6. Step 5: Actual send → Done
CLI 快速参考
# List messages
uv run python scripts/list_messages.py --account work --query "is:unread" --max 10
# Send email
uv run python scripts/send_message.py --account work --to "[email protected]" --subject "Subject" --body "Content"
# Check profile
uv run python scripts/manage_labels.py --account work profile
CLI 详细用法:
references/cli-usage.md搜索查询参考:references/search-queries.md
在网页版中查看邮件
发送后,使用返回的 Message ID 在 Gmail 网页版中直接查看:
# URL format
https://mail.google.com/mail/u/0/#inbox/{message_id}
# Example: Open in browser after test send
open "https://mail.google.com/mail/u/0/#inbox/19c145bbd47ddd01"
注意:
u/0是第一个登录的账号,u/1是第二个账号
文件结构
skills/gmail/
├── SKILL.md
├── accounts.yaml # Account metadata
├── scripts/ # CLI scripts
├── references/
│ ├── setup-guide.md # Initial setup guide
│ ├── cli-usage.md # Detailed CLI usage
│ ├── search-queries.md # Search query reference
│ └── credentials.json # OAuth Client ID (gitignore)
├── assets/
│ ├── accounts.default.yaml # Account config template
│ ├── email-templates.md # Email body templates
│ └── signatures.md # Signature templates (Plain/HTML)
└── accounts/ # Per-account tokens (gitignore)
错误处理
| 情况 | 解决方法 |
|---|---|
| accounts.yaml 缺失 | 阅读 references/setup-guide.md 进行初始设置 |
| 缺少令牌 | 指引用户运行 setup_auth.py --account <name> |
| 令牌过期 | 自动刷新;如果失败,指引用户重新进行身份验证 |
评论
支持 Markdown