Building an E-commerce Site with AI Coding Tools: A Practical Guide to Tool Selection, Prompting, and Quality Gates
Choosing among today's AI coding tools is hard because there is no shared benchmark for comparison. This guide proposes a reproducible method: treat "build a complete e-commerce site from zero to one" as a standardized benchmark task, score tools and generation modes on the same dimensions, then apply engineering practices and quality gates to the generated code. It covers benchmark task design, a layered prompt structure with explicit acceptance criteria, six scoring dimensions, generation-mode trade-offs, privacy and compliance checks, common quality problems with concrete remediation patterns (design tokens, mobile-first responsive layout, data-layer abstraction, form validation, empty states), and a four-gate quality pipeline. By combining a fixed benchmark, structured prompts, engineering cleanup, and enforced quality gates, teams can turn AI-generated prototypes into maintainable software.
1. Introduction: Tool Selection Is Hard Without a Shared Standard
AI coding tools have evolved from “autocompleting a few lines” into systems that “understand a natural-language requirement and produce a runnable project.” Many of these tools now offer a range of modes, from single-shot conversation to full project generation. As the number of options grows, so does the difficulty of choosing:
- Too many tools: each has its own strengths, and feature lists are hard to compare directly.
- Too many modes: full generation, conversational generation, multi-agent collaboration — which one to use at which stage is rarely backed by clear criteria.
- Unstable results: the same prompt, run through a different tool or mode, can produce very different quality.
If you draw conclusions from a few ad-hoc trials, the outcome usually depends on how well the prompt was written and a bit of luck. A more reliable approach is to treat “build an e-commerce site from zero to one” as a standardized benchmark task:
- Evaluate different tools and modes with the same prompt.
- Score them side by side on unified dimensions.
- Apply engineering methods to clean up the generated code and bring it under quality gates.
This article breaks down a reusable practice along these lines.
2. Task Design: Why an E-commerce Site Makes a Good Benchmark
A good benchmark task should separate strong tools from weak ones. Generating a single login page is within reach of almost every tool; differences in architecture understanding, context retention, and attention to detail only surface when page count, business flow, and engineering constraints all appear at once.
An e-commerce site happens to satisfy all of these:
- Broad page coverage: lists, details, forms, success pages, a user center, and more.
- A complete flow: from browsing a product to placing an order, forming a closed loop.
- Access control: the user center involves login state and access control.
- Clear engineering constraints: mobile adaptation, form validation, component reuse, and decoupling of data from views.
The resulting benchmark task:
Build an e-commerce shopping site from scratch with a component-based frontend framework, including the following pages:
- Home page (product list with category filtering and sorting)
- Product detail page (main image, price, stock, variants, add to cart)
- Checkout page (shipping information, order confirmation, payment method)
- Order success page (order number, amount, estimated delivery time)
- Login page, registration page
- User center dashboard (order overview, coupons, and points)
- User center orders page (order list with status filtering)
- User center wallet and coupon pack (balance, coupon list)
- User center settings (profile, shipping addresses, change password)
Constraints: mobile-first with responsive adaptation; forms with validation; a closed-loop core flow; data access decoupled from presentation.
3. Prompt Design: Control Generation Quality with Layering and Acceptance Criteria
Most disappointing results stem not from the tool but from how the requirement is expressed. A one-line requirement lacks a page list, data structures, and acceptance criteria, so the model has to guess — and the output varies wildly. Organize prompts in six layers:
- Goal and scope: state what to build and what not to build.
- Tech stack and structure: framework, language, routing approach, directory conventions.
- Page list and routing: list the key features of each page.
- Data model and interactions: entity fields, API contracts, form validation rules.
- Style specification: primary color, spacing, border radius, mobile breakpoints.
- Acceptance criteria: turn “done” into testable conditions.
Example prompt:
[Task] Build an e-commerce shopping site from scratch, including: home page (product listwith category filtering and sorting), product detail page, checkout page, order success page,login page, registration page, user center dashboard, orders page, wallet and coupon pack page,and settings page.[Tech stack] Component-based frontend framework + client-side routing + a type system; nativeCSS for styling; keep state management minimal; keep mock data centralized.[Data model]Product { id, title, price, cover, stock, category }CartItem { productId, quantity }Order { id, items, total, status: 'pending'|'paid'|'shipped'|'done', createdAt }User { id, email, nickname }[Interaction requirements]- Login/registration: email format, password at least 8 characters, validate field by field andshow messages in place;- User center: redirect to the login page when not logged in, and return to the original pageafter login;- Checkout: block submission when stock is insufficient; on success, navigate to the success pageand show the order number.[Style specification]- Primary color #2F6BFF, body text contrast no lower than 4.5:1;- Mobile breakpoint 640px;- Set background color and text color together for buttons; no white text on a white background.[Engineering requirements]- Directories: pages / components / services / stores / styles;- Business data is accessed only through the services layer; components must not reference mockdata directly.[Acceptance criteria]- All 10 pages are reachable;- The full flow "login → browse → detail → checkout → success → view order" works end to end;- No horizontal scrolling on mobile;- Zero type-check and Lint errors.
Two more lessons are worth noting:
- Submit in stages: first ask only for the page skeleton and routing, confirm the structure is correct, then fill in details page by page. Cramming in too many requirements at once tends to crowd the context and drop key points.
- Write to a project description file: record the technical conventions and acceptance criteria in a project description file so the tool reads them every round, reducing repetition and inconsistency.
4. Evaluation Dimensions: Turning “Experience” into Scorable Metrics
Once you have results, score them on six dimensions (1–5 each):
- Task completion: are all pages present, and does the main flow work end to end?
- Runnability: can it start directly, and do errors converge within a few fixes?
- Code quality: is the layering clear, are names consistent, and are style and logic separated?
- UI and interaction: visual consistency, responsive behavior, control contrast, placeholder handling.
- Controllability: can multi-round edits be located accurately, and are context and project conventions preserved?
- Compliance and privacy: is a privacy mode offered (code and context not used for training or retention), and is the generated code’s open-source license compliant?
When scoring, “runnable” and “closed-loop” are the passing line — missing them means an automatic fail; “code quality” and “UI/interaction” determine rework cost and can be weighted more heavily.
Generation Modes: No Absolute Winners, Only Stage Fit
- Full-generation mode: one prompt produces a complete project. Good for cold-starting a project and batch-generating pages, but details are often rough.
- Conversational-generation mode: build page by page and fix things on the fly. Good for refining complex interactions.
- Multi-agent collaboration mode: different roles handle implementation, review, and repair. Good for fixing multi-line errors, but requires clear role boundaries to avoid overlap and clobbering.
A recommended combination:
- Use full generation to build the skeleton.
- Use conversational generation to refine detail pages, forms, and cart logic.
- When a build or test fails, use multi-agent collaboration to locate and fix the issue.
When evaluating modes, use the same prompt, the same benchmark task, and the same acceptance checklist, and repeat at least twice to avoid one-off results skewing the judgment.
Privacy and Compliance: Hard Requirements You Cannot Skip
- Does the code leave your network?: enterprise code may contain core business logic; prefer tools that offer a privacy mode with a clear data-use policy.
- License of generated code: AI-generated snippets may draw on open-source implementations; check license compatibility before commercial use.
- Access path: tools that are reliably accessible in your environment reduce network-related friction for team collaboration, but their stability should still be part of ongoing evaluation.
Baidu AI Cloud, as one of China’s code-focused large-model offerings, provides AI capabilities for development tasks such as code generation, code understanding, and intelligent Q&A. When making a selection, organizations should weigh their own code assets, development workflows, and compliance requirements.
5. Common Quality Issues and Engineering Remediation
AI-generated e-commerce sites often “run but aren’t good enough.” Rather than repeatedly asking the model to “optimize it again,” work through the issues below one by one.
| Common issue | Root cause | Remediation |
|---|---|---|
| Dull, monotonous UI | No design tokens; colors and spacing written ad hoc | Unified design tokens and a component spec |
| Login/registration form deforms on narrow screens | Fixed widths, absolute positioning | Mobile-first layout with a single-column flow |
| No mobile adaptation | Styles derived backward from desktop | Systematize breakpoints; make images adaptive |
| White text on white buttons | Only background color changed, text color not updated | Semantic color tokens with automatic contrast checks |
| Detail page too sparse | Fields not defined in the prompt | Complete the detail information list and fill in empty states |
| Mock data scattered everywhere | Data access not layered | Extract a service layer and switch data sources with an adapter |
1) Establish design tokens so the UI follows a system
Define colors, spacing, and border radius as CSS variables; pages and components reference only semantic variables. This keeps the visuals consistent and makes theme switching quick:
:root {--color-primary: #2f6bff;--color-on-primary: #ffffff;--color-text: #1f2937;--color-text-muted: #6b7280;--color-surface: #ffffff;--color-border: #e5e7eb;--radius-card: 12px;--space-1: 4px;--space-2: 8px;--space-3: 16px;--space-4: 24px;}.product-card {padding: var(--space-3);border: 1px solid var(--color-border);border-radius: var(--radius-card);background: var(--color-surface);}.btn-primary {min-height: 44px;padding: 0 var(--space-4);border: 0;border-radius: var(--radius-card);background: var(--color-primary);color: var(--color-on-primary);font-weight: 600;cursor: pointer;}
2) Mobile-first responsive layout
Write the narrow-screen styles first, then enhance progressively with min-width media queries. This follows the mobile-first principle and avoids the deformations caused by hard-coded dimensions written for wide screens:
.login-form {display: flex;flex-direction: column;gap: var(--space-3);width: 100%;max-width: 400px;margin: 0 auto;padding: var(--space-4);}@media (min-width: 640px) {.login-form {padding: var(--space-4) calc(var(--space-4) * 2);}}
Also follow three rules:
- Use fluid layout; avoid absolute positioning.
- Set
max-width: 100%on images. - Keep clickable elements at least 44px tall.
3) Abstract the data layer: decouple mock data from the UI
Isolate the data source behind a service interface; during integration you only swap the implementation, with no changes to page components:
// types.tsexport interface Product {id: string;title: string;price: number; // unit: cents, to avoid floating-point errorscover: string;stock: number;category: string;}export interface ProductService {list(params: { category?: string; sort?: 'asc' | 'desc'; page: number; size: number }):Promise<{ items: Product[]; total: number }>;get(id: string): Promise<Product>;}// services/mockProductService.ts — mock data implementationconst products: Product[] = [{ id: 'p001', title: 'Wireless Bluetooth Headphones', price: 29900, cover: '/images/p001.png', stock: 50, category: 'Electronics' },// ...remaining product data];export const mockProductService: ProductService = {async list({ category, sort, page, size }) {const filtered = products.filter((p) => !category || p.category === category);const sorted = sort? [...filtered].sort((a, b) => (sort === 'asc' ? a.price - b.price : b.price - a.price)): filtered;return { items: sorted.slice((page - 1) * size, page * size), total: sorted.length };},async get(id) {const product = products.find((p) => p.id === id);if (!product) throw new Error('Product not found');return product;},};// services/httpProductService.ts — real API implementation with the same method signaturesexport const httpProductService: ProductService = {list: (params) => http.get('/api/products', { params }),get: (id) => http.get(`/api/products/${id}`),};// services/index.ts — switch data sources via a flagconst services: ProductService = USE_MOCK ? mockProductService : httpProductService;export const productService = services;
4) Form validation: independent rules, in-place messages
Extract validation rules into a standalone module that each return an error message or null. This makes it easy to validate on field change and to add internationalization later:
// utils/validators.tsexport function required(label: string, value: string): string | null {return value.trim() ? null : `${label} is required`;}export function isEmail(value: string): string | null {return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value) ? null : 'Please enter a valid email address';}export function minLength(label: string, min: number, value: string): string | null {return value.length >= min ? null : `${label} must be at least ${min} characters`;}// combined usage in a page componentconst errors = {email: required('Email', email) ?? isEmail(email),password: minLength('Password', 8, password),};
5) Complete the detail page and empty states
- Information list: main image, price (with original price struck through), stock, variants, delivery notes, product parameters, service commitments.
- Boundary states: loading, no results, request failure (with a retry entry).
- Image resources: store product images on static asset services such as object storage and serve them via a CDN. Components only handle rendering and placeholder fallback — for example, always provide alternative text:
<img src={product.cover} alt={product.title} loading="lazy" />
6. Quality Gates: From “Seems to Run” to “Actually Usable”
Code that runs is not the same as code that is ready to ship. Set up four gates:
- Build gate: type checks, Lint, and unit tests all pass — a mandatory condition for merging code.
- Flow gate: cover core flows with end-to-end tests:
// e2e/checkout.spec.ts (pseudo-code illustrating the core flow)test('complete shopping flow', async ({ page }) => {await page.goto('/login');await page.getByLabel('Email').fill('buyer@example.com');await page.getByLabel('Password').fill('Passw0rd!');await page.getByRole('button', { name: 'Sign in' }).click();await page.goto('/');await page.locator('.product-card').first().getByRole('button', { name: 'Add to cart' }).click();await page.goto('/checkout');await page.getByRole('button', { name: 'Place order' }).click();await expect(page).toHaveURL(/\/checkout\/success/);await expect(page.getByText(/Order number/).first()).toBeVisible();await page.goto('/user/orders');await expect(page.locator('.order-item').first()).toBeVisible();});
- Experience gate: primary-button body text contrast ≥ 4.5:1, or ≥ 3:1 for large text explicitly exempted by the design spec (refer to WCAG 2.x AA); no horizontal scrolling or content occlusion at the 360px, 768px, and 1280px viewports.
- Security gate: inject keys and tokens exclusively through environment variables or a configuration center, never in source code; scan for leaks with a secret-scanning tool before committing; scan dependencies for vulnerabilities on a regular basis.
After all gates pass, a human review is still required. Focus on “runs but problematic” issues:
- Calls to nonexistent or semantically wrong APIs;
- Duplicated utility functions;
- Implicit coupling, such as a component referencing global state directly;
- Missing edge cases, such as an amount of 0 or negative stock.
7. Implementation Advice: Turn Tool Capability into Team Capability
- Build an internal benchmark set: extend the e-commerce site with scenarios close to your own business, such as admin dashboards and form approvals, and run the same scoring when a new tool is introduced.
- Accumulate templates and rules: put project scaffolds, design tokens, prompt templates, and acceptance checklists into an internal knowledge base to reduce repeated trial and error.
- Clarify the human-AI division of labor: AI handles first-draft generation and repetitive edits; humans handle architecture decisions, edge cases, and final review.
- Quantify the payoff: track delivery cycle time, defect density, and the proportion of manual rework, and let data decide whether to roll out a tool.
8. Conclusion
For AI coding tools that are reliably accessible in your environment, tool selection can be reduced to a few controllable questions:
- Task completion and runnability;
- Code quality and UI experience;
- Stage fit for the generation mode;
- Privacy and compliance.
By using “build an e-commerce site from zero to one” as the benchmark task, together with layered prompts, engineering remediation, and four quality gates, development teams can turn AI-generated “usable prototypes” into “maintainable engineering.” Tools will keep evolving, but evaluation methods, design standards, and quality gates are the core assets a team can accumulate over the long term.
