Skip to content

Label and Archive Gmail

Label matching Gmail messages and archive them out of your inbox using the gws CLI.

Stars
32,059
Licence
Apache-2.0
Files
1 file

What it does

This skill teaches an AI agent a short recipe for tidying Gmail. It searches your mailbox for messages matching a query (for example, mail from one sender), adds a chosen label to them, and removes the INBOX label so they leave your inbox while staying in your account. It works by issuing commands through the Google Workspace command-line tool 'gws', and it depends on the companion gws-gmail skill for the underlying Gmail details.

Great for

  • People whose inbox fills up with automated notifications or newsletters they want sorted automatically
  • Users who already have the gws CLI installed and authenticated with their Google account
  • Anyone comfortable reviewing search queries before bulk changes are made to their mail

Skip it if

  • Permanently deleting or trashing email: the recipe only relabels and archives, but a broad query could move many messages out of view, so check matches first
  • Non-Gmail accounts or people without the gws tool set up, since the recipe cannot run without it

Try asking

  • “Label all emails from notifications@service.com as 'Alerts' and archive them”
  • “Archive every message from my bank's statement sender so they skip my inbox”
  • “Find emails matching a search query and move them under a new label”
Step-by-step guide: how to use Label and Archive GmailInstall, first run, examples, tips and FAQs

Install in 3 steps

  1. 1

    Download the skill

    The ZIP contains the 1 original files, the Apache-2.0 licence and an attribution note.

    recipe-label-and-archive-emails.zip
  2. 2

    Add it to your agent

    Claude Code (all projects)

    mkdir -p ~/.claude/skills && unzip recipe-label-and-archive-emails.zip -d ~/.claude/skills/

    Claude Code / Agent SDK (this project only)

    mkdir -p .claude/skills && unzip recipe-label-and-archive-emails.zip -d .claude/skills/

    Claude apps (web/desktop): Settings → Capabilities → Skills → Upload skill, and choose the ZIP.

  3. 3

    Ask for the task

    No special command needed — the agent reads the skill's description and loads it when your request matches. Try one of the prompts above.

Get better results

  • Run the search step first and review the results table before applying labels or archiving in bulk
  • Make your search query narrow (sender plus subject, for example) so only the intended messages are changed
  • Create the target label in Gmail beforehand and note its label ID so the modify command uses the correct value

What's inside

  • SKILL.md

Redistributed unmodified from googleworkspace/cli under the Apache-2.0 licence. The assessment was drafted with AI from the skill's files on 2026-10-29. Skills can instruct your agent to run code — read SKILL.md and any scripts before installing.