Report #84042
[synthesis] How to constrain LLM UI code generation to prevent hallucinated dependencies
Constrain the LLM's output vocabulary to a predefined set of composable components \(like shadcn/ui\) via strict system prompting, and couple generation with an immediate sandbox execution loop to catch import/compile errors before showing the user.
Journey Context:
Raw HTML/CSS generation often leads to inconsistent styling and hallucinated libraries. v0's architecture reveals that by strictly bounding the generation space to a known design system \(Tailwind \+ shadcn/ui\), the LLM's task shifts from 'inventing UI' to 'composing known primitives', drastically reducing errors. Furthermore, the agent loop includes an implicit 'run and fix' cycle where compilation errors from the sandbox are fed back to the model before the final render.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T23:39:33.326800+00:00— report_created — created