When to Use
Use this skill when the user needs to inspect or operate an IMAP mailbox across Gmail, Fastmail, ProtonMail Bridge, Exchange-compatible gateways, or self-hosted mail servers.
Activate it for inbox search, unread triage, header and body fetches, attachment handling, folder mapping, or incremental mailbox sync when correctness matters more than quick ad hoc scraping.
Architecture
Memory lives in ~/imap/. If ~/imap/ does not exist, run setup.md. See memory-template.md for the default structure and file templates.
CODEBLOCK0
Quick Reference
Use these files when the current mailbox task needs more detail than the core rules provide.
| Topic | File |
|---|
| Setup and activation defaults | INLINECODE4 |
| Memory and file templates |
memory-template.md |
| Session planning and discovery |
session-strategy.md |
| Search and fetch patterns |
search-and-fetch.md |
| State, flags, and sync rules |
state-and-flags.md |
| Attachment and MIME handling |
attachments.md |
| Failure diagnosis and provider quirks |
troubleshooting.md |
Core Rules
1. Discover mailbox capabilities before making assumptions
- - Identify server capabilities, namespace layout, delimiter behavior, and special-use folders before building commands or interpreting results.
- Check whether the server supports features such as
UIDPLUS, CONDSTORE, QRESYNC, MOVE, or XLIST replacements. - Folder names, archives, and flag behavior vary by provider, so do not hard-code Gmail semantics onto every mailbox.
2. Default to read-safe operations unless the user clearly wants mutation
- - Start with safe inspection patterns such as capability discovery, folder listing,
EXAMINE, header fetches, and targeted body retrieval. - Treat delete, move, copy, expunge, and bulk flag updates as mutating actions that require either explicit user approval or a previously confirmed standing policy.
- If the user only asked to inspect or summarize mail, do not silently mark messages seen or alter mailbox state.
3. Use UIDs and durable sync markers, not volatile sequence numbers
- - Sequence numbers shift as mail arrives or is removed, so they are unsafe for persistent tracking.
- For repeatable workflows, store
UIDVALIDITY, last processed UID, and when available HIGHESTMODSEQ or related sync checkpoints in ~/imap/sync-state.md. - If
UIDVALIDITY changes, treat prior cursors as invalid and rescan instead of trusting stale state.
4. Fetch the minimum data that answers the question
- - Start with folder listing, counts, flags, and envelope or header data before downloading full bodies or attachments.
- Escalate to body sections, MIME structure, or attachments only when the user actually needs that detail.
- Smaller fetches reduce latency, bandwidth, and the chance of dragging sensitive content into unnecessary downstream processing.
5. Search with explicit server-side filters and report what they mean
- - Prefer precise IMAP search constraints such as date ranges, sender, subject fragments, flags, size limits, or UID windows over broad mailbox scans.
- Be clear about whether the server search is header-only, text-oriented, charset-sensitive, or provider-specific in its matching behavior.
- When search semantics are ambiguous, explain the limitation and offer a narrower or confirmatory pass.
6. Treat MIME and attachments as structured data, not opaque blobs
- - Read
BODYSTRUCTURE or equivalent metadata before assuming where text lives or which parts are attachments. - Distinguish inline parts from downloadable attachments, decode filenames safely, and preserve charset and transfer-encoding details.
- Avoid downloading large attachments unless needed, and report part identifiers, sizes, and media types first when triaging.
7. Keep credentials out of skill memory and scope network use tightly
- - Store only non-secret connection notes, capabilities, and workflow preferences under
~/imap/. - Never ask the user to paste account passwords into memory files; use existing local auth flows, app passwords, OAuth-backed bridges, or other secure runtime mechanisms the environment already supports.
- Restrict network activity to the user-configured IMAP endpoint needed for the mailbox task at hand.
IMAP Traps
- - Treating message sequence numbers as stable identifiers -> follow-up fetches hit the wrong message after mailbox changes.
- Marking mail seen during a read-only review -> the user loses unread state without asking for it.
- Downloading entire folders to answer a narrow question -> latency, bandwidth, and privacy costs rise for no gain.
- Ignoring
UIDVALIDITY resets -> incremental sync silently skips or duplicates messages. - Assuming every server supports
MOVE, IDLE, or Gmail-style special folders -> commands fail or behave differently across providers. - Parsing attachments without checking MIME structure first -> inline parts, filenames, or charsets get misread.
External Endpoints
| Endpoint | Data Sent | Purpose |
|---|
| User-configured IMAP or IMAPS server | authentication material handled by the runtime, mailbox commands, requested headers, bodies, flags, and attachments | list folders, search messages, fetch content, and update mailbox state when approved |
No other data is sent externally.
Security & Privacy
Data that stays local:
- - Activation defaults, provider quirks, sync checkpoints, and reusable playbooks stored under INLINECODE26
- Mailbox notes the user explicitly wants remembered for future sessions
Data that leaves your machine:
- - Only the IMAP requests needed to talk to the configured mailbox server
- Message metadata, bodies, or attachments fetched from that mailbox when the current task requires them
This skill does NOT:
- - store mailbox passwords or OAuth tokens in INLINECODE27
- assume mutating mailbox access is allowed by default
- send mailbox content to undeclared third parties
- treat sequence numbers as durable sync state
Trust
By using this skill, data is exchanged with the user-configured mail provider or IMAP bridge.
Only use it with mailbox systems and local credential flows the user already trusts.
Related Skills
Install with
clawhub install <slug> if user confirms:
- -
api - use when the mailbox task is really an API integration or authenticated service wrapper problem. - INLINECODE30 - use when the work is request shaping, header debugging, or protocol inspection outside an IMAP session.
- INLINECODE31 - use when mailbox results need structured transformation, normalization, or downstream machine-readable output.
- INLINECODE32 - use when the user needs a full implementation, parser, or sync worker built and verified end to end.
- INLINECODE33 - use for shell-first mailbox tooling, local automation, and repeatable command wrappers.
Feedback
- - If useful: INLINECODE34
- Stay updated: INLINECODE35
何时使用
当用户需要检查或操作跨Gmail、Fastmail、ProtonMail Bridge、Exchange兼容网关或自托管邮件服务器的IMAP邮箱时,使用此技能。
当需要收件箱搜索、未读邮件分类、标头和正文获取、附件处理、文件夹映射或增量邮箱同步,且正确性比快速临时抓取更重要时,激活此技能。
架构
内存数据存储在 ~/imap/ 目录下。如果 ~/imap/ 不存在,请运行 setup.md。默认结构和文件模板请参见 memory-template.md。
~/imap/
├── memory.md # 激活默认值、变更策略、首选报告风格
├── accounts.md # 邮箱特定端点、认证说明和服务器能力
├── folder-map.md # 规范文件夹映射和提供商特性
├── sync-state.md # UIDVALIDITY、最后UID、MODSEQ和同步检查点
└── playbooks.md # 保存的邮箱工作流和可复用搜索方案
快速参考
当当前邮箱任务需要比核心规则更详细的说明时,请使用以下文件。
| 主题 | 文件 |
|---|
| 设置和激活默认值 | setup.md |
| 内存和文件模板 |
memory-template.md |
| 会话规划和发现 | session-strategy.md |
| 搜索和获取模式 | search-and-fetch.md |
| 状态、标志和同步规则 | state-and-flags.md |
| 附件和MIME处理 | attachments.md |
| 故障诊断和提供商特性 | troubleshooting.md |
核心规则
1. 在做出假设前先发现邮箱能力
- - 在构建命令或解释结果之前,先识别服务器能力、命名空间布局、分隔符行为和特殊用途文件夹。
- 检查服务器是否支持 UIDPLUS、CONDSTORE、QRESYNC、MOVE 或 XLIST 替代等功能。
- 文件夹名称、归档和标志行为因提供商而异,因此不要将Gmail语义硬编码到每个邮箱中。
2. 默认使用只读安全操作,除非用户明确要求变更
- - 从安全的检查模式开始,如能力发现、文件夹列表、EXAMINE、标头获取和针对性正文检索。
- 将删除、移动、复制、清除和批量标志更新视为变更操作,需要明确的用户批准或先前确认的既定策略。
- 如果用户仅要求检查或汇总邮件,不要静默标记邮件为已读或更改邮箱状态。
3. 使用UID和持久同步标记,而非易变的序列号
- - 序列号会随着邮件的到达或删除而变化,因此不适合持久跟踪。
- 对于可重复的工作流,将 UIDVALIDITY、最后处理的UID以及可用的 HIGHESTMODSEQ 或相关同步检查点存储在 ~/imap/sync-state.md 中。
- 如果 UIDVALIDITY 发生变化,将先前的游标视为无效,重新扫描而非信任过时状态。
4. 获取回答问题的所需最小数据
- - 从文件夹列表、计数、标志和信封或标头数据开始,然后再下载完整正文或附件。
- 仅在用户确实需要详细信息时,才升级到正文部分、MIME结构或附件。
- 较小的获取操作可减少延迟、带宽以及将敏感内容拖入不必要下游处理的风险。
5. 使用显式服务器端过滤器进行搜索,并报告其含义
- - 优先使用精确的IMAP搜索约束,如日期范围、发件人、主题片段、标志、大小限制或UID窗口,而非广泛的邮箱扫描。
- 明确说明服务器搜索是仅标头、面向文本、字符集敏感还是提供商特定的匹配行为。
- 当搜索语义不明确时,解释限制并提供更窄或确认性的通行方案。
6. 将MIME和附件视为结构化数据,而非不透明块
- - 在假设文本位置或哪些部分是附件之前,先读取 BODYSTRUCTURE 或等效元数据。
- 区分内联部分和可下载附件,安全解码文件名,并保留字符集和传输编码细节。
- 除非必要,避免下载大附件,并在分类时先报告部分标识符、大小和媒体类型。
7. 将凭据排除在技能内存之外,并严格限定网络使用范围
- - 仅在 ~/imap/ 下存储非机密的连接说明、能力和工作流偏好。
- 切勿要求用户将账户密码粘贴到内存文件中;使用现有的本地认证流程、应用密码、OAuth支持的桥接或环境已支持的其他安全运行时机制。
- 将网络活动限制在用户配置的、当前邮箱任务所需的IMAP端点。
IMAP陷阱
- - 将消息序列号视为稳定标识符 -> 邮箱更改后后续获取会命中错误消息。
- 在只读审查期间标记邮件为已读 -> 用户未要求但丢失了未读状态。
- 下载整个文件夹以回答狭窄问题 -> 延迟、带宽和隐私成本增加而无收益。
- 忽略 UIDVALIDITY 重置 -> 增量同步静默跳过或重复消息。
- 假设每个服务器都支持 MOVE、IDLE 或Gmail风格的特殊文件夹 -> 命令在不同提供商间失败或行为不同。
- 未检查MIME结构就解析附件 -> 内联部分、文件名或字符集被误读。
外部端点
| 端点 | 发送的数据 | 目的 |
|---|
| 用户配置的IMAP或IMAPS服务器 | 由运行时处理的认证材料、邮箱命令、请求的标头、正文、标志和附件 | 列出文件夹、搜索消息、获取内容以及在批准时更新邮箱状态 |
不向外部发送其他数据。
安全与隐私
本地保留的数据:
- - 存储在 ~/imap/ 下的激活默认值、提供商特性、同步检查点和可复用方案
- 用户明确希望为未来会话记住的邮箱说明
离开您机器的数据:
- - 仅与配置的邮箱服务器通信所需的IMAP请求
- 当前任务需要时从该邮箱获取的消息元数据、正文或附件
此技能不会:
- - 在 ~/imap/ 中存储邮箱密码或OAuth令牌
- 默认允许变更性邮箱访问
- 将邮箱内容发送给未声明的第三方
- 将序列号视为持久同步状态
信任
使用此技能时,数据将与用户配置的邮件提供商或IMAP桥接进行交换。
仅与用户已信任的邮箱系统和本地凭据流程一起使用。
相关技能
如果用户确认,使用 clawhub install
安装:
- - api - 当邮箱任务实际上是API集成或认证服务包装问题时使用。
- http - 当工作是请求塑造、标头调试或IMAP会话外的协议检查时使用。
- json - 当邮箱结果需要结构化转换、规范化或下游机器可读输出时使用。
- code - 当用户需要完整的实现、解析器或同步工作器端到端构建和验证时使用。
- bash - 用于以shell为主的邮箱工具、本地自动化和可重复的命令包装器。
反馈
- - 如果有用:clawhub star imap
- 保持更新:clawhub sync