AI · · 3 min read · Updated
Vibe Coding to Production: AI Guardrails in Next.js 16
How to ship fast with Claude Code and Cursor without vibe-coding regressions: AGENTS.md rules, client bundle budgets, and automated SEO/GEO gates.
Zayne Lovecraft
Software Engineer III

AI coding agents—whether you run Claude Code in the terminal, Cursor in the editor, or a multi-agent cloud runner—can scaffold a working Next.js feature in minutes. The bottleneck in 2026 is rarely writing the first draft. It is stopping an agent from quietly shipping a client-bundle regression, a broken "use client" boundary, or an unindexed route right alongside that feature.
Teams run into trouble when they treat "vibe coding" as a substitute for engineering constraints. Agents work dramatically better when your repository encodes the same guardrails a senior reviewer checks in a pull request.
1. Put architectural rules inside AGENTS.md and memory.md
Prompting an agent from scratch in every session guarantees drift. One prompt gets a Server Component; the next wraps half the page in "use client" because the agent reached for useState instead of URL search params.
As I documented in Filesystem-First AI Agent OS for Cursor and Claude Code, the highest-leverage fix is keeping two short Markdown files at the root of the repo:
AGENTS.md: Hard project invariants—package manager, where database schemas live, validation commands (pnpm lint && pnpm build), and framework constraints like Next.js 16 Cache Components or PPR rules.memory.md: A living correction log. Whenever an agent makes a subtle mistake once (for example, awaitingsearchParamsinsidegenerateMetadataor mutating a shared layout shell), record the rule in one sentence so future sessions read it before touching code.
When the rules live in git next to the code, every agent session starts with institutional memory instead of guessing.
2. Guard the "use client" boundary before it hits production
The fastest way an AI-generated PR hurts Core Web Vitals is by hoisting "use client" too high in the App Router tree. Everything looks fine in local dev, yet production users download extra JavaScript that delays Interaction to Next Paint (INP) and Largest Contentful Paint (LCP).
I break down the component composition pattern in Client Components and the "use client" Boundary in Next.js, and I automate the check in CI with next-vitals-guard:
pnpm build
npx -y github:zaynelovecraft/next-vitals-guard --max-kb=220 --max-chunk-kb=90
Because next-vitals-guard reads real gzipped chunks directly from .next/static/chunks, it fails the build in milliseconds whenever an agent accidentally pulls a heavy Markdown parser, icon pack, or charting library into the client bundle.
3. Enforce technical SEO and GEO checks on preview deploys
AI coding agents are great at shipping new routes and terrible at remembering everything around them: canonical tags, single <h1> discipline, structured JSON-LD entities, robots.txt rules for AI search bots, and /llms.txt updates.
Running geo-audit against a preview or staging URL turns those checks into a binary pass/fail step:
npx -y github:zaynelovecraft/geo-audit https://your-staging-url.example.com --min=90 --json
Pair that with dynamic /sitemap.xml and /llms.txt routes so new pages and articles register automatically without manual edits (see Generative Engine Optimization (GEO) & CWV Gates in Next.js).
4. Keep validation deterministic and local-first
Every agent workflow should end with deterministic checks the agent cannot talk its way past:
| Layer | What it catches | Command / Check |
|---|---|---|
| Types & lint | Broken imports, unsafe any, React hook issues | pnpm lint + tsc --noEmit |
| Production build | Invalid static/dynamic routes, Next.js 16 cache rules | pnpm build |
| Bundle budget | Accidental "use client" bloat | next-vitals-guard |
| Search & GEO | Missing canonicals, broken JSON-LD, blocked crawlers | geo-audit --min=90 |
Takeaway
AI coding agents multiply your output only when your repo pushes back automatically on bad patterns. Put your invariants in AGENTS.md, record corrections in memory.md, and gate every build with type checks, bundle budgets, and automated SEO checks—then let the agent move as fast as it wants inside those rails.
- AI Coding Agents
- Vibe Coding
- Next.js 16
- Core Web Vitals
- Cursor
Keep reading

Architecture · · 5 min read
Why Next.js Is Still the Best Frontend Framework in 2026
Why Next.js 16.4 leads for e-commerce and web apps: Cache Components, Partial Prefetching, Suspense streaming, Zustand state, and Supabase auth.

Architecture · · 4 min read
Architecting Zivvi: Hybrid Search & Traffic Rankings in Next.js 16
How I built zivvi.app to index 2,400+ web apps using daily Tranco 1M traffic deltas, Upstash Vector + Postgres hybrid search, and Next.js 16 Partial Prerendering.