cl1p.net - The internet clipboard
cl1p.net Discord
Login/Sign Up
cl1p.net/4560
cl1p.net/4560
cl1p.net Discord
Login/Sign Up
This cl1p will be deleted in in 14 hours.
Copy
# Standing Order: Gmail Storage Cleanup ## Program: Gmail Storage Cleanup **Purpose:** Reduce Gmail storage usage safely by reviewing old email in batches, applying labels, and maintaining a durable report. This program must never delete, trash, archive, send, unsubscribe, create filters, or change Gmail settings automatically. **Authority:** The agent may inspect Gmail messages/threads and apply cleanup labels only. The agent may write local report files. The owner will manually review and delete/unsubscribe later. **Trigger:** Manual command or scheduled OpenClaw cron job. **Default batch size:** Process at most 100 messages per run unless the owner explicitly requests a different limit. Never process more than 500 messages in one run. **Default search scope:** ```text older_than:6m -label:oc-cleanup/processed ``` Prefer oldest-first processing by date window. Do not rely on Gmail pagination alone as the durable cursor. The durable checkpoint is the `oc-cleanup/processed` label. --- ## Required Gmail Labels Ensure these labels exist before normal cleanup runs: ```text oc-cleanup/processed oc-cleanup/delete-candidate oc-cleanup/keep oc-cleanup/review oc-cleanup/unsubscribe-candidate oc-cleanup/large-attachment oc-cleanup/bulk-sender oc-cleanup/never-delete ``` A message may have multiple signal labels. However, exactly one final disposition label should be used where possible: ```text oc-cleanup/delete-candidate oc-cleanup/keep oc-cleanup/review ``` If uncertain, choose `oc-cleanup/review`. --- ## Allowed Actions The agent may: - List Gmail labels. - Create missing `oc-cleanup/*` labels. - Search Gmail messages/threads using safe queries. - Read message metadata, sender, date, subject/snippet, size/attachment indicators, and limited body content when needed for classification. - Apply Gmail labels from the approved `oc-cleanup/*` label set. - Append/update local reports and ledgers. - Report concise progress to the owner. --- ## Forbidden Actions The agent must never: - Delete messages. - Batch delete messages. - Trash messages. - Archive messages. - Mark messages read or unread. - Send emails. - Create, update, or send drafts. - Click unsubscribe links. - Use Gmail unsubscribe automatically. - Create, update, or delete Gmail filters. - Change forwarding, delegate, send-as, vacation responder, IMAP/POP, S/MIME, or other Gmail settings. - Remove labels unless the owner explicitly asks for a correction. - Process more than the configured batch size. If using a broad Gmail MCP, only use read/list/get label tools and modify-message/thread label tools. Do not call delete, trash, send, draft, filter, delegate, forwarding, or settings-update tools. --- ## Classification Rules ### Final disposition labels Apply one of: #### `oc-cleanup/delete-candidate` Use for messages that are likely safe for the owner to manually delete later, such as: - Old newsletters. - Marketing/promotional email. - Sale notifications. - Old automated status notifications. - Expired event reminders. - Old shipping/delivery notifications that are no longer useful. - Duplicate or low-value bulk mail. #### `oc-cleanup/keep` Use for messages that should probably be retained, such as: - Personal correspondence. - Family/friends messages. - Legal, tax, finance, insurance, medical, identity, security, or account-access messages. - Purchase receipts for important goods/services. - Warranty/license/subscription/account records. - Work/client/project correspondence. - Anything that appears uniquely important. #### `oc-cleanup/review` Use whenever uncertain, including: - Ambiguous sender or unclear purpose. - Possible account/security/billing relevance. - Messages with unusual attachments. - Messages that might be personal or work-related. - Any classification with low confidence. ### Signal labels Apply all relevant signal labels in addition to the final disposition: #### `oc-cleanup/unsubscribe-candidate` Use when the sender appears to be recurring promotional/newsletter/bulk mail and future messages are probably unwanted. Do not unsubscribe automatically. Only label and include in reports. #### `oc-cleanup/bulk-sender` Use for senders with repeated similar emails. #### `oc-cleanup/large-attachment` Use for messages likely to materially affect storage, especially messages matching or similar to: ```text larger:10M ``` #### `oc-cleanup/never-delete` Use for especially sensitive or important messages that should not be deletion candidates. --- ## Batch Execution Procedure For each cleanup run: 1. Ensure required `oc-cleanup/*` labels exist. 2. Load or create local cleanup state/report files. 3. Select the next date window or search query. 4. Search for messages matching: ```text older_than:6m -label:oc-cleanup/processed ``` or the current date-window equivalent. 5. Fetch at most the configured batch size. 6. Sort fetched messages oldest-first by Gmail/internal date when possible. 7. For each message/thread: - Inspect only what is needed to classify safely. - Choose one final disposition label: delete-candidate, keep, or review. - Add any relevant signal labels. - Always add `oc-cleanup/processed` after classification. - Append one row to the durable ledger. 8. Update cumulative summary files. 9. Send a concise progress report. 10. If no unprocessed messages remain, generate the final report. --- ## Reporting and Persistence Maintain these local files: ```text gmail-cleanup/ledger.jsonl gmail-cleanup/summary.md gmail-cleanup/runs/YYYY-MM-DD-HHMM.json gmail-cleanup/final-report.md ``` ### `ledger.jsonl` Append one JSON object per inspected message/thread. Include: ```json { "timestamp": "ISO timestamp", "messageId": "gmail message id", "threadId": "gmail thread id", "date": "message date", "from": "sender email or domain", "subjectHashOrSnippet": "short snippet or hash, avoid full bodies", "finalDecision": "delete-candidate | keep | review", "signals": ["unsubscribe-candidate", "bulk-sender", "large-attachment"], "reason": "brief reason", "queryOrWindow": "query/date window used" } ``` Avoid storing full email bodies unless explicitly requested. ### Per-run summary Each run should record: - Run timestamp. - Search query/date window. - Batch size requested. - Number processed. - Counts by final disposition. - Counts by signal label. - Oldest/newest message date in the batch. - Any failures or skipped messages. - Estimated remaining unprocessed count if available. ### Chat/Telegram report Keep the chat report brief, for example: ```text Processed 100 messages. 62 delete-candidate, 21 keep, 17 review. Signals: 18 unsubscribe-candidate, 6 large-attachment. Ledger and summary updated. No deletes performed. ``` Do not dump the full ledger into chat. --- ## Final Report When no messages remain matching the unprocessed cleanup query, generate: ```text gmail-cleanup/final-report.md ``` Include: 1. Overall totals. 2. Count by final disposition. 3. Top delete-candidate senders. 4. Top unsubscribe-candidate senders. 5. Large attachment candidates. 6. Review queue summary. 7. Suggested Gmail searches for manual review: ```text label:oc-cleanup/delete-candidate label:oc-cleanup/unsubscribe-candidate label:oc-cleanup/review label:oc-cleanup/large-attachment label:oc-cleanup/never-delete ``` 8. Safety notes and anything the owner should inspect before deleting. --- ## Safety Defaults - If classification confidence is low, label `oc-cleanup/review`. - If a message appears sensitive, label `oc-cleanup/keep` or `oc-cleanup/never-delete`. - Prefer false positives in review/keep over false positives in delete-candidate. - Never perform destructive actions. - Never silently skip errors. Log and report them. - Stop after one batch per run unless the owner explicitly asks to continue. --- ## Example Cron Prompt ```text Execute the Gmail Storage Cleanup standing order. Process one batch only, maximum 100 messages, using the default unprocessed cleanup query. Apply labels only. Never delete, trash, archive, send, unsubscribe, create filters, or change Gmail settings. Update the ledger and summary, then report concise counts. ```