Setup
On first use, follow setup.md to define provider scope, command path preferences, and safety defaults before any write action.
When to Use
User wants to control Apple Mail from CLI while keeping account sync managed by Mail.app.
Agent handles read, search, triage, draft, send, move, archive, and delete workflows across accounts already connected in Apple Mail.
Requirements
- - macOS with Mail.app account access enabled for terminal automation.
- At least one working command path:
osascript, shortcuts, or sqlite3 read-only for indexed lookup. - Provider accounts already connected in Mail.app (Gmail, Outlook, iCloud, Yahoo, Fastmail, and Proton via Bridge if used).
- Explicit confirmation before sending, deleting, or bulk actions.
Architecture
Memory lives in ~/apple-mail-macos/. See memory-template.md for structure.
CODEBLOCK0
Quick Reference
| Topic | File |
|---|
| Setup and first-run behavior | INLINECODE6 |
| Memory structure |
memory-template.md |
| Command hierarchy and probes |
command-paths.md |
| Provider behavior matrix |
provider-coverage.md |
| Safety checklist before writes |
safety-checklist.md |
| Deterministic operation patterns |
operation-patterns.md |
| Failure handling and recovery |
troubleshooting.md |
Data Storage
All skill files are stored in ~/apple-mail-macos/.
Before creating or changing local files, describe the planned write and ask for confirmation.
Core Rules
1. Treat Mail.app as the Unified Account Layer
- - Assume provider sync is already configured in Apple Mail and operate on that local unified mailbox layer.
- Do not request direct provider OAuth inside this skill unless user explicitly asks for setup help.
2. Detect Command Path Before Every Operation
- - Probe command paths in strict order:
osascript, then shortcuts, then sqlite3 for read-only indexed lookup. - If no safe path is available, stop and report the exact blocker instead of guessing.
3. Default to Dry-Run for Write Intents
- - For compose, reply, move, archive, and delete workflows, first produce a dry-run preview with impacted messages and fields.
- Do not execute live changes until user confirms the dry-run summary.
4. Enforce High-Risk Confirmation Gates
- - Require explicit confirmation for send, delete, bulk move, bulk archive, forwarding, and reply-all expansions.
- If external recipients are added or recipient count changes, require a second confirmation.
5. Use Operation IDs and Idempotency
- - Generate a unique operation ID for every write workflow and include it in local operation logs.
- Before send, verify there is no prior successful send with the same operation context.
6. Read First, Write Once, Verify Immediately
- - Resolve message identity with at least two fields (message ID plus sender or date) before any write action.
- After every write, run read-back verification and report final mailbox state.
7. Keep Exposure Minimal and Local-First
- - Use only required fields for the requested task and avoid broad mailbox exports by default.
- Never send message bodies or attachments to undeclared external endpoints.
Common Traps
- - Sending from draft without final recipient review -> wrong recipient incidents.
- Matching threads by subject only -> replies sent in the wrong conversation.
- Bulk archive or delete without dry-run count -> accidental data loss.
- Assuming provider folder names are identical -> move failures or misplaced messages.
- Skipping read-back verification -> false success reports.
Security & Privacy
Data that stays local:
- - Operational context and defaults in
~/apple-mail-macos/. - Message metadata needed to execute the requested task.
Data that may leave your machine:
- - Email content only when user confirms a send, reply, or forward through already configured provider accounts.
This skill does NOT:
- - Send mail without explicit user confirmation.
- Execute destructive mailbox actions without dry-run and confirmation gates.
- Request undeclared API keys or call undeclared third-party APIs.
Related Skills
Install with
clawhub install <slug> if user confirms:
- -
macos - macOS command workflows and system automation patterns. - INLINECODE20 - cross-platform mailbox handling patterns and protocol references.
- INLINECODE21 - event extraction and action-item framing from communications.
- INLINECODE22 - scheduling workflows linked to message-driven tasks.
- INLINECODE23 - execution and prioritization frameworks for daily work.
Feedback
- - If useful: INLINECODE24
- Stay updated: INLINECODE25
设置
首次使用时,在执行任何写入操作前,请先按照 setup.md 文件定义提供商范围、命令路径偏好和安全默认设置。
使用场景
用户希望通过命令行控制 Apple Mail,同时保持 Mail.app 管理账户同步。
代理负责处理已在 Apple Mail 中连接的账户的读取、搜索、分类、草稿、发送、移动、归档和删除工作流程。
要求
- - macOS 系统,Mail.app 已启用账户访问权限以支持终端自动化。
- 至少有一条可用的命令路径:osascript、shortcuts 或只读索引查询的 sqlite3。
- 提供商账户已在 Mail.app 中连接(Gmail、Outlook、iCloud、Yahoo、Fastmail,以及通过 Bridge 使用的 Proton)。
- 发送、删除或批量操作前需获得明确确认。
架构
内存文件存储在 ~/apple-mail-macos/ 目录下。结构请参见 memory-template.md 文件。
text
~/apple-mail-macos/
├── memory.md # 状态、提供商映射、安全默认设置
├── command-paths.md # 可用的命令路径及备用方案说明
├── provider-coverage.md # 各提供商特定行为及注意事项
├── safety-log.md # 发送/删除确认及回滚记录
└── operation-log.md # 操作ID、验证证据、结果
快速参考
| 主题 | 文件 |
|---|
| 设置及首次运行行为 | setup.md |
| 内存结构 |
memory-template.md |
| 命令层级及探测 | command-paths.md |
| 提供商行为矩阵 | provider-coverage.md |
| 写入前安全检查清单 | safety-checklist.md |
| 确定性操作模式 | operation-patterns.md |
| 故障处理与恢复 | troubleshooting.md |
数据存储
所有技能文件存储在 ~/apple-mail-macos/ 目录下。
在创建或修改本地文件前,请描述计划写入的内容并请求确认。
核心规则
1. 将 Mail.app 视为统一账户层
- - 假设提供商同步已在 Apple Mail 中配置完成,并在此本地统一邮箱层上操作。
- 除非用户明确请求设置帮助,否则不要在此技能内请求直接提供商 OAuth。
2. 每次操作前检测命令路径
- - 按严格顺序探测命令路径:osascript,然后 shortcuts,最后 sqlite3(仅限只读索引查询)。
- 如果没有安全路径可用,则停止并报告确切障碍,而非猜测。
3. 写入意图默认执行预演
- - 对于撰写、回复、移动、归档和删除工作流程,首先生成包含受影响邮件及字段的预演预览。
- 在用户确认预演摘要之前,不执行实际更改。
4. 强制执行高风险确认关卡
- - 发送、删除、批量移动、批量归档、转发和全部回复扩展需要明确确认。
- 如果添加了外部收件人或收件人数量发生变化,需进行二次确认。
5. 使用操作ID和幂等性
- - 为每个写入工作流程生成唯一操作ID,并将其记录在本地操作日志中。
- 发送前,验证不存在具有相同操作上下文的先前成功发送记录。
6. 先读取,后写入,立即验证
- - 在任何写入操作前,至少使用两个字段(邮件ID加发件人或日期)确认邮件身份。
- 每次写入后,执行回读验证并报告最终邮箱状态。
7. 保持最小暴露范围,优先本地处理
- - 仅使用所请求任务所需的字段,默认避免广泛的邮箱导出。
- 切勿将邮件正文或附件发送至未声明的外部端点。
常见陷阱
- - 未最终审查收件人即从草稿发送 → 收件人错误事件。
- 仅按主题匹配线程 → 回复发送到错误的对话中。
- 未进行预演计数即批量归档或删除 → 意外数据丢失。
- 假设提供商文件夹名称相同 → 移动失败或邮件错位。
- 跳过回读验证 → 虚假的成功报告。
安全与隐私
保留在本地的数据:
- - ~/apple-mail-macos/ 中的操作上下文和默认设置。
- 执行所请求任务所需的邮件元数据。
可能离开您设备的数据:
- - 仅在用户确认通过已配置的提供商账户发送、回复或转发时的邮件内容。
此技能不会:
- - 在未获得用户明确确认的情况下发送邮件。
- 未经预演和确认关卡执行破坏性邮箱操作。
- 请求未声明的API密钥或调用未声明的第三方API。
相关技能
如果用户确认,使用 clawhub install 安装:
- - macos - macOS 命令工作流程和系统自动化模式。
- mail - 跨平台邮箱处理模式和协议参考。
- events - 从通信中提取事件和行动项。
- schedule - 与消息驱动任务关联的调度工作流程。
- productivity - 日常工作的执行和优先级排序框架。
反馈
- - 如果觉得有用:clawhub star apple-mail-macos
- 保持更新:clawhub sync