googleworkspace avatar

Gws Gmail Watch

Streams incoming Gmail messages as NDJSON using Google Cloud Pub/Sub, which is useful for building email automation workflows or monitoring specific inboxes. Sets up the necessary Pub/Sub topic and subscription automatically, handles Gmail's push notifications, and lets you filter by label IDs like INBOX or UNREAD. The watch expires after 7 days so you'll need to re-run it periodically. Works well for feeding email data into scripts or dashboards, though you'll need a GCP project with billing enabled since it creates Pub/Sub resources.

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

Install

$ npx -y skills add googleworkspace/cli --skill gws-gmail-watch --agent claude-code

Installs into .claude/skills of the current project.

Files

gmail +watch

PREREQUISITE: Read ../gws-shared/SKILL.md for auth, global flags, and security rules. If missing, run gws generate-skills to create it.

Watch for new emails and stream them as NDJSON

Usage

gws gmail +watch

Flags

FlagRequiredDefaultDescription
--project——GCP project ID for Pub/Sub resources
--subscription——Existing Pub/Sub subscription name (skip setup)
--topic——Existing Pub/Sub topic with Gmail push permission already granted
--label-ids——Comma-separated Gmail label IDs to filter (e.g., INBOX,UNREAD)
--max-messages—10Max messages per pull batch
--poll-interval—5Seconds between pulls
--msg-format—fullGmail message format: full, metadata, minimal, raw
--once——Pull once and exit
--cleanup——Delete created Pub/Sub resources on exit
--output-dir——Write each message to a separate JSON file in this directory

Examples

Sponsors

Details

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

More from googleworkspace/cli

All 113
1googleworkspace avatargws-gmail-replygoogleworkspace/cliGmail: Reply to a message (handles threading automatically).36Kskills.sh installs
2googleworkspace avatargws-gmail-forwardgoogleworkspace/cliGmail: Forward a message to new recipients.34.5Kskills.sh installs
3googleworkspace avatargws-workflowgoogleworkspace/cliGoogle Workflow: Cross-service productivity workflows.34.3Kskills.sh installs
4googleworkspace avatargws-chatgoogleworkspace/cliGoogle Chat: Manage Chat spaces and messages.33.9Kskills.sh installs
5googleworkspace avatargws-peoplegoogleworkspace/cliGoogle People: Manage contacts and profiles.33.8Kskills.sh installs
6googleworkspace avatargws-gmail-reply-allgoogleworkspace/cliGmail: Reply-all to a message (handles threading automatically).33.8Kskills.sh installs