Page Development with AI Coding Tools: Write the Design Spec First, Then the Code

    AI coding tools often drift when asked to build a page from a vague prompt. This guide shows why the drift happens and how to fix it: produce a design spec before any code. It covers a ten-question design brief, a reusable prompt template, how to extract neutral rules from reference material, a seven-step workflow from intent to acceptance, design tokens in CSS, semantic markup and state coverage, and iteration anti-patterns. The result is steadier output and faster reviews.

    1. Where things go wrong: why AI coding tools drift when asked to build a page directly

    When engineers ask an AI coding tool to build a page, they usually jump straight to the coding step with a vague instruction such as “make a nice-looking landing page.” That instruction is missing three dimensions: what information the page is supposed to deliver, who will be looking at it, and what visual reference frame it should sit close to. The tool can only infer from an “average taste” distribution inside general training data, and the output typically shows the following characteristics:

    • The structure looks complete, but information priority is unclear and the first screen has no obvious primary action;
    • Colors and typefaces are safe, generic choices with no expression that matches the tone of the content;
    • Components share no consistent rules for spacing, corner radius, or hierarchy, so the style drifts after any local change;
    • Motion and interaction feedback are either missing or piled on excessively.

    It is worth stressing that none of this is a capability gap in the tool. It is goal drift caused by insufficient input. Page development is essentially constraint solving: only when business intent, audience cognition, reference coordinates, and acceptance criteria are made explicit does the tool have a stable basis for generation. The practical order should therefore be adjusted — produce the design spec document first, then produce the page code.

    2. A question checklist for the design spec

    The design spec does not need to read like a formal standards manual. Its value lies in surfacing implicit decisions. The following nine categories form the minimum viable set: the first four decide direction, and the last five decide implementation details.

    1. What must this page communicate

    State the single core proposition of the page in one to three sentences — for example, “help a visitor understand this product’s differentiating capability within ten seconds and leave a contact address.” Also list the three pieces of information you want a visitor to remember after leaving, ordered by priority. If you cannot state that priority, the layout will inevitably spread emphasis evenly.

    2. Who is the audience

    Describe the audience’s technical level, usage context, and concerns. For senior engineers, parameters, performance limits, and integration options matter more than emotional copy. For procurement or business decision makers, cost structure, delivery timeline, and risk control matter more. The audience definition directly determines term density and the type of evidence you need.

    3. What to learn from the reference

    Break the reference down into transferable, concrete properties rather than a whole impression. Say explicitly “learn its grid rhythm,” “learn its heading-to-body font size ratio,” “learn its whitespace proportion,” “learn how it handles button hierarchy.” The finer the granularity, the more controllable the output.

    4. What not to learn from the reference

    Equally important, and often overlooked. Write down things like “do not copy its stacked gradients,” “do not copy its screen-filling decorative illustrations,” “do not copy its form layout with excessive information density.” Negative constraints are an effective way to suppress templated output.

    5. How colors are determined

    Produce a semantic palette instead of scattered color values: a primary color for the core action, a secondary color for supporting emphasis, neutrals carrying large backgrounds and text hierarchy, and status colors for success, warning, and error feedback. Also state a contrast requirement so body text against its background clears a readability threshold.

    6. What the typography feels like

    Replace abstract adjectives with perceptible descriptions, such as “neutral, restrained, slightly engineering-oriented” or “headings slightly tight, body line spacing loose.” Then translate that into concrete rules: the font size scale, line height, maximum line width, and the weight difference between headings and body text.

    7. How the first screen is arranged

    The first screen serves one goal; it is not a pile of content. Use a four-part structure — “one value proposition + one line of supporting explanation + one primary action + one visual anchor” — and state the reflow strategy for narrow screens.

    8. How buttons and cards are built

    Define a three-tier button system (primary action, secondary action, text-link-style action) and specify five states: hover, focus, pressed, disabled, and loading. For cards, define padding, corner radius, and when to use a border versus a shadow, plus the criterion for “when to use a card and when a divider alone is enough.”

    9. How far motion should go

    Give an explicit upper bound, for example “used only to signal state changes and hierarchy, with durations in the range of two hundred milliseconds, respecting the system’s reduced motion preference.” The purpose of motion is to explain relationships, not to create surprise.

    10. Which “machine-flavored” patterns to avoid

    Writing high-frequency failure patterns into a blacklist noticeably raises the quality of the finished page: meaningless three-column icon-and-slogan blocks, feature lists with equal-length paragraphs, centered oversized empty headings, decorative gradient blocks, every section wrapped in the same card, and benefit statements with adjectives but no numbers.

    3. A prompt template you can reuse

    Turning the checklist into a prompt is the key to whether a team can keep using this method long term. The template below can be pasted and used as is:

    1. First help me put together a DESIGN.md, written so that non-technical teammates can follow it. Do not pile on jargon.
    2. It needs to cover:
    3. 1. The core proposition of this page (no more than three sentences)
    4. 2. The target reader and what they care about
    5. 3. Three concrete properties to learn from the reference material (grid / type scale / whitespace / buttons, etc.)
    6. 4. Three things you explicitly must not learn from the reference material
    7. 5. A semantic palette: primary, secondary, neutral, status colors, with contrast requirements noted
    8. 6. A description of the type feel, plus the font size scale, line height, and maximum line width
    9. 7. First-screen structure: value proposition, supporting explanation, primary action, visual anchor, plus the narrow-screen reflow strategy
    10. 8. The three-tier button system and five states; when cards are used and when they are not
    11. 9. Motion scope and the duration upper bound
    12. 10. A list of "machine-flavored" patterns to avoid
    13. After you finish DESIGN.md, stop and wait for my confirmation before moving to the implementation stage.

    Do not skip the confirmation step. Once the design spec is casually expanded into page code by the tool, rework costs multiply.

    4. Three categories of reference material, and how to neutralize them

    The quality of your reference material sets the ceiling on generation quality. Sort it by how directly it can be acted on, into three layers.

    The first category is a structured style collection, whose distinguishing feature is that it hands you reusable rule fragments directly, including palette, typography, and layout constraints. The way to use it is to pick the single collection closest to your content’s tone, take its rule sections in full, then append your own business constraints. This category is the most efficient, but watch out for ending up too similar to the source; take the rules, not the layout.

    The second category is design system and component documentation, whose value lies in state definitions and accessibility conventions. The way to use it is to extract its spacing system, control states, and semantic markup conventions, and use those as the baseline for implementation.

    The third category is real pages from comparable products: the most authentic information, and also the noisiest. Handle it by stripping: describe only the structure and hierarchy you observe, and do not cite recognizable brand marks, assets, or copy. When the material needs to be handed to the tool, convert it into an abstract description instead — for example, “the three-part first screen common on enterprise service sites” — so that external brand information never enters the generation context.

    Whatever the category, it is worth consolidating everything into internal structured reference files that note the source type, the transferable properties, and the forbidden properties. That turns it into an asset that accumulates rather than something you go hunting for every time.

    5. A seven-step workflow from intent to acceptance

    To turn the method into an engineering process, break it into seven stages, each with a clear deliverable:

    1. Intent clarification: produce a one-page statement of goals and audience, including the core proposition and three key messages.
    2. Reference abstraction: produce a property-level reference summary in two columns, “to learn” and “not to learn.”
    3. Design spec sign-off: produce a structured design spec document, confirmed by both design and business.
    4. Structural skeleton generation: generate only semantic structure and text hierarchy first, with no styles, and confirm the information priority.
    5. Style implementation: inject the palette and the font size scale as semantic variables; hard-coded concrete values inside components are not allowed.
    6. State and responsive completion: fill in interaction states, narrow-screen reflow, and the loading and empty-data cases.
    7. Visual and accessibility acceptance: check the spec point by point, focusing on contrast, visible focus, and keyboard reachability.

    The variable constraint in step 5 is especially important. With design tokens managed centrally, a local change by the tool will not break overall consistency:

    1. :root {
    2. --color-primary: #2b6cff;
    3. --color-primary-hover: #1f57d6;
    4. --color-text: #1a1d23;
    5. --color-text-muted: #5b6270;
    6. --color-surface: #ffffff;
    7. --color-border: #e6e8ec;
    8. --space-1: 4px;
    9. --space-2: 8px;
    10. --space-3: 16px;
    11. --space-4: 24px;
    12. --space-6: 48px;
    13. --font-size-body: 16px;
    14. --font-size-h3: 24px;
    15. --font-size-h1: 40px;
    16. --line-height-body: 1.7;
    17. --radius-md: 8px;
    18. }

    The component layer references variables only, avoiding magic numbers:

    1. .card {
    2. padding: var(--space-4);
    3. border: 1px solid var(--color-border);
    4. border-radius: var(--radius-md);
    5. background: var(--color-surface);
    6. }
    7. .btn-primary {
    8. padding: var(--space-2) var(--space-4);
    9. border: 0;
    10. border-radius: var(--radius-md);
    11. background: var(--color-primary);
    12. color: #fff;
    13. transition: background-color 180ms ease;
    14. }
    15. .btn-primary:hover {
    16. background: var(--color-primary-hover);
    17. }
    18. .btn-primary:focus-visible {
    19. outline: 2px solid var(--color-primary);
    20. outline-offset: 2px;
    21. }

    6. Semantic markup and state completeness

    Whether the output is reliable depends largely on whether the document structure is semantically correct and whether non-ideal states are covered. State the following requirements explicitly in your instructions:

    • Use semantic tags to organize content, never skip heading levels, and keep exactly one main heading per page;
    • Prefer native controls for interactive elements so that keyboard operation and visible focus come for free;
    • Give images meaningful alternative text, and mark purely decorative elements as ignorable;
    • Cover four edge cases: loading, empty data, error feedback, and very long text;
    • Give forms explicit labels and error association hints, rather than relying on color alone to distinguish state.

    Raising these requirements at the generation stage costs far less than patching them afterward. Error and empty states in particular will usually not be filled in by the tool unless you list them explicitly.

    7. Iteration strategy and common anti-patterns

    When iterating, follow the order “structure first, then density, then decoration.” Make one class of change request at a time, and ask the tool to state which files the change affects, so you avoid large-scale indiscriminate rewrites. If the result drifts, go back and add the missing constraint to the design spec rather than repeatedly fine-tuning at the code level.

    Anti-patterns worth avoiding include: skipping the design spec and generating straight away, piling adjectives into the instructions with no quantified standard, raising a dozen interlocking change requests at once, and treating visual acceptance and functional acceptance as the same exercise. The first three lead to uncontrollable output; the fourth makes it hard to locate problems.

    8. Closing: the minimum actionable change

    If you change only one habit, make it this: split “build a page” into “write the design spec first, then build the page.” The gains accumulate — the design spec becomes a team asset, the reference summaries become a searchable knowledge base, and the design tokens become a baseline that stays consistent across projects. When the constraints exist as documents, an AI coding tool shifts from “guessing the page you want” to “implementing a solution according to your rules,” and both output stability and review efficiency improve noticeably.

    For a team, the path to adoption can be light: start with one page, use the ten-question checklist to produce a first version of the design spec, confirm it, and only then move to implementation. After two rounds, harden the constraints that worked into the template and gradually extend them to a component library and a multi-page site. The tools will keep evolving, but the ability to state intent clearly remains the upstream variable of engineering quality.