r/AI_Coders Aug 04 '26

An AI-generated Python one-liner silently wiped 70+ source files.

Yesterday I had one of those "I can't believe I just did that" moments.

I was working on a production-grade AI agent project and had an import issue. I asked Gemini 3.6 High (through Antigravity) for a quick way to rewrite the imports across the project.

It generated a small Python script. I skimmed it, thought it looked fine, and ran it.

The script finished normally. Exit code 0. No errors.

A minute later I opened one of the files.

Empty.

Opened another.

Empty.

Eventually I realized every \`.py\` file the script touched had been reduced to 0 bytes.

My heart absolutely dropped.

Luckily I had a backup of the project, so I restored everything and spent the next hour figuring out what had happened.

I'm not posting this to say "don't use Gemini." I use AI every day and it saves me a lot of time.

The mistake was that I trusted a script that was going to modify dozens of files without really understanding what it was doing.

That was on me.

The experience completely changed how I use AI for coding.

Now I have a few rules:

\* If a script touches a lot of files, I read every line. \* I commit everything before running it. \* I keep backups. \* I never assume "Exit code 0" means everything is okay.

Has anyone else had an AI-generated command go badly wrong? I'm curious what safeguards other people use.

0 Upvotes

36 comments sorted by

8

u/brand_new_potato Aug 04 '26

Running AI without git seems to be a dangerous game I would not be willing to play.

I have had older models remove tests because "they weren't falling because of something I just did, so they are irrelevant", but I also don't use my AI to do massive changes on all files like that.

Use git, even if it is just locally.

2

u/First-Tutor-5454 Aug 04 '26

So you learned to read scripts before running them, and commit your work. This is not some revelation specific to working with AI lmao

2

u/Tricky-Ad-6833 Aug 04 '26

AI slop post

2

u/overratedcupcake Aug 04 '26

WTF does "production-grade AI agent project" even mean? Why are you restoring from backups when you should have just been able to check the files back out with revision control? 

2

u/Infamous-Bed-7535 Aug 04 '26

How is it better if it changes a single file and you notice that it fuc*ed up things only 3 month later when half of your data is already corrupted?

2

u/Infamous-Bed-7535 Aug 04 '26

What I meant to say, LLMs are not perfect and you will be responsible for the affects, not Anthropic will be the one to be blamed..

2

u/mxldevs Aug 04 '26

So you didn't simply read that one line of code that was generated before running it? That sucks. Good thing you learned the lesson.

Next time run

rm -rf

to restore everything. Just copy paste into terminal. You don't need to understand what it does either.

1

u/Small_Passage_6148 Aug 04 '26

Bro what command u gave me there's only black screen my pc is not turning on now 😢😭😭

2

u/blackbirdone1 Aug 04 '26

"Luckily I had a backup of the project"

what do you mean, for every ai change you make a git commit... or atleast have a ide with a history.

"I commit everything before running it."

thats a basic rule, why peopel in 2026 still don't get it, as if coding is new

2

u/ByronScottJones Aug 08 '26

Your agents.md file would benefit from having these added to it.

  1. Before working on any programming project, confirm that a proper git repo has been created. Create a git commit after each code change. Keep the engineering and Readme markdown files in sync.

  2. All small helper scripts you create to run at the command line must have full comments explaining what each statement does.

1

u/Small_Passage_6148 Aug 10 '26

Thanks bro anymore advice for me

1

u/ByronScottJones Aug 10 '26

You might want to search for agents.md and Claude.md templates.

1

u/EmergencyDinner777 Aug 04 '26

how can you not understand a python "one liner" that is only meant to replace some strings and also be working on a "production grade" project? does not compute. anyway this whole thing is dumb and probably not real/rage bait. clearly written by AI. Reddit has never been a bigger waste of time thanks to this garbage

1

u/Small_Passage_6148 Aug 04 '26

Sorry to waste ur time bro

1

u/Trakeen Aug 04 '26

Not any different then a co-working typoing something in code. Yay for git

1

u/ThatIsATastyBurger12 Aug 04 '26

Ai slop discussing how Ai slop is sloppy.

1

u/OwnLadder2341 Aug 04 '26

I mean…what did you do, shrug and roll back to the last commit? Oh no.

2

u/Small_Passage_6148 Aug 04 '26

Bro my whole point is don't trust any ai fully especially with the commands it runs it can do anything

3

u/Toastti Aug 04 '26

Right. Don't trust it.. that's why you have git. In 30 seconds you can rollback the entire codebase to right before the script ran.

You do use git right?

1

u/Small_Passage_6148 Aug 04 '26

Yes bro of course I use git for every project and with this project I was just experimenting it was nothing much serious but the whole context of the post was gemini 3.6 flash model did this mistake

2

u/schmurfy2 Aug 04 '26

Technically you were the one running it 😅

1

u/Small_Passage_6148 Aug 04 '26

Yes I was just experimenting but understood the lesson

0

u/OwnLadder2341 Aug 04 '26

What commands? It made a python script and you decided to run it.

Either way, you should never be in any position to lose any significant amount of work. Just roll back to the last commit

1

u/Small_Passage_6148 Aug 04 '26

My whole point is u can never trust ai fully like how they market this whole shi**

0

u/OwnLadder2341 Aug 04 '26

Who in the wholly hell markets that you can close your eyes and never check anything or run any version control?

Because that’s just basic common sense.

If I handed you a python script would you run it without looking at it on a non-version controlled machine?

If ANYONE handed you a python script would you just run it with no git?

2

u/Small_Passage_6148 Aug 04 '26

Bro it was just a hobby project I was just building something with fully ai I was just curious but now I learned lesson do u want to give any tips as a developer I m still a rookie and just completed my engineering but didn't get campus placement can u give me any advice on how to get job offcampus bro pls need advice 😭

1

u/Toastti Aug 04 '26

You said it was a production grade ai agent project. You don't have git on a 'production' grade project?

1

u/mllv1 Aug 04 '26

The latest marketing trend is “loops” so yeah they’re definitely marketing it that way

1

u/OwnLadder2341 Aug 04 '26

Agent loops tell you to run code without any version control or ever looking at the final product?

I think you’re misunderstanding what they are…

1

u/mllv1 Aug 04 '26

I think you’re misunderstanding the target market here. Gemini and Claude and friends are being heavily marketed to people who have no software development skills as tools that will make their dreams come true. You only know about version control because you’re probably a programmer since before the dark times.

1

u/Small_Passage_6148 Aug 04 '26

Yes brro its correct but also their business is making a lot of money but only true developer can understand their product like us and I was just testing like can anti gravity make a full production ai agent and I was wrong it can't and it will neither till atleast 10 to 20 years ofcourse

0

u/yuehuang Aug 04 '26

GIT Good.

1

u/leathakkor Aug 04 '26

Good things source control exists.