Giving old apps a new life: reverse engineering with Claude and computer use
Most organisations have one: the app that still does its job, but nobody wants to touch. The original developer has moved on, the framework is long out of support, the documentation is a README from another decade, and the only complete description of how it behaves is the running app itself.
That last part is useful. If the app runs, it can be observed. Claude can look at a screen, click through it and write down what happens, which turns "we need to rewrite this" from months of archaeology into a loop you can supervise. This post is the playbook: walk through the old app, write a spec, generate a Next.js version, check it against the original and deploy it to Cloudflare Workers.
Before you start: get permission
Only do this to software you own, or have written permission to rebuild. Check the licence, since some forbid reverse engineering, and local law differs on what is allowed. Cloning someone else's product is not the goal here. Rescuing your own is.
The pipeline
| Stage | Input | Output |
|---|---|---|
| Sandbox | The old app and fake data | A safe copy that can be reset |
| Walkthrough | A list of user journeys | Screenshots, steps and notes |
| Spec | Walkthrough evidence, plus code if you have it | Markdown files a human has reviewed |
| Rebuild | The spec | A Next.js app with tests |
| Parity | Old and new side by side | A list of differences to fix or accept |
| Deploy | The verified app | A Worker on Cloudflare |
Step 1: Sandbox the old app
An agent that clicks buttons will eventually click "Delete all". Run a copy of the app in a VM or container, seeded with made-up data, with no route to production, real email or payment providers. Take a snapshot so you can reset between runs, and create a test account for each role, because an admin and a normal user often see two different applications.
Treat everything on screen as untrusted too. A comment field containing "ignore your instructions" is a prompt injection attempt, whether someone planted it on purpose or not. Isolation and a domain allowlist are your real protection.
Step 2: Walk through it with computer use
First write down the journeys you care about: sign in, create an invoice, run the month end report, and so on. Ask someone who uses the app daily, because they know about the screen that only matters on the last Friday of the month.
There are two ways to run the walkthroughs. The quickest is Claude Code with the Claude in Chrome extension, pointed at your sandbox. For a web app, a prompt like this goes a long way:
Explore the app at http://localhost:8080 using the test account in .env.sandbox.
Walk through each journey in docs/journeys.md, one at a time.
For every screen, record in docs/spec/screens:
the URL, a screenshot, every field and button, validation messages
(try empty, too long and wrong type input), and what changes after each action.
Do not guess. Mark anything you could not observe as UNKNOWN.
Stop and ask me before any action that deletes or sends something.
For desktop apps, or when you want repeatable unattended runs, use the computer use tool in the Claude API. You provide the environment and execute the actions, and Claude decides what to do from the screenshots. The current version is a toolset, computer_toolset_20260801, with no beta header.
Here is a trimmed TypeScript loop for a web app, using Playwright as the hands and eyes:
import Anthropic from "@anthropic-ai/sdk"
import { chromium, type Page } from "playwright"
const client = new Anthropic()
const browser = await chromium.launch()
const page = await browser.newPage({ viewport: { width: 1280, height: 800 } })
// Only the sandbox is reachable
await page.route(
(url) => url.hostname !== "localhost",
(route) => route.abort(),
)
await page.goto("http://localhost:8080")
async function runAction(page: Page, name: string, input: any) {
if (name === "screenshot") {
const png = await page.screenshot()
const data = png.toString("base64")
return [{ type: "image" as const, source: { type: "base64" as const, media_type: "image/png" as const, data } }]
}
if (name === "left_click") await page.mouse.click(input.coordinate[0], input.coordinate[1])
else if (name === "type") await page.keyboard.type(input.text)
else if (name === "key") await page.keyboard.press(toPlaywrightKey(input.text))
else if (name === "scroll") await scrollPage(page, input)
else if (name === "wait") await page.waitForTimeout(input.duration * 1000)
else throw new Error("Action not implemented: " + name)
return "OK"
}
const messages: Anthropic.Beta.BetaMessageParam[] = [
{ role: "user", content: "Walk through the 'create invoice' journey. Describe every screen, field and rule you observe, then take a final screenshot." },
]
for (let turn = 0; turn < 40; turn++) {
const response = await client.beta.messages.create({
model: "claude-opus-5-5",
max_tokens: 16000,
betas: ["server-side-fallback-2026-07-01"],
fallbacks: "default",
tools: [{ type: "computer_toolset_20260801", configs: { zoom: { enabled: false } } }],
messages,
})
if (response.stop_reason === "refusal") throw new Error("Request was declined")
messages.push({ role: "assistant", content: response.content })
for (const block of response.content) if (block.type === "text") console.log(block.text)
const results: Anthropic.Beta.BetaToolResultBlockParam[] = []
let failed = false
for (const block of response.content) {
if (block.type !== "tool_use") continue
const base = { type: "tool_result" as const, tool_use_id: block.id, toolset_name: "computer" }
if (failed) {
results.push({ ...base, is_error: true, content: "Not executed: an earlier computer action in this turn failed." })
continue
}
try {
results.push({ ...base, content: await runAction(page, block.name, block.input) })
} catch (error) {
failed = true
results.push({ ...base, is_error: true, content: String(error) })
}
}
if (results.length === 0) break
messages.push({ role: "user", content: results })
}
await browser.close()
You still need to write toPlaywrightKey (key names differ, for example Return is Enter in Playwright) and scrollPage. A few details save debugging time:
- Claude can return several actions in one turn. Run them in order, stop at the first failure and answer every one of them
- Every result for a computer action must include
toolset_name - Coordinates are in screenshot pixels, so if you resize screenshots, scale clicks back
- Keep the history as it is. Deleting old screenshots to save tokens can invalidate later thinking blocks on newer models
- Cap the number of turns, and log every action with its screenshot, because that log is your evidence
The computer use documentation covers the full list of actions and the security guidance.
Step 3: Turn observations into a spec
Walkthroughs show behaviour, not intent. Ask Claude to organise the evidence into a small set of files:
screens.md: every screen, its fields, actions and screenshotsdata-model.md: entities and relationships inferred from forms, lists and reportsrules.md: validation, calculations, permissions and state changes, each linked to the evidence for itunknowns.md: everything that could not be observed
If you have the source code, database schema, exported data or HTTP traffic, hand those over too. A stored procedure will tell you in a minute what a hundred clicks only hint at. Ask Claude to flag places where the code and the observed behaviour disagree, as those are usually either bugs or undocumented features someone relies on.
Then read it yourself, and have a daily user read it. The unknowns.md file is the agenda for that conversation. Rounding, time zones, tax rules and scheduled jobs rarely show up on screen.
Step 4: Generate the Next.js version
Scaffold an empty app on Cloudflare first, deploy it, and only then let Claude fill it in:
npm create cloudflare@latest -- my-new-app --framework=next
Then give Claude Code the spec and work in vertical slices, one journey at a time:
Read docs/spec. Build only the "create invoice" journey.
Use the App Router, server components by default and TypeScript.
Validate input on the server. Write Playwright tests from rules.md first.
Keep the behaviour the same. List any improvement you want to make
instead of making it.
That last instruction is important. Get parity first and redesign second, otherwise you can't tell a deliberate change from a mistake. The exception is security: don't faithfully reproduce plain text passwords, missing authorisation checks or SQL built from strings. Fix those and write down that you did.
Step 5: Prove it behaves the same
Run the same journeys against both apps with the same seed data. Compare screenshots for layout, but compare outcomes for correctness: database rows, totals, generated files and error messages. Claude can drive both sides and produce a difference report. Each line then gets one of three labels: bug in the new app, accepted change, or bug in the old app.
Step 6: Deploy to Cloudflare Workers
Cloudflare now recommends vinext, which runs the Next.js API on Vite, and it's what this website runs on. My earlier post used OpenNext, which is still the fallback if vinext has a compatibility gap that blocks you. For an existing Next.js project:
npx vinext check
npx vinext init
npm run dev:vinext
npm run build:vinext
npx @vinext/cloudflare deploy
Workers is not a Node server, so decide early where the old app's state will live:
| Old app has | Cloudflare option |
|---|---|
| A small SQL database | D1 |
| An existing Postgres or MySQL you want to keep | Hyperdrive |
| Uploaded files on local disk | R2 |
| Cron jobs | Cron Triggers |
| Background work | Queues or Workflows |
Migrate data with a script you can run repeatedly, rehearse it on a copy, and run both apps side by side before switching DNS. Keep the old one available, read only, until a full business cycle has passed.
Where this goes wrong
- The journey list is incomplete, so whole features never get observed
- Inferred rules are accepted without review
- The agent is pointed at production
- Parity checks stop at "it looks the same"
Claude does the tedious part well: clicking through every screen, writing it down and building the first version. Deciding what the app is supposed to do is still your job. Start with one journey, take it all the way to a deployed Worker, and you'll know within a short while how well your old app gives up its secrets.