Series

Rapid agentic integration of sanity CMS for auserman chocolate

In a brief

Transitioning a static Next.js storefront into a real-time headless publishing system using an isolated agentic development workflow.

The cost of a monolithic rewrite

Moving a live e-commerce subscription experience from hardcoded TypeScript constants to a headless content management system typically requires days of manual schema authoring, API wiring, and cache configuration. For Auserman Chocolate, we avoided the standard monolithic rewrite. By pairing human product direction with an autonomous coding agent operating inside an isolated Git branch, the entire CMS architecture was designed, implemented, and refined through rapid, verifiable feedback loops.

Rather than shipping code in large unstructured batches, each iteration followed a strict operational cycle. We defined the exact user experience requirements, delegated the multi-file implementation to the agent, and validated every change on a live preview deployment before any code touched production.

A six-step flowchart diagram illustrating an agentic CMS development and real-time revalidation pipeline.
End-to-end agentic development loop and real-time runtime pipeline connecting sanity studio, webhooks, and the storefront.

Isolated preview testing and zero-downtime safety

A core architectural safeguard throughout the rollout was strict environment isolation. All Sanity schemas, embedded studio routes, and webhook handlers were developed exclusively on an isolated feature branch. Every push automatically generated a dedicated preview environment in under a minute.

This allowed the brand to run full editorial testing, simulate cart flows, and experiment with data schemas while keeping live customer traffic completely untouched. When the agent identified a monorepo edge case where missing environment variables triggered build failures during static route collection, we guarded the client initialization to render an informational notice gracefully rather than failing the build.

A web browser displays a Vercel deployment details dashboard showing build logs, preview thumbnails, and status for a web project.
Vercel preview deployment building in 47 seconds with its own isolated domain.

Evolving the schema without data loss

During rapid agentic iteration, data shapes naturally evolve. Fields move between singletons, plain text hex colors upgrade into structured color objects, and legacy fields become redundant. When schemas change, existing documents in the production dataset often throw validation warnings.

Instead of forcing editors to manually re-enter content or click through errors, the workflow relied on idempotent Node synchronization scripts. Using short-lived API tokens, we executed non-destructive seeding to populate new checkout labels, stripped deprecated search metadata fields, and migrated data types across both published documents and drafts in seconds. The production dataset remained perfectly aligned with the evolving codebase without human data entry.

Real-time cache and the deletion edge case

Static websites traditionally force a trade-off between page speed and editorial freshness. By combining Next.js 16 cache directives with GROQ-powered webhooks, the storefront achieves instant static page delivery alongside content updates that propagate in under two seconds.

Screenshot of the sanity.io web dashboard displaying configured GROQ-powered webhooks with an active Vercel revalidation endpoint.
Sanity webhook configured to trigger a revalidation endpoint whenever content changes.

Live testing quickly exposed a subtle webhook behavior. Editing a hero headline and clicking publish updated the preview storefront immediately. However, testing the creation and subsequent deletion of an experimental chocolate flavor revealed that deleted documents bypassed the cache purge. When a document is deleted, its post-mutation state is null, causing standard filters to skip the event.

A split desktop view displaying a content management system editor on the left alongside a live chocolate product website preview on the right.
Side-by-side validation where editing the home page in the studio immediately propagates to the storefront.

To guarantee that creating, updating, and deleting documents all purge stale cache tags immediately, the webhook filter was upgraded. By inspecting the before-state of the mutation, the endpoint accurately invalidates the cache even when the physical document no longer exists.

Editorial ergonomics and the five-section architecture

A content management system is only effective if non-technical brand editors can operate it confidently. After usability reviews of the storefront flows, we structured the studio into five clean, purpose-built sections. Global layout copy, page content, dynamic catalog items, and commercial pricing rules each received an unambiguous home.

A system diagram outlining a five-part editorial structure for sanity studio separated from a server-side financial integrity boundary.
Five-section studio information architecture separated from the server-side financial calculation.
Screenshot of a website builder sidebar menu displaying options like nav & footer, home page, and checkout page.
Clean top-level studio navigation organizing the global site structure.

We started with the dynamic flavor catalog. Managing chocolates in a single collection ensures edits propagate instantly to the hero section, the interactive drag-and-drop tray, and the checkout page. The current layout elegantly absorbs an additional bar, though pushing the catalog past eight active items will eventually require a visual redesign of the hero arc.

A screenshot of a sanity CMS dashboard displaying a list of chocolate flavors for a brand website.
Flavors collection managing ordered chocolate bars and their visibility status.

This high visual fidelity extended to the editor interface itself. When integrating the default color picker, a CSS inheritance conflict caused the widget to collapse to zero pixels in Safari. Instead of reverting to error-prone text strings, we built a custom native hex color input component, providing editors with a reliable visual swatch while preserving the strict data structure required by the frontend.

Navigating the content management system to manage chocolate flavors, custom hex colors, and packaging artwork.
A product data entry form displaying chocolate description fields along with an auserman dark chocolate packaging artwork preview.
Custom flavor schema rendering a crisp native color swatch in the studio.

With the catalog secured, the global structure fell into place. The home page singleton grouped narrative sections sequentially, closing with a dedicated SEO tab for search and social metadata. Because navigation and the footer are global elements, they were grouped into a unified section that also controls the slide-over cart drawer copy, ensuring instructional text remains consistent regardless of where the cart is opened.

Similarly, the checkout page logic decoupled static editorial labels from dynamic pricing. Every editable text field across these singletons was paired with an inline fallback hint, displaying the exact default copy rendered by the application if the input was left blank. This gave editors precise context without cluttering empty fields.

A content management system form interface displaying editable fields for configuring a new checkout page.
Checkout singleton inside the studio organized with inline fallback hints.
A website checkout page for a chocolate subscription with delivery details fields and an order summary card.
Checkout page combining editable editorial labels with dynamically calculated box subtotals.

Server-side financial integrity

The final section, dedicated entirely to pricing and rules, contains everything needed to run the financial calculator—from the base price per bar to shipping constraints and volume discount tiers. Giving non-technical editors control over commercial pricing requires strict security boundaries. If pricing variables are exposed to the browser, a client could potentially tamper with the payload sent to the payment processor.

To prevent this, all pricing rules were decoupled into this dedicated singleton. Whenever a customer submits a checkout request, the application independently fetches the live unit economics from the database. It validates the requested items, recalculates the subtotal based on current volume discounts and shipping fees entirely on the server, and initializes the Stripe session. The browser only receives the final, tamper-proof session ID.

The true value of an agentic workflow is not merely generating boilerplate code. It is the compression of time between architectural decisions and verifiable reality. By delegating the mechanical wiring to an autonomous process within an isolated loop, engineering effort remains focused on solving actual operational friction—from cache edge cases to strict financial security.

If anything here sounds like we can build together, let's talk!

What we do