How to auto-delete spam emails in Gmail with Claude AI

Set up a Gmail filter that deletes unwanted mail automatically, using Claude to write the search query for you. It suits anyone who gets a steady flow of junk mail and wants a cleaner inbox. You only need a Gmail account, a browser and a Claude chat.

YouTube video: How to Automatically Delete Spam Emails in Gmail with Claude AI (2026 Tutorial)

Caption availability is unknown. Check the CC control in the YouTube player.

Video length
2 min 26 s
Time to do it
15 minutes
Difficulty
Easy
Steps
6

What you need

Steps

  1. Open Gmail in a browser, click the gear icon and choose See all settings. Open the Filters and Blocked Addresses tab and remove any old rules that already target spam.

  2. Open a Claude chat and describe the junk you get, such as sender domains, subject words and phrases. Ask it to write one Gmail search query using from:, subject: and OR.

  3. Paste that query into the Gmail search bar and press Enter. Add or remove terms until only unwanted messages appear, then copy the final query.

  4. Go back to Filters and Blocked Addresses and click Create a new filter. Paste the query into the Has the words box and click Create filter.

  5. Tick Delete it. Tick Apply to matching conversations too if you want existing spam cleared, then click Create filter to save the rule.

  6. For scheduled clean-up, ask Claude for a Google Apps Script version, paste it into script.google.com and add a daily time-driven trigger.

Tips and common mistakes

Never build a filter on one vague word like sale or unsubscribe, since it will catch real mail.

Gmail keeps deleted messages in Trash for 30 days, so check Trash weekly for the first month.

Report missed spam with the Report spam button so Gmail learns the pattern alongside your filter.

Questions

Will this delete real emails by mistake?

It can if the query is too broad. Test the search in the Gmail bar first and keep the rule narrow, using sender domains and paired words.

Does Claude need access to my Gmail?

No. You only use it to write the search query or script, then paste that into Gmail yourself.

How do I undo the filter later?

Open Settings, go to Filters and Blocked Addresses and click delete next to the rule. Messages already removed stay in Trash for 30 days.

The notes are drafted automatically from video details and general task knowledge. How the guide was prepared

Report a correction

More in Apps & Software

See all