Clean-Room App Replication with LLM Agents on a Real Phone: 7 Hours and RMB 21
This article describes a clean-room workflow for replicating an AI creation app at the behavior level using LLM agents, ADB, UI-tree parsing, and screenshot analysis. It covers replication grading from L0 to L5, a five-step process, cost and efficiency findings, common pitfalls, reusable engineering assets, and compliance boundaries. Readers will learn how to validate an app concept on a real device without decompilation or traffic capture, while keeping the work focused on observable behavior and clear acceptance criteria.
1. Background: A Spontaneous Validation
Last weekend I shared how a friend used an agent workflow to replicate a short-drama studio from scratch. The comments quickly surfaced two kinds of questions: whether the workflow could replicate a specific free short-drama app, and whether it could replicate a mobile app itself.
I chose a safer validation target: an AI creation app that offers image generation, video generation, video editing, and video extension, rather than touching a copyright-sensitive short-drama product directly. The result was a high-fidelity replica produced in about 7 hours with approximately RMB 21 in API costs. The page-level fidelity was high, and the core capabilities were behaviorally aligned: real LLM proxy calls, continuous playback of an extended video, multi-version history retention, and correct attribution to the original image.
This article breaks down the methodology, the pitfalls, and the engineering lessons from the full process.
2. First Decision: Why Not Decompilation or Traffic Capture?
Engineers with mobile reverse-engineering experience may assume that replicating an app requires decompilation tools or dynamic hooking frameworks.
My answer is: no, and it should not. There are three reasons.
- Legal and compliance boundaries. Decompiling bytecode or hooking runtime behavior can easily cross the line beyond reasonable research. Clean-room replication relies only on publicly observable UI presentation and interaction results, with the code rewritten from scratch, which significantly lowers intellectual property risk.
- Engineering efficiency. Decompiled output is obfuscated intermediate representation, and recovering business logic from it often costs far more manpower than rewriting. LLM agents are good at translating visual information directly into code, which is exactly the strength needed here.
- A cleaner validation loop. The output of a clean-room approach is behavior alignment, not code alignment. The acceptance standard is naturally clear: on the same physical device, both apps should produce consistent interaction results.
I reused the agent workflow logic of investigate → rebuild → verify → deliver, and split the replication into a five-step framework.
3. The Five-Step Clean-Room Replication Method
Step 1: Set the Level — Decide How Far the Replication Should Go
Replication is not a binary question; it is a continuous spectrum. I divided it into six levels, L0 to L5:
- L0: Screenshot-level restoration — static pages look similar.
- L1: Interaction-level restoration — buttons respond and pages navigate.
- L2: Flow-level restoration — core business paths work end to end.
- L3: Effect-level restoration — real model capabilities are called, and outputs match the original experience. This is the default target.
- L4: Performance and stability alignment.
- L5: Ecosystem-level alignment, including accounts, billing, and content distribution.
The key constraint was explicit: stop at L3 by default and reject static fake data. Many “replication demos” essentially stop at L0: a shell assembled from screenshots that returns hard-coded fake results after a tap. Such replication has little engineering value and cannot validate the methodology.
Step 2: Direct ADB Connection to a Real Device — Give the Agent Hands-On Access
Emulator environments differ significantly from real devices, especially for media codecs, camera, and push capabilities. A real device is necessary. The setup is straightforward:
- Enable USB debugging on the phone.
- Connect it to the computer with a data cable and authorize debugging.
- Let the agent framework call Android Debug Bridge terminal commands to take over the phone, install the original app being replicated, and deploy an empty-shell project as the replication target.
The essence of this step is to turn “a human looking at the phone” into “a program looking at the phone,” preparing for automated analysis.
Step 3: Dual-Channel Parsing with Semantic Tree and Screenshots
This is the core of the methodology. With screenshots alone, an LLM can only roughly guess the layout. With the view hierarchy alone, it cannot capture visual details. The two channels complement each other:
- Semantic tree channel: Use the system’s built-in UI automation tool to dump the current screen’s view hierarchy, text content, resource IDs, and coordinate information. This gives the agent a structured map.
- Screenshot channel: Capture screenshots and pass them to a multimodal model to extract color schemes, corner radii, font-size hierarchy, icon style, and spacing patterns.
# Pseudocode: dual-channel collectionadb shell uiautomator dump /sdcard/ui.xmladb pull /sdcard/ui.xml ./shots/01_home.xmladb exec-out screencap -p > ./shots/01_home.png
Collect a set for every page and every interaction state: switching tabs, opening drawers, entering edit pages, triggering loading states, and error states. Incomplete state coverage is the biggest source of later rework.
Step 4: Specification Checklist — Turn “What Was Seen” into “What Can Be Executed”
After collection, have the agent produce two structured documents:
- Screen-by-screen UI difference table: layout structure, component list, style parameters such as color values, font sizes, and margins for each screen, plus differences from the existing empty-shell project.
- Behavior audit table: state changes triggered by each interaction — who initiates the request, what is requested, what is awaited, and where success and failure navigate.
These two documents translate fuzzy replication into engineering tasks with acceptance criteria. Each time the agent completes a module, it can check items off against the list instead of relying on a feeling that “it looks close.”
Step 5: Native Client and Server Rebuild, Then Same-Device Acceptance
- Client: Rewrite the UI and interaction logic in native mobile code rather than wrapping a Web shell. A native implementation preserves consistency in gestures, animations, list virtualization, and other experience-level details.
- Server: Use a lightweight service to handle business logic. Model-generation requests go through a unified LLM proxy layer that hides differences between underlying models.
- Acceptance: Install the original app and the replica on the same physical device and compare screen by screen and interaction by interaction. Focus on three hard indicators: whether real model calls work, whether an extended video can play continuously for more than 16 seconds, and whether multiple versions and original-image attribution are correctly retained.
4. Cost and Efficiency Analysis
The total cost of this exercise was approximately RMB 21, all for multimodal parsing and LLM code-generation API calls. Of the 7 hours, human intervention was mainly needed in three places: initial environment setup, manual confirmation of critical interaction paths, and final same-device acceptance. The remaining parsing, checklist generation, and code writing were completed automatically by the agent.
By comparison, a traditional two- or three-person team replicating a similar app usually takes weeks. The agent-driven clean-room process shifts the main cost from manual coding to process design and acceptance. That is the paradigm shift.
5. Pitfalls
- View hierarchy parsing fails on custom views. Some screens use custom-drawn controls, and the dumped semantic tree is almost empty. Screenshots plus multimodal reasoning must serve as a fallback.
- Asynchronous states are easy to miss. Loading states and skeleton-screen transitions often last only a few hundred milliseconds, so retries and delayed sampling are needed in addition to the dump command.
- Do not estimate style parameters by eye. Corner radii and colors must be extracted pixel by pixel from screenshots. Style deviations written from model descriptions tend to explode during acceptance.
- Connect video capabilities to the proxy early. Media-generation interfaces have the longest latency and highest failure rates. Leaving them for final integration will slow down the entire schedule.
6. Engineering Reuse: Make Replication Repeatable
After working through the pitfalls, I consolidated the lessons into a reusable skill package. Its core contents are collection command templates, checklist document schemas, an acceptance checklist, and handling strategies for common exceptions. I also organized the replicated client and server code into a repository for learning and secondary development. Using this skeleton to build your own AI generation product gives you a much higher starting point.
7. Final Note: Compliance Is the Baseline
The key discipline of clean-room replication is simple: observe public behavior only; do not touch private implementation. Replicating UI layouts and interaction patterns for learning and research is generally low-risk in many scenarios, but directly copying code, assets, trademarks, or using the result for commercial traffic generation can cross legal red lines. The stronger the technical capability, the more important it is to hold this boundary.
This “grade — connect — parse — checklist — rebuild — accept” framework does not depend on any specific vendor’s model or platform. Any agent orchestration framework with multimodal understanding and code-generation capabilities can apply it. For developers taking products global, it offers a fast and stable way to validate product ideas.
