AI-Native Instagram Publishing Pipeline
A production-grade system that turns uploaded photos into a curated, auto-scheduled, auto-published Instagram feed - three Claude agents for the judgment calls, deterministic code for everything that must be exact.
Problem
Running a branded Instagram feed is relentless manual work: every photo has to be screened for safety and quality, captioned and tagged in a consistent voice, slotted into a sensible posting rhythm, and published at the right time - every single day, without slipping. Naively automating it is worse than doing it by hand. Generative models hallucinate and drift, so letting one freely write captions or make safety calls is a brand risk. And the truly unforgiving part is mechanical: in a serverless, webhook-driven world, steps run twice or die halfway, and double-posting to a live account is a public, permanent mistake.
Solution
An event-driven pipeline where Postgres itself drives the flow (pending → approved → scheduled → posted) via Supabase DB webhooks - no queue, no poller. Three Claude agents own only the genuine judgment calls, each with structured (Zod-validated) output, prompt-cached rubrics, and deterministic fallbacks: a moderation agent (dual-axis safety + quality, with a confidence-gated human review queue), a classification agent (topic, mood, caption, alt text, hashtags - shaped by an operator-tunable brand voice), and a scheduling tie-breaker that only runs when there's an actual choice to make. Everything that must be exact stays deterministic code: canonical hour-boundary slot identity with reproducible jitter, idempotent fills with a reconciler cron, and defense-in-depth against double-posting (atomic compare-and-swap claims, media-ID guards, stale-claim recovery, retry-until-consistent writes). Instagram token rotation runs on a daily cron with DB-backed credentials, so it refreshes with zero downtime and no redeploy. The guiding rule throughout: AI for judgment, code for arithmetic.