Unofficial filters-first CLI for Gmail. Sign in once in Chrome. Then list, create, and delete message filters.
Built by True Frontier. Not affiliated with Google.
Same pattern as google-keep-cli, google-photos-cli, and google-recorder-cli.
The session stays on your machine, in a local Chrome profile. This tool does not print cookies, and it does not ship a cloud login.
- Python 3.10+
- Google Chrome
pipx install git+https://github.com/truefrontier/google-gmail-cli.gitOr from a checkout:
pipx install .Playwright uses your installed Chrome (channel="chrome"). You do not need playwright install chromium.
gmail login
gmail filters list
gmail filters list --limit 20
gmail filters list --compact | jq
gmail filters list --select id,matches,do_this --csv
gmail filters create --from "alerts@example.com" --skip-inbox
gmail filters create --query "unsubscribe" --mark-as-read
gmail filters delete <filter_id>gmail login opens Chrome. Sign in, wait until Gmail loads, and the window closes. The profile is saved at ~/.gmail-cli/chrome-profile/.
If a command says the session expired, run gmail login again.
After login, the CLI opens Gmail Filters settings (#settings/filters) with your saved Chrome profile and reads the same filter table the web UI shows. Create/delete drive that settings UI (the documented gmail.googleapis.com settings.filters REST calls reject browser cookie auth).
Inspired by CLI Printing Press agent UX:
- Piped stdout auto-uses JSON when
--formatistable(no--jsonneeded) --compactfor high-gravity fields only--select id,matchesto project JSON/CSV fields--csvfor spreadsheet-friendly rows--quiet/-qto suppress status lines- Exit codes:
0ok,2usage,3not found,4auth,5api/runtime
- Unofficial. Google can change the settings UI.
- Create/delete depend on the Filters settings dialogs; prefer
--skip-inbox/--mark-as-readstyle actions. - Do not commit
~/.gmail-cli/(chrome-profile / capture).