A Practical Guide to LLM-Driven AI Coding: From Code Snippets to Deliverable Projects

    This article explains why generating code with large language models is not the same as delivering a working project, and presents a transferable workflow for LLM-assisted engineering. Using a wallpaper browsing and AI image generation mini program as the example, it covers turning requirements into architecture and data models, advancing module by module with stable interfaces, keeping generation results controllable through explicit constraints and acceptance checklists, and debugging through minimal reproduction and logs. It also lists common pitfalls and improvements, showing how structured requirements, clear constraints, and upfront acceptance criteria turn an LLM into a conversational full-stack collaborator.

    1. Why “Writing Code” Is Not the Same as “Delivering a Project”

    When teams introduce large language models into AI coding tools, the first impression is usually that generation is fast. In practice, however, projects often get stuck on messy structure, tightly coupled modules, and unclear boundaries. The reason is simple: generating code snippets and delivering a runnable system are capabilities at two different levels. The former focuses on local correctness; the latter depends on overall consistency, maintainability, and extensibility.

    So whether a model is suitable for engineering tasks cannot be judged by single-file generation quality alone. It comes down to three things: whether it can first handle technology selection and architecture breakdown; whether it can advance module by module while keeping interfaces consistent; and whether it can provide a locatable, reproducible fix path when something goes wrong. This article uses a mini program project for wallpaper browsing plus AI image generation as the background to discuss a transferable set of practices.

    2. Step One: Turn Requirements into Architecture, Not Directly into Code

    2.1 Produce the Plan Before Coding

    The efficient approach is to have the model first produce a structured technical plan covering the frontend form, page structure, backend capabilities, data storage, external capability integration, and permission boundaries. Once the plan is confirmed, generating code module by module significantly reduces rework.

    A requirement description template you can reuse:

    1. Goal: build a mini program for image browsing and AI image generation
    2. Frontend: native mini program, three main pages (Home / Create / Profile)
    3. Backend: cloud development stack (cloud database + cloud functions + object storage)
    4. Capabilities: image analysis, prompt optimization, image generation
    5. Constraints: uploads must be compressed, lists must be paginated, keys must not be shipped to the client
    6. Output: architecture and data model first, then code

    2.2 Layered Architecture and Responsibility Boundaries

    It is advisable to split the system into four layers: the presentation layer handles the waterfall layout, previews, and interactions; the interface layer, carried by cloud functions, handles authentication, parameter validation, and rate limiting; the capability layer wraps the calls for image analysis and generation; and the data layer manages metadata and file indexes. The benefit of this split is that replacing the implementation of any layer does not affect the others — for example, switching the image generation approach only touches the capability layer.

    2.3 Define the Data Model First

    Defining collections and fields before writing code is key to avoiding later chaos. For example:

    1. wallpaper(id, title, tags[], size, storageKey, uploaderId, createdAt)
    2. album(id, name, coverKey, itemCount)
    3. task(id, uid, sourceKey, prompt, status, resultKey, createdAt)

    Here, status should use an explicit state machine of “queued — processing — succeeded — failed”, which makes frontend polling and retry on failure straightforward.

    3. Step Two: Advance Module by Module and Keep Interfaces Stable

    3.1 Lists and the Waterfall Layout

    The core of a waterfall layout is not the layout itself but the data rhythm. Agree on a unified response shape so the frontend only handles one form:

    1. { "items": [], "nextCursor": "opaque-token", "hasMore": true }

    Cursor-based pagination instead of page numbers avoids duplicates and misalignment caused by newly inserted data; wrapping lazy loading and placeholders inside the image component reduces first-screen pressure.

    3.2 Upload and Storage

    The recommended upload path is “client-side compression → obtain temporary credentials → upload directly to object storage → write metadata”. Temporary credentials are issued by a cloud function and scoped to a specific directory and validity period, so long-term keys never sit in the client. The compression strategy can be adjusted dynamically based on screen size and network conditions, balancing clarity against data usage.

    3.3 The AI Image Generation Flow

    Break the creation flow into four steps: upload, analysis, editing, and generation. The analysis step returns structured prompts across three dimensions — subject, style, and background; the editing step lets users add or remove keywords while keeping version history; the generation step runs asynchronously as a task, and the frontend retrieves results by querying status. Example task creation logic:

    1. // Cloud function: create a generation task
    2. exports.main = async (event) => {
    3. const { uid, sourceKey, prompt } = event;
    4. const task = await db.collection('task').add({
    5. data: { uid, sourceKey, prompt, status: 'queued', createdAt: Date.now() }
    6. });
    7. // Push to the async processing flow to avoid function timeouts
    8. await queue.push({ taskId: task._id });
    9. return { taskId: task._id, status: 'queued' };
    10. };

    Asynchrony is the key point here: image generation time is unpredictable, and waiting synchronously easily triggers timeouts and duplicate submissions.

    4. Step Three: Make Generated Results Controllable with “Constraints + Acceptance”

    The stability of model output depends largely on how explicit the constraints are. It is recommended to fix four categories of information in the prompt: tech stack and directory structure, interface inputs and outputs, error handling strategy, and prohibited items. For example: “long-term keys must not be shipped to the client”, “all cloud functions must validate parameters”, and “list interfaces must support cursors”.

    At the same time, prepare an acceptance checklist for each module so generated results can be verified objectively:

    • Does pagination remain correct when data is inserted or deleted?
    • Are there retries and messages for weak networks and failed uploads?
    • Can a failed task roll back its status and allow regeneration?
    • Is permission validation enforced on the server rather than only on the frontend?

    5. Step Four: Debugging and Collaboration

    When a problem appears, the most effective way to communicate is to provide a “minimal reproduction + expected behavior + relevant logs”. Have the model locate the issue based on logs and the call chain instead of rewriting whole files on guesswork. For cross-module problems, first have it output the call chain and data flow, then replace implementations segment by segment, which significantly lowers the chance of introducing new defects.

    Engineering practice can also add lightweight guardrails: run static checks and type checks before committing, add a few unit tests on critical paths, and wrap logging and duration tracking uniformly at cloud function entry points, making it easier to spot anomalies later through monitoring and alerting.

    6. Common Pitfalls and Suggested Improvements

    First, asking for all the code at once. The more files involved, the more obvious interface drift becomes, so generate in module batches and verify immediately. Second, describing only features and not constraints. Without security and performance constraints, generated results often “run but cannot go live”. Third, putting keys and business rules on the client. Any logic involving credentials and permissions should be pushed down to the server. Fourth, neglecting state management. Async tasks must have an explicit state machine and idempotent design to avoid duplicate charges or duplicate generation.

    7. Conclusion

    The value of large language models in AI coding is shifting from “completing snippets” to “taking on architecture and collaboration”. What really sets the ceiling on efficiency is whether the user can structure requirements, write constraints clearly, and define acceptance criteria upfront. When the plan, the interfaces, and the acceptance criteria are all in place, the model can reliably act as a “conversational full-stack collaborator” — and the combination of general capabilities such as cloud development, object storage, and monitoring and alerting offered by Baidu AI Cloud also provides a standard pattern for shipping this kind of application.