Evaluating LLMs' Requirement Fidelity in Frontend Code Generation

    Large language models can generate frontend pages far faster than manual coding, but speed alone does not guarantee that every requirement in a specification is correctly implemented. This article breaks down "requirement fidelity" into six measurable dimensions, analyzes three typical failure patterns (scattered filter conditions, cross-field form rules, and missing edge-case states), and provides practical methods for structuring requirement documents, building acceptance test checklists, and establishing a reliable engineering workflow for LLM-assisted frontend development.

    1. Why Requirement Fidelity Deserves Its Own Evaluation

    Large language models now generate frontend pages significantly faster than a human can write them by hand. What used to take days—turning a requirement document into a working page prototype—can now be done in under an hour. But speed is only one side of the story. What teams really care about is whether the output matches every clause in the requirement document: Are any features missing? Are all fields present? Are validation rules correct? Do interaction details behave as expected?

    These questions fall under what we call requirement fidelity: the model’s ability to extract functional points from natural-language descriptions, understand constraint relationships, and implement those constraints accurately in code. A page that looks complete does not mean the requirements are fully implemented. A correctly laid-out list page without its filter conditions prevents users from performing the most basic search operation.

    Therefore, evaluating LLM-assisted development cannot stop at “does the page run?” Each requirement must be verified against the document item by item. The following sections cover five aspects: evaluation dimensions, typical failure patterns, document structuring, acceptance testing, and the recommended engineering workflow.

    2. Breaking Down the Evaluation Dimensions

    Requirement fidelity for frontend pages should be split into six quantifiable dimensions, scored individually, rather than relying on impressions like “looks fine.”

    2.1 Page Structure Completeness

    Check whether all page modules are present: top navigation, search area, data table, pagination, action buttons, and so on. Structural completeness is a baseline requirement, but it only shows the model understood the visual skeleton of the page.

    2.2 Functional Coverage

    This is the most critical metric. Every function explicitly described in the requirement document—filtering, sorting, batch operations, export—should map to a checklist item. Coverage is calculated as: implemented functional points divided by total functional points in the document.

    2.3 Fields and Data Relationships

    In forms and detail pages, fields often have interdependencies. For example, the “Tax ID” field only appears when “Enterprise Customer” is selected; an amount must be greater than zero; an end date cannot precede a start date. These rules are scattered across different paragraphs of the document and are the easiest to miss.

    2.4 Interaction and State Details

    This includes loading states, empty-data messages, disabling buttons during submission, error message placement and wording, and redirect or refresh behavior after a successful operation. These details are rarely in the main requirement narrative but directly affect usability.

    2.5 Visual and Engineering Standards

    Check whether spacing, colors, and font sizes are consistent, whether components are reused sensibly, and whether the code structure supports future maintenance. Visual quality and requirement fidelity are separate concerns and should be scored separately so that one defect doesn’t distort the overall conclusion.

    2.6 Delivery Efficiency and Stability

    Record generation time, the number of failed retries, and reproducibility. If the same requirement produces substantially different results across multiple generations, the team needs stricter input specifications or more frequent human review.

    Below is a simplified scoring example on a 5-point scale:

    Dimension Weight Score Notes
    Page structure completeness 10% 4 Main modules present; minor layout adjustments needed
    Functional coverage 30% 3 Some filters and batch operations missing
    Fields and data relationships 25% 2 Conditional fields and cross-field validation incomplete
    Interaction and state details 15% 3 Loading state present; error message placement inconsistent
    Visual and engineering standards 10% 3 Usable, but low component reuse
    Delivery efficiency and stability 10% 3 Slow generation; inconsistent results across runs

    Weights should match business risk. For pages involving payments, permissions, or data submission, the weight of fields and data relationships should be higher than visual standards.

    3. Analysis of Typical Failure Patterns

    Based on hands-on validation across multiple page types, LLM requirement-fidelity issues fall into three categories.

    3.1 Filter and Query Features Are Easily Missed

    Filter conditions on list pages are usually scattered across multiple paragraphs. For example, a document may mention a search box in the “Page Overview,” describe dropdown filters in the “Interaction Notes,” and list status enumerations again in “Field Definitions.” If the model only extracts the main description from the overview, it will implement just the search box and miss the remaining filters.

    The root cause is information dispersion. The model must integrate information across paragraphs, and the way the requirement document is organized determines how hard that integration is.

    3.2 Complex Form Field Relationships Are Hard to Reproduce

    The difficulty in form pages is not the number of fields but the relationships between them. Common cases include:

    • Conditional visibility: a field appears only when another field has a specific value.
    • Linked assignment: selecting an option auto-fills other fields.
    • Cross-field validation: two or more fields must be combined to determine validity.
    • Asynchronous validation: e.g., a uniqueness check that requires a backend API call.

    Models generally handle single-field validation rules well, but their fidelity drops for cross-field logic and conditional branches. As the number of rules grows, the probability of omissions rises noticeably.

    3.3 Non-Main-Flow Interaction Details Are Ignored

    Requirement documents usually describe the happy path in detail and rarely cover exception flows: network failures, insufficient permissions, empty data, duplicate submissions. When the model fills in these states based on “common practice,” it tends to use generic wording that doesn’t match business requirements.

    In addition, model output is non-deterministic. Generating from the same document multiple times can produce different missing items. A single generation therefore cannot represent the model’s stable capability—evaluation should sample multiple runs and use the average or the worst case.

    4. Improving Fidelity with Structured Documents

    How the requirement document is written directly affects fidelity. Natural-language paragraphs work well for background and goals, but not for carrying large volumes of precise constraints. We recommend splitting requirements into “narrative + structured specification,” with the structured part expressed as tables or pseudo-code.

    4.1 Page Inventory

    First, list the pages and their entry relationships, clarifying each page’s purpose.

    1. pages:
    2. - id: product-list
    3. route: /products
    4. entry: Sidebar > Product Management
    5. - id: product-create
    6. route: /products/new
    7. entry: Product List > Create button

    4.2 Filter and Query Specification

    Write each filter condition as an independent entry, including type, options, default value, and trigger behavior.

    1. filters:
    2. - name: Product status
    3. type: single-select
    4. options: [Active, Inactive, Draft]
    5. default: All
    6. on_change: re-query, reset page number to 1
    7. - name: Created time
    8. type: date-range
    9. default: No limit
    10. on_change: re-query, reset page number to 1

    4.3 Field and Validation Specification

    The field table should include field name, type, required flag, display condition, and validation rule. Cross-field rules are listed separately.

    1. fields:
    2. - name: Customer type
    3. type: enum
    4. options: [Individual, Enterprise]
    5. - name: Tax ID
    6. type: string
    7. visible_when: Customer type == Enterprise
    8. required_when: Customer type == Enterprise
    9. rule: 15 to 20 alphanumeric characters
    10. cross_rules:
    11. - name: End date
    12. rule: End date >= Start date
    13. message: End date cannot be earlier than start date

    4.4 State and Exception Descriptions

    For each page, list the key states: loading, empty data, request failure, no permission, submitting. For each state, specify what is displayed and which actions are available.

    Structured writing has two benefits. First, it reduces the model’s burden of extracting information from long paragraphs. Second, it provides a direct basis for acceptance checks. The more precise the document, the more objective the acceptance judgment.

    5. Building an Acceptance Test Checklist

    Acceptance should use the requirement document as the baseline, converting every constraint into an executable or manually verifiable test case.

    5.1 Test Case Template

    Each case includes an ID, preconditions, steps, expected results, and actual results.

    1. case_id: LIST-003
    2. title: Product status filter
    3. precondition: The list contains data in both Active and Inactive states
    4. steps:
    5. 1. Open the product list page
    6. 2. Set "Product status" to "Inactive"
    7. expected:
    8. - The list shows only Inactive products
    9. - The page number resets to page 1
    10. - URL parameters update accordingly
    11. actual: to be filled in

    5.2 Coverage Statistics

    Count cases and passes by document section. For example, if the list-page module has 12 cases and 9 pass, coverage is 75%. Pages below the agreed coverage threshold should not enter the delivery pipeline.

    5.3 Combining Automation with Manual Review

    Suitable for automated checks:

    • Required-field and format validation
    • Mapping between API parameters and page fields
    • Request parameters after filter changes

    Require human judgment:

    • Whether wording fits the business context
    • Whether visual hierarchy is reasonable
    • Whether exception-flow UX is acceptable

    Test scripts themselves may also be generated by the model, so they need human review as well—otherwise you risk “using incorrect tests to validate an incorrect implementation.”

    LLM-assisted frontend development should be broken into the following steps, each with explicit pass criteria.

    1. Structure the requirements: Organize the document using the methods in Section 4, ensuring every functional point has a corresponding specification entry.
    2. Generate and record: Generate the page code, and record the version, elapsed time, and the input document’s version number for reproducibility.
    3. Static checks: Run type checking, linting, and the build process to confirm the code compiles.
    4. Requirement cross-check: Go through the test case checklist item by item and mark missing items.
    5. Targeted fixes: For each missing item, issue a more precise modification instruction, or have a developer fix it directly. Then re-run step 4.
    6. Human review: Product and engineering jointly review interaction details and business rules.
    7. Regression and archiving: Add passed cases to the regression suite, and feed issues found in this round back into the requirement template to continuously improve document quality.

    In step 5, how the modification instruction is written significantly affects the outcome. Each instruction should describe only one defect and state the expected behavior—for example: “The list page is missing the product status filter. Add a single-select dropdown in the search area with options Active, Inactive, and Draft, defaulting to All.” Vague instructions like “improve the list page” typically perform poorly.

    7. Applicable Boundaries and Team Recommendations

    Based on the analysis above, LLM-generated frontend pages deliver the most value in these scenarios:

    • Standard list and detail pages in admin/back-office systems
    • Prototype validation and internal tools
    • Pages with repetitive structure and simple business rules
    • Scaffolding and base component initialization

    Stricter human oversight is needed in these scenarios:

    • Forms involving monetary calculation, permission control, and data submission
    • Complex business flows with heavy cross-page state sharing
    • Public-facing pages with strict brand and visual requirements

    When adopting this approach, teams can start by building a small benchmark set: pick three to five representative pages—covering a simple list, a complex form, and a page with exception flows—freeze the requirement document version, and re-evaluate periodically. Benchmark data answers two key questions: Is the model’s capability improving across versions? And is the team’s document writing style actually improving fidelity?

    In conclusion, LLMs already offer practical value in frontend development, but their requirement fidelity has clear structural weaknesses—concentrated in scattered filter conditions, cross-field rules, and exception states. Teams should focus their effort on three things: structuring requirements, measuring coverage, and human review—rather than judging by the appearance of a single generated page.