gws-gmail-watch — Claude Code skill: Gmail and setup
Watches Gmail for new emails and streams events as NDJSON. Use it when an agent needs incoming mail as a live input.
npx skills add googleworkspace/cli --skill gws-gmail-watch -a claude-codeWhat gws-gmail-watch does
gws-gmail-watch runs gws gmail +watch and watches for new Gmail messages. Events are streamed as NDJSON, with filtering by Gmail label IDs such as INBOX or UNREAD. Each message can use the full, metadata, minimal, or raw format.
The skill can create Pub/Sub resources from a GCP project or use an existing subscription and topic. --once pulls one batch and exits, while --output-dir writes each message to its own JSON file. The default batch limit is 10 messages, and the default pull interval is 5 seconds.
You need gws, authentication, and the rules from gws-shared. Gmail watch expires after 7 days, so run it again to renew the watch. Install this skill when an agent needs a stream of new email; use gws-gmail commands for one-off mailbox operations.
What it helps with
- watch for new Gmail messages
- filter incoming mail by Gmail label IDs
- stream email events as NDJSON
- write each message to a separate JSON file
- pull one batch and exit
Example prompts for the agent
- Run `gws gmail +watch --project my-gcp-project` and pass new email events to the agent as NDJSON.
- Watch only inbox messages with `gws gmail +watch --project my-project --label-ids INBOX --once`.
- Run `gws gmail +watch --project my-project --cleanup --output-dir ./emails` and save messages in `./emails`.
How to install gws-gmail-watch
1Skills CLI (Vercel)
npx skills add googleworkspace/cli --skill gws-gmail-watch -a claude-code2Manually: put the files in place
~/.claude/skills/gws-gmail-watch/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/gws-gmail-watch/
1Skills CLI (Vercel)
npx skills add googleworkspace/cli --skill gws-gmail-watch -a codex2Manually: put the files in place
.agents/skills/gws-gmail-watch/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add googleworkspace/cli --skill gws-gmail-watch -a cursor2Manually: put the files in place
.cursor/skills/gws-gmail-watch/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install googleworkspace/cli gws-gmail-watch2Manually: put the files in place
.github/skills/gws-gmail-watch/SKILL.md1Skills CLI (Vercel)
npx skills add googleworkspace/cli --skill gws-gmail-watch -a gemini-cli2Platform CLI
gemini skills install https://github.com/googleworkspace/cli --path skills/gws-gmail-watchManually: put the files in place
.devin/skills/gws-gmail-watch/SKILL.mdThe legacy .windsurf/skills/ path still works
Skills CLI (Vercel)
npx skills add googleworkspace/cli --skill gws-gmail-watch -a opencodeClaude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
From the same set95
The whole set →Similar
Questions about gws-gmail-watch
How do I install gws-gmail-watch in Claude Code?
Run npx skills add googleworkspace/cli --skill gws-gmail-watch -a claude-code. The skill file is placed at ~/.claude/skills/gws-gmail-watch/SKILL.md.
What does gws-gmail-watch do?
It watches Gmail for new messages and streams them as NDJSON. It also supports label filtering, one-time pulls, and writing messages to JSON files.
What does gws-gmail-watch need to run?
You need gws, authentication, and the rules from gws-shared. Resource setup uses a GCP project, Pub/Sub subscription, or topic; existing resources can be passed with the matching flags.
Source text
SKILL.md · Apache-2.0
---
name: gws-gmail-watch
description: "Gmail: Watch for new emails and stream them as NDJSON."
metadata:
version: 0.22.5
openclaw:
category: "productivity"
requires:
bins:
- gws
cliHelp: "gws gmail +watch --help"
---
# 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
```bash
gws gmail +watch
```
## Flags
| Flag | Required | Default | Description |
|------|----------|---------|-------------|
| `--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` | — | 10 | Max messages per pull batch |
| `--poll-interval` | — | 5 | Seconds between pulls |
| `--msg-format` | — | full | Gmail 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
```bash
gws gmail +watch --project my-gcp-project
gws gmail +watch --project my-project --label-ids INBOX --once
gws gmail +watch --subscription projects/p/subscriptions/my-sub
gws gmail +watch --project my-project --cleanup --output-dir ./emails
```
## Tips
- Gmail watch expires after 7 days — re-run to renew.
- Without --cleanup, Pub/Sub resources persist for reconnection.
- Press Ctrl-C to stop gracefully.
## See Also
- [gws-shared](../gws-shared/SKILL.md) — Global flags and auth
- [gws-gmail](../gws-gmail/SKILL.md) — All send, read, and manage email commands
© googleworkspace · Apache-2.0 · googleworkspace/cli