I am awful with email. I have been for years.

I joke with customers that my inbox doesn’t carry an SLA. That’s true. But it’s not just because email is a flawed protocol. It’s primarily because my work inbox had roughly 30,000 unread emails. My personal inbox was over 60,000.

I was never an “Inbox Zero” advocate. Just the opposite. I was an “Inbox Infinity” practitioner. But recently, the new Google Workspace extension for Gemini gave me the kick I needed to remedy the situation.

Here is the story of my “Email Bankruptcy,” the technical trick that deleted them all, and the AI I built to stop it from happening again.

Step 1: Declaring Email Bankruptcy

I had to mentally let go.

I was once on a team where everyone emptied their calendars at the start of the year, declaring “Calendar Bankruptcy.” The logic was simple: If the meeting was actually important, you would get re-invited. If not, it was never meant to be.

I realized I had to do the same thing with my inbox.

If a message from 2018 was critical to my life or career, I would have dealt with it way before Thanksgiving 2025. Was I maybe going to delete something I would someday need? Maybe. But I also have that pile of wood in my workshop that I “might need one day.”

Spoiler: I won’t need it.

Step 2: The Purge (How to Bulk Delete 60k Emails)

Deleting 60,000 emails is harder than it sounds. Gmail says it will do it, but the UI often chokes on that volume. So, I asked the Gemini CLI to help me figure out a programmatic way to handle the nuclear option.

It gave me two solutions. One was good. The second one was magic.

Attempt 1: The Google Apps Script

First, Gemini wrote me a small Apps Script to batch delete messages 100 at a time.

function batchDeleteEmails() {
     // CONFIGURATION
     var SEARCH_QUERY = "label:inbox older_than:1y -is:starred"; 
     var BATCH_SIZE = 99; // 100 is a safe batch size

     var threads = GmailApp.search(SEARCH_QUERY, 0, BATCH_SIZE);
     var startTime = new Date().getTime();

     console.log("Found " + threads.length + " threads to process.");

     while (threads.length > 0) {
       // Delete the current batch
       GmailApp.moveThreadsToTrash(threads);

       // Check execution time (stop if running > 4.5 minutes to be safe)
       if (new Date().getTime() - startTime > 270000) {
         console.log("Time limit approaching. Scheduling next run...");
         ScriptApp.newTrigger("batchDeleteEmails")
                  .timeBased()
                  .after(1 * 60 * 1000) // Run again in 1 minute
                  .create();
         return;
       }

       // Fetch next batch
       threads = GmailApp.search(SEARCH_QUERY, 0, BATCH_SIZE);
     }

     // Cleanup: If no threads left, remove all triggers
     var triggers = ScriptApp.getProjectTriggers();
     for (var i = 0; i < triggers.length; i++) {
       ScriptApp.deleteTrigger(triggers[i]);
     }
     console.log("Done! No more emails matched the query.");
   }

It worked… for a while. It deleted about ~1000 emails per minute. Awesome! I set it up on a trigger to run every 5 minutes (“set it and forget it”). The number kept going down, and I felt great. Until it stopped.

It turns out the free tier of Apps Script is capped at around 20,000 calls per day. I had successfully deleted 20,000 old emails—W00t!—but I was still stuck with a mountain of 40,000 messages.

Attempt 2: The “Server-Side Filter” Hack

Then, Gemini gave me the best Gmail tip I have seen in a decade.

You can create a Filter using the same search terms I used in my script (older_than:1y, category:promotions, etc.). But instead of just applying a label, you check the box that says “Delete it” and—this is the key—“Also apply filter to matching conversations.”

When you do this, you aren’t asking your browser to delete them. You aren’t asking a script to delete them. You are telling Google’s backend servers to execute a mass purge logic on your data.

I hit “Create Filter.”

I actually broke my “Borg container” once (Google’s internal cluster management system). The operation was so massive that I got a server error for a few minutes. But when I refreshed?

60,000 emails became 200.

I was stunned. It took a couple of hours for the metadata to catch up, but the emails were gone.

Step 3: The Maintenance (Keeping It Clean)

Cleaning the inbox once is easy. Keeping it clean is the hard part.

I built a suite of inbox:* commands into my personal-intelligence extension to handle the daily maintenance for me. Instead of “checking email,” I just run commands.

  • /inbox:analyze: This is my strategist. It scans my last 100-200 messages, groups them by sender and pattern, and suggests new labels or unsubscribe opportunities. It tells me why my inbox is getting messy.
  • /inbox:cleanup: The housekeeper. It instantly finds anything older than 30 days that isn’t starred and moves it to trash. No mercy.
  • /inbox:zero: The heavy lifter. This command goes through my unread/unlabeled inbox messages and applies triage logic:
    • Actionable? (Requests, bills, alerts): It creates a task in my “TODO” list with a link to the email, stars the email, and archives it.
    • Informational? (Newsletters, receipts): It applies a label (@Finance, @Newsletters) and archives it.
    • Done. It marks processed items as read.
  • /inbox:mark-as-read: The “I Give Up” button. It finds everything that is archived but still marked “unread” and clears the notification. This keeps my badge count accurate to what actually matters.

Step 4: The Briefing (My AI Chief of Staff)

Finally, I needed a way to know what’s important without staring at a list.

I run a command: /briefing.

  1. Calendar Context: It scans my calendar for the next 24 hours.
  2. Intelligent Triage: It hunts for emails specifically from the people I’m meeting with today.
  3. Family Integration: It connects to Cozi to pull in our family “To-Do” and “Shopping” lists, so I don’t forget to buy milk while I’m thinking about Kubernetes.
  4. The Report: It generates a synthesized Markdown report with my agenda, critical emails, and family tasks.

Now I have a system that cleans itself, organizes my tasks, and tells me what’s important.

I still don’t have an SLA on my email. But at least now, when I ignore you, it’s on purpose.