Agent-Driven Product Replication: A Practical Guide for Building Runnable Prototypes in Days

    This guide explains how to replicate a mature product's engineering structure—not its assets—using AI agent coding tools. It covers a three-phase workflow (UI and information architecture, backend APIs and data contracts, model capability and prompt rebuilding), quantifiable acceptance criteria, tool selection based on general capabilities, cost control through context reuse, and a compliance checklist that separates structure and methods from protected assets and branding. Readers will learn how to turn a rough idea into a working local prototype while staying within legal and technical boundaries.

    1. Define “Replication” Correctly: You Replicate Engineering Structure, Not Assets

    During product research, shortening the distance from “idea to runnable prototype” is often more valuable than repeatedly refining requirements. Over the past year, demand for short-drama content products has grown noticeably. Many small teams want to enter this space but get stuck in the same place: no dedicated designer, so the interface looks rough; features are mostly stacked forms with a single interaction path; and the demo only works in a few fixed scenarios, breaking as soon as it deviates from the script.

    The root cause is not “not knowing how to code.” It is the lack of a method that breaks down a mature product’s engineering structure and fills in each piece one by one. Replication is essentially three things: restoring the information architecture and interaction paths, restoring the server’s responsibility boundaries and data contracts, and restoring how model calls and prompts are organized. It does not include copying another company’s brand identity, art assets, copy, audio/video content, or training weights. Those parts have clear ownership and carry high risk, so they must be excluded from the plan.

    Once the boundary is clear, talking about efficiency makes sense. One observed case: using an agent coding tool with long-context and plugin capabilities, a single developer completed a local prototype of a similar product in two days. During that time, the tool ran for about ten hours in total, produced dozens of sessions and billions of tokens in calls, with a cache hit rate close to 100%, and the actual model-side spend was on the order of about 100 RMB. This number does not show that a tool is “cheap.” It shows a change in cost structure brought by context reuse in long-horizon tasks—what really drives the bill is the proportion of repeated context, not the task duration itself.

    2. Overall Roadmap: Three Phases, One-Way Dependencies, Acceptance per Phase

    Break replication into three strictly ordered phases. Only after the previous phase passes acceptance do you move to the next. The order cannot be reversed for a simple reason: interface reverse engineering requires real interaction as a premise, and restoring capabilities and prompts requires the interface contract as a premise.

    1. Phase 1: Restore the UI appearance and information architecture. The goal is to make the prototype structurally identical to the original in visuals and operation paths.
    2. Phase 2: Reverse engineer server APIs and data models. The goal is to make the frontend actually run, not just show static pages.
    3. Phase 3: Rebuild model capabilities and prompt assets. The goal is to achieve similar output quality through compliant means, not by copying any weights.

    Each phase needs quantifiable acceptance criteria, such as “key path clicks no more than N steps,” “time to first interactive screen,” “API error rate,” and “output structure consistency rate under the same input.” Replication without acceptance criteria easily turns into endless visual tweaking.

    3. Tool Selection: Describe General Capabilities, Not a Specific Product

    The tools mentioned in the source material can be abstracted into three general capability categories. Match by capability when selecting; no need to stick to a specific implementation:

    • Desktop or locally runnable agent coding environment: the core trait is “everything is a plugin.” Base capabilities (file read/write, terminal execution, browser operation, retrieval) are mounted as plugins, support install/uninstall at runtime, and allow other coding agents to be scheduled concurrently as sub-agents.
    • UI and interaction reverse engineering: use browser automation to capture page structure, styles, and network requests, outputting a structured component tree and API list.
    • High-level generation: map natural-language requirements directly to a runnable frontend/backend skeleton.

    In related practice at Baidu AI Cloud, such needs typically fall under general cloud product categories: use a container platform to host the agent runtime and backend services, object storage for static assets and build artifacts, a message queue to decouple long tasks, logging and monitoring/alerting for observability, and a key management service to hold credentials. When selecting, focus on four points: whether context caching takes effect, the concurrency limit for sub-tasks, whether the plugin extension mechanism is open, and whether the execution process can be replayed.

    4. Phase 1: Restore the UI Appearance

    Build a “clickable skeleton” first, then visual details. Suggested flow:

    1. Use browser automation to traverse the target product’s public pages, exporting DOM structure, computed styles, asset lists, and network request records to form a component tree.
    2. Map the component tree to a local component library, reusing the existing design system first and avoiding pixel-by-pixel hardcoding.
    3. Have the agent generate page skeletons by route in batches, delivering one route at a time for easy rollback.
    4. Set up visual regression: take screenshots of the same set of routes and diff them, writing the difference threshold into the acceptance criteria.

    An illustrative task description for the agent could look like this:

    1. Goal: restore the /storyboard workspace page
    2. Input: component tree storyboard.json, style tokens tokens.json
    3. Constraints: use only the local component library; do not introduce external fonts or image assets;
    4. interaction states must cover empty/loading/error/insufficient-permission
    5. Acceptance: structural similarity to reference screenshot >= 0.9; key operation path <= 3 steps

    The most common pitfall in this phase is treating “looks similar” as “usable.” Be sure to fill in empty, loading, error, and permission states at the same time; otherwise, when Phase 2 connects real APIs, there will be large-scale rework.

    5. Phase 2: Reverse Engineer Server APIs and Data Contracts

    After the UI is restored, organize an API list from the network request records, with fields including path, method, auth scheme, request body, response body, error codes, and idempotency semantics. Then cluster by business domain to get the resource model: project, episode, shot, asset, task, permission.

    Suggested implementation order: define the data model and migration scripts first, then implement the APIs, and finally add auth and rate limiting. Example:

    1. create table project (
    2. id bigserial primary key,
    3. name varchar(128) not null,
    4. owner_id bigint not null,
    5. created_at timestamptz default now()
    6. );
    7. create table shot (
    8. id bigserial primary key,
    9. project_id bigint references project(id) on delete cascade,
    10. seq int not null,
    11. prompt text,
    12. status varchar(32) default 'draft'
    13. );

    Keep the API layer as “thin controllers + domain services” so the implementation can be swapped later:

    1. @app.post("/v1/projects/{pid}/shots")
    2. def create_shot(pid: int, body: ShotIn, user=Depends(auth)):
    3. return service.create_shot(pid, body, owner=user.id)

    Do not put long-running tasks (asset generation, batch rendering) in the request path. Send them to a message queue, have consumers execute them, and let the frontend get progress via polling or an event stream. Build observability in this phase: structured logs with trace_id, and key metrics (task success rate, queue time, per-task duration) wired into monitoring and alerting.

    6. Phase 3: Rebuild Capabilities and Prompts

    The goal of this phase is to approach the original output quality using publicly available model capabilities, not to obtain any protected model assets. A workable approach is “behavior alignment”: collect publicly available input/output samples, abstract task patterns, then write prompts and workflows.

    Take short-drama script generation as an example. It can be split into four steps: genre and audience setting, episode outline, shot script, and camera prompts. Each step has independent prompts and independent evaluation:

    1. Role: shot script generator
    2. Input: single-episode outline, character setting sheet, duration constraints
    3. Output: JSON array, each item containing shot_id/scene description/dialogue/duration/transition
    4. Rules: strict JSON; do not add characters; single shot duration 1.5~4 seconds
    5. Evaluation: structure validity rate, character consistency, duration distribution deviation

    The evaluation set should be small and stable—twenty to fifty items is enough. Run it every time you change a prompt and record the pass rate. For model routing, tier tasks by difficulty: use a small model for structured extraction, a more capable model for creative generation, and an async queue for batch summarization. Caching strategy matters too: keep the system prompt, reference material, and tool definitions fixed at the front, and put the changing parts at the tail. This can significantly improve context reuse, which is key to keeping long-task costs under control.

    7. Cost Control and Process Management

    • Session splitting: split by “one acceptance goal per session” to avoid unbounded context growth.
    • Context slimming: periodically clear irrelevant logs and screenshots, keeping only conclusions and difference lists.
    • Concurrency and rate limiting: leave headroom for sub-agent concurrency to avoid being rate-limited on the API side.
    • Cost dashboard: track tokens and cache hit rate by phase; locate sudden spikes immediately.
    • Store artifacts in version control: code, prompts, evaluation sets, and screenshot baselines all go into version management to ensure rollback.

    8. Compliance and Risk Checklist

    The legal space for replication centers on “structure and methods”; the red line is “assets and identity.” Not allowed: copying trademarks, logos, proprietary fonts, and art assets; scraping and reusing others’ copyrighted content; bypassing paywalls or access controls; obtaining or distilling protected model weights; forging the original product’s terms of service or privacy policy. Before starting, it is advisable to confirm the target page’s public terms, robots conventions, and data authorization scope. When user data is involved, follow the principle of least necessity, and use a key management service to hold credentials rather than writing them into the code repository.

    9. Conclusion

    Treat replication as an engineering exercise, not a speculative shortcut: advance the three phases in order, set acceptance for each phase, rebuild capabilities and prompts through behavior alignment, and control cost via context reuse and task tiering. The real payoff of this method is that it lets a team get a runnable prototype on a two-day-scale cycle, leaving time for user validation and differentiated innovation instead of burning it on repeated guesswork.