Install
openclaw skills install @kisssam6886/gmail-filter-architectDesign, verify and import a complete Gmail filter system: a small emoji label taxonomy, urgent mail starred, bills/finance/infra/codes labelled, marketing and social auto-archived, forwarded accounts tagged by source. Built from a 90-day sender census of your own mailbox, every rule is checked against your real mail for misfires before import, and every archiving rule carries a shared protection group so bills, codes and security alerts are never hidden. Use for: cleaning up Gmail filters, bills landing in promotions, important mail getting archived, 'set up the best Gmail filters', labelling mail forwarded from other accounts. 中文:整理 Gmail 过滤器、账单被当营销收走、重要邮件看不到、转发来的邮件标记来源账号、要一套最好的过滤规则。
openclaw skills install @kisssam6886/gmail-filter-architectGoal: nothing important is missed, noise is archived automatically, and every message shows at a glance what it is and which account it came from.
The generator is scripts/build_filters.py. Your personal settings live in profiles/<you>.json (start from profiles/TEMPLATE.json, or profiles/example.zh-CN.json for Chinese labels and keywords). Never commit a real profile to a public repo.
protect). Gmail has no "move back to inbox" action and there is no "stop processing"; every matching filter runs. If any one filter archives a message, nothing can bring it back. The protection group excludes subjects about codes, security, login, passwords, bills, receipts, invoices, statements, overdue, renewal, suspension, abuse, tickets, "action required", plus critical senders (Apple, cloud providers, account security).subject:. Gmail matches Chinese/Japanese/Korean as substrings, so a body match on 优惠 ("discount") also hits bank mail about 优惠利率 ("preferential rate"). In the first real run, body keyword filters had silently archived 85 transactional mails (hosting bills, credit card overdue notices, broker agreement updates, anti-fraud notices).unsubscribe to detect marketing. Bank payment reminders, broker login alerts, receipts and GitHub notifications all have it in the footer. Use category:promotions / category:social (the plural form works in search; the singular returned 0) plus a known marketing sender list.is:, label:, in: or dates in filters. New mail has none of those states, so they never match.With the Gmail connector (search_threads, metadata view, page size 50):
newer_than:90d (archived mail included). Group by sender address/domain: thread count, whether most sit in the inbox, one or two example subjects.from:{...} groups and subject keyword groups.Fill profiles/<you>.json: labels, protect, urgent, bill, infra, apple, fin (txn / mkt / exclude_compact / archive_rules), otp, biz, mkt (brand groups, social, cold, subject keywords), extra_rules (e.g. deliveredto: rules for forwarded accounts).
python3 scripts/build_filters.py profiles/<you>.json out/ --gmailctl
Outputs batchA.xml (label only), batchB.xml (star / archive), tests.json (one search query per filter) and, with --gmailctl, gmailctl.jsonnet. The script checks length and bracket balance.
Recommended labels (about ten; the emoji prefix makes them easy to spot and sorts them first):
| Label | Actions | Inbox? |
|---|---|---|
| ⚠️ Action | star + important + never spam | yes (new mail only) |
| 💳 Bills / 🍎 Apple / 📈 Finance / 🔐 Codes / 🛠 Infra / 🏢 Business | label + never spam | yes |
| Marketing / Marketing/Social / Marketing/Cold | archive + mark read + never important | no |
| From/ | label only (deliveredto:account@gmail.com) | yes |
High-volume routine infra and finance mail (DNS change confirmations, Search Console reports, GitHub CI, daily broker statements) gets its own "label + archive" rule, still with the protection group. For infra senders use a subject whitelist (archive only the routine subjects). Archiving a whole infra sender also swallowed its login codes, "zone deleted" alerts and nameserver warnings in the first run.
Run each query in tests.json as (<query>) newer_than:90d and read the first 30 subjects:
in:inbox newer_than:21d for marketing senders that no rule catches, and for important mail that no label covers.Pick one:
gmailctl.jsonnet into your config, gmailctl diff, then gmailctl apply. gmailctl only affects new mail.Batch A: tick "Also apply filter to matching conversations" (it only adds labels, so old mail gets categorised). Batch B: do not tick it (old mail would be starred or archived en masse).
Create labels first if you can (Gmail connector create_label, with colours). Renaming an existing label is safe: filters reference labels by ID.
Three import pitfalls seen in practice:
Import only adds; it never modifies existing filters. Save the old filters' text as a backup, then select the superseded ones by their criteria text (see pitfalls above) and bulk-delete.
label_thread with INBOX).The old filters' text is in the backup; new filters can be selected by label and deleted. Archived mail is still under its label; add INBOX back with label_thread.
references/research-2026-09.zh-CN.md: survey of widely recommended Gmail filter practice with sources (in Chinese).