The symptom

You ask for a small change. What comes back is the entire file, restructured, with different variable names, a framework you don't use, and your working feature subtly broken.

What's happening

The model has no idea which parts of your code you consider settled. Given a file and a request, it produces the best version of that file it can — including improvements you never asked for. It isn't being disobedient; nothing told it there were fixed points.

The fix

State the boundary explicitly, every time:

dont-rewrite.txt
Here is working code. <What it does now> works correctly and must
continue to work exactly as it does.

Change ONLY this: <the one change>

Rules:
- Show me only the changed lines or a diff, not the whole file.
- Do not rename anything you weren't asked to rename.
- Do not restructure, modernise, or "clean up" anything.
- If the change genuinely requires touching existing behaviour, stop
  and tell me what and why before writing it.

If it's already happened

Don't try to fix the rewrite. Revert to the last working version — this is what git restore . is for — and ask again with the boundary stated.

Salvaging a rewrite you didn't want takes longer than redoing the change properly, and you end up unsure which parts are yours.

Commit every time something works, before asking for the next change. It turns this from a disaster into ten seconds of inconvenience.