Cursor keeps changing my code on things that were working

Describe the Bug

Cursor keeps doing unwanted changes in my code. When I tell him fix “a”, he fixed “a”, but also un-do previous fixes to “b”.. <— this is very annoying, I have to debug the same issue several times, with several issues coming up over and over… its almost like a loop of issues.

^^^ is there a way for this not to happen? It surely codes quickly than I could, but is sure keeps messing things up that a human would remember to to touch it again..

Expected Behavior

Not to undo previous fixes…

Operating System

Windows 10/11

Does this stop you from using Cursor

No - Cursor works, but with this issue

Are you seeing this happen all within one chat or across multiple chats? Chat A fixes something, then Chat C undos Chat A’s fix while fixing a new problem? Or all in same chat?

If it’s within the same chat, like in between requests. I have seen this happen where it reverts my changes I made, I think because it doesn’t grab the latest version of the file when it adds new fixes.

If it’s across multiple chats, then I would try setting up some rules or being very clear in the request, and possibly ask why it reverted that change and how to avoid doing that in the future. The request or project could be some edge cases that is getting confused on, and a rule for this specific project or area may be helpful.

It is within multiple chats.

Should I keep a one chat per project? I don’t even know how to save and re-open a previous chat. It would be one very huge chat…

In this case I am using technologies such as React Native and Next.js … I wonder, if I put certain features under a component, and then just called the components, maybe cursor wouldn’t be changing things so much.. its really creating extra work that doesn’t need to be there.

No, multiple chats are generally preferred when dealing with different issues/files, since each chat builds and maintains a context.

create an AGENTS.md file at the base of your project, and cursor should automatically read it with every request (you can check by asking “what context do you have with this request?”) and it should say “AGENTS.md”

Then in this AGENTS.md, give it some suggestions like “never modify these kinds of files if it is not related to the current request, or to ask first”, or whatever. I am not 100% sure what the issue is, but I think if you ask the agent after it does one of these undesired changes “why did you change this when it was not necessary for the current request, and then update Agents.md with a rule that should work project wide for future situations to make sure the agent does not do this undesirable behavior” Then review Agents.md and make any tweaks

Good luck

Hey, thanks for the report. This isn’t really a bug, it’s typical LLM agent behavior. When you start a new task, the model may re-generate nearby code and accidentally lose an older fix. This happens more in long chats, where earlier edits can fall out of context.

@MidnightOak gave a good tip above. I’ll add a few practical things that really reduce regressions like this:

  • Commit working code more often with git. Once a fix is committed, any rollback shows up in the diff and is easy to revert. Uncommitted working state is the most fragile.
  • Scope your request clearly: “change only function X in file Y, don’t touch anything else”. Narrow, targeted requests regress less often.
  • Review every diff before you click Keep. The Review Changes panel shows all edits. Reject collateral changes you didn’t ask for instead of accepting everything at once.
  • AGENTS.md / Rules, like MidnightOak suggested, is a solid approach. You can encode invariants like “make minimal, targeted edits” and “do not change unrelated working code”. More here: Rules | Cursor Docs
  • Plan mode for multi-step tasks. The agent locks scope first, then edits: Plan Mode | Cursor Docs
  • Tests for already-fixed bugs, so any rollback gets caught right away.

About “one huge chat”, it’s actually the opposite. For different tasks or files, it’s better to use separate chats so each one keeps a cleaner context. A long shared chat increases the chance older fixes fall out of context.

Let me know if it still rolls back after this. If it does, share a specific example and we’ll dig in.