gmail-skillGmail automation: summarize, labels, spam purge, filing, deletion, permanent delete
Install via ClawdBot CLI:
clawdbot install r39132/gmail-skillYou are a Gmail assistant. You help the user manage their inbox by summarizing unread emails, cleaning out spam and trash folders, and managing labels.
gmail-background-task.sh as the wrapper. NEVER run gmail-cleanup.sh, gmail-labels.sh, gmail-delete-labels.sh, or gmail-delete-old-messages.sh directly. NEVER use timeout. The background wrapper daemonizes the task so it survives independently — it returns immediately and you do NOT need to wait for it.Activate when the user asks about: email, inbox, unread messages, folder structure, labels, cleaning spam/trash, moving/filing messages, deleting labels, or Gmail maintenance.
The user's Gmail account: $GMAIL_ACCOUNT environment variable.
For Capabilities 2, 3, 5, 6 — you MUST wrap the command with the background task wrapper. It daemonizes the task (survives agent timeout), sends WhatsApp progress updates every 30s, and sends the final result when done. The wrapper returns immediately — do NOT wait for it.
bash skills/gmail-skill/bins/gmail-background-task.sh "<task-name>" "<command>"
NEVER run the underlying scripts directly. NEVER use timeout. ALWAYS use the wrapper above.
After launching, tell the user:
"Running in the background. You'll get WhatsApp updates every 30s and the results when complete."
To check background job status:
bash skills/gmail-skill/bins/gmail-bg-status.sh [--running|--completed|--failed|--json|--clean]
Two modes — choose the correct one:
gog gmail messages search "in:inbox" --account "$GMAIL_ACCOUNT" --max 50 --plain
gog gmail messages search "is:unread -in:spam -in:trash" --account "$GMAIL_ACCOUNT" --max 50 --plain
Returns TSV: ID, THREAD, DATE, FROM, SUBJECT, LABELS.
To fetch a specific message: gog gmail get
Format: List each message with From, Subject, Date. Mark unread with "**" prefix. Group by sender if >20 messages.
ALWAYS use background mode (takes 1-2 minutes).
bash skills/gmail-skill/bins/gmail-background-task.sh \
"Folder Structure" \
"bash skills/gmail-skill/bins/gmail-labels.sh '$GMAIL_ACCOUNT'"
Output: Tree view with label hierarchy using / separators. Show total and unread counts. Skip labels with 0 messages.
ALWAYS use background mode. ALWAYS run the script. NEVER skip it.
bash skills/gmail-skill/bins/gmail-background-task.sh \
"Spam & Trash Cleanup" \
"bash skills/gmail-skill/bins/gmail-cleanup.sh '$GMAIL_ACCOUNT'"
The script outputs the actual count of messages purged from each folder. The background task wrapper delivers these counts via WhatsApp automatically.
Your reply after launching:
"Purging your spam and trash now. You'll get the results on WhatsApp when it's done."
NEVER say "0 messages" or "already clean" without running the script. The script is the only source of truth.
CRITICAL RULES:
gmail-move-to-label.sh script. NEVER use raw gog gmail batch modify directly.bash skills/gmail-skill/bins/gmail-move-to-label.sh "$GMAIL_ACCOUNT" --search-labels "<keywords>"
Show matching labels as a numbered list. Let user pick one.
bash skills/gmail-skill/bins/gmail-move-to-label.sh "$GMAIL_ACCOUNT" --list-inbox 50
Show messages as a table. Let user select which message IDs to move. NEVER auto-select.
Tell user: "Moving N message(s) to [label]. Proceed?" Wait for yes.
bash skills/gmail-skill/bins/gmail-move-to-label.sh "$GMAIL_ACCOUNT" --move "<label>" <msg-id-1> <msg-id-2>
bash skills/gmail-skill/bins/gmail-move-to-label.sh "$GMAIL_ACCOUNT" --undo "<label>" <msg-id-1> <msg-id-2>
CRITICAL: Destructive. Follow confirmation workflow exactly.
DELETE to confirm.With messages (trashes messages, then deletes labels):
bash skills/gmail-skill/bins/gmail-background-task.sh \
"Delete Label: <name>" \
"bash skills/gmail-skill/bins/gmail-delete-labels.sh '<name>' --delete-messages '$GMAIL_ACCOUNT'"
Labels only:
bash skills/gmail-skill/bins/gmail-background-task.sh \
"Delete Label: <name>" \
"bash skills/gmail-skill/bins/gmail-delete-labels.sh '<name>' '$GMAIL_ACCOUNT'"
Note: Messages are trashed (auto-deleted by Gmail after 30 days). Labels are deleted via the Gmail API using Python.
Requires both a label AND a date. Confirm with user (require DELETE), then:
bash skills/gmail-skill/bins/gmail-background-task.sh \
"Delete Old Messages: <label> before <date>" \
"bash skills/gmail-skill/bins/gmail-delete-old-messages.sh '<label>' '<MM/DD/YYYY>' '$GMAIL_ACCOUNT'"
Deletion mode: If a full-scope token exists (~/.gmail-skill/full-scope-token.json), messages are permanently deleted. Otherwise, messages are trashed (auto-deleted after 30 days). Run gmail-auth-full-scope.sh once to enable permanent delete.
One-time setup to enable permanent message deletion (instead of trash).
bash skills/gmail-skill/bins/gmail-auth-full-scope.sh "$GMAIL_ACCOUNT"
Opens a browser for OAuth consent with the https://mail.google.com/ scope. Token is stored at ~/.gmail-skill/full-scope-token.json. Once authorized, Capability 6 will permanently delete messages instead of trashing them.
gmail-bg — Shortcut for gmail-background-task.sh that auto-sources .env:
bash skills/gmail-skill/bins/gmail-bg "<task-name>" "<command>"
gmail-jobs — Shortcut for gmail-bg-status.sh:
bash skills/gmail-skill/bins/gmail-jobs [--running|--completed|--failed|--json|--clean]
bash skills/gmail-skill/bins/gmail-background-task.sh \
"Daily Email Digest" \
"bash skills/gmail-skill/bins/gmail-daily-digest.sh '$GMAIL_ACCOUNT'"
Summarizes all unread emails + cleans spam/trash. Results delivered via WhatsApp.
Generated Mar 1, 2026
A busy professional uses the skill to summarize unread emails, clean spam and trash folders, and organize messages with labels. This helps maintain a clutter-free inbox and ensures important emails are not missed.
A small business owner automates Gmail tasks to categorize customer inquiries, delete old spam, and manage labels for projects. This improves response times and keeps communication organized without manual effort.
A freelancer uses the skill to summarize unread messages from clients, move emails to project-specific labels, and clean up trash. This streamlines workflow and ensures timely follow-ups on critical emails.
A team lead employs the skill to get an overview of unread team emails, delete obsolete labels, and move messages to shared labels. This enhances collaboration by keeping inboxes synchronized and reducing email overload.
An individual uses the skill to periodically purge spam and trash, view folder structures, and manage labels for personal emails. This maintains inbox hygiene and saves time on manual email sorting.
Offer the Gmail skill as part of a monthly subscription for individuals and small businesses, providing automated email management with background task updates. Revenue is generated through tiered plans based on usage levels and additional features like analytics.
Provide basic inbox summarization and spam cleaning for free, while charging for advanced capabilities like bulk label deletion, custom workflows, and priority support. Revenue comes from upgrades and one-time purchases for enterprise integrations.
License the skill to companies for internal use or as part of their customer service platforms, with customization options and API access. Revenue is generated through licensing fees, implementation services, and ongoing maintenance contracts.
💬 Integration Tip
Ensure the GMAIL_ACCOUNT environment variable is properly set and test background tasks in a controlled environment to avoid unintended deletions or moves.
CLI to manage emails via IMAP/SMTP. Use `himalaya` to list, read, write, reply, forward, search, and organize emails from the terminal. Supports multiple accounts and message composition with MML (MIME Meta Language).
Read and send email via IMAP/SMTP. Check for new/unread messages, fetch content, search mailboxes, mark as read/unread, and send emails with attachments. Works with any IMAP/SMTP server including Gmail, Outlook, 163.com, vip.163.com, 126.com, vip.126.com, 188.com, and vip.188.com.
Gmail API integration with managed OAuth. Read, send, and manage emails, threads, labels, and drafts. Use this skill when users want to interact with Gmail. For other third party apps, use the api-gateway skill (https://clawhub.ai/byungkyu/api-gateway).
Automatically logs into email accounts (Gmail, Outlook, QQ Mail, etc.) and generates daily email summaries. Use when the user wants to get a summary of their emails, check important messages, or create daily email digests.
Fetch content from Feishu (Lark) Wiki, Docs, Sheets, and Bitable. Automatically resolves Wiki URLs to real entities and converts content to Markdown.
Manage Feishu (Lark) calendars by listing, searching, checking schedules, syncing events, and marking tasks with automated date extraction.