Evaluating LLM-Generated Frontend Code: Requirements, Acceptance Criteria, and Engineering Practices
This article presents a practical framework for assessing how completely large language models implement frontend requirements. It covers requirement-document-based acceptance, page-type-specific checks for display pages, list pages, and forms, interface-style scoring, engineering usability metrics, and the role of open-weight models. It also provides a human review checklist for using generated frontend code as a draft while managing complex rules and data security risks.
1. Why Systematic Evaluation Is Needed
Large language models can generate code quickly, and the resulting pages often open and run normally. This can easily lead to an incorrect judgment about delivery quality. A page that runs only proves that the syntax is correct and the main path is reachable. Whether the requirements have been fully implemented depends on whether filters actually work, whether constraints between fields are preserved, and whether exception states are handled. These details can only be verified by checking each requirement against the requirement document.
Evaluation should therefore focus on requirement fidelity, not on whether a page can be generated. The following sections provide a reusable method based on page types and engineering metrics.
2. Start with the Requirement Document
Evaluation requires a verifiable requirement document. When requirements are vague, it is difficult to determine whether the result is correct, whether the work is done by a person or a model. It is advisable to break each page’s requirements into the following categories:
- Display content: text, images, carousel count, and transition behavior.
- Data sources: API fields, field types, default values, and empty-value behavior.
- Interaction behavior: interface changes after clicks, input, or switching.
- Constraint rules: required fields, formats, value ranges, and dependencies between fields.
- State transitions: what is displayed during loading, success, failure, and no-data states.
Each item should be convertible into an input-expected output test case. For example, “the phone number must be 11 digits and start with 1” should include at least four input types: a valid value, an insufficient length, letters included, and a first digit other than 1.
3. Design Acceptance Dimensions by Page Type
3.1 Display-Oriented Pages
Login pages and landing pages are primarily display-oriented, and models usually handle their layout and basic components well. Evaluation should focus on details: whether the carousel switches automatically, whether manual paging is supported, whether it returns to the beginning after the last item, and whether hovering pauses it. These details are often written in requirement notes and are easy to overlook.
3.2 List Pages: Filtering and State Synchronization
List pages are where misunderstandings are most likely to surface. Requirements for filters usually include dropdowns, date ranges, keywords, and other types, and these filters may be linked. Acceptance should check the following:
- Whether each filter actually participates in the query rather than only rendering a control.
- Whether multiple conditions produce an intersection when applied together.
- Whether filter conditions remain consistent with pagination and sorting, and are not lost after page changes.
- Whether an empty state is displayed when there are no results, rather than an error or blank area.
Filter definitions can be organized into a structured description for easier comparison:
const filterSchema = {status: { type: 'enum', values: ['enabled', 'disabled'], param: 'status' },createdAt: { type: 'dateRange', param: ['start', 'end'] },keyword: { type: 'string', param: 'q', debounceMs: 300 },};// Check: every schema item should appear in the request parameter construction logicfunction buildQuery(state, schema) {const params = {};for (const key of Object.keys(schema)) {const value = state[key];if (value === undefined || value === '') continue;const def = schema[key];if (def.type === 'dateRange') {params[def.param[0]] = value[0];params[def.param[1]] = value[1];} else {params[def.param] = value;}}return params;}
The code above is not part of the generated result. It is a checking template for evaluation. Comparing it with the request construction logic in the generated code can quickly reveal problems where “the control exists but the parameter is missing.”
3.3 Form Pages: Field Relationships and Validation
The difficulty of complex forms lies in dependencies between fields. For example, “the unified social credit code is displayed only after an enterprise type is selected,” or “the end date cannot be earlier than the start date.” Such rules require the model to understand field definitions, display conditions, and the timing of validation before submission at the same time.
A rule table can be used to check items one by one:
const rules = {phone: [required(), pattern(/^1\d{10}$/)],budget: [required(), min(0), notGreaterThan('maxBudget')],maxBudget: [required(), min(0)],};
Evaluation should confirm three things: whether all rules are implemented; whether validation shows a message next to the failing field or only displays a generic error; and whether the submit button is correctly disabled or blocked when validation fails. In addition, client-side validation only improves the experience. The server still needs to repeat the validation, and this should be listed separately in the evaluation checklist.
4. How to Evaluate Interface Style
Style evaluation can easily become subjective. A more reliable approach is to define standards first and then score each item, for example:
- Whether spacing and alignment are consistent, and whether elements at the same level use the same spacing values.
- Whether colors come from unified theme variables rather than scattered color values.
- Whether font sizes and weights form a hierarchy, and whether headings, body text, and supporting text are distinguishable.
- Whether the states of basic components such as buttons and inputs are complete: default, hover, disabled, and error.
If the team already has design guidelines or a mature component library, that should be used as the baseline for comparison. The gap between generated results and mature templates usually appears in detail consistency and component state completeness, not in the overall layout.
5. Engineering Usability Metrics
In addition to functional completeness, the following engineering metrics should be recorded because they directly affect delivery cost:
- Generation time: the time from submitting requirements to obtaining a runnable result. The same requirement should be measured multiple times and averaged.
- Rework count: the number of additional prompts used to fix unimplemented functionality.
- Code readability: whether component splitting is reasonable, whether state management is centralized, and whether there are large blocks of duplicated code.
- Security baseline: whether secrets are hardcoded in the frontend, whether user input is directly concatenated into HTML, and whether output escaping is missing.
- Dependency list: whether introduced third-party dependencies are necessary and whether their licenses meet project requirements.
When recording these data points, retain the test environment, input document version, and prompt content to ensure the evaluation is reproducible. Otherwise, differences between two comparisons may come from changed inputs rather than from model capability itself.
6. The Engineering Significance of Open-Weight Models
The core value of discussing whether a model is open is controllability. For engineering teams, open weights mean the model can be deployed in their own environment, the inference process can be audited, the model can be adapted to business data, and evaluation can be completed without data leaving the domain. These capabilities are especially important in scenarios with high data compliance requirements, such as finance, healthcare, and government.
At the same time, openness does not automatically mean stronger capability. Evaluating a model still requires returning to the method above: using a unified requirement document, unified test cases, and unified scoring standards to compare different models on the same task. A single experience or subjective impression is not enough to support technology selection.
7. Implementation Recommendations and Human Review Checklist
Frontend code generated by large models is suitable as a first draft, but final delivery requires human review. It is advisable to set the following review points in the process:
- Check constraint rules and state transitions in the requirement document one by one.
- Perform code-level checks on list-page filter parameters and form-page validation rules.
- Add the same validation logic on the server side and do not rely on frontend validation.
- Scan the output to confirm that there are no hardcoded sensitive values and no unescaped dynamic content.
- Turn accepted test cases into regression tests for reuse in later iterations.
Through this process, teams can use the model’s strengths for rapid scaffolding and display-oriented pages while focusing human effort on high-risk areas such as complex rules and data security.
