HACKER Q&A
📣 namanyayg

Is Cursor deleting working code for you too or is it just me?


Cursor seems to mess up 3 times a day for me.

What kinds of hallucinations are you seeing?

Any tips on fixing those?


  👤 tony Accepted Answer ✓
Keep files <1000 lines. If you can.

Keep chats <30 minutes, ideally 20-minute continuous segments.

Use a `notes/TODO.md` file to main a checklist of objectives between chats. You can have claude update it.

Commit to version control often, for code you supervised that _does_ look good. Squash later.

This glitch often begins to happen around the time you'd be seeing "Start a new chat for better results - New chat" on the bottom right.

If you don't supervise, you will get snagged, and if you miss it and continue, it'll continue writing code under the assumption the deletion was fine: potentially losing the very coverage you'd hope to have gained.

If it does happen, try to scroll up to the chat before it happened and "Restore checkpoint"

claude-3.7-sonnet-thinking, Cursor 1.96.2


👤 anonzzzies
Yep, it's worse than it was, like the other poster in this thread, i am back just copying to and fro to claude and chatgpt as it just works better.

I am starting to wonder how this will all end up. For instance with API use, we (my company) can burn $100s/day with sometimes insanely bad results all of a sudden. Now I bet I signed away all my rights, but in some countries that doesn't cut mustard for consumers buying things. If an API delivers very solid results one day and crap the next and I spent a lot of money, how does that work? There are many people on reddit/youtube speculating why claude sometimes responds like a brilliant coder and sometimes as if it had a full frontal lobotomy. I see this in Cursor too.


👤 rm_-rf_root
What I’ve learned:

- Use apply (in chat) or composer only if you’re more interested in finding a quick solution than the risk to local code. Often Cursor removes important comments by default.

- Use chat. Create new chats when it doesn’t have the latest version of your code or history/shadow workspace is confusing it. Add relevant files or @Codebase or both.

- Learn to undo. Use git and checkout the files/directories again if needed. I don’t use composer, so files never get deleted.

- Autocomplete is often fairly terrible and regularly gets in the way of trying to see what you’re typing or trying to view. Hit the escape key regularly.

- Use Claude 3.7 for regular coding and 3.7 Thinking for larger things to solve.


👤 techpineapple
I’ve been trying to “vibe code” with cursor, and it’s pretty bad. Lots of regressions, I get stuck in loops where it keeps breaking something. Maybe it’s the language I’m using (typescript) to a less applicable application (games) or the model (Claude 3.5/7) but I am very surprised that people assert a non-developer could vibe code a full application.

In the one hand it’s impressive how quickly I could make a basic UI, on the other hand it’s quite unimpressive my ability to get the Ui to actually do anything, and the number of very basic mistakes (whoops, forgot to add types or here let me import a file that doesn’t exist)

I even had a weird thing where it asked me to paste in the code of a file, even though the file was explicitly added to its context.


👤 siva7
Do careful code reviews after every change by cursor. Do small changes, break up bigger tasks. Be very precise in your instructions. It doesn't replace an experienced developer. Not much different than how a senior engineer would tackle a task. Everything else will result in throw-away spaghetti crap like bolt and similiar-minded frameworks which will collapse in production on day 1 (if you get that far). It's tempting to take it as an autopilot but the results are much better if you treat it as a copilot.

👤 BrandiATMuhkuh
Same here. It seems to me Sonnet 3.7 causes it.

Just today, I asked Sonnet 3.7 to use the app's accent color, which can be found in the @global.css, to apply it to some element. It went on a massive tangent, scanning all sorts of documents, etc. I then asked Sonnet 3.5 for the same thing, and it simply took the accent color and applied it. No tangent, no grep, ...


👤 ost-ing
Is anyone actually getting a performance boon having these llms directly integrated into the editor? I find copy pasting blocks of code to chatgpt works really well to get help in isolation, especially if im doing something mathematical or algorithmic, or researching a new data struct or theory. Do I want it to run loose in my repository? Absolutely not

👤 pizza
Context length, context length, context length. LLM architectures (there are rare exceptions) inherently get worse at answering problems given too much context. From a user point of view, these appear as just idiosyncrasies to each model's ability to stay coherent - you just have to hope the devs are cognizant of this behavior in distributions of data close to yours.

Keep the input minimal. Keep a set of gold standard tests running in a loop to catch problems quick. Don't tune out. Debate whether you really need to use that new model you haven't worked with that much yet just because it's newer. And double check you aren't being sold e.g. a quantized version of the model.


👤 nextweek2
I have a lot of .cursor/rules

If it goes off track I put a rule in there. It’s like a junior developer that I have to keep constraining it to project goals, coding styles and other aspects.

I have different files in there to help with being able to reuse rules for different projects.

Overtime it’s getting better at staying on track.


👤 jvanderbot
It's not just cursor.

I use Aider for side projects (with Claude) and for some reason it will also delete working code when making a partial correction. It just throws out the good with the bad when I suggest something.


👤 oriel
After working with this tooling for about a month, I've found the biggest struggle is adapting my mental model as the paradigms change. Because make no mistake, this is a research-stage tool that has been thrust into the spotlight while in its infancy.

There's definitely shift between versions of cursor. One time I had an unpleasant crash that also upgraded the version, and suddenly .cursor/ files I thought were working (but hadnt been) showed up mid prompt, and derailed the entire composer run.

I've tried ideas ranging from TODO documents, append-only work logs, blueprint documents, faux-team interactions through role definitions, and much much more.

The most success I've had is by adding manual lines at the end of every prompt, akin to phrases like "be respectful of the existing code and functionality, make deliberate changes with caution and consideration". Beyond the normal "plan and take it step by step" type phrasing.

It would also be nice if .cursor/ rule files actually were actively used, instead of sometimes being hooked in if you wrote the description right.

Sometimes I have great success at utilizing specialized roles, with named team members and explicit direction, to elect the "appropriate" role for the items being worked on, and discuss pros/cons and facilitate brainstorming.

At the end of the day, I think I end up doing an annealing pattern for changes:

- Build the features and breaking is okay so long as we get the features.

- Distill the built features into a doc with examples and roll back the code by git.

- Build a v2 based on the distillation.

- Rinse repeat, usually until v4 or v5, when i tear it all down and write it 99% by hand from the distilled documents.

Definitely a rocky road so far.


👤 gizmo
Sonnet 3.5 is better at respecting your code than 3.7.

👤 neuralkoi
Same here. I had an issue yesterday where it liberally deleted a chunk of code it must have thought was extraneous but at the same time introduced a huge privacy vulnerability.

If you use Cursor for personal projects, I recommend reviewing each change very, very carefully.


👤 muzani
Claude 3.7 feels overtuned. I asked it to write tests. It replicated my code into mocks and "monkey-patched" it to pass tests. Basically if it didn't pass tests, it will rewrite the mock to pass.

It seems that cursor-thinking will come up with 3 options and pick the dumbest one. Leading to much worse performance than non-thinking sometimes.

A big part of it seems to be increased focus on following instructions vs 3.5. If you don't tell it to not cheat, it cheats lol. Sometimes it's even aware of this, saying things like "I should be careful to not delete this" but deleting it is the fastest path to solving the question as asked, so it deletes.


👤 haffi112
It has happened to me on very large files and when you've had a long composer session. I usually check every file that is being modified for large removals because of this. It's a bit annoying, but something I can tolerate.

👤 MrMcCall
No. Never.

And neither has a drunken meth addict on an oz of shrooms and ketamine while snorting low-grade fentanyl.

Because I care about my craft.

> Any tips on fixing those?

Understand that no matter how fancy the guess-the-next-token machine is, it will NEVER replace the hard graft of logically deducing how a change is going to percolate througout your codebase.

The programmer's motto should resemble the old Porshe one:

  Logical reasoning: accept no substitute
When an engine can use my codebase to build up an internal logical structure of its cascading effects where potential changes to the code can be what-if'd as a kind of diff, then I will consider it to be worthy of evaluation.

Until then, I feel like an NBA player seeing that their opponent has chosen to only dribble with their ass.

I don't think you folks realize that you're the ones hallucinating. Predicting the next token is never going to be anywhere near 100% successful, especially for interesting projects.

Seriously, folks. I mean, week after week we keep seeing this shit show up here and y'all're like "You got any tips how I can keep smoking meth but not lose my last three teeth?"


👤 futhey
This isn't new or unique. The model seems to be too focused on the task at hand, "cleaning up" unrelated code.

I basically have to branch, commit every time it makes any progress at all, and squash later. There are built-in checkpoints that basically do this.

I actually run this side-by-side with my preferred IDE, and GitHub Desktop (to visualize the diffs). So, prompt -> Claude makes a change -> I view the diff -> I make some edits -> Commit -> back to Cursor.


👤 pawelduda
I often tell cursor to "Keep the changes to an absolute minimum, don't do anything out of scope". I find it helps prevent a sneaky component structure/CSS class change or something along these lines

👤 delduca
I do not trust AI on my editor, I prefer to use on a separate application.

👤 stuaxo
Do people use Cursor in containers or just set it going in their actual terminal ?

I can't imagine not using something like PodMan, I just haven't set it up, so haven't tried Cursor.


👤 electroly
Go back to Claude 3.5. There are still issues with 3.7 in Cursor.

👤 viraptor
This seems very language specific. I haven't seen it in ruby, but in python the autocompletion tries to delete a correct end of the function all the time.

👤 ph4evers
One of the devs just announced an upcoming fix for version 0.47 on Reddit. Seems like they have some problems with integrating Sonnet 3.7 in Cursor.

👤 4b11b4
I don't understand most of the comments on this thread. They must not know about the built in restore points, git commits and diff, system prompts, and cursor rules.

Yes, these models are merely approximations, but things aren't just blindly bad as it these comments make it seem.

Edit: Yes, Sonnet 3.7 is eager, but I'd have to assume is designed that way. Yes, sometimes Sonnet ignores my system prompt. Again, these things are merely approximations that map from tokens to tokens. They are not reasoning or intelligent.


👤 himeexcelanta
I was getting this with claude (sonnet) 3.7

Restarting the editor worked! Can also try restarting the computer.


👤 singularity2001
Not just working code also useful comments, but this behavior is not specific to cursor

👤 Jotalea
I don't know man, I'm busy learning how to use neovim.

👤 GardenLetter27
I wish it were easier to just send code to a chat and then get a diff back, and limit the files or lines that can be changed.

Too many of these tools seem to either give no diff, or make absolutely massive edits.


👤 pranav7
have experienced it a couple times. 3.7 seems to go on random tangents unrelated to the original ask.

👤 android521
i tried vibe coding and it was kind of working like magic unit it didn't. It took much longer to recover my working code. Now i have given up on vibe coding. AI is only used for small cope clearly defined tasks to speed things up.

👤 miwaniza
Just happened to me: Sonnet 3.7 was editing one file by my request. Then Cursor agent process was interrupted because file was edited ¯\_(ツ)_/¯. Happened multiple times, with 3.5 version too. No external changes were issued.