# Send Gmail Cleaner to your agent
Hand the extracted package to your coding agent with a concrete install brief instead of figuring it out manually.
## Fast path
- Download the package from Yavira.
- Extract it into a folder your agent can access.
- Paste one of the prompts below and point your agent at the extracted folder.
## Suggested prompts
### New install

```text
I downloaded a skill package from Yavira. Read SKILL.md from the extracted folder and install it by following the included instructions. Tell me what you changed and call out any manual steps you could not complete.
```
### Upgrade existing

```text
I downloaded an updated skill package from Yavira. Read SKILL.md from the extracted folder, compare it with my current installation, and upgrade it while preserving any custom configuration unless the package docs explicitly say otherwise. Summarize what changed and any follow-up checks I should run.
```
## Machine-readable fields
```json
{
  "schemaVersion": "1.0",
  "item": {
    "slug": "gmail-cleaner",
    "name": "Gmail Cleaner",
    "source": "tencent",
    "type": "skill",
    "category": "效率提升",
    "sourceUrl": "https://clawhub.ai/cedarscy/gmail-cleaner",
    "canonicalUrl": "https://clawhub.ai/cedarscy/gmail-cleaner",
    "targetPlatform": "OpenClaw"
  },
  "install": {
    "downloadUrl": "/downloads/gmail-cleaner",
    "sourceDownloadUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=gmail-cleaner",
    "sourcePlatform": "tencent",
    "targetPlatform": "OpenClaw",
    "packageFormat": "ZIP package",
    "primaryDoc": "SKILL.md",
    "includedAssets": [
      "scripts/auth.py",
      "scripts/clean.py",
      "scripts/deep_clean.py",
      "scripts/organize.py",
      "scripts/restore.py",
      "scripts/scan.py"
    ],
    "downloadMode": "redirect",
    "sourceHealth": {
      "source": "tencent",
      "slug": "gmail-cleaner",
      "status": "healthy",
      "reason": "direct_download_ok",
      "recommendedAction": "download",
      "checkedAt": "2026-04-30T00:43:33.098Z",
      "expiresAt": "2026-05-07T00:43:33.098Z",
      "httpStatus": 200,
      "finalUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=gmail-cleaner",
      "contentType": "application/zip",
      "probeMethod": "head",
      "details": {
        "probeUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=gmail-cleaner",
        "contentDisposition": "attachment; filename=\"gmail-cleaner-1.0.0.zip\"",
        "redirectLocation": null,
        "bodySnippet": null,
        "slug": "gmail-cleaner"
      },
      "scope": "item",
      "summary": "Item download looks usable.",
      "detail": "Yavira can redirect you to the upstream package for this item.",
      "primaryActionLabel": "Download for OpenClaw",
      "primaryActionHref": "/downloads/gmail-cleaner"
    },
    "validation": {
      "installChecklist": [
        "Use the Yavira download entry.",
        "Review SKILL.md after the package is downloaded.",
        "Confirm the extracted package contains the expected setup assets."
      ],
      "postInstallChecks": [
        "Confirm the extracted package includes the expected docs or setup files.",
        "Validate the skill or prompts are available in your target agent workspace.",
        "Capture any manual follow-up steps the agent could not complete."
      ]
    }
  },
  "links": {
    "detailUrl": "https://openagent3.xyz/skills/gmail-cleaner",
    "downloadUrl": "https://openagent3.xyz/downloads/gmail-cleaner",
    "agentUrl": "https://openagent3.xyz/skills/gmail-cleaner/agent",
    "manifestUrl": "https://openagent3.xyz/skills/gmail-cleaner/agent.json",
    "briefUrl": "https://openagent3.xyz/skills/gmail-cleaner/agent.md"
  }
}
```
## Documentation

### 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

### 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

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 "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

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
## Trust
- Source: tencent
- Verification: Indexed source record
- Publisher: cedarscy
- Version: 1.0.0
## Source health
- Status: healthy
- Item download looks usable.
- Yavira can redirect you to the upstream package for this item.
- Health scope: item
- Reason: direct_download_ok
- Checked at: 2026-04-30T00:43:33.098Z
- Expires at: 2026-05-07T00:43:33.098Z
- Recommended action: Download for OpenClaw
## Links
- [Detail page](https://openagent3.xyz/skills/gmail-cleaner)
- [Send to Agent page](https://openagent3.xyz/skills/gmail-cleaner/agent)
- [JSON manifest](https://openagent3.xyz/skills/gmail-cleaner/agent.json)
- [Markdown brief](https://openagent3.xyz/skills/gmail-cleaner/agent.md)
- [Download page](https://openagent3.xyz/downloads/gmail-cleaner)