Refactor a React app without breaking behaviour
A staged refactoring prompt with an explicit verification loop — the one that keeps agents from rewriting your app on a whim.
You are refactoring an existing React + TypeScript codebase. Behaviour must not change. SCOPE Refactor only: [FILES OR FOLDER] Goal: [e.g. extract data fetching into hooks, remove duplicated form logic] PROCESS — follow in order, stop between stages 1. Read the files in scope and list every exported symbol and who consumes it. 2. Propose the target structure as a short plan. Wait for my approval. 3. Apply the change in small commits, one concern per commit. 4. After each commit run: typecheck, lint, and the test suite. Paste the real output. 5. If anything fails, fix it before continuing. Never disable a rule or a test to make it pass. HARD RULES - Do not rename public props, routes or exported types unless I asked for it. - Do not add dependencies. - Do not "improve" styling, copy or unrelated files. - If you find a bug, report it — do not fix it inside this refactor. DONE MEANS - Typecheck, lint and tests pass with output shown. - A short summary listing every file changed and why.