Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from bundle
Preview-first Gmail search and guarded batch archive using existing gog auth.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
SKILL.md
1---2name: gmail-safe-batch-ops3description: Search, preview, and batch-archive Gmail safely with gog auth, dry-run-first filters, and safety caps for inbox cleanup.4allowed-tools: Bash Read5---67# gmail-safe-batch-ops89Use this when you need Gmail search, inbox triage, or cautious batch cleanup without jumping straight into destructive mailbox changes.1011## What this bundle gives you1213- fast read-only Gmail search via `gog`14- a bundled Python helper for preview-first mailbox filtering15- guarded batch archive mode with message-count and ratio safety caps16- JSON summaries that are easy to inspect, save, or review before applying changes1718## Requirements1920- `gog` installed and authenticated for Gmail21- `python3` available22- Gmail OAuth credentials already set up through `gog`23- in headless environments, `GOG_KEYRING_PASSWORD` must be available or stored at the default `gog` keyring password path2425## Read-only first2627Use plain `gog` when you only need quick search results.2829```bash30gog gmail search 'newer_than:7d' --max 1031gog gmail messages search 'in:inbox from:[email protected]' --max 2032```3334Use the bundled helper when you need stricter local filters, previews, exportable JSON, or guarded archive actions.3536## Bundled helper3738Run from this skill directory:3940```bash41python3 scripts/gmail_mail_tool.py --help42```4344### Common preview flows4546Preview GitHub notifications older than 14 days:4748```bash49python3 scripts/gmail_mail_tool.py \50--account [email protected] \51--from-email [email protected] \52--older-than-days 1453```5455Preview newsletters by subject text and keep only inbox mail missing a label:5657```bash58python3 scripts/gmail_mail_tool.py \59--account [email protected] \60--subject-contains newsletter \61--missing-label IMPORTANT62```6364Preview with a Gmail query plus local sender filtering, then save JSON:6566```bash67python3 scripts/gmail_mail_tool.py \68--account [email protected] \69--query 'category:promotions newer_than:30d' \70--from-contains digest \71--out ./preview.json72```7374### Apply archive after preview7576Only archive after checking the preview summary first.7778```bash79python3 scripts/gmail_mail_tool.py \80--account [email protected] \81--from-email [email protected] \82--older-than-days 30 \83--max-apply-messages 100 \84--apply85```8687Archive from all mail only when you truly mean it:8889```bash90python3 scripts/gmail_mail_tool.py \91--account [email protected] \92--all-mail \93--query 'label:newsletters older_than:90d' \94--has-label INBOX \95--apply96```9798## Safety rules99100- default mode is preview only101- `--apply` removes the `INBOX` label from selected messages; it does not delete mail102- the helper refuses empty-filter runs unless you explicitly pass `--allow-empty-filter`103- the helper refuses oversized apply runs unless you raise the caps or pass `--force-unsafe-apply`104- for risky cleanups, save the preview JSON before applying changes105106## Useful flags107108- `--query` for Gmail-native filtering109- `--from-email`, `--from-contains`, `--subject-contains`, `--snippet-contains` for local filtering110- `--has-label` and `--missing-label` for label-aware cleanup111- `--older-than-days` / `--newer-than-days` for age windows112- `--sample-limit` to control preview size113- `--out` to persist the JSON summary114115## Environment overrides116117The helper supports these optional environment variables:118119- `GMAIL_TOOL_ACCOUNT`120- `GOG_ACCOUNT`121- `GMAIL_TOOL_GOG_CREDENTIALS`122- `GMAIL_TOOL_GOG_KEYRING_PASSWORD_FILE`123- `GMAIL_TOOL_LOG_FILE`124- `GOG_KEYRING_PASSWORD`125126## Recommended agent behavior1271281. Start with read-only search or preview.1292. Inspect sender, subject, date, labels, and sample output.1303. Apply only after the preview matches the intended cleanup scope.1314. For large mailboxes, narrow the query first instead of forcing a huge apply.132