A Three-Tier Testing Guide for LLM Code Generation and Frontend Aesthetics
This guide presents a three-tier method for evaluating how well large language models generate frontend code. Instead of judging a single flashy output, it tests three levels in sequence: basic usability (does the code run and stay semantically correct), engineering structure (is the code maintainable), and aesthetics and interaction (does the page feel ready to ship). It includes sample prompts, a maintainability scoring table, advanced prompting techniques for iterative convergence, common failure modes with fixes, and advice for teams that want to build reusable evaluation assets. The framework is product-agnostic and works for model selection, prompt tuning, and internal benchmarking.
1. From “It Generates” to “It Ships”: The Real Difficulty of Frontend Code Generation
As agentic coding becomes more common, large language models can already generate page structure, styling, and basic interactions from natural-language descriptions. But once this moves into real engineering work, developers find a clear gap between “generating a piece of code” and “delivering a usable page.” Frontend code generation involves at least four layers of problems: whether the requirement is understood accurately, whether the code runs, whether the structure is maintainable, and whether the visuals and interactions meet a shippable standard.
Traditional one-shot text generation usually solves only the first layer, outputting a piece of seemingly complete code from a prompt. In real projects, however, a page typically involves state changes, form validation, responsive layout, error messages, loading states, empty states, permission differences, and accessibility requirements. Without reflection and verification mechanisms, a model easily produces code that “looks correct but fails at runtime.” So evaluating a model’s frontend code generation ability cannot rest on whether a single output looks impressive; it must rest on stability under multi-turn constraints, error feedback, and iterative correction.
This article proposes a three-tier gradient testing method: the first tier verifies basic usability, the second verifies engineering structure, and the third verifies aesthetics and interaction. The method does not depend on any specific product and can serve as a general framework for team selection, prompt optimization, and internal evaluation.
2. Tier 1: Basic Usability Testing — Confirming the Code “Runs and Is Semantically Correct”
The goal of the first tier is not complex effects but confirming that the model can reliably generate frontend code with complete structure, correct syntax, and runnable core logic. This stage is well suited to single-page tasks, form pages, list pages, or simple dashboards as test samples.
The test input should include four parts: the page goal, the functional scope, the technical constraints, and the acceptance criteria. For example:
Generate a task board page.Functional requirements:1. Show three task columns: To Do, In Progress, Done;2. Support adding tasks;3. Support switching task status;4. The page stacks vertically on narrow screens.Technical constraints:1. Use semantic tags;2. Do not rely on external resources;3. Keep styles scoped;4. Avoid global pollution.Acceptance criteria:1. The page runs directly;2. Adding and status switching work;3. No layout overflow.
This stage focuses on three kinds of metrics. The first is syntax correctness, including whether tags are closed, scripts execute, and style declarations are valid. The second is logical closure, meaning whether key paths such as add, delete, switch, and validate are complete. The third is boundary handling, such as whether empty lists, duplicate submissions, and invalid input get basic feedback.
If the model frequently shows missing structure or broken logic at the first tier, later aesthetic optimization has limited value. In that case, adjust the prompt first: split complex requirements into several smaller tasks, and ask the model to output a structure description before the code.
3. Tier 2: Engineering Structure Testing — Evaluating Whether the Code Is Maintainable
The second tier focuses on whether the code is fit to enter a real project. A page that runs is not enough; if all logic is piled into one file, style naming is chaotic, and state management is untraceable, it has no engineering value. This stage should ask the model to output a clear file organization and explain each module’s responsibility.
A prompt like this can be used:
Refactor the task board above into a maintainable structure.Requirements:1. Split components by responsibility;2. Separate data from view;3. Define clear style scope;4. Provide a directory description;5. Each module has a single responsibility.
The evaluation focuses on whether component boundaries are clear, whether state is managed centrally, whether styles avoid conflicts, whether event handling is traceable, and whether there is a large amount of duplicate code. An illustrative directory could look like this:
src/components/TaskBoard/TaskItem/TaskForm/state/taskStore/styles/theme/utils/validation/
At this stage you can use a “maintainability scorecard” for quantified observation, for example:
| Dimension | What to observe | Score |
|---|---|---|
| Component split | Separated by responsibility | 1-5 |
| State management | Traceable and recoverable | 1-5 |
| Style isolation | Avoids global pollution | 1-5 |
| Naming convention | Semantically clear | 1-5 |
| Extensibility | Low cost to add fields | 1-5 |
The value of the second tier is exposing whether the model has an “engineering mindset.” Excellent output not only generates a page but also proactively considers future extension, such as how to add task types, add filter conditions, or swap static data for backend data.
4. Tier 3: Aesthetics and Interaction Testing — Judging Whether the Page Has Delivery Quality
The third tier is the key to distinguishing “usable” from “pleasant to use.” Frontend pages ultimately face users, and visual hierarchy, whitespace, color, motion, and feedback all affect the experience. This stage should not simply ask the model to “generate a beautiful page”; it should break aesthetics into verifiable constraints.
Design the test across five dimensions:
- Visual hierarchy: whether the main title, action buttons, and content cards have clear priority.
- Layout rhythm: whether spacing, alignment, and grouping are reasonable and avoid crowding.
- Color control: whether a limited palette is used and cheap, high-saturation colors are avoided.
- Interaction feedback: whether clicks, submissions, and status switches give immediate feedback.
- Accessibility: whether color contrast, focus states, and keyboard operation are considered.
The prompt can be written as:
Improve the visual and interactive quality of the task board.Requirements:1. Use a restrained palette of no more than three primary colors;2. Strengthen card hierarchy and whitespace;3. Provide feedback for add, delete, and status switch;4. Support keyboard focus;5. Avoid excessive animation.
At this stage, differences in model output are clearly amplified. Some models produce structurally correct but visually stiff pages; others proactively use gradient backgrounds, soft shadows, micro-interactions, and status hints to make the page closer to a mature product. Note that aesthetics are not better when more complex. Excessive decoration, meaningless animation, and low-contrast text all reduce usability. So the third tier should hold to the principle that “aesthetics serve the task.”
5. Advanced Prompting: From Single Generation to Iterative Convergence
The three tiers are not run in isolation; they should form a closed loop through prompt iteration. A recommended approach is “role constraints + step-by-step output + self-check list.”
Role constraints define the model’s output style:
You are a senior frontend engineer who values semantics, maintainability, and interaction detail.
Step-by-step output reduces complexity:
First output a page structure sketch, then the component split, then the code, and finally the self-check results.
A self-check list prompts the model to find problems on its own:
After outputting, check:1. Are there any unclosed tags;2. Is there any global style pollution;3. Do all buttons have feedback;4. Are empty and error states considered;5. Is narrow-screen layout supported.
This approach effectively reduces the cost of “generate once, rework repeatedly.” For complex pages, you can also follow the order “skeleton first, then styles, then interactions.” First have the model generate the structure and data model, then add visual styles, and finally add state feedback. Keep a human confirmation point at each step to avoid accumulating errors.
6. Common Failure Modes and Fixes
In real testing, common problems in LLM-generated frontend code include style drift, missing interactions, overly complex structure, poor fit for the Chinese-language context, and chaotic state management.
For style drift, add design constraints such as a defined spacing system, a border-radius range, and a palette count, and ask the model to output a style-variable description. For missing interactions, explicitly list all states in the prompt: default, loading, success, failure, and empty. For overly complex structure, ask the model to satisfy a minimum viable version first, then extend step by step. For the Chinese-language context, specify the copy style, number format, date display, and empty-state wording. For chaotic state management, ask the model to define the state model first, then generate the view.
7. Team Adoption: Building Reusable Evaluation Assets
If a team wants to evaluate code generation ability over the long term, it should accumulate three kinds of assets. The first is a test-sample library covering common scenarios such as forms, lists, boards, detail pages, and settings pages. The second is a scorecard that quantifies runnability, maintainability, and aesthetics/interaction separately. The third is a prompt-template library that turns effective constraints into team standards.
At the same time, generated code still needs automated checks and human review. Automated checks can cover syntax, formatting, duplicate code, and basic rules; human review focuses on experience details and business semantics. Through this layered mechanism, large models can shift from a “demo tool” to “stable productivity.”
Overall, the core of the three-tier gradient testing is not finding the single “strongest model” but building an explainable, reproducible, and iterable evaluation method. When a team can clearly define what “runnable,” “maintainable,” and “aesthetically acceptable” mean, improving code generation ability turns from an occasional experience into an engineering capability.
