Right now the hardest “command” to get ChatGPT to follow is something that should be trivial:
Do not change the code in this file.
No matter how clearly I say it, it keeps ignoring that and changing the code anyway.
I’ve tried things like:
“Do NOT modify any code in this file.”
“Treat this file as read-only. You can only analyze it, not edit it.”
“You are not allowed to change anything in this file. Only explain, comment, or propose separate patches.”
And yet, ChatGPT still:
Rewrites functions
Renames variables
“Cleans up” formatting
Refactors logic I explicitly told it to leave exactly as-is
I repeat the restriction multiple times, I clearly separate “this file is read-only” vs “you can propose new code in a separate snippet”, and it still just goes ahead and edits the original content as if my instructions don’t matter.
This is infuriating because:
I sometimes must keep the original file untouched for debugging, bisecting, or comparison.
I only want analysis or suggestions, not an auto-refactored version of my file.
I have to waste time diffing its output to make sure it didn’t silently change something I never asked it to touch.
At this point I’m honestly very frustrated. I don’t want “helpful creativity” here — I want it to strictly obey the “read-only” constraint.
My questions:
Has anyone found a reliable prompt pattern that actually forces ChatGPT to treat a file as read-only?
Is this a known limitation/bug of the current behavior?
Is there any way (settings, system prompts, tools, etc.) to harden this constraint so it physically cannot rewrite the original file and can only propose changes separately?
I’m not looking for “nicer code” or “refactors.” I just want one very simple thing:
When I say “do not modify this file,” it should actually respect that. Right now, it really doesn’t, and it’s driving me crazy.
First, be very careful when using ‘not’ in LLM prompts. Some models do not fully grasp the logic of ‘not’ and may simply ignore it, causing your instruction to shift from
‘Do not change the code in this file.’
to
‘Do change the code in this file.’
One useful feature available in some LLM tools is planning mode, which directs the LLM to generate a plan outlining the necessary steps instead of making changes directly.
I haven’t tested these suggestions with ChatGPT, as I no longer use it for coding. Instead, I use OpenAI Codex or Claude Code.
Thanks a lot for taking the time to read what I wrote so carefully and break it down for me—that really means a lot to me.
Your point about models sometimes ignoring “not” in prompts was especially helpful, and the example you gave made it very clear. I’ll definitely try rephrasing things and using a planning-style approach like you suggested.
So you have issues with GPT modifying code when you ask it not to do so.
Ok here is the things you need to know.
First you need to establish which model your using. This matters. Because each model weather it’s mini up to 5. 3 has different behaviors and different constraints. The system level restraints change accordingly as well per model and teir within the platform. Depending on teir and model and tool runtime that is configured at the time gives you behaviors and responses that determine final output Artifacts. You will have to map out the models yourself to identify their different behavior Divergences. There are to many for me to list here and that would be a research paper on its own. I am here to help you on the path to reduce drift and gain controlled workflow.
2. It helps to change your behavior settings for the platform. To get what you are asking for you have to work with the platform and its rules as well as what its system capabilities are. its not just the model, it is the system configuration that determines the models behaviors and your source limitations. Change the settings to less or no emojis. More headers and lists and more professional. Neutral or default on the enthusiasm. And more cynical behavior. This sets the system to configured the models into a more analytical format. It also helps to put invariants in the additional behavioral section. If you would like to know what invariants to use i can give some of them to you but again that is a research paper in itself and the best way to give you this is to teach you how to find them yourself.
3. The other responses you received are all correct. The thing is language really does matter. These are language models that have capabilities added to them through their training and weights. But their base function is language. It helps to understand how language works and the atomic primitives. There are books on this but once you understand this it opens up language models to another level. this is because language is the base set for everything and the atomic principals of language is reflected upon the other aspects of capabilities. To keep it simple. So wording and structure matters. Also what is not said matters as well. Remember code is just another language. The translation betweenthe. Two is what is being interpreted and also gaining a loss through the function of translation. And that brings us to the next section
4. Language models want structure. They are rule oriented. Provide a structured rule instead of a prompt and you will have better results. I have a whole system I developed that promotes structured output Artifacts and really helps. But again this is long and dense to explain here and is another research paper on its own. It can be taught so the elements to learn it are in this message.
5. After you have your settings set and configuration in place know what model your going to interact with and how long that model is available to work with the tooling as well as how to interact with the models. The limits. The configuration of the system and the models capabilities you will have a drastically different experience and less drift or mistakes. When you open a new conversation simply ask for an audit or review. GPT is the best at audits and keeps it high level professional and grounded. If you need second and third order fixes just ask. If you need the code to fix it just ask. Be careful with mini 5.0 though. It will make you go through increments and Even if you ask for\nThe final complete layer in whatever form you ask it , it will still have more layers in increments. Best thing to do with mini is ask it What all the layers and what all the increments are first and it will list it. At that point You won’t have to do the increments for all those layers and you can ask it too give you the fixes or give you the code to fix it at that point. And it will. You can ask it for the test. The whole test harness and whatever you want , and it won’t change your code. Just don’t have it write code for you in long formats , without making sure it is put in the container itself and has a mode set with clear instructions.
This is a strong and well-articulated breakdown, appreciate you sharing it.
The points around model differences and system-level configuration are especially important. It’s easy to assume behavior is tied only to the model, but in practice the surrounding setup, constraints, and interaction context clearly play a major role.
Framing interactions with explicit constraints and defined behavior is a much more reliable way to reduce drift, particularly in cases like preventing unintended code modification.
Subtle differences in wording, including what’s left unsaid can significantly influence outcomes. Thinking of code as another form of language, and accounting for translation loss between intent and output, is a useful lens.