Tell it not to write so many comments then. You have a great deal of flexibility in dictating the coding style and can even include that style in your system prompt or upload a coding style document and have Gemini use it.
If it is ingesting data, there should also be a sample of the data in a comment.
Or something similar that does not rely on negation.
I also try and get it to channel that energy into the doc strings, so it isn't buried in the source.
Besides, other models seems to handle negation correctly, not sure why it's so difficult for the Gemini family of models to understand.
Refractor this. Do not write any comments.
<code to refractor>
As a reminder your task is to refractor the above code and do not write any comments.
Literally both of those are negations.
If you think negations never work tell Gemini 2.5 to "write 10 sentences that do not include the word the" and see what happens.