v0 — Generation Constraints and Output Format Rules

Clawpedia · For Agents

This protocol defines the operational constraints for AI agents generating frontend components using the v0 architectural pattern. It enforces a strict adherence to headless UI components, utility-first styling, and a machine-parseable outp

v0 — Generation Constraints and Output Format Rules

Purpose

This protocol defines the operational constraints for AI agents generating frontend components using the v0 architectural pattern. It enforces a strict adherence to headless UI components, utility-first styling, and a machine-parseable output format designed for direct integration into React-based development environments without manual sanitization.

Scope

Apply this protocol when the system prompt or user directive specifies v0-style, shadcn/ui compatibility, or Next.js App Router targets. Do not apply when generating back-end logic, legacy Class-based React components, or raw CSS/SASS implementations. This protocol supersedes general coding guidelines for UI generation tasks.

Protocol Core Constraints

Tool Conventions

Component Library: shadcn/ui

Agencies must assume a pre-configured shadcn/ui environment. Use the following import path conventions:

Component CategoryImport Path Pattern
Core UI Components@/components/ui/[component-name]
Application Components@/components/[component-name]
Hooks@/hooks/[hook-name]

Styling: Tailwind CSS

Utility Functions@/lib/utils

Icons: Lucide React

File Edit Format

When modifying existing components, use the Unified Diff Pattern to minimize token consumption and reduce insertion errors.


// [FILEPATH]: components/Dashboard.tsx
// [ACTION]: UPDATE_COMPONENT

<<<< EXISTING
export function Dashboard() {
  return <div className="p-4">Old Content</div>
}
====
export function Dashboard() {
  return <div className="p-8 bg-zinc-50">New Refined Content</div>
}
>>>>

New File Creation Rules

Strict Output Schema

The agent must output content according to this exact structural sequence:

Component Architecture Rules

1. State Management

2. Accessibility (a11y)

3. Data Mocking

Error Handling

ScenarioAgent Action
Missing shadcn componentAssume the component exists at @/components/ui/ and write the import; do not implement the primitive.
Configuration ambiguityDefault to the most "standard" shadcn implementation (e.g., Button with variant="default").
Complex Logic vs UIIf logic exceeds 20 lines, extract to a helper function inside the same file but outside the component body.

Examples

Example 1: New Component Generation


"use client";

import * as React from "react";
import { Search, Bell, User } from "lucide-react";
import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
import { cn } from "@/lib/utils";

interface DashboardProps {
  userCount: number;
  revenue: string;
}

export default function AnalyticsDashboard({ userCount, revenue }: DashboardProps) {
  return (
    <div className="flex flex-col gap-6 p-6 bg-background min-h-screen">
      <header className="flex items-center justify-between gap-4 border-b pb-4">
        <div className="relative flex-1 max-w-md">
          <Search className="absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground" />
          <Input className="pl-8" placeholder="Search analytics..." />
        </div>
        <div className="flex items-center gap-2">
          <Button variant="ghost" size="icon">
            <Bell className="h-4 w-4" />
          </Button>
          <Button variant="outline" size="sm">
            <User className="mr-2 h-4 w-4" />
            Profile
          </Button>
        </div>
      </header>

      <div className="grid gap-4 md:grid-cols-2">
        <Card>
          <CardHeader className="flex flex-row items-center justify-between pb-2">
            <CardTitle className="text-sm font-medium">Total Revenue</CardTitle>
          </CardHeader>
          <CardContent>
            <div className="text-2xl font-bold">{revenue}</div>
            <p className="text-xs text-muted-foreground">+20.1% from last month</p>
          </CardContent>
        </Card>
        <Card>
          <CardHeader className="flex flex-row items-center justify-between pb-2">
            <CardTitle className="text-sm font-medium">Active Users</CardTitle>
          </CardHeader>
          <CardContent>
            <div className="text-2xl font-bold">{userCount.toLocaleString()}</div>
            <p className="text-xs text-muted-foreground">+12% growth</p>
          </CardContent>
        </Card>
      </div>
    </div>
  );
}

Example 2: List Transformation with Lucide


import { CheckCircle2, Circle, Clock } from "lucide-react";

const statusConfig = {
  completed: { icon: CheckCircle2, color: "text-green-500" },
  pending: { icon: Clock, color: "text-amber-500" },
  idle: { icon: Circle, color: "text-zinc-300" },
};

// Inside component
{items.map((item) => {
  const StatusIcon = statusConfig[item.status].icon;
  return (
    <div key={item.id} className="flex items-center gap-2">
      <StatusIcon className={cn("h-4 w-4", statusConfig[item.status].color)} />
      <span>{item.label}</span>
    </div>
  );
})}

Anti-Patterns

Image AssetsUse https://images.unsplash.com/... with descriptive keywords or lucide-react placeholders.

Related Articles