/install gmail-cleaner
Gmail Cleaner
Bulk Gmail cleanup using the Gmail API. Processes 1000 messages per API call.
Prerequisites
google-api-python-client,google-auth-oauthlibPython packages (scripts auto-install if missing)- OAuth credentials JSON from Google Cloud Console (Desktop app type)
- Token files stored as
.pklfiles per account
Workflow
1. Auth (first time or new account)
python scripts/auth.py --credentials /path/to/credentials.json --token /path/to/token.pkl --scopes settings
basicscopes: read/modify/delete messages + labelssettingsscopes: addsgmail.settings.basic(required for creating filters)- Default token path:
~/.openclaw/workspace/gmail_token.pkl - Default creds path:
~/.openclaw/workspace/gmail_credentials.json
For a second account, specify a different --token path (e.g., gmail_token_work.pkl).
2. Scan (identify what to clean)
python scripts/scan.py --token /path/to/token.pkl --sample 500
Shows inbox counts by category + top 40 senders. Run this first.
3. Clean (bulk trash/delete)
# Trash specific senders:
python scripts/clean.py --from "[email protected],[email protected]"
# Trash by Gmail search query:
python scripts/clean.py --query "category:promotions older_than:30d"
# From a JSON config file (list of {query, label}):
python scripts/clean.py --config senders.json
# Permanently delete instead of trash:
python scripts/clean.py --from "[email protected]" --delete
# Dry run first:
python scripts/clean.py --from "[email protected]" --dry-run
4. Deep Clean (comprehensive)
# Full deep clean (4 steps: trash promos → archive old → mark read → purge trash):
python scripts/deep_clean.py
# Custom age thresholds:
python scripts/deep_clean.py --promo-days 7 --archive-days 30 --unread-days 14
# Skip trash purge (keep trash for 30-day auto-delete):
python scripts/deep_clean.py --skip-trash-purge
5. Organize (labels + filters)
# Apply built-in label set (Business, Banking, Tech, Personal, Trading, Social):
python scripts/organize.py
# Custom labels/rules/filters from JSON:
python scripts/organize.py --config labels.json
# Labels only (no filters):
python scripts/organize.py --skip-filters
6. Restore (rescue emails from trash)
# Restore all emails from a sender + apply a label:
python scripts/restore.py --from [email protected] --label "Harvard Health"
# Restore by query:
python scripts/restore.py --query "from:apple.com in:trash" --label "Tech/Apple"
Multiple Accounts
Run each script with a different --token path per account:
python scripts/scan.py --token ~/.openclaw/workspace/gmail_token_personal.pkl
python scripts/scan.py --token ~/.openclaw/workspace/gmail_token_work.pkl
python scripts/deep_clean.py --token ~/.openclaw/workspace/gmail_token_work.pkl
Common Patterns
Full cleanup for one account:
python scripts/auth.py --scopes settings
python scripts/scan.py # identify top senders
python scripts/clean.py --from "..." # trash specific senders
python scripts/deep_clean.py # clean categories
python scripts/organize.py # create labels + filters
Rescue important emails caught in bulk delete:
python scripts/restore.py --from [email protected] --label "Important"
Senders config file format for clean.py --config:
[
{"query": "from:[email protected]", "label": "Temu"},
{"query": "category:promotions older_than:7d", "label": "Old Promos"}
]
Notes
batchModifymoves to TRASH — Gmail auto-purges after 30 daysbatchDeleteis permanent and irreversible — always dry-run first- Gmail filter creation requires
gmail.settings.basicscope — re-auth with--scopes settingsif filters fail with 403 scan.pysamples N messages; large inboxes may need--sample 2000for accuracy- Credentials JSON comes from Google Cloud Console → APIs & Services → Credentials → OAuth 2.0 → Desktop → Download JSON
- 确保已安装 OpenClaw(本地或 Docker 部署)
- 在对话框中输入安装命令:
/install gmail-cleaner - 安装完成后,直接呼叫该 Skill 的名称或使用
/gmail-cleaner触发 - 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
Gmail Cleaner 是什么?
Clean and organize Gmail accounts in bulk. Use when asked to clean Gmail, remove spam, trash newsletters/promotional emails, bulk-delete emails by sender, cr... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 543 次。
如何安装 Gmail Cleaner?
在 OpenClaw 或 Claude Code 对话框中运行命令「/install gmail-cleaner」即可一键安装,无需额外配置。
Gmail Cleaner 是免费的吗?
是的,Gmail Cleaner 完全免费(开源免费),可自由下载、安装和使用。
Gmail Cleaner 支持哪些平台?
Gmail Cleaner 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。
谁开发了 Gmail Cleaner?
由 cedarscy(@cedarscy)开发并维护,当前版本 v1.0.0。