Clean-Room Mobile App Replication with an AI Agent: 7 Hours and 21 CNY

    This article describes a clean-room method for replicating a mobile app using only publicly visible screens and interactions, without decompiling code or relying on private interfaces. It walks through a five-step workflow that uses an AI agent and a device's system debugging interface. The steps cover defining verification levels, recording UI and behavior specifications, rebuilding the client and server, and running side-by-side checks on the same device. It also covers cost, risk, and engineering recommendations.

    In mobile app development and compatibility research, “replicating an app” is often mistaken for decompiling, packet capture, or copying resources directly. A safer and more engineering-oriented approach is clean-room replication. It does not depend on the target app’s private code or internal interfaces. Instead, it observes only public interfaces, public interactions, and visible results, then rewrites the client and server contracts from scratch. This article uses a small-scale practice as a case study. It shows how an AI agent and the system debugging interface can produce a runnable, testable mobile app prototype at relatively low time and resource cost.

    The “7 hours and 21 CNY” in the title represents the time and resources spent on one validation exercise. The focus is the method, not the figures. The method chains together four activities: observing the interface, walking through flows, recording state, and writing code and verifying it. Together, these form a reusable pipeline.

    1. Set Boundaries First: Clean-Room Replication Is Not Reverse Engineering

    The core principle of clean-room replication is to look only at public results and avoid private implementations. Engineering work should follow three boundaries:

    1. Observe only public interfaces and interaction results. This includes page structure, control positions, colors, corner radii, font sizes, state changes, error messages, and loading behavior.
    2. Do not bypass authentication, crack paid features, or copy protected resources. Replication should serve legitimate purposes, such as rebuilding your own product, learning and research, or authorized compatibility testing.
    3. Define the server contract from observed public behavior. This does not mean recovering the other party’s private interfaces. Instead, derive from visible interactions what capabilities the client needs, what data structures it returns, and how exceptions appear.

    Therefore, the replication target should be abstracted from a specific product into a category: multimodal apps with features such as image and video generation, editing, extension, and version retention. This makes the method general.

    2. Five-Step Framework: From Grading to Same-Device Acceptance

    The workflow has five steps: grade, connect directly to a real device, parse the semantic tree and screenshots, create a specification checklist, then rebuild the native client and server and verify the result.

    1. Grade: Turn “Looks Similar” into Testable Levels

    Replication projects fail when their goals are vague. Define six levels, from L0 to L5:

    • L0 Static placeholder: Only screenshots or static pages. Nothing is interactive.
    • L1 Consistent UI structure: Matching layout, hierarchy, and main control positions.
    • L2 Consistent interaction paths: Taps, back navigation, dialogs, loading, and error messages all work end to end.
    • L3 Consistent results: Real data drives the app, and functional results match the target behavior. Static fake data is not acceptable.
    • L4 Consistent exception and performance behavior: Weak networks, empty states, timeouts, retries, and concurrency behave closely to the target.
    • L5 Maintainable and extensible: Well-structured code, configuration, logging, monitoring, and tests.

    Most validation projects only need to reach L3. At that level, the UI looks right, the flows work, and the results are real. Aiming for L5 from the start easily leads to overengineering.

    2. Connect Directly to a Real Device: Give the Agent Observable “Hands”

    Replicating a mobile app cannot rely on web screenshots alone. The app must run in a real device environment. Enable developer debugging mode on the target phone, then connect the device to a computer through the system debugging bridge interface. The AI agent can then call controlled commands to navigate pages, tap controls, enter text, go back, take screenshots, and export the UI structure.

    The key question is not whether the agent can tap. It is whether each operation is recorded, replayable, and auditable. Every tap should log the current page identifier, control semantics, coordinates, the state before and after the action, and the screenshot ID. This turns exploration into a specification.

    3. Parse the Semantic Tree and Screenshots: Capture Both Structure and Visuals

    Screenshots alone show the agent what something looks like, not what it is. A semantic tree alone shows where controls are, but not their visual details. The two sources must be combined:

    • UI semantic tree: Control hierarchy, tappable areas, text, content descriptions, coordinate ranges, and visibility states.
    • Screen screenshots: Colors, corner radii, shadows, font sizes, spacing, icon style, and empty and loading states.
    • Cross-normalization: Align semantic tree nodes with screenshot regions to form control-visual-behavior triples.

    For example, a button should not be recorded only as “tappable.” Also record its text, position, color, and corner radius. Note whether a dialog appears after tapping, the order of the dialog’s buttons, and how the dialog can be closed.

    4. Create a Specification Checklist: Turn Exploration into Development Input

    After exploration, produce two tables:

    • Per-screen UI diff table: Page ID, section, control type, position constraints, color, font size, corner radius, icons, and state variants.
    • Behavior audit table: Trigger conditions, operation path, state before and after requests, loading state, success state, failure state, and back-stack changes.

    The specification checklist makes two things possible. Developers no longer rebuild the UI by feel, and acceptance no longer depends on someone saying the result “looks similar.” Each page has items that can be checked, and each behavior has a path that can be reproduced.

    5. Rebuild the Native Client and Server: Verify Side by Side on the Same Device

    Rewrite the client in the target platform’s native language. Implement the server in a general-purpose server-side language, using an interface contract derived from observed public behavior. When both are finished, install them on the same real device. Show the original on the left and the replica on the right, then check each screen. Finally, walk through each item in the behavior audit table.

    1. task = plan("target app's public screens and interactions")
    2. for screen in agent.explore(task):
    3. tree = capture_ui_semantics(screen)
    4. shot = capture_screen(screen)
    5. spec = normalize(tree, shot)
    6. record_ui_diff(spec)
    7. record_behavior_audit(spec)
    8. client = build_native_client(spec)
    9. service = build_service_contract(spec)
    10. verify(side_by_side(original, client), audit_table)

    The pseudocode illustrates the process. It does not depend on any specific tool or interface.

    3. Verify Results: Do Not Stop at “Looks Similar”

    L3 acceptance covers at least four areas:

    1. Real data-driven behavior: Lists, details, generated results, and editing parameters come from the real server contract, not hardcoded data.
    2. Complete flow playback: For flows such as video extension, clip stitching, and multi-version results, verify end to end that content plays, saves, and returns correctly.
    3. Multi-version retention: When the same input produces several results, the version list, selected state, deletion, and restore logic must behave consistently.
    4. Source asset ownership: During editing, extension, or secondary generation, the relationship between original images or videos and derived results must be clear. This prevents state errors.

    4. Cost, Risk, and Engineering Recommendations

    The low cost comes from three factors. Automated agent exploration reduces manual screenshot collection. The specification checklist reduces rework. Same-device verification reduces the gap between an app that looks right in development and one that looks wrong on a real device.

    Manage risks early as well. Pursue only authorized and lawful scenarios. Do not collect sensitive data. Do not bypass any access controls. Give the replica its own brand, and replace its assets independently. Keep operation logs and acceptance records.

    For engineering, turn the process into internal templates: a grading template, a UI diff table template, a behavior audit table template, and an acceptance script skeleton. The next time a similar app comes up, only the specification checklist needs replacing rather than starting from scratch.

    In summary, having an AI agent operate a phone is not magic replication. It is a closed loop of observation, recording, specification, rebuilding, and verification. Grade the target first, then connect to the device. Parse the semantics and screenshots first, then build the checklist. Finally, verify on the same device. With the right method, a low-cost replication prototype is within reach.