Gmail Cleaner
简介
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...
通过你的 Agent 添加
安装目录:gmail-cleaner/(目录名取自 SKILL.md 的 frontmatter name,不是 URL 里的 slug)。
点「快速安装」复制一段指令贴给你的 Agent:它会先下载到 /tmp、把文件清单和校验值给你看,你确认之后才解压安装。不会一步装完、也不改系统其它位置。
或者手动安装
包是「根级 SKILL.md + 作者附带的文件」,解压到上面的 <slug>/ 目录即可;
目录名不用换,也不要把包直接解压到 skills 根目录。
技能申请的权限由作者决定:装之前先看清单里有没有脚本、它会读写什么。
技能正文
name: gmail-cleaner
description: Clean and organize Gmail accounts in bulk. Use when asked to clean Gmail, remove spam, trash newsletters/promotional emails, bulk-delete emails by sender, create labels, set up auto-filters, or restore emails from trash. Handles single or multiple Gmail accounts via OAuth token files. Works with any Gmail account using the Gmail API.
Gmail Cleaner
Bulk Gmail cleanup using the Gmail API. Processes 1000 messages per API call.
Prerequisites
google-api-python-client, google-auth-oauthlib Python packages (scripts auto-install if missing)
- OAuth credentials JSON from Google Cloud Console (Desktop app type)
- Token files stored as
.pkl files 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
basic scopes: read/modify/delete messages + labels
settings scopes: adds gmail.settings.basic (required for creating filters)
- Default token path:
~/.openclaw/workspace/gmail_token.pkl
- Default creds path:
~/.openclaw/workspace/gmail_credentials.json
google-api-python-client, google-auth-oauthlib Python packages (scripts auto-install if missing).pkl files per account1. Auth (first time or new account)
python scripts/auth.py --credentials /path/to/credentials.json --token /path/to/token.pkl --scopes settings
basic scopes: read/modify/delete messages + labelssettings scopes: adds gmail.settings.basic (required for creating filters)~/.openclaw/workspace/gmail_token.pkl~/.openclaw/workspace/gmail_credentials.jsonFor 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
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 "spam@example.com,news@example.org"
# 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 "spam@example.com" --delete
# Dry run first:
python scripts/clean.py --from "spam@example.com" --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 healthbeat@mail.health.harvard.edu --label "Harvard Health"
# Restore by query:
python scripts/restore.py --query "from:apple.com in:trash" --label "Tech/Apple"
Multiple Accounts
# Trash specific senders:
python scripts/clean.py --from "spam@example.com,news@example.org"
# 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 "spam@example.com" --delete
# Dry run first:
python scripts/clean.py --from "spam@example.com" --dry-run
# 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 healthbeat@mail.health.harvard.edu --label "Harvard Health"
# Restore by query:
python scripts/restore.py --query "from:apple.com in:trash" --label "Tech/Apple"
Multiple Accounts
# 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
# Restore all emails from a sender + apply a label:
python scripts/restore.py --from healthbeat@mail.health.harvard.edu --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 important@example.com --label "Important"
Senders config file format for clean.py --config:
[
{"query": "from:temu@eu.temuemail.com", "label": "Temu"},
{"query": "category:promotions older_than:7d", "label": "Old Promos"}
]
Notes
batchModify moves to TRASH — Gmail auto-purges after 30 days
batchDelete is permanent and irreversible — always dry-run first
- Gmail filter creation requires
gmail.settings.basic scope — re-auth with --scopes settings if filters fail with 403
scan.py samples N messages; large inboxes may need --sample 2000 for accuracy
- Credentials JSON comes from Google Cloud Console → APIs & Services → Credentials → OAuth 2.0 → Desktop → Download JSON
batchModify moves to TRASH — Gmail auto-purges after 30 daysbatchDelete is permanent and irreversible — always dry-run firstgmail.settings.basic scope — re-auth with --scopes settings if filters fail with 403scan.py samples N messages; large inboxes may need --sample 2000 for accuracy正文来自原始发布页, 版权归作者所有,许可未标注。 权利人认为有不妥,可申请下架。