Frontend Code Generation with Chinese LLMs: A Three-Tier Test and Prompt Engineering Guide
This article presents a reproducible three-tier testing method for evaluating whether a large language model is ready for production frontend code generation. It breaks down what agentic coding changes, defines test tiers for static pages, stateful interactive components, and multi-turn refactoring, and provides a scoring rubric, acceptance checklist, prompt structure, common failure modes with tuning tactics, and practical notes on cost, context loading, and engineering integration. Readers will learn how to judge model convergence under pressure instead of relying on a single benchmark score.
1. Why Frontend Code Generation Is Hard to Get Right
AI-assisted programming has entered a more demanding phase, and frontend page generation remains a notoriously difficult scenario. The difficulty is not syntax. It comes from three capabilities that must work together: translating natural language requirements into structured DOM and state logic; making visual decisions about layout, color, and whitespace that match modern design standards; and handling loading, empty, error, and edge-case inputs at the interaction layer. Most models do reasonably well on the first capability but degrade noticeably on the second and third, producing code with rigid structure, cheap-looking color schemes, and no state handling.
For a long time, the industry treated “good taste and relatively few bugs” as the exclusive trait of a certain class of overseas closed-source models, while domestic models were seen as scoring well on benchmarks but feeling weak in practice. That view has been shifting over the past year. With more mature chain-of-thought enhancement, ultra-long context, and tool-calling capabilities, Chinese large models now have the foundation to compete with the first tier in agentic coding. This article does not benchmark any specific product. Instead, it offers a reproducible three-tier testing method so readers can judge for themselves whether the model in hand crosses the production-ready line.
2. What Agentic Coding Actually Changes
The traditional mode is single-turn text generation in a one-question-one-answer loop, where the model never sees the runtime result. The key addition in agentic coding is a feedback loop: the model can retrieve information, execute commands, read errors, and revise code until it passes validation. This loop turns “generating something correct” from a probability problem into an engineering problem of convergence.
In practice, this usually involves four stages: requirement parsing and task decomposition; context loading (project structure, dependency versions, design conventions); execution and observation (build, type check, tests); and self-correction with regression. Understanding this matters because it determines what the prompt should contain. What really affects the success rate is often not polished wording, but whether you feed in the constraints, acceptance criteria, and observable information.
3. Three-Tier Test Design
Tier 1: Single-File Static Page (Basic Fidelity)
The goal is to test layout and visual fundamentals. Provide a requirement description and ask for a single HTML file with inline styles and scripts, with no external resources. Things to watch: whether semantic tags are used, whether flex layout is used instead of stacking fixed pixels, whether the color palette is restrained, and whether responsive breakpoints are included.
Sample requirement snippet:
Generate the hero section of a product landing page:- Left copy area (headline / subheadline / two buttons), right visual area- Stack vertically on mobile, breakpoint at 768px- 1 primary color, 3 neutral levels; do not fill the background with pure black or pure white- Output a single file; do not reference any external resources
Tier 2: Stateful Interactive Component (Logic and Edge Cases)
Add data and state on top of the static page to test logical rigor. Typical tasks are a list with filtering, sorting, and pagination, or a form with validation. The focus is whether the model proactively handles four kinds of edge cases—empty data, failed requests, duplicate submissions, and overflow of very long text—rather than only writing the happy path.
Add a task list to the Tier 1 page:- Support filtering by status and keyword search; filters and search must combine- Empty, loading, and request-failure states must be implemented explicitly- Disable the submit button while a request is in flight; allow retry after failure- Truncate overlong list-item text to a single line with ellipsis and provide a title tooltip
Tier 3: Multi-Turn Refactoring and Engineering (Agentic Loop)
The first two tiers test generation; the third tests convergence. The approach is to append three conflicting constraints in a row—for example, “split into components,” “remove all inline styles and use design variables instead,” and “add type definitions and basic unit tests”—then observe whether the model keeps existing functionality from regressing. This tier best separates “can write code” from “can modify code.”
4. Scoring Dimensions and Acceptance Checklist
A four-dimension score is recommended, 1–5 points each. A total below 16 is not advised for production:
| Dimension | Key Criteria |
|---|---|
| Logical correctness | Zero type-check and build errors; complete edge-case branches |
| Visual aesthetics | Clear hierarchy, systematic spacing, restrained palette, no cheap gradient stacking |
| Interaction completeness | Loading/empty/error states all present; keyboard reachable; visible focus |
| Maintainability | Consistent naming, variables for styles, splittable structure, comments that explain intent rather than restate syntax |
The acceptance step should be automated as much as possible, moving subjective aesthetic concerns forward into design conventions expressed as checkable clauses:
# Example: build + type check + tests as an objective gatenpm run build && npm run typecheck && npm test
5. Advanced Prompt Structure
Stable output does not come from luck; it comes from structure. A five-part structure is recommended: role and artifact constraints, context loading, functional requirements, aesthetic and interaction constraints, and acceptance criteria. Two parts are the most overlooked yet the most rewarding: first, explicit “prohibited items,” such as no external resources and no fixed-pixel layout; second, explicit “failure handling,” requiring the model to list assumptions before producing code when information is insufficient.
[Artifact] Single-file HTML, inline styles and scripts, no external resources[Context] Existing component directory structure is as follows... reuse existing design variable naming[Function] ...(numbered item by item, checkable)[Aesthetics] 3 neutral levels; no more than two kinds each of border radius and shadow; motion duration 150–250ms[Acceptance] Build and type check pass; all three states present; no horizontal scroll at 375px on mobile[When uncertain] First output no more than 5 assumptions, then give the code
6. Common Failure Modes and Tuning Tactics
The first is “over-engineering,” where the model pulls in a huge dependency on its own; the fix is to explicitly constrain the tech stack and file boundaries. The second is “aesthetic drift,” where the palette becomes messy after multiple rounds of edits; the fix is to put design variables into the context and allow only the variable values to change. The third is “silent degradation,” where the model quietly drops a feature when it hits an unsupported capability; the fix is to require item-by-item completion status against the requirement list. The fourth is context pollution, where early constraints are forgotten in a long conversation; the fix is to repeat key constraints every new turn, or start a new session in segments carrying a summary.
7. Cost, Context, and Engineering Integration
Ultra-long context makes “feeding the whole repository” possible, but a more effective approach is layered loading: keep global conventions and the dependency list resident, inject files relevant to the current task on demand, and compress historical conclusions into a summary. This controls token consumption and reduces interference from irrelevant information. If you use a cloud model service, you can store build artifacts in object storage, observe call quality with logging services and monitoring alerts, and use a message queue to smooth peaks, bringing model calls into a regular observability system rather than leaving them scattered across scripts.
8. Conclusion
Whether a model can take on frontend generation should not be judged by a single benchmark score, but by its convergence under the three-tier pressure test: static fidelity shows aesthetics, stateful components show logic, and multi-turn refactoring shows engineering discipline. Tested with the method above, the current first-tier Chinese large models can already produce clear, interaction-complete page code stably in a Chinese-language context and meet the conditions for entering a production workflow. What truly sets the ceiling is no longer the model itself, but the precision of requirement descriptions, the completeness of constraints, and the degree of acceptance automation.
