googleworkspace avatar

Recipe Label And Archive Emails

This is a Gmail automation recipe that searches for emails matching your criteria, slaps a label on them, and archives them in one go. You'd use this to automatically organize recurring emails like notifications, newsletters, or automated reports without manually sorting through your inbox. It's essentially a poor man's Gmail filter built with command-line tools. The three-step process is straightforward: search with a Gmail query, apply your chosen label, then remove the INBOX label to archive. Works well for bulk cleanup operations or when you need more complex matching logic than Gmail's built-in filters provide.

skills.sh installs
31.1K
GitHub stars
32.2K
last updated
Aug 21, 2026

Install

$ npx -y skills add googleworkspace/cli --skill recipe-label-and-archive-emails --agent claude-code

Installs into .claude/skills of the current project.

Files

Label and Archive Gmail Threads

PREREQUISITE: Load the following skills to execute this recipe: gws-gmail

Apply Gmail labels to matching messages and archive them to keep your inbox clean.

Steps

  1. Search for matching emails: gws gmail users messages list --params '{"userId": "me", "q": "from:notifications@service.com"}' --format table
  2. Apply a label: gws gmail users messages modify --params '{"userId": "me", "id": "MESSAGE_ID"}' --json '{"addLabelIds": ["LABEL_ID"]}'
  3. Archive (remove from inbox): gws gmail users messages modify --params '{"userId": "me", "id": "MESSAGE_ID"}' --json '{"removeLabelIds": ["INBOX"]}'

Sponsors

Details

Repository
github.com/googleworkspace/cli
Categories
CLI & Terminal, Office & Documents

More from googleworkspace/cli

All 113
1googleworkspace avatarrecipe-save-email-to-docgoogleworkspace/cliSave a Gmail message body into a Google Doc for archival or reference.31.1Kskills.sh installs
2googleworkspace avatarpersona-team-leadgoogleworkspace/cliLead a team — run standups, coordinate tasks, and communicate.31Kskills.sh installs
3googleworkspace avatarrecipe-create-task-listgoogleworkspace/cliSet up a new Google Tasks list with initial tasks.30.9Kskills.sh installs
4googleworkspace avatarrecipe-schedule-recurring-eventgoogleworkspace/cliCreate a recurring Google Calendar event with attendees.30.9Kskills.sh installs
5googleworkspace avatarrecipe-review-meet-participantsgoogleworkspace/cliReview who attended a Google Meet conference and for how long.30.8Kskills.sh installs
6googleworkspace avatarrecipe-collect-form-responsesgoogleworkspace/cliRetrieve and review responses from a Google Form.30.8Kskills.sh installs