gmail-extract-archive
DEPRECATED — superseded by gmail-extract-and-act. Extract Gmail data into archive repo, parse attachments, legal scan, then delete. Uses archive-everything model.
Best use case
gmail-extract-archive is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
DEPRECATED — superseded by gmail-extract-and-act. Extract Gmail data into archive repo, parse attachments, legal scan, then delete. Uses archive-everything model.
Teams using gmail-extract-archive should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/gmail-extract-archive/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How gmail-extract-archive Compares
| Feature / Agent | gmail-extract-archive | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
DEPRECATED — superseded by gmail-extract-and-act. Extract Gmail data into archive repo, parse attachments, legal scan, then delete. Uses archive-everything model.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# Gmail Extract & Archive Pipeline
Extract Gmail messages into `~/gmail-archive/` — a dedicated private repo as the single source of truth for all email data. Every message → markdown. Every attachment → saved. Every spreadsheet → parsed to CSV. Legal scan mandatory. Delete from inbox after successful archive.
## Prerequisites
- gmail-multi-account skill configured (3 accounts with OAuth tokens)
- `~/gmail-archive/` repo exists (created via `gh repo create vamseeachanta/gmail-archive --private`)
- openpyxl installed in repo: `uv pip install openpyxl pyyaml`
- Deny-list copied: `config/deny-list.yaml` from workspace-hub
## Repo Structure
```
gmail-archive/
├── README.md # Archive conventions
├── config/
│ ├── accounts.yaml # Account definitions (tokens external)
│ └── deny-list.yaml # Legal scan patterns
├── data/
│ ├── {account}/
│ │ ├── messages/ # Individual .md extracts per message
│ │ ├── threads/ # Full thread .md extracts
│ │ ├── attachments/ # Downloaded files organized by thread
│ │ └── spreadsheets/ # Parsed JSON + CSV for each Excel
├── reports/
│ ├── digest/ # Daily digest outputs
│ └── cleanup/ # Cleanup tracking logs
└── scripts/
└── extract.py # Main extraction pipeline
```
## Extraction Commands
### Basic extraction (scan + preview)
```bash
cd ~/gmail-archive
uv run scripts/extract.py --account ace --query "from:sandsig.com in:inbox" --max 500 --dry-run
```
### Extract + save (no delete)
```bash
uv run scripts/extract.py --account ace --query "from:sandsig.com in:inbox" --max 500
```
### Extract + delete from Gmail
```bash
uv run scripts/extract.py --account ace --query "from:sandsig.com in:inbox" --max 500 --delete
```
### Extract full threads
```bash
uv run scripts/extract.py --account skestates --query "subject:1099 has:attachment" --threads --delete
```
### Force through legal violations
```bash
uv run scripts/extract.py --account personal --query "category:promotions" --max 1000 --delete --force
```
## Common Queries
| Purpose | Query |
|---------|-------|
| All inbox | `in:inbox -in:trash` |
| From specific domain | `from:sandsig.com` |
| With attachments | `has:attachment` |
| Specific thread | `subject:"2025 Form 1099-MISC"` |
| Old unread | `is:unread older_than:30d` |
| Spam-like | `subject:(unsubscribe OR no-reply)` |
## Key Learnings / Pitfalls
### 1. Headless OAuth limitation
The `gmail-mcp-multiauth` npm package requires a GUI browser for OAuth flow. On headless servers:
- Generate auth URL manually: `accounts.google.com/o/oauth2/v2/auth?access_type=offline&scope=https://www.googleapis.com/auth/gmail.modify+https://www.googleapis.com/auth/gmail.settings.basic&response_type=code&client_id={client_id}&redirect_uri=urn:ietf:wg:oauth:2.0:oob`
- Sign in via browser on another machine
- Extract authorization code from the page
- Exchange code for tokens via `https://oauth2.googleapis.com/token`
- Save tokens as `~/.gmail-{account}/credentials.json`
### 2. Token refresh
OAuth access tokens expire in 1 hour. Always refresh at runtime using the refresh_token in credentials.json:
```python
data = urllib.parse.urlencode({
"client_id": ..., "client_secret": ...,
"refresh_token": saved["refresh_token"], "grant_type": "refresh_token",
})
```
### 3. Legal scan is mandatory
Run against `config/deny-list.yaml` before every commit. Skip (don't archive) messages that match "block" patterns. Use `--force` only for known safe data.
### 4. Spreadsheet parsing
Gmail API returns attachments as base64. For spreadsheets:
1. Save the raw .xlsx to `spreadsheets/`
2. Parse with openpyxl: `wb = openpyxl.load_workbook(xlsx_path, data_only=True)`
3. Export each sheet to CSV: `ws.iter_rows(values_only=True)`
4. Also save full data as JSON for analysis
### 5. Category queries return 0
Gmail API `category:promotions` and similar queries may return 0 results via REST API even though the Gmail UI shows results. Use domain-based or sender-based queries instead: `from:collide.io OR from:promote.weebly.com OR from:e.swimoutlet.com`
### 6. Self-forwards are smaller than expected
The "personal→ace shuttle" pattern was estimated at 2,000-3,000 emails from sent-folder analysis. Actual count was only ~183. Most "shuttle" entries were brief notes ("FYI", "Print") without attachments, or were external emails received in the personal inbox, not actual file transfers.
## Account-Specific Patterns
### ace (vamsee.achanta@aceengineer.com)
- Sands IG CRE listings: `from:sandsig.com` → extract, parse property data, then delete
- Keep: github.com, openrouter.ai, substack.com (review), deeplearning.ai
- Delete: collide.io, promowebly.com, email.theparkingspot.com, etc.
### personal (achantav@gmail.com)
- Keep: parentsquare.com (school), github.com, em1.turbotax.intuit.com (tax)
- Delete: promote.weebly.com, e.swimoutlet.com, mail.urbanairparks.com, lists.wikimedia.org, etc.
- Review: rigzonemail.com, info.marineinsight.com, m.learn.coursera.org
### skestates (skestatesinc@gmail.com)
- Almost all emails are actionable business correspondence
- Sands IG CRE listings forwarded: extract, then delete
- Thread archive critical for tax/legal reference
## Data Flow After Extraction
Extracted data feeds into:
- `sabithaandkrishnaestates/docs/tax/` — tax documents, payment analyses
- `aceengineer-admin/admin/contacts/` — contact databases
- `assethold/data/` — CRE market intelligence
- `achantas-data/` — personal/family docsRelated Skills
llm-wiki-source-extraction-coverage
Doc-type-aware extraction contract for llm-wiki source ingestion with measurable coverage and source-anchored traceability. Use when (1) ingesting a PDF, DOCX, XLSX, PPTX, HTML, or scanned-image source into a wiki `sources/` page, (2) computing the pre-extraction estimate (what fraction of the source we expect to recover) and post-extraction yield (what fraction we actually recovered), (3) anchoring wiki claims back to specific page / paragraph / cell / slide positions in the source so a reviewer can re-verify or revise against the actual document, (4) deciding whether OCR fallback or manual transcription is needed. Codifies workspace-hub's existing OCR fallback chain and python-docx / openpyxl / trafilatura patterns into a format-specific routing table. Companion to research/llm-wiki-page-shape-contract (Rule 7 input-layer pages) and research/llm-wiki — this skill is the defense against silent extraction failure.
sodir-data-extractor
Extract and process Norwegian Petroleum Directorate field and production data from SODIR
bsee-data-extractor
Extract and process BSEE (Bureau of Safety and Environmental Enforcement) data including production, WAR (Well Activity Reports), and APD (Application for Permit to Drill) data. Use for querying production data, well activities, drilling permits, completions, and workovers by API number, block, lease, or field with automatic data normalization and caching.
portable-baseline-pattern-extraction
Extract and separate portable baseline config from machine-specific overrides in multi-environment projects
extract-skills-from-hermes-sessions
Automatically analyze Codex session transcripts to identify and extract reusable skills using LLM analysis via OpenRouter
extract-skills-from-Codex-sessions
Automatically extract reusable skills from Codex session transcripts using LLM analysis and wire them into a Stop hook
extract-and-archive-tax-summary-data
Capture structured tax return summaries as YAML when PDF downloads are blocked or inaccessible
extract-learnings-to-issues
Extract unstructured user reflections and learnings, distill core themes, route insights to existing GitHub issues as contextual comments rather than creating duplicates.
doc-extraction-naval-architecture
Layer 3 domain sub-skill for extracting naval architecture data from SNAME PNA, IMO stability codes, IACS structural rules, and classification society guidelines. Provides detection heuristics for stability constants, resistance equations, hull form coefficients, hydrostatic curves, IMO stability criteria, and structural scantling tables. type: reference
doc-extraction-drilling-riser
Layer 3 domain sub-skill for extracting drilling riser data from API RP 16Q, DNV-RP-C205, and riser analysis reports. Provides detection heuristics for VIV parameters, kill/choke line specs, and BOP stack configurations. type: reference
doc-extraction
Classify and extract structured content from engineering documents using a 3-layer taxonomy: generic content types, engineering patterns, and domain sub-skills. Use when ingesting standards, reports, or technical manuals into structured data for downstream analysis. type: reference
gmail-triage
Daily multi-account Gmail inbox triage — scan unread, classify by urgency, cross-reference contacts, generate actionable digest. Supports ace/personal/skestates accounts.