Data Research
Structured research pipeline: search sources, extract structured data,
archive raw, deduplicate, update canonical trackers, backlink entities.
Contract
One skill for any email-to-structured-data pipeline. The only differences
between tracking investor updates, expenses, and company metrics
are the search queries, extraction schemas, and tracker page format.
All three use the same 7-phase pipeline with parameterized recipes.
When to Use
- User wants to track structured data from email, web, or API sources
- User says "research", "track", "extract from email", "build a tracker"
- User mentions investor updates, donations, company metrics, filings
- User wants to set up recurring data collection (with cron recipe)
Phases
Phase 1: Define Research Recipe
Ask the user what they want to track. Either:
- Pick a built-in recipe: investor-updates, expense-tracker, company-updates
- Define a custom recipe with: source queries, classification rules, extraction schema,
tracker page path, tracker format
Recipes are YAML files at ~/.gbrain/recipes/{name}.yaml. Use gbrain research init
to scaffold a new one.
Phase 2: Search Sources
Brain first (maybe we already have this data). Then:
- Email via credential gateway: windowed queries (quarterly, monthly if truncated)
- Web via search: public filings, press releases, regulatory data
- APIs: any structured data source the recipe defines
- Attachments: PDF extraction, HTML stripping
Phase 3: Classify
Deterministic first (regex patterns from recipe), LLM fallback.
Log every LLM fallback for future regex improvement (fail-improve loop).
Skip marketing, newsletters, noise based on recipe's classification rules.
Phase 4: Extract Structured Data
EXTRACTION INTEGRITY RULE:
- Save raw source immediately (before any extraction)
- Extract fields using deterministic regex first, LLM fallback
- When summarizing batch results: re-read from saved files
- Never trust LLM working memory after batch processing
This prevents a known hallucination bug where batch-processed amounts were
13/13 wrong from LLM working memory while saved files were correct.
Phase 5: Archive Raw Sources
put_raw_data for email bodies, API responses
file_upload for PDF attachments, documents
- Create
.redirect.yaml pointers for large files in storage
- Every tracker entry must link back to its raw source
Phase 6: Deduplicate
Before adding to tracker:
- Exact match (same key fields) → skip
- Fuzzy match (same entity + date + similar amount within tolerance) → flag for review
- Different amount for same entity+date → add with note (could be correction)
Phase 7: Update Canonical Tracker + Backlink
- Parse existing tracker page (markdown table)
- Append new entries in correct section (grouped by year/quarter/entity)
- Compute running totals
- Backlink every mentioned entity (person → people/ page, company → companies/ page)
- Uses enrichment service for entity pages
Built-In Recipes
Three example recipes ship with GBrain (see ~/.gbrain/recipes/):
- investor-updates — extract MRR, ARR, growth, burn, runway, headcount from investor update emails
- expense-tracker — extract amounts, recipients, platforms from receipt emails (subscriptions, services, recurring charges)
- company-updates — extract revenue, users, key metrics from portfolio company update emails
Anti-Patterns
- Trusting LLM working memory for amounts after batch processing (use extraction integrity rule)
- Creating tracker entries without raw source links
- Running without deduplication (leads to double-counted entries)
- Hardcoding source-specific patterns in the pipeline code (use recipes)
Output Format
Brain page at the recipe's tracker_page path with markdown tables:
### 2026
| Date | Company | MRR | ARR | Growth | Status |
|------|---------|-----|-----|--------|--------|
| 2026-04-01 | Example Co | $188K | $2.3M | +14.7% MoM | [Source](link) |
Each entry links to its raw source. Running totals at the bottom of each section.
Conventions
References skills/conventions/quality.md for citation and back-linking rules.
1---2name: data-research3description: Structured data research: search sources, extract structured data, archive raw sources, maintain canonical tracker pages, deduplicate. Parameterized via YAML recipes for investor updates, donations, company updates, or any email-to-structured-data pipeline.4---56# Data Research78Structured research pipeline: search sources, extract structured data,9archive raw, deduplicate, update canonical trackers, backlink entities.1011## Contract1213One skill for any email-to-structured-data pipeline. The only differences14between tracking investor updates, expenses, and company metrics15are the **search queries**, **extraction schemas**, and **tracker page format**.16All three use the same 7-phase pipeline with parameterized recipes.1718## When to Use1920- User wants to track structured data from email, web, or API sources21- User says "research", "track", "extract from email", "build a tracker"22- User mentions investor updates, donations, company metrics, filings23- User wants to set up recurring data collection (with cron recipe)2425## Phases2627### Phase 1: Define Research Recipe2829Ask the user what they want to track. Either:30- Pick a built-in recipe: investor-updates, expense-tracker, company-updates31- Define a custom recipe with: source queries, classification rules, extraction schema,32 tracker page path, tracker format3334Recipes are YAML files at `~/.gbrain/recipes/{name}.yaml`. Use `gbrain research init`35to scaffold a new one.3637### Phase 2: Search Sources3839Brain first (maybe we already have this data). Then:40- **Email** via credential gateway: windowed queries (quarterly, monthly if truncated)41- **Web** via search: public filings, press releases, regulatory data42- **APIs**: any structured data source the recipe defines43- **Attachments**: PDF extraction, HTML stripping4445### Phase 3: Classify4647Deterministic first (regex patterns from recipe), LLM fallback.48Log every LLM fallback for future regex improvement (fail-improve loop).49Skip marketing, newsletters, noise based on recipe's classification rules.5051### Phase 4: Extract Structured Data5253**EXTRACTION INTEGRITY RULE:**541. Save raw source immediately (before any extraction)552. Extract fields using deterministic regex first, LLM fallback563. When summarizing batch results: **re-read from saved files**574. Never trust LLM working memory after batch processing5859This prevents a known hallucination bug where batch-processed amounts were6013/13 wrong from LLM working memory while saved files were correct.6162### Phase 5: Archive Raw Sources6364- `put_raw_data` for email bodies, API responses65- `file_upload` for PDF attachments, documents66- Create `.redirect.yaml` pointers for large files in storage67- Every tracker entry must link back to its raw source6869### Phase 6: Deduplicate7071Before adding to tracker:72- Exact match (same key fields) → skip73- Fuzzy match (same entity + date + similar amount within tolerance) → flag for review74- Different amount for same entity+date → add with note (could be correction)7576### Phase 7: Update Canonical Tracker + Backlink7778- Parse existing tracker page (markdown table)79- Append new entries in correct section (grouped by year/quarter/entity)80- Compute running totals81- Backlink every mentioned entity (person → people/ page, company → companies/ page)82- Uses enrichment service for entity pages8384## Built-In Recipes8586Three example recipes ship with GBrain (see `~/.gbrain/recipes/`):87881. **investor-updates** — extract MRR, ARR, growth, burn, runway, headcount from investor update emails892. **expense-tracker** — extract amounts, recipients, platforms from receipt emails (subscriptions, services, recurring charges)903. **company-updates** — extract revenue, users, key metrics from portfolio company update emails9192## Anti-Patterns9394- Trusting LLM working memory for amounts after batch processing (use extraction integrity rule)95- Creating tracker entries without raw source links96- Running without deduplication (leads to double-counted entries)97- Hardcoding source-specific patterns in the pipeline code (use recipes)9899## Output Format100101Brain page at the recipe's `tracker_page` path with markdown tables:102103```markdown104### 2026105106| Date | Company | MRR | ARR | Growth | Status |107|------|---------|-----|-----|--------|--------|108| 2026-04-01 | Example Co | $188K | $2.3M | +14.7% MoM | [Source](link) |109```110111Each entry links to its raw source. Running totals at the bottom of each section.112113## Conventions114115References `skills/conventions/quality.md` for citation and back-linking rules.