Pgowda2/gmail-smart-cleaner
Project Overview
Gmail Smart Cleaner
Flask web app that auto-trashes old Gmail emails and saves important ones to Calendar or Tasks using Claude AI.
True Intent (AI Assessment)
A personal, locally-hosted Gmail automation tool that deletes stale mail while rescuing meetings, events, and job communications into Google Calendar and Tasks.
README Accuracy
Notes
Behavior matches the README. Minor concerns: the hardcoded Claude model name 'claude-sonnet-4-6' appears invalid and may cause the AI classifier to fail silently; Flask debug mode is enabled; pickle-based token storage is fragile but standard for Google API quickstarts. No signs of malicious intent or data exfiltration beyond the disclosed Anthropic call.
This is a locally-run Python Flask application that connects to a user's Google account via OAuth2 and automates inbox maintenance. It scans Gmail for emails older than a configurable threshold (default 15 days), classifies each one as a meeting, event, job-related, or unimportant, and takes action accordingly — creating Google Calendar events for meetings/events, Google Tasks entries for job-related emails, and moving everything else to Trash. It also permanently purges the Spam folder on every run and protects starred emails from deletion.
The problem it addresses is inbox overload. Manually triaging months of accumulated newsletters, promotions, and receipts while trying not to lose important interview invitations, meeting confirmations, or event registrations is tedious. This tool automates that triage using either simple keyword matching or Anthropic's Claude API for smarter classification, and rescues the important items into the appropriate Google productivity surface (Calendar or Tasks) before deleting the rest.
The intended user is an individual Gmail power-user comfortable with running a local Python server, creating a Google Cloud OAuth client, and optionally supplying an Anthropic API key. It is a single-user, self-hosted utility — not a multi-tenant service. Users interact through a dark-themed browser dashboard at localhost:5000, where they set the day threshold, click Run, and view stat cards showing counts of scanned, deleted, calendar-added, and task-added emails.
Architecturally, the code is cleanly modularized: auth.py handles OAuth2 with pickled token caching; gmail_client.py, calendar_client.py, and tasks_client.py wrap the three Google APIs; classifier.py implements a two-tier classification pipeline (keyword match first, Claude API fallback); cleaner.py orchestrates the pipeline; and app.py exposes a small REST-style API (/api/run, /api/tasks, /api/stats, /api/auth) consumed by vanilla JS in static/app.js. Configuration and keyword lists live in config.py.
Notable observations: the Claude model string 'claude-sonnet-4-6' looks non-standard and may not resolve against Anthropic's real model catalog, potentially breaking the AI path silently and falling back to keywords. The app runs with Flask debug=True which is unsafe for anything beyond local use. OAuth tokens are stored as pickle files (a known deserialization risk if the file is ever tampered with). Privacy claims are reasonable: only subject plus first 800 chars are sent to Anthropic when AI is enabled, and credentials.json/token.pickle are gitignored.
| Languages | Python, JavaScript, HTML, CSS |
| Runtime | Python 3.10+ (uses PEP 604 union syntax) |
| Framework | Flask 3.0+ |
| Database | None (in-memory stats, pickle file for OAuth token) |
| Package Manager | pip |
| Key Dependencies | flask, google-api-python-client, google-auth-oauthlib, anthropic, python-dateutil |
| Build Tool | None |
| Test Framework | None detected |