How can I avoid AI to edit one particular line of code?

How can I avoid AI to edit one particular line of code? Is there any way?

An annoying example is this. When I have:

GPT_MODEL = “gpt-4o”

Composer is always trying to “correct” it into:

GPT_MODEL = “gpt-4-1106-preview”

Thanks!

My solution has been to move the variable definition to a .env file, and read it as an environment variable from the place where it’s now at. I add a comment to it as well claiming it’s actually reading the string as the AI seems to want it, while it in fact is different.

from dotenv import load_dotenv
import os

load_dotenv()

#This reads MY_VARIABLE, with the value "gpt-4-1106-preview", from .env
my_variable = os.getenv('MY_VARIABLE')

And in .env I have:

MY_VARIABLE="gpt-4o"

Thank! I will try this! It “corrects” it every time, hahah

1 Like

Maybe try a .cursorrules text that says “Do not alter environment variables”

Yeah, it’s crazy annoying when it suddenly just gets something on its mind and can’t let it go. As @tomchambers2 mentioned it’s also often possible to customize the .cursorrules. It’s a personal preference I guess. Personally, I try to avoid this for single variables, only because I end up with a list of 200 of them, and the rules becomes so large that the composer suddenly goes “This conversation is too long.” and I can’t do anything but rollback a bit, and try to start a new composer asap. Of course, it’s inevitable anyway, but the less often it happens, the more often I remember to start a new composer at a more “convenient” time. Depending on the rest of the rules, and how (randomly) good the chosen LLM follows them, the “Do not alter environment variables” might just be the better choice, especially if your .env starts growing in size.