@minhduydev/mdpi 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/dist/index.js +1 -1
  2. package/dist/template/.pi/VERSION +1 -1
  3. package/dist/template/.pi/extensions/templates-injector.ts +34 -6
  4. package/dist/template/.pi/prompts/INDEX.md +3 -9
  5. package/dist/template/.pi/skills/INDEX.md +81 -19
  6. package/dist/template/.pi/skills/accessibility-audit/SKILL.md +8 -2
  7. package/dist/template/.pi/skills/baseline-ui/SKILL.md +211 -0
  8. package/dist/template/.pi/skills/dcp-hygiene/SKILL.md +1 -1
  9. package/dist/template/.pi/skills/design-taste-frontend/SKILL.md +53 -42
  10. package/dist/template/.pi/skills/fixing-accessibility/SKILL.md +509 -0
  11. package/dist/template/.pi/skills/frontend-design/SKILL.md +60 -47
  12. package/dist/template/.pi/skills/frontend-design/references/animation/motion-advanced.md +88 -15
  13. package/dist/template/.pi/skills/frontend-design/references/animation/motion-core.md +148 -13
  14. package/dist/template/.pi/skills/frontend-design/references/shadcn/setup.md +127 -20
  15. package/dist/template/.pi/skills/frontend-ui-engineering/SKILL.md +21 -27
  16. package/dist/template/.pi/skills/nextjs-app-router/SKILL.md +334 -0
  17. package/dist/template/.pi/skills/nextjs-cache/SKILL.md +262 -0
  18. package/dist/template/.pi/skills/oklch-color-workflow/SKILL.md +426 -0
  19. package/dist/template/.pi/skills/production-hardening/SKILL.md +652 -0
  20. package/dist/template/.pi/skills/react-best-practices/SKILL.md +79 -1
  21. package/dist/template/.pi/skills/react-compiler/SKILL.md +237 -0
  22. package/dist/template/.pi/skills/react-hook-form/SKILL.md +374 -0
  23. package/dist/template/.pi/skills/react-server-actions/SKILL.md +299 -0
  24. package/dist/template/.pi/skills/shadcn-ui/SKILL.md +404 -0
  25. package/dist/template/.pi/skills/tanstack-query/SKILL.md +330 -0
  26. package/dist/template/.pi/skills/ui-craft-principles/SKILL.md +564 -0
  27. package/dist/template/.pi/skills/ui-quality-audit/SKILL.md +329 -0
  28. package/dist/template/.pi/skills/v0/SKILL.md +264 -0
  29. package/dist/template/.pi/skills/zustand/SKILL.md +333 -0
  30. package/dist/template/.pi/templates/DESIGN.md +76 -0
  31. package/dist/template/.pi/workflows/INDEX.md +2 -1
  32. package/dist/template/.pi/workflows/frontend-feature-workflow.md +343 -0
  33. package/dist/template/.pi/workflows/quality-loop.md +1 -1
  34. package/package.json +1 -1
  35. package/dist/template/.pi/prompts/loop-check.md +0 -87
  36. package/dist/template/.pi/prompts/loop-init.md +0 -157
  37. package/dist/template/.pi/prompts/loop-review.md +0 -90
  38. package/dist/template/.pi/skills/loop-audit/SKILL.md +0 -141
  39. package/dist/template/.pi/skills/loop-cost/SKILL.md +0 -130
  40. package/dist/template/.pi/skills/loop-engineering/SKILL.md +0 -175
  41. package/dist/template/.pi/templates/loop-github-action.yml +0 -162
  42. package/dist/template/.pi/templates/loop-orchestrator.sh +0 -514
  43. package/dist/template/.pi/templates/loop-orchestrator.test.ts +0 -332
  44. package/dist/template/.pi/templates/loop-orchestrator.ts +0 -936
  45. package/dist/template/.pi/templates/loop-state.json +0 -24
  46. package/dist/template/.pi/templates/loop-state.md +0 -98
  47. package/dist/template/.pi/templates/loop-vision.md +0 -110
  48. /package/dist/template/.pi/templates/{design.md → feature-design.md} +0 -0
@@ -0,0 +1,329 @@
1
+ ---
2
+ name: ui-quality-audit
3
+ description: 5-dimension UI quality scoring audit — accessibility, performance, theming, responsive, and anti-pattern detection with P0-P3 severity tags
4
+ ---
5
+
6
+ # UI Quality Audit
7
+
8
+ ## When to Use
9
+
10
+ - Before merging UI changes to production
11
+ - When triaging a backlog of UI issues
12
+ - During design system reviews
13
+ - When retrofitting quality into existing components
14
+ - As a gate check before launching new features
15
+
16
+ ## When NOT to Use
17
+
18
+ - Quick visual review (use `design-system-audit` instead)
19
+ - Non-UI code (backend, APIs, data processing)
20
+ - When the component is not yet implemented (audit after implementation)
21
+
22
+ ---
23
+
24
+ ## Severity Levels
25
+
26
+ | Level | Label | Action |
27
+ |-------|-------|--------|
28
+ | **P0** | Ship blocker | Do not deploy. Immediate fix required. |
29
+ | **P1** | Must fix this release | Fix before the next production release. |
30
+ | **P2** | Should fix | Fix when time permits. Not blocking. |
31
+ | **P3** | Nice to have | Polish improvement. Low priority. |
32
+
33
+ ---
34
+
35
+ ## 5-Dimension Scoring Rubric
36
+
37
+ Each dimension is scored 0–4. A score of 0 means critical failures exist. A score of 4 means the dimension is flawless.
38
+
39
+ ### 1. Accessibility (Weight: High)
40
+
41
+ **Focus:** Keyboard navigation, ARIA, color contrast, focus management, semantic HTML.
42
+
43
+ | Score | Description |
44
+ |-------|-------------|
45
+ | **4** | Perfect WCAG 2.1 AA compliance. No violations. Keyboard navigable, proper ARIA, 4.5:1+ contrast everywhere. |
46
+ | **3** | Minor issues (P2-P3 only). Most flows accessible. Some ARIA labels could be more descriptive. |
47
+ | **2** | Moderate issues (P1). Some interactive elements not keyboard-accessible. Contrast failures on non-critical text. |
48
+ | **1** | Major issues (P0-P1). Keyboard traps, missing alt text on critical images, form labels missing. |
49
+ | **0** | Critical failures. Page is not navigable by keyboard. No focus indicators. ARIA missing entirely. |
50
+
51
+ **P0 checks (ship blockers):**
52
+
53
+ - [ ] Keyboard trap exists — user cannot tab through all interactive elements
54
+ - [ ] `outline: none` without `:focus-visible` fallback
55
+ - [ ] Missing form labels on required inputs
56
+ - [ ] Color contrast < 3:1 on any text (P0 if body text, P1 if decorative)
57
+
58
+ **P1 checks (must fix this release):**
59
+
60
+ - [ ] Color contrast < 4.5:1 but ≥ 3:1
61
+ - [ ] Missing `alt` text on informative images
62
+ - [ ] Missing `aria-label` on icon-only buttons
63
+ - [ ] Skip-to-content link missing
64
+ - [ ] Heading hierarchy skipped (h1 → h3)
65
+
66
+ **P2 checks (should fix):**
67
+
68
+ - [ ] ARIA labels present but unhelpful (e.g., "button" as label)
69
+ - [ ] Focusable elements in illogical tab order
70
+ - [ ] Missing `lang` attribute on `<html>`
71
+ - [ ] Redundant ARIA on semantic HTML
72
+
73
+ **P3 checks (nice to have):**
74
+
75
+ - [ ] ARIA live regions missing for dynamic content
76
+ - [ ] Touch targets slightly below 44px (40px-43px)
77
+
78
+ ---
79
+
80
+ ### 2. Performance (Weight: High)
81
+
82
+ **Focus:** Bundle size, render performance, animation performance, image optimization.
83
+
84
+ | Score | Description |
85
+ |-------|-------------|
86
+ | **4** | Lighthouse 90+ in all categories. Images optimized. Bundle < 200KB gzip. No layout shifts. |
87
+ | **3** | Lighthouse 80-89. Minor optimization opportunities. Bundle < 400KB. |
88
+ | **2** | Lighthouse 60-79. Moderate issues. Large images unoptimized. Render-blocking resources. |
89
+ | **1** | Lighthouse < 60. Major issues. Massive bundle. No lazy loading. Layout shifts present. |
90
+ | **0** | Critical failures. Bundle > 1MB. No code splitting. Unoptimized images everywhere. CLS > 0.25. |
91
+
92
+ **P0 checks:**
93
+
94
+ - [ ] Cumulative Layout Shift (CLS) > 0.25
95
+ - [ ] Largest Contentful Paint (LCP) > 4s
96
+ - [ ] No lazy loading on below-fold images
97
+ - [ ] Bundle size > 1MB (gzip)
98
+
99
+ **P1 checks:**
100
+
101
+ - [ ] CLS > 0.1
102
+ - [ ] LCP > 2.5s
103
+ - [ ] Images loaded without dimensions (causing reflow)
104
+ - [ ] No code splitting on route boundaries
105
+ - [ ] Unoptimized images (no WebP/AVIF, no responsive sizes)
106
+
107
+ **P2 checks:**
108
+
109
+ - [ ] Animations running on CPU (not GPU-composited)
110
+ - [ ] Font files > 200KB total
111
+ - [ ] Third-party scripts blocking main thread
112
+ - [ ] Missing `loading="lazy"` on below-fold images
113
+
114
+ **P3 checks:**
115
+
116
+ - [ ] `will-change` applied permanently
117
+ - [ ] No `preconnect` for critical origins
118
+ - [ ] No `font-display: swap` for web fonts
119
+
120
+ ---
121
+
122
+ ### 3. Theming (Weight: Medium)
123
+
124
+ **Focus:** Token consistency, dark mode support, color contrast, typography scale.
125
+
126
+ | Score | Description |
127
+ |-------|-------------|
128
+ | **4** | Complete design token system. Full dark mode. Consistent spacing/typography/color. OKLCH colors. |
129
+ | **3** | Token system exists with gaps. Dark mode works but misses some surfaces. Mostly consistent. |
130
+ | **2** | Partial token usage. Hardcoded colors/spacing in some places. Dark mode partial or absent. |
131
+ | **1** | Minimal token system. Mostly hardcoded values. No dark mode. Typography scale inconsistent. |
132
+ | **0** | No design tokens. All hardcoded values. No theming system. Arbitrary colors and spacing. |
133
+
134
+ **P0 checks:**
135
+
136
+ - [ ] Hardcoded colors prevent dark mode entirely
137
+ - [ ] Missing contrast in dark mode — text invisible on dark backgrounds
138
+
139
+ **P1 checks:**
140
+
141
+ - [ ] Spacing doesn't follow 4pt or 8pt scale — arbitrary values used
142
+ - [ ] More than 1-2 accent colors fighting for attention
143
+ - [ ] Font size scale doesn't follow consistent ratio (1.25x or similar)
144
+
145
+ **P2 checks:**
146
+
147
+ - [ ] Token naming inconsistent (mix of `--color-primary` and `--blue-500`)
148
+ - [ ] Typography scale gaps — missing sizes for specific use cases
149
+ - [ ] Component uses hardcoded colors outside the token system
150
+
151
+ **P3 checks:**
152
+
153
+ - [ ] OKLCH not used where color gamut matters
154
+ - [ ] Missing transition on theme switch (`color-scheme` transition)
155
+
156
+ ---
157
+
158
+ ### 4. Responsive (Weight: Medium)
159
+
160
+ **Focus:** Breakpoint coverage, touch targets, content reflow, viewport configuration.
161
+
162
+ | Score | Description |
163
+ |-------|-------------|
164
+ | **4** | Perfect at all breakpoints (320px-2560px). Touch targets 44px+. No horizontal scroll. Content reflows properly. |
165
+ | **3** | Minor issues at edge breakpoints (320px or 2560px). Most views work well. |
166
+ | **2** | Moderate issues. Some pages have horizontal scroll. Touch targets < 44px. Content overlaps at certain widths. |
167
+ | **1** | Major issues. Mobile layout broken. Content cut off. Interactive elements overlap. |
168
+ | **0** | Critical failures. Desktop-only layout. No responsive meta tag. Unusable on mobile. |
169
+
170
+ **P0 checks:**
171
+
172
+ - [ ] Page unusable at 375px width (content cut off, overlapping)
173
+ - [ ] Missing `<meta name="viewport" content="width=device-width, initial-scale=1">`
174
+ - [ ] Horizontal scroll on main content at standard breakpoints
175
+
176
+ **P1 checks:**
177
+
178
+ - [ ] Touch targets < 44px on interactive elements
179
+ - [ ] Content does not reflow at 400% zoom (WCAG failure)
180
+ - [ ] Tables not responsive (no horizontal scroll or card conversion)
181
+
182
+ **P2 checks:**
183
+
184
+ - [ ] Images don't scale down on small viewports
185
+ - [ ] Font sizes too small to read on mobile (< 16px for body)
186
+ - [ ] Gaps/whitespace not adjusted for small screens
187
+
188
+ **P3 checks:**
189
+
190
+ - [ ] `prefers-reduced-motion` media query missing
191
+ - [ ] `prefers-color-scheme` not respected for dark mode
192
+ - [ ] Print stylesheet missing
193
+
194
+ ---
195
+
196
+ ### 5. Anti-Patterns (Weight: Medium)
197
+
198
+ **Focus:** AI fingerprints, dead code, over-engineering, inconsistent patterns.
199
+
200
+ | Score | Description |
201
+ |-------|-------------|
202
+ | **4** | No AI fingerprints. No dead code. Consistent component patterns. No over-engineering. |
203
+ | **3** | Minor anti-patterns. 1-2 instances of extraneous abstraction or inconsistent naming. |
204
+ | **2** | Moderate. Multiple AI fingerprint patterns. Dead code present. Inconsistent patterns across similar components. |
205
+ | **1** | Major. Pervasive AI-generated patterns. Significant dead code. Architecture is inconsistent. |
206
+ | **0** | Critical. Codebase reads as entirely AI-generated. No coherent patterns. Massive dead code. |
207
+
208
+ **P0 checks:**
209
+
210
+ - [ ] `div onClick` as button pattern without proper ARIA
211
+ - [ ] Purple/blue gradient hero sections (AI fingerprint)
212
+ - [ ] 3-column identical card pattern (AI fingerprint)
213
+ - [ ] Emojis used instead of icons or text
214
+
215
+ **P1 checks:**
216
+
217
+ - [ ] Glassmorphism applied without functional purpose
218
+ - [ ] Bounce/elastic easing on UI elements
219
+ - [ ] Inter/Roboto/Arial fonts specified
220
+ - [ ] Dead code or commented-out components in active files
221
+
222
+ **P2 checks:**
223
+
224
+ - [ ] Over-engineered abstractions (component with 15+ props when 5 would do)
225
+ - [ ] Inconsistent naming conventions (`user-card`, `UserCard`, `user_card`)
226
+ - [ ] Prop drilling through 5+ component levels without context
227
+ - [ ] Unnecessary `useMemo`/`useCallback` wrapping simple values
228
+
229
+ **P3 checks:**
230
+
231
+ - [ ] Generic placeholder content ("Lorem ipsum", "John Doe", "Acme Corp")
232
+ - [ ] Hardcoded English strings without i18n wrapper
233
+ - [ ] Missing `key` props or using index as key
234
+
235
+ ---
236
+
237
+ ## Audit Report Format
238
+
239
+ When producing an audit, use this format:
240
+
241
+ ```markdown
242
+ ## UI Quality Audit: [Component/Page]
243
+
244
+ ### Overall Score: [X]/20 (Average: [X.X]/4)
245
+
246
+ | Dimension | Score | P0 | P1 | P2 | P3 |
247
+ |-----------|-------|----|----|----|------|
248
+ | Accessibility | [0-4] | [#] | [#] | [#] | [#] |
249
+ | Performance | [0-4] | [#] | [#] | [#] | [#] |
250
+ | Theming | [0-4] | [#] | [#] | [#] | [#] |
251
+ | Responsive | [0-4] | [#] | [#] | [#] | [#] |
252
+ | Anti-patterns | [0-4] | [#] | [#] | [#] | [#] |
253
+
254
+ ### Critical (P0)
255
+ 1. **[Issue]** — [Component] — [Fix recommendation]
256
+ 2. **[Issue]** — [Component] — [Fix recommendation]
257
+
258
+ ### Must Fix (P1)
259
+ 1. ...
260
+
261
+ ### Should Fix (P2)
262
+ 1. ...
263
+
264
+ ### Nice to Have (P3)
265
+ 1. ...
266
+ ```
267
+
268
+ ### Example filled report:
269
+
270
+ ```markdown
271
+ ## UI Quality Audit: UserProfilePage
272
+
273
+ ### Overall Score: 12/20 (Average: 2.4/4)
274
+
275
+ | Dimension | Score | P0 | P1 | P2 | P3 |
276
+ |-----------|-------|----|----|----|------|
277
+ | Accessibility | 2 | 1 | 2 | 1 | 0 |
278
+ | Performance | 3 | 0 | 1 | 1 | 1 |
279
+ | Theming | 4 | 0 | 0 | 0 | 1 |
280
+ | Responsive | 2 | 1 | 1 | 1 | 0 |
281
+ | Anti-patterns | 1 | 1 | 2 | 0 | 1 |
282
+
283
+ ### Critical (P0)
284
+ 1. **[A11y]** Avatar button without label — keyboard users cannot access profile menu.
285
+ → Add `aria-label="Open profile menu"` to button.
286
+ 2. **[Responsive]** Profile table overflows at 375px — horizontal scroll on main content.
287
+ → Convert table to stacked card layout on mobile.
288
+
289
+ ### Must Fix (P1)
290
+ 1. **[A11y]** Color contrast 3.8:1 on bio text (gray-500 on white).
291
+ → Use gray-600 instead.
292
+ 2. **[Perf]** Avatar image loaded at 800×800, displayed at 40×40.
293
+ → Add `?w=80&q=75` to image URL or use proper responsive srcset.
294
+ ```
295
+
296
+ ---
297
+
298
+ ## Audit Workflow
299
+
300
+ 1. **Scan** — Run all automated checks (axe-core, Lighthouse, bundle analyzer)
301
+ 2. **Score** — Fill each dimension using the rubric above
302
+ 3. **Tag** — Categorize findings by severity (P0-P3)
303
+ 4. **Fix P0** — Address all ship-blockers immediately
304
+ 5. **Plan P1** — Schedule remaining must-fix items for this release
305
+ 6. **Triage P2-P3** — Decide what to fix vs. backlog
306
+
307
+ ## Don't
308
+
309
+ | Pattern | Replacement | Because |
310
+ |---------|-------------|---------|
311
+ | Keyboard trap — user cannot tab through all elements | Ensure logical tab order with proper focus management | Keyboard trap makes site unusable for non-mouse users |
312
+ | `outline: none` without `:focus-visible` alternative | Custom focus ring via `:focus-visible` | Removing focus breaks keyboard navigation |
313
+ | Color contrast < 3:1 on body text | Darken text to meet minimum 3:1 contrast | Below 3:1 is illegible for low-vision users |
314
+ | CLS > 0.25 (Cumulative Layout Shift) | Reserve space with aspect-ratio containers and fixed dimensions | High CLS degrades Core Web Vitals |
315
+ | No lazy loading on below-fold images | Add `loading="lazy"` to all images below the fold | Eager loading wastes bandwidth and slows page load |
316
+ | Page unusable at 375px width | Implement responsive layout that reflows at all breakpoints | Mobile users are the primary audience |
317
+ | `<div onClick>` as interactive button | Use `<button type="button">` with proper ARIA | div onClick has no keyboard/screen reader semantics |
318
+ | Purple/blue gradient hero sections | Single flat accent or subtle tonal gradient | Purple/blue gradient is the #1 AI generation fingerprint |
319
+
320
+ ## Verification
321
+
322
+ - [ ] Accessibility scored and all P0 items identified
323
+ - [ ] Performance scored with Lighthouse evidence
324
+ - [ ] Theming scored with token audit evidence
325
+ - [ ] Responsive scored with screenshots at 375px, 768px, 1440px
326
+ - [ ] Anti-patterns scored with code review evidence
327
+ - [ ] Audit report generated with all 5 dimensions, severity tags, and fix recommendations
328
+ - [ ] P0 items resolved before merge
329
+ - [ ] P1 items have assigned fix tickets
@@ -0,0 +1,264 @@
1
+ ---
2
+ name: v0
3
+ description: Use when generating UI with v0 (Vercel's AI-powered generator). Covers prompt engineering, CLI/SDK/MCP integration, shadcn/ui-aware patterns. MUST load before any v0 workflow.
4
+ ---
5
+
6
+ # v0 — Vercel AI UI Generator
7
+
8
+ ## Overview
9
+
10
+ v0 (v0.app) is Vercel's AI-powered UI and application generator. It generates React components using **shadcn/ui** primitives + **Tailwind CSS**, targeting **Next.js App Router** by default.
11
+
12
+ In February 2026, v0 evolved to **v2.0** — a full production development platform. Beyond UI generation, it now supports: importing GitHub repos into sandboxes, git branching/PRs/merging from the browser, database integrations (Snowflake, AWS DBs), enterprise SSO, and agent-based workflows.
13
+
14
+ v0 generates "code that looks like a senior frontend engineer wrote it."
15
+
16
+ ## When to Use
17
+
18
+ - Generating shadcn/ui components or pages with AI
19
+ - Writing effective v0 prompts using the 5-block brief
20
+ - Adding v0-generated code to projects via CLI or SDK
21
+ - Integrating v0 with IDEs via MCP (`https://mcp.v0.dev`)
22
+ - Building programmatic UI generation workflows with the v0 SDK
23
+ - Designing brand-aware v0 output via custom shadcn/ui registries
24
+
25
+ ## When NOT to Use
26
+
27
+ - Plain UI without AI generation (use `frontend-design` skill)
28
+ - Backend-only or non-UI tasks
29
+ - When you already have the component and only need manual edits
30
+
31
+ ## Relationship to Other Skills
32
+
33
+ | Skill | Role |
34
+ |-------|------|
35
+ | `shadcn-ui` | Upstream — ensures shadcn/ui is configured correctly before v0 generation |
36
+ | `frontend-design` | Downstream — use for manual refinement of v0 output, design system application |
37
+ | `design-taste-frontend` | Aesthetic baseline applied to v0 generations |
38
+
39
+ **Pipeline**: `shadcn-ui` → `v0` → `frontend-design`
40
+
41
+ ## Prompt Engineering: The 5-Block Component Brief
42
+
43
+ Every v0 prompt should include these 5 blocks. Missing blocks = v0 guesses = expensive iterations.
44
+
45
+ | # | Block | Question | Example |
46
+ |---|-------|----------|---------|
47
+ | 1 | **What it is** | What component? | "A subscription pricing card for a SaaS dashboard" |
48
+ | 2 | **Behavior** | How does it work? | "Three tiers (Free/Pro/Enterprise), monthly/yearly toggle switches pricing, clicking a tier highlights it" |
49
+ | 3 | **States** | What states? | "Loading spinner while pricing loads, error state if fetch fails, empty state if no tiers returned" |
50
+ | 4 | **Props / Data Shape** | What's the contract? | "`tiers: Tier[]`, `billing: 'monthly' | 'yearly'`, `onSelect: (tier) => void`" |
51
+ | 5 | **Visual Intent** | What should it look like? | "shadcn Card layout, data-first, accent color on recommended tier, generous whitespace, no shadows" |
52
+
53
+ ### Prompt Patterns
54
+
55
+ | Pattern | Example | Why |
56
+ |---------|---------|-----|
57
+ | **Constraint anchoring** | "Use only shadcn/ui primitives and Tailwind classes" | Prevents unknown imports |
58
+ | **Negative instruction** | "Do not use inline styles or external CSS files" | Eliminates anti-patterns |
59
+ | **Type contract** | "Define TypeScript interface for all props first" | Forces explicit API surface |
60
+ | **Responsive breakpoints** | "Mobile-first: stack on sm, 2-col on md, 3-col on lg" | Correct Tailwind prefixes |
61
+ | **State specification** | "Lift filter state to the parent via onFilterChange" | Proper unidirectional data flow |
62
+ | **System context** | "You are generating for Next.js App Router with shadcn/ui Vega style..." | Foundation for consistency |
63
+
64
+ ### Anti-Patterns in Prompts
65
+
66
+ | Anti-Pattern | Fix |
67
+ |-------------|-----|
68
+ | One-word prompt ("Pricing page") | Write a 5-block brief |
69
+ | Generating full pages | Generate component by component, compose pages manually |
70
+ | Hard-coded data | Generate data-less components, wire real data separately |
71
+ | "Make it look like Stripe" | Describe visual intent concretely, not by brand reference |
72
+ | 10+ refinements in one follow-up | 1-2 changes per loop; rewrite brief from scratch if complex |
73
+ | UI-first architecture | Design API/schema first, then generate UI that matches it |
74
+ | Passing API secrets through prompts | Never send secrets through v0 chat |
75
+
76
+ ## Integration Paths
77
+
78
+ ### Path A — shadcn CLI Pull (Recommended)
79
+
80
+ 1. Generate UI on [v0.app](https://v0.app)
81
+ 2. Click **"Add to Codebase"** → copy the command:
82
+ ```bash
83
+ npx shadcn@latest add "https://v0.dev/chat/b/<project_id>?token=<token>"
84
+ ```
85
+ 3. Run in your project root — pulls component + installs deps
86
+
87
+ ### Path B — v0 CLI
88
+
89
+ ```bash
90
+ # One-time setup in existing Next.js project
91
+ npx v0@latest init
92
+
93
+ # Add specific generated component by ID
94
+ npx v0@latest add <id>
95
+ ```
96
+
97
+ The `v0` CLI (v2.2.5) installs deps: `@radix-ui/react-icons`, `clsx`, `lucide-react`.
98
+
99
+ ### Path C — SDK (Programmatic)
100
+
101
+ ```bash
102
+ npm install v0-sdk
103
+ ```
104
+
105
+ ```typescript
106
+ import { v0 } from 'v0-sdk'
107
+
108
+ const client = v0.createClient({ apiKey: process.env.V0_API_KEY })
109
+
110
+ // Create a chat
111
+ const chat = await client.chats.create({
112
+ message: "Build a pricing card with three tiers and monthly/yearly toggle"
113
+ })
114
+
115
+ // Stream the response
116
+ for await (const chunk of chat.stream()) {
117
+ console.log(chunk)
118
+ }
119
+
120
+ // Initialize with existing files
121
+ await client.chats.init({
122
+ files: [{ path: 'components/ui/button.tsx', content: '...' }]
123
+ })
124
+ ```
125
+
126
+ ### v0 SDK Ecosystem
127
+
128
+ | Package | Version | Purpose |
129
+ |---------|---------|---------|
130
+ | `v0-sdk` | 0.16.4 | Core TypeScript SDK — chats, projects, deployments |
131
+ | `@v0-sdk/react` | 0.5.0 | Headless React components for v0 content |
132
+ | `@v0-sdk/ai-tools` | 0.3.8 | AI SDK tools for agents (~20 tools) |
133
+ | `create-v0-sdk-app` | 0.2.1 | Scaffold SDK-powered apps |
134
+
135
+ ### Path D — MCP Server
136
+
137
+ Connect IDEs to v0 via MCP:
138
+
139
+ ```json
140
+ {
141
+ "mcpServers": {
142
+ "v0": {
143
+ "command": "npx",
144
+ "args": ["mcp-remote", "https://mcp.v0.dev", "--header", "Authorization: Bearer ${V0_API_KEY}"]
145
+ }
146
+ }
147
+ }
148
+ ```
149
+
150
+ Supports: Cursor, Claude Desktop, VS Code, Windsurf, any MCP-compatible IDE.
151
+
152
+ ## Platform API (Public Beta)
153
+
154
+ REST API at `https://api.v0.dev/v1`. Covers: chats, projects, deployments, users, webhooks, MCP servers.
155
+
156
+ ```typescript
157
+ // Direct REST
158
+ const res = await fetch('https://api.v0.dev/v1/chats', {
159
+ method: 'POST',
160
+ headers: {
161
+ 'Authorization': `Bearer ${process.env.V0_API_KEY}`,
162
+ 'Content-Type': 'application/json'
163
+ },
164
+ body: JSON.stringify({
165
+ message: "Build a login form with email/password fields"
166
+ })
167
+ })
168
+ ```
169
+
170
+ ## Integration with shadcn/ui
171
+
172
+ v0 generates code using shadcn/ui by default. Key integration points:
173
+
174
+ - **Before generating**: Run `npx shadcn init` in your project
175
+ - **Custom design systems**: Publish a shadcn/ui Registry with your design tokens → v0 generates brand-consistent output
176
+ - **Registry MCP**: Connect your registry to v0 for design-aware generation
177
+ - **`components.json`**: v0 respects your project's aliases and style config
178
+ - **Check deps**: After pulling v0 code, verify all shadcn components are installed
179
+
180
+ ### Design System Integration
181
+
182
+ ```json
183
+ // components.json — exposed to v0 for brand-aware generation
184
+ {
185
+ "style": "vega",
186
+ "tsx": true,
187
+ "tailwind": { "cssVariables": true },
188
+ "aliases": { "components": "@/components", "ui": "@/components/ui" }
189
+ }
190
+ ```
191
+
192
+ ## v0 2.0 Platform (Feb 2026)
193
+
194
+ Key capabilities beyond UI generation:
195
+
196
+ - **Import any GitHub repo** into sandbox with auto-pulled Vercel env vars
197
+ - **Git panel** — branching, PRs, merging from the browser
198
+ - **DB integrations** — Snowflake, AWS databases, Neon + Drizzle scaffolding
199
+ - **Enterprise** — deployment protection, access controls, SSO, signed Git commits
200
+ - **Agents** — plan and build end-to-end agentic workflows
201
+ - **Design Mode** — floating toolbar, layers viewer, measure overlay
202
+ - **Cmd+K** — command palette navigation
203
+ - **Shopify integration** — storefront building
204
+ - **Auto merge conflict resolution**
205
+
206
+ ## Best Patterns
207
+
208
+ ### Component-First Decomposition
209
+
210
+ Instead of: "Build a dashboard page"
211
+
212
+ Do:
213
+ 1. Generate `StatCard` → pull → verify
214
+ 2. Generate `DataTable` → pull → verify
215
+ 3. Generate `ChartWidget` → pull → verify
216
+ 4. Compose in the page manually
217
+
218
+ ### System Prompt Template
219
+
220
+ When using the SDK or Platform API, set a system prompt:
221
+
222
+ ```
223
+ You are a shadcn/ui component generator.
224
+ Framework: Next.js 15+ App Router.
225
+ Language: TypeScript strict mode.
226
+ Styling: Tailwind CSS v4 with CSS variables.
227
+ Imports: use @/ path alias.
228
+ Data: accept via props, never hard-code.
229
+ States: loading, empty, error, normal.
230
+ Accessibility: ARIA labels, keyboard nav, focus management.
231
+ Dark mode: CSS variable overrides.
232
+ ```
233
+
234
+ ### v0 → Production Workflow
235
+
236
+ 1. **Spec** → Define data model, user flow, design tokens
237
+ 2. **Generate** → v0 with 5-block brief for each component
238
+ 3. **Pull** → Add to codebase via CLI
239
+ 4. **Review** → Check TypeScript types, accessibility, theme compliance
240
+ 5. **Wire** → Connect real data sources, auth, API routes
241
+ 6. **Harden** → Loading states, error boundaries, edge cases
242
+ 7. **Deploy** → Vercel preview + production
243
+
244
+ ## Common Pitfalls
245
+
246
+ | Pitfall | Fix |
247
+ |---------|-----|
248
+ | Treating v0 output as production-ready | v0 handles presentation only — you need auth, data, logic |
249
+ | Letting v0 define your data model | Your domain expertise defines the model; v0 adapts |
250
+ | Client-only generation | Plan SSR boundaries; v0 generates client components by default |
251
+ | Not checking shadcn deps before pulling | `npx shadcn info --json` to verify installed components |
252
+ | Generating without design tokens | Set system prompt with CSS variable references |
253
+ | Skipping review | Every v0 component needs human review for correctness |
254
+
255
+ ## Verification
256
+
257
+ - [ ] Generated components use project design tokens (CSS variables, not hard-coded hex)
258
+ - [ ] All components accept typed props (no hard-coded data)
259
+ - [ ] Loading, empty, error states handled
260
+ - [ ] Required shadcn/ui primitives installed (`npx shadcn info --json`)
261
+ - [ ] TypeScript compiles without errors
262
+ - [ ] Keyboard navigation and ARIA labels verified
263
+ - [ ] Light and dark mode both render correctly
264
+ - [ ] Components refactored for reusability (not page-specific)