Scripts Reference
Reference for all CLI scripts in the scripts/ directory. These run via npx tsx (TypeScript execution) and use the Supabase service role key for direct database access.
Prerequisites
All scripts require these environment variables in .env:
SUPABASE_SERVICE_ROLE_KEY=... # Required for all scripts
VITE_SUPABASE_URL=... # Required for all scripts
BLITZ_API_KEY=... # Required for enrichment scripts
Enrichment Scripts
enrich-attorneys.ts
The main attorney enrichment pipeline. Finds attorneys at law firms via Blitz API and enriches with email, phone, education, and work history.
# Test run (1 firm, 5 attorneys)
npx tsx scripts/enrich-attorneys.ts --test
# Full enrichment by tier
npx tsx scripts/enrich-attorneys.ts --tier amlaw_10
npx tsx scripts/enrich-attorneys.ts --tier amlaw_25
npx tsx scripts/enrich-attorneys.ts --tier amlaw_50
npx tsx scripts/enrich-attorneys.ts --tier amlaw_100
npx tsx scripts/enrich-attorneys.ts --tier amlaw_200
# Specific firm
npx tsx scripts/enrich-attorneys.ts --firm "Kirkland"
# Limit attorneys per firm
npx tsx scripts/enrich-attorneys.ts --tier amlaw_10 --max 100
# Skip phone (saves 5 credits/attorney)
npx tsx scripts/enrich-attorneys.ts --tier amlaw_10 --skip-phone
# Skip email enrichment
npx tsx scripts/enrich-attorneys.ts --tier amlaw_10 --skip-email
# Dry run (preview, no API calls)
npx tsx scripts/enrich-attorneys.ts --tier amlaw_10 --dry-run
# Resume interrupted run
npx tsx scripts/enrich-attorneys.ts --resume
Cost: 2--7 credits per attorney (1 finder + 1 email + 5 phone).
Rate limits: 700ms between attorneys, 3s between firms.
Checkpoint: Progress saved to .enrichment-progress.json.
See Enrichment Pipeline for the full runbook.
detect-profile-patterns.ts
Detects firm website URL patterns for attorney bio pages. Tests 37 patterns per firm and validates with 2 attorneys.
# Test all firms (dry run)
npx tsx scripts/detect-profile-patterns.ts
# Save detected patterns to database
npx tsx scripts/detect-profile-patterns.ts --save
# Test a single firm
npx tsx scripts/detect-profile-patterns.ts --firm "Kirkland"
# Skip firms that already have patterns
npx tsx scripts/detect-profile-patterns.ts --save --skip-existing
# Parallel firm processing (default: 3)
npx tsx scripts/detect-profile-patterns.ts --concurrency 5
Requires: Enriched attorneys in the database (at least 2 per firm).
Writes to: firms.profile_url_pattern
blitz-enrich-attorney-contacts.ts
Batch email and phone enrichment for attorneys already in the database who are missing contact information.
npx tsx scripts/blitz-enrich-attorney-contacts.ts
Useful for backfilling contact data on attorneys found by the employee-finder but whose email/phone enrichment was skipped or failed.
scrape-attorney-profiles.ts
Puppeteer-based web scraping for attorney bio pages on firm websites. Used to populate the 34 fields that cannot be obtained from the Blitz API (practice areas, bar admissions, rankings, publications, etc.).
npx tsx scripts/scrape-attorney-profiles.ts
Some firms (e.g., Skadden) use JavaScript-rendered pages that require Puppeteer with the stealth plugin. Simple HTTP requests will not work for these firms.
Analysis Scripts
analyze-firms-by-date.ts
Analyzes the enrichment timeline -- shows when firms were enriched and how many attorneys were found per batch.
npx tsx scripts/analyze-firms-by-date.ts
analyze-recent-campaign.ts
Generates a performance analysis for a recent campaign, including call metrics, disposition breakdown, and engagement levels.
npx tsx scripts/analyze-recent-campaign.ts
dump-record.ts
Inspects a single database record by table and ID. Shows all columns with their values, highlighting which fields are populated vs null.
npx tsx scripts/dump-record.ts
Useful for debugging enrichment results or verifying data after imports.
check-missing-firms.js
Identifies gaps in firm coverage -- firms that exist in the firms table but have no enriched attorneys.
npx tsx scripts/check-missing-firms.js
Data Scripts
add-firms-blitz-only.ts
Adds new firms to the firms table using data from the Blitz API. Looks up firm details by LinkedIn company URL.
npx tsx scripts/add-firms-blitz-only.ts
backfill-company-websites.ts
Populates missing website and domain fields on the firms table by looking up firm domains.
npx tsx scripts/backfill-company-websites.ts
backfill-phones.ts
Backfills missing phone numbers for attorneys who have a LinkedIn URL but no phone_mobile. Uses the Blitz phone enrichment endpoint (5 credits per found number).
npx tsx scripts/backfill-phones.ts
Quick Reference Table
| Script | Command | Credits | Purpose |
|---|---|---|---|
enrich-attorneys.ts | npx tsx scripts/enrich-attorneys.ts [opts] | 2-7/attorney | Main enrichment pipeline |
detect-profile-patterns.ts | npx tsx scripts/detect-profile-patterns.ts [--save] | 0 | URL pattern detection |
blitz-enrich-attorney-contacts.ts | npx tsx scripts/blitz-enrich-attorney-contacts.ts | 1-6/attorney | Batch contact enrichment |
scrape-attorney-profiles.ts | npx tsx scripts/scrape-attorney-profiles.ts | 0 | Firm website scraping |
analyze-firms-by-date.ts | npx tsx scripts/analyze-firms-by-date.ts | 0 | Enrichment timeline |
analyze-recent-campaign.ts | npx tsx scripts/analyze-recent-campaign.ts | 0 | Campaign performance |
dump-record.ts | npx tsx scripts/dump-record.ts | 0 | Record inspection |
check-missing-firms.js | npx tsx scripts/check-missing-firms.js | 0 | Firm coverage gaps |
add-firms-blitz-only.ts | npx tsx scripts/add-firms-blitz-only.ts | varies | Add firms |
backfill-company-websites.ts | npx tsx scripts/backfill-company-websites.ts | 0 | Firm website backfill |
backfill-phones.ts | npx tsx scripts/backfill-phones.ts | 5/found | Phone backfill |