Start with the working app and the actual failure
Before choosing an approach, demonstrate one important task that works and one problem you can reproduce. Record the version you tested and the information users need to keep. A messy folder tree can be annoying without making the whole app unusable. Equally, clean-looking code can hide rules that disagree.
The question is which approach restores the needed behavior at a reasonable cost. Compare the work required to repair the current app with the work required to replace it, including migration and verification.
Repair when the cause and boundary are narrow
Choose a bounded repair when one reproducible failure has a clear owner and surrounding behavior remains credible. A drawer that fails to release a scroll lock does not automatically justify replacing authentication, routing, and persistence. Establish the failing sequence, fix the responsible lifecycle, and verify the surrounding interactions. If the agent discovers a wider contradiction, reassess from that evidence instead of quietly expanding the job.
Refactor when the behavior is right but the code is hard to change
Refactoring changes the internal structure while preserving the intended external behavior. It fits duplicated logic, tangled responsibilities, or difficult-to-test code when you can demonstrate which behavior is correct. Record that behavior before reorganizing the code and verify it afterward. If two implementations disagree about what the product should do, moving them into cleaner files does not settle the disagreement. Resolve the governing rule first.
Replace one dependency when the product works but a component no longer fits
Sometimes the application behaves correctly, but a service or library cannot support the next product requirement. For example, an illustrative app may need an authentication capability its current provider does not support. Inspect whether replacing that provider is enough before replacing the whole app. Confirm the new capability, the records and identities that must survive, integration changes, and a recovery path. A dependency replacement can be consequential even when the screens look the same.
Rebuild a domain when the shell works but its core disagrees with itself
Selective rebuilding fits a product whose usable interface or infrastructure surrounds an untrustworthy model. For example, a planning app might have useful navigation and authentication but three competing definitions of the current plan. Replacing only that domain may preserve working assets while establishing one owner for official state. Whether existing records can be migrated, archived, or reset is a separate decision. Test data and real customer commitments cannot be treated alike.
Consider a full rewrite only with an explicit preservation and cutover plan
A broader rewrite may be justified when the current implementation cannot support the required product boundary at an acceptable repair cost. That conclusion requires inspection, not a confident label. Inventory the behavior, records, integrations, permissions, operational obligations, and migration duties that must survive. Define how the new system is verified and how you can recover from a failed cutover. If no live users or valuable records exist, the reset burden may be lower, but verify that premise.
Compare the options before committing
Use this table as a starting point, then have the agent inspect your app. These are decision criteria, not a diagnosis or a fixed estimate.
- List the working journeys, records, and integrations that must survive.
- For each viable option, state what changes and what must migrate.
- Identify the unknown most likely to change the recommendation, and check it first.
| Approach | When it fits | What to check |
|---|---|---|
| Repair | One reproducible defect with a clear cause. | The failing sequence and the working actions around it. |
| Refactor | Correct behavior is difficult to maintain because the code is tangled. | Record the behavior before changing structure; verify it afterward. |
| Replace a dependency | A library or service cannot support a required capability. | Compatibility, records and identities, integration changes, and a recovery route. |
| Selective rebuild | One part has conflicting rules or unreliable records, while other parts remain useful. | Which part owns the rule, what survives, and how affected data moves. |
| Full rewrite | The current system cannot support the required product at an acceptable repair cost. | Preservation, migration, permissions, integrations, cutover, and rollback. |
Copy the repair, refactor, or rebuild decision worksheet
Use the same starting point and preserved outcomes for every option. Ask the agent or developer to inspect the app before filling the estimates. Unknown migration or verification work is still unknown work; it is not zero.
Evidence-based decision worksheet
# Repair, refactor, or rebuild: decision worksheet ## 1. Demonstrated starting point App purpose and next needed outcome: [what users must finish] Baseline version and environment: [exact version; local/hosted] Working journey: [steps + observed result] Failing journey: [steps + expected result + observed failure] Frequency and evidence: [reproduction, screenshots/logs, or unknown] Unverified assumptions: [what has not been inspected] ## 2. Preserve User journeys and product rules: [what must continue to work] Records and identities: [valuable data; ownership; retention] Integrations and interfaces: [who depends on them] Operating obligations: [live users, payments, access, support] ## 3. Compare viable options Option: [repair / refactor / replace dependency / selective rebuild / rewrite] Evidence that supports this option: [actual findings] Affected boundary: [what owns the problem] What stays: [working assets and behavior] What changes: [system responsibilities and implementation] Migration: [records, identities, compatibility, or not applicable] Implementation effort range: [estimate + assumptions, or unknown] Verification effort range: [estimate + checks, or unknown] Migration effort range: [estimate, or unknown/not applicable] Release/recovery effort range: [estimate + cutover/rollback duties] Risks not represented by time: [data loss, access, outage, wrong rules] First check that could disprove the recommendation: [specific investigation] ## 4. Compare total work honestly For each option, add implementation + verification + migration + release/recovery effort using the same units and scope. Keep unknowns unknown; do not enter zero because no estimate exists. Do not choose by the total alone when the risks or preserved outcomes differ. ## 5. Recommendation and acceptance Recommended option: [why the evidence favors it] Open decision most likely to change it: [question + owner] First bounded milestone: [complete observable outcome] Acceptance: [working journey, repaired failure, preserved records, other role, important conflict/failure, and real environment] Cutover/recovery route: [if applicable] Owner approval needed for: [consequential changes or data decisions] This worksheet organizes an investigation. It is not an automatic diagnosis, a fixed estimate, or permission to delete valuable data.
Compare the whole job, not just the coding estimate
For each viable option, compare implementation effort + verification effort + migration effort + release/recovery effort. Use the same units, scope, and preservation obligations. If the estimates are ranges, add the lower and upper bounds separately. If a required term is unknown, keep the total incomplete until that uncertainty is investigated.
For an illustrative comparison, a selective rebuild might be estimated at 4–6 days of implementation, 2–3 days of verification, 1–2 days of migration, and 1 day of release/recovery work: 8–12 days in total. A “rewrite in 5 days” estimate is not comparable if it excludes moving existing records and checking the promised behavior. These are arithmetic examples, not estimates for your app.
The lowest total does not automatically win. An option with a greater chance of data loss, an unacceptable outage, or a different product outcome may be unsuitable even when it looks faster. Record those consequences alongside the effort range.
Worked example: a booking disappears after reopening
Suppose an illustrative room-booking app confirms a reservation, but the record disappears after signing out and reopening. First pin the version, reproduce the failure, and trace the write, read, identity, and environment. A UI confirmation alone does not prove that the authoritative booking was saved.
These are conditional recommendations. The symptom alone does not establish which finding is true. Start with the investigation most likely to change the decision. Once the choice is made, turn it into a complete implementation milestone.
| Finding after inspection | Candidate response | What still must be verified |
|---|---|---|
| The intended record is saved, but the reopened screen reads the wrong environment or account. | Bounded repair of the read/configuration/access path. | The same owned record reappears; other roles and existing writes still behave correctly. |
| One booking operation duplicates writes, while the governing booking rules are clear. | Repair or refactor that operation and its repeat-request behavior. | Reopening, retries, overlap rejection, and surrounding booking/cancellation journeys. |
| Different parts of the app enforce incompatible definitions of an active booking. | Resolve the rule and consider rebuilding the affected booking domain. | Preserved records, migration, ownership, and one authoritative state transition. |
| Inspection shows the required product cannot be supported within a viable bounded change. | Compare a larger replacement with an explicit preservation and cutover plan. | The complete replacement cost, retained commitments, migration, real-environment checks, and recovery. |
See a real architecture recovery case
DeskSnap's approved case study describes recovering architecture around an existing product, rather than treating all previous work as useless. Read the evidence and outcome limits before using it as an analogy for your own app. Driftbreak can help establish what should survive and how implementation should proceed, but your coding agent or developer still has to prove the repair or replacement in the real environment.