In this case, using Git would have helped even if it was local-only.
What did the AI actually do? Because `rm -rf .` is not something git can help you with.
AFAICT, it only deleted the code using the library, not the whole repository.
It was a fake post anyway, but the instructions were to remove the output of that library and code using it, not delete everything on the computer or project.