archive-mail-tree

archive-mail-tree is a command for Claude Code from PsychQuant/che-apple-mail-mcp. It costs 25 tokens per session (2,166 once invoked), scanned A, original, MIT.

A command for finding and distributing email through a registered archive hierarchy. It first captures messages in an intake location, previews proposed destinations, and then performs or resumes the approved archival work.

In plain words
What is it for?
Use it to search configured mail targets, remove duplicate message IDs, stage candidates, archive messages, resume interrupted work, and reconcile the affected archive indexes.
Why use it?
It prevents duplicate processing and stops uncertain messages from being silently assigned to the wrong archive. It also preserves search scope and historical records while checking each destination.

Command for Claude Code

Written for Claude Code: allowed-tools in frontmatter.

Part of the che-apple-mail-mcp plugin — 3 skills, 9 commands, 1 hook shipped together

Good fit Use it to search configured mail targets, remove duplicate message IDs, stage candidates, archive messages, resume interrupted work, and reconcile the affected archive indexes.

Compare 6 commands from other repositories ↓
Install with agentmods
npx agentmods add commands/psychquant/che-apple-mail-mcp/archive-mail-tree
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Clone the repo
git clone --depth 1 https://github.com/PsychQuant/che-apple-mail-mcp

Made for: Claude Code.

Or install che-apple-mail-mcp, the plugin that ships this one along with the rest of its 3 skills, 9 commands, 1 hook.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for archive-mail-tree

README.md
[![agentmods](https://agentmods.dev/badge/commands/psychquant/che-apple-mail-mcp/archive-mail-tree/github.svg)](https://agentmods.dev/commands/psychquant/che-apple-mail-mcp/archive-mail-tree)
Your own site
<a href="https://agentmods.dev/commands/psychquant/che-apple-mail-mcp/archive-mail-tree"><img src="https://agentmods.dev/badge/commands/psychquant/che-apple-mail-mcp/archive-mail-tree/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for archive-mail-tree

Your own site · 80×15
<a href="https://agentmods.dev/commands/psychquant/che-apple-mail-mcp/archive-mail-tree"><img src="https://agentmods.dev/badge/commands/psychquant/che-apple-mail-mcp/archive-mail-tree.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 25 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 2,166 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00025 $0.02166
Opus 5.5 $0.00010 $0.00866
Sonnet 5.5 $0.00005 $0.00433
Haiku 4.5 $0.00003 $0.00217

Measured 6d ago against content hash b9b0f5aaa7e7, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

archive-mail-tree scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 6d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

plugin/commands/archive-mail-tree.md · 71 lines

How it starts

The opening of the file, as written. The whole thing — 71 lines — stays where its author put it; the contents beside it link to each section on GitHub.

階層歸檔

本命令處理已登錄目標,使用 archive_registry.py 與 archive_distribution.py,不是把目錄名字當成分類規則。未登錄者回原 archive-mail;不自動建立 registry。

階段清單

建立並逐項更新工作清單:驗證 registry/scope;搜尋與去重;目的地預覽;完整 staging;執行或 resume;所有受影響目標 reconcile;報告。任一步未完成不得回報整體成功。

1. 範圍、搜尋與歷史

  1. 用 registry helper 的 snapshot 讀取所選目標的整個組織樹。缺少/損壞 index 即停止,不以空歷史繼續。保留 JSON 快照、index 指紋及 locations 至本輪結束。
  2. 本命令未另限 filter 時,各目標依自己 config 的 filters 搜尋,因為父層 filter 不保證包含子層。從原 /archive-mail <filter> <output> 轉入時,保留原本已授權的 filter/範圍,不默默搜尋其餘所有 config。需要擴大 corpus 時先顯示範圍並取得使用者同意。
  3. 搜尋、sender/recipient 判斷、refinement、false-positive scan、草稿處理及 Message-ID 正規化沿用 archive-mail.md Steps 1.4、1.5、3–4 的程序;以每個目標自己的 config 和共同 identity alias 結果執行。這是引用程序,不要遞迴呼叫 /archive-mail。
  4. 各層候選以真實 Message-ID 去重,再排除 snapshot.history 的全部鍵(包含 tombstone),即使 local 設 last_archived 也必須做 registry 去重。date-only 策略仍可作額外篩選,不能取代已知 ID 歷史。
  5. 樹內目標由 registry index 負責;distributed_archives 若解析到樹內 output,略過重複掃描。樹外目錄沿用原 Step 2.1 的只讀額外 dedup,缺目錄仍警告。不從 distributed_archives 反向建立 parent。
  6. 已在 history 的信只回報位置及 index-only 狀態,不重抓補檔。這不阻擋保留「父 filter 沒抓到、child 才發現」且 history 沒有的新信。

2. 目的地預覽

為每個新 Message-ID 寫 candidates JSON;matched_target_ids 只放已確認分類判準命中的目標,沒把握放 []。同名 collaborator 或 filter 命中不是自動歸屬證據。以 helper plan 產生 plan.json。

預覽必須逐項列出信件、發現來源、capture root、最後目的地與判斷理由。跨支線歧義留共同祖先 intake,無匹配留 root intake。先依既有 confirmation-protocol 取得這份 corpus/目的地映射的授權;先前只批准單一 workspace 的動作,不能當成額外子樹寫入授權。沒有新信則報告既有位置/去重結果後結束,不呼叫 execute。

3. 完整 staging(尚未寫入歸檔目標)

  • 在獲准的 workspace 下建立專用、一般名稱的暫存目錄,例如 archive-stage-<uuid>,以檔案 API 建立,所有路徑作為資料引數。不能在 $HOME/.claude 等 export 禁止位置繞過工具政策。
  • 引用原 Steps 5、5.5 的完整本文匯出、附件清單與下載程序,輸出改為 stage。此時不更新任何目標 index/threads。凍結六欄 frontmatter 與 verbatim body,不能為方便分派改寫內容。
  • 檔名由已支援的 filename_style: archive-mail 或原 Date-header 同源 fallback 產生。先檢查預計 intake/目的地皆沒有同名檔,且各目標 index 的歷史 entry(含 tombstone)沒有保留該檔名;以大小寫與 Unicode 等價比較。碰撞時依原命名規則另取 -N,更新預覽與 manifest。executor 永不覆寫既有檔。
  • 每封所有 explicit/inline 附件均下載到 stage 內,使用原 safe leaf 與 Markdown label/URL encoding 規則。只使用標準 inline links:[label](URL-encoded-relative-path) 或 ![label](URL-encoded-relative-path);不帶 title、不用 reference-style,不留下同附件的 ./... 等另一拼法。不要改與附件無關的原始信件內文連結;若無法安全準備,停止該項並揭露。
  • manifest 必須列出全部已列舉附件。任何附件下載失敗、內容為 partial/header-only、真實 Message-ID 未確認,皆不得提交該封為完整 capture;保留 stage 與錯誤供重試,不用空 attachments 假裝成功。
  • 分別讀 root 與目的地 config 的有效 attachment_routing(#334 逐欄覆寫);將每個附件的 intake_path/destination_path 設為該目標 workspace 相對路徑,或明確登錄 attachment_roots 內的絕對路徑。暫存位置不必與最終位置相同;executor 會依對應清單改寫已知附件 URL。

Read the full file on GitHub · 71 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 6d ago First seen · 71 lines · 25 tokens per session scan A b9b0f5aaa7e7

Subscribe to this mod's changes

archive-mail-tree is a command published in the GitHub repository PsychQuant/che-apple-mail-mcp (10 stars, last pushed yesterday), licensed MIT. It adds 25 tokens to every session and 2,166 once invoked, about $0.0001 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-10-30.