Evaluating LLM-Generated Frontend Code: Requirement Fidelity and Engineering Acceptance
This article examines how to move beyond demo-level impressions when assessing LLM-generated frontend pages. It explains how to structure page requirements for machine readability, identifies four common failure modes, and presents a four-dimensional acceptance framework with a requirement coverage matrix and page-by-page validation. It also offers practical recommendations for improving generation results and criteria for comparing code-generation tools.
1. From Demo Results to Engineering Acceptance
In the past year, code-generation models have become capable of producing runnable frontend pages in a short amount of time. Such demos can easily create the impression that the output is ready to use directly. However, engineering teams care less about whether a page opens and more about whether it fully implements every constraint in the requirements document. The gap between these two standards determines whether generated results can enter the formal iteration process.
This article uses a real frontend requirement as a sample, summarizes model performance on three typical page types, and presents a reusable evaluation method.
2. Structuring Page Requirements
The quality of the requirements document directly affects generation results. Models can only read text. Once a team’s implicit assumptions are not written down, they may be lost during generation. Requirements should therefore be split into the smallest checkable units.
It is recommended to organize requirements at five levels:
- Page level: page goal, entry path, and access permissions.
- Region level: header, filter area, table area, action bar, and other layout blocks.
- Component level: type, data source, and default value for each component.
- Interaction level: trigger conditions and results for clicks, input, linkage, and navigation.
- Validation level: required rules, format rules, dependencies, and error message text.
Below is an example of how to describe a form field requirement:
Field: Enterprise typeType: RadioOptions: Enterprise / Sole proprietorshipRequired: YesDependency: When "Sole proprietorship" is selected, hide "Enterprise ID" and show "Operator ID number"Validation: Operator ID number must be 18 characters; the last character may be XError message: "Please enter an 18-digit ID number"
The advantage of this format is that each line can correspond to a test case. The disadvantage is that it is costly to write and requires ongoing maintenance by both product and development teams. Teams can use the full format only for high-risk pages and use summary descriptions for other pages.
3. Four Typical Failure Modes
3.1 Missing Filter Logic
Filter conditions on list pages are among the most easily overlooked parts. Filter controls sit above the table and have a state-synchronization relationship with table data. A complete filter implementation includes at least the following elements:
- Rendering of condition controls;
- Combination logic for multiple conditions (AND, OR, range);
- Data requests or local filtering after condition changes;
- Pagination reset and filter state restoration.
In the sample above, generated results usually complete the first two items but tend to miss pagination reset and state restoration. The page looks complete, but during actual operation the filter results do not match the selected options. Such issues are difficult to find through manual scanning and require test-case validation.
3.2 Insufficient Restoration of Form Relationships and Validation
The difficulty of complex forms lies in dependencies between fields. The value of one field may change the display, required state, and validation rules of several other fields. Models are usually accurate when implementing individual fields, but less stable when restoring cross-field relationships.
There are three common manifestations: missing field linkage; validation that checks only format without dependency conditions; and error messages that do not match the required text. These issues do not cause page errors, so they are easy to miss during self-testing.
3.3 Visual Completeness and Engineering Standards
Generated interfaces are generally usable, but they deviate from a team’s existing design standards. Spacing, font size, color, and component variants may all be inconsistent with the standards. If the team already has a mature component library or design tokens, these constraints should be explicitly stated in the generation prompt. Otherwise, the model will define styles on its own, increasing the cost of later merging.
3.4 Generation Time and Queueing
Generating an entire page takes noticeably longer than a single code completion. Queueing and quota limits during peak periods can also interrupt the workflow. Teams should include generation tasks in scheduling, split tasks by page, and avoid submitting an entire requirement at once.
4. Building a Requirement Coverage Evaluation System
Page screenshots alone cannot determine completeness. It is recommended to use four-dimensional scoring and record conclusions separately for each dimension:
| Dimension | Check method | Typical issue |
|---|---|---|
| Functional coverage | Map requirement items to test cases one by one | Filters, buttons, or exports not implemented |
| Interaction consistency | Execute operation paths according to a script | Incorrect linkage or wrong navigation target |
| Validation accuracy | Construct valid and invalid inputs | Missing rules or mismatched error messages |
| Engineering quality | Static checks and structural review | Duplicate code or scattered state |
4.1 Requirement Coverage Matrix
Number requirement items and establish a mapping to test case IDs to form a coverage matrix. An item not covered by any test case is an omission. The logic is illustrated below:
Read requirement list requirements.yamlRead test case list test_cases.yamlFor each requirement item r:If r.id is not in the covers field of any test case:Record as uncoveredOutput: coverage rate = covered item count / total item countOutput: list of uncovered items
Coverage rate alone does not represent quality, but it can quickly expose systematic omissions. If the coverage rate for a certain type of component is noticeably low, the problem is likely in how that component is described. In that case, priority should be given to improving the description rather than reworking pages one by one.
4.2 Page-by-Page Batch Acceptance
Do not wait until the entire system has been generated before starting acceptance. Generate and validate in batches by page so that issues remain localized. After each batch passes, proceed to the next batch, and record the failed items in the current batch to improve subsequent requirement writing.
5. Practical Recommendations for Improving Generation Results
- Requirements first. Complete field-level descriptions before generation to avoid having the model guess business rules on behalf of the business side.
- Fix the technology stack and standards. Specify framework version, component library, directory structure, and naming rules.
- Split tasks. Generate only one page or one module at a time to reduce the risk of context loss.
- Require a self-check explanation. Ask the model to explain, item by item, where each requirement item is implemented in the output, and have a human spot-check whether the explanation is accurate.
- Keep manual review. Logic involving amounts, permissions, or data deletion must be reviewed line by line by a human.
6. Criteria for Tool Selection
The most reliable basis for choosing a generation tool is the result of a horizontal test on the same requirement. It is recommended to focus on the following dimensions:
- Depth of requirement understanding: whether cross-field relationships and implicit constraints are handled correctly;
- Structural completeness: whether every page region has a corresponding implementation;
- Response speed: single-page generation time and queueing conditions;
- Controllability: whether constraint files can fix the technology stack and styles;
- Cost: total cost calculated by number of calls or quota.
The same requirement should be tested multiple times and averaged to reduce the randomness of a single result. For each test, record the requirement version, model version, prompt content, and acceptance conclusion to support reproducibility and comparison.
7. Conclusion
Large models can already complete most of the work involved in building an interface skeleton. The engineering team’s task is to write requirements to a verifiable level and then use coverage rates and layered acceptance to find omissions. Whether generated results can enter the production process depends on this evaluation mechanism, not on the effect of a single demo.
