archive-mail-repair-synthetic-ids

archive-mail-repair-synthetic-ids is a command for Claude Code from PsychQuant/che-apple-mail-mcp. It costs 0 tokens per session (1,269 once invoked), scanned A, original, MIT.

A one-time repair command for archived email files whose message ID was replaced with a made-up placeholder. A message ID is the identifier email systems use to distinguish one message from another.

In plain words
What is it for?
Use it to scan an archive, repair message metadata and its email index, identify files that cannot be matched, and place confirmed duplicates in a separate quarantine folder.
Why use it?
Made-up IDs can change between runs, causing the same email to be archived more than once. The command tries to recover the real ID from Mail and avoids merging messages unless they are confirmed duplicates.

Command for Claude Code

Written for Claude Code: shipped in a Claude Code plugin.

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

Good fit Use it to scan an archive, repair message metadata and its email index, identify files that cannot be matched, and place confirmed duplicates in a separate quarantine folder.

Compare 6 commands from other repositories ↓
Install with agentmods
npx agentmods add commands/psychquant/che-apple-mail-mcp/archive-mail-repair-synthetic-ids
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, 5 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-repair-synthetic-ids

README.md
[![agentmods](https://agentmods.dev/badge/commands/psychquant/che-apple-mail-mcp/archive-mail-repair-synthetic-ids/github.svg)](https://agentmods.dev/commands/psychquant/che-apple-mail-mcp/archive-mail-repair-synthetic-ids)
Your own site
<a href="https://agentmods.dev/commands/psychquant/che-apple-mail-mcp/archive-mail-repair-synthetic-ids"><img src="https://agentmods.dev/badge/commands/psychquant/che-apple-mail-mcp/archive-mail-repair-synthetic-ids/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-repair-synthetic-ids

Your own site · 80×15
<a href="https://agentmods.dev/commands/psychquant/che-apple-mail-mcp/archive-mail-repair-synthetic-ids"><img src="https://agentmods.dev/badge/commands/psychquant/che-apple-mail-mcp/archive-mail-repair-synthetic-ids.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 0 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,269 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.00000 $0.01269
Opus 5 $0.00000 $0.00634
Sonnet 5 $0.00000 $0.00254
Haiku 4.5 $0.00000 $0.00127

Measured 13d ago against content hash 8e715430280c, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-12, from the pricing page.

Security

Grade A, and why

archive-mail-repair-synthetic-ids 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 13d 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-repair-synthetic-ids.md · 68 lines

How it starts

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

/archive-mail-repair-synthetic-ids — 修復 synthetic message_id 佔位符(一次性,mail#319)

掃描歸檔目錄中 message_id 匹配 ^synthetic: 的 markdown 檔,嘗試從 Mail 重新解析真實 RFC 5322 Message-ID 並就地修復 frontmatter + email_index.json保守優先:寧可留 unparseable 交人工,絕不錯誤合併兩封不同的信。

背景(為什麼存在)

過去某些 session 在拿不到真 Message-ID 時即興發明了 synthetic:<ISO-timestamp> 佔位符(SOP 當時對缺值沒有規定——現已明文禁止,見 archive-mail frontmatter 規則)。synthetic key 的 timestamp 是執行當下時間,同一封信每次重跑產生不同 key → dedup 結構性失效:mail#319 實測單一 target 84/273 檔帶 synthetic key、單輪 12 封靜默重複、所有既有 gate 全綠。

用法

/archive-mail-repair-synthetic-ids <archive_target 或 output_dir>

Execution

Step 0: Bootstrap Task List(強制)

TaskCreate(name="scan_synthetic", description="glob 頂層 *.md,抓 frontmatter message_id 匹配 ^synthetic: 的清單")
TaskCreate(name="rekey_attempts", description="逐檔嘗試從 Mail 重新定位真 Message-ID(保守匹配,見下)")
TaskCreate(name="apply_repairs", description="可修者:改寫 frontmatter message_id + email_index.json 換 key(temp+rename 原子寫)")
TaskCreate(name="dedupe_pass", description="re-key 後同一真 Message-ID 對到多檔 → 內容比對確認重複 → 保留最早、其餘移 duplicates/ 子目錄(不刪)")
TaskCreate(name="report", description="修復報告:repaired / still-unparseable / duplicates-quarantined 三清單")

Step 1: 掃描

僅頂層 *.md(同 Step 8.5 紀律,不深入子目錄)。抓 frontmatter message_id 匹配 ^synthetic: 者,連同其 datethread_keysender、body Subject: 行入清單。

Step 2: 重新定位真 Message-ID(保守階梯)

對每檔依序嘗試,第一個成功即停

  1. Subject 精確搜尋search_emails(field: "subject", query: <bare subject>, projection: "summary", dedup: "logical") → 候選中 sender 相同且 date 相差 < 2 分鐘 者恰好一封 → 用該 id 呼叫 get_email_headers 取真 Message-ID。
  2. 候選為零或多於一封(含同 thread 密集時間戳的情形)→ 不猜。記入 still-unparseable

mail#319 issue 作者自證:ad-hoc (sender, bare_subject, ±時間窗) 三元組在密集 thread 中不可靠——所以匹配窗刻意窄(2 分鐘、恰好一封),寬鬆匹配寧可失敗。

Step 3: 修復

  • frontmatter:message_id: "synthetic:…"message_id: "<真值>"(原檔就地改寫)。
  • email_index.json:舊 synthetic key 的 entry 換 key 為真 Message-ID(temp+rename 原子寫,同 Step 8.5 紀律)。
  • 順帶修 date offset(mail#319 secondary defect):該檔 date 無 offset 時,用 get_email_headers 的 Date header 重寫為帶 offset 的 ISO。

Read the full file on GitHub · 68 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. 13d ago First seen · 68 lines · 0 tokens per session scan A 8e715430280c

Subscribe to this mod's changes

archive-mail-repair-synthetic-ids is a command published in the GitHub repository PsychQuant/che-apple-mail-mcp (8 stars, last pushed today), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 1,269 tokens. 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-08-30.