Engineering an E-Commerce One-Click Virtual Try-On Skill: A Complete Tutorial

    This article explains how to turn a one-click virtual try-on workflow for e-commerce visual production into an installable Skill project. It covers a three-layer structure of a skill file, reference documents, and a single-file HTML demo; mutually exclusive and verifiable reference-image roles; bilingual prompt assembly with grouped negative constraints; a seven-dimension quality gate with three-state results and targeted retries; default direct generation with adapters added only on demand; shot-plan templates for batch production; packaging; and capability and compliance boundaries. Readers will get a practical engineering blueprint they can reuse across compatible Agent frameworks.

    1. Background: Why Ad Hoc Conversations Cannot Support Long-Term Work

    In e-commerce visual production, one-click virtual try-on is a high-frequency, repetitive, and tightly constrained task. The inputs are a model reference image, a garment product image, and optionally a pose image and a scene image; the output is an on-model outfit image that can be used directly for main images, detail pages, or social-style content. Many teams start by opening a temporary session in an AI platform and describing the requirements repeatedly in natural language. This works well for validation, but once the task enters daily production, three structural problems appear.

    First, context cannot be persisted. When a temporary session is closed, cleared, or expired, the tuned prompt structure, negative constraints, and lessons from failures are all lost, so the next day starts from scratch. Second, the workflow cannot be reused. Try-on is actually a pipeline: asset analysis, visual planning, prompt assembly, image generation, quality inspection, targeted retries, and delivery. Operations scattered across a conversation cannot be executed reliably. Third, the capability cannot be ported. The business often needs to switch between different Agent frameworks or runtime environments, and an approach bound to a single session cannot move with it.

    The right approach is to abstract the task as a Skill project: a structured skill description defines inputs, outputs, and constraints; reference documents carry shot planning and the generation interface contract; and a lightweight HTML page connects the interaction. From a neutral technical perspective, this article presents an engineering solution that can be implemented directly, with stronger emphasis on the quality gates and safety boundaries that are easy to overlook.

    2. Overall Architecture: A Three-Layer Structure of Skill, Reference Documents, and HTML Demo

    An installable Skill project should be split into three layers.

    The first layer is the main skill file, which declares capability boundaries, execution steps, and hard rules. It is usually written in Markdown with a semantic name such as SKILL.md. It is the single authoritative source the Agent reads to decide whether the task can be done, how to do it, and when to refuse.

    The second layer is the reference document directory, for example references/shot-plans.md and references/api-reference.md. The former holds shot-planning templates for different e-commerce scenarios; the latter describes the calling contract of the image generation capability, including inputs, outputs, and error-code semantics. Keeping volatile details in reference documents while the main file retains only stable rules significantly reduces maintenance cost.

    The third layer is the demo and integration layer: a single-file HTML page. It carries no business logic. It only collects the four asset types, displays generated results, presents quality inspection conclusions, and offers a helper to copy prompts with one click. This makes it easy for non-engineers to use and lets developers run an end-to-end demo without a complete backend.

    The three layers are connected by explicit contracts: the HTML produces structured input, the Skill consumes the input and executes the workflow, and the reference documents supply variable parameters and shot templates.

    3. Core Design 1: Reference Image Roles Must Be Mutually Exclusive and Verifiable

    The most common failure in one-click try-on is mixing the roles of different reference images, which lets the model improvise. Engineering practice must fix each role in writing and validate it before execution.

    • Model reference image: locks only the person’s identity, including facial features, hairstyle, skin tone, and body proportions. Changes to the facial structure are not allowed.
    • Garment product image: locks only the style, color, fit, and fabric texture, including pattern placement and structural details such as buttons and zippers. Changes to the cut are not allowed.
    • Pose image (optional): controls only the action and composition, including stance, hand position, and camera angle. It must not affect identity or garment style.
    • Scene image (optional): controls only the environment and lighting, including background, ground, weather, and time of day. It must not introduce extra people or brand elements.

    Hard rule: if the model image or the garment image is missing, the process must terminate immediately and ask for the missing asset. Fabricating a person or using default assets is strictly forbidden. This must be written in the main file as an imperative statement, for example: “Return an error immediately when a required input is missing; do not continue generation.”

    Add front-end validation in the HTML layer: disable the generate button when either required asset is empty, and perform basic checks on image dimensions and formats so obviously unusable assets never enter the downstream workflow.

    4. Core Design 2: Prompt Assembly and Negative Constraints

    Prompts should be generated automatically in both Chinese and English: Chinese for business review, English for execution on the model side. The positive prompt is concatenated in the order “identity lock + garment lock + pose + scene + quality and commercial standards” to avoid semantic overlap. A sample structure:

    1. [identity] keep the same face, hairstyle, skin tone and body proportion as the model reference
    2. [garment] preserve exact style, color, pattern placement, fit and fabric texture from the product image
    3. [pose] follow the pose reference for action and framing only
    4. [scene] use the scene reference for environment and lighting only
    5. [quality] commercial e-commerce photo, clean background, natural hands, consistent lighting, high detail

    Negative prompts must cover frequent defects: face swapping, facial drift, garment deformation, color shift, pattern misalignment, deformed hands and feet, extra or missing fingers, extra people, text, logos, watermarks, inconsistent lighting, over-smoothing, and a plastic look. Group the negative items so they can be added or removed per scenario instead of piling them into one long sentence.

    5. Core Design 3: Quality Inspection and Targeted Retries

    Generation is not the endpoint; the quality gate is. After each output, check seven dimensions and return a three-state conclusion: pass, recommend manual review, or fail.

    1. Face consistency: compare facial features and hairstyle with the model image; any drift is a fail.
    2. Garment fidelity: whether style, color, fit, fabric, and pattern placement match.
    3. Wearing plausibility: whether the collar, cuffs, hem, and buttoning follow physical logic.
    4. Body naturalness: whether finger count, joint orientation, and occlusion are natural.
    5. Pose compliance: whether the result follows the pose image and the composition is usable.
    6. Scene and lighting: whether the environment is correct and the light direction, color temperature, and shadows are consistent.
    7. Commercial cleanliness: whether impurities such as text, logos, watermarks, or bystanders appear.

    The key to retries is to change only the failed variable. If the face fails, adjust only the identity-lock strength and face-related negative items, keeping the garment, pose, and scene settings that already passed. If the garment fails, strengthen only the garment lock and structural detail description. This avoids breaking three things while fixing one.

    6. Core Design 4: Direct Generation by Default, Development Requests Deferred

    The main workflow calls the image generation capability built into the runtime by default and does not force the introduction of a web service or a third-party API. Only when the user explicitly asks for a web page or an external API integration should adapters, environment variables, and a backend proxy be provided. This “simplest by default, extend on demand” strategy reduces delivery friction.

    If engineering integration is truly needed, the following pseudocode expresses the adapter boundary; note that it contains no specific vendor interface names:

    1. def generate(input_bundle, options):
    2. validate_required(input_bundle) # error out if model or garment image is missing
    3. prompt = build_prompt(input_bundle) # assemble positive and negative prompts
    4. result = image_backend.submit(prompt, options)
    5. report = quality_gate(result, input_bundle)
    6. if report.status == "fail":
    7. return retry_with_failed_vars(result, report)
    8. return deliver(result, report)

    7. Scenario-Based Shot Planning and Batch Production

    The shot templates in the reference documents should cover five types: e-commerce main images, detail pages, lookbooks, social-style images, and batch shot planning. Each template fixes the composition ratio, camera distance, pose preference, scene preference, and a subset of negative items; execution only replaces assets and never changes the structure. In batch scenarios, generate the shot list first, then execute items one by one and aggregate the quality report; failed items automatically enter the targeted retry queue.

    8. HTML Demo Page and Packaging

    Build the HTML page as a single file containing an asset upload area, scene and shot selection, a generate button, a result preview, and a quality conclusion panel. It stores no data and clears everything on refresh, which suits demos and training. When the project is complete, remove placeholder content, verify the directory structure and the rules in the main file, then package everything as ai-fashion-tryon.zip with a brief description and sample assets.

    9. Capability Boundaries and Compliance Requirements

    State clearly that this Skill does not promise absolute fidelity; results depend on asset quality and model capability, and manual review is required before key commercial placement. It also refuses any sexualized or exploitative content involving minors; such inputs must be terminated immediately with the reason stated. Writing boundaries into the main file is more reliable than fixing problems after the fact.

    10. Conclusion

    Turning one-click try-on from a one-off conversation into a Skill project is essentially converting tacit experience into explicit contracts: mutually exclusive input roles, a fixed prompt structure, three-state quality gates, retries that change only failed variables, and direct generation by default with extension on demand. Together with a lightweight HTML demo and standardized packaging, a team can reuse this capability reliably in any compatible Agent framework, converting repeated debugging cost into a one-time engineering investment.