3. Backfill Summaries

Purpose: Generate AI summaries for change events that are missing them, typically after API credit exhaustion or outage caused summarization failures.

Prerequisites:

  • .env.local with DATABASE_URL, ANTHROPIC_API_KEY, OPENAI_API_KEY
  • Change events exist in the database without corresponding summaries

Cost / Duration: ~$1 AI cost | 10-30 min

Prompt

Backfill missing AI summaries for change events.

Step 1 — Preview what would be backfilled:

```bash
bun scripts/backfill-summaries.ts --dry-run
```

Shows the count of events missing summaries without generating anything.

Step 2 — Run with batch size control:

```bash
bun scripts/backfill-summaries.ts --batch=50
```

Default batch size is 25. Adjust based on API budget.

Step 3 — Run with date filter:

```bash
bun scripts/backfill-summaries.ts --since=2026-02-01
```

Only backfills events created after the specified date.

Step 4 — Combine batch size and date filtering:

```bash
bun scripts/backfill-summaries.ts --batch=50 --since=2026-02-01
```

Verify: Re-run dry-run to confirm reduced count.

```bash
bun scripts/backfill-summaries.ts --dry-run
```

Expected: `0 events missing summaries` or significantly reduced count.

Verification

  • Dry-run before execution to estimate scope
  • Backfill completes without AI generation errors
  • Re-run --dry-run confirms reduced count
  • No database connection errors
  • Cost within expected range (~$1 for typical batch)

Back to index