A Low-Cost Practical Guide to Clean-Room Reimplementation of Mobile Apps
This article presents a practical, low-cost methodology for clean-room reimplementation of a mobile app using only publicly observable information. It explains a five-stage workflow—fidelity grading, device debugging channel setup, joint semantic-tree and screenshot parsing, specification generation, and native/server rebuild with same-device acceptance—along with the tooling, state modeling, cost controls, and three-part evidence needed to verify functional equivalence without decompilation or packet capture.
1. Background: Why Rebuilding an App Is Harder Than It Looks
As intelligent coding tools and large-model agents mature, an appealing idea has emerged: let an agent take over a real device, observe how an app behaves from the outside, and rebuild a functionally equivalent product from scratch. The original experiment reported “7 hours and 21 yuan”—recreating the interface and interactions of an AI product with image generation, video generation, video editing, and duration extension at extremely low compute cost.
This article is not about any specific product. Instead, it abstracts this kind of work into a general engineering problem: how to rebuild a mobile app’s interface and behavior in a measurable, acceptance-ready way using only publicly visible information. In engineering terms, this is called clean-room reimplementation, and its legitimacy rests on observing external behavior only, never touching internal implementation.
Approaches such as decompilation and packet capture are deliberately excluded here, for three reasons:
- Compliance risk: bypassing technical protection measures or reverse-engineering private communication protocols may cross legal and platform-terms boundaries.
- Engineering fragility: decompiled output is usually heavily obfuscated, and capture results depend on certificates and protocol versions, making maintenance costly.
- Mismatched payoff: the goal is behavioral equivalence, which is determined mainly by interface structure and state transitions—information already fully exposed through public interaction.
2. Overall Framework: Study, Build, Check, Ready
The workflow follows a closed loop of Study → Build → Check → Ready, broken into five stages:
- Grading: define the fidelity target to avoid unbounded effort.
- Direct channel connection: let the agent take control of a physical device through the device debugging channel.
- Semantic parsing: capture both the control hierarchy and visual screenshots.
- Specification: turn observations into an actionable diff table and a behavior audit table.
- Rebuild and same-device acceptance: implement the native client and server, then compare them on the same device.
The key design choice is “specify first, code second.” Most reimplementation efforts fail not because the UI cannot be built, but because observations stay at the level of impressions and never become acceptance conditions.
3. Step 1: Grade Fidelity to Lock Cost Within Budget
The most common cause of runaway effort is a vague target. Six levels from L0 to L5 are recommended:
- L0 wireframe: restore information hierarchy and navigation relationships only.
- L1 layout: restore grids, spacing, and control types.
- L2 visual: restore colors, corner radii, font sizes, shadows, and animation timing.
- L3 functional: make the main flows’ outputs equivalent to the real product; no static fake data.
- L4 state: cover error states, empty states, loading states, retry on failure, and permission branches.
- L5 performance: align metrics such as startup time, scroll frame rate, and memory usage.
The original experiment locked the target at L3, a very pragmatic trade-off: L2 determines “does it look right,” L3 determines “is it usable,” while the marginal cost of L4 and L5 rises sharply. Write the grading into the acceptance document at project start; record any observation beyond the agreed level but do not implement it.
4. Step 2: Connect the Device Debugging Channel Directly
To operate a physical device, the agent needs a stable control channel. In engineering practice, this typically means device debugging bridge capabilities, using terminal commands for installation, launch, taps, swipes, log capture, and screenshot export. An illustrative script:
# List connected devices to confirm the channel is availabledevices list# Install the rebuilt package for acceptanceinstall -r app-rebuilt.apk# Launch the target screenshell am start -n com.example.app/.MainActivity# Simulate tap and swipe (coordinates come from parsing)shell input tap 540 1200shell input swipe 540 1600 540 600 300# Export a screenshot for visual comparisonshell screencap -p /sdcard/shot.pngpull /sdcard/shot.png ./baseline/
Three pitfalls dominate in practice. First, permission and background restrictions differ across device vendors, causing agent commands to time out. Second, coordinate drift makes taps miss when screen resolution and system scaling disagree. Third, the device sleeps during long tasks, so sleep must be disabled in the developer settings. The reliable approach is to fix one “reference device” as the baseline and anchor all screenshots and coordinates to it.
5. Step 3: Joint Parsing of the Semantic Tree and Screenshots
Any single information source will distort. The control hierarchy gives accurate nesting, clickability, and coordinates, but not real colors or corner radii; screenshots give complete visuals but cannot distinguish two containers with nearly identical pixels. Both channels must therefore run in parallel:
- Structure channel: export the view hierarchy to obtain control types, text, unique identifiers, bounding rectangles, and clickable and scrollable attributes.
- Visual channel: capture each screen and extract primary and secondary colors, corner radius, font-size hierarchy, icon placement, and key animation frames.
Parsing output should be normalized into a structured intermediate format so specifications can be generated later:
{"screen": "creation_home","nodes": [{"id": "tab_image", "type": "Button", "text": "Image", "bounds": [80, 220, 300, 320], "clickable": true},{"id": "prompt_input", "type": "EditText", "hint": "Describe the scene you want", "bounds": [60, 400, 1020, 560]}],"visual": {"primary": "#1B1B1F", "radius": 28, "titleSize": 34}}
With a unified intermediate format, the agent can traverse business flows in batches and record each step’s “action → interface change,” producing a replayable observation trace.
6. Step 4: Specification Checklists That Turn Observations into Acceptance Conditions
This step carries the core value of the method and produces two documents.
Per-screen UI diff table, with fields for screen identifier, control identifier, target value, measured value, deviation type (missing / extra / misaligned / style mismatch), and priority.
Behavior audit table, with fields for entry point, precondition, action sequence, expected state transition, actual state transition, and whether an external dependency is involved. Example:
| Scenario | Precondition | Action | Expected result | Fidelity level |
|---|---|---|---|---|
| Generate image | Prompt entered | Tap generate | Enters task queue and shows progress | L3 |
| Video extension | A 16-second clip exists | Choose extend | A new version is generated and the original is kept | L3 |
| Retry on failure | Dependent service unavailable | Tap retry | Error state is shown and resubmission is possible | L4 |
The value of the behavior audit table is exposing implicit dependencies. Capabilities such as video extension, multi-version retention, and original-asset ownership essentially depend on server-side task scheduling and version management; restoring only the frontend inevitably yields fake data. This is exactly why the fidelity level must be capped at L3 and the server must be rebuilt alongside the client.
7. Step 5: Rebuilding the Native Client and the Server
For the native client, keep a declarative UI and state-driven architecture: each screen only describes a state-to-interface mapping, and all asynchronous results converge through a single state machine, avoiding multiple conflicting loading flags. An illustrative state definition:
sealed class GenerateState {object Idle : GenerateState()data class Queued(val taskId: String) : GenerateState()data class Running(val taskId: String, val progress: Float) : GenerateState()data class Success(val versionId: String, val assetUri: String) : GenerateState()data class Failed(val reason: String, val retryable: Boolean) : GenerateState()}
The server carries four general responsibilities: task intake and queuing, asynchronous execution and callbacks, artifact storage and version ownership, and usage metering with rate limiting. On the storage side, object storage can hold image and video artifacts, metadata goes into a relational database, long-running tasks are decoupled through a message queue, and logs and metrics flow into logging and monitoring/alerting systems respectively. This satisfies multi-version retention and original-asset ownership while keeping cost observable.
Three general cost-control measures apply. First, cache prompts and parameters locally so a cache hit skips the external call. Second, batch high-cost generation tasks to reduce repeated scheduling. Third, set step and call limits on the agent’s observation process to prevent infinite loops from consuming quota. The reported “7 hours and 21 yuan” is the result of such constraints taking effect, not some special capability.
8. Same-Device Acceptance: Turning “Behavioral Equivalence” into a Repeatable Experiment
Acceptance must run on the same reference device under the same account state, with per-screen screenshot overlay comparison and end-to-end replay of key flows. Three-part evidence is recommended:
- Visual evidence: side-by-side screenshot sets of the original and rebuilt apps on the same screens.
- Behavioral evidence: state-transition logs under identical action sequences.
- Artifact evidence: real output from actually invoking the generation pipeline, fully playable with correct version ownership.
Only when all three kinds of evidence are present can L3 be claimed. If any part relies on hard-coded sample data, the result should be failed outright.
9. Capturing Experience: Turning the Process into Reusable Capability
The real compounding value of this kind of work comes from writing the pitfalls into executable checklists: the troubleshooting order for device connection failures, methods for correcting coordinate drift, the sampling frame rate for aligning animations, and templates for the diff table plus acceptance scripts. Teams can consolidate these checklists into an internal skill package or scaffold, so the next reimplementation becomes “execute the checklist” rather than “figure it out again.”
If the goal is to build your own AI generation product, the safer path is to use this method for competitive analysis and interaction benchmarking, then implement your own generation pipeline and version management on top of general cloud capabilities (object storage, message queues, container platforms, logging, monitoring and alerting), forming an engineering asset that can evolve over the long term.
